Modification Module#

Module: pyradise.process.modification

General#

The modification module provides functionality to add and remove images from a subject on a filter-based approach. In addition, this module contains a filter to merge (i.e. MergeSegmentationFilter) multiple SegmentationImage s into one common SegmentationImage.

Class Overview#

The following classes are provided by the modification module:

Class

Description

AddImageFilterParams

Parameterization class for the AddImageFilter.

AddImageFilter

Filter to add new Image instances to a Subject instance.

RemoveImageByOrganFilterParams

Parameterization class for the RemoveImageByOrganFilter.

RemoveImageByOrganFilter

Filter to remove a SegmentationImage instances from a subject via its Organ.

RemoveImageByAnnotatorFilterParams

Parameterization class for the RemoveImageByAnnotatorFilter.

RemoveImageByAnnotatorFilter

Filter to remove a SegmentationImage instances from a subject via its Annotator.

RemoveImageByModalityFilterParams

Parameterization class for the RemoveImageByModalityFilter.

RemoveImageByModalityFilter

Filter to remove a IntensityImage instances from a subject via its Modality.

MergeSegmentationFilterParams

Parameterization class for the MergeSegmentationFilter.

MergeSegmentationFilter

Filter to merge / combine multiple SegmentationImage instances in to one multi-label instance.

Details#

class AddImageFilterParams(images)[source]#

Bases: FilterParams

A filter parameter class for the AddImageFilter class.

Parameters:

