Dear Fred,
your script looks fine (could be simplified though, see 'help cellstr').
However, with SPM8, for such applications, you don't really need to
write a MATLAB script by yourself, see this chapter from the SPM manual:
http://www.fil.ion.ucl.ac.uk/spm/doc/manual.pdf#Chap:batch_interface
especially the "Advanced features" section.
Best regards,
Guillaume.
Fred Sanders wrote:
> Hi All,
>
> I have limited knowledge of writing MATLAB script but I have been
> working on a script for batching my DICOM to NIFTI function.
> Below is what I have come up with:
>
>
> DICOM_dir = 'DIRECTORY OF INTEREST';
> P_dicom = spm_select('FPList',DICOM_dir, '^i.*'); %%% modify as needed
> clear P_dicom_Cell
> for k = 1:size (P_dicom,1)
> P_dicom_Cell{k} = deblank(P_dicom(k,:))
> end
> matlabbatch{1}.spm.util.dicom.data = P_dicom_Cell;
> matlabbatch{1}.spm.util.dicom.root = 'flat';
> matlabbatch{1}.spm.util.dicom.outdir = {'DIRECTORY OF INTEREST'}; %%%
> modify as needed
> matlabbatch{1}.spm.util.dicom.convopts.format = 'img';
> matlabbatch{1}.spm.util.dicom.convopts.icedims = 0;
> spm_jobman('run', matlabbatch);
>
>
>
> To then add more runs, can I just add the following???
>
> DICOM_dir = 'DIRECTORY OF INTEREST';
> P_dicom = spm_select('FPList', DICOM_dir, '^i.*'); %%% modify as needed
> clear P_dicom_Cell
> for k = 1:size (P_dicom,1)
> P_dicom_Cell{k} = deblank(P_dicom(k,:))
> end
> matlabbatch{2}.spm.util.dicom.data = P_dicom_Cell;
> matlabbatch{2}.spm.util.dicom.root = 'flat';
> matlabbatch{2}.spm.util.dicom.outdir = {'DIRECTORY OF INTEREST\'}; %%%
> modify as needed
> matlabbatch{2}.spm.util.dicom.convopts.format = 'img';
> matlabbatch{2}.spm.util.dicom.convopts.icedims = 0;
> spm_jobman('run', matlabbatch);
>
>
>
> THANKS!!!!
>
> Fred.
>
>
--
Guillaume Flandin, PhD
Wellcome Trust Centre for Neuroimaging
University College London
12 Queen Square
London WC1N 3BG
|