Skip to content

Commit 6ffd627

Browse files
auto updates (#399)
Signed-off-by: monai-bot <monai.miccai2019@gmail.com> Signed-off-by: monai-bot <monai.miccai2019@gmail.com> Co-authored-by: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com>
1 parent aba3a68 commit 6ffd627

9 files changed

Lines changed: 272 additions & 258 deletions

File tree

prostate-mri-lesion-seg/LICENSE

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
Prostate-MRI_Lesion_Detection, v3.0 (Release date: September 17, 2024)
2-
DEFINITIONS: AUTHOR(S) NVIDIA Corp. and National Cancer Institute, NIH
3-
4-
PROVIDER: the National Cancer Institute (NCI), a participating institute of the
5-
National Institutes of Health (NIH), and an agency of the United States Government.
6-
7-
SOFTWARE: the machine readable, binary, object code form,
8-
and the related documentation for the modules of the Prostate-MRI_Lesion_Detection, v2.0
9-
software package, which is a collection of operators which accept (T2, ADC, and High
10-
b-value DICOM images) and produce prostate organ and lesion segmentation files
11-
12-
RECIPIENT: the party that downloads the software.
13-
14-
By downloading or otherwise receiving the SOFTWARE, RECIPIENT may
15-
use and/or redistribute the SOFTWARE, with or without modification,
16-
subject to RECIPIENT’s agreement to the following terms:
17-
18-
1. THE SOFTWARE SHALL NOT BE USED IN THE TREATMENT OR DIAGNOSIS
19-
OF HUMAN SUBJECTS. RECIPIENT is responsible for
20-
compliance with all laws and regulations applicable to the use
21-
of the SOFTWARE.
22-
23-
2. THE SOFTWARE is distributed for NON-COMMERCIAL RESEARCH PURPOSES ONLY. RECIPIENT is
24-
responsible for appropriate-use compliance.
25-
26-
3. RECIPIENT agrees to acknowledge PROVIDER’s contribution and
27-
the name of the author of the SOFTWARE in all written publications
28-
containing any data or information regarding or resulting from use
29-
of the SOFTWARE.
30-
31-
4. THE SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
32-
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
33-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
34-
ARE DISCLAIMED. IN NO EVENT SHALL THE PROVIDER OR THE INDIVIDUAL DEVELOPERS
35-
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36-
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37-
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38-
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39-
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40-
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
41-
THE POSSIBILITY OF SUCH DAMAGE.
42-
43-
5. RECIPIENT agrees not to use any trademarks, service marks, trade names,
44-
logos or product names of NVIDIA, NCI or NIH to endorse or promote products derived
45-
from the SOFTWARE without specific, prior and written permission.
46-
47-
6. For sake of clarity, and not by way of limitation, RECIPIENT may add its
48-
own copyright statement to its modifications or derivative works of the SOFTWARE
49-
and may provide additional or different license terms and conditions in its
50-
sublicenses of modifications or derivative works of the SOFTWARE provided that
51-
RECIPIENT’s use, reproduction, and distribution of the SOFTWARE otherwise complies
52-
with the conditions stated in this Agreement. Whenever Recipient distributes or
53-
redistributes the SOFTWARE, a copy of this Agreement must be included with
54-
each copy of the SOFTWARE.
1+
Prostate-MRI_Lesion_Detection, v3.0 (Release date: September 17, 2024)
2+
DEFINITIONS: AUTHOR(S) NVIDIA Corp. and National Cancer Institute, NIH
3+
4+
PROVIDER: the National Cancer Institute (NCI), a participating institute of the
5+
National Institutes of Health (NIH), and an agency of the United States Government.
6+
7+
SOFTWARE: the machine readable, binary, object code form,
8+
and the related documentation for the modules of the Prostate-MRI_Lesion_Detection, v2.0
9+
software package, which is a collection of operators which accept (T2, ADC, and High
10+
b-value DICOM images) and produce prostate organ and lesion segmentation files
11+
12+
RECIPIENT: the party that downloads the software.
13+
14+
By downloading or otherwise receiving the SOFTWARE, RECIPIENT may
15+
use and/or redistribute the SOFTWARE, with or without modification,
16+
subject to RECIPIENT’s agreement to the following terms:
17+
18+
1. THE SOFTWARE SHALL NOT BE USED IN THE TREATMENT OR DIAGNOSIS
19+
OF HUMAN SUBJECTS. RECIPIENT is responsible for
20+
compliance with all laws and regulations applicable to the use
21+
of the SOFTWARE.
22+
23+
2. THE SOFTWARE is distributed for NON-COMMERCIAL RESEARCH PURPOSES ONLY. RECIPIENT is
24+
responsible for appropriate-use compliance.
25+
26+
3. RECIPIENT agrees to acknowledge PROVIDER’s contribution and
27+
the name of the author of the SOFTWARE in all written publications
28+
containing any data or information regarding or resulting from use
29+
of the SOFTWARE.
30+
31+
4. THE SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
32+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
33+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
34+
ARE DISCLAIMED. IN NO EVENT SHALL THE PROVIDER OR THE INDIVIDUAL DEVELOPERS
35+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
41+
THE POSSIBILITY OF SUCH DAMAGE.
42+
43+
5. RECIPIENT agrees not to use any trademarks, service marks, trade names,
44+
logos or product names of NVIDIA, NCI or NIH to endorse or promote products derived
45+
from the SOFTWARE without specific, prior and written permission.
46+
47+
6. For sake of clarity, and not by way of limitation, RECIPIENT may add its
48+
own copyright statement to its modifications or derivative works of the SOFTWARE
49+
and may provide additional or different license terms and conditions in its
50+
sublicenses of modifications or derivative works of the SOFTWARE provided that
51+
RECIPIENT’s use, reproduction, and distribution of the SOFTWARE otherwise complies
52+
with the conditions stated in this Agreement. Whenever Recipient distributes or
53+
redistributes the SOFTWARE, a copy of this Agreement must be included with
54+
each copy of the SOFTWARE.

prostate-mri-lesion-seg/prostate_mri_lesion_seg_app/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'''
1+
"""
22
Prostate-MRI_Lesion_Detection, v3.0 (Release date: September 17, 2024)
33
DEFINITIONS: AUTHOR(S) NVIDIA Corp. and National Cancer Institute, NIH
44
@@ -52,7 +52,7 @@
5252
RECIPIENT’s use, reproduction, and distribution of the SOFTWARE otherwise complies
5353
with the conditions stated in this Agreement. Whenever Recipient distributes or
5454
redistributes the SOFTWARE, a copy of this Agreement must be included with
55-
each copy of the SOFTWARE.'''
55+
each copy of the SOFTWARE."""
5656

5757
from app import AIProstateLesionSegApp
5858

prostate-mri-lesion-seg/prostate_mri_lesion_seg_app/app.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'''
1+
"""
22
Prostate-MRI_Lesion_Detection, v3.0 (Release date: September 17, 2024)
33
DEFINITIONS: AUTHOR(S) NVIDIA Corp. and National Cancer Institute, NIH
44
@@ -52,24 +52,24 @@
5252
RECIPIENT’s use, reproduction, and distribution of the SOFTWARE otherwise complies
5353
with the conditions stated in this Agreement. Whenever Recipient distributes or
5454
redistributes the SOFTWARE, a copy of this Agreement must be included with
55-
each copy of the SOFTWARE.'''
55+
each copy of the SOFTWARE."""
5656

5757
import logging
5858
from pathlib import Path
5959

60+
from custom_lesion_classifier_operator import ProstateLesionClassifierOperator
61+
from custom_lesion_seg_operator import ProstateLesionSegOperator
62+
63+
# Local imports
64+
from organ_seg_operator import ProstateSegOperator
65+
6066
# MONAI Deploy SDK imports
6167
from monai.deploy.conditions import CountCondition
6268
from monai.deploy.core import AppContext, Application
6369
from monai.deploy.operators.dicom_data_loader_operator import DICOMDataLoaderOperator
6470
from monai.deploy.operators.dicom_series_selector_operator import DICOMSeriesSelectorOperator
6571
from monai.deploy.operators.dicom_series_to_volume_operator import DICOMSeriesToVolumeOperator
6672

67-
# Local imports
68-
from organ_seg_operator import ProstateSegOperator
69-
from custom_lesion_seg_operator import ProstateLesionSegOperator
70-
from custom_lesion_classifier_operator import ProstateLesionClassifierOperator
71-
72-
7373
# Custom rules for T2, ADC, and HIGHB series selection in ProstateX
7474
Rules_T2 = """
7575
{
@@ -128,6 +128,7 @@
128128
}
129129
"""
130130

131+
131132
class AIProstateLesionSegApp(Application):
132133
def __init__(self, *args, **kwargs):
133134
"""Creates an application instance."""
@@ -166,18 +167,32 @@ def compose(self):
166167
series_to_vol_HIGHB_op = DICOMSeriesToVolumeOperator(self, name="series_to_vol_HIGHB")
167168

168169
# AI operators
169-
organ_seg_op = ProstateSegOperator(self, app_context=app_context, model_path=model_path/"organ", name="organ_seg_op")
170-
lesion_seg_op = ProstateLesionSegOperator(self, app_context=app_context, model_path=model_path, name="lesion_seg_op")
171-
lesion_classifier_op = ProstateLesionClassifierOperator(self, app_context=app_context, model_path=model_path, name="lesion_classifier_op")
170+
organ_seg_op = ProstateSegOperator(
171+
self, app_context=app_context, model_path=model_path / "organ", name="organ_seg_op"
172+
)
173+
lesion_seg_op = ProstateLesionSegOperator(
174+
self, app_context=app_context, model_path=model_path, name="lesion_seg_op"
175+
)
176+
lesion_classifier_op = ProstateLesionClassifierOperator(
177+
self, app_context=app_context, model_path=model_path, name="lesion_classifier_op"
178+
)
172179

173180
#################### Pipeline DAG ####################
174181
# Data ingestion
175182
self.add_flow(study_loader_op, series_selector_T2_op, {("dicom_study_list", "dicom_study_list")})
176183
self.add_flow(study_loader_op, series_selector_ADC_op, {("dicom_study_list", "dicom_study_list")})
177184
self.add_flow(study_loader_op, series_selector_HIGHB_op, {("dicom_study_list", "dicom_study_list")})
178-
self.add_flow(series_selector_T2_op, series_to_vol_T2_op, {("study_selected_series_list", "study_selected_series_list")})
179-
self.add_flow(series_selector_ADC_op, series_to_vol_ADC_op, {("study_selected_series_list", "study_selected_series_list")})
180-
self.add_flow(series_selector_HIGHB_op, series_to_vol_HIGHB_op, {("study_selected_series_list", "study_selected_series_list")})
185+
self.add_flow(
186+
series_selector_T2_op, series_to_vol_T2_op, {("study_selected_series_list", "study_selected_series_list")}
187+
)
188+
self.add_flow(
189+
series_selector_ADC_op, series_to_vol_ADC_op, {("study_selected_series_list", "study_selected_series_list")}
190+
)
191+
self.add_flow(
192+
series_selector_HIGHB_op,
193+
series_to_vol_HIGHB_op,
194+
{("study_selected_series_list", "study_selected_series_list")},
195+
)
181196

182197
# Organ inference
183198
self.add_flow(series_to_vol_T2_op, organ_seg_op, {("image", "image")})
@@ -198,6 +213,7 @@ def compose(self):
198213
self._logger.debug(f"End {self.compose.__name__}")
199214
#################### Pipeline DAG ####################
200215

216+
201217
if __name__ == "__main__":
202218
# Creates the app and test it standalone.
203219
logging.info(f"Begin {__name__}")

prostate-mri-lesion-seg/prostate_mri_lesion_seg_app/common.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'''
1+
"""
22
Prostate-MRI_Lesion_Detection, v3.0 (Release date: September 17, 2024)
33
DEFINITIONS: AUTHOR(S) NVIDIA Corp. and National Cancer Institute, NIH
44
@@ -52,13 +52,16 @@
5252
RECIPIENT’s use, reproduction, and distribution of the SOFTWARE otherwise complies
5353
with the conditions stated in this Agreement. Whenever Recipient distributes or
5454
redistributes the SOFTWARE, a copy of this Agreement must be included with
55-
each copy of the SOFTWARE.'''
55+
each copy of the SOFTWARE."""
5656

57-
import numpy as np
5857
import copy
58+
59+
import numpy as np
5960
from skimage.measure import label
6061

6162
###############################################################################
63+
64+
6265
def bounding_box_3d(nda):
6366

6467
r = np.any(nda, axis=(1, 2))
@@ -80,6 +83,7 @@ def bounding_box_3d(nda):
8083

8184
return bbox
8285

86+
8387
def crop_pos_classification_multi_channel_3d(nda, nda_gt, crop_size):
8488
if nda_gt.ndim == 4:
8589
nda_ref = np.amax(nda_gt, axis=0)
@@ -104,12 +108,12 @@ def crop_pos_classification_multi_channel_3d(nda, nda_gt, crop_size):
104108

105109
nda = nda[
106110
...,
107-
indices[0]:indices[0] + crop_size[0],
108-
indices[1]:indices[1] + crop_size[1],
109-
indices[2]:indices[2] + crop_size[2]
110-
]
111+
indices[0] : indices[0] + crop_size[0],
112+
indices[1] : indices[1] + crop_size[1],
113+
indices[2] : indices[2] + crop_size[2],
114+
]
111115

112-
gt = np.unique(nda_gt[label_image==1])[0]
116+
gt = np.unique(nda_gt[label_image == 1])[0]
113117
elif num_crop > 1:
114118
images = []
115119
labels = []
@@ -125,10 +129,10 @@ def crop_pos_classification_multi_channel_3d(nda, nda_gt, crop_size):
125129

126130
nda_crop = nda[
127131
...,
128-
indices[0]:indices[0] + crop_size[0],
129-
indices[1]:indices[1] + crop_size[1],
130-
indices[2]:indices[2] + crop_size[2]
131-
]
132+
indices[0] : indices[0] + crop_size[0],
133+
indices[1] : indices[1] + crop_size[1],
134+
indices[2] : indices[2] + crop_size[2],
135+
]
132136

133137
gt = np.unique(nda_gt[label_image == k + 1])[0]
134138

@@ -140,6 +144,7 @@ def crop_pos_classification_multi_channel_3d(nda, nda_gt, crop_size):
140144

141145
return nda, gt
142146

147+
143148
def standard_normalization_multi_channel(nda):
144149
for _i in range(nda.shape[0]):
145150
if np.amax(np.abs(nda[_i, ...])) < 1e-7:

0 commit comments

Comments
 (0)