images (Union[IntensityImage, SegmentationImage, Tuple[Union[IntensityImage, SegmentationImage], ...]) – The Image instances to add to the provided Subject instance.

class AddImageFilter(warning_on_non_invertible=False)[source]#

Bases: Filter

A filter class to add Image instances to the provided Subject instance.

Note

This filter currently does not support the inverse operation (the removal of the added images). This feature will be added in the future.

static is_invertible()[source]#

Return whether the filter is invertible or not.

Note: This filter currently does not support the inverse operation (the removal of the added images). This feature will be added in the future.

Returns:

False because the addition of Image instances is currently not supported.

Return type:

bool

execute(subject, params)[source]#

Execute the addition procedure.

Parameters:
Returns:

The Subject instance including the added Image instances.

Return type:

Subject

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

Return the provided subject without any processing because the inverse addition procedure (the removal) is currently not supported.

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

  • 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 provided Subject instance.

Return type:

Subject

class RemoveImageByOrganFilterParams(organs)[source]#

Bases: FilterParams

A filter parameter class for the RemoveImageByOrganFilter class.

Parameters:

organs (Sequence[Union[Organ, str]]) – The organs to remove from the provided Subject instance.

class RemoveImageByOrganFilter(warning_on_non_invertible=False)[source]#

Bases: Filter

A filter class to remove SegmentationImage instances from the provided Subject instance. The SegmentationImage instances are identified by their Organ instance.

Note

If multiple SegmentationImage instances exist with the same Organ instance all of them will be removed.

static is_invertible()[source]#

Return whether the filter is invertible or not.

Returns:

False because the removal of SegmentationImage instances is not invertible.

Return type:

bool

execute(subject, params)[source]#

Execute the removal procedure.

Parameters:
Returns:

The Subject instance excluding the removed SegmentationImage instances.

Return type:

Subject

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

Return the provided subject without any processing because the removal procedure is not invertible.

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

  • 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 provided Subject instance.

Return type:

Subject

class RemoveImageByAnnotatorFilterParams(annotators)[source]#

Bases: FilterParams

A filter parameter class for the RemoveImageByAnnotatorFilter class.

Parameters:

annotators (Sequence[Union[Annotator, str]]) – The annotators identifying the SegmentationImage instances to remove from the provided Subject instance.

class RemoveImageByAnnotatorFilter(warning_on_non_invertible=False)[source]#

Bases: Filter

A filter class to remove SegmentationImage instances from the provided Subject instance. The SegmentationImage instances are identified by their Annotator instance.

Note

If multiple SegmentationImage instances exist with the same Annotator instance all of them will be removed.

static is_invertible()[source]#

Return whether the filter is invertible or not.

Returns:

False because the removal of SegmentationImage instances is not invertible.

Return type:

bool

execute(subject, params)[source]#

Execute the removal procedure.

Parameters:
Returns:

The Subject instance excluding the removed SegmentationImage instances.

Return type:

Subject

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

Return the provided subject without any processing because the removal procedure is not invertible.

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

  • 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 provided Subject instance.

Return type:

Subject

class RemoveImageByModalityFilterParams(modalities)[source]#

Bases: FilterParams

A filter parameter class for the RemoveImageByModalityFilter class.

Parameters:

modalities (Sequence[Union[Modality, str]]) – The modalities identifying the IntensityImage instances to remove from the provided Subject instance.

class RemoveImageByModalityFilter(warning_on_non_invertible=False)[source]#

Bases: Filter

A filter class to remove IntensityImage instances from the provided Subject instance. The IntensityImage instances are identified by their Modality instance.

Note

If multiple SegmentationImage instances exist with the same Modality instance all of them will be removed.

static is_invertible()[source]#

Return whether the filter is invertible or not.

Returns:

False because the removal of IntensityImage instances is not invertible.

Return type:

bool

execute(subject, params)[source]#

Execute the removal procedure.

Parameters:
Returns:

The Subject instance excluding the removed IntensityImage instances.

Return type:

Subject

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

Return the provided subject without any processing because the removal procedure is not invertible.

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

  • transform_info (TransformInfo) – The transform information.

  • target_image (Optional[Union[SegmentationImage, IntensityImage]]) – The target image to which the inverse

  • None (transformation should be applied. If) –

  • (default (the inverse transformation is applied to all images) –

  • None).

Returns:

The provided Subject instance.

Return type:

Subject

class MergeSegmentationFilterParams(organs, output_organ_indexes, output_organ, output_annotator, output_orientation=SpatialOrientation.LPS)[source]#

Bases: FilterParams

A filter parameter class for the MergeSegmentationFilter class.

Note

The order of the provided organs determines the merging order. The first organ will be inserted into the resulting segmentation first, the second one second, etc. Therefore, if the segmentations overlap the segmentation of the first organ will be overwritten by the segmentation of the second organ, etc.

Parameters:
  • organs (Sequence[Union[Organ, str]]) – The Organ instances to merge.

  • output_organ_indexes (Sequence[int]) – The indexes of the organs at the output (must be of equal length as organs). If `None is provided the organs will be enumerated from 1 to n (default: None).

  • output_organ (Union[Organ, str]) – The Organ instance of the resulting segmentation.

  • output_annotator (Union[Annotator, str]) – The Annotator instance of the resulting segmentation.

  • output_orientation (Union[SpatialOrientation, str]) – The orientation of the output segmentation (default: LPS).

class MergeSegmentationFilter(warning_on_non_invertible=False)[source]#

Bases: Filter

A filter class for merging multiple SegmentationImage instances into a new SegmentationImage instance assigned to the provided Subject instance.

Note

If the provided SegmentationImage instances are non-binary all non-zero label values will be set to the provided organ index of the corresponding organ. Thus, non-binary segmentations will be treated as binary ones with all non-zero values being considered as foreground.

Note that the merging order is defined by the order of the provided organs. However, the resulting segmentation will contain the organ indexes associated with the provided organs.

The separation of segmentations is technically feasible to some extent. However, in radiotherapy the separation of merged segmentations can have adverse effects because it may lead to corrupted segmentations if segmentations overlap. Therefore, this filter does not provide the inverse procedure.

static is_invertible()[source]#

Returns whether the filter is invertible or not.

Note

The separation of segmentations is technically feasible to some extent. However, in radiotherapy the separation of merged segmentations can have adverse effects because it may lead to corrupted segmentations if segmentations overlap. Therefore, this filter does not provide the inverse procedure.

Returns:

False because the merging of segmentations is not fully invertible.

Return type:

bool

execute(subject, params)[source]#

Execute the merging procedure.

Parameters:
Returns:

The subject with the merged SegmentationImage instance added.

Return type:

Subject

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

Return the provided subject without any processing because the merging procedure is not invertible.

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

  • 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 provided Subject instance.

Return type:

Subject