Well, you could get this matrix for both images, an then matrix-divide them I guess?
 
V1=spm_vol('file1.nii')
V2=spm_vol('file2.nii')
 
V2.mat/V1.mat
 
When I remember the math well this matrix should map file1 to file2 in worldspace, if that is what you are after.
 
check 'help mrdivide' and 'help mldivide' to be sure, I just do this math from the head right now.
 
But when you want to map one image to another, why dont you use coregister > estimate in SPM, which is the normal way? You would not have to bother with matrix algebra altogether ...
 
Good luck,
 
Bas
--------------------------------------------------
Dr. S.F.W. Neggers
Division of Brain Research
Rudolf Magnus Institute for Neuroscience
Utrecht University Medical Center
Visiting : Heidelberglaan 100, 3584 CX Utrecht
              Room B.01.1.03
Mail     : Huispost B.01.206, P.O. Box 85500
             3508 GA Utrecht, the Netherlands
Tel       : +31 (0)88 7559609
Fax      : +31 (0)88 7555443
E-mail  : [log in to unmask]
Web    : http://www.neuromri.nl/people/bas-neggers
             http://www.neuralnavigator.com
--------------------------------------------------
 


Van: [log in to unmask] [mailto:[log in to unmask]] Namens Dan Golding
Verzonden: vrijdag 21 mei 2010 15:13
Aan: Neggers, S.F.W.
Onderwerp: Re: [SPM] Finding affine transformation parameters

Thanks, but would you mind explaining this in a bit more detail?

I'm don't quite see the difference in loading an image using spm_vol(spm_select) and using spm_vol('filename.nii') which is how I have been doing it. The .mat field gives information about the individual images, but not about how to transform one image to another which is what I am looking for. Unless I have misunderstood?

If you could please explain to me how I can coregister one nifti image to another, and get the affine transformation matrix describing that transformation, I would greatly appreciate it.

Thanks
Dan

On Fri, May 21, 2010 at 2:54 PM, Neggers, S.F.W. <[log in to unmask]> wrote:
V=spm_vol(spm_select);

V.mat


--------------------------------------------------
Dr. S.F.W. Neggers
Division of Brain Research
Rudolf Magnus Institute for Neuroscience
Utrecht University Medical Center
Visiting : Heidelberglaan 100, 3584 CX Utrecht
             Room B.01.1.03
Mail     : Huispost B.01.206, P.O. Box 85500
            3508 GA Utrecht, the Netherlands
Tel       : +31 (0)88 7559609
Fax      : +31 (0)88 7555443
E-mail  : [log in to unmask]
Web    : http://www.neuromri.nl/people/bas-neggers
            http://www.neuralnavigator.com
--------------------------------------------------



> -----Oorspronkelijk bericht-----
> Van: SPM (Statistical Parametric Mapping)
> [mailto:[log in to unmask]] Namens Dan Golding
> Verzonden: vrijdag 21 mei 2010 14:43
> Aan: [log in to unmask]
> Onderwerp: [SPM] Finding affine transformation parameters
>
> Hi,
>
> I would like to find the 12 parameters for an affine
> transformation between two nifti images. I have been looking
> into using spm_coreg and spm_matrix but I couldn't quite
> understand how to use them form their help. spm_coreg outputs
> 6 parameters, I'm not sure what these 6 are?
>
> Also is there a function that does the reverse of spm_matrix,
> i.e. one that can take an affine transformation matrix and
> split it into 3 rotations, 3 scalings etc...?
>
> Thanks
> Dan
>

------------------------------------------------------------------------------

De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is
uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht
ontvangt, wordt u verzocht de inhoud niet te gebruiken en de afzender direct
te informeren door het bericht te retourneren. Het Universitair Medisch
Centrum Utrecht is een publiekrechtelijke rechtspersoon in de zin van de W.H.W.
(Wet Hoger Onderwijs en Wetenschappelijk Onderzoek) en staat geregistreerd bij
de Kamer van Koophandel voor Midden-Nederland onder nr. 30244197.

Denk s.v.p aan het milieu voor u deze e-mail afdrukt.

------------------------------------------------------------------------------

This message may contain confidential information and is intended exclusively
for the addressee. If you receive this message unintentionally, please do not
use the contents but notify the sender immediately by return e-mail. University
Medical Center Utrecht is a legal person by public law and is registered at
the Chamber of Commerce for Midden-Nederland under no. 30244197.

Please consider the environment before printing this e-mail.