0

I am working with MRI images which in their raw form are 5-dimensional. I can load them in using nibabel package which gives me nibabel.Nifti1Image objects. Then I can slice that object into a bunch of 3D numpy arrays from which I create SimpleITK.Image objects, but I would like to preserve the metadata (affine, header) contained in nibabel.Nifti1Image. When working with just SimpleITK.Image objects, you can use the .CopyInformation() method, unfortunately that does not work with nibabel.Nifti1Image. How do I copy the information across?

I don't know how to copy the information across manually as I do not understand the difference in how either package approaches defining spatial information.

Barbara Gendron
  • 385
  • 1
  • 2
  • 16
Jeremy Joe
  • 11
  • 3
  • Looking at Nibabel's docs, they store image geometry as an affine transform. SimpleITK uses image origin, orientation and pixel spacing. So there's no easy way to go from affine to SimpleITK. To do it correctly, you'd have to create an AffineTransform in SimpleITK and then resample the image. – Dave Chen Mar 06 '23 at 16:05
  • @DaveChen that's what I was afraid of. I noticed you're helping develop SimpleITK. If someone needs to load in images that are more than 4D, how would sitk handle that? Do I just need to separate my images into 3 or 4D and load those in one by one or what's the usual process? In my case I have DTI images with shape (x, y, z, diffusion direction, repetition). – Jeremy Joe Mar 07 '23 at 14:43
  • Yeah, SimpleITK doesn't handle higher dimensional images. In fact, I don't think the 4D support is that great either. You'd have to split your images. Maybe ask folks on the discourse how they do things. discourse.itk.org. – Dave Chen Mar 07 '23 at 16:15

0 Answers0