Skip to content

Commit

Permalink
address changes suggested by mhub dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul Soni committed Nov 14, 2023
1 parent f3d5674 commit db1dd3b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 54 deletions.
12 changes: 4 additions & 8 deletions models/bamf_nnunet_ct_liver/config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
33 changes: 0 additions & 33 deletions models/bamf_nnunet_ct_liver/config/meta.json

This file was deleted.

3 changes: 3 additions & 0 deletions models/bamf_nnunet_ct_liver/config/slicer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ execute:
- NrrdImporter
- NiftiConverter
- NNUnetRunner
- BamfProcessorRunner
- JsonSegExporter
- DataOrganizer

Expand All @@ -25,6 +26,8 @@ modules:
nnunet_model: '3d_fullres'
roi: LIVER

BamfProcessorRunner:

DataOrganizer:
targets:
- nifti:mod=seg-->[basename]
Expand Down
8 changes: 3 additions & 5 deletions models/bamf_nnunet_ct_liver/dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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"]
1 change: 1 addition & 0 deletions models/bamf_nnunet_ct_liver/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 2 additions & 8 deletions models/bamf_nnunet_ct_liver/utils/BamfProcessorRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,18 @@
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
self.v("Running BamfProcessor on....")
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)
Expand Down

0 comments on commit db1dd3b

Please sign in to comment.