monai.deploy.operators.DICOMSegmentationWriterOperator¶
- class monai.deploy.operators.DICOMSegmentationWriterOperator(fragment, *args, segment_descriptions, output_folder, custom_tags=None, **kwargs)[source]¶
Bases:
holoscan.core.Operator
This operator writes out a DICOM Segmentation Part 10 file to disk
- Named inputs:
seg_image: The Image object of the segment. study_selected_series_list: The DICOM series from which the segment was derived. output_folder: Optional, folder for file output, overriding what is set on the object.
- Named output:
None
- File output:
Generated DICOM instance file in the output folder set on this object or optional input.
Instantiates the DICOM Seg Writer instance with optional list of segment label strings.
Each unique, non-zero integer value in the segmentation image represents a segment that must be described by an item of the segment descriptions list with the corresponding segment number. Items in the list must be arranged starting at segment number 1 and increasing by 1.
For example, in the CT Spleen Segmentation application, the whole image background has a value of 0, and the Spleen segment of value 1. This then only requires the caller to pass in a list containing a segment description, which is used as label for the Spleen in the DICOM Seg instance.
Note: this interface is subject to change. It is planned that a new object will encapsulate the segment label information, including label value, name, description etc.
- Parameters
fragment (Fragment) – An instance of the Application class which is derived from Fragment.
segment_descriptions (
List
[SegmentDescription
]) – List[SegmentDescription] Object encapsulating the description of each segment present in the segmentation.output_folder (
Path
) – Folder for file output, overridden by named input on compute. Defaults to current working dir’s child folder, output.custom_tags (
Optional
[Dict
[str
,str
]]) – OptonalDict[str, str], optional Dictionary for setting custom DICOM tags using Keywords and str values only
Methods
__init__
(fragment, *args, …[, custom_tags])Instantiates the DICOM Seg Writer instance with optional list of segment label strings.
add_arg
(*args, **kwargs)Overloaded function.
compute
(op_input, op_output, context)Performs computation for this operator and handles I/O.
create_dicom_seg
(image, dicom_series, output_dir)initialize
(self)Operator initialization method.
process_images
(image, …)select_input_file
(input_folder[, extensions])Select the input files based on supported extensions.
setup
(spec)Set up the named input(s), and output(s) if applicable, aka ports.
start
(self)Operator start method.
stop
(self)Operator stop method.
Attributes
DCM_EXTENSION
DEFAULT_OUTPUT_FOLDER
SUPPORTED_EXTENSIONS
The list of arguments associated with the component.
Conditions associated with the operator.
YAML formatted string describing the operator.
The fragment that the operator belongs to.
The identifier of the component.
The name of the operator.
The operator type.
Resources associated with the operator.
spec
- class OperatorType(self: holoscan.core._core.Operator.OperatorType, value: int) None ¶
Bases:
pybind11_builtins.pybind11_object
Members:
NATIVE
GXF
- property name¶
- __init__(fragment, *args, segment_descriptions, output_folder, custom_tags=None, **kwargs)[source]¶
Instantiates the DICOM Seg Writer instance with optional list of segment label strings.
Each unique, non-zero integer value in the segmentation image represents a segment that must be described by an item of the segment descriptions list with the corresponding segment number. Items in the list must be arranged starting at segment number 1 and increasing by 1.
For example, in the CT Spleen Segmentation application, the whole image background has a value of 0, and the Spleen segment of value 1. This then only requires the caller to pass in a list containing a segment description, which is used as label for the Spleen in the DICOM Seg instance.
Note: this interface is subject to change. It is planned that a new object will encapsulate the segment label information, including label value, name, description etc.
- Parameters
fragment (Fragment) – An instance of the Application class which is derived from Fragment.
segment_descriptions (
List
[SegmentDescription
]) – List[SegmentDescription] Object encapsulating the description of each segment present in the segmentation.output_folder (
Path
) – Folder for file output, overridden by named input on compute. Defaults to current working dir’s child folder, output.custom_tags (
Optional
[Dict
[str
,str
]]) – OptonalDict[str, str], optional Dictionary for setting custom DICOM tags using Keywords and str values only
- add_arg(*args, **kwargs)¶
Overloaded function.
add_arg(self: holoscan.core._core.Component, arg: holoscan.core._core.Arg) -> None
Add an argument to the component.
add_arg(self: holoscan.core._core.Component, arg: holoscan.core._core.ArgList) -> None
Add a list of arguments to the component.
- property args¶
The list of arguments associated with the component.
arglist : holoscan.core.ArgList
- compute(op_input, op_output, context)[source]¶
Performs computation for this operator and handles I/O.
For now, only a single segmentation image object or file is supported and the selected DICOM series for inference is required, because the DICOM Seg IOD needs to refer to original instance. When there are multiple selected series in the input, the first series’ containing study will be used for retrieving DICOM Study module attributes, e.g. StudyInstanceUID.
- Raises
FileNotFoundError – When image object not in the input, and segmentation image file not found either.
ValueError – Neither image object nor image file’s folder is in the input, or no selected series.
- property conditions¶
Conditions associated with the operator.
- property description¶
YAML formatted string describing the operator.
- property fragment¶
The fragment that the operator belongs to.
name : holoscan.core.Fragment
- property id¶
The identifier of the component.
The identifier is initially set to -1, and will become a valid value when the component is initialized.
With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.
id : int
- initialize(self: holoscan.core._core.Operator) None ¶
Operator initialization method.
- property name¶
The name of the operator.
name : str
- property operator_type¶
The operator type.
holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.
- property resources¶
Resources associated with the operator.
- select_input_file(input_folder, extensions=['.nii', '.nii.gz', '.mhd'])[source]¶
Select the input files based on supported extensions.
- Parameters
input_folder (string) – the path of the folder containing the input file(s)
extensions (array) – the supported file formats identified by the extensions.
- Returns
The path of the selected file ext (string): The extension of the selected file
- Return type
file_path (string)
- setup(spec)[source]¶
Set up the named input(s), and output(s) if applicable, aka ports.
- Parameters
spec (OperatorSpec) – The Operator specification for inputs and outputs etc.
- start(self: holoscan.core._core.Operator) None ¶
Operator start method.
- stop(self: holoscan.core._core.Operator) None ¶
Operator stop method.