SPM batch is not working but path is right..

5 ビュー (過去 30 日間)
Chang-Soo Yun
Chang-Soo Yun 2021 年 11 月 1 日
回答済み: yanqi liu 2021 年 11 月 2 日
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

回答 (1 件)

yanqi liu
yanqi liu 2021 年 11 月 2 日
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

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by