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

MHub / GC - Add SPIDER baseline model/algorithm #53

Merged
merged 26 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
217da9e
WIP basic edits towards getting the spider baseline setup
silvandeleemput Aug 2, 2023
b5d864e
add working algorithm configuration, Dockerfile, runner, and pipeline…
silvandeleemput Sep 3, 2023
8d93c78
fix git commits for Dockerfile install, add runner comments, make inp…
silvandeleemput Sep 12, 2023
6411cfd
Merge branch 'MHubAI:main' into m-gc-spider-baseline
silvandeleemput Oct 10, 2023
b4fc5a1
add first draft meta.json
silvandeleemput Oct 10, 2023
29f7306
add basic dicomseg output support using dseg rois
silvandeleemput Oct 18, 2023
cbc3066
fixed some typos and descriptions
silvandeleemput Oct 18, 2023
dc324c8
update meta.json with segmentation classes
silvandeleemput Oct 18, 2023
4a4cf07
Moved creation of the static configuration files to the SpiderBaselin…
silvandeleemput Nov 15, 2023
ea5774c
Merge branch 'MHubAI:main' into m-gc-spider-baseline
silvandeleemput Nov 23, 2023
573f6b5
removed WORKDIR line from and added mhub model definition import lines
silvandeleemput Nov 23, 2023
88c5998
Merge branch 'm-gc-spider-baseline' of github.com:DIAGNijmegen/MHubAI…
silvandeleemput Nov 23, 2023
934322f
Dockerfile consistency one line per command
silvandeleemput Nov 27, 2023
b31fc4d
added MR support to default.yml
silvandeleemput Nov 27, 2023
6e0ea91
runner - refactor code for better readability, add comments, add new …
silvandeleemput Nov 27, 2023
08ea473
fix remapping indices for the segmentation labels
silvandeleemput Nov 28, 2023
33da4a6
Merge branch 'MHubAI:main' into m-gc-spider-baseline
silvandeleemput Apr 11, 2024
30b6e74
PR comments
miriam-groeneveld Apr 11, 2024
f2efc4f
PR comments
miriam-groeneveld Apr 11, 2024
f8a9919
Remove classes
miriam-groeneveld Apr 11, 2024
780593d
Remove comma
miriam-groeneveld Apr 11, 2024
0ee3f32
Add valuetype
miriam-groeneveld Apr 11, 2024
cf908b9
Change title to label
miriam-groeneveld Apr 11, 2024
cf6466e
update meta.json and fix order of segmentation labels to actually mat…
silvandeleemput Apr 15, 2024
733bc68
meta.json - highlight usage of lumbar spine only
silvandeleemput Apr 17, 2024
7499333
Handled PR comments
miriam-groeneveld Apr 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions models/gc_spider_baseline/config/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
general:
data_base_dir: /app/data
version: 1.0
description: SPIDER baseline segment vertebrae in Sagittal Spine MRI or CT (dicom to dicom segmentation)

execute:
- DicomImporter
- MhaConverter
- SpiderBaselineRunner
- DsegConverter
- DataOrganizer

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

MhaConverter:
engine: panimg

DsegConverter:
model_name: GCSpiderBaseline
target_dicom: dicom:mod=mr|ct
source_segs: [mha:mod=seg:seg=remapped]
skip_empty_slices: True
segment_id_meta_key: roi
body_part_examined: SPINE

DataOrganizer:
targets:
- mha:mod=seg:seg=raw-->[i:sid]/spider_baseline_vertebrae_segmentation_raw.mha
- mha:mod=seg:seg=remapped-->[i:sid]/spider_baseline_vertebrae.seg.mha
- dicomseg:mod=seg-->[i:sid]/spider_baseline_vertebrae.seg.dcm
39 changes: 39 additions & 0 deletions models/gc_spider_baseline/dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM mhubai/base:latest

# Update authors label
LABEL authors="[email protected]"

# Install PyTorch 2.0.1 (CUDA enabled)
RUN pip3 install --no-cache-dir torch==2.0.1+cu118 -f https://download.pytorch.org/whl/torch_stable.html

