-
Notifications
You must be signed in to change notification settings - Fork 82
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
base: dev
Are you sure you want to change the base?
Add coronary artery segmentation bundle (CoronSegmentator) #761
Conversation
models/CoronSegmentator/.gitignore
Outdated
@@ -0,0 +1,7 @@ | |||
Input/ |
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.
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?
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.
There is no problem removing them. Thanks.
@@ -0,0 +1,17 @@ | |||
{ | |||
"bundle_root": "./", |
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.
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
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.
@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]()"]
}
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.
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.
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.
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.
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.
@KumoLiu I add the path of bundle into the sys.path and solve it, Thanks!
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.
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", |
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.
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.
"monai": " 1.4.0", | ||
"nnunetv2": "2.6.0", | ||
"nibabel": "5.3.2", | ||
"numpy": "2.3.1", |
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.
Could you please double check the monai version you are using, the one mentioned above is "1.4.0"? Thanks!
"monai": " 1.4.0", | |
"nnunetv2": "2.6.0", | |
"nibabel": "5.3.2", | |
"numpy": "2.3.1", | |
"nnunetv2": "2.6.0", | |
"nibabel": "5.3.2", |
"0": "Background", | ||
"1": "Coronary Artery" |
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.
It seems the "num_channels" is only one for the outputs.
"optional_packages_version": { | ||
"monai": "1.3.2", | ||
"torch": "2.7.0+cu126", | ||
"numpy": "2.3.1" | ||
} |
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.
I guess you can remove this part, the "optional_packages_version" is no longer a required one in the latest schema. thanks.
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.
The version of monai used in our project is “1.4.0”. “optional_packages_version" will be removed.
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'' |
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.
Would be better to mention the dataset link in the "Data" section, what do you think?
# 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 |
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.
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 | ||
) | ||
# 计算平移量,使得基底中心移动到原点 |
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.
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", |
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.
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.
…and metadata.json
…/model-zoo into 760-CoronSegmentator
for more information, see https://pre-commit.ci
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.
Did you mis-delete this test file?
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.
We have fixed the issue of incorrectly deleting test files.
…/model-zoo into 760-CoronSegmentator
for more information, see https://pre-commit.ci
proposed Model: CoronSegmentator
This PR adds a new coronary artery segmentation model named
coronsegmentator
undermodels/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.