"Attempt to reference field of non-structure array" when reading in from a text file using spm_read_vols

3 次查看(过去 30 天)
I have a list of nifti files that I want to read in from a text file rather than inputting every nifti in the script. I'm trying to get the first timepoint for each nifti file. When I try this command, where '10niftis.txt' is my list of niftis,
data = spm_read_vols('10niftis.txt, 1');
I get the error message "Attempt to reference field of non-structure array".
Any ideas? I'm not sure if I can use textread because I only want the first timepoint within each file.

采纳的回答

Walter Roberson
Walter Roberson 2015-11-25
I do not know about getting the first time point of each file, but you are using spm_read_vols incorrectly. It should be something like:
fid = fopen('10niftis.txt', 'rt');
K = 0;
while true
this_nifti = fgetl(fid);
if ~ischar(this_nifti); break; end %end of file detected
K = K + 1;
V{K} = spm_vol(this_nifti);
data{K} = spm_read_vols(V{K});
end
fclose(fid);
Maybe you can use
data{K} = spm_read_vols(V{K}(1));
to read only the first time-point -- I have not researched the representation of spm volumes.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Neuroimaging 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by