-
Notifications
You must be signed in to change notification settings - Fork 20
BAMF MR Brain tumor segmentation #93
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
base: main
Are you sure you want to change the base?
Changes from 13 commits
6146429
22636ff
afcda3e
029fa7f
0bdc69f
03679eb
2acda92
c1b29fd
f11aeb0
75050b2
b927a85
f158a7d
43a08df
ef4621f
be2e7a0
d382e5f
1126c9d
57b1f56
16196f7
49bdb90
044d076
5be31ea
996d543
628022d
f40185f
8a4967d
489d518
224131a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| general: | ||
| data_base_dir: /app/data | ||
| version: 1.0 | ||
| description: Default configuration for Bamf NNUnet Brain tumor segmentation on MR scans (dicom to dicom) | ||
|
|
||
| segdb: | ||
| triplets: | ||
| T_EDEMA_MABNORMALITY: | ||
| code: 79654002 | ||
| meaning: Edema | ||
| scheme_designator: SCT | ||
| T_NECROSIS_MABNORMALITY: | ||
| code: 6574001 | ||
| meaning: Necrosis | ||
| scheme_designator: SCT | ||
| T_ENHANCING_MABNORMALITY: | ||
| code: C113842 | ||
| meaning: Enhancing Lesion | ||
| scheme_designator: NCIt | ||
| segments: | ||
| EDEMA: | ||
| name: Edema | ||
| category: C_MORPHOLOGICALLY_ABNORMAL_STRUCTURE | ||
| type: T_EDEMA_MABNORMALITY | ||
| color: [140, 224, 228] | ||
| NECROSIS: | ||
| name: Necrosis | ||
| category: C_MORPHOLOGICALLY_ABNORMAL_STRUCTURE | ||
| type: T_EDEMA_MABNORMALITY | ||
| color: [216, 191, 216] | ||
| ENHANCING: | ||
| name: Enhancing Lesion | ||
| category: C_MORPHOLOGICALLY_ABNORMAL_STRUCTURE | ||
| type: T_ENHANCING_MABNORMALITY | ||
| color: [128, 174, 128] | ||
LennyN95 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| execute: | ||
| - FileStructureImporter | ||
| - NiftiConverter | ||
| - ReOrientationRunner | ||
| - BiasCorrectionRunner | ||
| - FLIRTRegistrationRunner | ||
| - SkullStripRunner | ||
| - StdRegistrationRunner | ||
| - NNUnetRunnerV2 | ||
| - InverseStdRegistrationRunner | ||
| - InverseRegistrationRunner | ||
| - module: DsegConverter | ||
| target_dicom: dicom:mod=mr:type=t1 | ||
| source_segs: nifti:mod=mr:type=t1:task=inverse | ||
| - module: DsegConverter | ||
| target_dicom: dicom:mod=mr:type=t1ce | ||
| source_segs: nifti:mod=mr:type=t1ce:task=inverse | ||
| - module: DsegConverter | ||
| target_dicom: dicom:mod=mr:type=t2 | ||
| source_segs: nifti:mod=mr:type=t2:task=inverse | ||
| - module: DsegConverter | ||
| target_dicom: dicom:mod=mr:type=flair | ||
| source_segs: nifti:mod=mr:type=flair:task=inverse | ||
| - DataOrganizer | ||
|
|
||
| modules: | ||
| FileStructureImporter: | ||
| input_dir: 'input_data' | ||
| structures: | ||
| - $patientID@instance/t1@dicom:mod=mr:type=t1 | ||
| - $patientID/t1ce@dicom:mod=mr:type=t1ce | ||
| - $patientID/$type@dicom:mod=mr:type=t2 | ||
| - $patientID/flair@dicom:mod=mr:type=flair | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see you use a structures:
- $patientID@instance/t1@dicom:mod=mr:type=t1
- $patientID/t1ce@dicom:mod=mr:type=t1ce
- $patientID/t2@dicom:mod=mr:type=t2
- $patientID/flair@dicom:mod=mr:type=flairThis is equivalent to the use of a variable as in the example below, because the structures:
- $patientID@instance/$type@dicom:mod=mr
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jithenece I see you already updated this to the latter example. However, for the transparency with we should stick with the first, more verbose variant.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This explains. I have reverted this to earlier verbose variant.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jithenece Can you check if you pushed this already, I still see the simplified version in the most recent commit.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have pushed it now. please check
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is still a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missed it. I have updated now. |
||
| import_id: patientID | ||
|
|
||
| NiftiConverter: | ||
| allow_multi_input: True | ||
| out_datas: nifti:mod=mr:task=conversion | ||
| engine: dcm2niix | ||
|
|
||
| ReOrientationRunner: | ||
| in_datas: nifti:mod=mr | ||
|
|
||
| BiasCorrectionRunner: | ||
| in_datas: nifti:mod=mr:task=reorientation | ||
|
|
||
| FLIRTRegistrationRunner: | ||
| in_datas: nifti:mod=mr:task=bias_corrected | ||
| reference_data: nifti:mod=mr:task=bias_corrected:type=t1ce | ||
|
|
||
| SkullStripRunner: | ||
| in_datas: nifti:mod=mr:task=registration | ||
|
|
||
| StdRegistrationRunner: | ||
| in_datas: nifti:mod=mr:task=skull_stripped | ||
|
|
||
| NNUnetRunnerV2: | ||
| in_t1_data: nifti:mod=mr:task=std_registration:type=t1 | ||
| in_t1ce_data: nifti:mod=mr:task=std_registration:type=t1ce | ||
| in_t2_data: nifti:mod=mr:task=std_registration:type=t2 | ||
| in_flair_data: nifti:mod=mr:task=std_registration:type=flair | ||
| nnunet_dataset: Dataset002_BRATS19 | ||
| nnunet_config: 3d_fullres | ||
|
|
||
| InverseStdRegistrationRunner: | ||
| in_seg_data: nifti:mod=seg:model=nnunet:nnunet_dataset=Dataset002_BRATS19 | ||
| in_mat_datas: txt:task=std_registration_transform_mat | ||
| in_registration_datas: nifti:mod=mr:task=registration | ||
|
|
||
| InverseRegistrationRunner: | ||
| in_seg_datas: nifti:mod=mr:task=std_inverse | ||
| in_mat_datas: txt:task=registration_transform_mat | ||
| in_registration_datas: nifti:mod=mr:task=bias_corrected | ||
|
|
||
| DsegConverter: | ||
| model_name: Bamf NNUnet Brain segmentation | ||
| skip_empty_slices: True | ||
|
|
||
| DataOrganizer: | ||
| targets: | ||
| - dicomseg:type=t1ce-->[i:patientID]/t1ce.seg.dcm | ||
| - dicomseg:type=t1-->[i:patientID]/t1.seg.dcm | ||
| - dicomseg:type=t2-->[i:patientID]/t2.seg.dcm | ||
| - dicomseg:type=flair-->[i:patientID]/flair.seg.dcm | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| FROM mhubai/base:latest | ||
|
|
||
| ENV DEBIAN_FRONTEND "noninteractive" | ||
| ENV LANG "en_GB.UTF-8" | ||
|
|
||
| # 1. Install gcc-14 and build ants | ||
| RUN apt-get update && apt-get install -y cmake make ninja-build git bzip2 flex manpages-dev g++ wget unzip file | ||
| RUN wget https://github.com/gcc-mirror/gcc/archive/refs/tags/releases/gcc-11.4.0.zip \ | ||
| && unzip gcc-11.4.0.zip && cd gcc-releases-gcc-11.4.0 && ./contrib/download_prerequisites \ | ||
| && mkdir /app/gcc-build && cd /app/gcc-build \ | ||
| && ../gcc-releases-gcc-11.4.0/configure -v --target=x86_64-linux-gnu --prefix=/usr/local/gcc-11.4.0 --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-11.4 \ | ||
| && make -j$(nproc) && make install-strip \ | ||
| && update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-11.4.0/bin/gcc-11.4 11 --slave /usr/bin/g++ g++ /usr/local/gcc-11.4.0/bin/g++-11.4 \ | ||
| && rm -rf /app/gcc-* | ||
|
|
||
| ENV PATH=/usr/local/gcc-11.4.0/bin:$PATH | ||
| ENV LD_LIBRARY_PATH="/usr/local/gcc-11.4.0/lib64:$LD_LIBRARY_PATH" | ||
|
|
||
| RUN git clone https://github.com/ANTsX/ANTs.git /usr/local/src/ants \ | ||
| && mkdir /app/build && cd /app/build && cmake -DBUILD_TESTING=ON \ | ||
| -DRUN_LONG_TESTS=OFF \ | ||
| -DRUN_SHORT_TESTS=ON \ | ||
| -DBUILD_SHARED_LIBS=OFF \ | ||
| -DCMAKE_INSTALL_PREFIX=/opt/ants \ | ||
| /usr/local/src/ants \ | ||
| && cmake --build . --parallel \ | ||
| && cd /app/build/ANTS-build && cmake --build . --target test \ | ||
| && cmake --install . && rm -rf /app/build | ||
|
|
||
| # 2. Install mri_convert | ||
| ENV FREESURFER_HOME="/freesurfer" | ||
| RUN git clone https://github.com/freesurfer/freesurfer.git && cd freesurfer/mri_synthstrip \ | ||
| git+https://github.com/freesurfer/surfa.git@0d83332351083b33c4da221e9d10a63a93ae7f52 \ | ||
| && mkdir -p $FREESURFER_HOME/models/ \ | ||
| && git remote add datasrc https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/repo/annex.git \ | ||
| && apt-get update -y && apt-get install -y git-annex \ | ||
| && git fetch datasrc && git-annex get . \ | ||
| && cp mri_synthstrip $FREESURFER_HOME \ | ||
| && cp synthstrip.*.pt $FREESURFER_HOME/models/ | ||
|
|
||
| # 3. Install fsl | ||
| RUN wget https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/releases/fslinstaller.py && \ | ||
| python3 ./fslinstaller.py -V 6.0.7.11 -d /usr/local/fsl/ && rm fslinstaller.py | ||
|
|
||
| ENV PATH="/opt/ants/bin:$PATH:/$FREESURFER_HOME:/usr/local/fsl/bin" \ | ||
| LD_LIBRARY_PATH="/opt/ants/lib:$LD_LIBRARY_PATH" | ||
|
|
||
| # 3. Install nnunet | ||
| # 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 | ||
|
|
||
| # 4. Install nnunet and surfa | ||
| RUN pip3 install --no-cache-dir torch surfa==0.6 | ||
| RUN apt-get update && apt-get install -y python3.9 python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* | ||
| RUN python3.9 -m pip install nnunetv2==2.4.1 | ||
| RUN apt-get update && apt-get install -y bc | ||
|
|
||
| # Clone the main branch of MHubAI/models | ||
| ARG MHUB_MODELS_REPO | ||
| RUN buildutils/import_mhub_model.sh bamf_mr_brain_tumor ${MHUB_MODELS_REPO} | ||
|
|
||
| # Pull nnUNet model weights into the container | ||
| ENV WEIGHTS_DIR=/root/.nnunet/nnUNet_models/ | ||
| RUN mkdir -p $WEIGHTS_DIR | ||
| ENV WEIGHTS_FN=Dataset002_BRATS19.zip | ||
| ENV WEIGHTS_URL=https://zenodo.org/records/11582627/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_mr_brain_tumor/config/default.yml"] |
Uh oh!
There was an error while loading. Please reload this page.