Skip to content

Commit d62dd39

Browse files
committed
Make DICOM PDF and SR writer consistent
Signed-off-by: M Q <mingmelvinq@nvidia.com>
1 parent 91ffbdb commit d62dd39

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

monai/deploy/operators/dicom_encapsulated_pdf_writer_operator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ def __init__(
5858
fragment: Fragment,
5959
*args,
6060
output_folder: Union[str, Path],
61-
copy_tags: bool,
6261
model_info: ModelInfo,
6362
equipment_info: Optional[EquipmentInfo] = None,
63+
copy_tags: bool = True,
6464
custom_tags: Optional[Dict[str, str]] = None,
6565
**kwargs,
6666
):
@@ -69,7 +69,7 @@ def __init__(
6969
Args:
7070
fragment (Fragment): An instance of the Application class which is derived from Fragment.
7171
output_folder (str or Path): The folder for saving the generated DICOM instance file.
72-
copy_tags (bool): True for copying DICOM attributes from a provided DICOMSeries.
72+
copy_tags (bool): True, default, for copying DICOM attributes from a provided DICOMSeries.
7373
If True and no DICOMSeries obj provided, runtime exception is thrown.
7474
model_info (ModelInfo): Object encapsulating model creator, name, version and UID.
7575
equipment_info (EquipmentInfo, optional): Object encapsulating info for DICOM Equipment Module.
@@ -151,10 +151,11 @@ def compute(self, op_input, op_output, context):
151151
if not pdf_bytes or not len(pdf_bytes.strip()):
152152
raise IOError("Input is read but blank.")
153153

154+
study_selected_series_list = None
154155
try:
155156
study_selected_series_list = op_input.receive(self.input_name_dcm_series)
156157
except Exception:
157-
study_selected_series_list = None
158+
pass
158159

159160
dicom_series = None # It can be None if not to copy_tags.
160161
if self.copy_tags:

monai/deploy/operators/dicom_text_sr_writer_operator.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ def __init__(
5757
fragment: Fragment,
5858
*args,
5959
output_folder: Union[str, Path],
60-
copy_tags: bool,
6160
model_info: ModelInfo,
61+
copy_tags: bool = True,
6262
equipment_info: Optional[EquipmentInfo] = None,
6363
custom_tags: Optional[Dict[str, str]] = None,
6464
**kwargs,
@@ -67,7 +67,8 @@ def __init__(
6767
6868
Args:
6969
output_folder (str or Path): The folder for saving the generated DICOM instance file.
70-
copy_tags (bool): True for copying DICOM attributes from a provided DICOMSeries.
70+
copy_tags (bool): True, default, for copying DICOM attributes from a provided DICOMSeries.
71+
If True and no DICOMSeries obj provided, runtime exception is thrown.
7172
model_info (ModelInfo): Object encapsulating model creator, name, version and UID.
7273
equipment_info (EquipmentInfo, optional): Object encapsulating info for DICOM Equipment Module.
7374
Defaults to None.
@@ -120,7 +121,7 @@ def setup(self, spec: OperatorSpec):
120121
"""
121122

122123
spec.input(self.input_name_text)
123-
spec.input(self.input_name_dcm_series)
124+
spec.input(self.input_name_dcm_series).condition(ConditionType.NONE) # Optional input
124125

125126
def compute(self, op_input, op_output, context):
126127
"""Performs computation for this operator and handles I/O.
@@ -143,10 +144,11 @@ def compute(self, op_input, op_output, context):
143144
if not result_text:
144145
raise IOError("Input is read but blank.")
145146

147+
study_selected_series_list = None
146148
try:
147149
study_selected_series_list = op_input.receive(self.input_name_dcm_series)
148150
except Exception:
149-
study_selected_series_list = None
151+
pass
150152

151153
dicom_series = None # It can be None if not to copy_tags.
152154
if self.copy_tags:

0 commit comments

Comments
 (0)