SimpleITK cast 4D image

The question is inspired by this reply: Weighted average over temporal dimension

Shortly: I have an external intercept parameter -1024 and a SimpleITK image (4D) with an unsigned data type of which I want to subtract 1024. Since casting of 4D is not supported in SimpleITK, what would we the best way to go about this keeping my spacing, origin and direction, and others intact?
In ITK perhaps SliceBySliceImageFilter might be an option (?) but it is not supported in SimpleITK.

1 Like

Please look at this example with a python function decorator called slice_by_slice: Slice by Slice Adaptive Histogram Equalization — SimpleITK 2.0rc2 documentation

You can use it like this:

@slice_by_slice
def do_3d_image_stuff(img):
     return sitk.Cast(img, sitk.sitkFloat32)

1 Like