Skip to content

Commit 8f3bc68

Browse files
Restore deleted unit test: test_brain_image_synthesis_latent_diffusion_model.py
2 parents 009a68f + c8b3ad0 commit 8f3bc68

File tree

8 files changed

+126
-57
lines changed

8 files changed

+126
-57
lines changed

ci/unit_tests/test_brain_image_synthesis_latent_diffusion_model.py

Lines changed: 0 additions & 47 deletions
This file was deleted.

ci/unit_tests/test_coronaryArtery_ct_segmentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ def test_infer_config(self, override):
8383
if __name__ == "__main__":
8484
loader = unittest.TestLoader()
8585
loader.sortTestMethodsUsing = test_order
86-
unittest.main(testLoader=loader)
86+
unittest.main(testLoader=loader)

models/CoronSegmentator/configs/inference.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,27 @@
2020
"network_def": {},
2121

2222
"run": ["[email protected]()"]
23+
"imports": [
24+
"$import glob"
25+
],
26+
"bundle_root": ".",
27+
"ckpt_dir": "$@bundle_root + '/models'",
28+
"dataset_dir": "",
29+
"data": "$list(sorted(glob.glob(@dataset_dir + '/*.nii.gz')))",
30+
"output_ext": ".usd",
31+
"output_dir": "$@bundle_root + '/Output'",
32+
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
33+
"inferer": {
34+
"_target_": "scripts.heart_digital_twin.CoroSegmentator_Pipeline",
35+
"input_params": {
36+
"inputFile": "$@data[0]",
37+
"outputDir": "$@output_dir"
38+
}
39+
},
40+
"dataset": {},
41+
"evaluator": {},
42+
"network_def": {},
43+
"run": [
44+
45+
]
2346
}

models/CoronSegmentator/configs/logging.conf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ formatter=fullFormatter
1818
args=(sys.stdout,)
1919

2020
[formatter_fullFormatter]
21-
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
21+
<<<<<<< HEAD
22+
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
23+
=======
24+
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
25+
>>>>>>> c8b3ad0a5842cf425f0ffb9355bfcb67ce994382

models/CoronSegmentator/configs/metadata.json

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
<<<<<<< HEAD
23
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
34
"name": "coronaryArtery_ct_segmentation",
45
"version": "1.0.0",
@@ -71,4 +72,92 @@
7172
"numpy": "2.3.1"
7273
}
7374
}
74-
}
75+
}
76+
=======
77+
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
78+
"name": "coronaryArtery_ct_segmentation",
79+
"version": "1.0.0",
80+
"monai_version": "1.4.0",
81+
"pytorch_version": "1.4.0",
82+
"numpy_version": "2.3.1",
83+
"required_packages_version": {
84+
"fire": "0.7.0",
85+
"PyYAML": "6.0.2",
86+
"gdown": "5.2.0",
87+
"nnunetv2": "2.6.0",
88+
"nibabel": "5.3.2",
89+
"numpy_stl": "3.2.0",
90+
"pynrrd": "1.1.3",
91+
"scipy": "1.16.0",
92+
"simpleitk": "2.5.0",
93+
"scikit-image": "0.25.2",
94+
"torch": "2.7.0+cu126",
95+
"trimesh": "4.6.10",
96+
"usd_core": "25.5.1",
97+
"numpy-stl": "3.2.0"
98+
},
99+
"task": "Coronary artery ct segmentation",
100+
"description": "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 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.",
101+
"authors": "Y. Ke, MC. Chen, TY. Lin, YC. Chan Foxconn Digital Health AI Team",
102+
"copyright": "Copyright \u00a9 2025 Hon Hai Precision Industry Co.,Ltd. All rights reserved",
103+
"data_source": "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",
104+
"data_type": "nifti",
105+
"image_classes": "3D volume data",
106+
"label_classes": "single channel data, 1 is coronary artery, 0 is background",
107+
"pred_classes": "2 channels OneHot data, channel 1 is coronary artery, channel 0 is background",
108+
"intended_use": "This is an example, not to be used for diagnostic purposes",
109+
"references": [
110+
"Zeng, An, et al. ImageCAS: A large-scale dataset and benchmark for coronary artery segmentation based on computed tomography angiography images. Computerized Medical Imaging and Graphics 109 (2023): 102287.",
111+
"Isensee, Fabian, et al. nnU-Net: a self-configuring method for deep learning-based biomedical image segmentation. Nature methods 18.2 (2021): 203-211."
112+
],
113+
"network_data_format": {
114+
"inputs": {
115+
"image": {
116+
"type": "image",
117+
"format": "hounsfield",
118+
"modality": "CT",
119+
"num_channels": 1,
120+
"spatial_shape": [
121+
512,
122+
512,
123+
256
124+
],
125+
"dtype": "float32",
126+
"value_range": [
127+
0,
128+
1
129+
],
130+
"is_patch_data": true,
131+
"channel_def": {
132+
"0": "image"
133+
}
134+
}
135+
},
136+
"outputs": {
137+
"pred": {
138+
"type": "usd",
139+
"format": "segmentation",
140+
"num_channels": 1,
141+
"spatial_shape": [
142+
512,
143+
512,
144+
256
145+
],
146+
"dtype": "float32",
147+
"value_range": [
148+
0,
149+
1
150+
],
151+
"channel_def": {
152+
"0": "Coronary Artery (1 = target, 0 = background)"
153+
}
154+
}
155+
},
156+
"optional_packages_version": {
157+
"monai": "1.3.2",
158+
"torch": "2.7.0+cu126",
159+
"numpy": "2.3.1"
160+
}
161+
}
162+
}
163+
>>>>>>> c8b3ad0a5842cf425f0ffb9355bfcb67ce994382

