-
Notifications
You must be signed in to change notification settings - Fork 53
MONet Bundle Integration into MONAI Deploy #543
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
Open
SimoneBendazzoli93
wants to merge
218
commits into
Project-MONAI:main
Choose a base branch
from
SimoneBendazzoli93:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
218 commits
Select commit
Hold shift + click to select a range
ed2a45c
Bump version: 0.3.0 → 0.4.0
MMelQin f84493f
Update release notes for v0.4.0
MMelQin e0f6780
Add the newly introduced example to readme.md (#313)
MMelQin fc81010
DOC: Use upstream/downstream instead of source/destination (#316)
Leengit e3418b2
Implement highdicom seg operator (#327)
CPBridge 60de91b
Fix the setting of init state in its own PR, instead of rolled into o…
MMelQin 5384e7d
Add highdicom license to the Third Party Notices (#334)
MMelQin f6b56a0
Improve STL operator so the enclosing app obj can run repetitively (#…
MMelQin d443c29
Added support of matching instance level tags, and update liver seg (…
MMelQin 7053478
Nuance PIN MONAI Integration Example App (#328)
aihsani eb97cd4
minor adjustment for proper result alignment (#354)
aihsani aa4e52f
Nuance pin integration minor adjustments (#355)
aihsani f11a1a3
Enhance some attributes in the text SR writer (#346)
MMelQin ff526eb
Update executor path to new version (#135)
KavinKrishnan 9614fe4
App SDK updated to be compatible with monai 1.0.0 and its MetaTensor …
MMelQin c6548f9
Minor typo in property method
diazandr3s cc98293
Update method name
diazandr3s a1f39cc
Add DICOM PDF Writer and split dicom_utils common module out of Text …
MMelQin b6f22be
Add the missing python package, PyPDF2 (#372)
MMelQin 1c76efa
Enhanced multi-value DateElement parsing (#370)
MMelQin f76de96
Doc changes for addressing issues and for releasing App SDK v0.5 (#373)
MMelQin e3089ec
Add missed change (#374)
MMelQin 1392e0a
Update notebook output after retest (#375)
MMelQin 659b1d3
Various fixes to PIN integration example
c865b0a
Fix style errors
a13410c
Fix f-strings
39bfb35
Tweak to README
cbbb016
Release v0.5.0 (#376)
MMelQin d8e516f
Enhanced code to extract and parse specific config files from TorchSc…
MMelQin 27aad68
Deprecate the MIS as it does not serve intended purpose (#379)
MMelQin f32441d
Fix app requirements to working version (#380)
aihsani 2abdbb2
Merge Nuance Updates (#377)
iain-henderson 52f695c
Add Pancreas Seg app, multi-model app, and Jupyter Notebook tutorial …
MMelQin 401871c
Added breast density classifier app
17e650e
Fied formatting and readme
d29fca7
Fixed typo
86b2889
Added a Nifti data loader for issue #270
a4ad962
Quick fix to avoid package not found error by use optional import (#386)
MMelQin ca3f937
ENH: Versions as strings, not numbers, so that 3.1 != 3.10, etc. (#385)
Leengit 26f65d9
Enhance Packager to make the MAP more secure, easier to use, and base…
MMelQin 2ae514a
Make app.py's __main__ to init and run the app, as this is how MAP is…
MMelQin 897e676
Update README.md
dbericat c25f54e
changed name from integrations to platforms (#390)
dbericat a599e94
Create Enhancement
MMelQin f27d90d
Update and rename Enhancement to enhancement_request.md
MMelQin 24d661a
Create aide
dbericat fb1949f
Create mayo_cai_viewer
dbericat cb423fa
Rename aide to london_aicentre_aide
dbericat 262444d
Make the output DICOM SR instance part of the original study
MMelQin eb8f02f
Use simple series selection rule on modality and image type
MMelQin 8630d94
Delete london_aicentre_aide
hshuaib90 9513bf3
Create README.md
hshuaib90 8eac5b1
Add new image and update text
hshuaib90 7d45c67
Expose option to omit empty frames
1cdc076
Fix issue 410 where the latest typeguard version 3.x is incompatible …
MMelQin 8f03e32
Update enhancement_request.md
MMelQin 447ebc5
enable AMD GPU (#406)
vickytsang cfe663a
Fix broken links in Readme (#432)
MMelQin 0b95a7c
Update importutil.py (#436)
filipmu 83f4559
Added option for SimpleInferer (#428)
vikashg 94c4b02
Updated the mednist notebooks adding the dependencies of pydicom and …
MMelQin 00d8462
Update pr.yml
MMelQin 83efc3d
Update SDK to support typeguard v3.0 and above, which has a breaking …
MMelQin 907319f
Update Read The Docs configuration to support Python 3.8 (#439)
gigony 34859a3
Bump version: 0.5.0 → 0.5.1
MMelQin b7fddfb
Create aws_healthimaging.md (#449)
flamingofugang 03bcc40
App SDK Migration (to depend on Holoscan SDK) (#441)
MMelQin 66e7142
Merge V0.6 release notes to main (#452)
MMelQin a1438f0
test build
MMelQin 300fe19
Address a removed monai function, fix CUDA 11 runtime lib, and resurr…
MMelQin 98dff55
Update pr.yml to pip install cuda12 runtime
MMelQin 5978263
Update pr.yml
MMelQin 8ff73f8
Update pr.yml
MMelQin edc70d1
Update pr.yml
MMelQin 4123c92
Update pr.yml
MMelQin e084b4e
Update pr.yml
MMelQin 1f54d1d
Updating the SDK to use newer and updated dependencies, namely Holosc…
MMelQin 919912b
Releasing and tagging V1.0 (#482)
MMelQin 8467932
test out the minimal set of reqs
MMelQin 680f00d
Update readthedocs configuration
gigony e114513
removed the commented out reqs
MMelQin d5d5957
Fix package and LD_LIBRARY_PATH issues for readthedocs
gigony 9c4612f
Update pr.yml to set LD_LIBRARY_PATH consistently with Holoscan SDK 2.0
MMelQin 4e1b32b
Update to release v2.0 that is dependent on HSDK v2 (#485)
MMelQin 65f6693
V2.0 (#487)
MMelQin b1a5c4a
Changes to v2 release did not get saved (#488)
MMelQin e8fadf2
Fix breast density example application to make it work with SDK v0.6+…
MMelQin 08e789a
Adding missed step for setting input env var to fix the doc issue (#496)
MMelQin d74e0c2
Update example apps' test data path, patch hsdk in local env, and ens…
MMelQin 5efee16
DICOM Seg Writer operater: Fix for case where input image is already …
CPBridge 7528d9c
Update tutorials after testing with holoscan v2.9.0 (#522)
MMelQin 5632b9c
Update README.md (#499)
vikashg 0e386e9
DICOMSeriesSelectorOperator Enhancements (#501)
bluna301 f677275
Added a sample integration for LLM models in huggingface (#494)
vikashg e65ec33
Editorial changes to correct typos, rename parameters, and add commen…
MMelQin 16c4b6f
slice removal fix (#527)
bluna301 558cfec
Add nnUNet segmentation application and dependencies
SimoneBendazzoli93 1887fb7
CCHMC Ped Abd CT Seg Example App (#525)
bluna301 c359a04
Fix meta_data handling in MonaiBundleInferenceOperator to ensure it d…
SimoneBendazzoli93 ee9a3e6
Update requirements and fix data shape handling in Monai nUNet Bundle…
SimoneBendazzoli93 e72535b
Add NiftiDataWriter operator and update NiftiDataLoader to return Sim…
SimoneBendazzoli93 51f5b21
Add nvflare to requirements for ai_spleen_nnunet_seg_app
SimoneBendazzoli93 a0835ea
duplicate ipps non-loaded (#535)
bluna301 fdec500
ModelInfo arg added to DICOMSegWriterOp (#533)
bluna301 0774906
Support remote inference on Triton Inference Server with ease of use …
MMelQin 9d90ea1
Fix DICOMSeriesToVolumeOperator casting bug (#529)
WillButAgain eecb747
Formatting changes and tag value for unsigned int is 0 (#537)
MMelQin 75c2a53
Prepared changes for releasing v3 (#538)
MMelQin cff8edf
Fix _version.py and various version-related issues (#539)
MMelQin f7ef3fd
Bump version: 2.0.0 → 3.0.0 (#540)
MMelQin 5e7f12a
Fix NiftiDataWriter spacing handling for 1mm pixel dimensions
SimoneBendazzoli93 7dc2ed8
Refactor nnUNet bundle inference operator to MONetBundleInferenceOper…
SimoneBendazzoli93 4aa297d
Update documentation to reflect changes from nnUNet to MONet Bundle i…
SimoneBendazzoli93 65bb871
Refactor import statements in app.py and monet_bundle_inference_opera…
SimoneBendazzoli93 9c5aca7
Update application title and fix operator name in imports for MONet B…
SimoneBendazzoli93 96d30b7
Refactor NiftiDataLoader to return transposed numpy array from NIfTI …
SimoneBendazzoli93 e80ecde
Remove NiftiDataWriter operator and clean up imports in __init__.py
SimoneBendazzoli93 225f9eb
Remove SimpleITK image handling from MonaiBundleInferenceOperator
SimoneBendazzoli93 c512780
Fix import statement for MONetBundleInferenceOperator to use the corr…
SimoneBendazzoli93 e6cf4ac
Fix _version.py and various version-related issues (#539)
MMelQin dbe645c
Bump version: 2.0.0 → 3.0.0 (#540)
MMelQin 6eab3d9
Fix formatting in docstring and remove unused import statements in MO…
SimoneBendazzoli93 99eb8c9
Enhance predict method to support multimodal data concatenation and u…
SimoneBendazzoli93 1447f5a
Add NiftiDataWriter operator and update NiftiDataLoader to return Sim…
SimoneBendazzoli93 86628e6
Fix _version.py and various version-related issues (#539)
MMelQin 8c76e99
Bump version: 2.0.0 → 3.0.0 (#540)
MMelQin 22085d5
Fix NiftiDataWriter spacing handling for 1mm pixel dimensions
SimoneBendazzoli93 560cd44
Update application title and fix operator name in imports for MONet B…
SimoneBendazzoli93 adab674
Refactor NiftiDataLoader to return transposed numpy array from NIfTI …
SimoneBendazzoli93 6236a19
Remove NiftiDataWriter operator and clean up imports in __init__.py
SimoneBendazzoli93 b0d12d7
Remove SimpleITK image handling from MonaiBundleInferenceOperator
SimoneBendazzoli93 4ec9dba
Fix _version.py and various version-related issues (#539)
MMelQin ca73591
Bump version: 2.0.0 → 3.0.0 (#540)
MMelQin 6c0f134
test build
MMelQin d017501
Address a removed monai function, fix CUDA 11 runtime lib, and resurr…
MMelQin a917623
Update pr.yml to pip install cuda12 runtime
MMelQin 2371476
Update pr.yml
MMelQin 8f74f43
Update pr.yml
MMelQin a7bd084
Update pr.yml
MMelQin cb116b1
Update pr.yml
MMelQin ae22e88
Update pr.yml
MMelQin 0634f2c
Updating the SDK to use newer and updated dependencies, namely Holosc…
MMelQin 17c997c
Releasing and tagging V1.0 (#482)
MMelQin a3ff417
test out the minimal set of reqs
MMelQin 1261b8a
Update readthedocs configuration
gigony b542174
removed the commented out reqs
MMelQin 111569d
Fix package and LD_LIBRARY_PATH issues for readthedocs
gigony 61f3a67
Update pr.yml to set LD_LIBRARY_PATH consistently with Holoscan SDK 2.0
MMelQin 7bebf05
Update to release v2.0 that is dependent on HSDK v2 (#485)
MMelQin e9d5050
V2.0 (#487)
MMelQin 7748e49
Changes to v2 release did not get saved (#488)
MMelQin 55036a2
Fix breast density example application to make it work with SDK v0.6+…
MMelQin 07ea1f7
Adding missed step for setting input env var to fix the doc issue (#496)
MMelQin ef25d17
Update example apps' test data path, patch hsdk in local env, and ens…
MMelQin 10c8459
DICOM Seg Writer operater: Fix for case where input image is already …
CPBridge eb9eb70
Update tutorials after testing with holoscan v2.9.0 (#522)
MMelQin 05966bb
Update README.md (#499)
vikashg 76d8dc3
Added a sample integration for LLM models in huggingface (#494)
vikashg 104c4e7
Editorial changes to correct typos, rename parameters, and add commen…
MMelQin 489d105
Add nnUNet segmentation application and dependencies
SimoneBendazzoli93 140e652
CCHMC Ped Abd CT Seg Example App (#525)
bluna301 46ea98e
Update requirements and fix data shape handling in Monai nUNet Bundle…
SimoneBendazzoli93 9aadccf
Add NiftiDataWriter operator and update NiftiDataLoader to return Sim…
SimoneBendazzoli93 3fe4a3f
Add nvflare to requirements for ai_spleen_nnunet_seg_app
SimoneBendazzoli93 d94b4aa
duplicate ipps non-loaded (#535)
bluna301 c0f75e9
ModelInfo arg added to DICOMSegWriterOp (#533)
bluna301 da9939f
Support remote inference on Triton Inference Server with ease of use …
MMelQin 112723d
Fix DICOMSeriesToVolumeOperator casting bug (#529)
WillButAgain 57a9481
Formatting changes and tag value for unsigned int is 0 (#537)
MMelQin c89a0b9
Prepared changes for releasing v3 (#538)
MMelQin 26114a2
Fix _version.py and various version-related issues (#539)
MMelQin a892131
Bump version: 2.0.0 → 3.0.0 (#540)
MMelQin 1cefd11
Fix NiftiDataWriter spacing handling for 1mm pixel dimensions
SimoneBendazzoli93 7dd1975
Refactor nnUNet bundle inference operator to MONetBundleInferenceOper…
SimoneBendazzoli93 4389ef5
Update documentation to reflect changes from nnUNet to MONet Bundle i…
SimoneBendazzoli93 e0b99dc
Refactor import statements in app.py and monet_bundle_inference_opera…
SimoneBendazzoli93 14d7101
Update application title and fix operator name in imports for MONet B…
SimoneBendazzoli93 aa78d07
Refactor NiftiDataLoader to return transposed numpy array from NIfTI …
SimoneBendazzoli93 183be50
Remove NiftiDataWriter operator and clean up imports in __init__.py
SimoneBendazzoli93 fef8593
Remove SimpleITK image handling from MonaiBundleInferenceOperator
SimoneBendazzoli93 9e9fc97
Fix import statement for MONetBundleInferenceOperator to use the corr…
SimoneBendazzoli93 33f4a75
Fix _version.py and various version-related issues (#539)
MMelQin 0a75061
Bump version: 2.0.0 → 3.0.0 (#540)
MMelQin e548447
Fix formatting in docstring and remove unused import statements in MO…
SimoneBendazzoli93 b2838de
Enhance predict method to support multimodal data concatenation and u…
SimoneBendazzoli93 e1f702e
Add nnUNet segmentation application and dependencies
SimoneBendazzoli93 fb74df5
CCHMC Ped Abd CT Seg Example App (#525)
bluna301 6bd4fcc
Update requirements and fix data shape handling in Monai nUNet Bundle…
SimoneBendazzoli93 b28b0ee
Add NiftiDataWriter operator and update NiftiDataLoader to return Sim…
SimoneBendazzoli93 9ec0ea5
Add nvflare to requirements for ai_spleen_nnunet_seg_app
SimoneBendazzoli93 15931b4
Support remote inference on Triton Inference Server with ease of use …
MMelQin 6f5570e
Fix DICOMSeriesToVolumeOperator casting bug (#529)
WillButAgain 2d48751
Formatting changes and tag value for unsigned int is 0 (#537)
MMelQin bf8d361
Prepared changes for releasing v3 (#538)
MMelQin 3d9f752
Fix _version.py and various version-related issues (#539)
MMelQin 677c8a9
Bump version: 2.0.0 → 3.0.0 (#540)
MMelQin 9036d24
Fix NiftiDataWriter spacing handling for 1mm pixel dimensions
SimoneBendazzoli93 292c70c
Refactor nnUNet bundle inference operator to MONetBundleInferenceOper…
SimoneBendazzoli93 58f7a29
Update documentation to reflect changes from nnUNet to MONet Bundle i…
SimoneBendazzoli93 8656d2d
Refactor import statements in app.py and monet_bundle_inference_opera…
SimoneBendazzoli93 d08f35f
Update application title and fix operator name in imports for MONet B…
SimoneBendazzoli93 7941da9
Refactor NiftiDataLoader to return transposed numpy array from NIfTI …
SimoneBendazzoli93 f6e3e64
Remove NiftiDataWriter operator and clean up imports in __init__.py
SimoneBendazzoli93 3ff1250
Remove SimpleITK image handling from MonaiBundleInferenceOperator
SimoneBendazzoli93 8b4d4ac
Fix import statement for MONetBundleInferenceOperator to use the corr…
SimoneBendazzoli93 5724bbe
CCHMC Ped Abd CT Seg Example App (#525)
bluna301 4c5e506
Support remote inference on Triton Inference Server with ease of use …
MMelQin 111f5c3
Prepared changes for releasing v3 (#538)
MMelQin d8da34f
Fix _version.py and various version-related issues (#539)
MMelQin 6011478
Bump version: 2.0.0 → 3.0.0 (#540)
MMelQin 56155c0
Fix formatting in docstring and remove unused import statements in MO…
SimoneBendazzoli93 343e5fd
Enhance predict method to support multimodal data concatenation and u…
SimoneBendazzoli93 75fe572
DICOMSeriesSelectorOperator Improvements (#542)
bluna301 3b127ed
Regression tests with HSDK 3.4 and CLI 3.4.1 (#545)
MMelQin dcc20c8
Merge branch 'main' into main
SimoneBendazzoli93 44803a2
Remove unused import
SimoneBendazzoli93 7804d84
Add method to set model network for nnUNet predictor and validate inp…
SimoneBendazzoli93 fe15cf6
Merge branch 'Project-MONAI:main' into main
SimoneBendazzoli93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2021-2023 MONAI Consortium | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
import sys | ||
|
||
_current_dir = os.path.abspath(os.path.dirname(__file__)) | ||
if sys.path and os.path.abspath(sys.path[0]) != _current_dir: | ||
sys.path.insert(0, _current_dir) | ||
del _current_dir |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2021-2023 MONAI Consortium | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import logging | ||
|
||
from app import AISpleennnUNetSegApp | ||
|
||
if __name__ == "__main__": | ||
logging.info(f"Begin {__name__}") | ||
AISpleennnUNetSegApp().run() | ||
logging.info(f"End {__name__}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
# Copyright 2021-2023 MONAI Consortium | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import logging | ||
from pathlib import Path | ||
|
||
from pydicom.sr.codedict import codes | ||
|
||
from monai.deploy.conditions import CountCondition | ||
from monai.deploy.core import AppContext, Application | ||
from monai.deploy.core.domain import Image | ||
from monai.deploy.core.io_type import IOType | ||
from monai.deploy.operators.dicom_data_loader_operator import DICOMDataLoaderOperator | ||
from monai.deploy.operators.dicom_seg_writer_operator import DICOMSegmentationWriterOperator, SegmentDescription | ||
from monai.deploy.operators.dicom_series_selector_operator import DICOMSeriesSelectorOperator | ||
from monai.deploy.operators.dicom_series_to_volume_operator import DICOMSeriesToVolumeOperator | ||
from monai.deploy.operators.monai_bundle_inference_operator import BundleConfigNames, IOMapping | ||
from monai.deploy.operators.monet_bundle_inference_operator import MONetBundleInferenceOperator | ||
from monai.deploy.operators.stl_conversion_operator import STLConversionOperator | ||
|
||
|
||
# @resource(cpu=1, gpu=1, memory="7Gi") | ||
# pip_packages can be a string that is a path(str) to requirements.txt file or a list of packages. | ||
# The monai pkg is not required by this class, instead by the included operators. | ||
class AISpleennnUNetSegApp(Application): | ||
"""Demonstrates inference with built-in MONet Bundle inference operator with DICOM files as input/output | ||
|
||
This application loads a set of DICOM instances, select the appropriate series, converts the series to | ||
3D volume image, performs inference with the built-in MONet Bundle inference operator, including nnUNet resampling, pre-processing | ||
and post-processing, save the segmentation image in a DICOM Seg OID in an instance file, and optionally the | ||
surface mesh in STL format. | ||
|
||
Pertinent nnUNet MONAI Bundle: | ||
<Upload to the MONAI Model Zoo> | ||
|
||
Execution Time Estimate: | ||
With a Nvidia RTXA600 48GB GPU, for an input DICOM Series of size 106x415x415 and patches of size 64x192x160, the execution time is around | ||
50 seconds with saving both DICOM Seg and surface mesh STL file. | ||
""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Creates an application instance.""" | ||
self._logger = logging.getLogger("{}.{}".format(__name__, type(self).__name__)) | ||
super().__init__(*args, **kwargs) | ||
|
||
def run(self, *args, **kwargs): | ||
# This method calls the base class to run. Can be omitted if simply calling through. | ||
self._logger.info(f"Begin {self.run.__name__}") | ||
super().run(*args, **kwargs) | ||
self._logger.info(f"End {self.run.__name__}") | ||
|
||
def compose(self): | ||
"""Creates the app specific operators and chain them up in the processing DAG.""" | ||
|
||
logging.info(f"Begin {self.compose.__name__}") | ||
|
||
# Use Commandline options over environment variables to init context. | ||
app_context: AppContext = Application.init_app_context(self.argv) | ||
app_input_path = Path(app_context.input_path) | ||
app_output_path = Path(app_context.output_path) | ||
|
||
# Create the custom operator(s) as well as SDK built-in operator(s). | ||
study_loader_op = DICOMDataLoaderOperator( | ||
self, CountCondition(self, 1), input_folder=app_input_path, name="study_loader_op" | ||
) | ||
series_selector_op = DICOMSeriesSelectorOperator(self, rules=Sample_Rules_Text, name="series_selector_op") | ||
series_to_vol_op = DICOMSeriesToVolumeOperator(self, name="series_to_vol_op") | ||
|
||
# Create the inference operator that supports MONAI Bundle and automates the inference. | ||
# The IOMapping labels match the input and prediction keys in the pre and post processing. | ||
# The model_name is optional when the app has only one model. | ||
# The bundle_path argument optionally can be set to an accessible bundle file path in the dev | ||
# environment, so when the app is packaged into a MAP, the operator can complete the bundle parsing | ||
# during init. | ||
|
||
config_names = BundleConfigNames(config_names=["inference"]) # Same as the default | ||
|
||
bundle_spleen_seg_op = MONetBundleInferenceOperator( | ||
self, | ||
input_mapping=[IOMapping("image", Image, IOType.IN_MEMORY)], | ||
output_mapping=[IOMapping("pred", Image, IOType.IN_MEMORY)], | ||
app_context=app_context, | ||
bundle_config_names=config_names, | ||
name="nnunet_bundle_spleen_seg_op", | ||
) | ||
|
||
# Create DICOM Seg writer providing the required segment description for each segment with | ||
# the actual algorithm and the pertinent organ/tissue. The segment_label, algorithm_name, | ||
# and algorithm_version are of DICOM VR LO type, limited to 64 chars. | ||
# https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html | ||
segment_descriptions = [ | ||
SegmentDescription( | ||
segment_label="Spleen", | ||
segmented_property_category=codes.SCT.Organ, | ||
segmented_property_type=codes.SCT.Spleen, | ||
algorithm_name="volumetric (3D) segmentation of the spleen from CT image", | ||
algorithm_family=codes.DCM.ArtificialIntelligence, | ||
algorithm_version="0.3.2", | ||
) | ||
] | ||
|
||
custom_tags = {"SeriesDescription": "AI generated Seg, not for clinical use."} | ||
|
||
dicom_seg_writer = DICOMSegmentationWriterOperator( | ||
self, | ||
segment_descriptions=segment_descriptions, | ||
custom_tags=custom_tags, | ||
output_folder=app_output_path, | ||
name="dicom_seg_writer", | ||
) | ||
|
||
# Create the processing pipeline, by specifying the source and destination operators, and | ||
# ensuring the output from the former matches the input of the latter, in both name and type. | ||
self.add_flow(study_loader_op, series_selector_op, {("dicom_study_list", "dicom_study_list")}) | ||
self.add_flow( | ||
series_selector_op, series_to_vol_op, {("study_selected_series_list", "study_selected_series_list")} | ||
) | ||
self.add_flow(series_to_vol_op, bundle_spleen_seg_op, {("image", "image")}) | ||
# Note below the dicom_seg_writer requires two inputs, each coming from a source operator. | ||
self.add_flow( | ||
series_selector_op, dicom_seg_writer, {("study_selected_series_list", "study_selected_series_list")} | ||
) | ||
self.add_flow(bundle_spleen_seg_op, dicom_seg_writer, {("pred", "seg_image")}) | ||
# Create the surface mesh STL conversion operator and add it to the app execution flow, if needed, by | ||
# uncommenting the following couple lines. | ||
stl_conversion_op = STLConversionOperator( | ||
self, output_file=app_output_path.joinpath("stl/spleen.stl"), name="stl_conversion_op" | ||
) | ||
self.add_flow(bundle_spleen_seg_op, stl_conversion_op, {("pred", "image")}) | ||
|
||
logging.info(f"End {self.compose.__name__}") | ||
|
||
|
||
# This is a sample series selection rule in JSON, simply selecting CT series. | ||
# If the study has more than 1 CT series, then all of them will be selected. | ||
# Please see more detail in DICOMSeriesSelectorOperator. | ||
Sample_Rules_Text = """ | ||
{ | ||
"selections": [ | ||
{ | ||
"name": "CT Series", | ||
"conditions": { | ||
"StudyDescription": "(.*?)", | ||
"Modality": "(?i)CT", | ||
"SeriesDescription": "(.*?)" | ||
} | ||
} | ||
] | ||
} | ||
""" | ||
|
||
if __name__ == "__main__": | ||
logging.info(f"Begin {__name__}") | ||
AISpleennnUNetSegApp().run() | ||
logging.info(f"End {__name__}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
%YAML 1.2 | ||
# SPDX-FileCopyrightText: Copyright (c) 2022-2023 MONAI. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
--- | ||
application: | ||
title: MONAI Deploy App Package - Spleen MONet Seg Inference | ||
version: 1.0 | ||
inputFormats: ["file"] | ||
outputFormats: ["file"] | ||
|
||
resources: | ||
cpu: 1 | ||
gpu: 1 | ||
memory: 1Gi | ||
gpuMemory: 7Gi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
scikit-image>=0.17.2 | ||
pydicom>=2.3.0 | ||
highdicom>=0.18.2 | ||
SimpleITK>=2.0.0 | ||
Pillow>=8.0.0 | ||
numpy-stl>=2.12.0 | ||
trimesh>=3.8.11 | ||
nibabel>=3.2.1 | ||
torch>=1.12.0 | ||
nvflare | ||
git+https://github.com/SimoneBendazzoli93/dynamic-network-architectures.git | ||
git+https://github.com/SimoneBendazzoli93/MONAI.git@dev | ||
git+https://github.com/SimoneBendazzoli93/nnUNet.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Copyright 2002 MONAI Consortium | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from typing import Any, Dict, Tuple, Union | ||
|
||
from monai.deploy.core import Image | ||
from monai.deploy.operators.monai_bundle_inference_operator import MonaiBundleInferenceOperator, get_bundle_config | ||
from monai.deploy.utils.importutil import optional_import | ||
from monai.transforms import ConcatItemsd, ResampleToMatch | ||
|
||
torch, _ = optional_import("torch", "1.10.2") | ||
MetaTensor, _ = optional_import("monai.data.meta_tensor", name="MetaTensor") | ||
__all__ = ["MONetBundleInferenceOperator"] | ||
|
||
|
||
class MONetBundleInferenceOperator(MonaiBundleInferenceOperator): | ||
""" | ||
A specialized operator for performing inference using the MONet bundle. | ||
This operator extends the `MonaiBundleInferenceOperator` to support nnUNet-specific | ||
configurations and prediction logic. It initializes the nnUNet predictor and provides | ||
a method for performing inference on input data. | ||
|
||
Attributes | ||
---------- | ||
_nnunet_predictor : torch.nn.Module | ||
The nnUNet predictor module used for inference. | ||
|
||
Methods | ||
------- | ||
_init_config(config_names) | ||
Initializes the configuration for the nnUNet bundle, including parsing the bundle | ||
configuration and setting up the nnUNet predictor. | ||
predict(data, *args, **kwargs) | ||
Performs inference on the input data using the nnUNet predictor. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
*args, | ||
**kwargs, | ||
): | ||
|
||
super().__init__(*args, **kwargs) | ||
|
||
self._nnunet_predictor: torch.nn.Module = None | ||
|
||
def _init_config(self, config_names): | ||
|
||
super()._init_config(config_names) | ||
parser = get_bundle_config(str(self._bundle_path), config_names) | ||
self._parser = parser | ||
|
||
self._nnunet_predictor = parser.get_parsed_content("network_def") | ||
|
||
def _set_model_network(self, model_network): | ||
""" | ||
Sets the model network for the nnUNet predictor. | ||
|
||
Parameters | ||
---------- | ||
model_network : torch.nn.Module or torch.jit.ScriptModule | ||
The model network to be used for inference. | ||
""" | ||
if not isinstance(model_network, torch.nn.Module) and not torch.jit.isinstance(model_network, torch.jit.ScriptModule): | ||
raise TypeError("model_network must be an instance of torch.nn.Module or torch.jit.ScriptModule") | ||
self._model_network = model_network | ||
|
||
def predict(self, data: Any, *args, **kwargs) -> Union[Image, Any, Tuple[Any, ...], Dict[Any, Any]]: | ||
"""Predicts output using the inferer. If multimodal data is provided as keyword arguments, | ||
it concatenates the data with the main input data.""" | ||
|
||
self._set_model_network(self._nnunet_predictor) | ||
|
||
if len(kwargs) > 0: | ||
multimodal_data = {"image": data} | ||
for key in kwargs.keys(): | ||
if isinstance(kwargs[key], MetaTensor): | ||
multimodal_data[key] = ResampleToMatch(mode="bilinear")(kwargs[key], img_dst=data | ||
) | ||
data = ConcatItemsd(keys=list(multimodal_data.keys()),name="image")(multimodal_data)["image"] | ||
if len(data.shape) == 4: | ||
data = data[None] | ||
return self._nnunet_predictor(data) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Including dependencies directly from forks may hinder reproducibility; consider pinning to a stable release or official package versions.
Copilot uses AI. Check for mistakes.