You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: icatb_selRefFunc.m
    path of file: ./repos/gift/GroupICAT/icatb
    
    the code of the file until where you have to start completion: function [refAppdata] = icatb_selRefFunc(varargin)
% Select the regressors based on the given information
% case 1: When the regressor Names are given and Indices are not given
% case 2: When the regressor Nmes and Indices are given
%
% Input:
%
% Output:
% needed fields:
% selected timecourse
% selectedRegressorNames
% selectedIndices (actual)
% OriginalIndices
% OriginalRegressorNames

% defaults:
typeSelection = 'single';
helpDetails.str = sprintf(['Click on the left listbox and the corresponding reference functions will be displayed at', ...
    ' the bottom. The sel
    
function okCallback(handleObj, evd, handles)

% get the selected reference functions and delete the current figure

try
    % get the userdata
    refAppData = get(handleObj, 'userdata');

    subListH = findobj(handles, 'tag', 'subjectListbox'); % subject listbox

    spmAppData = get(subListH, 'userdata'); % listbox user data

    maxEntries = get(findobj(handles, 'tag', 'referenceListbox'), 'max');

    subListStrings = get(subListH, 'string'); % get the strings of the subject listbox

    subjectTextH = findobj(handles, 'tag', 'subject_text'); % get the subject text

    % check if any of the selected model time courses are not selected
    for ii = 1:size(refAppData, 2)
        if isempty(refAppData(ii).name)
            error(['Reference Functions are not selected for data set ', subListStrings(ii, :)]);
        end