13
13
from pathlib import Path
14
14
15
15
from livertumor_seg_operator import LiverTumorSegOperator
16
-
17
- # Required for setting SegmentDescription attributes. Direct import as this is not part of App SDK package.
18
- from pydicom .sr .codedict import codes
16
+ from pydicom .sr .codedict import codes # Required for setting SegmentDescription attributes.
19
17
20
18
from monai .deploy .conditions import CountCondition
21
19
from monai .deploy .core import AppContext , Application
26
24
from monai .deploy .operators .dicom_series_to_volume_operator import DICOMSeriesToVolumeOperator
27
25
from monai .deploy .operators .stl_conversion_operator import STLConversionOperator
28
26
29
- # from monai.deploy.operators.publisher_operator import PublisherOperator
30
-
31
- # This is a sample series selection rule in JSON, simply selecting CT series.
32
- # If the study has more than 1 CT series, then all of them will be selected.
33
- # Please see more detail in DICOMSeriesSelectorOperator.
34
- # For list of string values, e.g. "ImageType": ["PRIMARY", "ORIGINAL"], it is a match if all elements
35
- # are all in the multi-value attribute of the DICOM series.
36
-
37
- Sample_Rules_Text = """
38
- {
39
- "selections": [
40
- {
41
- "name": "CT Series",
42
- "conditions": {
43
- "Modality": "(?i)CT",
44
- "ImageType": ["PRIMARY", "ORIGINAL"],
45
- "PhotometricInterpretation": "MONOCHROME2"
46
- }
47
- }
48
- ]
49
- }
50
- """
27
+ # This sample example completes the processing of a DICOM series with around 600 instances within 45 seconds,
28
+ # and time reduces to about 23 seconds if the STL generation is disabled,
29
+ # on a desktop with Ubuntu 20.04, 32GB of RAM, and a Nvidia GPU GV100 with 32GB of memory.
51
30
52
31
53
32
# @resource(cpu=1, gpu=1, memory="7Gi")
54
- # pip_packages can be a string that is a path(str) to requirements.txt file or a list of packages.
55
- # The MONAI pkg is not required by this class, instead by the included operators.
56
33
class AILiverTumorApp (Application ):
57
34
def __init__ (self , * args , ** kwargs ):
58
35
"""Creates an application instance."""
@@ -62,9 +39,9 @@ def __init__(self, *args, **kwargs):
62
39
63
40
def run (self , * args , ** kwargs ):
64
41
# This method calls the base class to run. Can be omitted if simply calling through.
65
- self ._logger .debug (f"Begin { self .run .__name__ } " )
42
+ self ._logger .info (f"Begin { self .run .__name__ } " )
66
43
super ().run (* args , ** kwargs )
67
- self ._logger .debug (f"End { self .run .__name__ } " )
44
+ self ._logger .info (f"End { self .run .__name__ } " )
68
45
69
46
def compose (self ):
70
47
"""Creates the app specific operators and chain them up in the processing DAG."""
@@ -88,7 +65,7 @@ def compose(self):
88
65
# self, model_path=model_path, output_folder=app_output_path, name="seg_op"
89
66
# )
90
67
91
- # Create the publisher operator
68
+ # Create the surface mesh STL conversion operator
92
69
stl_op = STLConversionOperator (self , output_file = app_output_path .joinpath ("stl/mesh.stl" ), name = "stl_op" )
93
70
94
71
# Create DICOM Seg writer providing the required segment description for each segment with
@@ -144,6 +121,27 @@ def compose(self):
144
121
self ._logger .info (f"End { self .compose .__name__ } " )
145
122
146
123
124
+ # This is a sample series selection rule in JSON, simply selecting CT series.
125
+ # If the study has more than 1 CT series, then all of them will be selected.
126
+ # Please see more detail in DICOMSeriesSelectorOperator.
127
+ # For list of string values, e.g. "ImageType": ["PRIMARY", "ORIGINAL"], it is a match if all elements
128
+ # are all in the multi-value attribute of the DICOM series.
129
+
130
+ Sample_Rules_Text = """
131
+ {
132
+ "selections": [
133
+ {
134
+ "name": "CT Series",
135
+ "conditions": {
136
+ "Modality": "(?i)CT",
137
+ "ImageType": ["PRIMARY", "ORIGINAL"],
138
+ "PhotometricInterpretation": "MONOCHROME2"
139
+ }
140
+ }
141
+ ]
142
+ }
143
+ """
144
+
147
145
if __name__ == "__main__" :
148
146
# Creates the app and test it standalone. When running is this mode, please note the following:
149
147
# -m <model file>, for model file path
0 commit comments