I’m working on a Python application that uses ITK, and I’m looking for guidance on how to regularize or resample a 3D volume when the slice spacing is not uniform—i.e., the distance between slices varies throughout the volume.
I know that 3D Slicer handles this kind of situation internally when loading and resampling volumes, but I need to implement a similar solution within my own application using ITK and Python.
Is there a recommended approach or existing method in ITK (or SimpleITK) for dealing with this? Ideally, I’d like to resample the volume to have isotropic or at least regular spacing across all dimensions.
Any suggestions, code examples, or references would be greatly appreciated.
A very generic approach would be to treat this problem as a scattered data approximation of a scalar field. For that, you could use this B-spline ITK filter. Unfortunately, I don’t see it implemented in SimpleITK. However, we do have it implemented in ANTsPy as the function ants.fit_bspline_object_to_scattered_data. Input is a numpy point set providing the data (in your case, this would be the intensity values), a numpy point set providing the physical location of those intensity values, and physical space definition of the bounding box (in terms of origin, spacing, direction). Output is an ITK image representing the sampled B-spline object (i.e., volume).
Here’s an example of this approach where I had 3 sets of ~10 orthogonal thick slices oriented in 3-D space sampling a particular . I wanted to use all three sets of data to create a single image volume.