Dear SPM experts,
I have some problem selecting multiple nifti images in Matlab loop. Could you help me to find where is the problem?
when my code is as follows:
if preprocess == 1
disp('------Preprocessing started------');
for subj = subjList
disp(strcat('Subject: ',subj));
clear matlabbatch;
cd(dataDir);
cd(char(strcat(dataDir,subj)));
files = {};
funFiles = {};
filename = {};
func = {};
for i = 1: length(runList)
files{i} = char(strcat(dataDir,subj,'/',runList{i}));
filename{i} = dir(fullfile(files{i}, '*.nii'));
funFiles{i} = strcat(filename{i}.folder,'/',filename{i}.name);
%read multiple nii files
func{i} = spm_select('expand',funFiles{i});
func{i} = cellstr(func{i}(1:254,:));
end;
funFiles = funFiles';
func = func';
preprocessing_job(funFiles);
end;
disp('------Preprocessing ended------');
end;
When the scripts run before spm_select sentences, all are good. However, when fully run this part of scripts, the following errors come out:
error using read_hdr (line 36)
Error reading header file "/".
error nifti (line 26)
vol = read_hdr(fname);
error spm_select>spm_select_get_nbframes (line 268)
N = nifti(file);
error spm_select>spm_select_expand (line 254)
n = spm_select_get_nbframes(ifiles{i});
error spm_select (line 130)
varargout{1} = spm_select_expand(varargin{2});
error main_analysis_script (line 40)
func{i} = spm_select('expand',funFiles{i});
I want to know the reason of first error about 'read_hdr'. Is there any problem with the header file? The functional file is in 4D nifti format
Wait for your reply!
Regards,
Feng
|