Resample Scalar/Vector/DWI Volume produces weird results

I want to resample an image to spacing (1,1,1), origin (0,0,0), and direction 1,0,0,0,1,0,0,0,1.

I tried using the “Resample Scalar/Vector/DWI Volume” module.

I loaded a volume, set it as the input volume, and created a new output volume for the output.
The only parameters I changed were Spacig, Size, Origin, and Direction Matrix in “Manual Output Parameters.”

The resampled image, however, doesn’t resemble the input image at all, as you can see in the screenshot (the resampled image is this small white segmentation-like object)

Am I doing something wrong?

Here is the link to the volume that I’m uisng.

Stable Release 3D Slicer 5.6.2, Ubutu 22.04.4 LTS

I also tried doing it in the Python console, as described here but I also get strange results.

When I set those 4 parameters:

params["inputVolume"] = slicer.util.getFirstNodeByName("moving")
params["outputVolume"] = slicer.util.getFirstNodeByName("moving_2")
params["interpolationType"] = "linear"
params["outputImageSpacing"] = (1,1,1)

the resampling works.

When I add this parameter

params["outputImageOrigin"] = (0,0,0)

the resampling finishes, but the origin remains unchanged and those two messages appear around 25 times each:

[VTK] Input port 0 of algorithm vtkImageMapToWindowLevelColors (0x80bc240) has 0 connections but is not optional.
[VTK] Input port 0 of algorithm vtkImageThreshold (0x80a9230) has 0 connections but is not optional.


When I remove the origin parameter and set the direction:

params["directionMatrix"] = (1,0,0,0,1,0,0,0,1)

the resampling finishes, the direction matrix is set correctly, but the entire image is now filled with 0s and the same VTK message appear

I’m not sure what is intended when you try to specify those parameters independently, but you could read the source code to see how they are used.

Typically you provide a reference volume to define the grid in which you want the input volume resampled. That is, you can create a volume that has the origin, spacing, directions, and dimensions to cover the geometric extent you want to sample. You can look at the CropVolume code to see how this is done.

I have a fixed and moving volume, both with non-isotropic spacing and a non-identity direction matrix.

I’m using Slicer to perform a rigid registration of the moving to the fixed.

Then, I want to export both with isotropic spacing and identity direction matrix.

So once I have the fixed with those requirements, I can resample the moving onto the fixed like you described - but I can’t figure out how to process the fixed.

You can create an empty volume with isotropic spacing and identity directions with the origin and dimensions needed to enclose your fixed volume. Then you can resample both fixed and moving using your empty volume as the reference geometry.

You can also use the Crop volume module to create a new volume with isotropic spacing, with axis-aligned orientation.