Resampling Module#

Module: pyradise.process.resampling

General#

The resampling module provides functionality for resampling Image instances.

Class Overview#

The following classes are provided by the resampling module:

Class

Description

ResampleFilterParams

Parameterization class for the ResampleFilter.

ResampleFilter

Filter for resampling Image instances.

Details#

class ResampleFilterParams(output_size, output_spacing, reference_modality=None, transform=<SimpleITK.SimpleITK.AffineTransform; proxy of <Swig Object of type 'itk::simple::AffineTransform *'> >, centering_method='none', rescaling_intensity_images=True)[source]#

Bases: FilterParams

A filter parameter class for the ResampleFilter class.

The associated filter provides the following three centering_methods for resampling images:

  • The none centering_method resamples an image such that the output origin and direction does not change.

  • The reference centering_method resamples an image such that the output origin and direction is the same as the reference image (identified by the reference images modality).

  • The label_moment centering_method resamples an image such that the center of the resampled image is the average between the label center and the gravity center of the reference image. This method is a good approach for resampling data with bilateral and symmetric segmentations. However, it is an experimental method and should be used with caution.

Parameters:
  • output_size (Optional[Tuple[int, ...]]) – The output size of the images.

  • output_spacing (Optional[Tuple[float, ...]]) – The output spacing of the images.

  • reference_modality (Optional[Union[Modality, str]]) – The reference modality used if centering_method = 'reference' or centering_method = 'label_moment' (default: None).

  • transform (sitk.Transform) – The transformation applied during resampling (default: sitk.AffineTransform(3) (identity transform)).

  • centering_method (str) – The method to center the image (options: ‘none’, ‘reference’, ‘label_moment’) (default: ‘none’).

  • rescaling_intensity_images (bool) – If True the intensity images will be automatically rescaled to the original intensity range (default: True).

class ResampleFilter(warning_on_non_invertible=False)[source]#

Bases: Filter

An invertible filter class for resampling all IntensityImage and SegmentationImage instances of a Subject instance.

Warning

The inverse resampling procedure may not yield the expected results if successive Filter s are applied to the same Image instances. Thus, it’s recommended to use the invertibility feature with appropriate caution.

Note

Due to the limited precision of floating point numbers, the inverse normalization may not be exact.

static is_invertible()[source]#

Returns whether the filter is invertible or not.

Returns:

True because the resampling of images is invertible.

Return type:

bool

execute(subject, params)[source]#

Executes the resampling filter procedure.

Parameters:
Returns:

The Subject instance with resampled IntensityImage and SegmentationImage instances.

Return type:

Subject

execute_inverse(subject, transform_info, target_image=None)[source]#

Executes the inverse resampling filter procedure.

Parameters:
  • subject (Subject) – The Subject instance to be processed.

  • transform_info (TransformInfo) – The transform information.

  • target_image (Optional[Union[SegmentationImage, IntensityImage]]) – The target image to which the inverse transformation should be applied. If None, the inverse transformation is applied to all images (default: None).

Returns:

The Subject instance with inversely resampled IntensityImage and SegmentationImage instances.

Return type:

Subject