"Attempt to reference field of non-structure array" when reading in from a text file using spm_read_vols
2 ビュー (過去 30 日間)
古いコメントを表示
Charlotte Chaze
2015 年 11 月 24 日
回答済み: Walter Roberson
2015 年 11 月 25 日
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.
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Neuroimaging についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!