Skip to content

Commit

Permalink
auto updates (#399)
Browse files Browse the repository at this point in the history
Signed-off-by: monai-bot <[email protected]>

Signed-off-by: monai-bot <[email protected]>
Co-authored-by: Mingxin Zheng <[email protected]>
  • Loading branch information
monai-bot and mingxin-zheng authored Oct 23, 2024
1 parent aba3a68 commit 6ffd627
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 258 deletions.
108 changes: 54 additions & 54 deletions prostate-mri-lesion-seg/LICENSE
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
Prostate-MRI_Lesion_Detection, v3.0 (Release date: September 17, 2024)
DEFINITIONS: AUTHOR(S) NVIDIA Corp. and National Cancer Institute, NIH
PROVIDER: the National Cancer Institute (NCI), a participating institute of the
National Institutes of Health (NIH), and an agency of the United States Government.
SOFTWARE: the machine readable, binary, object code form,
and the related documentation for the modules of the Prostate-MRI_Lesion_Detection, v2.0
software package, which is a collection of operators which accept (T2, ADC, and High
b-value DICOM images) and produce prostate organ and lesion segmentation files
RECIPIENT: the party that downloads the software.
By downloading or otherwise receiving the SOFTWARE, RECIPIENT may
use and/or redistribute the SOFTWARE, with or without modification,
subject to RECIPIENT’s agreement to the following terms:
1. THE SOFTWARE SHALL NOT BE USED IN THE TREATMENT OR DIAGNOSIS
OF HUMAN SUBJECTS. RECIPIENT is responsible for
compliance with all laws and regulations applicable to the use
of the SOFTWARE.
2. THE SOFTWARE is distributed for NON-COMMERCIAL RESEARCH PURPOSES ONLY. RECIPIENT is
responsible for appropriate-use compliance.
3. RECIPIENT agrees to acknowledge PROVIDER’s contribution and
the name of the author of the SOFTWARE in all written publications
containing any data or information regarding or resulting from use
of the SOFTWARE.
4. THE SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
ARE DISCLAIMED. IN NO EVENT SHALL THE PROVIDER OR THE INDIVIDUAL DEVELOPERS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
5. RECIPIENT agrees not to use any trademarks, service marks, trade names,
logos or product names of NVIDIA, NCI or NIH to endorse or promote products derived
from the SOFTWARE without specific, prior and written permission.
6. For sake of clarity, and not by way of limitation, RECIPIENT may add its
own copyright statement to its modifications or derivative works of the SOFTWARE
and may provide additional or different license terms and conditions in its
sublicenses of modifications or derivative works of the SOFTWARE provided that
RECIPIENT’s use, reproduction, and distribution of the SOFTWARE otherwise complies
with the conditions stated in this Agreement. Whenever Recipient distributes or
redistributes the SOFTWARE, a copy of this Agreement must be included with
each copy of the SOFTWARE.
Prostate-MRI_Lesion_Detection, v3.0 (Release date: September 17, 2024)
DEFINITIONS: AUTHOR(S) NVIDIA Corp. and National Cancer Institute, NIH

PROVIDER: the National Cancer Institute (NCI), a participating institute of the
National Institutes of Health (NIH), and an agency of the United States Government.

SOFTWARE: the machine readable, binary, object code form,
and the related documentation for the modules of the Prostate-MRI_Lesion_Detection, v2.0
software package, which is a collection of operators which accept (T2, ADC, and High
b-value DICOM images) and produce prostate organ and lesion segmentation files

RECIPIENT: the party that downloads the software.

By downloading or otherwise receiving the SOFTWARE, RECIPIENT may
use and/or redistribute the SOFTWARE, with or without modification,
subject to RECIPIENT’s agreement to the following terms:

1. THE SOFTWARE SHALL NOT BE USED IN THE TREATMENT OR DIAGNOSIS
OF HUMAN SUBJECTS. RECIPIENT is responsible for
compliance with all laws and regulations applicable to the use
of the SOFTWARE.

2. THE SOFTWARE is distributed for NON-COMMERCIAL RESEARCH PURPOSES ONLY. RECIPIENT is
responsible for appropriate-use compliance.

3. RECIPIENT agrees to acknowledge PROVIDER’s contribution and
the name of the author of the SOFTWARE in all written publications
containing any data or information regarding or resulting from use
of the SOFTWARE.

4. THE SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
ARE DISCLAIMED. IN NO EVENT SHALL THE PROVIDER OR THE INDIVIDUAL DEVELOPERS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.

5. RECIPIENT agrees not to use any trademarks, service marks, trade names,
logos or product names of NVIDIA, NCI or NIH to endorse or promote products derived
from the SOFTWARE without specific, prior and written permission.

6. For sake of clarity, and not by way of limitation, RECIPIENT may add its
own copyright statement to its modifications or derivative works of the SOFTWARE
and may provide additional or different license terms and conditions in its
sublicenses of modifications or derivative works of the SOFTWARE provided that
RECIPIENT’s use, reproduction, and distribution of the SOFTWARE otherwise complies
with the conditions stated in this Agreement. Whenever Recipient distributes or
redistributes the SOFTWARE, a copy of this Agreement must be included with
each copy of the SOFTWARE.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''
"""
Prostate-MRI_Lesion_Detection, v3.0 (Release date: September 17, 2024)
DEFINITIONS: AUTHOR(S) NVIDIA Corp. and National Cancer Institute, NIH
Expand Down Expand Up @@ -52,7 +52,7 @@
RECIPIENT’s use, reproduction, and distribution of the SOFTWARE otherwise complies
with the conditions stated in this Agreement. Whenever Recipient distributes or
redistributes the SOFTWARE, a copy of this Agreement must be included with
each copy of the SOFTWARE.'''
each copy of the SOFTWARE."""

from app import AIProstateLesionSegApp

Expand Down
44 changes: 30 additions & 14 deletions prostate-mri-lesion-seg/prostate_mri_lesion_seg_app/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''
"""
Prostate-MRI_Lesion_Detection, v3.0 (Release date: September 17, 2024)
DEFINITIONS: AUTHOR(S) NVIDIA Corp. and National Cancer Institute, NIH
Expand Down Expand Up @@ -52,24 +52,24 @@
RECIPIENT’s use, reproduction, and distribution of the SOFTWARE otherwise complies
with the conditions stated in this Agreement. Whenever Recipient distributes or
redistributes the SOFTWARE, a copy of this Agreement must be included with
each copy of the SOFTWARE.'''
each copy of the SOFTWARE."""

import logging
from pathlib import Path

from custom_lesion_classifier_operator import ProstateLesionClassifierOperator
from custom_lesion_seg_operator import ProstateLesionSegOperator

# Local imports
from organ_seg_operator import ProstateSegOperator

# MONAI Deploy SDK imports
from monai.deploy.conditions import CountCondition
from monai.deploy.core import AppContext, Application
from monai.deploy.operators.dicom_data_loader_operator import DICOMDataLoaderOperator
from monai.deploy.operators.dicom_series_selector_operator import DICOMSeriesSelectorOperator
from monai.deploy.operators.dicom_series_to_volume_operator import DICOMSeriesToVolumeOperator

# Local imports
from organ_seg_operator import ProstateSegOperator
from custom_lesion_seg_operator import ProstateLesionSegOperator
from custom_lesion_classifier_operator import ProstateLesionClassifierOperator


# Custom rules for T2, ADC, and HIGHB series selection in ProstateX
Rules_T2 = """
{
Expand Down Expand Up @@ -128,6 +128,7 @@
}
"""


class AIProstateLesionSegApp(Application):
def __init__(self, *args, **kwargs):
"""Creates an application instance."""
Expand Down Expand Up @@ -166,18 +167,32 @@ def compose(self):
series_to_vol_HIGHB_op = DICOMSeriesToVolumeOperator(self, name="series_to_vol_HIGHB")

# AI operators
organ_seg_op = ProstateSegOperator(self, app_context=app_context, model_path=model_path/"organ", name="organ_seg_op")
lesion_seg_op = ProstateLesionSegOperator(self, app_context=app_context, model_path=model_path, name="lesion_seg_op")
lesion_classifier_op = ProstateLesionClassifierOperator(self, app_context=app_context, model_path=model_path, name="lesion_classifier_op")
organ_seg_op = ProstateSegOperator(
self, app_context=app_context, model_path=model_path / "organ", name="organ_seg_op"
)
lesion_seg_op = ProstateLesionSegOperator(
self, app_context=app_context, model_path=model_path, name="lesion_seg_op"
)
lesion_classifier_op = ProstateLesionClassifierOperator(
self, app_context=app_context, model_path=model_path, name="lesion_classifier_op"
)

#################### Pipeline DAG ####################
# Data ingestion
self.add_flow(study_loader_op, series_selector_T2_op, {("dicom_study_list", "dicom_study_list")})
self.add_flow(study_loader_op, series_selector_ADC_op, {("dicom_study_list", "dicom_study_list")})
self.add_flow(study_loader_op, series_selector_HIGHB_op, {("dicom_study_list", "dicom_study_list")})
self.add_flow(series_selector_T2_op, series_to_vol_T2_op, {("study_selected_series_list", "study_selected_series_list")})
self.add_flow(series_selector_ADC_op, series_to_vol_ADC_op, {("study_selected_series_list", "study_selected_series_list")})
self.add_flow(series_selector_HIGHB_op, series_to_vol_HIGHB_op, {("study_selected_series_list", "study_selected_series_list")})
self.add_flow(
series_selector_T2_op, series_to_vol_T2_op, {("study_selected_series_list", "study_selected_series_list")}
)
self.add_flow(
series_selector_ADC_op, series_to_vol_ADC_op, {("study_selected_series_list", "study_selected_series_list")}
)
self.add_flow(
series_selector_HIGHB_op,
series_to_vol_HIGHB_op,
{("study_selected_series_list", "study_selected_series_list")},
)

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


if __name__ == "__main__":
# Creates the app and test it standalone.
logging.info(f"Begin {__name__}")
Expand Down
29 changes: 17 additions & 12 deletions prostate-mri-lesion-seg/prostate_mri_lesion_seg_app/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''
"""
Prostate-MRI_Lesion_Detection, v3.0 (Release date: September 17, 2024)
DEFINITIONS: AUTHOR(S) NVIDIA Corp. and National Cancer Institute, NIH
Expand Down Expand Up @@ -52,13 +52,16 @@
RECIPIENT’s use, reproduction, and distribution of the SOFTWARE otherwise complies
with the conditions stated in this Agreement. Whenever Recipient distributes or
redistributes the SOFTWARE, a copy of this Agreement must be included with
each copy of the SOFTWARE.'''
each copy of the SOFTWARE."""

import numpy as np
import copy

import numpy as np
from skimage.measure import label

###############################################################################


def bounding_box_3d(nda):

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

return bbox


def crop_pos_classification_multi_channel_3d(nda, nda_gt, crop_size):
if nda_gt.ndim == 4:
nda_ref = np.amax(nda_gt, axis=0)
Expand All @@ -104,12 +108,12 @@ def crop_pos_classification_multi_channel_3d(nda, nda_gt, crop_size):

nda = nda[
...,
indices[0]:indices[0] + crop_size[0],
indices[1]:indices[1] + crop_size[1],
indices[2]:indices[2] + crop_size[2]
]
indices[0] : indices[0] + crop_size[0],
indices[1] : indices[1] + crop_size[1],
indices[2] : indices[2] + crop_size[2],
]

gt = np.unique(nda_gt[label_image==1])[0]
gt = np.unique(nda_gt[label_image == 1])[0]
elif num_crop > 1:
images = []
labels = []
Expand All @@ -125,10 +129,10 @@ def crop_pos_classification_multi_channel_3d(nda, nda_gt, crop_size):

nda_crop = nda[
...,
indices[0]:indices[0] + crop_size[0],
indices[1]:indices[1] + crop_size[1],
indices[2]:indices[2] + crop_size[2]
]
indices[0] : indices[0] + crop_size[0],
indices[1] : indices[1] + crop_size[1],
indices[2] : indices[2] + crop_size[2],
]

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

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

return nda, gt


def standard_normalization_multi_channel(nda):
for _i in range(nda.shape[0]):
if np.amax(np.abs(nda[_i, ...])) < 1e-7:
Expand Down
Loading

0 comments on commit 6ffd627

Please sign in to comment.