help > RE: Help with Batch scripting using 3d nii files
Jul 27, 2012  03:07 AM | Alfonso Nieto-Castanon - Boston University
RE: Help with Batch scripting using 3d nii files
Hi Mac

No problem, something along these lines should work:

nsubjects=175;
SubjectFolder=arrayfun(@(x)['/data/patients/x',num2str(x,'%03d')],1:nsubjects,'uni',0);
SessionSubFolder={'functional'};
StructuralFolder='structural';
for nsub=1:numel(SubjectFolder)
    for nses=1:numel(SessionSubFolder)
        files=conn_dir(fullfile(SubjectFolder{nsub},SessionSubFolder{nses},'vol*.img'));
        batch.New.functionals{nsub}{nses}=files;
        fprintf('Subject %d, Session %d: %d functional files in %s\n',nsub,nses,size(files,1),fullfile(SubjectFolder{nsub},SessionSubFolder{nses}));
    end
    files=conn_dir(fullfile(SubjectFolder{nsub},StructuralFolder,'anat*.img'));
    if size(files,1)~=1, error('no anatomical file found'); end
    batch.New.structurals{nsub}=files;
end
(please change the reference to 'anat*.img' to something appropriate for the filename of your structural volumes)
Hope this helps

Best
Alfonso


Originally posted by Mac Shine:
Hi Alfredo

That worked perfectly for the functional scans. Is there a similar code that would work for the structural scans? When I try what I think would work, MATLAB just sighs and gives up!

Mac

Threaded View

TitleAuthorDate
Mac Shine Jul 24, 2012
Alfonso Nieto-Castanon Jul 25, 2012
Mac Shine Jul 25, 2012
Alfonso Nieto-Castanon Jul 25, 2012
Mac Shine Jul 26, 2012
RE: Help with Batch scripting using 3d nii files
Alfonso Nieto-Castanon Jul 27, 2012