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.
Ensures that the operator is valid.
This method gets executed after “compute()” of an operator is called.
This method gets executed before compute() of an operator is called.
Random number generator to generate n digit int, where 1 <= n <= 32.
save_dcm_file
(data_set, file_path[, …])write
(content_text, dicom_series, output_dir)Writes DICOM object
write_common_modules
(dicom_series, …[, …])Writes DICOM object common modules with or without a reference DCIOM Series
Attributes
DCM_EXTENSION
Gives access to the environment.
Returns the name of this operator.
Retrieves the operator info.
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 image object or result content is supported and the selected DICOM series for inference is required, because the generated 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 result object not in the input, and result file not found either.
ValueError – Neither image object nor image file’s folder is in the input, or no selected series.
- 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.
- static random_with_n_digits(n)[source]¶
Random number generator to generate n digit int, where 1 <= n <= 32.
- 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
- static write_common_modules(dicom_series, copy_tags, modality_type, sop_class_uid, model_info=None, equipment_info=None)[source]¶
Writes DICOM object common modules with or without a reference DCIOM Series
Common modules include Study, Patient, Equipment, Series, and SOP common.
- Parameters
dicom_series (DicomSeries) – DicomSeries object encapsulating the original series.
copy_tags (bool) – If true, dicom_series must be provided for copying tags.
modality_type (str) – DICOM Modality Type, e.g. SR.
sop_class_uid (str) – Media Storage SOP Class UID, e.g. “1.2.840.10008.5.1.4.1.1.88.34” for Comprehensive 3D SR IOD.
model_info (MoelInfo) – Object encapsulating model creator, name, version and UID.
equipment_info (EquipmentInfo) – Object encapsulating attributes for DICOM Equipment Module
- Returns
pydicom Dataset
- Raises
ValueError – When dicom_series is not a DICOMSeries object, and new_study is not True.