Matlab/SPM Batch Script Help
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Walter Roberson
el 22 de Jun. de 2012
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!