Skip to content

Commit 42bec18

Browse files
authored
Merge pull request #401 from Project-MONAI/seg_add_empty_frames_omit
Expose option to omit empty frames
2 parents 3a68559 + a8a1d8b commit 42bec18

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

monai/deploy/operators/dicom_seg_writer_operator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def __init__(
172172
self,
173173
segment_descriptions: List[SegmentDescription],
174174
custom_tags: Optional[Dict[str, str]] = None,
175+
omit_empty_frames: bool = True,
175176
*args,
176177
**kwargs,
177178
):
@@ -192,12 +193,15 @@ def __init__(
192193
Args:
193194
segment_descriptions: List[SegmentDescription]
194195
Object encapsulating the description of each segment present in the segmentation.
195-
custom_tags: OptonalDict[str, str], optional
196+
custom_tags: Optional[Dict[str, str]], optional
196197
Dictionary for setting custom DICOM tags using Keywords and str values only
198+
omit_empty_frames: bool, optional
199+
Whether to omit frames that contain no segmented pixels from the output segmentation.
197200
"""
198201

199202
self._seg_descs = [sd.to_segment_description(n) for n, sd in enumerate(segment_descriptions, 1)]
200203
self._custom_tags = custom_tags
204+
self._omit_empty_frames = omit_empty_frames
201205

202206
def compute(self, op_input: InputContext, op_output: OutputContext, context: ExecutionContext):
203207
"""Performs computation for this operator and handles I/O.
@@ -290,6 +294,7 @@ def create_dicom_seg(self, image: np.ndarray, dicom_series: DICOMSeries, output_
290294
manufacturer_model_name="MONAI Deploy App SDK",
291295
software_versions=version_str,
292296
device_serial_number="0000",
297+
omit_empty_frames=self._omit_empty_frames,
293298
)
294299

295300
# Adding a few tags that are not in the Dataset

0 commit comments

Comments
 (0)