From e091ee39475544e48ee9b4a942b189f420ffc152 Mon Sep 17 00:00:00 2001 From: jakob Date: Thu, 16 Jan 2025 13:25:27 +0100 Subject: [PATCH] update coronary_arteries model --- .github/workflows/run_tests_nnunet.yml | 4 ++-- README.md | 4 ++-- .../bin/totalseg_download_weights.py | 2 +- .../download_pretrained_weights.py | 2 +- totalsegmentator/libs.py | 7 ++----- totalsegmentator/python_api.py | 19 ++++++++++--------- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/workflows/run_tests_nnunet.yml b/.github/workflows/run_tests_nnunet.yml index 5c24b0acb..f0b7e90f7 100644 --- a/.github/workflows/run_tests_nnunet.yml +++ b/.github/workflows/run_tests_nnunet.yml @@ -8,8 +8,8 @@ jobs: run-tests: strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest] # fails on windows until https://github.com/MIC-DKFZ/nnUNet/issues/2396 is resolved - # os: [ubuntu-latest, macos-latest] + # os: [ubuntu-latest, windows-latest, macos-latest] # fails on windows until https://github.com/MIC-DKFZ/nnUNet/issues/2396 is resolved + os: [ubuntu-latest, macos-latest] python-version: ["3.10"] runs-on: ${{ matrix.os }} diff --git a/README.md b/README.md index b09049808..de875cc15 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,6 @@ Openly available for any usage: * **vertebrae_mr**: sacrum, vertebrae_L5, vertebrae_L4, vertebrae_L3, vertebrae_L2, vertebrae_L1, vertebrae_T12, vertebrae_T11, vertebrae_T10, vertebrae_T9, vertebrae_T8, vertebrae_T7, vertebrae_T6, vertebrae_T5, vertebrae_T4, vertebrae_T3, vertebrae_T2, vertebrae_T1, vertebrae_C7, vertebrae_C6, vertebrae_C5, vertebrae_C4, vertebrae_C3, vertebrae_C2, vertebrae_C1 (for CT this is part of the `total` task) * **cerebral_bleed**: intracerebral_hemorrhage (cite [paper](https://www.mdpi.com/2077-0383/12/7/2631))* * **hip_implant**: hip_implant* -* **coronary_arteries**: coronary_arteries* * **pleural_pericard_effusion**: pleural_effusion (cite [paper](http://dx.doi.org/10.1097/RLI.0000000000000869)), pericardial_effusion (cite [paper](http://dx.doi.org/10.3390/diagnostics12051045))* * **head_glands_cavities**: eye_left, eye_right, eye_lens_left, eye_lens_right, optic_nerve_left, optic_nerve_right, parotid_gland_left, parotid_gland_right, submandibular_gland_right, submandibular_gland_left, nasopharynx, oropharynx, hypopharynx, nasal_cavity_right, nasal_cavity_left, auditory_canal_right, auditory_canal_left, soft_palate, hard_palate (cite [paper](https://www.mdpi.com/2072-6694/16/2/415)) * **head_muscles**: masseter_right, masseter_left, temporalis_right, temporalis_left, lateral_pterygoid_right, lateral_pterygoid_left, medial_pterygoid_right, medial_pterygoid_left, tongue, digastric_right, digastric_left @@ -73,7 +72,7 @@ Openly available for any usage: * **headneck_muscles**: sternocleidomastoid_right, sternocleidomastoid_left, superior_pharyngeal_constrictor, middle_pharyngeal_constrictor, inferior_pharyngeal_constrictor, trapezius_right, trapezius_left, platysma_right, platysma_left, levator_scapulae_right, levator_scapulae_left, anterior_scalene_right, anterior_scalene_left, middle_scalene_right, middle_scalene_left, posterior_scalene_right, posterior_scalene_left, sterno_thyroid_right, sterno_thyroid_left, thyrohyoid_right, thyrohyoid_left, prevertebral_right, prevertebral_left (cite [paper](https://www.mdpi.com/2072-6694/16/2/415)) * **liver_vessels**: liver_vessels, liver_tumor (cite [paper](https://arxiv.org/abs/1902.09063))* * **oculomotor_muscles**: skull, eyeball_right, lateral_rectus_muscle_right, superior_oblique_muscle_right, levator_palpebrae_superioris_right, superior_rectus_muscle_right, medial_rectus_muscle_left, inferior_oblique_muscle_right, inferior_rectus_muscle_right, optic_nerve_left, eyeball_left, lateral_rectus_muscle_left, superior_oblique_muscle_left, levator_palpebrae_superioris_left, superior_rectus_muscle_left, medial_rectus_muscle_right, inferior_oblique_muscle_left, inferior_rectus_muscle_left, optic_nerve_right* -* **lung_nodules**: lung, lung_nodules (this model is kindly provided by [BLUEMIND AI](https://bluemind.co/)) +* **lung_nodules**: lung, lung_nodules (provided by [BLUEMIND AI](https://bluemind.co/): Fitzjalen R., Aladin M., Nanyan G.) (trained on 1353 subjects, partly from LIDC-IDRI) * **kidney_cysts**: kidney_cyst_left, kidney_cyst_right (strongly improved accuracy compared to kidney_cysts inside of `total` task) * **breasts**: breast @@ -91,6 +90,7 @@ Available with a license (free licenses available for non-commercial usage [here * **face_mr**: face_region (for anonymization) * **thigh_shoulder_muscles**: thigh_posterior_compartment_left, thigh_posterior_compartment_right, sartorius_left, sartorius_right, pectoralis_minor, serratus_anterior, teres_major, triceps_brachii (WIP) * **thigh_shoulder_muscles_mr**: thigh_posterior_compartment_left, thigh_posterior_compartment_right, sartorius_left, sartorius_right, pectoralis_minor, serratus_anterior, teres_major, triceps_brachii (for MR images) +* **coronary_arteries**: coronary_arteries (also works on non-contrast images) Usage: ``` diff --git a/totalsegmentator/bin/totalseg_download_weights.py b/totalsegmentator/bin/totalseg_download_weights.py index afbccafed..226723670 100644 --- a/totalsegmentator/bin/totalseg_download_weights.py +++ b/totalsegmentator/bin/totalseg_download_weights.py @@ -40,7 +40,7 @@ def main(): "lung_vessels": [258], "cerebral_bleed": [150], "hip_implant": [260], - "coronary_arteries": [503], + "coronary_arteries": [507], "pleural_pericard_effusion": [315], "body": [299], "body_fast": [300], diff --git a/totalsegmentator/download_pretrained_weights.py b/totalsegmentator/download_pretrained_weights.py index 5347e974c..885ae3b52 100644 --- a/totalsegmentator/download_pretrained_weights.py +++ b/totalsegmentator/download_pretrained_weights.py @@ -6,7 +6,7 @@ """ Download all pretrained weights """ - for task_id in [291, 292, 293, 294, 295, 297, 298, 258, 150, 260, 503, + for task_id in [291, 292, 293, 294, 295, 297, 298, 258, 150, 260, 315, 299, 300, 850, 851, 852, 853, 775, 776, 777, 778, 779]: download_pretrained_weights(task_id) diff --git a/totalsegmentator/libs.py b/totalsegmentator/libs.py index 2af76041f..80a36b16c 100644 --- a/totalsegmentator/libs.py +++ b/totalsegmentator/libs.py @@ -292,11 +292,6 @@ def download_pretrained_weights(task_id): # WEIGHTS_URL = "https://zenodo.org/record/7510288/files/Task315_thoraxCT.zip?download=1" # WEIGHTS_URL = url + "/static/totalseg_v2/Dataset315_thoraxCT.zip" WEIGHTS_URL = url + "/v2.0.0-weights/Dataset315_thoraxCT.zip" - elif task_id == 503: - weights_path = config_dir / "Dataset503_cardiac_motion" - # WEIGHTS_URL = "https://zenodo.org/record/7271576/files/Task503_cardiac_motion.zip?download=1" - # WEIGHTS_URL = url + "/static/totalseg_v2/Dataset503_cardiac_motion.zip" - WEIGHTS_URL = url + "/v2.0.0-weights/Dataset503_cardiac_motion.zip" elif task_id == 8: weights_path = config_dir / "Dataset008_HepaticVessel" WEIGHTS_URL = url + "/v2.4.0-weights/Dataset008_HepaticVessel.zip" @@ -325,6 +320,8 @@ def download_pretrained_weights(task_id): weights_path = config_dir / "Dataset409_neuro_550subj" elif task_id == 857: weights_path = config_dir / "Dataset857_TotalSegMRI_thigh_shoulder_1088subj" + elif task_id == 507: + weights_path = config_dir / "Dataset507_coronary_arteries_cm_nativ_400subj" else: raise ValueError(f"For task_id {task_id} no download path was found.") diff --git a/totalsegmentator/python_api.py b/totalsegmentator/python_api.py index c0e62c8d9..5758153ff 100644 --- a/totalsegmentator/python_api.py +++ b/totalsegmentator/python_api.py @@ -216,15 +216,6 @@ def totalsegmentator(input: Union[str, Path, Nifti1Image], output: Union[str, Pa model = "3d_fullres" folds = [0] if fast: raise ValueError("task hip_implant does not work with option --fast") - elif task == "coronary_arteries": - task_id = 503 - resample = None - trainer = "nnUNetTrainer" - crop = ["heart"] - model = "3d_fullres" - folds = [0] - print("WARNING: The coronary artery model does not work very robustly. Use with care!") - if fast: raise ValueError("task coronary_arteries does not work with option --fast") elif task == "body": if fast: task_id = 300 @@ -463,6 +454,16 @@ def totalsegmentator(input: Union[str, Path, Nifti1Image], output: Union[str, Pa folds = [0] if fast: raise ValueError("task thigh_shoulder_muscles_mr does not work with option --fast") show_license_info() + elif task == "coronary_arteries": + task_id = 507 + resample = [0.7, 0.7, 0.7] + trainer = "nnUNetTrainer_DASegOrd0_NoMirroring" + crop = ["heart"] + crop_addon = [20, 20, 20] + model = "3d_fullres_high" + folds = [0] + if fast: raise ValueError("task coronary_arteries does not work with option --fast") + show_license_info() elif task == "test": task_id = [517]