Skip to content

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
wants to merge 217 commits into
base: main
Choose a base branch
from

Conversation

SimoneBendazzoli93
Copy link

This PR introduces support for the MONet Bundle (an nnUNet wrapper for the MONAI Bundle) into MONAI Deploy.

Key Features:

  • Added a new operator: MONetBundleInferenceOperator, extending MonaiBundleInferenceOperator

  • Included an example application demonstrating spleen segmentation using the MONetBundleInferenceOperator

@SimoneBendazzoli93 SimoneBendazzoli93 marked this pull request as ready for review June 17, 2025 12:50
@MMelQin MMelQin requested review from bluna301, MMelQin and Copilot June 25, 2025 15:41
Copilot

This comment was marked as outdated.

@MMelQin
Copy link
Collaborator

MMelQin commented Jun 27, 2025

@SimoneBendazzoli93 Please sign off the commits with the steps shown in the details of the DECO check error. Thanks.

@MMelQin MMelQin requested a review from Copilot June 27, 2025 00:29
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates the new MONetBundleInferenceOperator for nnUNet-based MONAI Bundles into MONAI Deploy and provides an example application demonstrating spleen segmentation.

  • Adds MONetBundleInferenceOperator subclassing the existing bundle inference operator to support nnUNet predictors.
  • Updates core operator file to fix a string method misuse and handle missing metadata.
  • Supplies a complete example app with requirements, pipeline code, and entrypoints.
Comments suppressed due to low confidence (2)

monai/deploy/operators/monet_bundle_inference_operator.py:1

  • [nitpick] The copyright year appears incorrect (2002); update to the current year or range (e.g., 2023).
# Copyright 2002 MONAI Consortium

examples/apps/ai_spleen_nnunet_seg_app/app.py:33

  • [nitpick] The class name has a typo with triple 'n' in AISpleennnUNetSegApp; consider renaming to AISpleenNnunetSegApp for clarity.
class AISpleennnUNetSegApp(Application):

nibabel>=3.2.1
torch>=1.12.0
nvflare
git+https://github.com/SimoneBendazzoli93/dynamic-network-architectures.git
Copy link
Preview

Copilot AI Jun 27, 2025

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.

MMelQin and others added 20 commits July 17, 2025 07:24
Signed-off-by: mmelqin <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
Signed-off-by: mmelqin <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
* Add the newly introduced example to readme.md

This is a a bit of a chicken-and-egg problem, since the readme.md refers
to the published latest version of the doc with which can only happen when
the release build is done, and this particular doc is part of the build,
included in the package to be pushed to pypi.org.

Next time, need to consider add the entry, with a placeholder/no-existent
URL prior to the release build, so that the content will show up in the new
package, and URL leads to valid content post build.

Signed-off-by: mmelqin <[email protected]>

* Added verbiage to name but a few tutorials.

Signed-off-by: mmelqin <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
…ONAI#316)

* DOC: Use upstream/downstream instead of source/destination

For monai.deploy.core.Operator, instead of sometimes using "upstream"
and "downstream" and sometimes using "source" and "destination",
consistently use former.

Signed-off-by: Lee Newberg <[email protected]>

* DOC: Use source/destination instead of upstream/downstream

For monai.deploy.core.Operator, instead of sometimes using "upstream"
and "downstream" and sometimes using "source" and "destination",
consistently use the latter.

Signed-off-by: Lee Newberg <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
* Implement highdicom seg operator

Signed-off-by: Chris Bridge <[email protected]>

* Formatting fixes

Signed-off-by: Chris Bridge <[email protected]>

* Typing fixes

Signed-off-by: Chris Bridge <[email protected]>

* Update the Spleen App to use HighDicom Seg Writer.

The app is still not compatible with monai v0.9.1 as the app testing
revealed that to its Invert transform failed resample the predicted
image back to input image spacings. Also, the new Seg Writer impl is
strict on DICOM attribute VR conformance, and would throw exception
when the input DICOM instances have non-conformant attribute VR values.

Signed-off-by: mmelqin <[email protected]>

* Fix isort error for ordering of imports

Signed-off-by: mmelqin <[email protected]>

* Update doc strings and comments for seg label and algorithm name and version

Signed-off-by: mmelqin <[email protected]>

* Pin moani==0.9.0 for now as 0.9.1 causes issues. Also pydicom to 2.3.0

as the use of highdicom require pydicom>=2.3.0

Signed-off-by: mmelqin <[email protected]>

* Updated apps that have multiple segments

Signed-off-by: mmelqin <[email protected]>

