monai.deploy.operators.DICOMSegmentationWriterOperator

class monai.deploy.operators.DICOMSegmentationWriterOperator(fragment, *args, segment_descriptions, output_folder, custom_tags=None, omit_empty_frames=True, **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]]) – Optonal[Dict[str, str]], optional Dictionary for setting custom DICOM tags using Keywords and str values only

  • omit_empty_frames (bool) – bool, optional Whether to omit frames that contain no segmented pixels from the output segmentation. Defaults to True, same as the underlying lib API.

Methods

__init__(fragment, *args, …[, …])

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()

Default implementation of initialize

process_images(image, …)

resource(self, name)

Resources associated with the operator.

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()

Default implementation of start

stop()

Default implementation of stop

Attributes

DCM_EXTENSION

DEFAULT_OUTPUT_FOLDER

SUPPORTED_EXTENSIONS

args

The list of arguments associated with the component.

conditions

Conditions associated with the operator.

description

YAML formatted string describing the operator.

fragment

The fragment (holoscan.core.Fragment) that the operator belongs to.

id

The identifier of the component.

name

The name of the operator.

operator_type

The operator type.

resources

Resources associated with the operator.

spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

class OperatorType(self: holoscan.core._core.Operator.OperatorType, value: int) None

Bases: pybind11_builtins.pybind11_object

Enum class for operator types used by the executor.

  • NATIVE: Native operator.

  • GXF: GXF operator.

  • VIRTUAL: Virtual operator. (for internal use, not intended for use by application authors)

Members:

NATIVE

GXF

VIRTUAL

property name
__init__(fragment, *args, segment_descriptions, output_folder, custom_tags=None, omit_empty_frames=True, **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]]) – Optonal[Dict[str, str]], optional Dictionary for setting custom DICOM tags using Keywords and str values only

  • omit_empty_frames (bool) – bool, optional Whether to omit frames that contain no segmented pixels from the output segmentation. Defaults to True, same as the underlying lib API.

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.Operator, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.Operator, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

  1. add_arg(self: holoscan.core._core.Operator, **kwargs) -> None

Add arguments to the component via Python kwargs.

  1. add_arg(self: holoscan.core._core.Operator, arg: holoscan.core._core.Condition) -> None

  2. add_arg(self: holoscan.core._core.Operator, arg: holoscan.core._core.Resource) -> None

Add a condition or resource to the Operator.

This can be used to add a condition or resource to an operator after it has already been constructed.

argholoscan.core.Condition or holoscan.core.Resource

The condition or resource to add.

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 (holoscan.core.Fragment) that the operator belongs to.

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()

Default implementation of initialize

property name

The name of the operator.

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.

resource(self: holoscan.core._core.Operator, name: str) Optional[object]

Resources associated with the operator.

name : str The name of the resource to retrieve

holoscan.core.Resource or None

The resource with the given name. If no resource with the given name is found, None is returned.

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.

property spec

The operator spec (holoscan.core.OperatorSpec) associated with the operator.

start()

Default implementation of start

stop()

Default implementation of stop