diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c0ff7cc..5fb063c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,14 +15,20 @@ jobs: build: strategy: matrix: - image: [dockerfile_MCR, Dockerfile] + image: [dockerfile_1] fail-fast: false runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: get test data + run: make tests/data/MoAEpilot - name: Build the Docker image run: | docker build . --file ${{ matrix.image }} --tag cat12 docker images + - name: help + run: docker run --rm -it cat12_mcr + - name: test + run: docker run \ -v ${PWD}/tests/data/MoAEpilot:/data \ --rm -it cat12_mcr \ /data/sub-01/anat/sub-01_T1w.nii \ -b cat_standalone_segment.m diff --git a/.gitignore b/.gitignore index b1c9591..b867ad4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ .simg + +tests/data/raw +tests/data/MoAEpilot diff --git a/Dockerfile_1 b/Dockerfile_1 new file mode 100644 index 0000000..278841d --- /dev/null +++ b/Dockerfile_1 @@ -0,0 +1,84 @@ +# Generated by Neurodocker and Reproenv. + +FROM ubuntu:22.04 +ENV LANG="en_US.UTF-8" \ + LC_ALL="en_US.UTF-8" \ + ND_ENTRYPOINT="/neurodocker/startup.sh" +RUN export ND_ENTRYPOINT="/neurodocker/startup.sh" \ + && apt-get update -qq \ + && apt-get install -y -q --no-install-recommends \ + apt-utils \ + bzip2 \ + ca-certificates \ + curl \ + locales \ + unzip \ + && rm -rf /var/lib/apt/lists/* \ + && sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ + && dpkg-reconfigure --frontend=noninteractive locales \ + && update-locale LANG="en_US.UTF-8" \ + && chmod 777 /opt && chmod a+s /opt \ + && mkdir -p /neurodocker \ + && if [ ! -f "$ND_ENTRYPOINT" ]; then \ + echo '#!/usr/bin/env bash' >> "$ND_ENTRYPOINT" \ + && echo 'set -e' >> "$ND_ENTRYPOINT" \ + && echo 'export USER="${USER:=`whoami`}"' >> "$ND_ENTRYPOINT" \ + && echo 'if [ -n "$1" ]; then "$@"; else /usr/bin/env bash; fi' >> "$ND_ENTRYPOINT"; \ + fi \ + && chmod -R 777 /neurodocker && chmod a+s /neurodocker +ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/opt/MCR-2017b/v93/runtime/glnxa64:/opt/MCR-2017b/v93/bin/glnxa64:/opt/MCR-2017b/v93/sys/os/glnxa64:/opt/MCR-2017b/v93/extern/bin/glnxa64" \ + MATLABCMD="/opt/MCR-2017b/v93/toolbox/matlab" \ + XAPPLRESDIR="/opt//opt/MCR-2017b/v93/x11/app-defaults" \ + MCRROOT="/opt/MCR-2017b/v93" +RUN export TMPDIR="$(mktemp -d)" \ + && apt-get update -qq \ + && apt-get install -y -q --no-install-recommends \ + bc \ + curl \ + dbus-x11 \ + libncurses5 \ + libxext6 \ + libxmu6 \ + libxpm-dev \ + libxt6 \ + openjdk-8-jre \ + unzip \ + && rm -rf /var/lib/apt/lists/* \ + && echo "Downloading MATLAB Compiler Runtime ..." \ + && curl -o "$TMPDIR/mcr.zip" https://ssd.mathworks.com/supportfiles/downloads/R2017b/deployment_files/R2017b/installers/glnxa64/MCR_R2017b_glnxa64_installer.zip \ + && unzip -q "$TMPDIR/mcr.zip" -d "$TMPDIR/mcrtmp" \ + && "$TMPDIR/mcrtmp/install" -destinationFolder /opt/MCR-2017b -mode silent -agreeToLicense yes \ + && rm -rf "$TMPDIR" \ + && unset TMPDIR +ENV CAT_VERSION=".8.1_r2042_R2017b" +ENV FORCE_SPMMCR="1" \ + SPM_HTML_BROWSER="0" \ + MCR_INHIBIT_CTF_LOCK="1" \ + SPMROOT="/opt/CAT12${CAT_VERSION}" \ + PATH="/opt/CAT12${CAT_VERSION}:$PATH" \ + STANDALONE="/opt/CAT12${CAT_VERSION}/standalone" +RUN apt-get update -qq \ + && apt-get install -y -q --no-install-recommends \ + ca-certificates \ + curl \ + unzip \ + && rm -rf /var/lib/apt/lists/* \ + # Install cat12 + && echo "Downloading standalone CAT12 ..." \ + && curl -fL -o /tmp/cat12.zip http://www.neuro.uni-jena.de/cat12/CAT12${CAT_VERSION}_MCR_Linux.zip \ + && unzip -q /tmp/cat12.zip -d /tmp \ + && rm -rf /tmp/cat12.zip \ + && mkdir -p /opt/CAT12${CAT_VERSION} \ + && mv /tmp/*${CAT_VERSION}*/* /opt/CAT12${CAT_VERSION}/ \ + && chmod -R 777 /opt/CAT12${CAT_VERSION} \ + # Test + && /opt/CAT12${CAT_VERSION}/spm12 function exit + +# transfer code and set permission +RUN mkdir -p /code +COPY ./code /code +RUN ls /code && find /code -type f -print0 | xargs -0 chmod +r + +WORKDIR ${STANDALONE} + +ENTRYPOINT ["/code/main"] diff --git a/code/main b/code/main index cdb9e7a..c3c6189 100755 --- a/code/main +++ b/code/main @@ -1,18 +1,15 @@ #!/bin/bash -# Help +# Copy or view batch files +# Help if [ "$#" = 0 ] then echo "ERROR: No arguments passed." - cat /.singularity.d/runscript.help + exec ${STANDALONE}/cat_standalone.sh exit 1 fi -# Copy or view batch files - -STANDALONE="/opt/spm12/toolbox/cat12/standalone" - if [ "$1" = "copy" ] then if [ "$2" = "all" ] @@ -37,13 +34,12 @@ then cat ${STANDALONE}/"$2" exit 0 else - echo "ERROR: batch file $2 not found. Available batch files are:" + echo "ERROR: batch file '$2' not found. Available batch files are:" find ${STANDALONE} -name "*.m" -printf "%f\n" exit 1 fi fi # Run CAT - NOW=$(date +%s) -exec /code/cat_standalone.sh "$@" 2>&1 |tee cat_$NOW.log +exec ${STANDALONE}/cat_standalone.sh "$@" 2>&1 | tee cat_$NOW.log diff --git a/makefile b/makefile new file mode 100644 index 0000000..df73771 --- /dev/null +++ b/makefile @@ -0,0 +1,5 @@ +tests/data/MoAEpilot: + mkdir -p tests/data + curl -fL -o moae.zip https://www.fil.ion.ucl.ac.uk/spm/download/data/MoAEpilot/MoAEpilot.bids.zip + unzip -q moae.zip -d tests/data + rm -f moae.zip