# How to slice diagonally (SITK/Python)

Greetings,

I just started using ITK (simpleITK/Python) and I would like to slice CT images according to some diagonal axes.
I managed to visualize slices according to the x-, y-, and z- axis separately, but I don’t get how to visualize/generate a slice according to a non-orthogonal plane that I would define.

I’d appreciate if you share your experiences if you have done this, or any tutorials that might help me with this task.
(P.S. Sorry if the question is too basic.)

Cheers,
JSphine

What you basically need to do is define where your slice needs to be and use resample filter. You could take a look at this IJ article, as it tries to make it easier to construct that transform.

1 Like

Thank you very much for the quick reply and the ressources!
I will have a look at them.

To elaborate a little further, defining an arbitrary oriented plane is a tricky task. Not only do you need to define a plane ( perhaps by a point and a vector ) you also need to define the orientation for the sampling grid. Additionally the bounds for the slice need to be defined, and an arbitrary slice through a cube does not have to be a quadrilateral.

This problem can be phrased as a resampling problem of a 3D image to a 3D image with an identity transform. The number of pixels could be 1 in the z-direction to get a “slice”. The trick is to define the proper parameters for the physical location of the output parameter. That includes origin, direction cosine matrix, and the physical extent of the output image. The correct orientation for the resulting slice can be done with the output direction cosine matrix. Computing these attributes for an arbitrary case is tricky, but just applied linear algebra.

2 Likes