From 8d5bc53612230e1d3873acfa2e08223800c15c34 Mon Sep 17 00:00:00 2001 From: Usman Akinyemi Date: Sat, 1 Jun 2024 09:04:32 -0400 Subject: [PATCH 1/2] created the dockerise version of the TF2.4_IVIM-MRI_CodeCollection --- .dockerignore | 16 ++++++++++++++++ Dockerfile | 17 +++++++++++++++++ requirements.txt | 3 +-- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..31bf074 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +# Ignore editor and system files +.vscode/ +.git/ +.gitignore +*.md + +# Exclude development and test artifacts +__pycache__ +conftest + +# Docs +docs +doc + +# Others + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..70edb3c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3.9-slim + +WORKDIR /usr/src/app + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + libssl-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt ./ + +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +ENTRYPOINT ["python3", "-m", "WrapImage.nifti_wrapper"] diff --git a/requirements.txt b/requirements.txt index 18d4f2e..0d0e85b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,6 @@ numpy scipy torchio torch -logging joblib dipy matplotlib @@ -13,4 +12,4 @@ pytest tqdm pandas sphinx -sphinx_rtd_theme \ No newline at end of file +sphinx_rtd_theme From d44c6e7b2a43ab8a6fb8369b6e5088ce8ad14df1 Mon Sep 17 00:00:00 2001 From: Usman Akinyemi Date: Wed, 5 Jun 2024 10:41:21 -0400 Subject: [PATCH 2/2] Make the python to use version 3.11 docker version, created a dedicated directory for the Dockerfile and also added a README file to explain the build and run process --- .dockerignore => Docker/.dockerignore | 0 Dockerfile => Docker/Dockerfile | 6 +-- Docker/README.md | 61 +++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 3 deletions(-) rename .dockerignore => Docker/.dockerignore (100%) rename Dockerfile => Docker/Dockerfile (83%) create mode 100644 Docker/README.md diff --git a/.dockerignore b/Docker/.dockerignore similarity index 100% rename from .dockerignore rename to Docker/.dockerignore diff --git a/Dockerfile b/Docker/Dockerfile similarity index 83% rename from Dockerfile rename to Docker/Dockerfile index 70edb3c..a5537f9 100644 --- a/Dockerfile +++ b/Docker/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9-slim +FROM python:3.11-slim WORKDIR /usr/src/app @@ -8,10 +8,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY requirements.txt ./ +COPY ../requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt -COPY . . +COPY .. . ENTRYPOINT ["python3", "-m", "WrapImage.nifti_wrapper"] diff --git a/Docker/README.md b/Docker/README.md new file mode 100644 index 0000000..5d77553 --- /dev/null +++ b/Docker/README.md @@ -0,0 +1,61 @@ +# TF2.4_IVIM-MRI_CodeCollection + +This project is designed to run the `nifti_wrapper` script using a Docker container. Below are the steps to build and run the Docker image. + +## Prerequisites + +- Docker must be installed on your system. + +## Directory Structure + +``` +~/TF2.4_IVIM-MRI_CodeCollection/ +│ +├── Docker/ +│ └── Dockerfile +│ +├── WrapImage/ +│ └── nifti_wrapper.py +│ +└── requirements.txt +``` + +## Options + +Before running the Docker container, here are the available options for the `Docker image` script: + +- `input_file`: Path to the input 4D NIfTI file. +- `bvec_file`: Path to the b-vector file. +- `bval_file`: Path to the b-value file. +- `--affine`: Affine matrix for NIfTI image (optional). +- `--algorithm`: Select the algorithm to use (default is "OJ_GU_seg"). +- `algorithm_args`: Additional arguments for the algorithm (optional). + +## Building the Docker Image + +1. Open a terminal and navigate to the project directory: + + ```sh + cd ~/TF2.4_IVIM-MRI_CodeCollection + ``` + +2. Build the Docker image using the `docker build` command: + + ```sh + sudo docker build -t tf2.4_ivim-mri_codecollection -f Docker/Dockerfile . + ``` + +## Running the Docker Container + +1. Once the image is built, you can run the Docker container using the `docker run` command. This command runs the Docker image with the specified input files: + + ```sh + sudo docker run -it --rm --name TF2.4_IVIM-MRI_CodeCollection \ + -v ~/TF2.4_IVIM-MRI_CodeCollection:/usr/src/app \ + -v ~/TF2.4_IVIM-MRI_CodeCollection:/usr/app/output \ + tf2.4_ivim-mri_codecollection brain.nii.gz brain.bvec brain.bval + ``` + + Replace `brain.nii.gz`, `brain.bvec`, and `brain.bval` with the actual file names you want to use. + +---