Loop in SPM batch not working
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
For some reason when I try passing the subjects into the subjMP path, the subject isn't inserted into the path. Is there another way I should script it to get into each subjects directory? When I run the code line by line this is the output I get for the subjects:
'ifs/loni/faculty/mbraskie/HABLE/MPRAGE//baseline/*_MPRAGE.nii.gz'
%% MATLAB AND SPM12 BATCH SCRIPTING:
% Processing segmentation single-subject T1 for PET roi analysis
% Testing
SPM12='/usr/local/spm12';
AAL3='/ifs/loni/faculty/mbraskie/HABLE/PET/spmtest/AAL3';
MPRAGE='/ifs/loni/faculty/mbraskie/HABLE/MPRAGE';
addpath (genpath(SPM12));
addpath (genpath(AAL3));
addpath (genpath(MPRAGE));
targets = [8030 8483];
for subj = targets
subjMP=fullfile(MPRAGE,subj,'baseline','*_MPRAGE.nii.gz')
cd (subjMP); mkdir spm; cd spm;
spm;
matlabbatch{1}.spm.spatial.preproc.channel.vols = {'${subjMP},1'};
matlabbatch{1}.spm.spatial.preproc.channel.biasreg = 0.001;
matlabbatch{1}.spm.spatial.preproc.channel.biasfwhm = 60;
matlabbatch{1}.spm.spatial.preproc.channel.write = [0 0];
matlabbatch{1}.spm.spatial.preproc.tissue(1).tpm = {'/usr/local/spm12/tpm/TPM.nii,1'};
matlabbatch{1}.spm.spatial.preproc.tissue(1).ngaus = 1;
matlabbatch{1}.spm.spatial.preproc.tissue(1).native = [1 0];
matlabbatch{1}.spm.spatial.preproc.tissue(1).warped = [0 0];
matlabbatch{1}.spm.spatial.preproc.tissue(2).tpm = {'/usr/local/spm12/tpm/TPM.nii,2'};
matlabbatch{1}.spm.spatial.preproc.tissue(2).ngaus = 1;
matlabbatch{1}.spm.spatial.preproc.tissue(2).native = [1 0];
matlabbatch{1}.spm.spatial.preproc.tissue(2).warped = [0 0];
matlabbatch{1}.spm.spatial.preproc.tissue(3).tpm = {'/usr/local/spm12/tpm/TPM.nii,3'};
matlabbatch{1}.spm.spatial.preproc.tissue(3).ngaus = 2;
matlabbatch{1}.spm.spatial.preproc.tissue(3).native = [1 0];
matlabbatch{1}.spm.spatial.preproc.tissue(3).warped = [0 0];
matlabbatch{1}.spm.spatial.preproc.tissue(4).tpm = {'/usr/local/spm12/tpm/TPM.nii,4'};
matlabbatch{1}.spm.spatial.preproc.tissue(4).ngaus = 3;
matlabbatch{1}.spm.spatial.preproc.tissue(4).native = [1 0];
matlabbatch{1}.spm.spatial.preproc.tissue(4).warped = [0 0];
matlabbatch{1}.spm.spatial.preproc.tissue(5).tpm = {'/usr/local/spm12/tpm/TPM.nii,5'};
matlabbatch{1}.spm.spatial.preproc.tissue(5).ngaus = 4;
matlabbatch{1}.spm.spatial.preproc.tissue(5).native = [1 0];
matlabbatch{1}.spm.spatial.preproc.tissue(5).warped = [0 0];
matlabbatch{1}.spm.spatial.preproc.tissue(6).tpm = {'/usr/local/spm12/tpm/TPM.nii,6'};
matlabbatch{1}.spm.spatial.preproc.tissue(6).ngaus = 2;
matlabbatch{1}.spm.spatial.preproc.tissue(6).native = [0 0];
matlabbatch{1}.spm.spatial.preproc.tissue(6).warped = [0 0];
matlabbatch{1}.spm.spatial.preproc.warp.mrf = 1;
matlabbatch{1}.spm.spatial.preproc.warp.cleanup = 1;
matlabbatch{1}.spm.spatial.preproc.warp.reg = [0 0.001 0.5 0.05 0.2];
matlabbatch{1}.spm.spatial.preproc.warp.affreg = 'mni';
matlabbatch{1}.spm.spatial.preproc.warp.fwhm = 0;
matlabbatch{1}.spm.spatial.preproc.warp.samp = 3;
matlabbatch{1}.spm.spatial.preproc.warp.write = [1 1];
end
0 Kommentare
Antworten (1)
Cris LaPierre
am 18 Mär. 2020
Bearbeitet: Cris LaPierre
am 18 Mär. 2020
The issue I see is that you are trying to combine text and numbers using a function that is expecting all text. As you've observerd, that doesn't work:
'\ifs\loni\faculty\mbraskie\HABLE\MPRAGE\\baseline\*_MPRAGE.nii.gz'
Try first converting subj to text using num2str.
subjMP=fullfile(MPRAGE,num2str(subj),'baseline','*_MPRAGE.nii.gz')
'\ifs\loni\faculty\mbraskie\HABLE\MPRAGE\8030\baseline\*_MPRAGE.nii.gz'
0 Kommentare
Siehe auch
Kategorien
Mehr zu Neuroimaging finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!