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

SeriesInfoSelector

Base class for all SeriesInfoSelector classes.

ModalityInfoSelector

A SeriesInfoSelector to keep SeriesInfo entries with specific Modality s.

OrganInfoSelector

A SeriesInfoSelector to keep SeriesInfo entries with specific Organ s.

AnnotatorInfoSelector

A SeriesInfoSelector to keep SeriesInfo entries with specific Annotator s.

NoRegistrationInfoSelector

A SeriesInfoSelector to exclude all DicomSeriesRegistrationInfo entries.

NoRTSSInfoSelector

A SeriesInfoSelector to exclude all DicomSeriesRTSSInfo entries.

Details#

class SeriesInfoSelector[source]#

Bases: ABC

An abstract base class for all SeriesInfoSelector classes. A selector is used to select a subset of SeriesInfo entries from a list of SeriesInfo entries 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 SeriesInfo entries are kept.

Parameters:

infos (Sequence[SeriesInfo]) – The SeriesInfo entries to select from.

Returns:

The selected SeriesInfo entries.

Return type:

Tuple[SeriesInfo, …]

class SeriesInfoSelectorPipeline(selectors)[source]#

Bases: object

A class for constructing SeriesInfoSelector pipelines. A pipeline is a sequence of SeriesInfoSelector s 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 SeriesInfoSelector s of the pipeline in a given order.

add_selector(selector)[source]#

Add a SeriesInfoSelector to the pipeline.

Parameters:

selector (SeriesInfoSelector) – The SeriesInfoSelector to add.

Return type:

None

execute(infos)[source]#

Perform the selection of the SeriesInfo entries according to the SeriesInfoSelector s specified.

Parameters:

infos (Sequence[SeriesInfo]) – The SeriesInfo entries to select from.

Returns:

The selected SeriesInfo entries.

Return type:

Tuple[SeriesInfo, …]

class ModalityInfoSelector(keep=None)[source]#

Bases: SeriesInfoSelector

A SeriesInfoSelector to remove all IntensityFileSeriesInfo and DicomSeriesImageInfo entries that do not have a matching Modality.

Note:

If a DicomSeriesImageInfo entry is removed, the associated DicomSeriesRegistrationInfo entry is also removed because a registration always requires both referenced registration images.

Args:
keep (Tuple[Union[Modality, str], …]): The Modality entries of

the SeriesInfo entries to keep.

execute(infos=None)[source]#

Remove all IntensityFileSeriesInfo and DicomSeriesImageInfo entries that do not contain one of the specified Modality entries.

Parameters:

infos (Sequence[SeriesInfo]) – The SeriesInfo entries to select from.

Returns:

The selected SeriesInfo entries.

Return type:

Tuple[SeriesInfo, …]

class OrganInfoSelector(keep=None)[source]#

Bases: SeriesInfoSelector

A SeriesInfoSelector to remove all SegmentationFileSeriesInfo entries that do not have a matching Organ.

Important

This selector does not remove DicomSeriesRTSSInfo entries 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 Organ entries of the SeriesInfo entries to keep.

execute(infos=None)[source]#

Remove all SegmentationFileSeriesInfo entries that do not contain one of the specified Organ entries.

Parameters:

infos (Sequence[SeriesInfo]) – The SeriesInfo entries to select from.

Returns:

The selected SeriesInfo entries.

Return type:

Tuple[SeriesInfo, …]

class AnnotatorInfoSelector(keep=None)[source]#

Bases: SeriesInfoSelector

A SeriesInfoSelector to remove all SegmentationFileSeriesInfo and DicomSeriesRTSSInfo entries that do not have a matching Annotator.

Parameters:

keep (Tuple[Union[Annotator, str], ...]) – The Annotator entries of the SeriesInfo entries to keep.

execute(infos=None)[source]#

Remove all SegmentationFileSeriesInfo and DicomSeriesRTSSInfo entries that do not contain one of the specified Annotator entries.

Parameters:

infos (Sequence[SeriesInfo]) – The SeriesInfo entries to select from.

Returns:

The selected SeriesInfo entries.

Return type:

Tuple[SeriesInfo, …]

class NoRegistrationInfoSelector[source]#

Bases: SeriesInfoSelector

A SeriesInfoSelector to remove all DicomSeriesRegistrationInfo entries such that no registration is applied during loading.

execute(infos=None)[source]#

Remove all DicomSeriesRegistrationInfo entries from the provided SeriesInfo entries.

Parameters:

infos (Tuple[SeriesInfo, ...]) – The SeriesInfo entries to select from.

Returns:

The selected SeriesInfo entries.

Return type:

Sequence[SeriesInfo]

class NoRTSSInfoSelector[source]#

Bases: SeriesInfoSelector

A SeriesInfoSelector to remove all DicomSeriesRTSSInfo entries such that all DICOM-RTSS data is excluded from loading.

execute(infos=None)[source]#

Remove all DicomSeriesRTSSInfo entries from the provided SeriesInfo entries.

Parameters:

infos (Sequence[SeriesInfo]) – The SeriesInfo entries to select from.

Returns:

The selected SeriesInfo entries.

Return type:

Tuple[SeriesInfo, …]