Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAMF - NNUnet Lung and Nodules #78

Closed
wants to merge 16 commits into from
Closed
50 changes: 50 additions & 0 deletions models/bamf_nnunet_ct_lung/config/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
general:
data_base_dir: /app/data
version: 1.0
description: default configuration for Bamf NNUnet Lung, Nodules and Tumor segmentation (dicom to dicom)

execute:
- DicomImporter
- NiftiConverter
- NNUnetRunner
- CustomNNUnetRunner
- LungPostProcessor
- DsegConverter
- DataOrganizer

modules:
DicomImporter:
source_dir: input_data
import_dir: sorted_data
sort_data: true
meta:
mod: '%Modality'

CustomNNUnetRunner:
in_data: nifti:mod=ct
nnunet_task: Task777_CT_Nodules
nnunet_model: 3d_fullres
roi: LEFT_LUNG+RIGHT_LUNG,LEFT_LUNG+RIGHT_LUNG+NODULES
export_prob_maps: False

NNUnetRunner:
in_data: nifti:mod=ct
nnunet_task: Task775_CT_NSCLC_RG
nnunet_model: 3d_fullres
roi: NEOPLASM_MALIGNANT_PRIMARY
export_prob_maps: False

LungPostProcessor:
in_rg_data: nifti:mod=seg:nnunet_task=Task775_CT_NSCLC_RG
in_nodules_data: nifti:mod=seg:nnunet_task=Task777_CT_Nodules

DsegConverter:
model_name: Bamf NNUnet CT Lung
target_dicom: dicom:mod=ct
source_segs: nifti:mod=seg:processor=bamf
skip_empty_slices: True
json_config_path: models/bamf_nnunet_ct_lung/config/dseg.json

DataOrganizer:
targets:
- dicomseg-->[i:sid]/bamf_nnunet_ct_lung.seg.dcm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that bamf_nnunet_ct_lungnodules would be a better fit for a name?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated with this naming convention.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx! This would require to change the folder name (modles/$model_name) too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the model directory to bamf_nnunet_ct_lungnodules

63 changes: 63 additions & 0 deletions models/bamf_nnunet_ct_lung/config/dseg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"ContentCreatorName": "BAMFHealth^AI",
"ClinicalTrialSeriesID": "Session1",
"ClinicalTrialTimePointID": "1",
"SeriesDescription": "AIMI Lung Nodule Segmentation",
"SeriesNumber": "300",
"InstanceNumber": "1",
"BodyPartExamined": "LUNG",
"segmentAttributes": [
[
{
"labelID": 1,
"SegmentDescription": "Lung",
"SegmentAlgorithmType": "AUTOMATIC",
"SegmentAlgorithmName": "BAMF-Lung-CT",
"SegmentedPropertyCategoryCodeSequence": {
"CodeValue": "123037004",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Anatomical Structure"
},
"SegmentedPropertyTypeCodeSequence": {
"CodeValue": "39607008",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Lung"
},
"SegmentedPropertyTypeModifierCodeSequence": {
"CodeValue": "51440002",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Right and left"
}
},
{
"labelID": 2,
"SegmentDescription": "Nodule",
"SegmentAlgorithmType": "AUTOMATIC",
"SegmentAlgorithmName": "BAMF-Lung-CT",
"AnatomicRegionSequence": {
"CodeValue": "39607008",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Lung"
},
"AnatomicRegionModifierSequence": {
"CodeValue": "51440002",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Right and left"
},
"SegmentedPropertyCategoryCodeSequence": {
"CodeValue": "49755003",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Morphologically Altered Structure"
},
"SegmentedPropertyTypeCodeSequence": {
"CodeValue": "27925004",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Nodule"
}
}
]
],
"ContentLabel": "SEGMENTATION",
"ContentDescription": "Image segmentation",
"ClinicalTrialCoordinatingCenterName": "dcmqi"
}
40 changes: 40 additions & 0 deletions models/bamf_nnunet_ct_lung/dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM mhubai/base:latest

# FIXME: set this environment variable as a shortcut to avoid nnunet crashing the build
# by pulling sklearn instead of scikit-learn
# N.B. this is a known issue:
# https://github.com/MIC-DKFZ/nnUNet/issues/1281
# https://github.com/MIC-DKFZ/nnUNet/pull/1209
ENV SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True

# Install nnunet and platipy
RUN pip3 install --no-cache-dir \
nnunet

# Clone the main branch of MHubAI/models
ARG MHUB_MODELS_REPO
RUN buildutils/import_mhub_model.sh bamf_nnunet_ct_lung ${MHUB_MODELS_REPO}

# Pull nnUNet model weights into the container for Task777_CT_Nodules
ENV WEIGHTS_DIR=/root/.nnunet/nnUNet_models/nnUNet/
RUN mkdir -p $WEIGHTS_DIR
ENV WEIGHTS_FN=Task777_CT_Nodules.zip
ENV WEIGHTS_URL=https://zenodo.org/record/8290147/files/$WEIGHTS_FN
RUN wget --directory-prefix ${WEIGHTS_DIR} ${WEIGHTS_URL}
RUN unzip ${WEIGHTS_DIR}${WEIGHTS_FN} -d ${WEIGHTS_DIR}
RUN rm ${WEIGHTS_DIR}${WEIGHTS_FN}

