diff --git a/models/bamf_nnunet_ct_liver/config/default.yml b/models/bamf_nnunet_ct_liver/config/default.yml index 149948a1..9f7c777b 100644 --- a/models/bamf_nnunet_ct_liver/config/default.yml +++ b/models/bamf_nnunet_ct_liver/config/default.yml @@ -19,21 +19,17 @@ modules: meta: mod: '%Modality' - NiftiConverter: - NNUnetRunner: - in_data: 'nifti:mod=ct' - nnunet_task: 'Task773_Liver' - nnunet_model: '3d_fullres' + in_data: nifti:mod=ct + nnunet_task: Task773_Liver + nnunet_model: 3d_fullres roi: LIVER BamfProcessorRunner: - in_data: 'nifti:mod=ct' DsegConverter: - model_name: 'Bamf NNUnet CT Liver' + model_name: Bamf NNUnet CT Liver skip_empty_slices: True - json_config_path: '/app/models/bamf_nnunet_ct_liver/config/meta.json' DataOrganizer: targets: diff --git a/models/bamf_nnunet_ct_liver/config/meta.json b/models/bamf_nnunet_ct_liver/config/meta.json deleted file mode 100644 index 45310ab4..00000000 --- a/models/bamf_nnunet_ct_liver/config/meta.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "ContentCreatorName": "BAMFHealth^AI", - "ClinicalTrialSeriesID": "Session1", - "ClinicalTrialTimePointID": "1", - "SeriesDescription": "AIMI Liver Segmentation", - "SeriesNumber": "300", - "InstanceNumber": "1", - "BodyPartExamined": "LIVER", - "segmentAttributes": [ - [ - { - "labelID": 1, - "SegmentDescription": "Liver", - "SegmentAlgorithmType": "AUTOMATIC", - "SegmentAlgorithmName": "BAMF-Liver-CT", - "SegmentedPropertyCategoryCodeSequence": { - "CodeValue": "123037004", - "CodingSchemeDesignator": "SCT", - "CodeMeaning": "Anatomical Structure" - }, - "SegmentedPropertyTypeCodeSequence": { - "CodeValue": "10200004", - "CodingSchemeDesignator": "SCT", - "CodeMeaning": "Liver" - }, - "recommendedDisplayRGBValue": [221, 130, 101] - } - ] - ], - "ContentLabel": "SEGMENTATION", - "ContentDescription": "Image segmentation", - "ClinicalTrialCoordinatingCenterName": "dcmqi" - } \ No newline at end of file diff --git a/models/bamf_nnunet_ct_liver/config/slicer.yml b/models/bamf_nnunet_ct_liver/config/slicer.yml index 80493d70..0e45dac1 100644 --- a/models/bamf_nnunet_ct_liver/config/slicer.yml +++ b/models/bamf_nnunet_ct_liver/config/slicer.yml @@ -7,6 +7,7 @@ execute: - NrrdImporter - NiftiConverter - NNUnetRunner +- BamfProcessorRunner - JsonSegExporter - DataOrganizer @@ -25,6 +26,8 @@ modules: nnunet_model: '3d_fullres' roi: LIVER + BamfProcessorRunner: + DataOrganizer: targets: - nifti:mod=seg-->[basename] diff --git a/models/bamf_nnunet_ct_liver/dockerfiles/Dockerfile b/models/bamf_nnunet_ct_liver/dockerfiles/Dockerfile index aa2a8c76..c19e859b 100644 --- a/models/bamf_nnunet_ct_liver/dockerfiles/Dockerfile +++ b/models/bamf_nnunet_ct_liver/dockerfiles/Dockerfile @@ -12,10 +12,8 @@ RUN pip3 install --no-cache-dir \ nnunet # Clone the main branch of MHubAI/models -RUN git stash \ - && git sparse-checkout set "models/bamf_nnunet_ct_liver" \ - && git fetch https://github.com/MHubAI/models.git main \ - && git merge FETCH_HEAD +ARG MHUB_MODELS_REPO +RUN buildutils/import_mhub_model.sh bamf_nnunet_ct_liver ${MHUB_MODELS_REPO} # Pull weights into the container ENV WEIGHTS_DIR=/root/.nnunet/nnUNet_models/nnUNet/ @@ -30,5 +28,5 @@ RUN rm ${WEIGHTS_DIR}${WEIGHTS_FN} ENV WEIGHTS_FOLDER=$WEIGHTS_DIR # Default run script -ENTRYPOINT ["python3", "-m", "mhubio.run"] +ENTRYPOINT ["mhub.run"] CMD ["--config", "/app/models/bamf_nnunet_ct_liver/config/default.yml"] diff --git a/models/bamf_nnunet_ct_liver/meta.json b/models/bamf_nnunet_ct_liver/meta.json index 386b9a8a..ba42e9a7 100644 --- a/models/bamf_nnunet_ct_liver/meta.json +++ b/models/bamf_nnunet_ct_liver/meta.json @@ -57,6 +57,7 @@ "weights": "28.08.2023", "pub": "23.10.2023" }, + "cite": "Murugesan, Gowtham Krishnan, Diana McCrumb, Mariam Aboian, Tej Verma, Rahul Soni, Fatima Memon, and Jeff Van Oss. The AIMI Initiative: AI-Generated Annotations for Imaging Data Commons Collections. arXiv preprint arXiv:2310.14897 (2023).", "licence": { "code": "MIT", "weights": "CC BY-NC 4.0" diff --git a/models/bamf_nnunet_ct_liver/utils/BamfProcessorRunner.py b/models/bamf_nnunet_ct_liver/utils/BamfProcessorRunner.py index 95c66b29..4ce765da 100644 --- a/models/bamf_nnunet_ct_liver/utils/BamfProcessorRunner.py +++ b/models/bamf_nnunet_ct_liver/utils/BamfProcessorRunner.py @@ -17,11 +17,11 @@ import shutil -@IO.ConfigInput('in_data', 'nifti:mod=ct|mr', the="input data to run BamfProcessor on") + class BamfProcessorRunner(Module): @IO.Instance - @IO.Input("in_data", the="input data to run nnunet on") + @IO.Input('in_data', 'nifti:mod=ct|mr', the='input data to run nnunet on') def task(self, instance: Instance, in_data: InstanceData, out_data: InstanceData) -> None: # Log bamf runner info @@ -29,12 +29,6 @@ def task(self, instance: Instance, in_data: InstanceData, out_data: InstanceData self.v(f" > input data: {in_data.abspath}") self.v(f" > output data: {out_data.abspath}") - # data - # bring input data in nnunet specific format - # NOTE: only for nifti data as we hardcode the nnunet-formatted-filename (and extension) for now. - assert in_data.type.ftype == FileType.NIFTI - assert in_data.abspath.endswith('.nii.gz') - # read image self.v(f"Reading image from {in_data.abspath}") img_itk = sitk.ReadImage(in_data.abspath)