Dear Jane, there are several ways to do this (it also depends on which version of SPM you are using): * create a new 4D file without the dummy scans and proceed as normal: SPM > Util > 3D to 4D File Conversion See http://en.wikibooks.org/wiki/SPM/Working_with_4D_data#Creating_4D_NIfTI_files_in_SPM * use the dedicated batch module: SPM > Util > Expand image frames * use spm_select('ExtFPList',...) where you can specify your frames of interest: spm_select('ExtFPList',SCAN_dir,'^SCAN\.nii$',6:180) * use spm_select('expand',fullfile(SCAN_dir,'SCAN.nii')) in SPM12 to get the entire list of 3D scans and then select a subset tmp = spm_select('expand',fullfile(SCAN_dir,'SCAN.nii')); tmp = cellstr(tmp(6:180,:)); Best wishes, Guillaume. On 06/10/14 09:03, Jane Garrison wrote: > I have a relatively large number of 4D nifti files that I need to > manipulate. The first 5 volumes of each file are dummy scans which need > to be discarded for the analysis. > > I am reading the volume information using spm_vol() and have determined > the number of volumes in each scan. I now need to pass a subset of the > volumes to various SPM functions for analysis. I am struggling to find > the correct syntax and would appreciate some assistance. > > Suppose the scan in question is called SCAN.nii, it resides in SCAN_dir, > and the number of volumes has been determined to be 180. I am trying to > run code similar to the following example (which is failing): > > tmp = strcat(spm_select('FPList', SCAN_dir,SCAN.nii),',6:180)); > matlabbatch{1}.spm.spatial.realignunwarp.data(1).scans = cellstr(tmp); > > Please could someone offer some advice with the correct syntax here. > > Thanks so much > Jane. -- Guillaume Flandin, PhD Wellcome Trust Centre for Neuroimaging University College London 12 Queen Square London WC1N 3BG