Skip to content

Add coronary artery segmentation bundle (CoronSegmentator) #761

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 9 commits into
base: dev
Choose a base branch
from

Conversation

Foxconn-bgroup-aidd
Copy link

proposed Model: CoronSegmentator

This PR adds a new coronary artery segmentation model named coronsegmentator under models/coronsegmentator/.

Coronsegmentator is an automated pipeline that performs dual-task segmentation on cardiac CT images, focusing on both whole-heart and coronary artery structures. It integrates MONAI’s Auto3DSeg for general cardiac segmentation and a custom nnU-Net model for detailed coronary artery segmentation. The pipeline further converts segmentation results (in STL format) into USD files for downstream 3D visualization and digital twin simulation using NVIDIA Omniverse.

@Nic-Ma Nic-Ma requested review from yiheng-wang-nv and KumoLiu July 21, 2025 16:22
@@ -0,0 +1,7 @@
Input/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @Foxconn-bgroup-aidd , can we remove this file?
A part of files are already ignored (set in https://github.com/Project-MONAI/model-zoo/blob/dev/.gitignore), and for customized folder like Input/ and Output/, I think we can remove them directly. What do you think?

Choose a reason for hiding this comment

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

There is no problem removing them. Thanks.

@@ -0,0 +1,17 @@
{
"bundle_root": "./",
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you prepare a unit test script?
It's helpful to check if (1) large files are downloadable (2) inference pipeline works (3) dependencies mentioned in metadata are correct and enough to run the script.

You can refer to this example to prepare the script: https://github.com/Project-MONAI/model-zoo/blob/dev/ci/unit_tests/test_spleen_ct_segmentation.py

Copy link

@tylin7111095022 tylin7111095022 Jul 23, 2025

Choose a reason for hiding this comment

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

@yiheng-wang-nv, I prepare the script refer to above url. but when I try to run the script , I got the error: ModuleNotFoundError: Cannot locate class or function path: 'scripts.heart_digital_twin.CoroSegmentator_Pipeline'. It seems to can't access the custom class is defined in inference.json. I put the script in ci/unitest/ folder and run the script at model_zoo root directory. How can I solve the problem? Thanks for answer. Following is revised inference.json:

{
  "imports": ["$import glob"],
  "bundle_root": "./",
  "ckpt_dir": "$@bundle_root + 'models'",
  "dataset_dir": "",
  "data": "$list(sorted(glob.glob(@dataset_dir + '/*.nii.gz')))",
  "output_ext": ".usd",
  "output_dir": "$@bundle_root + 'Output'",
  "device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
  "inferer": {
    "_target_": "scripts.heart_digital_twin.CoroSegmentator_Pipeline",
    "input_params": {
      "inputFile": "$@data[0]",
      "outputDir": "$@output_dir"
    }
  },

  "dataset": {},
  "evaluator": {},
  "network_def": {},

  "run": ["[email protected]()"]
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @Foxconn-bgroup-aidd, please try create an init.py file in the scripts directory to make it as Python packages and also put the scripts folder just under you bundle instead of under the unittest folder. Thanks.

Choose a reason for hiding this comment

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

Thanks for comment, @KumoLiu . Following is my directory tree of project

model-zoo/
|--ci/
    |--unit_tests/
        |--test_coronaryArtery_ct_segmentation.py
|--models/
    |--myBundle/
        |--large_file.yml
        |--LICENSE
        |--configs/
            |--inference.json
            |--metadata.json
        |--docs/
        |--models/
        |--scripts/
            |--__init__.py
            |--heartDitgitalTwin.py

I run the python ci/unit_tests/test_coronaryArtery_ct_segmentation.py and got the ModuleNotFoundError: Cannot locate class or function path: 'scripts.heart_digital_twin.CoroSegmentator_Pipeline'. I still try to solve the problem which pydoc.locate(scripts.heart_digital_twin.CoroSegmentator_Pipeline) can't access custom class. Thanks for help.

Choose a reason for hiding this comment

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

@KumoLiu I add the path of bundle into the sys.path and solve it, Thanks!

Copy link
Collaborator

@KumoLiu KumoLiu left a comment

Choose a reason for hiding this comment

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

Hi @Foxconn-bgroup-aidd, thanks for the contributions! Leave several comments inline.

@@ -0,0 +1,88 @@
{
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @Foxconn-bgroup-aidd, could you please utilize the latest schema available at the following link:
"https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20240725.json"

Based on the content, it appears that you are already using the most recent version, as it includes "required_packages_version." Thanks.

Comment on lines 10 to 13
"monai": " 1.4.0",
"nnunetv2": "2.6.0",
"nibabel": "5.3.2",
"numpy": "2.3.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please double check the monai version you are using, the one mentioned above is "1.4.0"? Thanks!

Suggested change
"monai": " 1.4.0",
"nnunetv2": "2.6.0",
"nibabel": "5.3.2",
"numpy": "2.3.1",
"nnunetv2": "2.6.0",
"nibabel": "5.3.2",

Comment on lines 77 to 78
"0": "Background",
"1": "Coronary Artery"
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems the "num_channels" is only one for the outputs.

Comment on lines 83 to 87
"optional_packages_version": {
"monai": "1.3.2",
"torch": "2.7.0+cu126",
"numpy": "2.3.1"
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess you can remove this part, the "optional_packages_version" is no longer a required one in the latest schema. thanks.

Copy link
Author

@Foxconn-bgroup-aidd Foxconn-bgroup-aidd Jul 23, 2025

Choose a reason for hiding this comment

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

The version of monai used in our project is “1.4.0”. “optional_packages_version" will be removed.

Comment on lines +45 to +46
The ImageCAS dataset is publicly available at:
https://github.com/XiaoweiXu/ImageCAS-A-Large-Scale-Dataset-and-Benchmark-for-Coronary-Artery-Segmentation-based-on-CT.git''
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be better to mention the dataset link in the "Data" section, what do you think?

Comment on lines 174 to 183
# try:
# Step 1: Convert input to NRRD
input_nrrd = self._convert_to_nrrd(self.input_path, input_tmp_dir)
# Step 2: Run segmentation
seg_nrrd = self._run_segmentation(input_nrrd, output_tmp_dir)
# Step 3: Process results
self._process_segmentation_results(seg_nrrd, output_tmp_dir)
# except Exception as e:
# logger.error(f"Processing failed: {str(e)}")
# raise
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please remove the comment code here or perhaps include the try-catch logic is also make sense.

base_center = Gf.Vec3d(
(bbox_min[0] + bbox_max[0]) / 2, bbox_min[1], (bbox_min[2] + bbox_max[2]) / 2
)
# 计算平移量,使得基底中心移动到原点
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please check and remove all Chinese comments inline. Thanks.

"output_ext": ".usd",
"input_file": "Input/E_CT_0000.nii.gz",
"infer": {
"_target_": "scripts.heart_digital_twin.CoroSegmentator_Pipeline",
Copy link
Collaborator

Choose a reason for hiding this comment

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

As @yiheng-wang-nv mentioned above, please include the unit test to ensure the bundle works as expected.
I didn't see this file under the scripts folder.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mis-delete this test file?

Choose a reason for hiding this comment

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

We have fixed the issue of incorrectly deleting test files.

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.

4 participants