SPM batch is not working but path is right..

5 Ansichten (letzte 30 Tage)
Chang-Soo Yun
Chang-Soo Yun am 1 Nov. 2021
Beantwortet: yanqi liu am 2 Nov. 2021
path_name = 'C:\Users\Chang-Soo\Desktop\ADNI_CN_UPLOAD\'
cd(path_name);
lists_norm = dir(pwd); % Here I can see the folder list which contain .nii files
a = length(lists_norm);
for bb = 3:a
file_name_path = strcat(path_name,lists_norm(bb).name); %Here is the problem.
cd(file_name_path) % Go in to the specific folder which contain .nii files
lists_again = dir(pwd);
folder_value = size(lists_again,1);
for aa = 3:folder_value
aaa = aa-2;
matlabbatch{1}.spm.spatial.normalise.estwrite.subj(aaa).vol = {strcat(file_name_path,'\',lists_again(aa).name)};
matlabbatch{1}.spm.spatial.normalise.estwrite.subj(aaa).resample = {strcat(file_name_path,'\',lists_again(aa).name)};
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.biasreg = 0.0001;
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.biasfwhm = 60;
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.tpm = {'C:\Users\Chang-Soo\Documents\MATLAB\spm12\tpm\TPM.nii'};
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.affreg = 'mni';
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.reg = [0 0.001 0.5 0.05 0.2];
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.fwhm = 0;
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.samp = 3;
matlabbatch{1}.spm.spatial.normalise.estwrite.woptions.bb = [-78 -112 -70
78 76 85];
matlabbatch{1}.spm.spatial.normalise.estwrite.woptions.vox = [2 2 2];
matlabbatch{1}.spm.spatial.normalise.estwrite.woptions.interp = 4;
matlabbatch{1}.spm.spatial.normalise.estwrite.woptions.prefix = 'normalized_';
end
cd ..
end
This code
file_name_path = strcat(path_name,lists_norm(bb).name); %Here is the problem.
is the problem.
When I put a specific value instead bb for example...
file_name_path = strcat(path_name,lists_norm(3).name);
It works but I input the character its not working....
I don't know what exact the problem...
Here is the error when I use a spm batch script

Antworten (1)

yanqi liu
yanqi liu am 2 Nov. 2021
clc; clear all; close all;
path_name = 'C:\Users\Chang-Soo\Desktop\ADNI_CN_UPLOAD\'
cd(path_name);
lists_norm = dir(pwd); % Here I can see the folder list which contain .nii files
a = length(lists_norm);
for bb = 1:a
if isequal(lists_norm(bb).name, '.') || isequal(lists_norm(bb).name, '..') || lists_norm(bb).isdir == 0
continue;
end
file_name_path = fullfile(path_name,lists_norm(bb).name);
cd(file_name_path) % Go in to the specific folder which contain .nii files
lists_again = dir(pwd);
folder_value = size(lists_again,1);
for aa = 3:folder_value
aaa = aa-2;
matlabbatch{1}.spm.spatial.normalise.estwrite.subj(aaa).vol = {strcat(file_name_path,'\',lists_again(aa).name)};
matlabbatch{1}.spm.spatial.normalise.estwrite.subj(aaa).resample = {strcat(file_name_path,'\',lists_again(aa).name)};
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.biasreg = 0.0001;
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.biasfwhm = 60;
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.tpm = {'C:\Users\Chang-Soo\Documents\MATLAB\spm12\tpm\TPM.nii'};
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.affreg = 'mni';
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.reg = [0 0.001 0.5 0.05 0.2];
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.fwhm = 0;
matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.samp = 3;
matlabbatch{1}.spm.spatial.normalise.estwrite.woptions.bb = [-78 -112 -70
78 76 85];
matlabbatch{1}.spm.spatial.normalise.estwrite.woptions.vox = [2 2 2];
matlabbatch{1}.spm.spatial.normalise.estwrite.woptions.interp = 4;
matlabbatch{1}.spm.spatial.normalise.estwrite.woptions.prefix = 'normalized_';
end
cd ..
end

Kategorien

Mehr zu Image Processing Toolbox 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!

Translated by