0001 function infiles=get_set_infiles(gui_infiles_or_tmplt,sub_ids)
0002
0003
0004
0005
0006
0007
0008 if strcmpi(gui_infiles_or_tmplt,'GUI'),
0009 loading=1;
0010 infiles=[];
0011 while loading,
0012 [neofname, inpath]=uigetfile({'*.set','*.set files'; ...
0013 '*clean.set','*clean.set files'; ...
0014 '*noartIC.set','*noartIC.set files'; ...
0015 '*.*','All Files (*.*)'},'EEGLAB set Files to Import','MultiSelect','on');
0016 if ischar(neofname),
0017 clear infname;
0018 infname{1}=neofname;
0019 else
0020 infname=neofname;
0021 end
0022 if ~inpath,
0023 if isempty(infiles),
0024 error('File selection cancelled. Aborting processing.\n');
0025 else
0026 loading=0;
0027 end
0028 else
0029 if isempty(infiles),
0030 infiles=cell(1,length(infname));
0031 for a=1:length(infname),
0032 infiles{a}=[inpath infname{a}];
0033 end
0034 else
0035 n_files=length(infiles);
0036 ct=0;
0037 for a=(n_files+1):(n_files+length(infname)),
0038 ct=ct+1;
0039 infiles{a}=[inpath infname{ct}];
0040 end
0041 end
0042
0043 resp=questdlg('Do you want to load more files?',...
0044 'OUTPUT','Yes','No','Yes');
0045 if strcmpi(resp,'No'),
0046 loading=0;
0047 end
0048 end
0049 end
0050 elseif iscell(gui_infiles_or_tmplt)
0051 infiles=gui_infiles_or_tmplt;
0052 else
0053 if isempty(sub_ids)
0054 error('If gui_infiles_or_tmplt is a string filename template, you must specify the participant numbers with the argument ''sub_ids''.');
0055 elseif ~ismember('#',gui_infiles_or_tmplt),
0056 error('The filename template %s needs to contain a # to indicate where the participant numbers go (e.g., odbl#.nrm).', ...
0057 gui_infiles_or_tmplt);
0058 else
0059 lb_id=find(gui_infiles_or_tmplt=='#');
0060 prefix=gui_infiles_or_tmplt(1:(lb_id(1)-1));
0061 postfix=gui_infiles_or_tmplt((lb_id(1)+1):end);
0062 n_subs=length(sub_ids);
0063 infiles=cell(1,n_subs);
0064 for s=1:n_subs,
0065 no_pad=[prefix num2str(sub_ids(s)) postfix];
0066 if sub_ids(s)<10,
0067 padded=[prefix num2str(sub_ids(s),'%.2d') postfix];
0068 if ismac || isunix
0069
0070 [sP wP]=unix(['ls ' padded]);
0071 [sNP wNP]=unix(['ls ' no_pad]);
0072 if ~sP
0073 if ~sNP,
0074 error('You have a file named %s and one named %s. I don''t know which one to load!\n', ...
0075 padded,no_pad);
0076 else
0077 infiles{s}=padded;
0078 end
0079 else
0080 infiles{s}=no_pad;
0081 end
0082 else
0083
0084 infiles{s}=no_pad;
0085 end
0086 else
0087 infiles{s}=no_pad;
0088 end
0089 end
0090 end
0091 end