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 |
|---|---|
Parameterization class for the |
|
Parameterization class for the |
|
Filter to remove a |
|
Parameterization class for the |
|
Filter to remove a |
|
Parameterization class for the |
|
Filter to remove a |
|
Parameterization class for the |
|
Filter to merge / combine multiple |
Details#
- class AddImageFilterParams(images)[source]#
Bases:
FilterParamsA filter parameter class for the
AddImageFilterclass.- Parameters:
images (Union[IntensityImage, SegmentationImage, Tuple[Union[IntensityImage, SegmentationImage], ...]) – The
Imageinstances to add to the providedSubjectinstance.
- class AddImageFilter(warning_on_non_invertible=False)[source]#
Bases:
FilterA filter class to add
Imageinstances to the providedSubjectinstance.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
Imageinstances is currently not supported.- Return type:
bool
- 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:
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
Subjectinstance.- Return type:
- class RemoveImageByOrganFilterParams(organs)[source]#
Bases:
FilterParamsA filter parameter class for the
RemoveImageByOrganFilterclass.
- class RemoveImageByOrganFilter(warning_on_non_invertible=False)[source]#
Bases:
FilterA filter class to remove
SegmentationImageinstances from the providedSubjectinstance. TheSegmentationImageinstances are identified by theirOrganinstance.Note
If multiple
SegmentationImageinstances exist with the sameOrganinstance all of them will be removed.- static is_invertible()[source]#
Return whether the filter is invertible or not.
- Returns:
False because the removal of
SegmentationImageinstances is not invertible.- Return type:
bool
- execute(subject, params)[source]#
Execute the removal procedure.
- Parameters:
subject (Subject) – The
Subjectinstance to remove the appropriateSegmentationImageinstances from.params (RemoveImageByOrganFilterParams) – The filter parameters.
- Returns:
The
Subjectinstance excluding the removedSegmentationImageinstances.- Return type:
- execute_inverse(subject, transform_info, target_image=None)[source]#
Return the provided subject without any processing because the removal procedure is not invertible.
- Parameters:
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
Subjectinstance.- Return type:
- class RemoveImageByAnnotatorFilterParams(annotators)[source]#
Bases:
FilterParamsA filter parameter class for the
RemoveImageByAnnotatorFilterclass.- Parameters:
annotators (Sequence[Union[Annotator, str]]) – The annotators identifying the
SegmentationImageinstances to remove from the providedSubjectinstance.
- class RemoveImageByAnnotatorFilter(warning_on_non_invertible=False)[source]#
Bases:
FilterA filter class to remove
SegmentationImageinstances from the providedSubjectinstance. TheSegmentationImageinstances are identified by theirAnnotatorinstance.Note
If multiple
SegmentationImageinstances exist with the sameAnnotatorinstance all of them will be removed.- static is_invertible()[source]#
Return whether the filter is invertible or not.
- Returns:
False because the removal of
SegmentationImageinstances is not invertible.- Return type:
bool
- execute(subject, params)[source]#
Execute the removal procedure.
- Parameters:
subject (Subject) – The
Subjectinstance to remove the appropriateSegmentationImageinstances from.params (RemoveImageByAnnotatorFilterParams) – The filter parameters.
- Returns:
The
Subjectinstance excluding the removedSegmentationImageinstances.- Return type:
- execute_inverse(subject, transform_info, target_image=None)[source]#
Return the provided subject without any processing because the removal procedure is not invertible.
- Parameters:
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
Subjectinstance.- Return type:
- class RemoveImageByModalityFilterParams(modalities)[source]#
Bases:
FilterParamsA filter parameter class for the
RemoveImageByModalityFilterclass.- Parameters:
modalities (Sequence[Union[Modality, str]]) – The modalities identifying the
IntensityImageinstances to remove from the providedSubjectinstance.
- class RemoveImageByModalityFilter(warning_on_non_invertible=False)[source]#
Bases:
FilterA filter class to remove
IntensityImageinstances from the providedSubjectinstance. TheIntensityImageinstances are identified by theirModalityinstance.Note
If multiple
SegmentationImageinstances exist with the sameModalityinstance all of them will be removed.- static is_invertible()[source]#
Return whether the filter is invertible or not.
- Returns:
False because the removal of
IntensityImageinstances is not invertible.- Return type:
bool
- execute(subject, params)[source]#
Execute the removal procedure.
- Parameters:
subject (Subject) – The
Subjectinstance to remove the appropriateIntensityImageinstances from.params (RemoveImageByModalityFilterParams) – The filter parameters.
- Returns:
The
Subjectinstance excluding the removedIntensityImageinstances.- Return type:
- execute_inverse(subject, transform_info, target_image=None)[source]#
Return the provided subject without any processing because the removal procedure is not invertible.
- Parameters:
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
Subjectinstance.- Return type:
- class MergeSegmentationFilterParams(organs, output_organ_indexes, output_organ, output_annotator, output_orientation=SpatialOrientation.LPS)[source]#
Bases:
FilterParamsA filter parameter class for the
MergeSegmentationFilterclass.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
Organinstances to merge.output_organ_indexes (Sequence[int]) – The indexes of the organs at the output (must be of equal length as organs). If
`Noneis provided the organs will be enumerated from 1 to n (default: None).output_organ (Union[Organ, str]) – The
Organinstance of the resulting segmentation.output_annotator (Union[Annotator, str]) – The
Annotatorinstance 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:
FilterA filter class for merging multiple
SegmentationImageinstances into a newSegmentationImageinstance assigned to the providedSubjectinstance.Note
If the provided
SegmentationImageinstances 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:
subject (Subject) – The
Subjectinstance containing the segmentations to merge.params (MergeSegmentationFilterParams) – The filter parameters.
- Returns:
The subject with the merged
SegmentationImageinstance added.- Return type:
- execute_inverse(subject, transform_info, target_image=None)[source]#
Return the provided subject without any processing because the merging procedure is not invertible.
- Parameters:
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
Subjectinstance.- Return type: