Computing the intersection of a mask image and an arbitrary plane

Hi there,
my VTK lessons are failing me, so asking this here.

I have an anatomical image of a brain, and a segmentation of a region of interest. Both saved as NIfTI files.

I would like to be able to compute and visualize the intersection of an arbitrary plane (e.g. axial, coronal, sagittal at any given slice) on the contour of the segmentation. When the normal of the clipping plane is not a given one, there seems to be no intersection, whereas I expect there should be one.

Maybe that has to do with the fact that my volume is not centered at the origin. I see that my plane and the contour are far apart when visualizing, but I do set the origin of my cutting plane to the center of my image data. Furthermore, I guess that if that were an issue, it should also affect to the plane normal value that works.

Any guess what step I’m missing to make it work for any arbitrary plane/normal?

I’m using Python and VTK 9.1.0. Attached some pictures illustrating the volume data and the segmentation, the result of the clip with a normal plane that actually works, and the script. The NIfTI files of interest can be found here:

I’m using nibabel to load the NIfTI files.

The script can be called as:
python T1.nii.gz CC.nii.gz

Thanks for the time. (5.0 KB)

OK, I think I found some answers.

In summary, if I translate my segmentation to the origin, then the normals that are expected to cut the segmentation, do provide an intersection and I am able to see them properly.

And the intersection and the displayed plane are both at the “right location” (although in the script I do not set properly its extension).

So moving the intersection actor to the volume’s location should allow to display it on top of the anatomy.