[Neuroimaging] Slicing images on different planes

Christopher Markiewicz markiewicz at stanford.edu
Mon Mar 22 09:07:01 EDT 2021


Hi Samuel,

If the images have come from a single session where multiple scans have been taken of the object without removing it from the scanner, and the different image sequences you use will induce the same distortions, then this should work. In fact, it would not even be necessary to reorient them to achieve voxel-to-voxel correspondence.

If the images come from multiple sessions but have been registered so that their affines correspond, then yes, resampling should provide voxel-to-voxel correspondence. Again, this assumes constant distortion.

If the images have distortions, do not match the above situations, or are of unknown provenance, then the odds are good that you'll need to perform image registration to bring them into alignment. In most cases, you will select an image as canonical and register all other images to that. If there is such a thing as a standard reference image, you can also register your images to that, which will allow you to use coordinates that others can interpret without your image.

As a rule, images with the same expected distortions can be registered with a rigid (6 dof) transformation. Registration between modalities with different spatial distortions or to a standard reference will generally require nonlinear transformations.

If you're just getting started on registration, I would suggest that it's worth your time to learn ANTs (https://antsx.github.io/ANTs/). It's extremely flexible, but they have a bunch of scripts that handle common cases and are useful demonstrations if you need to go beyond them: https://github.com/ANTsX/ANTs/tree/master/Scripts. One caveat with ANTs is that if there are any shear components to your affine matrix, ANTs will not respect them.

Best,
Chris

________________________________________
From: Neuroimaging <neuroimaging-bounces+markiewicz=stanford.edu at python.org> on behalf of Samuel Botter Martins <sbm.martins at gmail.com>
Sent: Monday, March 22, 2021 7:53 AM
To: Neuroimaging analysis in Python
Subject: Re: [Neuroimaging] Slicing images on different planes

Dear Christopher,


On Sat, Mar 20, 2021 at 11:46 PM Christopher Markiewicz <markiewicz at stanford.edu<mailto:markiewicz at stanford.edu>> wrote:
Hi Carl,

It sounds like what you want to do is to interpolate the image in a space that's more conveniently rotated so that image dimensions correspond to meaningful directions in the world and then visualize slices. The way to go about that is going to depend on how well the orientation is described in the image affine matrix.

If the affine correctly describes rotations, then you can simply resample the image with nibabel.processing.resample_to_output() (https://nipy.org/nibabel/reference/nibabel.processing.html#resample-to-output). That will produce an image in-memory that you can work with as you show in your code, or save and open in another viewer.

So, does this mean I could reorient/serialize all images in memory to the same voxel space?
I mean, regardless of the orientation of each image stored on file, this function will reorient all of them to the same voxel coordinate space, so that a voxel img[x, y, z] correspond to the precise position in all images, am I correct?
Of course, if the image has stored its affine matrix.

Best.

--
Prof. Dr. Samuel Botter Martins
Professor in Federal Institute of Education, Science and Technology of São Paulo


More information about the Neuroimaging mailing list