Skip to content

Commit 7b9c313

Browse files
author
Chris Bridge
committed
Fix imports
1 parent 0a762cb commit 7b9c313

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

monai/deploy/operators/dicom_seg_writer_operator.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import os
1313
from pathlib import Path
1414
from random import randint
15-
from typing import List, Union
15+
from typing import TYPE_CHECKING, List, Union
1616

1717
import numpy as np
1818

@@ -28,6 +28,10 @@
2828
hd, _ = optional_import("highdicom")
2929
sitk, _ = optional_import("SimpleITK")
3030
codes, _ = optional_import("pydicom.sr.codedict", name="codes")
31+
if TYPE_CHECKING:
32+
from highdicom.seg import SegmentDescription
33+
else:
34+
SegmentDescription, _ = optional_import("highdicom.seg", name="SegmentDescription")
3135

3236
import monai.deploy.core as md
3337
from monai.deploy.core import DataPath, ExecutionContext, Image, InputContext, IOType, Operator, OutputContext
@@ -51,7 +55,7 @@ class DICOMSegmentationWriterOperator(Operator):
5155
# Suffix to add to file name to indicate DICOM Seg dcm file.
5256
DICOMSEG_SUFFIX = "-DICOMSEG"
5357

54-
def __init__(self, segment_descriptions: List[hd.seg.SegmentDescription], *args, **kwargs):
58+
def __init__(self, segment_descriptions: List[SegmentDescription], *args, **kwargs):
5559
super().__init__(*args, **kwargs)
5660
"""Instantiates the DICOM Seg Writer instance with optional list of segment label strings.
5761

0 commit comments

Comments
 (0)