1

I have three different isotropic MRI DICOM volumes of the same object, each with a different direction (orthogonal sagittal, coronal and transverse acquisitions of same object).

I would like to convert them to numpy arrays and plot them, in such a way that their indexing matches. Let's say that if I have three numpy arrays issued from sitk images:

sag_array = sitk.GetArrayFromImage( sag_sitk )
dors_array = sitk.GetArrayFromImage( dors_sitk )
trans_array = sitk.GetArrayFromImage( trans_sitk )

I would like to be able to plot them using the same indexing, so that the slices

sag_array[:,:,index]
dors_array[:,:,index]
trans_array[:,:,index]

correspond to the same view, with no flipping or inversion of the axes.

I guess this info is contained in the Direction of the SimpleITK images, is there a way to transfer it to the numpy arrays after the conversion?

Does the Direction property in general have any effect on the numpy conversion, or is it lost?

Amit Joshi
  • 15,448
  • 21
  • 77
  • 141
walew
  • 11
  • 2
  • Numpy arrays don't have any meta-information with them, so the direction is lost. To get your volumes to match in numpy you're going to have to flip them. – Dave Chen Feb 18 '21 at 15:45

1 Answers1

0

I solved it by pre-processing all the images with the sitk.Resample() function to a common Origin and Direction. In this way, when converting to numpy arrays, since they occupied the same physical space, they're sliced coherently among each other.

walew
  • 11
  • 2