Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose option to omit empty frames #401

Merged
merged 1 commit into from Dec 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion monai/deploy/operators/dicom_seg_writer_operator.py
Expand Up @@ -172,6 +172,7 @@ def __init__(
self,
segment_descriptions: List[SegmentDescription],
custom_tags: Optional[Dict[str, str]] = None,
omit_empty_frames: bool = True,
*args,
**kwargs,
):
Expand All @@ -192,12 +193,15 @@ def __init__(
Args:
segment_descriptions: List[SegmentDescription]
Object encapsulating the description of each segment present in the segmentation.
custom_tags: OptonalDict[str, str], optional
custom_tags: Optional[Dict[str, str]], optional
Dictionary for setting custom DICOM tags using Keywords and str values only
omit_empty_frames: bool, optional
Whether to omit frames that contain no segmented pixels from the output segmentation.
"""

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

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

# Adding a few tags that are not in the Dataset
Expand Down