* Found the few missing codes, so avoided use of generic "Organ"

Signed-off-by: mmelqin <[email protected]>

Signed-off-by: Chris Bridge <[email protected]>
Signed-off-by: mmelqin <[email protected]>
Co-authored-by: mmelqin <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
Signed-off-by: mmelqin <[email protected]>

Signed-off-by: mmelqin <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
…roject-MONAI#337)

* Improve STL operator so the enclosing app obj can run repetitively with the new sample code

Signed-off-by: M Q <[email protected]>

* Fixing Flake8 complaints

Signed-off-by: M Q <[email protected]>

* Ignore Flake8 B024: abstract base class, but it has no abstract methods

Signed-off-by: M Q <[email protected]>

* Silence mypy complaint on types

Signed-off-by: M Q <[email protected]>

* Quiet another mypy error.

Signed-off-by: M Q <[email protected]>

* MyPy complaint fix

Signed-off-by: M Q <[email protected]>

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
…roject-MONAI#345)

* Added support of matching instance level tags, and update liver seg

Signed-off-by: M Q <[email protected]>

* Fix Flake8 complaint

Signed-off-by: M Q <[email protected]>

* Still enable publish intermediate nii files.

Signed-off-by: M Q <[email protected]>

* Corrections per review comments

Signed-off-by: M Q <[email protected]>

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
* Added support of matching instance level tags, and update liver seg

Signed-off-by: M Q <[email protected]>

* Fix Flake8 complaint

Signed-off-by: M Q <[email protected]>

* Still enable publish intermediate nii files.

Signed-off-by: M Q <[email protected]>

* Corrections per review comments

Signed-off-by: M Q <[email protected]>

* Enhance attribute settings

Signed-off-by: M Q <[email protected]>

* Fixed styling complaints

Signed-off-by: M Q <[email protected]>

* Fix MyPy complaint

Signed-off-by: M Q <[email protected]>

* Use content sequence for section of text

Signed-off-by: M Q <[email protected]>

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
Signed-off-by: kavink <[email protected]>

Signed-off-by: kavink <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
…roject-MONAI#360)

* Updated to be compitable with monai 1.0.0 and its MetaTensor

Signed-off-by: M Q <[email protected]>

* Made bundle inference operator compatible with MetaTensor

Signed-off-by: M Q <[email protected]>

* Removed the use of ToTensor from all apps.

Signed-off-by: M Q <[email protected]>

* Fix MyPy complaints

Signed-off-by: M Q <[email protected]>

* Fix isort complaint

Signed-off-by: M Q <[email protected]>

* Use a constant for repeated use of monai.utils str literal; SonarCloud code smell.

Signed-off-by: M Q <[email protected]>

* Updated Seg Writer and Spleen Seg Jupyter notebooks

Signed-off-by: M Q <[email protected]>

* Minor to address comments and checker complaint

Signed-off-by: M Q <[email protected]>

* Updated clara-viz Jupyter notebook and fixed checking complaint

