Nifti Header with Talairach or MNI coordinates

AIMS library and commands usage

Moderators: riviere, denghien

User avatar
François Leroy
Posts: 30
Joined: Wed Feb 22, 2006 5:22 pm

Nifti Header with Talairach or MNI coordinates

Postby François Leroy » Tue Jun 25, 2013 2:28 pm

Let's say I would like to send a nifti volume file to a remote collegue. He strongly asked me to save the Talairach or MNI coordinates within the nifti header. How should I proceed?

Usually, when looking at a T1 MRI (eg T1volume.nii) that has been imported in Brainvisa, getting Talairach or MNI coordinates is all done automitically using the new Morphologist pipeline. However, this is done by our beloved Anatomist browser through TRM transformation files e.g. T1volume_TO_Talairach-MNI.trm. This file magically put our T1 volume into the Talairach or MNI referential.
What should I do to use this TRM file to save the T1 volume in a NIFTI file with proper Talairach or MNI coordinates?

I first tried the following : "AimsResample -i T1volume.nii -o T1volume_MNI.nii -m T1volume_TO_Talairach-MNI.trm"
Unfortunatly, the rotation puts the T1 volume out of the result volume. :oops:

Let us say now that the T1 volume has a volume size of 256x256x256.
I then edited the TRM file and added the value 128 to each term of the first line (i.e. half the volume size to the TRM translation vector). I updated the TRM file and re-run the AimsResample command. It worked fine. So far, so good. :)

Well, well, almost. When looking at the resampled T1 volume with Anatomist, the coordinates do not appear to be the true MNI coordinates. As one could have expected, the coordinates have been translated by a [128 128 128] vector probably due to my previous TRM update. How can I get rid of this 128x128x128 translation in the MNI coordinates?

In some other posts, one of our magic brainvisa/anatomist dream team suggested to edit the nifti header. So I tried it in the following way:
from soma import aims
vol_mni ="T1_volume_MNI.nii")
vol_mni.header()['transformations'][0][3] -= 128
vol_mni.header()['transformations'][0][7] -= 128
vol_mni.header()['transformations'][0][11] -= 128
aims.write(vol_mni, "T1_volume_MNI-128.nii")

I then open the T1_volume_MNI-128.nii in Anatomist. :shock: The coordinates did not change at all when looking at the cursor value. The (0, 0, 0) remained in the corner of the volume, not at the true MNI referential origin.

In summary, my questions are:
1) Was my initial 128x128x128 translation a good move to get the resampled volume in the MNI referential
2) Was my a posteriori correction, i.e. updating the "transformations" parameter in the Nifti header, the right one to get true MNI coordinates ?
3) Is there a way to see a MNI volume with proper coordinates, i.e. having (0,0,0) at the MNI referential origin, by using Anatomist (and without having to load a TRM transformation file)?

I hope these questions are not too cumbersome :? . Thanks a lot!

User avatar
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France

Re: Nifti Header with Talairach or MNI coordinates

Postby riviere » Tue Jun 25, 2013 6:31 pm

Hi François,

Is your initial nifti volume normalized in MNI space, or has transformation info to it ? It's not clear to me when I read your explanations.
Anyway, if you have the proper .trm file to the MNI space, you can store it in the nifti header in a python script this way:

Code: Select all

from soma import aims
vol = 'volume.nii' )
trans = 'T1volume_TO_Talairach-MNI.trm' )
vol.header()[ 'transformations' ] = [ trans.toVector() ]
vol.header()[ 'referentials' ] = [ aims.StandardReferentials.mniTemplateReferential() ]
aims.write( vol, 'volume_with_trans.nii' )

You should not need to build a translation of 128x128x128, which has many chances to be wrong (unless your image is actually normalized and you exactly control the field of view).
Resampling the volume is also probably not what you want: you want to have transformation info, not to actually apply it.

In Anatomist, this transformation will not be used by default, unless you set the settings option "use referential/transformation info from file headers". You can manually get it using the right-click option on the volume in Anatomist.


User avatar
François Leroy
Posts: 30
Joined: Wed Feb 22, 2006 5:22 pm

Re: Nifti Header with Talairach or MNI coordinates

Postby François Leroy » Wed Jun 26, 2013 1:22 pm

Great! It worked all fine! Thanks a lot Denis.

Return to “AIMS”

Who is online

Users browsing this forum: No registered users and 1 guest