Hi all,
this is my first post to the list, and I am an absolute beginner as far
as SPM is concerned, so please excuse my trivial question.
I have some brain MR images, and a template with which I wish to
coregistrate the images.
I am writing a matlab function: the input parameters are:
- the template file name (it is a double-resolution, half voxel-size
version of the SPM T1 template, nii format);
- the moving-image file name
The function should create a new nii file containing the coregistered
image.
Before trying to write this script, I already used SPM from its GUI, and
I could with no problem insert the template and the input file name into
the corresponding user fields of the SPM (fmri) form called "Coreg:
Estimate and Reslice", obtaining the registered image as a file with the
same name as my moving image, with a heading 'r' (something like
'rIm005.nii').
This is now the code I am using (copied from somewhere, without fully
understanding all the details):
function coregister(filename)
VG = spm_vol('T1_templateSPM2.nii');
VF = spm_vol(filename);
x = spm_coreg(VG,VF);
spm_reslice([VG,VF],struct('which',1));
I am somewhat confused: it looks like the part that is building the
registered-image file is the second one (spm_reslice), because the
spm_coreg does not create any file, and I see no communication between
coreg and reslice.
Moreover, this script also creates meanT1_templateSPM2.nii, which I did
not see when using the GUI.
Can someone please explain what is going up?
Where can I find examples of SPM scripting, with some comments?
When this peace of code works, and if nobody complains for the low level
of this question, I'll be back with something about spm_segment syntax...
Thanks
Giorgio
|