models/CoronSegmentator/scripts/coronaryArtery_segmentation/coronaryArtery_seg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def initialize_vertex_map(self):
126126
"""
127127
if self.num_triangles == 0:
128128
return
129-
129+
130130
vectors = self.original_mesh.vectors
131131
# Process in batches to reduce memory pressure
132132
batch_size = min(10000, self.num_triangles) # Adjust batch size based on available memory

models/CoronSegmentator/scripts/download.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def _calculate_md5(filepath: Path, block_size: int = 65536) -> str:
1212
Calculate md5 value of file
1313
"""
1414
md5 = hashlib.md5()
15-
15+
1616
with open(filepath, 'rb') as f:
1717
for block in iter(lambda: f.read(block_size), b''):
1818
md5.update(block)
@@ -30,7 +30,7 @@ def download_and_verify():
3030
"""
3131
with open(DOWNLOAD_CONFIG, 'r') as file:
3232
downloadConfig = yaml.safe_load(file)
33-
33+
3434
for fileInfo in downloadConfig['large_files']:
3535
rel_path = fileInfo.get("path")
3636
url = fileInfo.get("url")
@@ -52,4 +52,4 @@ def download_and_verify():
5252

5353
final_hash = _calculate_md5(destination_path)
5454
if final_hash != expected_hash:
55-
raise RuntimeError(f"final_hash donesn't match expected_hash")
55+
raise RuntimeError(f"final_hash donesn't match expected_hash")

models/CoronSegmentator/scripts/file_process/file_conversion.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,17 @@ def convert_nrrd_to_stl(nrrd_file_path, stl_file_path, gaussian_sigma=1.0):
8686
raise RuntimeError(f"Failed during image smoothing: {str(e)}")
8787

8888
logger.debug("Converting image to numpy array")
89-
89+
9090
volume_data = sitk.GetArrayFromImage(smoothed_image)
9191
del smoothed_image
9292
logger.debug("Generating mesh using marching cubes algorithm")
9393

9494
if np.all(volume_data == 0):
95-
95+
9696
dummy_vertices = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
9797
dummy_faces = [[0, 1, 2]]
9898
mesh_obj = trimesh.Trimesh(vertices=dummy_vertices, faces=dummy_faces)
99-
99+
100100
else:
101101
verts, faces, _, _ = marching_cubes(volume_data, level=0.5)
102102
del volume_data

0 commit comments

Comments
 (0)