Selection Module#
Module: pyradise.fileio.selection
General#
The selection module provides extensible functionality to select appropriate
SeriesInfo instances from a list such that unused data does not need to be
loaded. This is especially useful if more data is provided to your pipeline than there is actually needed.
In this module a SeriesInfoSelector base class is provided and several SeriesInfoSelector
implementations which can be used to select specific SeriesInfo entries according
to the Modality, Organ, or
Annotator. In addition, two SeriesInfoSelector implementations are provided
to exclude all DicomSeriesRegistrationInfo entries and all
DicomSeriesRTSSInfo entries such that no registration is applied to
the data during loading and that no DICOM-RTSS is loaded, respectively.
In order to extend the provided functionality, the SeriesInfoSelector base class can be subclassed.
Class Overview#
The following SeriesInfoSelector classes are provided:
Class |
Description |
|---|---|
Base class for all |
|
A |
|
A |
|
A |
|
A |
|
A |
Details#
- class SeriesInfoSelector[source]#
Bases:
ABCAn abstract base class for all
SeriesInfoSelectorclasses. A selector is used to select a subset ofSeriesInfoentries from a list ofSeriesInfoentries such that unused entries will be excluded from the loading and probable conversion procedures. The aim of using a selector is to improve speed and reduce memory usage while allowing the input directory to contain unused data.- abstract execute(infos=None)[source]#
Perform the selection procedure such that the appropriate
SeriesInfoentries are kept.- Parameters:
infos (Sequence[SeriesInfo]) – The
SeriesInfoentries to select from.- Returns:
The selected
SeriesInfoentries.- Return type:
Tuple[SeriesInfo, …]
- class SeriesInfoSelectorPipeline(selectors)[source]#
Bases:
objectA class for constructing
SeriesInfoSelectorpipelines. A pipeline is a sequence ofSeriesInfoSelectors that are executed sequentially in a given order. The output of one selector is the input of the next selector.- Parameters:
selectors (Sequence[SeriesInfoSelector]) – The
SeriesInfoSelectors of the pipeline in a given order.
- add_selector(selector)[source]#
Add a
SeriesInfoSelectorto the pipeline.- Parameters:
selector (SeriesInfoSelector) – The
SeriesInfoSelectorto add.- Return type:
None
- execute(infos)[source]#
Perform the selection of the
SeriesInfoentries according to theSeriesInfoSelectors specified.- Parameters:
infos (Sequence[SeriesInfo]) – The
SeriesInfoentries to select from.- Returns:
The selected
SeriesInfoentries.- Return type:
Tuple[SeriesInfo, …]
- class ModalityInfoSelector(keep=None)[source]#
Bases:
SeriesInfoSelectorA
SeriesInfoSelectorto remove allIntensityFileSeriesInfoandDicomSeriesImageInfoentries that do not have a matchingModality.- Note:
If a
DicomSeriesImageInfoentry is removed, the associatedDicomSeriesRegistrationInfoentry is also removed because a registration always requires both referenced registration images.- Args:
- keep (Tuple[Union[Modality, str], …]): The
Modalityentries of the
SeriesInfoentries to keep.
- keep (Tuple[Union[Modality, str], …]): The
- execute(infos=None)[source]#
Remove all
IntensityFileSeriesInfoandDicomSeriesImageInfoentries that do not contain one of the specifiedModalityentries.- Parameters:
infos (Sequence[SeriesInfo]) – The
SeriesInfoentries to select from.- Returns:
The selected
SeriesInfoentries.- Return type:
Tuple[SeriesInfo, …]
- class OrganInfoSelector(keep=None)[source]#
Bases:
SeriesInfoSelectorA
SeriesInfoSelectorto remove allSegmentationFileSeriesInfoentries that do not have a matchingOrgan.Important
This selector does not remove
DicomSeriesRTSSInfoentries because a DICOM-RTSS contains multiple organs and the information about the organs is not retrieved before loading.- Parameters:
keep (Tuple[Union[Organ, str], ...]) – The
Organentries of theSeriesInfoentries to keep.
- execute(infos=None)[source]#
Remove all
SegmentationFileSeriesInfoentries that do not contain one of the specifiedOrganentries.- Parameters:
infos (Sequence[SeriesInfo]) – The
SeriesInfoentries to select from.- Returns:
The selected
SeriesInfoentries.- Return type:
Tuple[SeriesInfo, …]
- class AnnotatorInfoSelector(keep=None)[source]#
Bases:
SeriesInfoSelectorA
SeriesInfoSelectorto remove allSegmentationFileSeriesInfoandDicomSeriesRTSSInfoentries that do not have a matchingAnnotator.- Parameters:
keep (Tuple[Union[Annotator, str], ...]) – The
Annotatorentries of theSeriesInfoentries to keep.
- execute(infos=None)[source]#
Remove all
SegmentationFileSeriesInfoandDicomSeriesRTSSInfoentries that do not contain one of the specifiedAnnotatorentries.- Parameters:
infos (Sequence[SeriesInfo]) – The
SeriesInfoentries to select from.- Returns:
The selected
SeriesInfoentries.- Return type:
Tuple[SeriesInfo, …]
- class NoRegistrationInfoSelector[source]#
Bases:
SeriesInfoSelectorA
SeriesInfoSelectorto remove allDicomSeriesRegistrationInfoentries such that no registration is applied during loading.- execute(infos=None)[source]#
Remove all
DicomSeriesRegistrationInfoentries from the providedSeriesInfoentries.- Parameters:
infos (Tuple[SeriesInfo, ...]) – The
SeriesInfoentries to select from.- Returns:
The selected
SeriesInfoentries.- Return type:
Sequence[SeriesInfo]
- class NoRTSSInfoSelector[source]#
Bases:
SeriesInfoSelectorA
SeriesInfoSelectorto remove allDicomSeriesRTSSInfoentries such that all DICOM-RTSS data is excluded from loading.- execute(infos=None)[source]#
Remove all
DicomSeriesRTSSInfoentries from the providedSeriesInfoentries.- Parameters:
infos (Sequence[SeriesInfo]) – The
SeriesInfoentries to select from.- Returns:
The selected
SeriesInfoentries.- Return type:
Tuple[SeriesInfo, …]