monai.deploy.operators.DICOMSeriesSelectorOperator¶
- class monai.deploy.operators.DICOMSeriesSelectorOperator(rules='', all_matched=False, *args, **kwargs)[source]¶
Bases:
monai.deploy.core.operator.Operator
This operator selects a list of DICOM Series in a DICOM Study for a given set of selection rules.
This class can be considered a base class, and a derived class can override the ‘filer’ function to with custom logics.
- In its default implementation, this class
selects a series or all matched series within the scope of a study in a list of studies
uses rules defined in JSON string, see below for details
supports DICOM Study and Series module attribute matching, including regex for string types
supports multiple named selections, in the scope of each DICOM study
outputs a list of SutdySelectedSeries objects, as well as a flat list of SelectedSeries (to be deprecated)
- The selection rules are defined in JSON,
attribute “selections” value is a list of selections
each selection has a “name”, and its “conditions” value is a list of matching criteria
each condition has uses the implicit equal operator, except for regex for str type and union for set type
DICOM attribute keywords are used, and only for those defined as DICOMStudy and DICOMSeries properties
An example selection rules: {
- “selections”: [
- {
“name”: “CT Series 1”, “conditions”: {
“StudyDescription”: “(?i)^Spleen”, “Modality”: “(?i)CT”, “SeriesDescription”: “(?i)^No series description|(.*?)”
}
}, {
“name”: “CT Series 2”, “conditions”: {
“Modality”: “CT”, “BodyPartExamined”: “Abdomen”, “SeriesDescription” : “Not to be matched. For illustration only.”
}
}
]
}
Constructor of the base operator.
It creates an instance of Data Store which holds on to all inputs and outputs relavant for this operator.
- Parameters
args – Arguments.
kwargs – Keyword arguments.
Methods
__init__
([rules, all_matched])Constructor of the base operator.
add_input
(label, data_type, storage_type)add_output
(label, data_type, storage_type)compute
(op_input, op_output, context)Performs computation for this operator.
Ensures that the operator is valid.
filter
(selection_rules, dicom_study_list[, …])Selects the series with the given matching rules.
This method gets executed after “compute()” of an operator is called.
This method gets executed before compute() of an operator is called.
Attributes
Gives access to the environment.
Returns the name of this operator.
Retrieves the operator info.
Gives access to the UID of the operator.
- ensure_valid()¶
Ensures that the operator is valid.
This method needs to be executed by add_operator() and add_flow() methods in the compose() method of the application. This sets default values for the operator in the graph if necessary. (e.g., set default value for the operator’s input port, set default value for the operator’s output port, etc.)
- property env: monai.deploy.core.operator.OperatorEnv¶
Gives access to the environment.
This sets a default value for the operator’s environment if not set.
- Return type
OperatorEnv
- Returns
An instance of OperatorEnv.
- filter(selection_rules, dicom_study_list, all_matched=False)[source]¶
Selects the series with the given matching rules.
If rules object is None, all series will be returned with series instance UID as the selection name.
- Simplistic matching is used for demonstration:
Number: exactly matches String: matches case insensitive, if fails then tries RegEx search String array matches as subset, case insensitive
- Parameters
selection_rules (object) – JSON object containing the matching rules.
dicom_study_list (list) – A list of DICOMStudiy objects.
all_matched (bool) – Gets all matched series in a study. Defaults to False for first match only.
- Returns
A list of objects of type StudySelectedSeries.
- Return type
list
- Raises
ValueError – If the selection_rules object does not contain “selections” attribute.
- property name: str¶
Returns the name of this operator.
- Return type
str
- property op_info: monai.deploy.core.operator_info.OperatorInfo¶
Retrieves the operator info.
Args:
- Return type
OperatorInfo
- Returns
An instance of OperatorInfo.
- post_compute()¶
This method gets executed after “compute()” of an operator is called.
This is a post-execution step before the operator is done doing its main action. This needs to be overridden by a base class for any meaningful action.
- pre_compute()¶
This method gets executed before compute() of an operator is called.
This is a preperatory step before the operator executes its main job. This needs to be overridden by a base class for any meaningful action.
- property uid: uuid.UUID¶
Gives access to the UID of the operator.
- Return type
UUID
- Returns
UID of the operator.