Resampling a linear transformation

In the recent versions of Slicer, I am having a hard time exporting a resampled volume from a linear transform. Hardening simply changes the image direction matrix, so does the crop volume (when the image is under a linear transform). I am pretty sure at some point Crop Volume used to create a resampled image, but that doesn’t seem to be the behavior anymore.

I don’t want to use resample vector/DWI because that means I need to figure out a reference image and its extends. That’s too much unnecessary work.

Resampling is automatically done for non-linear transforms. I think this needs to be an option for linear transforms too (e.g., harden vs harden via resample),

“Crop volume” module resamples the image if Interpolated cropping option is enabled. This behavior has not been changed in the past couple of years. The output volume is placed under the same transform as the input volume, so one thing to pay attention to is that if you want to have a volume with RAS-aligned axes then you need to harden the transform on the input volume before cropping. Would this fulfill your needs? If hardening the transform before cropping is an issue then we could add an advanced option to place the output under the parent transform of the ROI (instead of the parent transform of the input volume).

Adding a “Harden via resample” option would add quite a bit of noise to the GUI, as it would need to be added at 3 places (Data module / Subject hierarchy tab, right-click on transform column; Data module / Subject hierarchy tab, right-click on transformed node; Transforms module / Apply transforms) and it would be nice if the user could also specify the desired output spacing and background fill value.

I assume that you need this for reorienting non-clinical scans to canonical orientation. I think the closest to this is Crop volume module, we would just need to make it a bit easier to use it for this purpose. Maybe something like these would be sufficient:

  • Add a “Reorient” checkbox (show/hide the transform interaction handles; if no transform is applied yet then add a parent transform) and a “Harden transform” button next to it (it would harden the transform on the volume). These would make it very easy to set the correct orientation.
  • Add a “Resize to volume” button (next to “Fit to volume” button), which would set the ROI axes to the axes of the parent transform (by default RAS) coordinate system axes and just change the size of the ROI to include the entire volume. If “Interpolated cropping” is enabled then the auto-fix button could use this “Resize to volume” button.

Then reorientation could be completed by these steps:

  • Check “Reorient” checkbox
  • Adjust the volume orientation in slice views using the transform handles
  • Click “Harden transform”
  • Click “Resize to volume”
  • Click “Apply”

True, and sometime people want to move data to other programs that does not read the image direction fields of NRRD (like Fiji). So volume needs to be resampled.

I don’t think that true: This is my original data:


Now I rotated with interaction widget to make it consistent with planes:


I have hardened the interaction transform, and used the crop volume with interpolation checked and the first evidence that it is not resampled, output dimensions are not changing:

And if you look at image directions of that cropped volume you can see it simply copied the transfrom from the original image:.

The only way I can make this work, if I volume render and set the ROI to image extends in the volume rendering and then crop. The image is resampled.

The ROI that “Fit to volume” button (or automatix “Fix” button) creates is aligned with the volume’s voxel axes (to avoid quality loss by default when cropping). That’s why the output volume had non-identity orientation matrix.

To get output volume with axes aligned with RAS directions, you can place an ROI manually (or as you did with the Volume Rendering module: create an ROI before the volume is transformed and then just change the size manually).

The “Resize to volume” button that I proposed above would simplify the ROI placement. It would create/update only the ROI size (to include the entire volume), but it would not change its orientation (by default it would be aligned with the parent coordinate system = RAS axes).

I think this is where we can provide the lossy, resampling option, for people who need. An option to set the ROI in the way Volume Rendering does, not align with voxel axes. Setting the ROI before and then modifying manually, or using the volume rendering is both cumbersome options.

@lassoan I added an issue on Slicer to track this: Add an option to more easily resample linear transforms in Crop Volume · Issue #8415 · Slicer/Slicer · GitHub

I agree, this feature will make it easier to create an RAS-axis-aligned volume by resampling.

1 Like