0001 function volidx = get_middle_vol(fname, logfid)
0002
0003
0004
0005
0006
0007
0008
0009
0010 if ~exist(fname,'file') && ~exist([fname '.nii'],'file') ...
0011 && ~exist([fname '.nii.gz'],'file')
0012 error('get_middle_vol:Could not find file: %s', fname)
0013 end
0014
0015 try logfid;
0016 catch logfid = 1;
0017 end
0018
0019 fsl_str = sprintf('fslnvols %s', fname);
0020 fprintf(logfid,'%s\n', fsl_str);
0021 [status, volidx] = unix(fsl_str);
0022 volidx = str2num(volidx);
0023 volidx = fix(volidx/2);
0024
0025 if volidx == 0
0026 volidx = 1;
0027 end