Set target region for image resampling

Operating system: Ubuntu 16.04 LTS, MacOS 10.12.3
Slicer version: 4.6.2, also tested on 4.7.0 latest
Expected behavior: preserved transformed state when file opened outside Slicer including the entire volume of interest
Actual behavior: volume transformed but inappropriately cropped following resampling

Hi there,

This question builds on another thread I’ve found on the Slicer forum:

I have used the ACPC Transform module to align an image relative to the AC-PC plane in a brain volume (make it more symmetric). As a result, I have a transform matrix.

I first tried applying then hardening the transform and saving the volume (as .nii.gz format), but the transformation was not preserved (the output is identical to the input image). I followed the suggestion in the referenced thread and tried using the Resample Image (BRAINS) module with the following parameters:


  • Image to Warp: original_volume
  • Reference Image: none


  • Output Image: transformed_volume
  • Pixel Type: float

Warping Parameters:

  • Displacement Field (deprecated): None
  • Transform file: ACPC transform
  • Interpolation Mode: NearestNeighbor

All other settings were by default. After clicking apply, the volume appears transformed but is inappropriately cropped. I believe this is a result of not specifying a Reference Image (help text: “Reference image used only to define the output space. If not specified, the warping is done in the same space as the image to warp.”). I don’t have a reference image that matches the dimensions to be expected post-transform.

Any thoughts on how to resolve this problem?


If the external program properly uses axis directions information in the image header then you don’t need resampling. If your program ignores axis directions and operates in voxel space then you need resampling.

To resample using an arbitrary region, you can use Crop volume module:

  • Input volume: your transformed volume (no need to harden the transform)
  • Input ROI: create a new RAS-axes-aligned region of interest by selecting ROI mouse mode on the toolbar, clicking in the middle of the image and a corner in the image, then adjust the size as needed.
  • Click Apply

ROI place mode on the toolbar:

1 Like

Appreciate your quick response!

I’ve attached a screenshot of my current workflow. It may be worth stepping back for a moment to better explain my objective, which is to correct a tilt in an image volume. I have used the ACPC Transform module, to reorient the image, and want to resample it then export as .nii format (input image was also .nii format). The goal is to have the AC-PC anatomical structures (labelled as 1 and 2 in the screenshot) aligned to be parallel to the anterior-posterior axis of the resampled volume.

I am following your suggestion to use the Crop Volume module. You mention ways to augment the size of the ROI box (white outline on screenshot). Is there a way to rotate/ the ROI box? I’m also wondering if there is a more automatic way to detect the optimal crop volume (looks like the magenta-coloured box in the 3D view would be the optimal ROI box so if somehow that could be fed in as the input ROI to Crop Volume…).

Create a new RAS-axes-aligned region of interest by selecting ROI mouse mode on the toolbar, clicking in the middle of the image and a corner in the image, then adjust the size as needed. If you make the Crop Volume module create the ROI for you or you use Fit ROI button then the ROI will be aligned with your volume’s axes and not with RAS axes.

Of course, you can also rotate the ROI box by applying the transform to it. If you use it for ACPC alignment, then you need to invert the transform if you apply it to the ROI.

1 Like

Thanks, this worked!

To recap, here is the workflow:

  1. Import original_volume (.nii.gz) into 3D Slicer.
  2. Compute the transformation using the ACPC Transform module.
  3. Apply the transformation to the original_volume using the Transforms module.
  4. Create a new RAS-axes aligned ROI (toolbar; see screenshot above from @lassoan) centered on the midpoint between AC and PC. Manually adjust the size of the box.
  5. Use the Crop Volume module with the following settings, and hit Apply:
    • Input Volume: original_volume
    • Input ROI: R (default name for new RAS ROI)
    • Output Volume: transformed_volume
    • Interpolated Cropping: On
    • Spacing scale: 1.00x
    • Isotropic spacing: On
    • Interpolator: Linear
  6. Save the transformed_volume as .nii.gz

Comments: It is not immediately obvious that post-tranformation resampling would be handled by a Slicer module called Crop Volume (luckily there is great support here!). A nice-to-have down the road would be to have resampling as options in the ACPC Transform or better yet the Transforms module (perhaps as an option next to “hardening the transform”)? I understand that part of the problem stems from the export to .nii.gz format (which is not handling the axis information the way Slicer expects), but it is worth considering that this is one of the most common neuroimaging file formats in use these days.

What software do you use for visualizing the saved nifti file? If that software does not ignore image axis directions then you don’t even need resampling.

We could add resampling to Transforms or ACPC modules, but as you can see, resampling is not trivial (has many options), so overall it’s cleaner to have it in a separate module instead of repeating it in many modules. But I agree that having automatic fitting of RAS-axis-aligned ROI would be useful and it would be also nice to consolidate all the cropping/resampling modules (there are 4 of them), and have better names. Maybe “Crop and resample volume” name would be more descriptive?

I use mainly fslview and ITK-snap for visualizing the saved nifti files. I’m not sure if nifti takes into account image axis directions.

I would put my vote in for a resampling option in Transforms with automatic fitting of RAS-axis aligned ROI. Consolidating the different options would also make sense. Is there a protocol I should follow for making these feature requests?

Features requests can be entered at However, this request is a typical example where we would need to choose between conflicting requirements of flexibility <-> ease of use of the software. Also, it is difficult to implement resampling of volume types in the core Transforms module for unknown volumes (that are defined in extensions, such as tensor volumes, 4D volumes, etc). In general, we try to keep core modules as simple as possible and not bundle multiple features, which are often used together in certain workflows, because in other workflows they are not, or they are combined with other modules.

Nowadays, we address conflicting flexibility <-> ease of use requirements and avoid complicated designs by implementing application-specific workflows by Python scripted modules. Very small and simple Python scripted modules can provide a streamlined user interface and internally use multiple core modules.

In your case, you could add a simple extension that would use ACPC, Transforms, and Resample modules to implement the complete processing workflow. If you think it would be too much work for you then what we can do is to add automatic ROI extension to one of the resample modules or maybe rename the Crop volume module to better reflect that it does resampling, too?

ITK-Snap correctly reads image header but it does not support editing in oblique planes, so you need to resample the input images manually.

Slicer’s recently introduced Segment Editor module (available in nightly builds) does not have this limitation: you can segment in arbitrarily oriented planes (if needed, image resampling is performed automatically in the background). Segment Editor has many more effects than ITK-Snap and has many unique features (allows overlapping segments, has sophisticated masking options, editing in 3D views, support of standard DICOM terminologies, etc). I would recommend to try Segment Editor and let us know if you find that compared to ITK-Snap anything is missing or you cannot figure out how to use. See reference manual and tutorials.

Sorry for the delay in responding. I did not receive an email notice.

I understand your concerns about feature modifications to core modules. However if transforming 4D or diffusion data works as expected in the Transforms module, I would imagine it would be possible to also handle resampling in the module as well (just apply the same resampling to each of the associated volumes in the N-D dataset)?

Regarding quicker fixes, one of the modules named “Resample …” should handle this functionality so either of the options you proposed would work. It’s just intuitively where any beginner-to-immediate user would look.

I’ve been meaning to give the Segment Editor a try. (please tell me there is an undo button)

There is.

Use the latest nightly version of Slicer.