monai.deploy.operators.DICOMTextSRWriterOperator

class monai.deploy.operators.DICOMTextSRWriterOperator(copy_tags, model_info, equipment_info=None, custom_tags=None, *args, **kwargs)[source]

Bases: monai.deploy.core.operator.Operator

Class to write DICOM SR SOP Instance for AI textual result in memory or in a file.

Parameters
  • copy_tags (bool) – True for copying DICOM attributes from a provided DICOMSeries.

  • model_info (ModelInfo) – Object encapsulating model creator, name, version and UID.

  • equipment_info (EquipmentInfo, optional) – Object encapsulating info for DICOM Equipment Module. Defaults to None.

  • custom_tags (Dict[str, str], optional) – Dictionary for setting custom DICOM tags using Keywords and str values only. Defaults to None.

Raises

ValueError – If copy_tags is true and no DICOMSeries object provided, or if result cannot be found either in memory or from file.

Methods

__init__(copy_tags, model_info[, …])

Class to write DICOM SR SOP Instance for AI textual result in memory or in a file.

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 and handles I/O.

ensure_valid()

Ensures that the operator is valid.

post_compute()

This method gets executed after “compute()” of an operator is called.

pre_compute()

This method gets executed before compute() of an operator is called.

write(content_text, dicom_series, output_dir)

Writes DICOM object

Attributes

DCM_EXTENSION

env

Gives access to the environment.

name

Returns the name of this operator.

op_info

Retrieves the operator info.

uid

Gives access to the UID of the operator.

__init__(copy_tags, model_info, equipment_info=None, custom_tags=None, *args, **kwargs)[source]

Class to write DICOM SR SOP Instance for AI textual result in memory or in a file.

Parameters
  • copy_tags (bool) – True for copying DICOM attributes from a provided DICOMSeries.

  • model_info (ModelInfo) – Object encapsulating model creator, name, version and UID.

  • equipment_info (EquipmentInfo, optional) – Object encapsulating info for DICOM Equipment Module. Defaults to None.

  • custom_tags (Dict[str, str], optional) – Dictionary for setting custom DICOM tags using Keywords and str values only. Defaults to None.

Raises

ValueError – If copy_tags is true and no DICOMSeries object provided, or if result cannot be found either in memory or from file.

compute(op_input, op_output, context)[source]

Performs computation for this operator and handles I/O.

For now, only a single result content is supported, which could be in memory or an accessible file. The DICOM series used during inference is optional, but is required if the copy_tags is true indicating the generated DICOM object needs to copy study level metadata.

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 result object not in the input, and result file not found either.

  • ValueError – Content object and file path not in the inputs, or no DICOM series when required.

  • IOError – If the input content is blank.

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.

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.

write(content_text, dicom_series, output_dir)[source]

Writes DICOM object

Parameters
  • content_file (str) – file containing the contents

  • dicom_series (DicomSeries) – DicomSeries object encapsulating the original series.

  • model_info (MoelInfo) – Object encapsulating model creator, name, version and UID.

Returns

PyDicom Dataset