SPM batch is not working but path is right..
    조회 수: 5 (최근 30일)
  
       이전 댓글 표시
    
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
댓글 수: 0
답변 (1개)
  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
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!