# Pull nnUNet model weights into the container for Task775_CT_NSCLC_RG
ENV TASK_NAME_NSCLC_RG=Task775_CT_NSCLC_RG
ENV WEIGHTS_FN=$TASK_NAME_NSCLC_RG.zip
ENV WEIGHTS_URL=https://zenodo.org/record/8290169/files/$WEIGHTS_FN
RUN wget --directory-prefix ${WEIGHTS_DIR} ${WEIGHTS_URL}
RUN unzip ${WEIGHTS_DIR}${WEIGHTS_FN} -d ${WEIGHTS_DIR}
RUN rm ${WEIGHTS_DIR}${WEIGHTS_FN}

# specify nnunet specific environment variables
ENV WEIGHTS_FOLDER=$WEIGHTS_DIR

# Default run script
ENTRYPOINT ["mhub.run"]
CMD ["--config", "/app/models/bamf_nnunet_ct_lung/config/default.yml"]
139 changes: 139 additions & 0 deletions models/bamf_nnunet_ct_lung/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"id": "",
"name": "bamf_nnunet_ct_lung",
"title": "AIMI CT Lung and Nodules",
"summary": {
"description": "An nnU-Net based model to segment lung from CT scans",
"inputs": [
{
"label": "Input Image",
"description": "The CT scan of a patient.",
"format": "DICOM",
"modality": "CT",
"bodypartexamined": "LUNG",
"slicethickness": "2.5mm",
"non-contrast": true,
"contrast": false
}
],
"outputs": [
{
"label": "Segmentation",
"type": "Segmentation",
"description": "Segmentation lung",
"classes": [
"LUNG",
"LUNG+NODULES",
"LUNG+NEOPLASM_MALIGNANT_PRIMARY"
]
}
],
"model": {
"architecture": "U-net",
"training": "supervised",
"cmpapproach": "3D"
},
"data": {
"training": {
"vol_samples": 833
},
"evaluation": {
"vol_samples": 47
},
"public": true,
"external": true
}
},
"details": {
"name": "AIMI CT Lung",
"version": "1.0.0",
"devteam": "BAMF Health",
"authors": [
"Soni, Rahul",
"McCrumb, Diana",
"Murugesan, Gowtham Krishnan",
"Van Oss, Jeff"
],
"type": "nnU-Net (U-Net structure, optimized by data-driven heuristics)",
"date": {
"code": "17.10.2023",
"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).",
"license": {
"code": "MIT",
"weights": "CC BY-NC 4.0"
},
"publications": [
{
"title": "The AIMI Initiative: AI-Generated Annotations in IDC Collections",
"uri": "https://arxiv.org/abs/2310.14897"
}
],
"github": "https://github.com/bamf-health/aimi-ct-lung"
},
"info": {
"use": {
"title": "Intended Use",
"text": "This model is intended to perform lung, nodules and tumor segmentation in CT scans. The model has been trained and tested on scans aquired during clinical care of patients, so it might not be suited for a healthy population. The generalization capabilities of the model on a range of ages, genders, and ethnicities are unknown."
},
"analyses": {
"title": "Quantitative Analyses",
"text": "The model's performance was assessed using the Dice Coefficient and Normalized Surface Distance (NSD) with tolerance 7mm, as specified in the CT Liver segmentation task in the Medical Segmentation Decathlon challenge. The model was used to segment cases from the IDC collection TCGA-LIHC [1]. Nine of those cases were reviewed and corrected by a board-certified radiologist and a non-expert. The analysis is published here [2]",
"tables": [
{
"label": "Label-wise metrics (mean (standard deviation)) between AI derived and manually corrected CT lung annotations",
"entries": {
"Dice: Radiologist": "0.97 (0.07)",
"NSD: Radiologist": "0.96 (0.09)",
"Dice: Non-expert": "0.97 (0.08)",
"NSD: Non-expert": "0.95 (0.11)"
}
}
],
"references": [
{
"label": "DICOM-LIDC-IDRI-Nodules",
"uri": "https://wiki.cancerimagingarchive.net/pages/viewpage.action?pageId=6885436"
},
{
"label": "The AIMI Initiative: AI-Generated Annotations for Imaging Data Commons Collections",
"uri": "https://arxiv.org/abs/2310.14897"
}
]
},
"evaluation": {
"title": "Evaluation Data",
"text": "The model was used to segment cases 89 from the IDC [1] collection TCGA-LIHC [1]. Nine of those cases were randomly selected to be reviewed and corrected by a board-certified radiologist. The model predictions, and radiologist corrections are published on zenodo [3]",
"references": [
{
"label": "Imaging Data Collections (IDC)",
"uri": "https://datacommons.cancer.gov/repository/imaging-data-commons"
},
{
"label": "TCGA-LIHC",
"uri": "https://wiki.cancerimagingarchive.net/pages/viewpage.action?pageId=6885436"
},
{
"label": "Image segmentations produced by the AIMI Annotations initiative",
"uri": "https://zenodo.org/records/10009368"
}
]
},
"training": {
"title": "Training Data",
"text": "The training dataset consists of 1565 CT liver annotations taken from TotalSegmentator [1] (N=1204) and Flare21 Liver Dataset [2] (N=361).",
"references": [
{
"label": "TotalSegmentator Dataset",
"uri": "https://zenodo.org/records/10047292"
},
{
"label": "Flare21 Dataset",
"uri": "https://zenodo.org/records/5903672"
}
]
}
}
}
Loading
Loading