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 15 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"]
135 changes: 135 additions & 0 deletions models/gc_spider_baseline/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"id": "aed5a82e-2188-4d50-83f9-45bce09f9daa",
"name": "spider_baseline",
"title": "SPIDER Baseline algorithm: Iterative Instance Segmentation of the spine",
"summary": {
"description": "The SPIDER Challenge focuses on the segmentation of three anatomical structures in lumbar spine MRI: vertebrae, intervertebral discs (IVDs), and spinal canal. The segmentation task requires similar algorithms to produce separate masks for each vertebra, IVD, and the spinal canal in the lumbar spine MRI volume. 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.",
LennyN95 marked this conversation as resolved.
Show resolved Hide resolved
"inputs": [
{
"label": "Sagittal Spine MRI",
"description": "Sagittal MRI of the spine",
"format": "DICOM",
"modality": "MR",
"bodypartexamined": "Spine",
"slicethickness": "2.0mm",
"non-contrast": false,
"contrast": false
}
],
"outputs": [
{
"type": "Segmentation",
"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"
]
}
],
"model": {
"architecture": "3D U-Net-like fully-convolutional neural network",
"training": "supervised",
"cmpapproach": "2D"
},
"data": {
"training": {
"vol_samples": 179
},
"evaluation": {
"vol_samples": 39
},
"public": false,
"external": false
}
},
"details": {
"name": "SPIDER Baseline algorithm: Iterative Instance Segmentation of the spine",
"version": "",
"devteam": "DIAGNijmegen (Diagnostic Image Analysis Group, Radboud UMC, The Netherlands)",
"type": "U-net",
"date": {
"weights": "",
"code": "2023-08-15",
"pub": "2023-06-23"
},
"cite": "Nikolas Lessmann, Bram van Ginneken, Pim A. de Jong, Ivana Išgum, Iterative fully convolutional neural networks for automatic vertebra segmentation and identification, Medical Image Analysis, Volume 53, 2019, Pages 142-155, ISSN 1361-8415, https://doi.org/10.1016/j.media.2019.02.005.",
"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://arxiv.org/abs/2306.12217"
}
],
"github": "https://github.com/DIAGNijmegen/SPIDER-Baseline-IIS",
"zenodo": "",
"colab": "",
"slicer": false
},
"info": {
"use": {
"title": "Intended use",
"text": "Segmentation of three anatomical structures in lumbar spine MRI: vertebrae, intervertebral discs (IVDs), and spinal canal.",
LennyN95 marked this conversation as resolved.
Show resolved Hide resolved
"references": [],
"tables": []
},
"analyses": {
"title": "Evaluation",
"text": "The segmentation performance was evaluated 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 sur- face of all structures.",
LennyN95 marked this conversation as resolved.
Show resolved Hide resolved
"references": [],
"tables": []
},
"evaluation": {
"title": "Evaluation data",
"text": "The test set consists of 39 lumbar MRI studies of unique patients, which includes 15 out of the 20 fully manually annotated studies.",
LennyN95 marked this conversation as resolved.
Show resolved Hide resolved
LennyN95 marked this conversation as resolved.
Show resolved Hide resolved
"references": [],
"tables": []
},
"training": {
"title": "Training data",
"text": "This is a large publicly available multi-center lumbar spine magnetic resonance imaging (MRI) dataset with reference segmentations of vertebrae, intervertebral discs (IVDs), and spinal canal. The dataset includes 447 sagittal T1 and T2 MRI series from 218 studies of 218 patients with a history of low back pain. ",
LennyN95 marked this conversation as resolved.
Show resolved Hide resolved
"references": [
{
"label": "SPIDER - Lumbar spine segmentation in MR images: a dataset and a public benchmark",
"uri": "https://zenodo.org/record/8009680"
}
],
"tables": []
},
"ethics": {
"title": "",
"text": "",
"references": [],
"tables": []
},
"limitations": {
"title": "Limitation",
"text": "This algorithm was developed for research purposes only.",
"references": [],
"tables": []
}
}
}
Loading