-
Notifications
You must be signed in to change notification settings - Fork 16
Implement several fixes and QoL improvements to the Data Preparation MLCube #85
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: fets_2.0
Are you sure you want to change the base?
Changes from all commits
3b23ad0
7da8400
7d5734b
5b4ea40
2455563
ad03a74
99a2c73
7efa53a
ce7b8fe
6cabe3f
448386f
8b93a14
b83904b
987daf1
1ef8939
3df8792
5c6e364
559d7ba
9d9b9c9
f58aefa
7ea221d
a59572a
a6412bf
9988405
8284b60
24788a9
0ba6a9d
ad6e3b2
067c6de
ec3eb6f
c3f7077
af5ecb3
264e3fb
6f3cbef
2fcbac3
bdd6bc9
ed952b8
47026d9
e32edff
1e2bcb0
07dc092
373214a
7ddf3b8
06f9181
1e3ac0c
6afc374
04b25cb
0f9ae38
8b8fa6f
1c22016
b2fcf6e
2b48703
2c846dc
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 |
|---|---|---|
|
|
@@ -5,8 +5,8 @@ LABEL authors="FeTS_Admin <[email protected]>" | |
| RUN apt-get update && apt-get update --fix-missing && apt-get install -y libnss3 libnspr4 libxcursor1 libxcursor-dev libasound2 libdbus-1-dev libglfw3-dev libgles2-mesa-dev ffmpeg libsm6 libxext6 python3.8 python3.8-venv python3.8-dev python3-setuptools | ||
|
|
||
| ENV PATH=/CaPTk/bin/qt/5.12.1/bin:/CaPTk/bin/qt/5.12.1/libexec:$PATH | ||
| ENV CMAKE_PREFIX_PATH=/CaPTk/bin/ITK-build:/CaPTk/bin/DCMTK-build:/CaPTk/bin/qt/5.12.1/lib/cmake/Qt5:$CMAKE_PREFIX_PATH | ||
|
|
||
| ENV CMAKE_PREFIX_PATH=/CaPTk/bin/ITK-build:/CaPTk/bin/DCMTK-build:/CaPTk/bin/qt/5.12.1/lib/cmake/Qt5 | ||
| ENV DCMTK_DIR=/CaPTk/bin/DCMTK-build | ||
| RUN pwd && ls -l | ||
|
|
||
| WORKDIR /Front-End | ||
|
|
@@ -88,13 +88,10 @@ RUN pip install git+https://github.com/mlcommons/GaNDLF@616b37bafad8f89d5c816a88 | |
| # setup a separate env for nnunet | ||
| RUN python -m venv /nnunet_env && /nnunet_env/bin/pip install --upgrade pip | ||
|
|
||
| RUN /nnunet_env/bin/pip install torch==1.12.1+cu102 torchvision==0.13.1+cu102 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu102 | ||
| RUN /nnunet_env/bin/pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu118 | ||
|
|
||
| RUN /nnunet_env/bin/pip install git+https://github.com/MIC-DKFZ/nnUNet.git@nnunetv1 | ||
|
|
||
| ENV nnUNet_raw_data_base="/tmp/nnUNet_raw_data_base" | ||
| ENV nnUNet_preprocessed="/tmp/nnUNet_preprocessed" | ||
| # see https://docs.docker.com/config/containers/resource_constraints/#gpu for detailed explanation | ||
| ENV CUDA_VISIBLE_DEVICES="0" | ||
|
|
||
| COPY ./mlcubes/data_preparation/project /project | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,4 +7,5 @@ | |
| */mlcube/workspace/* | ||
| !requirements.txt | ||
| !*/mlcube/workspace/parameters.yaml | ||
| models | ||
| models | ||
| tmpmodel | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| rm -rf workspace/data | ||
| rm -rf workspace/labels | ||
| rm -rf workspace/metadata | ||
| rm -rf workspace/report | ||
| rm -rf workspace/statistics |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,63 @@ | ||||||||
|
|
||||||||
| DATA=./workspace/data | ||||||||
|
|
||||||||
| run() { | ||||||||
| mlcube run --mlcube ./mlcube.yaml --task prepare --network=none --mount=ro \ | ||||||||
| report_file=report/report.yaml \ | ||||||||
| labels_path=input_data \ | ||||||||
| -Pdocker.cpu_args="-u $(id -u):$(id -g)" \ | ||||||||
| -Pdocker.gpu_args="-u $(id -u):$(id -g)" | ||||||||
| } | ||||||||
|
|
||||||||
| run_other() { | ||||||||
| mlcube run --mlcube ./mlcube.yaml --task sanity_check --network=none --mount=ro \ | ||||||||
| -Pdocker.cpu_args="-u $(id -u):$(id -g)" \ | ||||||||
| -Pdocker.gpu_args="-u $(id -u):$(id -g)" | ||||||||
|
|
||||||||
| mlcube run --mlcube ./mlcube.yaml --task statistics --network=none --mount=ro \ | ||||||||
| output_path=statistics/statistics.yaml \ | ||||||||
| -Pdocker.cpu_args="-u $(id -u):$(id -g)" \ | ||||||||
| -Pdocker.gpu_args="-u $(id -u):$(id -g)" | ||||||||
| } | ||||||||
|
|
||||||||
| STARTTIME=$(date +%s.%N) | ||||||||
|
|
||||||||
|
|
||||||||
| run | ||||||||
|
|
||||||||
| # manual review | ||||||||
| cp $DATA/tumor_extracted/DataForQC/AAAC_1/2008.03.31/TumorMasksForQC/AAAC_1_2008.03.31_tumorMask_model_0.nii.gz \ | ||||||||
| $DATA/tumor_extracted/DataForQC/AAAC_1/2008.03.31/TumorMasksForQC/finalized/AAAC_1_2008.03.31_tumorMask_model_0.nii.gz | ||||||||
|
|
||||||||
| cp $DATA/tumor_extracted/DataForQC/AAAC_1/2012.01.02/TumorMasksForQC/AAAC_1_2012.01.02_tumorMask_model_0.nii.gz \ | ||||||||
| $DATA/tumor_extracted/DataForQC/AAAC_1/2012.01.02/TumorMasksForQC/finalized/AAAC_1_2012.01.02_tumorMask_model_0.nii.gz | ||||||||
|
|
||||||||
| cp $DATA/tumor_extracted/DataForQC/AAAC_2/2001.01.01/TumorMasksForQC/AAAC_2_2001.01.01_tumorMask_model_0.nii.gz \ | ||||||||
| $DATA/tumor_extracted/DataForQC/AAAC_2/2001.01.01/TumorMasksForQC/finalized/AAAC_2_2001.01.01_tumorMask_model_0.nii.gz | ||||||||
| # end manual review | ||||||||
|
|
||||||||
| run & | ||||||||
| PID=$! | ||||||||
|
|
||||||||
| # prompt response | ||||||||
| BREAK=0 | ||||||||
| while [ $BREAK -eq "0" ] | ||||||||
| do | ||||||||
| if [ -f $DATA/".prompt.txt" ]; | ||||||||
| then BREAK=1; | ||||||||
| else | ||||||||
| sleep 0.1s; | ||||||||
| fi | ||||||||
|
|
||||||||
| done | ||||||||
|
|
||||||||
| echo -n "y" >> $DATA/.response.txt | ||||||||
| # end prompt response | ||||||||
|
|
||||||||
| wait ${PID} | ||||||||
|
|
||||||||
| ENDTIME=$(date +%s.%N) | ||||||||
| DIFF=$(echo "$ENDTIME - $STARTTIME" | bc) | ||||||||
| echo $DIFF | ||||||||
|
|
||||||||
| run_other | ||||||||
|
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.
Suggested change
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,62 @@ | ||||||||
|
|
||||||||
| DATA=./workspace/data | ||||||||
|
|
||||||||
| run() { | ||||||||
| mlcube run --mlcube ./mlcube.yaml --task prepare --network=none --mount=ro --platform=singularity \ | ||||||||
| report_file=report/report.yaml \ | ||||||||
| labels_path=input_data \ | ||||||||
| -Psingularity.run_args="-nce" | ||||||||
| } | ||||||||
|
|
||||||||
| run_other() { | ||||||||
| mlcube run --mlcube ./mlcube.yaml --task sanity_check --network=none --mount=ro --platform=singularity \ | ||||||||
| -Psingularity.run_args="-nce" | ||||||||
|
|
||||||||
|
|
||||||||
| mlcube run --mlcube ./mlcube.yaml --task statistics --network=none --mount=ro --platform=singularity \ | ||||||||
| output_path=statistics/statistics.yaml \ | ||||||||
| -Psingularity.run_args="-nce" | ||||||||
|
|
||||||||
| } | ||||||||
|
|
||||||||
| STARTTIME=$(date +%s.%N) | ||||||||
|
|
||||||||
|
|
||||||||
| run | ||||||||
|
|
||||||||
| # manual review | ||||||||
| cp $DATA/tumor_extracted/DataForQC/AAAC_1/2008.03.31/TumorMasksForQC/AAAC_1_2008.03.31_tumorMask_model_0.nii.gz \ | ||||||||
| $DATA/tumor_extracted/DataForQC/AAAC_1/2008.03.31/TumorMasksForQC/finalized/AAAC_1_2008.03.31_tumorMask_model_0.nii.gz | ||||||||
|
|
||||||||
| cp $DATA/tumor_extracted/DataForQC/AAAC_1/2012.01.02/TumorMasksForQC/AAAC_1_2012.01.02_tumorMask_model_0.nii.gz \ | ||||||||
| $DATA/tumor_extracted/DataForQC/AAAC_1/2012.01.02/TumorMasksForQC/finalized/AAAC_1_2012.01.02_tumorMask_model_0.nii.gz | ||||||||
|
|
||||||||
| cp $DATA/tumor_extracted/DataForQC/AAAC_2/2001.01.01/TumorMasksForQC/AAAC_2_2001.01.01_tumorMask_model_0.nii.gz \ | ||||||||
| $DATA/tumor_extracted/DataForQC/AAAC_2/2001.01.01/TumorMasksForQC/finalized/AAAC_2_2001.01.01_tumorMask_model_0.nii.gz | ||||||||
| # end manual review | ||||||||
|
|
||||||||
| run & | ||||||||
| PID=$! | ||||||||
|
|
||||||||
| # prompt response | ||||||||
| BREAK=0 | ||||||||
| while [ $BREAK -eq "0" ] | ||||||||
| do | ||||||||
| if [ -f $DATA/".prompt.txt" ]; | ||||||||
| then BREAK=1; | ||||||||
| else | ||||||||
| sleep 0.1s; | ||||||||
| fi | ||||||||
|
|
||||||||
| done | ||||||||
|
|
||||||||
| echo -n "y" >> $DATA/.response.txt | ||||||||
| # end prompt response | ||||||||
|
|
||||||||
| wait ${PID} | ||||||||
|
|
||||||||
| ENDTIME=$(date +%s.%N) | ||||||||
| DIFF=$(echo "$ENDTIME - $STARTTIME" | bc) | ||||||||
| echo $DIFF | ||||||||
|
|
||||||||
| run_other | ||||||||
|
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.
Suggested change
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||||
| FROM hasan7/baselocal:0.0.0 | ||||||||
|
|
||||||||
| COPY ./atlasImage_0.125.nii.gz /project | ||||||||
| COPY ./tmpmodel /project | ||||||||
|
|
||||||||
| # use a downsampled reference image for DICOM to NIFTI conversion | ||||||||
| RUN mv /project/atlasImage_0.125.nii.gz /Front-End/bin/install/appdir/usr/data/sri24/atlasImage.nii.gz | ||||||||
|
|
||||||||
| # remove heavy brain extraction models | ||||||||
| RUN rm -rf /project/stages/data_prep_models/brain_extraction/model_0/ | ||||||||
| RUN rm -rf /project/stages/data_prep_models/brain_extraction/model_1/ | ||||||||
|
|
||||||||
| # use dummy brain extraction models | ||||||||
| RUN cp -r /project/tmpmodel /project/stages/data_prep_models/brain_extraction/model_0 | ||||||||
| RUN mv /project/tmpmodel /project/stages/data_prep_models/brain_extraction/model_1 | ||||||||
|
|
||||||||
| ENTRYPOINT ["python", "/project/mlcube.py"] | ||||||||
|
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.
Suggested change
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # How to run tests | ||
|
|
||
| 1. Download and extract (sha256: 701fbba8b253fc5b2f54660837c493a38dec986df9bdbf3d97f07c8bc276a965): | ||
| <https://storage.googleapis.com/medperf-storage/rano_test_assets/dev.tar.gz> | ||
|
|
||
| 2. Move `additional_files` and `input_data` to the mlcube workspace | ||
| 3. Move `tmpmodel` and `atlasImage_0.125.nii.gz` to the mlcube project folder | ||
|
|
||
| 4. Build the base docker image from the repo's root folder Dockerfile | ||
| 5. Build the dev docker image using `Dockerfile.dev` in the mlcube project folder. | ||
| 6. Then change the docker image name in `mlcube.yaml` according to step 5. | ||
| 7. Then go to `mlcube` folder and run the tests scripts |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import os | ||
| import shutil | ||
| import argparse | ||
| import pandas as pd | ||
| import yaml | ||
|
|
@@ -157,10 +158,25 @@ def init_report(args) -> pd.DataFrame: | |
| def main(): | ||
| args = setup_argparser() | ||
|
|
||
| os.environ["RESULTS_FOLDER"] = os.path.join(args.models, "nnUNet_trained_models") | ||
| output_path = args.data_out | ||
| models_path = args.models | ||
|
|
||
| tmpfolder = os.path.join(output_path, ".tmp") | ||
| cbica_tmpfolder = os.path.join(tmpfolder, ".cbicaTemp") | ||
| os.environ["TMPDIR"] = tmpfolder | ||
| os.environ["CBICA_TEMP_DIR"] = cbica_tmpfolder | ||
| os.makedirs(tmpfolder, exist_ok=True) | ||
| os.makedirs(cbica_tmpfolder, exist_ok=True) | ||
| os.environ["RESULTS_FOLDER"] = os.path.join(models_path, "nnUNet_trained_models") | ||
| os.environ["nnUNet_raw_data_base"] = os.path.join(tmpfolder, "nnUNet_raw_data_base") | ||
| os.environ["nnUNet_preprocessed"] = os.path.join(tmpfolder, "nnUNet_preprocessed") | ||
|
|
||
| report = init_report(args) | ||
| pipeline = init_pipeline(args) | ||
| pipeline.run(report, args.report) | ||
|
|
||
| # cleanup tmp folder | ||
| shutil.rmtree(tmpfolder, ignore_errors=True) | ||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
|
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. Please add a new line at the end for consistency. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.