mne_setup_toolbox MEG_DIR='/space/ventzl/1/users/MEG_DIR/'; % sub={'001' '002' '004' '005' '006' '007' '008' '009' '010' '011' '012' '013' '014' '015' '016' '017' '019' '020' '024'}; % analysis='direction_gradonly_resplock'; % hemi={'lh' 'rh'}; % cond={'Pright' 'Pleft' 'Aright' 'Aleft'}; % suffix='-Avg7-integ20-spm'; sub={'001' '002' '004' '005' '006' '007' '008' '009' '010' '011' '012' '013' '014' '015' '016' '017' '019' '020' '024'}; analysis='pro_anti_gradonly'; hemi={'lh' 'rh'}; cond={'Pro' 'Anti'}; suffix='-integ10-meg_normals'; fprintf('\n'); for h=1:length(hemi) for c=1:length(cond) data=[]; fprintf('%s(%s):\n',cond{c},hemi{h}); for s=1:length(sub) cmd=sprintf('fin=''%s/mano%s/%s/stc/mano%s_%s%s-%s.stc'';',MEG_DIR,sub{s},analysis,sub{s},cond{c},suffix,hemi{h}); eval(cmd); stc=mne_read_stc_file(fin); data=cat(3,data,stc.data); data=sum(data,3); fprintf('mano%s\n',sub{s}); end stc_out=stc; % stc_out.data=mean(data,3); % runs out of memory stc_out.data=data./s; cmd=sprintf('fout=''%s/meg_normals/%s/stc/%s%s-%s.stc'';',MEG_DIR,analysis,cond{c},suffix,hemi{h}); eval(cmd); fprintf('\nSaving to: %s\n',fout); mne_write_stc_file(fout, stc_out) fprintf('Done!\n\n'); end end