Hello John!
Thank you very much for your quick and helpful reply. As you guessed, all fields except four ('cost_fun', 'sep', 'tol' and 'fwhm'), were stripped by matlabbatch (e.g. 'graphics' and 'params' were stripped). Since I couldn't find were that 'stripping' was executed in the matlabbatch source code I did a 'quick and dirty' modification in the spm_coreg.m. For reference I give my solution (probably far from the optimal one) here:
When calling spm_jobman, I assume that a user-set 'eoptions.sep' has to be a two element vector. I then 'sneak' in the command to do a 12-parameter affine registration by adding an arbitrary value to the 'sep' vector, e.g.:
...eoptions.sep = [4 2 0];
In spm_coreg I added the following code snippet right after all flags has been set (i.e., after the 'if nargin < 3' statement):
% edited by AA to allow the use of a 12 degree affine coregistration % when running batch with spm_jobman/matlabbatch if (length(flags.sep)>2)
flags.sep = flags.sep(1:2)
flags.params = [0 0 0 0 0 0 1 1 1 0 0 0] end
Kind regards,
André
-----Ursprungligt meddelande-----
Frĺn: John Ashburner [mailto:[log in to unmask]]
Skickat: den 11 oktober 2012 19:07
Till: André Ahlgren
Kopia: [log in to unmask]
Ämne: Re: [SPM] 12 parameter affine coregistration
Spatial normalisation usually begins with a 12-parameter affine registration, but this is usually using a mean squared difference objective function. For aligning across modality, you'll need to use a different approach because the image contrast in a perfusion map is very different to that of an MPRAGE.
There is a hidden option for the Coregistration, which allows it to use 12 parameters. I generally leave the option hidden because it is not so stable. The modified code snippet below may work (depending whether or not matlabbatch strips off any fields it does not recognise)...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% using standard spm coreg settings
matlabbatch{1}.spm.spatial.coreg.estwrite.ref = {files.coreg_fix}; matlabbatch{1}.spm.spatial.coreg.estwrite.source = {files.coreg_mov}; matlabbatch{1}.spm.spatial.coreg.estwrite.other = {''}; matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.cost_fun = 'nmi';
% Supply 12 starting estimate parameters matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.params = ...
[0 0 0 0 0 0 1 1 1 0 0 0];
matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.sep = [4 2]; matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.tol =...
[0.02 0.02 0.02 0.001 0.001 0.001 0.01 0.01 0.01 0.001 0.001 0.001]; matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.fwhm = [7 7]; matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.graphics = 0; matlabbatch{1}.spm.spatial.coreg.estwrite.roptions.interp = 1; matlabbatch{1}.spm.spatial.coreg.estwrite.roptions.wrap = [0 0 0]; matlabbatch{1}.spm.spatial.coreg.estwrite.roptions.mask = 1; matlabbatch{1}.spm.spatial.coreg.estwrite.roptions.prefix = coreg_file_prefix; inputs = cell(0,1); evalc(['spm_jobman(' '''' 'serial' '''' ',matlabbatch,' '''' ''''
',inputs{:})']);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
If it doesn't help, you may need to do a bit of extra coding to call spm_coreg directly (see config/spm_run_coreg.m for syntax etc) with the eoptions.params field.
Best regards,
-John
On 10 October 2012 15:04, André Ahlgren <[log in to unmask]> wrote:
> Hi!
>
>
>
> I am currently using SPM8 (spm8_r4290) for a coregistration using the
> spm_jobman-function. Since I coregister a MR-perfusion map to a MPRAGE
> (standard nii-files), I feel that the 6 parameter linear
> coregistration does not suffice, and would therefore want to perform a
> 12 parameter (affine) registration. I have seen references to this in
> some various literature regarding SPM (I know that the first part of
> the normalization consists of a 12-degree affine coregistration), but
> have not been able to execute one myself. Can I somehow do it from a matlab-batch-script?
>
>
>
> Here is the code (sorry for the horrible use of evalc):
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> % using standard spm coreg settings
>
> matlabbatch{1}.spm.spatial.coreg.estwrite.ref = {files.coreg_fix};
>
> matlabbatch{1}.spm.spatial.coreg.estwrite.source = {files.coreg_mov};
>
> matlabbatch{1}.spm.spatial.coreg.estwrite.other = {''};
>
> matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.cost_fun = 'nmi';
>
> matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.sep = [4 2];
>
> matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.tol =...
>
> [0.02 0.02 0.02 0.001 0.001 0.001 0.01 0.01 0.01 0.001 0.001
> 0.001];
>
> matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.fwhm = [7 7];
>
> matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.graphics = 0;
>
>
>
> matlabbatch{1}.spm.spatial.coreg.estwrite.roptions.interp = 1;
>
> matlabbatch{1}.spm.spatial.coreg.estwrite.roptions.wrap = [0 0 0];
>
> matlabbatch{1}.spm.spatial.coreg.estwrite.roptions.mask = 1;
>
> matlabbatch{1}.spm.spatial.coreg.estwrite.roptions.prefix =
> coreg_file_prefix;
>
> inputs = cell(0,1);
>
>
>
> evalc(['spm_jobman(' '''' 'serial' '''' ',matlabbatch,' '''' ''''
> ',inputs{:})']);
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
>
>
>
>
> With regards,
>
> André Ahlgren
>
>
>
> ___________________________________________
>
>
>
> André Ahlgren
>
> Department of Medical Radiation Physics
>
> Barngatan 2:1
>
> Lund University
>
> SE-221 85 Lund, Sweden
>
>
>
> Phone: +46 46 173132
> Mobile: +46 735 749052
>
>
|