Signed-off-by: M Q <[email protected]>

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
Signed-off-by: Andres <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
Signed-off-by: Andres <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
…SR Writer (Project-MONAI#366)

* Created dicom_utils for common obj and func, and added DICOM PDF Writer

Signed-off-by: M Q <[email protected]>

* Formatting update

Signed-off-by: M Q <[email protected]>

* Fix flake8 complaints

Signed-off-by: M Q <[email protected]>

* Address mypy complaints

Signed-off-by: M Q <[email protected]>

* Formatting

Signed-off-by: M Q <[email protected]>

* Change to use full path of dicom_utils

Signed-off-by: M Q <[email protected]>

* Replace Union with Optional

Signed-off-by: M Q <[email protected]>

* Replace unused Union

Signed-off-by: M Q <[email protected]>

* Update the year in the copyright notice

Signed-off-by: M Q <[email protected]>

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
* Add the missing python package, PyPDF2

Signed-off-by: M Q <[email protected]>

* Add PyPDF2>=2.11.1

Signed-off-by: M Q <[email protected]>

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
Signed-off-by: M Q <[email protected]>

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
WillButAgain and others added 23 commits July 17, 2025 07:24
* fix casting, add check

Signed-off-by: will tepe <[email protected]>

* code review changes

Signed-off-by: will tepe <[email protected]>

* fix fir slope as well

---------

Signed-off-by: will tepe <[email protected]>
Co-authored-by: will tepe <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
…#537)

* The tag value for usinged int is 0

Signed-off-by: M Q <[email protected]>

* Fix formmating complaints

Signed-off-by: M Q <[email protected]>

---------

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
* Prepared changes for releasing v3

Signed-off-by: M Q <[email protected]>

* Bump the required version to 3.9

Signed-off-by: M Q <[email protected]>

* Update Python version references to 3.9 in documentation and configuration files

- Updated .gitignore to include new input and test directories.
- Changed Python version from 3.8 to 3.9 in .readthedocs.yml, setup.cfg, and run script.
- Updated documentation to reflect the use of Python 3.9 in various tutorials.

Signed-off-by: M Q <[email protected]>

---------

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
- Removed unnecessary logic in setup.py
- Fix versioneer issues

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
* Bump version: 2.0.0 → 3.0.0

Signed-off-by: M Q <[email protected]>

* Bump version: 2.0.0 -> 3.0.0 with __init__.py fix

Signed-off-by: M Q <[email protected]>

* Remove blank line complained by black

Signed-off-by: M Q <[email protected]>

* Fix more formatting complaints

Signed-off-by: M Q <[email protected]>

---------

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
…ator and add implementation

Signed-off-by: Simone Bendazzoli <[email protected]>
* hugging_face_integration_app dependency cleanup

Signed-off-by: bluna301 <[email protected]>

* cchmc_ped_abd_ct_seg example app

Signed-off-by: bluna301 <[email protected]>

* license update + code optimizations

Signed-off-by: bluna301 <[email protected]>

* cleanup

Signed-off-by: bluna301 <[email protected]>

* spelling + dependency cleanup

Signed-off-by: bluna301 <[email protected]>

* model DICOM tag cleanup

Signed-off-by: bluna301 <[email protected]>

---------

Signed-off-by: bluna301 <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
…roject-MONAI#536)

* Adding requirements for Triton client impl

Signed-off-by: M Q <[email protected]>

* Updated/added core classes to support Triton remote inference, and added a new example

Signed-off-by: M Q <[email protected]>

* GitHub build server complains about conflicts for tritonclient[]>=2.54 for no specific reasons

Signed-off-by: M Q <[email protected]>

* Fix flake8 complaints

Signed-off-by: M Q <[email protected]>

* Fix pytype complaints by simplifying code

Signed-off-by: M Q <[email protected]>

* Remove now unused imports

Signed-off-by: M Q <[email protected]>

* Addressed all pytype and mypy complaint in new code in the dev env

Signed-off-by: M Q <[email protected]>

* No complaint in local dev env, but on GitHub

Signed-off-by: M Q <[email protected]>

* Add model confgi.pbtxt and example env settings

Signed-off-by: M Q <[email protected]>

* Doc update

Signed-off-by: M Q <[email protected]>

* update license dates

Signed-off-by: M Q <[email protected]>

* Updated the copyright year of new files

Signed-off-by: M Q <[email protected]>

---------

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
* Prepared changes for releasing v3

Signed-off-by: M Q <[email protected]>

* Bump the required version to 3.9

Signed-off-by: M Q <[email protected]>

* Update Python version references to 3.9 in documentation and configuration files

- Updated .gitignore to include new input and test directories.
- Changed Python version from 3.8 to 3.9 in .readthedocs.yml, setup.cfg, and run script.
- Updated documentation to reflect the use of Python 3.9 in various tutorials.

Signed-off-by: M Q <[email protected]>

---------

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
- Removed unnecessary logic in setup.py
- Fix versioneer issues

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
* Bump version: 2.0.0 → 3.0.0

Signed-off-by: M Q <[email protected]>

* Bump version: 2.0.0 -> 3.0.0 with __init__.py fix

Signed-off-by: M Q <[email protected]>

* Remove blank line complained by black

Signed-off-by: M Q <[email protected]>

* Fix more formatting complaints

Signed-off-by: M Q <[email protected]>

---------

Signed-off-by: M Q <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
…NetBundleInferenceOperator

Signed-off-by: Simone Bendazzoli <[email protected]>
* series selector improvements

Signed-off-by: bluna301 <[email protected]>

* PatientPosition tag check

Signed-off-by: bluna301 <[email protected]>

* exclusion matching for set type

Signed-off-by: bluna301 <[email protected]>

---------

Signed-off-by: bluna301 <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
@SimoneBendazzoli93 SimoneBendazzoli93 force-pushed the main branch 2 times, most recently from 677f748 to 3b127ed Compare July 17, 2025 07:57
Signed-off-by: Simone Bendazzoli <[email protected]>
Signed-off-by: Simone Bendazzoli <[email protected]>
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
32.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.