Matlab/SPM Batch Script Help
19 ビュー (過去 30 日間)
古いコメントを表示
Hi guys, I'm new to Matlab and SPM and would like some help coming up with or editing a short script to shorten the input field for some fMRI images so that batch processing across multiple subjects could be done easily.
matlabbatch{1}.spm.temporal.st.scans = {
{
'C:\face_rep\rawepi\RawEPI\rsM03953_0005_0006.img,1'
'C:\face_rep\rawepi\RawEPI\rsM03953_0005_0007.img,1'
'C:\face_rep\rawepi\RawEPI\rsM03953_0005_0008.img,1'
'C:\face_rep\rawepi\RawEPI\rsM03953_0005_0009.img,1'
.
.
.
'C:\face_rep\rawepi\RawEPI\rsM03953_0005_0300.img,1'
}
}';
matlabbatch{1}.spm.temporal.st.nslices = 24;
An example I was previously given was the use of a for loop which allows the files for each subject to be processed with a simple change of the directories and works well.
cd(imgdir);
imgfiles = ls('r*.img');
for spmimages = 1:size(imgfiles, 1)
matlabbatch{1}.spm.temporal.st.scans(spmimages,:) = {['C:\face_rep\rawepi\RawEPI\' imgfiles(spmimages,:)]};
end
However, when I try to do up the loop from scratch, I am a little unsure about how to define the 'spmimages' and 'matlabbatch' variables from scratch as I get the "Error using ==> horzcat" message so any help there would be greatly appreciated. Thanks!
0 件のコメント
採用された回答
Walter Roberson
2012 年 6 月 22 日
cd(imgdir);
imgfiles = dir('r*.img');
for spmimages = 1:size(imgfiles, 1)
matlabbatch{1}.spm.temporal.st.scans{spmimages} = fullfile(imgdir, imgfiles(spmimages).name);
end
Or more simply,
cd(imgdir);
imgfiles = dir('r*.img');
matlabbatch{1}.spm.temporal.st.scans = strcat(imgdir, '\', { imgfiles.name });
The above assume you are just constructing the name, not loading data from them.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!