Page 1 of 1

ROI mask output does not keep matrices of nifti file

Posted: Thu Apr 18, 2013 5:47 pm
by Manik
Hi,

a colleague trying to segment a lesion on an T1 MRI (nifti file) using Anatomist ROI module and exporting the resulting mask as nifti was unable to view it in SPM alongside the T1 with a synchronized cursor.
It seems the problem is that exporting a ROI as a mask does not keep the geometrical transformations from the source image's header (scanner-based referential).
Is there a way to get Anatomist to copy the transformations to the mask ?

Re: ROI mask output does not keep matrices of nifti file

Posted: Thu Apr 18, 2013 10:05 pm
by riviere
Hi Manik,
I thought the main attributes of the original image header were copied to the exported ROI, but it seems that it is not so. We will look at it.
In the meantime, you can add the missing transformation by dirfferent means:
- extract the transformation from the original image, using AimsFileInfo, copy the "referentials" and "transformations" fields to the extracted ROI .minf header, then re-write the ROI image using AimsFileConvert (you can re-write it on itself), this will ensure the new information is inserted in the nifti file itself (and not only the .minf extra header)
- you can do the same via a python script:

Code: Select all

from soma import aims
orig = aims.read( 'original_image.nii' )
roi = aims.read( 'exported_roi.nii' )
roi.header()[ 'referentials' ] = orig.header()[ 'referentials' ]
roi.header()[ 'transformations' ] = orig.header()[ 'transformations ]
aims.write( roi, 'exported_roi.nii' )
In a more general way, you can probably copy the entire original image header to the exported ROI's:

Code: Select all

roi.header().update( orig.header() )
Denis