From 38d7dd4376c631b85aa91fa5b31268cd6c6dd30d Mon Sep 17 00:00:00 2001 From: David Bouget Date: Wed, 19 Jun 2024 10:38:21 +0200 Subject: [PATCH] Backend requirements update and support for the cavity class (#78) * Testing the latest seg/rads lib * Quick-fix support for running cavity segmentation [skip ci] --- .github/workflows/build_macos.yml | 2 +- .../CentralAreaExecutionWidget.py | 19 ++++++++++++++++--- utils/data_structures/AnnotationStructure.py | 1 + utils/logic/PipelineCreationHandler.py | 10 ++++++---- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index bb2562a..bc5c7bd 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -45,7 +45,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install git+https://github.com/dbouget/raidionics_rads_lib.git@software + pip install git+https://github.com/dbouget/raidionics_rads_lib.git@master pip install -r assets/requirements.txt pip install matplotlib==3.3.4 pip install --force-reinstall --no-cache-dir pyside6 diff --git a/gui/SinglePatientComponent/CentralAreaExecutionWidget.py b/gui/SinglePatientComponent/CentralAreaExecutionWidget.py index 0015547..425dea9 100644 --- a/gui/SinglePatientComponent/CentralAreaExecutionWidget.py +++ b/gui/SinglePatientComponent/CentralAreaExecutionWidget.py @@ -146,7 +146,7 @@ def on_pipeline_execution(self, pipeline_code: str) -> None: """ self.model_name = "" - if ("Classification" not in pipeline_code) and ("Brain" not in pipeline_code) and ("postop" not in pipeline_code): + if ("Classification" not in pipeline_code) and ("Brain" not in pipeline_code) and ("postop" not in pipeline_code) and ("Edema" not in pipeline_code) and ("Cavity" not in pipeline_code): diag = TumorTypeSelectionQDialog(self) code = diag.exec_() if code == 0: # Operation cancelled @@ -165,10 +165,23 @@ def on_pipeline_execution(self, pipeline_code: str) -> None: self.model_name = self.model_name + '_multiclass' if diag.tumor_type == 'Low-Grade Glioma': self.model_name = "MRI_GBM_multiclass" + elif "postop" in pipeline_code: + diag = TumorTypeSelectionQDialog(self) + code = diag.exec_() + if code == 0: # Operation cancelled + return + if diag.tumor_type == 'Glioblastoma': + self.model_name = "MRI_GBM_Postop_FV_4p" + pipeline_code = pipeline_code + '_GBM' + elif diag.tumor_type == 'Low-Grade Glioma': + self.model_name = "MRI_LGGlioma_Postop" + pipeline_code = pipeline_code + '_LGGlioma' elif "Brain" in pipeline_code: self.model_name = "MRI_Brain" - elif "postop" in pipeline_code: - self.model_name = "MRI_GBM_Postop_FV_4p" + elif "Edema" in pipeline_code: + self.model_name = "MRI_Edema" + elif "Cavity" in pipeline_code: + self.model_name = "MRI_Cavity" self.process_started.emit() self.pipeline_main_wrapper(pipeline_code) diff --git a/utils/data_structures/AnnotationStructure.py b/utils/data_structures/AnnotationStructure.py index 70ba1f5..1835849 100644 --- a/utils/data_structures/AnnotationStructure.py +++ b/utils/data_structures/AnnotationStructure.py @@ -25,6 +25,7 @@ class AnnotationClassType(Enum): Tumor = 1, 'Tumor' Necrosis = 2, 'Necrosis' Edema = 3, 'Edema' + Cavity = 4, 'Cavity' Lungs = 100, 'Lungs' Airways = 101, 'Airways' diff --git a/utils/logic/PipelineCreationHandler.py b/utils/logic/PipelineCreationHandler.py index 4d81837..bd20ae0 100644 --- a/utils/logic/PipelineCreationHandler.py +++ b/utils/logic/PipelineCreationHandler.py @@ -63,8 +63,10 @@ def create_pipeline(model_name: str, patient_parameters, task: str) -> dict: return __create_folders_classification_pipeline() elif task == 'preop_segmentation': return __create_segmentation_pipeline(model_name, patient_parameters) - elif task == 'postop_segmentation': - model_name = select_appropriate_postop_model(patient_parameters) + elif 'postop_segmentation' in task: + # @TODO. Will have to clean up all this for dealing with the new use-cases... + if "GBM" in task: + model_name = select_appropriate_postop_model(patient_parameters) download_model(model_name=model_name) return __create_postop_segmentation_pipeline(model_name, patient_parameters) elif task == 'other_segmentation': @@ -392,7 +394,7 @@ def __create_custom_pipeline(task, tumor_type, patient_parameters): pip[pip_num]["description"] = "Lungs segmentation in T1CE (T{})".format(str(timestamp_order)) download_model(model_name="CT_Lungs") - if split_task[1] == 'Tumor': + if split_task[1] == 'Tumor' or split_task[1] == 'Edema' or split_task[1] == 'Cavity': infile = open(os.path.join(SoftwareConfigResources.getInstance().models_path, tumor_type, 'pipeline.json'), 'rb') raw_pip = json.load(infile) @@ -401,7 +403,7 @@ def __create_custom_pipeline(task, tumor_type, patient_parameters): pip_num_int = pip_num_int + 1 pip_num = str(pip_num_int) pip[pip_num] = raw_pip[steps] - if split_task[1] == 'Brain': + elif split_task[1] == 'Brain': infile = open(os.path.join(SoftwareConfigResources.getInstance().models_path, tumor_type, 'pipeline.json'), 'rb') raw_pip = json.load(infile)