# Install git-lfs (required for unpacking model weights)
RUN apt update && \
apt install -y --no-install-recommends git-lfs && \
rm -rf /var/lib/apt/lists/*

# Install spider baseline algorithm
# - Git clone to tmp directory and reset to specific commit (main branch commit at 2023-09-12)
# - Extract relevant files to src
# - Remove tmp directory to remove history from layer
RUN git clone https://github.com/DIAGNijmegen/SPIDER-Baseline-IIS.git /tmp/algorithm && \
cd /tmp/algorithm && \
git reset --hard 1b26e2e0a710151db66f1cac0b51a3408368a2ef && \
mkdir -p /app/src/datasets/spider_input/images && \
mv /tmp/algorithm/devel /app/src/devel && \
mv /tmp/algorithm/experiments /app/src/experiments && \
rm -rf /tmp/algorithm

# Install additional spider baseline dependencies (stable branch commit at 2023-09-12)
RUN pip3 install --no-cache-dir git+https://github.com/DIAGNijmegen/Tiger.git@4c63f6d58ed3f8e7a0cec04b0352949f7b512919

# Import the MHub model definiton
ARG MHUB_MODELS_REPO
RUN buildutils/import_mhub_model.sh gc_spider_baseline ${MHUB_MODELS_REPO}

# Setup required environment variables for SPIDER algorithm
ENV PYTHONPATH="/app:/app/src/devel"
ENV VERSEG_BASEDIR="/app/src/"

# Default run script
ENTRYPOINT ["python3", "-m", "mhubio.run"]
CMD ["--config", "/app/models/gc_spider_baseline/config/default.yml"]
223 changes: 223 additions & 0 deletions models/gc_spider_baseline/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
{
"id": "aed5a82e-2188-4d50-83f9-45bce09f9daa",
"name": "gc_spider_baseline",
"title": "SPIDER Baseline algorithm: Iterative Instance Segmentation of the spine",
"summary": {
"description": "This model segments three anatomical structures in lumbar spine MRI: vertebrae, intervertebral discs (IVDs), and spinal canal. Each vertebrae and IVD is labeled according to standard naming convention.",
"inputs": [
{
"label": "Sagittal Lumbar Spine T1 T2 MRI",
"description": "Sagittal T1 or T2 weighted MRI of the lumbar spine. It is important to provide the input image in sagittal orientation for proper functioning of the model.",
LennyN95 marked this conversation as resolved.
Show resolved Hide resolved
"format": "DICOM",
"modality": "MR",
"bodypartexamined": "Spine",
"slicethickness": "2.0mm",
"non-contrast": false,
"contrast": false
}
],
"outputs": [
{
"type": "Segmentation",
"label": "Sagittal Spine Segmentation",
"description": "DICOM Segmentation of the spine.",
"classes": [
"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",
"VERTEBRAE_DISK_L5S1",
"VERTEBRAE_DISK_L4L5",
"VERTEBRAE_DISK_L3L4",
"VERTEBRAE_DISK_L2L3",
"VERTEBRAE_DISK_L1L2",
"VERTEBRAE_DISK_T12L1",
"VERTEBRAE_DISK_T11T12",
"VERTEBRAE_DISK_T10T11",
"VERTEBRAE_DISK_T9T10",
"VERTEBRAE_DISK_T8T9",
"VERTEBRAE_DISK_T7T8",
"VERTEBRAE_DISK_T6T7",
"VERTEBRAE_DISK_T5T6",
"VERTEBRAE_DISK_T4T5",
"VERTEBRAE_DISK_T3T4",
"VERTEBRAE_DISK_T2T3",
"VERTEBRAE_DISK_T1T2",
"VERTEBRAE_DISK_C7T1",
"VERTEBRAE_DISK_C6C7",
"VERTEBRAE_DISK_C5C6",
"VERTEBRAE_DISK_C4C5",
"VERTEBRAE_DISK_C3C4",
"VERTEBRAE_DISK_C2C3",
"SPINAL_CANAL"
]
},
{
"type": "Prediction",
"label": "Raw Sagittal Spine Segmentation",
"valueType": "Raw segmentation image",
"description": "The raw segmentation of the segmented structures as mha. The vertebrae are subsequently labeled between 1 and 24, with 24 being the lowest lumbar vertebra (L5). Vertebra which are not completely visible within the field of view of the MR image are labeled between 101 and 124. The intervertebral discs are labeled between 201 and 224 and are decided by the vertebra above it. The spinal canal is labeled as 100."
}
],
"model": {
"architecture": "3D U-Net-like fully-convolutional neural network",
"training": "supervised",
"cmpapproach": "2D"
},
"data": {
"training": {
"vol_samples": 447
},
"evaluation": {
"vol_samples": 87
},
"public": true,
"external": false
}
},
"details": {
"name": "SPIDER Baseline algorithm: Iterative Instance Segmentation of the spine",
"version": "0.1.0",
"devteam": "DIAGNijmegen (Diagnostic Image Analysis Group, Radboud UMC, The Netherlands)",
"type": "U-net",
"date": {
"weights": "",
"code": "2023-08-15",
"pub": "2023-06-23"
},
"cite": "van der Graaf, J.W., van Hooff, M.L., Buckens, C.F.M. et al. Lumbar spine segmentation in MR images: a dataset and a public benchmark. Sci Data 11, 264 (2024). doi: 10.1038/s41597-024-03090-w",
"license": {
"code": "Apache 2.0",
"weights": "Apache 2.0"
},
"publications": [
{
"title": "Lumbar spine segmentation in MR images: a dataset and a public benchmark",
"uri": "https://doi.org/10.1038/s41597-024-03090-w"
},
{
"title": "Iterative fully convolutional neural networks for automatic vertebra segmentation and identification",
"uri": "https://doi.org/10.1016/j.media.2019.02.005"
}
],
"github": "https://github.com/DIAGNijmegen/SPIDER-Baseline-IIS",
"zenodo": "",
"colab": "",
"slicer": false
},
"info": {
"use": {
"title": "Intended use",
"text": "This model is intended to be used with T1 or T2 weighted MRI images of the lumbar spine. It is important to provide the input image in sagittal orientation for proper functioning of the model. Ensure that the lumbar spine is visible in the input MRI images to ensure reliable results. This algorithm is available on Grand Challenge [1] and is used as baseline for the SPIDER challenge [2].",
"references": [
{
"label": "SPIDER baseline algorithm on grand-challenge",
"uri": "https://grand-challenge.org/algorithms/spider-baseline-iis/"
},
{
"label": "SPIDER challenge details",
"uri": "https://spider.grand-challenge.org/"
}
],
"tables": []
},
"analyses": {
"title": "Evaluation",
"text": "The segmentation performance was evaluated as part of the SPIDER challenge using two metrics: (1) The Dice coefficient to measure the volume overlap, and (2) the average absolute surface distance (ASD) as an indication of the segmentation accuracy along the surface of all structures.",
"references": [
{
"label": "SPIDER baseline algorithm evaluation results on grand-challenge",
"uri": "https://spider.grand-challenge.org/evaluation/11bf4d89-6768-4e2f-b540-60178ba33a95/"
}
],
"tables": [
{
"label": "Dice score.",
"entries":
{
"Vertebrae": "0.93 ± 0.05",
"Intervertebral discs": "0.84 ± 0.10",
"Spinal canal": "0.92 ± 0.04"
}
},
{
"label": "ASD (mm).",
"entries":
{
"Vertebrae": "0.48 ± 0.95",
"Intervertebral discs": "0.54 ± 0.45",
"Spinal canal": "0.39 ± 0.45"
}
}
]
},
"evaluation": {
"title": "Evaluation data",
"text": "The test set consists of 87 lumbar MRI images from 39 patients, which includes the fully manually annotated images of 15 patients, randomly selected from the set of fully annotated dataset, see Training data.",
"references": [],
"tables": []
},
"training": {
"title": "Training data",
"text": "For training a large, publicly available, multi-center, lumbar spine MRI dataset was used [1]. It includes reference segmentations of vertebrae, intervertebral discs (IVDs), and spinal canal. The dataset includes 447 sagittal T1 and T2 MRI images from 218 patients with a history of low back pain. For 20 patients from the UMC dataset the images were fully, manually annotated. This model is based on a previously developed model trained on both CT and MRI data [2]. It was extended by also segmenting the IVDs and spinal canal, using MRI only. For training details see Baseline 1 in the associated paper [3].",
"references": [
{
"label": "The public dataset of lumbar spine MRI",
"uri": "https://doi.org/10.5281/zenodo.10159290"
},
{
"label": "Iterative fully convolutional neural networks for automatic vertebra segmentation and identification",
"uri": "https://doi.org/10.1016/j.media.2019.02.005"
},
{
"label": "Lumbar spine segmentation in MR images: a dataset and a public benchmark",
"uri": "https://doi.org/10.1038/s41597-024-03090-w"
}
],
"tables": [
{
"label": "Number of patient data provided by the various hospitals",
"entries":
{
"University Medical Center (UMC)": "41",
"Regional Hospital 1": "43",
"Regional Hospital 2": "44",
"Orthopedic Hospital": "90"
}
}
]
},
"ethics": {
"title": "",
"text": "",
"references": [],
"tables": []
},
"limitations": {
"title": "Limitation",
"text": "This algorithm was developed for research purposes only. Ensure that the lumbar spine is visible in the input MRI image to ensure reliable results. When the lumbar spine is absent, the model will produce unreliable labels for the detected structures.",
"references": [],
"tables": []
}
}
}
Loading
Loading