From 77e200171f8f6fb03b790e72babdca209aedd966 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 1 Aug 2024 07:28:55 +0200 Subject: [PATCH 01/13] set up CI --- .gitattributes | 1 + .github/dependabot.yml | 14 +++++++++++++ .github/workflows/apptainer.yml | 27 ++++++++++++++++++++++++ .github/workflows/docker.yml | 27 ++++++++++++++++++++++++ .pre-commit-config.yaml | 37 +++++++++++++++++++++++++++++++++ README.md | 8 ++----- 6 files changed, 108 insertions(+), 6 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/apptainer.yml create mode 100644 .github/workflows/docker.yml create mode 100644 .pre-commit-config.yaml diff --git a/.gitattributes b/.gitattributes index 6846369..79223c1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,3 +2,4 @@ **/.git* annex.largefiles=nothing CHANGELOG.md annex.largefiles=nothing README.md annex.largefiles=nothing +.github annex.largefiles=nothing diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..e73f065 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +--- +# Documentation +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file +version: 2 +updates: +- package-ecosystem: github-actions + directory: / + schedule: + interval: monthly + +- package-ecosystem: gitsubmodule + directory: / + schedule: + interval: monthly diff --git a/.github/workflows/apptainer.yml b/.github/workflows/apptainer.yml new file mode 100644 index 0000000..ec691a0 --- /dev/null +++ b/.github/workflows/apptainer.yml @@ -0,0 +1,27 @@ +--- +name: apptainer build + +on: + push: + branches: [master] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + strategy: + matrix: + image: [Singularity_MCR, Singularity] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: eWaterCycle/setup-apptainer@v2 + with: + apptainer-version: 1.3.0 + - name: build sif image + run: apptainer build cat12.sif ${{ matrix.image }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..f843834 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,27 @@ +--- +name: docker build + +on: + push: + branches: [master] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + build: + strategy: + matrix: + image: [dockerfile_MCR, Dockerfile] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Build the Docker image + run: | + docker build . --file Dockerfile --tag cat12 + docker images diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..566f090 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,37 @@ +--- +ci: + skip: [hadolint-docker] + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-yaml + - id: check-json + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-case-conflict + - id: check-merge-conflict + - id: mixed-line-ending + +- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt + rev: 0.2.3 + hooks: + - id: yamlfmt + args: [--mapping, '4', --sequence, '4', --offset, '0'] + + +- repo: https://github.com/hadolint/hadolint + rev: v2.13.0-beta + hooks: + - id: hadolint-docker + name: Lint Dockerfiles + description: Runs hadolint Docker image to lint Dockerfiles + language: docker_image + types: [dockerfile] + entry: ghcr.io/hadolint/hadolint hadolint + +- repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell diff --git a/README.md b/README.md index 94b570e..712bc3b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,3 @@ -# Project +# CAT-12 container -## Dataset structure - -- All inputs (i.e. building blocks from other sources) are located in - `inputs/`. -- All custom code is located in `code/`. +Docker and Apptainer image for [CAT12](https://neuro-jena.github.io/cat/). From 0b9311c402e1adaa2102f61e037b24518cb93365 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 05:29:38 +0000 Subject: [PATCH 02/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .gitignore | 2 +- Dockerfile | 2 +- Singularity | 6 +++--- code/main | 2 +- dockerfile_MCR | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 698bde4..b1c9591 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -.simg \ No newline at end of file +.simg diff --git a/Dockerfile b/Dockerfile index 397a7de..efb5c09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,4 +55,4 @@ RUN mkdir -p /batch \ # clean RUN rm -f /opt/spm12/src/*.{mex,o,a} -ENTRYPOINT ['/code/main "$@"'] \ No newline at end of file +ENTRYPOINT ['/code/main "$@"'] diff --git a/Singularity b/Singularity index d65eef3..f4db1da 100644 --- a/Singularity +++ b/Singularity @@ -22,15 +22,15 @@ From: debian:bookworm-slim DEBIAN_FRONTEND=noninteractive apt-get --yes --quiet install \ octave \ liboctave-dev - + mkdir /opt/spm12 - curl -fsSL --retry 5 https://github.com/spm/spm12/archive/r7771.tar.gz | tar -xzC /opt/spm12 --strip-components 1 + curl -fsSL --retry 5 https://github.com/spm/spm12/archive/r7771.tar.gz | tar -xzC /opt/spm12 --strip-components 1 curl -fsSL --retry 5 https://raw.githubusercontent.com/spm/spm-octave/main/spm12_r7771.patch | patch -p0 make -C /opt/spm12/src PLATFORM=octave distclean make -C /opt/spm12/src PLATFORM=octave make -C /opt/spm12/src PLATFORM=octave install ln -s /opt/spm12/bin/spm12-octave /usr/local/bin/spm12 - + CATversion="r2560" cd /downloads diff --git a/code/main b/code/main index dacc88c..cdb9e7a 100755 --- a/code/main +++ b/code/main @@ -22,7 +22,7 @@ then exit 0 elif [ -f ${STANDALONE}/"$2" ] then - echo "Copying batch file to:" + echo "Copying batch file to:" cp -vi ${STANDALONE}/"$2" "$3" exit 0 else diff --git a/dockerfile_MCR b/dockerfile_MCR index 060985b..55b43e0 100644 --- a/dockerfile_MCR +++ b/dockerfile_MCR @@ -54,8 +54,8 @@ RUN mkdir -p /batch \ && cd /code && ln -s ${STANDALONE}/*.sh . \ && cd /batch && ln -s ${STANDALONE}/*.m . - + # clean RUN rm -f /downloads -ENTRYPOINT ['/code/main "$@"'] \ No newline at end of file +ENTRYPOINT ['/code/main "$@"'] From 03e5579364e67d9574eb385651af8073c72f42ee Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 1 Aug 2024 07:35:06 +0200 Subject: [PATCH 03/13] fixes --- .github/workflows/docker.yml | 2 +- Singularity_MCR | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f843834..32e13a7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -23,5 +23,5 @@ jobs: fetch-depth: 0 - name: Build the Docker image run: | - docker build . --file Dockerfile --tag cat12 + docker build . --file ${{ matrix.image }} --tag cat12 docker images diff --git a/Singularity_MCR b/Singularity_MCR index 04223cd..0799a47 100644 --- a/Singularity_MCR +++ b/Singularity_MCR @@ -161,7 +161,7 @@ USAGE: -a2 | --arg2 2nd additional argument (otherwise use defaults or batch) -a | --add add option to batch file - The first occurance of the parameter "" in the batch file will be replaced by the + The first occurrence of the parameter "" in the batch file will be replaced by the list of input files. You can use the existing batch files in this folder or create your own batch file with the SPM12 batch editor and leave the data field undefined. Please note that for creating your own batch file CAT12 has to be called in expert mode because the CAT12 standalone installation From 48da0ab0cb7bbf0311a2fdaac1ab337e01d640c2 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 1 Aug 2024 08:11:21 +0200 Subject: [PATCH 04/13] rename singularity def --- .pre-commit-config.yaml | 11 -- Singularity.def | 202 ++++++++++++++++++++++ Singularity_MCR.def | 375 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 577 insertions(+), 11 deletions(-) create mode 100644 Singularity.def create mode 100644 Singularity_MCR.def diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 566f090..bd81012 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,17 +20,6 @@ repos: - id: yamlfmt args: [--mapping, '4', --sequence, '4', --offset, '0'] - -- repo: https://github.com/hadolint/hadolint - rev: v2.13.0-beta - hooks: - - id: hadolint-docker - name: Lint Dockerfiles - description: Runs hadolint Docker image to lint Dockerfiles - language: docker_image - types: [dockerfile] - entry: ghcr.io/hadolint/hadolint hadolint - - repo: https://github.com/codespell-project/codespell rev: v2.3.0 hooks: diff --git a/Singularity.def b/Singularity.def new file mode 100644 index 0000000..ba90012 --- /dev/null +++ b/Singularity.def @@ -0,0 +1,202 @@ +Bootstrap: docker +From: debian:bookworm-slim@sha256:5f7d5664eae4a192c2d2d6cb67fc3f3c7891a8722cd2903cc35aa649a12b0c8d + +%setup + mkdir -p ${SINGULARITY_ROOTFS}/batch + mkdir -p ${SINGULARITY_ROOTFS}/code + mkdir -p ${SINGULARITY_ROOTFS}/downloads + + install -m 755 ./code/* ${SINGULARITY_ROOTFS}/code + +%post + apt-get -qq update + apt-get --yes --quiet --no-install-recommends install \ + wget \ + unzip \ + libxext6 \ + libxt6 \ + moreutils \ + build-essential \ + curl \ + ca-certificates + DEBIAN_FRONTEND=noninteractive apt-get --yes --quiet install \ + octave \ + liboctave-dev + + mkdir /opt/spm12 + curl -fsSL --retry 5 https://github.com/spm/spm12/archive/r7771.tar.gz | tar -xzC /opt/spm12 --strip-components 1 + curl -fsSL --retry 5 https://raw.githubusercontent.com/spm/spm-octave/main/spm12_r7771.patch | patch -p0 + make -C /opt/spm12/src PLATFORM=octave distclean + make -C /opt/spm12/src PLATFORM=octave + make -C /opt/spm12/src PLATFORM=octave install + ln -s /opt/spm12/bin/spm12-octave /usr/local/bin/spm12 + + CATversion="r2560" + + cd /downloads + wget http://www.neuro.uni-jena.de/cat12/cat12_${CATversion}.zip && unzip -d /opt/spm12/toolbox/ cat12_${CATversion}.zip + rm -fr /downloads + + # install CAT standalone interface + STANDALONE="/opt/spm12/toolbox/cat12/standalone" + cd ${STANDALONE} && chmod +rx *.sh + cd /code && ln -s ${STANDALONE}/*.sh . + cd /batch && ln -s ${STANDALONE}/*.m . + + # set permissions + find /code -type f -print0 | xargs -0 chmod +r + + rm -f /opt/spm12/src/*.{mex,o,a} + apt-get --yes remove build-essential curl liboctave-dev + apt-get --yes autoremove + apt-get --yes clean + +%environment + export SPM_HOME=/opt/spm12 + +%runscript + exec /code/main "$@" + +%labels + Author fil.spm@ucl.ac.uk + Malgorzata Wierzba (m.wierzba@fz-juelich.de) + Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) + Version v1.1 + +%help + This is a container with SPM12, CAT12 and GNU Octave. + +This container allows to run the standalone version of the +Computational Anatomy Toolbox (CAT), which is an extension to SPM +software using Octave 7.3.0 + +The container runs Debian bookworm-slim and includes: + +- Octave (7.3.0) +- Standalone version of SPM software (SPM12, r7771) +- Computational Anatomy Toolbox (CAT12.9 ${CATversion}) +- CAT interface scripts (cat_standalone.sh, cat_parallelize.sh). + +For more details on the exact version of the software used in this +container, please refer to the README file. + + +HOW TO USE: + +In principle this container allows you to perform the very same types +of analysis that are possible with the standalone version of CAT. It +is assumed that the user is familiar with the content of the batch +files dedicated for the use with the standalone version of CAT +(cat_standalone_segment.m, cat_standalone_simple.m, +cat_standalone_resample.m, cat_standalone_smooth.m) and can modify +their content according to his/her needs. For more details, please +refer to the CAT12 documentation and manual. + + +-- Available batch files -- + +The content of the batch files can be explored by using the 'view' and +'copy' subcommands: + +singularity run + +To view a batch file, use the 'view' subcommand: + +singularity run container.simg view cat_standalone_smooth.m + +To copy a batch file to your computer, use the 'copy' subcommand and +specify destination path as an additional argument: + +singularity run container.simg copy cat_standalone_smooth.m $HOME + +Make sure that the specified path is mounted to the container (more +information on this can be found below) and that you have write access +to this path! + +To copy all available batch files, use the 'all' argument: + +singularity run container.simg copy all $HOME + + +-- Running CAT -- + +Run the CAT analysis with the following command: +singularity run --cleanenv + +To use a default batch file, use one of the files included in the +container ('/batch'): +singularity run --cleanenv container.simg \ + -b /batch/cat_standalone_segment.m \ + T1.nii + +To use your own, customised batch file, simply specify its path: +singularity run --cleanenv container.simg \ + -b $HOME/cat_standalone_segment.m \ + T1.nii + + +-- Bind paths -- + +Please note that most of the host files remain inaccessible from within +the container. By default the following directories are mounted within +the container: '$HOME', '/tmp', '/proc', '/sys', '/dev', and '$PWD' +(see the Singularity documentation for more details). + +If you want the container to be able to access other locations, +specify a bind path of your choice. For instance, to make the contents +of the '/data' folder on your computer available in the '/mnt' folder +inside the container, specify the mount point in the following way: + +singularity run --cleanenv --bind /data:/mnt container.simg \ + -b /batch/cat_standalone_segment.m \ + /mnt/T1.nii + + +EXAMPLES: + +CAT12 segmentation batch: +singularity run --cleanenv container.simg \ + -b cat_standalone_segment.m \ + T1.nii + +CAT12 simple processing batch: +singularity run --cleanenv container.simg \ + -b cat_standalone_simple.m \ + T1.nii + +CAT12 resample & smooth batch: +singularity run --cleanenv container.simg \ + -b cat_standalone_resample.m \ + -a1 "12" -a2 "1" \ + lh.thickness.T1 + +CAT12 volume smoothing batch: +singularity run --cleanenv container.simg \ + -b cat_standalone_smooth.m \ + -a1 "[6 6 6]" -a2 "'s6'" \ + T1.nii + + + +Contact information: + +Any problems or concerns regarding this container should be reported +to Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) and regarding +CAT12 to Christian Gaser (christian.gaser@uni-jena.de) + + +Acknowledgements: + +The CAT toolbox (http://www.neuro.uni-jena.de/cat) is developed by +Christian Gaser and Robert Dahnke (Jena University Hospital, +Departments of Psychiatry and Neurology) and is free but copyright +software, distributed under the terms of the GNU General Public +Licence. + +The SPM software (https://www.fil.ion.ucl.ac.uk/spm/) is developed by +the Wellcome Trust Centre for Neuroimaging and is free but copyright +software, distributed under the terms of the GNU General Public +Licence (GPL). + +GNU Octave is a freely redistributable software under the terms of +the GPL as published by the Free Software Foundation. diff --git a/Singularity_MCR.def b/Singularity_MCR.def new file mode 100644 index 0000000..c5b9182 --- /dev/null +++ b/Singularity_MCR.def @@ -0,0 +1,375 @@ +Bootstrap: docker +From: debian:buster-slim@sha256:5f7d5664eae4a192c2d2d6cb67fc3f3c7891a8722cd2903cc35aa649a12b0c8d + +%setup + mkdir -p ${SINGULARITY_ROOTFS}/batch + mkdir -p ${SINGULARITY_ROOTFS}/code + mkdir -p ${SINGULARITY_ROOTFS}/downloads + + install -m 755 ./code/* ${SINGULARITY_ROOTFS}/code + +%post + apt-get update + apt-get -y install wget unzip libxext6 libxt6 moreutils + + # download software & unzip + MCRURL="https://ssd.mathworks.com/supportfiles/downloads/R2017b/deployment_files/R2017b/installers/glnxa64/MCR_R2017b_glnxa64_installer.zip" + SPMURL="http://www.neuro.uni-jena.de/cat12/CAT12.8.1_r2042_R2017b_MCR_Linux.zip" + + cd /downloads + wget "${MCRURL}" && unzip -d /downloads/MCR MCR_R2017b_glnxa64_installer.zip + wget "${SPMURL}" && unzip -d /code/SPM CAT12.8.1_r2042_R2017b_MCR_Linux.zip + + # install MCR + /downloads/MCR/install -mode silent -agreeToLicense yes + + # generalize CAT12 version + mv /code/SPM/CAT12.8.1_r2042_R2017b_MCR_Linux/ /code/SPM/MCR_Linux/ + + # install SPM + /code/SPM/MCR_Linux/run_spm12.sh /usr/local/MATLAB/MATLAB_Runtime/v93 quit + cd /code/SPM/MCR_Linux && chmod +rx run_spm12.sh spm12.sh spm12 spm12.ctf + + # install CAT standalone interface + STANDALONE="/code/SPM/MCR_Linux/standalone" + cd ${STANDALONE} && chmod +rx *.sh + cd /code && ln -s ${STANDALONE}/*.sh . + cd /batch && ln -s ${STANDALONE}/*.m . + + # set permissions + find /code -type f -print0 | xargs -0 chmod +r + find /code/SPM/MCR_Linux/spm12_mcr/ -name 'CAT.glnx86' -print0 | xargs -0 chmod +rx -R + + rm -fr /downloads + + apt-get clean + apt-get autoremove + +%environment + export SPMROOT=/code/SPM/MCR_Linux + export MCRROOT=/usr/local/MATLAB/MATLAB_Runtime/v93 + export MCR_INHIBIT_CTF_LOCK=1 + +%runscript + exec /code/main "$@" + +%labels + Authors Malgorzata Wierzba (m.wierzba@fz-juelich.de) + Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) + Version 1.1 + +%help + +This container allows to run the standalone, compiled version of the +Computational Anatomy Toolbox (CAT), which is an extension to SPM +software. Using the container does not require the availability of a +MATLAB licence. + +The container includes: + +- MATLAB Compiler Runtime (R2017b, 9.3) +- Standalone version of SPM software (SPM12, r7771) +- Computational Anatomy Toolbox (CAT12.8 r2042) +- CAT interface scripts (cat_standalone.sh, cat_parallelize.sh). + +For more details on the exact version of the software used in this +container, please refer to the README file. + + +HOW TO USE: + +In principle this container allows you to perform the very same types +of analysis that are possible with the standalone version of CAT. It +is assumed that the user is familiar with the content of the batch +files dedicated for the use with the standalone version of CAT +(cat_standalone_segment.m, cat_standalone_simple.m, +cat_standalone_resample.m, cat_standalone_smooth.m) and can modify +their content according to his/her needs. For more details, please +refer to the CAT12 documentation and manual. + + +-- Available batch files -- + +The content of the batch files can be explored by using the 'view' and +'copy' subcommands: + +singularity run + +To view a batch file, use the 'view' subcommand: + +singularity run container.simg view cat_standalone_smooth.m + +To copy a batch file to your computer, use the 'copy' subcommand and +specify destination path as an additional argument: + +singularity run container.simg copy cat_standalone_smooth.m $HOME + +Make sure that the specified path is mounted to the container (more +information on this can be found below) and that you have write access +to this path! + +To copy all available batch files, use the 'all' argument: + +singularity run container.simg copy all $HOME + + +-- Running CAT -- + +Run the CAT analysis with the following command: +singularity run --cleanenv + +To use a default batch file, use one of the files included in the +container ('/batch'): +singularity run --cleanenv container.simg \ + -b /batch/cat_standalone_segment.m \ + T1.nii + +To use your own, customised batch file, simply specify its path: +singularity run --cleanenv container.simg \ + -b $HOME/cat_standalone_segment.m \ + T1.nii + + +-- Bind paths -- + +Please note that most of the host files remain inaccessible from within +the container. By default the following directories are mounted within +the container: '$HOME', '/tmp', '/proc', '/sys', '/dev', and '$PWD' +(see the Singularity documentation for more details). + +If you want the container to be able to access other locations, +specify a bind path of your choice. For instance, to make the contents +of the '/data' folder on your computer available in the '/mnt' folder +inside the container, specify the mount point in the following way: + +singularity run --cleanenv --bind /data:/mnt container.simg \ + -b /batch/cat_standalone_segment.m \ + /mnt/T1.nii + + +EXAMPLES: + +USAGE: + cat_standalone.sh filename(s) [-s spm_standalone_folder] [-m mcr_folder] [-b batch_file] + [-a1 additional_argument1] [-a2 additional_argument2] + [-a add_to_batch] + + -s | --spm SPM12 folder of standalone version (can be also defined by SPMROOT) + -m | --mcr Matlab Compiler Runtime (MCR) folder (can be also defined by MCRROOT) + -b | --batch batch file to execute + -a1 | --arg1 1st additional argument (otherwise use defaults or batch) + -a2 | --arg2 2nd additional argument (otherwise use defaults or batch) + -a | --add add option to batch file + + The first occurrence of the parameter "" in the batch file will be replaced by the + list of input files. You can use the existing batch files in this folder or create your own batch + file with the SPM12 batch editor and leave the data field undefined. Please note that for creating + your own batch file CAT12 has to be called in expert mode because the CAT12 standalone installation + will only run in expert mode to allow more options. + See cat_standalone_segment.m for an example. + + You can also define one or two optional arguments to change other parameters that are indicated by + "" in the batch file. Please take care of the order of the "" fields in the + batch file! If no additional arguments are defined the default values are used. + Also, you must use multiple quotes if the argument is a string (e.g. " 'your_string' "). + + If you use a computer cluster it is recommended to use the batch files to only process one data set + and use a job or queue tool to call the (single) jobs on the cluster. + +PURPOSE: + Command line call of (CAT12) batch files for SPM12 standalone installation + +EXAMPLES + ----------------------------------------------------------------------------------------------- + Segmentation + -a1 TPM + -a2 Shooting template + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_segment.m sTRIO0001.nii + Preprocess (segment) the single file sTRIO0001.nii using the default CAT12 preprocessing batch. + SPM12 standalone version is located in $SPMROOT and Matlab Compiler Runtime in + /Applications/MATLAB/MATLAB_Runtime/v93. + + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_segment.m sTRIO000*.nii.gz \ + -a1 " '${cat12_dir}/templates_MNI152NLin2009cAsym/TPM_Age11.5.nii' " \ + -a2 " '${cat12_dir}/templates_MNI152NLin2009cAsym/Template_0_GS1mm.nii' " + Unzip and preprocess (segment) the files sTRIO0001.nii.gz using the default CAT12 preprocessing + batch, but use the children TPM provided with CAT12 and a 1mm Shooting template (not provided + with CAT12). Please note that zipped file can only be handled with this standalone batch and also + note the multiple quotes for parameter a1 and a2. + + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_segment.m sTRIO0001.nii \ + -a "matlabbatch{1}.spm.tools.cat.estwrite.output.surface = 0;" + Preprocess (segment) the single file sTRIO0001.nii using the default CAT12 preprocessing batch, + but skip surface estimation. + + ----------------------------------------------------------------------------------------------- + Longitudinal Segmentation + -a1 longitudinal model (0 - developmental; 1 - plasticity/learning; 2 - aging; 3 - save models 1 and 2) + -a2 TPM + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_segment_long.m sTRIO000*.nii \ + -a1 "2" + Preprocess (segment) the files sTRIO000*.nii with the longitudinal pipeline optimized for + detecting aging/developmental effects. In order to choose the longitudinal model optimized for + detecting small changes due to plasticity/learning change the a1 parameter to "1". + + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_segment_long.m sTRIO000*.nii \ + -a1 "1" -a2 " '${cat12_dir}/templates_MNI152NLin2009cAsym/TPM_Age11.5.nii' " + Preprocess (segment) the files sTRIO000*.nii with the longitudinal pipeline optimized for + detecting plasticity/learning effects and use the children TPM provided with CAT12. + Please note the multiple quotes for parameter a2. + + ----------------------------------------------------------------------------------------------- + Segmentation (Simple Mode) + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_simple.m sTRIO0001.nii + Process the single file sTRIO0001.nii using the simple processing batch. + + ----------------------------------------------------------------------------------------------- + Resample & Smooth Surfaces + -a1 smoothing filter size surface values + -a2 use 32k mesh from HCP (or 164k mesh from Freesurfer) + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_resample.m lh.thickness.sTRIO0001 \ + -a1 "12" -a2 "1" + Resample and smooth the single thickness file lh.thickness.sTRIO0001 with 12mm and save the + resampled mesh as 32k mesh (HCP conform mesh). Only the left surface file has to be defined. + The right hemisphere is processed automatically. + + ----------------------------------------------------------------------------------------------- + Smoothing + -a1 smoothing filter size + -a2 prepending string for smoothed file (e.g. 's6') + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_smooth.m sTRIO*nii \ + -a1 "[6 6 6]" -a2 " 's6' " + Smooth the volume files sTRIO*nii with 6mm and prepend the string "s6" to the smoothed files. + Please note the multiple quotes for parameter a2. + + ----------------------------------------------------------------------------------------------- + Dicom Import + -a1 directory structure + -a2 output directory + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_dicom2nii.m *.dcm \ + -a1 " 'patid_date' " -a2 "{'converted'}" + Import DICOM files *.dcm and save converted nifti files in directory "converted" with structure + ./// + Other options for directory structure are: + 'flat' No directory hierarchy + 'series' ./ + 'patid_date' ./// + 'patid' .// + 'date_time' .// + Please note the multiple quotes for parameter a1. + + ----------------------------------------------------------------------------------------------- + De-Facing + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_deface.m sTRIO*.nii + Apply de-facing to sTRIO*.nii and save the files prefixed by "anon_". + + ----------------------------------------------------------------------------------------------- + Estimate and Save Quality Measures for Volumes or Surfaces + -a1 csv output filename + -a2 enable global scaling with TIV (only for volumes meaningful) + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_get_quality.m mwp1sTRIO*nii \ + -a1 " 'Quality_measures.csv' " -a2 "1" + Estimate mean z-scores using global scaling with TIV for the files mwp1sTRIO*nii and save quality + measures in Quality_measures.csv for external analysis. Processing of surface meshes is also + supported. + Please note the multiple quotes for parameter a1. + + ----------------------------------------------------------------------------------------------- + Estimate mean/volume inside ROI + -a1 output-file string + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_get_ROI_values.m catROI_*.xml \ + -a1 " 'ROI' " + Save mean volume values in mL (e.g. GM volume) or the mean surface values (e.g. thickness) for + all data catROI_*.xml in a csv-file. The csv-file is named "ROI_" followed by the atlas name + and the name of the measure (e.g. Vgm). + Please note the multiple quotes for parameter a1. + + ----------------------------------------------------------------------------------------------- + TFCE Statistical Estimation + -a1 contrast number + -a2 number of permutations + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_tfce.m SPM.mat \ + -a1 "2" -a2 "20000" + Call estimation of TFCE statistics for the given SPM.mat file for contrast number 2 with 20000 + permutations. + + ----------------------------------------------------------------------------------------------- + Parallelization + ----------------------------------------------------------------------------------------------- + cat_parallelize.sh -p 8 -l /tmp \ + -c "cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 -b ${cwd}/cat_standalone_segment.m" sTRIO*.nii + Parallelize CAT12 preprocessing by splitting all sTRIO*.nii files into 8 jobs + (processes) and save log file in /tmp folder. + + The parameters SPMROOT and MCRROOT have to be defined (exported) to skip the use of the flags -s -m. + +INPUT: + nifti files or surface data + +OUTPUT: + processed images and optionally surfaces according to settings in cat_standalone_*.m + +USED FUNCTIONS: + cat_parallelize.sh + SPM12 standalone version (compiled) + CAT12 toolbox (compiled within SPM12 if installed) + MATLAB Compiler Runtime R2017b (Version 9.3) + +This script was written by Christian Gaser (christian.gaser@uni-jena.de). +This is ${version}. + + +Known issues: + +- Parallelization with cat_parallelize.sh is not implemented yet. +- Longitudinal segmentation with cat_standalone_segment_long.m + is not tested yet. + + +Contact information: + +Any problems or concerns regarding this container should be reported +to Malgorzata Wierzba (m.wierzba@fz-juelich.de), Michael Hanke +(m.hanke@fz-juelich.de) or Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) + + +Acknowledgements: + +The CAT toolbox (http://www.neuro.uni-jena.de/cat) is developed by +Christian Gaser and Robert Dahnke (Jena University Hospital, +Departments of Psychiatry and Neurology) and is free but copyright +software, distributed under the terms of the GNU General Public +Licence. + +The SPM software (https://www.fil.ion.ucl.ac.uk/spm/) is developed by +the Wellcome Trust Centre for Neuroimaging and is free but copyright +software, distributed under the terms of the GNU General Public +Licence. + +MATLAB Compiler Runtime +(https://uk.mathworks.com/products/compiler/matlab-runtime.html) is +developed by the The MathWorks, Inc. and is subject to the MATLAB +Runtime licence. From f729411e6bf2dcbddc3b51d9ecb26c5168f18a0b Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 1 Aug 2024 08:11:49 +0200 Subject: [PATCH 05/13] pin base image version --- Dockerfile | 34 +++++++++++++++++----------------- dockerfile_MCR | 36 ++++++++++++++++++------------------ 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Dockerfile b/Dockerfile index efb5c09..2b3e370 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bookworm-slim +FROM debian:bookworm-slim@sha256:5f7d5664eae4a192c2d2d6cb67fc3f3c7891a8722cd2903cc35aa649a12b0c8d LABEL org.opencontainers.image.authors="fil.spm@ucl.ac.uk, Malgorzata Wierzba (m.wierzba@fz-juelich.de), Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de)" LABEL org.opencontainers.image.source="https://gin.g-node.org/felixh/cat12-container" @@ -11,22 +11,22 @@ ENV STANDALONE="/opt/spm12/toolbox/cat12/standalone" RUN apt-get update -qq && \ apt-get -qq -y --no-install-recommends install \ - build-essential \ - ca-certificates \ - curl \ - unzip \ - liboctave-dev \ - libxext6 \ - libxt6 \ - moreutils \ - octave \ - wget \ - && apt-get clean \ - && rm -rf \ - /tmp/hsperfdata* \ - /var/*/apt/*/partial \ - /var/lib/apt/lists/* \ - /var/log/apt/term* + build-essential \ + ca-certificates \ + curl \ + unzip \ + liboctave-dev \ + libxext6 \ + libxt6 \ + moreutils \ + octave \ + wget \ + && apt-get clean \ + && rm -rf \ + /tmp/hsperfdata* \ + /var/*/apt/*/partial \ + /var/lib/apt/lists/* \ + /var/log/apt/term* # install SPM12 RUN mkdir /opt/spm12 \ diff --git a/dockerfile_MCR b/dockerfile_MCR index 55b43e0..7fe586a 100644 --- a/dockerfile_MCR +++ b/dockerfile_MCR @@ -1,4 +1,4 @@ -FROM debian:bookworm-slim +FROM debian:bookworm-slim@sha256:5f7d5664eae4a192c2d2d6cb67fc3f3c7891a8722cd2903cc35aa649a12b0c8d LABEL org.opencontainers.image.authors="fil.spm@ucl.ac.uk, Malgorzata Wierzba (m.wierzba@fz-juelich.de), Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de)" LABEL org.opencontainers.image.source="https://gin.g-node.org/felixh/cat12-container" @@ -15,24 +15,24 @@ ENV MCR_INHIBIT_CTF_LOCK="1" RUN apt-get update -qq && \ apt-get -qq -y --no-install-recommends install \ - build-essential \ - ca-certificates \ - curl \ - unzip \ - liboctave-dev \ - libxext6 \ - libxt6 \ - moreutils \ - wget \ - && apt-get clean \ - && rm -rf \ - /tmp/hsperfdata* \ - /var/*/apt/*/partial \ - /var/lib/apt/lists/* \ - /var/log/apt/term* + build-essential \ + ca-certificates \ + curl \ + unzip \ + liboctave-dev \ + libxext6 \ + libxt6 \ + moreutils \ + wget \ + && apt-get clean \ + && rm -rf \ + /tmp/hsperfdata* \ + /var/*/apt/*/partial \ + /var/lib/apt/lists/* \ + /var/log/apt/term* # install MCR -RUN mkdir /downloads/MCR \ +RUN mkdir -p /downloads/MCR \ && curl -fsSL --retry 5 https://ssd.mathworks.com/supportfiles/downloads/R2017b/deployment_files/R2017b/installers/glnxa64/MCR_R2017b_glnxa64_installer.zip | tar -xzC /downloads/MCR MCR_R2017b_glnxa64_installer.zip --strip-components 1 \ && bash /downloads/MCR/install -mode silent -agreeToLicense yes @@ -49,7 +49,7 @@ RUN mkdir -p /batch \ && rm -fr /downloads \ && /code/SPM/MCR_Linux/run_spm12.sh /usr/local/MATLAB/MATLAB_Runtime/v93 quit \ && cd /code/SPM/MCR_Linux \ - && chmod +rx run_spm12.sh spm12.sh spm12 spm12.ctf + && chmod +rx run_spm12.sh spm12.sh spm12 spm12.ctf \ && cd ${STANDALONE} && chmod +rx *.sh \ && cd /code && ln -s ${STANDALONE}/*.sh . \ && cd /batch && ln -s ${STANDALONE}/*.m . From 49a919cff0a38fdc800ab42b67a3420b7707a35d Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 1 Aug 2024 08:13:33 +0200 Subject: [PATCH 06/13] precommit fixes --- Singularity | 202 -------------------------- Singularity_MCR | 375 ------------------------------------------------ 2 files changed, 577 deletions(-) delete mode 100644 Singularity delete mode 100644 Singularity_MCR diff --git a/Singularity b/Singularity deleted file mode 100644 index f4db1da..0000000 --- a/Singularity +++ /dev/null @@ -1,202 +0,0 @@ -Bootstrap: docker -From: debian:bookworm-slim - -%setup - mkdir -p ${SINGULARITY_ROOTFS}/batch - mkdir -p ${SINGULARITY_ROOTFS}/code - mkdir -p ${SINGULARITY_ROOTFS}/downloads - - install -m 755 ./code/* ${SINGULARITY_ROOTFS}/code - -%post - apt-get -qq update - apt-get --yes --quiet --no-install-recommends install \ - wget \ - unzip \ - libxext6 \ - libxt6 \ - moreutils \ - build-essential \ - curl \ - ca-certificates - DEBIAN_FRONTEND=noninteractive apt-get --yes --quiet install \ - octave \ - liboctave-dev - - mkdir /opt/spm12 - curl -fsSL --retry 5 https://github.com/spm/spm12/archive/r7771.tar.gz | tar -xzC /opt/spm12 --strip-components 1 - curl -fsSL --retry 5 https://raw.githubusercontent.com/spm/spm-octave/main/spm12_r7771.patch | patch -p0 - make -C /opt/spm12/src PLATFORM=octave distclean - make -C /opt/spm12/src PLATFORM=octave - make -C /opt/spm12/src PLATFORM=octave install - ln -s /opt/spm12/bin/spm12-octave /usr/local/bin/spm12 - - CATversion="r2560" - - cd /downloads - wget http://www.neuro.uni-jena.de/cat12/cat12_${CATversion}.zip && unzip -d /opt/spm12/toolbox/ cat12_${CATversion}.zip - rm -fr /downloads - - # install CAT standalone interface - STANDALONE="/opt/spm12/toolbox/cat12/standalone" - cd ${STANDALONE} && chmod +rx *.sh - cd /code && ln -s ${STANDALONE}/*.sh . - cd /batch && ln -s ${STANDALONE}/*.m . - - # set permissions - find /code -type f -print0 | xargs -0 chmod +r - - rm -f /opt/spm12/src/*.{mex,o,a} - apt-get --yes remove build-essential curl liboctave-dev - apt-get --yes autoremove - apt-get --yes clean - -%environment - export SPM_HOME=/opt/spm12 - -%runscript - exec /code/main "$@" - -%labels - Author fil.spm@ucl.ac.uk - Malgorzata Wierzba (m.wierzba@fz-juelich.de) - Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) - Version v1.1 - -%help - This is a container with SPM12, CAT12 and GNU Octave. - -This container allows to run the standalone version of the -Computational Anatomy Toolbox (CAT), which is an extension to SPM -software using Octave 7.3.0 - -The container runs Debian bookworm-slim and includes: - -- Octave (7.3.0) -- Standalone version of SPM software (SPM12, r7771) -- Computational Anatomy Toolbox (CAT12.9 ${CATversion}) -- CAT interface scripts (cat_standalone.sh, cat_parallelize.sh). - -For more details on the exact version of the software used in this -container, please refer to the README file. - - -HOW TO USE: - -In principle this container allows you to perform the very same types -of analysis that are possible with the standalone version of CAT. It -is assumed that the user is familiar with the content of the batch -files dedicated for the use with the standalone version of CAT -(cat_standalone_segment.m, cat_standalone_simple.m, -cat_standalone_resample.m, cat_standalone_smooth.m) and can modify -their content according to his/her needs. For more details, please -refer to the CAT12 documentation and manual. - - --- Available batch files -- - -The content of the batch files can be explored by using the 'view' and -'copy' subcommands: - -singularity run - -To view a batch file, use the 'view' subcommand: - -singularity run container.simg view cat_standalone_smooth.m - -To copy a batch file to your computer, use the 'copy' subcommand and -specify destination path as an additional argument: - -singularity run container.simg copy cat_standalone_smooth.m $HOME - -Make sure that the specified path is mounted to the container (more -information on this can be found below) and that you have write access -to this path! - -To copy all available batch files, use the 'all' argument: - -singularity run container.simg copy all $HOME - - --- Running CAT -- - -Run the CAT analysis with the following command: -singularity run --cleanenv - -To use a default batch file, use one of the files included in the -container ('/batch'): -singularity run --cleanenv container.simg \ - -b /batch/cat_standalone_segment.m \ - T1.nii - -To use your own, customised batch file, simply specify its path: -singularity run --cleanenv container.simg \ - -b $HOME/cat_standalone_segment.m \ - T1.nii - - --- Bind paths -- - -Please note that most of the host files remain inaccessible from within -the container. By default the following directories are mounted within -the container: '$HOME', '/tmp', '/proc', '/sys', '/dev', and '$PWD' -(see the Singularity documentation for more details). - -If you want the container to be able to access other locations, -specify a bind path of your choice. For instance, to make the contents -of the '/data' folder on your computer available in the '/mnt' folder -inside the container, specify the mount point in the following way: - -singularity run --cleanenv --bind /data:/mnt container.simg \ - -b /batch/cat_standalone_segment.m \ - /mnt/T1.nii - - -EXAMPLES: - -CAT12 segmentation batch: -singularity run --cleanenv container.simg \ - -b cat_standalone_segment.m \ - T1.nii - -CAT12 simple processing batch: -singularity run --cleanenv container.simg \ - -b cat_standalone_simple.m \ - T1.nii - -CAT12 resample & smooth batch: -singularity run --cleanenv container.simg \ - -b cat_standalone_resample.m \ - -a1 "12" -a2 "1" \ - lh.thickness.T1 - -CAT12 volume smoothing batch: -singularity run --cleanenv container.simg \ - -b cat_standalone_smooth.m \ - -a1 "[6 6 6]" -a2 "'s6'" \ - T1.nii - - - -Contact information: - -Any problems or concerns regarding this container should be reported -to Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) and regarding -CAT12 to Christian Gaser (christian.gaser@uni-jena.de) - - -Acknowledgements: - -The CAT toolbox (http://www.neuro.uni-jena.de/cat) is developed by -Christian Gaser and Robert Dahnke (Jena University Hospital, -Departments of Psychiatry and Neurology) and is free but copyright -software, distributed under the terms of the GNU General Public -Licence. - -The SPM software (https://www.fil.ion.ucl.ac.uk/spm/) is developed by -the Wellcome Trust Centre for Neuroimaging and is free but copyright -software, distributed under the terms of the GNU General Public -Licence (GPL). - -GNU Octave is a freely redistributable software under the terms of -the GPL as published by the Free Software Foundation. diff --git a/Singularity_MCR b/Singularity_MCR deleted file mode 100644 index 0799a47..0000000 --- a/Singularity_MCR +++ /dev/null @@ -1,375 +0,0 @@ -Bootstrap: docker -From: debian:buster-slim - -%setup - mkdir -p ${SINGULARITY_ROOTFS}/batch - mkdir -p ${SINGULARITY_ROOTFS}/code - mkdir -p ${SINGULARITY_ROOTFS}/downloads - - install -m 755 ./code/* ${SINGULARITY_ROOTFS}/code - -%post - apt-get update - apt-get -y install wget unzip libxext6 libxt6 moreutils - - # download software & unzip - MCRURL="https://ssd.mathworks.com/supportfiles/downloads/R2017b/deployment_files/R2017b/installers/glnxa64/MCR_R2017b_glnxa64_installer.zip" - SPMURL="http://www.neuro.uni-jena.de/cat12/CAT12.8.1_r2042_R2017b_MCR_Linux.zip" - - cd /downloads - wget "${MCRURL}" && unzip -d /downloads/MCR MCR_R2017b_glnxa64_installer.zip - wget "${SPMURL}" && unzip -d /code/SPM CAT12.8.1_r2042_R2017b_MCR_Linux.zip - - # install MCR - /downloads/MCR/install -mode silent -agreeToLicense yes - - # generalize CAT12 version - mv /code/SPM/CAT12.8.1_r2042_R2017b_MCR_Linux/ /code/SPM/MCR_Linux/ - - # install SPM - /code/SPM/MCR_Linux/run_spm12.sh /usr/local/MATLAB/MATLAB_Runtime/v93 quit - cd /code/SPM/MCR_Linux && chmod +rx run_spm12.sh spm12.sh spm12 spm12.ctf - - # install CAT standalone interface - STANDALONE="/code/SPM/MCR_Linux/standalone" - cd ${STANDALONE} && chmod +rx *.sh - cd /code && ln -s ${STANDALONE}/*.sh . - cd /batch && ln -s ${STANDALONE}/*.m . - - # set permissions - find /code -type f -print0 | xargs -0 chmod +r - find /code/SPM/MCR_Linux/spm12_mcr/ -name 'CAT.glnx86' -print0 | xargs -0 chmod +rx -R - - rm -fr /downloads - - apt-get clean - apt-get autoremove - -%environment - export SPMROOT=/code/SPM/MCR_Linux - export MCRROOT=/usr/local/MATLAB/MATLAB_Runtime/v93 - export MCR_INHIBIT_CTF_LOCK=1 - -%runscript - exec /code/main "$@" - -%labels - Authors Malgorzata Wierzba (m.wierzba@fz-juelich.de) - Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) - Version 1.1 - -%help - -This container allows to run the standalone, compiled version of the -Computational Anatomy Toolbox (CAT), which is an extension to SPM -software. Using the container does not require the availability of a -MATLAB licence. - -The container includes: - -- MATLAB Compiler Runtime (R2017b, 9.3) -- Standalone version of SPM software (SPM12, r7771) -- Computational Anatomy Toolbox (CAT12.8 r2042) -- CAT interface scripts (cat_standalone.sh, cat_parallelize.sh). - -For more details on the exact version of the software used in this -container, please refer to the README file. - - -HOW TO USE: - -In principle this container allows you to perform the very same types -of analysis that are possible with the standalone version of CAT. It -is assumed that the user is familiar with the content of the batch -files dedicated for the use with the standalone version of CAT -(cat_standalone_segment.m, cat_standalone_simple.m, -cat_standalone_resample.m, cat_standalone_smooth.m) and can modify -their content according to his/her needs. For more details, please -refer to the CAT12 documentation and manual. - - --- Available batch files -- - -The content of the batch files can be explored by using the 'view' and -'copy' subcommands: - -singularity run - -To view a batch file, use the 'view' subcommand: - -singularity run container.simg view cat_standalone_smooth.m - -To copy a batch file to your computer, use the 'copy' subcommand and -specify destination path as an additional argument: - -singularity run container.simg copy cat_standalone_smooth.m $HOME - -Make sure that the specified path is mounted to the container (more -information on this can be found below) and that you have write access -to this path! - -To copy all available batch files, use the 'all' argument: - -singularity run container.simg copy all $HOME - - --- Running CAT -- - -Run the CAT analysis with the following command: -singularity run --cleanenv - -To use a default batch file, use one of the files included in the -container ('/batch'): -singularity run --cleanenv container.simg \ - -b /batch/cat_standalone_segment.m \ - T1.nii - -To use your own, customised batch file, simply specify its path: -singularity run --cleanenv container.simg \ - -b $HOME/cat_standalone_segment.m \ - T1.nii - - --- Bind paths -- - -Please note that most of the host files remain inaccessible from within -the container. By default the following directories are mounted within -the container: '$HOME', '/tmp', '/proc', '/sys', '/dev', and '$PWD' -(see the Singularity documentation for more details). - -If you want the container to be able to access other locations, -specify a bind path of your choice. For instance, to make the contents -of the '/data' folder on your computer available in the '/mnt' folder -inside the container, specify the mount point in the following way: - -singularity run --cleanenv --bind /data:/mnt container.simg \ - -b /batch/cat_standalone_segment.m \ - /mnt/T1.nii - - -EXAMPLES: - -USAGE: - cat_standalone.sh filename(s) [-s spm_standalone_folder] [-m mcr_folder] [-b batch_file] - [-a1 additional_argument1] [-a2 additional_argument2] - [-a add_to_batch] - - -s | --spm SPM12 folder of standalone version (can be also defined by SPMROOT) - -m | --mcr Matlab Compiler Runtime (MCR) folder (can be also defined by MCRROOT) - -b | --batch batch file to execute - -a1 | --arg1 1st additional argument (otherwise use defaults or batch) - -a2 | --arg2 2nd additional argument (otherwise use defaults or batch) - -a | --add add option to batch file - - The first occurrence of the parameter "" in the batch file will be replaced by the - list of input files. You can use the existing batch files in this folder or create your own batch - file with the SPM12 batch editor and leave the data field undefined. Please note that for creating - your own batch file CAT12 has to be called in expert mode because the CAT12 standalone installation - will only run in expert mode to allow more options. - See cat_standalone_segment.m for an example. - - You can also define one or two optional arguments to change other parameters that are indicated by - "" in the batch file. Please take care of the order of the "" fields in the - batch file! If no additional arguments are defined the default values are used. - Also, you must use multiple quotes if the argument is a string (e.g. " 'your_string' "). - - If you use a computer cluster it is recommended to use the batch files to only process one data set - and use a job or queue tool to call the (single) jobs on the cluster. - -PURPOSE: - Command line call of (CAT12) batch files for SPM12 standalone installation - -EXAMPLES - ----------------------------------------------------------------------------------------------- - Segmentation - -a1 TPM - -a2 Shooting template - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_segment.m sTRIO0001.nii - Preprocess (segment) the single file sTRIO0001.nii using the default CAT12 preprocessing batch. - SPM12 standalone version is located in $SPMROOT and Matlab Compiler Runtime in - /Applications/MATLAB/MATLAB_Runtime/v93. - - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_segment.m sTRIO000*.nii.gz \ - -a1 " '${cat12_dir}/templates_MNI152NLin2009cAsym/TPM_Age11.5.nii' " \ - -a2 " '${cat12_dir}/templates_MNI152NLin2009cAsym/Template_0_GS1mm.nii' " - Unzip and preprocess (segment) the files sTRIO0001.nii.gz using the default CAT12 preprocessing - batch, but use the children TPM provided with CAT12 and a 1mm Shooting template (not provided - with CAT12). Please note that zipped file can only be handled with this standalone batch and also - note the multiple quotes for parameter a1 and a2. - - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_segment.m sTRIO0001.nii \ - -a "matlabbatch{1}.spm.tools.cat.estwrite.output.surface = 0;" - Preprocess (segment) the single file sTRIO0001.nii using the default CAT12 preprocessing batch, - but skip surface estimation. - - ----------------------------------------------------------------------------------------------- - Longitudinal Segmentation - -a1 longitudinal model (0 - developmental; 1 - plasticity/learning; 2 - aging; 3 - save models 1 and 2) - -a2 TPM - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_segment_long.m sTRIO000*.nii \ - -a1 "2" - Preprocess (segment) the files sTRIO000*.nii with the longitudinal pipeline optimized for - detecting aging/developmental effects. In order to choose the longitudinal model optimized for - detecting small changes due to plasticity/learning change the a1 parameter to "1". - - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_segment_long.m sTRIO000*.nii \ - -a1 "1" -a2 " '${cat12_dir}/templates_MNI152NLin2009cAsym/TPM_Age11.5.nii' " - Preprocess (segment) the files sTRIO000*.nii with the longitudinal pipeline optimized for - detecting plasticity/learning effects and use the children TPM provided with CAT12. - Please note the multiple quotes for parameter a2. - - ----------------------------------------------------------------------------------------------- - Segmentation (Simple Mode) - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_simple.m sTRIO0001.nii - Process the single file sTRIO0001.nii using the simple processing batch. - - ----------------------------------------------------------------------------------------------- - Resample & Smooth Surfaces - -a1 smoothing filter size surface values - -a2 use 32k mesh from HCP (or 164k mesh from Freesurfer) - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_resample.m lh.thickness.sTRIO0001 \ - -a1 "12" -a2 "1" - Resample and smooth the single thickness file lh.thickness.sTRIO0001 with 12mm and save the - resampled mesh as 32k mesh (HCP conform mesh). Only the left surface file has to be defined. - The right hemisphere is processed automatically. - - ----------------------------------------------------------------------------------------------- - Smoothing - -a1 smoothing filter size - -a2 prepending string for smoothed file (e.g. 's6') - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_smooth.m sTRIO*nii \ - -a1 "[6 6 6]" -a2 " 's6' " - Smooth the volume files sTRIO*nii with 6mm and prepend the string "s6" to the smoothed files. - Please note the multiple quotes for parameter a2. - - ----------------------------------------------------------------------------------------------- - Dicom Import - -a1 directory structure - -a2 output directory - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_dicom2nii.m *.dcm \ - -a1 " 'patid_date' " -a2 "{'converted'}" - Import DICOM files *.dcm and save converted nifti files in directory "converted" with structure - ./// - Other options for directory structure are: - 'flat' No directory hierarchy - 'series' ./ - 'patid_date' ./// - 'patid' .// - 'date_time' .// - Please note the multiple quotes for parameter a1. - - ----------------------------------------------------------------------------------------------- - De-Facing - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_deface.m sTRIO*.nii - Apply de-facing to sTRIO*.nii and save the files prefixed by "anon_". - - ----------------------------------------------------------------------------------------------- - Estimate and Save Quality Measures for Volumes or Surfaces - -a1 csv output filename - -a2 enable global scaling with TIV (only for volumes meaningful) - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_get_quality.m mwp1sTRIO*nii \ - -a1 " 'Quality_measures.csv' " -a2 "1" - Estimate mean z-scores using global scaling with TIV for the files mwp1sTRIO*nii and save quality - measures in Quality_measures.csv for external analysis. Processing of surface meshes is also - supported. - Please note the multiple quotes for parameter a1. - - ----------------------------------------------------------------------------------------------- - Estimate mean/volume inside ROI - -a1 output-file string - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_get_ROI_values.m catROI_*.xml \ - -a1 " 'ROI' " - Save mean volume values in mL (e.g. GM volume) or the mean surface values (e.g. thickness) for - all data catROI_*.xml in a csv-file. The csv-file is named "ROI_" followed by the atlas name - and the name of the measure (e.g. Vgm). - Please note the multiple quotes for parameter a1. - - ----------------------------------------------------------------------------------------------- - TFCE Statistical Estimation - -a1 contrast number - -a2 number of permutations - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_tfce.m SPM.mat \ - -a1 "2" -a2 "20000" - Call estimation of TFCE statistics for the given SPM.mat file for contrast number 2 with 20000 - permutations. - - ----------------------------------------------------------------------------------------------- - Parallelization - ----------------------------------------------------------------------------------------------- - cat_parallelize.sh -p 8 -l /tmp \ - -c "cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 -b ${cwd}/cat_standalone_segment.m" sTRIO*.nii - Parallelize CAT12 preprocessing by splitting all sTRIO*.nii files into 8 jobs - (processes) and save log file in /tmp folder. - - The parameters SPMROOT and MCRROOT have to be defined (exported) to skip the use of the flags -s -m. - -INPUT: - nifti files or surface data - -OUTPUT: - processed images and optionally surfaces according to settings in cat_standalone_*.m - -USED FUNCTIONS: - cat_parallelize.sh - SPM12 standalone version (compiled) - CAT12 toolbox (compiled within SPM12 if installed) - MATLAB Compiler Runtime R2017b (Version 9.3) - -This script was written by Christian Gaser (christian.gaser@uni-jena.de). -This is ${version}. - - -Known issues: - -- Parallelization with cat_parallelize.sh is not implemented yet. -- Longitudinal segmentation with cat_standalone_segment_long.m - is not tested yet. - - -Contact information: - -Any problems or concerns regarding this container should be reported -to Malgorzata Wierzba (m.wierzba@fz-juelich.de), Michael Hanke -(m.hanke@fz-juelich.de) or Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) - - -Acknowledgements: - -The CAT toolbox (http://www.neuro.uni-jena.de/cat) is developed by -Christian Gaser and Robert Dahnke (Jena University Hospital, -Departments of Psychiatry and Neurology) and is free but copyright -software, distributed under the terms of the GNU General Public -Licence. - -The SPM software (https://www.fil.ion.ucl.ac.uk/spm/) is developed by -the Wellcome Trust Centre for Neuroimaging and is free but copyright -software, distributed under the terms of the GNU General Public -Licence. - -MATLAB Compiler Runtime -(https://uk.mathworks.com/products/compiler/matlab-runtime.html) is -developed by the The MathWorks, Inc. and is subject to the MATLAB -Runtime licence. From d85bcad8cc58f8a0e33ef8f0ab775ab835c40823 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 1 Aug 2024 08:16:13 +0200 Subject: [PATCH 07/13] fixes --- .github/workflows/apptainer.yml | 5 +++-- .github/workflows/docker.yml | 1 + .pre-commit-config.yaml | 3 --- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/apptainer.yml b/.github/workflows/apptainer.yml index ec691a0..49a08fb 100644 --- a/.github/workflows/apptainer.yml +++ b/.github/workflows/apptainer.yml @@ -14,7 +14,8 @@ jobs: build: strategy: matrix: - image: [Singularity_MCR, Singularity] + image: [Singularity_MCR.def, Singularity.def] + fail-fast: false runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -24,4 +25,4 @@ jobs: with: apptainer-version: 1.3.0 - name: build sif image - run: apptainer build cat12.sif ${{ matrix.image }} + run: apptainer build cat12.sif ${{ matrix.image }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 32e13a7..c0ff7cc 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,6 +16,7 @@ jobs: strategy: matrix: image: [dockerfile_MCR, Dockerfile] + fail-fast: false runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bd81012..6899e2d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,4 @@ --- -ci: - skip: [hadolint-docker] - repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 From a8c7ddbdb10f1a7f41e30f9cdbe4fe3c71d66a89 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 1 Aug 2024 08:19:29 +0200 Subject: [PATCH 08/13] do not use digest in singularity def --- Singularity.def | 203 +----------------------- Singularity_MCR.def | 376 +------------------------------------------- 2 files changed, 2 insertions(+), 577 deletions(-) mode change 100644 => 120000 Singularity.def mode change 100644 => 120000 Singularity_MCR.def diff --git a/Singularity.def b/Singularity.def deleted file mode 100644 index ba90012..0000000 --- a/Singularity.def +++ /dev/null @@ -1,202 +0,0 @@ -Bootstrap: docker -From: debian:bookworm-slim@sha256:5f7d5664eae4a192c2d2d6cb67fc3f3c7891a8722cd2903cc35aa649a12b0c8d - -%setup - mkdir -p ${SINGULARITY_ROOTFS}/batch - mkdir -p ${SINGULARITY_ROOTFS}/code - mkdir -p ${SINGULARITY_ROOTFS}/downloads - - install -m 755 ./code/* ${SINGULARITY_ROOTFS}/code - -%post - apt-get -qq update - apt-get --yes --quiet --no-install-recommends install \ - wget \ - unzip \ - libxext6 \ - libxt6 \ - moreutils \ - build-essential \ - curl \ - ca-certificates - DEBIAN_FRONTEND=noninteractive apt-get --yes --quiet install \ - octave \ - liboctave-dev - - mkdir /opt/spm12 - curl -fsSL --retry 5 https://github.com/spm/spm12/archive/r7771.tar.gz | tar -xzC /opt/spm12 --strip-components 1 - curl -fsSL --retry 5 https://raw.githubusercontent.com/spm/spm-octave/main/spm12_r7771.patch | patch -p0 - make -C /opt/spm12/src PLATFORM=octave distclean - make -C /opt/spm12/src PLATFORM=octave - make -C /opt/spm12/src PLATFORM=octave install - ln -s /opt/spm12/bin/spm12-octave /usr/local/bin/spm12 - - CATversion="r2560" - - cd /downloads - wget http://www.neuro.uni-jena.de/cat12/cat12_${CATversion}.zip && unzip -d /opt/spm12/toolbox/ cat12_${CATversion}.zip - rm -fr /downloads - - # install CAT standalone interface - STANDALONE="/opt/spm12/toolbox/cat12/standalone" - cd ${STANDALONE} && chmod +rx *.sh - cd /code && ln -s ${STANDALONE}/*.sh . - cd /batch && ln -s ${STANDALONE}/*.m . - - # set permissions - find /code -type f -print0 | xargs -0 chmod +r - - rm -f /opt/spm12/src/*.{mex,o,a} - apt-get --yes remove build-essential curl liboctave-dev - apt-get --yes autoremove - apt-get --yes clean - -%environment - export SPM_HOME=/opt/spm12 - -%runscript - exec /code/main "$@" - -%labels - Author fil.spm@ucl.ac.uk - Malgorzata Wierzba (m.wierzba@fz-juelich.de) - Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) - Version v1.1 - -%help - This is a container with SPM12, CAT12 and GNU Octave. - -This container allows to run the standalone version of the -Computational Anatomy Toolbox (CAT), which is an extension to SPM -software using Octave 7.3.0 - -The container runs Debian bookworm-slim and includes: - -- Octave (7.3.0) -- Standalone version of SPM software (SPM12, r7771) -- Computational Anatomy Toolbox (CAT12.9 ${CATversion}) -- CAT interface scripts (cat_standalone.sh, cat_parallelize.sh). - -For more details on the exact version of the software used in this -container, please refer to the README file. - - -HOW TO USE: - -In principle this container allows you to perform the very same types -of analysis that are possible with the standalone version of CAT. It -is assumed that the user is familiar with the content of the batch -files dedicated for the use with the standalone version of CAT -(cat_standalone_segment.m, cat_standalone_simple.m, -cat_standalone_resample.m, cat_standalone_smooth.m) and can modify -their content according to his/her needs. For more details, please -refer to the CAT12 documentation and manual. - - --- Available batch files -- - -The content of the batch files can be explored by using the 'view' and -'copy' subcommands: - -singularity run - -To view a batch file, use the 'view' subcommand: - -singularity run container.simg view cat_standalone_smooth.m - -To copy a batch file to your computer, use the 'copy' subcommand and -specify destination path as an additional argument: - -singularity run container.simg copy cat_standalone_smooth.m $HOME - -Make sure that the specified path is mounted to the container (more -information on this can be found below) and that you have write access -to this path! - -To copy all available batch files, use the 'all' argument: - -singularity run container.simg copy all $HOME - - --- Running CAT -- - -Run the CAT analysis with the following command: -singularity run --cleanenv - -To use a default batch file, use one of the files included in the -container ('/batch'): -singularity run --cleanenv container.simg \ - -b /batch/cat_standalone_segment.m \ - T1.nii - -To use your own, customised batch file, simply specify its path: -singularity run --cleanenv container.simg \ - -b $HOME/cat_standalone_segment.m \ - T1.nii - - --- Bind paths -- - -Please note that most of the host files remain inaccessible from within -the container. By default the following directories are mounted within -the container: '$HOME', '/tmp', '/proc', '/sys', '/dev', and '$PWD' -(see the Singularity documentation for more details). - -If you want the container to be able to access other locations, -specify a bind path of your choice. For instance, to make the contents -of the '/data' folder on your computer available in the '/mnt' folder -inside the container, specify the mount point in the following way: - -singularity run --cleanenv --bind /data:/mnt container.simg \ - -b /batch/cat_standalone_segment.m \ - /mnt/T1.nii - - -EXAMPLES: - -CAT12 segmentation batch: -singularity run --cleanenv container.simg \ - -b cat_standalone_segment.m \ - T1.nii - -CAT12 simple processing batch: -singularity run --cleanenv container.simg \ - -b cat_standalone_simple.m \ - T1.nii - -CAT12 resample & smooth batch: -singularity run --cleanenv container.simg \ - -b cat_standalone_resample.m \ - -a1 "12" -a2 "1" \ - lh.thickness.T1 - -CAT12 volume smoothing batch: -singularity run --cleanenv container.simg \ - -b cat_standalone_smooth.m \ - -a1 "[6 6 6]" -a2 "'s6'" \ - T1.nii - - - -Contact information: - -Any problems or concerns regarding this container should be reported -to Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) and regarding -CAT12 to Christian Gaser (christian.gaser@uni-jena.de) - - -Acknowledgements: - -The CAT toolbox (http://www.neuro.uni-jena.de/cat) is developed by -Christian Gaser and Robert Dahnke (Jena University Hospital, -Departments of Psychiatry and Neurology) and is free but copyright -software, distributed under the terms of the GNU General Public -Licence. - -The SPM software (https://www.fil.ion.ucl.ac.uk/spm/) is developed by -the Wellcome Trust Centre for Neuroimaging and is free but copyright -software, distributed under the terms of the GNU General Public -Licence (GPL). - -GNU Octave is a freely redistributable software under the terms of -the GPL as published by the Free Software Foundation. diff --git a/Singularity.def b/Singularity.def new file mode 120000 index 0000000..56b2a97 --- /dev/null +++ b/Singularity.def @@ -0,0 +1 @@ +.git/annex/objects/8Q/98/MD5E-s6255--ac5590f5bdfc1188a9692c0eea2b36e5.def/MD5E-s6255--ac5590f5bdfc1188a9692c0eea2b36e5.def \ No newline at end of file diff --git a/Singularity_MCR.def b/Singularity_MCR.def deleted file mode 100644 index c5b9182..0000000 --- a/Singularity_MCR.def +++ /dev/null @@ -1,375 +0,0 @@ -Bootstrap: docker -From: debian:buster-slim@sha256:5f7d5664eae4a192c2d2d6cb67fc3f3c7891a8722cd2903cc35aa649a12b0c8d - -%setup - mkdir -p ${SINGULARITY_ROOTFS}/batch - mkdir -p ${SINGULARITY_ROOTFS}/code - mkdir -p ${SINGULARITY_ROOTFS}/downloads - - install -m 755 ./code/* ${SINGULARITY_ROOTFS}/code - -%post - apt-get update - apt-get -y install wget unzip libxext6 libxt6 moreutils - - # download software & unzip - MCRURL="https://ssd.mathworks.com/supportfiles/downloads/R2017b/deployment_files/R2017b/installers/glnxa64/MCR_R2017b_glnxa64_installer.zip" - SPMURL="http://www.neuro.uni-jena.de/cat12/CAT12.8.1_r2042_R2017b_MCR_Linux.zip" - - cd /downloads - wget "${MCRURL}" && unzip -d /downloads/MCR MCR_R2017b_glnxa64_installer.zip - wget "${SPMURL}" && unzip -d /code/SPM CAT12.8.1_r2042_R2017b_MCR_Linux.zip - - # install MCR - /downloads/MCR/install -mode silent -agreeToLicense yes - - # generalize CAT12 version - mv /code/SPM/CAT12.8.1_r2042_R2017b_MCR_Linux/ /code/SPM/MCR_Linux/ - - # install SPM - /code/SPM/MCR_Linux/run_spm12.sh /usr/local/MATLAB/MATLAB_Runtime/v93 quit - cd /code/SPM/MCR_Linux && chmod +rx run_spm12.sh spm12.sh spm12 spm12.ctf - - # install CAT standalone interface - STANDALONE="/code/SPM/MCR_Linux/standalone" - cd ${STANDALONE} && chmod +rx *.sh - cd /code && ln -s ${STANDALONE}/*.sh . - cd /batch && ln -s ${STANDALONE}/*.m . - - # set permissions - find /code -type f -print0 | xargs -0 chmod +r - find /code/SPM/MCR_Linux/spm12_mcr/ -name 'CAT.glnx86' -print0 | xargs -0 chmod +rx -R - - rm -fr /downloads - - apt-get clean - apt-get autoremove - -%environment - export SPMROOT=/code/SPM/MCR_Linux - export MCRROOT=/usr/local/MATLAB/MATLAB_Runtime/v93 - export MCR_INHIBIT_CTF_LOCK=1 - -%runscript - exec /code/main "$@" - -%labels - Authors Malgorzata Wierzba (m.wierzba@fz-juelich.de) - Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) - Version 1.1 - -%help - -This container allows to run the standalone, compiled version of the -Computational Anatomy Toolbox (CAT), which is an extension to SPM -software. Using the container does not require the availability of a -MATLAB licence. - -The container includes: - -- MATLAB Compiler Runtime (R2017b, 9.3) -- Standalone version of SPM software (SPM12, r7771) -- Computational Anatomy Toolbox (CAT12.8 r2042) -- CAT interface scripts (cat_standalone.sh, cat_parallelize.sh). - -For more details on the exact version of the software used in this -container, please refer to the README file. - - -HOW TO USE: - -In principle this container allows you to perform the very same types -of analysis that are possible with the standalone version of CAT. It -is assumed that the user is familiar with the content of the batch -files dedicated for the use with the standalone version of CAT -(cat_standalone_segment.m, cat_standalone_simple.m, -cat_standalone_resample.m, cat_standalone_smooth.m) and can modify -their content according to his/her needs. For more details, please -refer to the CAT12 documentation and manual. - - --- Available batch files -- - -The content of the batch files can be explored by using the 'view' and -'copy' subcommands: - -singularity run - -To view a batch file, use the 'view' subcommand: - -singularity run container.simg view cat_standalone_smooth.m - -To copy a batch file to your computer, use the 'copy' subcommand and -specify destination path as an additional argument: - -singularity run container.simg copy cat_standalone_smooth.m $HOME - -Make sure that the specified path is mounted to the container (more -information on this can be found below) and that you have write access -to this path! - -To copy all available batch files, use the 'all' argument: - -singularity run container.simg copy all $HOME - - --- Running CAT -- - -Run the CAT analysis with the following command: -singularity run --cleanenv - -To use a default batch file, use one of the files included in the -container ('/batch'): -singularity run --cleanenv container.simg \ - -b /batch/cat_standalone_segment.m \ - T1.nii - -To use your own, customised batch file, simply specify its path: -singularity run --cleanenv container.simg \ - -b $HOME/cat_standalone_segment.m \ - T1.nii - - --- Bind paths -- - -Please note that most of the host files remain inaccessible from within -the container. By default the following directories are mounted within -the container: '$HOME', '/tmp', '/proc', '/sys', '/dev', and '$PWD' -(see the Singularity documentation for more details). - -If you want the container to be able to access other locations, -specify a bind path of your choice. For instance, to make the contents -of the '/data' folder on your computer available in the '/mnt' folder -inside the container, specify the mount point in the following way: - -singularity run --cleanenv --bind /data:/mnt container.simg \ - -b /batch/cat_standalone_segment.m \ - /mnt/T1.nii - - -EXAMPLES: - -USAGE: - cat_standalone.sh filename(s) [-s spm_standalone_folder] [-m mcr_folder] [-b batch_file] - [-a1 additional_argument1] [-a2 additional_argument2] - [-a add_to_batch] - - -s | --spm SPM12 folder of standalone version (can be also defined by SPMROOT) - -m | --mcr Matlab Compiler Runtime (MCR) folder (can be also defined by MCRROOT) - -b | --batch batch file to execute - -a1 | --arg1 1st additional argument (otherwise use defaults or batch) - -a2 | --arg2 2nd additional argument (otherwise use defaults or batch) - -a | --add add option to batch file - - The first occurrence of the parameter "" in the batch file will be replaced by the - list of input files. You can use the existing batch files in this folder or create your own batch - file with the SPM12 batch editor and leave the data field undefined. Please note that for creating - your own batch file CAT12 has to be called in expert mode because the CAT12 standalone installation - will only run in expert mode to allow more options. - See cat_standalone_segment.m for an example. - - You can also define one or two optional arguments to change other parameters that are indicated by - "" in the batch file. Please take care of the order of the "" fields in the - batch file! If no additional arguments are defined the default values are used. - Also, you must use multiple quotes if the argument is a string (e.g. " 'your_string' "). - - If you use a computer cluster it is recommended to use the batch files to only process one data set - and use a job or queue tool to call the (single) jobs on the cluster. - -PURPOSE: - Command line call of (CAT12) batch files for SPM12 standalone installation - -EXAMPLES - ----------------------------------------------------------------------------------------------- - Segmentation - -a1 TPM - -a2 Shooting template - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_segment.m sTRIO0001.nii - Preprocess (segment) the single file sTRIO0001.nii using the default CAT12 preprocessing batch. - SPM12 standalone version is located in $SPMROOT and Matlab Compiler Runtime in - /Applications/MATLAB/MATLAB_Runtime/v93. - - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_segment.m sTRIO000*.nii.gz \ - -a1 " '${cat12_dir}/templates_MNI152NLin2009cAsym/TPM_Age11.5.nii' " \ - -a2 " '${cat12_dir}/templates_MNI152NLin2009cAsym/Template_0_GS1mm.nii' " - Unzip and preprocess (segment) the files sTRIO0001.nii.gz using the default CAT12 preprocessing - batch, but use the children TPM provided with CAT12 and a 1mm Shooting template (not provided - with CAT12). Please note that zipped file can only be handled with this standalone batch and also - note the multiple quotes for parameter a1 and a2. - - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_segment.m sTRIO0001.nii \ - -a "matlabbatch{1}.spm.tools.cat.estwrite.output.surface = 0;" - Preprocess (segment) the single file sTRIO0001.nii using the default CAT12 preprocessing batch, - but skip surface estimation. - - ----------------------------------------------------------------------------------------------- - Longitudinal Segmentation - -a1 longitudinal model (0 - developmental; 1 - plasticity/learning; 2 - aging; 3 - save models 1 and 2) - -a2 TPM - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_segment_long.m sTRIO000*.nii \ - -a1 "2" - Preprocess (segment) the files sTRIO000*.nii with the longitudinal pipeline optimized for - detecting aging/developmental effects. In order to choose the longitudinal model optimized for - detecting small changes due to plasticity/learning change the a1 parameter to "1". - - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_segment_long.m sTRIO000*.nii \ - -a1 "1" -a2 " '${cat12_dir}/templates_MNI152NLin2009cAsym/TPM_Age11.5.nii' " - Preprocess (segment) the files sTRIO000*.nii with the longitudinal pipeline optimized for - detecting plasticity/learning effects and use the children TPM provided with CAT12. - Please note the multiple quotes for parameter a2. - - ----------------------------------------------------------------------------------------------- - Segmentation (Simple Mode) - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_simple.m sTRIO0001.nii - Process the single file sTRIO0001.nii using the simple processing batch. - - ----------------------------------------------------------------------------------------------- - Resample & Smooth Surfaces - -a1 smoothing filter size surface values - -a2 use 32k mesh from HCP (or 164k mesh from Freesurfer) - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_resample.m lh.thickness.sTRIO0001 \ - -a1 "12" -a2 "1" - Resample and smooth the single thickness file lh.thickness.sTRIO0001 with 12mm and save the - resampled mesh as 32k mesh (HCP conform mesh). Only the left surface file has to be defined. - The right hemisphere is processed automatically. - - ----------------------------------------------------------------------------------------------- - Smoothing - -a1 smoothing filter size - -a2 prepending string for smoothed file (e.g. 's6') - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_smooth.m sTRIO*nii \ - -a1 "[6 6 6]" -a2 " 's6' " - Smooth the volume files sTRIO*nii with 6mm and prepend the string "s6" to the smoothed files. - Please note the multiple quotes for parameter a2. - - ----------------------------------------------------------------------------------------------- - Dicom Import - -a1 directory structure - -a2 output directory - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_dicom2nii.m *.dcm \ - -a1 " 'patid_date' " -a2 "{'converted'}" - Import DICOM files *.dcm and save converted nifti files in directory "converted" with structure - ./// - Other options for directory structure are: - 'flat' No directory hierarchy - 'series' ./ - 'patid_date' ./// - 'patid' .// - 'date_time' .// - Please note the multiple quotes for parameter a1. - - ----------------------------------------------------------------------------------------------- - De-Facing - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_deface.m sTRIO*.nii - Apply de-facing to sTRIO*.nii and save the files prefixed by "anon_". - - ----------------------------------------------------------------------------------------------- - Estimate and Save Quality Measures for Volumes or Surfaces - -a1 csv output filename - -a2 enable global scaling with TIV (only for volumes meaningful) - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_get_quality.m mwp1sTRIO*nii \ - -a1 " 'Quality_measures.csv' " -a2 "1" - Estimate mean z-scores using global scaling with TIV for the files mwp1sTRIO*nii and save quality - measures in Quality_measures.csv for external analysis. Processing of surface meshes is also - supported. - Please note the multiple quotes for parameter a1. - - ----------------------------------------------------------------------------------------------- - Estimate mean/volume inside ROI - -a1 output-file string - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_get_ROI_values.m catROI_*.xml \ - -a1 " 'ROI' " - Save mean volume values in mL (e.g. GM volume) or the mean surface values (e.g. thickness) for - all data catROI_*.xml in a csv-file. The csv-file is named "ROI_" followed by the atlas name - and the name of the measure (e.g. Vgm). - Please note the multiple quotes for parameter a1. - - ----------------------------------------------------------------------------------------------- - TFCE Statistical Estimation - -a1 contrast number - -a2 number of permutations - ----------------------------------------------------------------------------------------------- - cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ - -b ${cwd}/cat_standalone_tfce.m SPM.mat \ - -a1 "2" -a2 "20000" - Call estimation of TFCE statistics for the given SPM.mat file for contrast number 2 with 20000 - permutations. - - ----------------------------------------------------------------------------------------------- - Parallelization - ----------------------------------------------------------------------------------------------- - cat_parallelize.sh -p 8 -l /tmp \ - -c "cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 -b ${cwd}/cat_standalone_segment.m" sTRIO*.nii - Parallelize CAT12 preprocessing by splitting all sTRIO*.nii files into 8 jobs - (processes) and save log file in /tmp folder. - - The parameters SPMROOT and MCRROOT have to be defined (exported) to skip the use of the flags -s -m. - -INPUT: - nifti files or surface data - -OUTPUT: - processed images and optionally surfaces according to settings in cat_standalone_*.m - -USED FUNCTIONS: - cat_parallelize.sh - SPM12 standalone version (compiled) - CAT12 toolbox (compiled within SPM12 if installed) - MATLAB Compiler Runtime R2017b (Version 9.3) - -This script was written by Christian Gaser (christian.gaser@uni-jena.de). -This is ${version}. - - -Known issues: - -- Parallelization with cat_parallelize.sh is not implemented yet. -- Longitudinal segmentation with cat_standalone_segment_long.m - is not tested yet. - - -Contact information: - -Any problems or concerns regarding this container should be reported -to Malgorzata Wierzba (m.wierzba@fz-juelich.de), Michael Hanke -(m.hanke@fz-juelich.de) or Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) - - -Acknowledgements: - -The CAT toolbox (http://www.neuro.uni-jena.de/cat) is developed by -Christian Gaser and Robert Dahnke (Jena University Hospital, -Departments of Psychiatry and Neurology) and is free but copyright -software, distributed under the terms of the GNU General Public -Licence. - -The SPM software (https://www.fil.ion.ucl.ac.uk/spm/) is developed by -the Wellcome Trust Centre for Neuroimaging and is free but copyright -software, distributed under the terms of the GNU General Public -Licence. - -MATLAB Compiler Runtime -(https://uk.mathworks.com/products/compiler/matlab-runtime.html) is -developed by the The MathWorks, Inc. and is subject to the MATLAB -Runtime licence. diff --git a/Singularity_MCR.def b/Singularity_MCR.def new file mode 120000 index 0000000..44c89d7 --- /dev/null +++ b/Singularity_MCR.def @@ -0,0 +1 @@ +.git/annex/objects/2v/V7/MD5E-s16982--97fcbeaf066ad61012381ffe82b98551.def/MD5E-s16982--97fcbeaf066ad61012381ffe82b98551.def \ No newline at end of file From 92912714c00b1cb39c51361b27eae1c13b1d2d81 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 1 Aug 2024 11:57:20 +0200 Subject: [PATCH 09/13] typo --- .gitattributes | 3 +- .github/workflows/docker.yml | 29 +------------ .gitignore | 3 ++ Dockerfile_1 | 84 ++++++++++++++++++++++++++++++++++++ Singularity.def | 2 +- Singularity_MCR.def | 2 +- code/main | 14 +++--- makefile | 5 +++ 8 files changed, 102 insertions(+), 40 deletions(-) create mode 100644 Dockerfile_1 mode change 120000 => 100644 Singularity.def mode change 120000 => 100644 Singularity_MCR.def create mode 100644 makefile diff --git a/.gitattributes b/.gitattributes index 79223c1..9427c04 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,4 +2,5 @@ **/.git* annex.largefiles=nothing CHANGELOG.md annex.largefiles=nothing README.md annex.largefiles=nothing -.github annex.largefiles=nothing +.github/**/*.yml annex.largefiles=nothing +*.def annex.largefiles=nothing diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c0ff7cc..a52cacc 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,28 +1 @@ ---- -name: docker build - -on: - push: - branches: [master] - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - - build: - strategy: - matrix: - image: [dockerfile_MCR, Dockerfile] - fail-fast: false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Build the Docker image - run: | - docker build . --file ${{ matrix.image }} --tag cat12 - docker images +/annex/objects/MD5E-s908--d79893dc28bfcb54aa92dd21c567641a.yml 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/Singularity.def b/Singularity.def deleted file mode 120000 index 56b2a97..0000000 --- a/Singularity.def +++ /dev/null @@ -1 +0,0 @@ -.git/annex/objects/8Q/98/MD5E-s6255--ac5590f5bdfc1188a9692c0eea2b36e5.def/MD5E-s6255--ac5590f5bdfc1188a9692c0eea2b36e5.def \ No newline at end of file diff --git a/Singularity.def b/Singularity.def new file mode 100644 index 0000000..f3c6887 --- /dev/null +++ b/Singularity.def @@ -0,0 +1 @@ +/annex/objects/MD5E-s6255--ac5590f5bdfc1188a9692c0eea2b36e5.def diff --git a/Singularity_MCR.def b/Singularity_MCR.def deleted file mode 120000 index 44c89d7..0000000 --- a/Singularity_MCR.def +++ /dev/null @@ -1 +0,0 @@ -.git/annex/objects/2v/V7/MD5E-s16982--97fcbeaf066ad61012381ffe82b98551.def/MD5E-s16982--97fcbeaf066ad61012381ffe82b98551.def \ No newline at end of file diff --git a/Singularity_MCR.def b/Singularity_MCR.def new file mode 100644 index 0000000..595cb09 --- /dev/null +++ b/Singularity_MCR.def @@ -0,0 +1 @@ +/annex/objects/MD5E-s16982--97fcbeaf066ad61012381ffe82b98551.def 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 From 53b3631f27c5eba2089a452305a3317c5f16bfee Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 1 Aug 2024 12:01:13 +0200 Subject: [PATCH 10/13] unannex --- .github/workflows/docker.yml | 35 +++- Singularity.def | 203 ++++++++++++++++++- Singularity_MCR.def | 376 ++++++++++++++++++++++++++++++++++- 3 files changed, 611 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a52cacc..ba24487 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1 +1,34 @@ -/annex/objects/MD5E-s908--d79893dc28bfcb54aa92dd21c567641a.yml +--- +name: docker build + +on: + push: + branches: [master] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + build: + strategy: + matrix: + 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/Singularity.def b/Singularity.def index f3c6887..f4db1da 100644 --- a/Singularity.def +++ b/Singularity.def @@ -1 +1,202 @@ -/annex/objects/MD5E-s6255--ac5590f5bdfc1188a9692c0eea2b36e5.def +Bootstrap: docker +From: debian:bookworm-slim + +%setup + mkdir -p ${SINGULARITY_ROOTFS}/batch + mkdir -p ${SINGULARITY_ROOTFS}/code + mkdir -p ${SINGULARITY_ROOTFS}/downloads + + install -m 755 ./code/* ${SINGULARITY_ROOTFS}/code + +%post + apt-get -qq update + apt-get --yes --quiet --no-install-recommends install \ + wget \ + unzip \ + libxext6 \ + libxt6 \ + moreutils \ + build-essential \ + curl \ + ca-certificates + DEBIAN_FRONTEND=noninteractive apt-get --yes --quiet install \ + octave \ + liboctave-dev + + mkdir /opt/spm12 + curl -fsSL --retry 5 https://github.com/spm/spm12/archive/r7771.tar.gz | tar -xzC /opt/spm12 --strip-components 1 + curl -fsSL --retry 5 https://raw.githubusercontent.com/spm/spm-octave/main/spm12_r7771.patch | patch -p0 + make -C /opt/spm12/src PLATFORM=octave distclean + make -C /opt/spm12/src PLATFORM=octave + make -C /opt/spm12/src PLATFORM=octave install + ln -s /opt/spm12/bin/spm12-octave /usr/local/bin/spm12 + + CATversion="r2560" + + cd /downloads + wget http://www.neuro.uni-jena.de/cat12/cat12_${CATversion}.zip && unzip -d /opt/spm12/toolbox/ cat12_${CATversion}.zip + rm -fr /downloads + + # install CAT standalone interface + STANDALONE="/opt/spm12/toolbox/cat12/standalone" + cd ${STANDALONE} && chmod +rx *.sh + cd /code && ln -s ${STANDALONE}/*.sh . + cd /batch && ln -s ${STANDALONE}/*.m . + + # set permissions + find /code -type f -print0 | xargs -0 chmod +r + + rm -f /opt/spm12/src/*.{mex,o,a} + apt-get --yes remove build-essential curl liboctave-dev + apt-get --yes autoremove + apt-get --yes clean + +%environment + export SPM_HOME=/opt/spm12 + +%runscript + exec /code/main "$@" + +%labels + Author fil.spm@ucl.ac.uk + Malgorzata Wierzba (m.wierzba@fz-juelich.de) + Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) + Version v1.1 + +%help + This is a container with SPM12, CAT12 and GNU Octave. + +This container allows to run the standalone version of the +Computational Anatomy Toolbox (CAT), which is an extension to SPM +software using Octave 7.3.0 + +The container runs Debian bookworm-slim and includes: + +- Octave (7.3.0) +- Standalone version of SPM software (SPM12, r7771) +- Computational Anatomy Toolbox (CAT12.9 ${CATversion}) +- CAT interface scripts (cat_standalone.sh, cat_parallelize.sh). + +For more details on the exact version of the software used in this +container, please refer to the README file. + + +HOW TO USE: + +In principle this container allows you to perform the very same types +of analysis that are possible with the standalone version of CAT. It +is assumed that the user is familiar with the content of the batch +files dedicated for the use with the standalone version of CAT +(cat_standalone_segment.m, cat_standalone_simple.m, +cat_standalone_resample.m, cat_standalone_smooth.m) and can modify +their content according to his/her needs. For more details, please +refer to the CAT12 documentation and manual. + + +-- Available batch files -- + +The content of the batch files can be explored by using the 'view' and +'copy' subcommands: + +singularity run + +To view a batch file, use the 'view' subcommand: + +singularity run container.simg view cat_standalone_smooth.m + +To copy a batch file to your computer, use the 'copy' subcommand and +specify destination path as an additional argument: + +singularity run container.simg copy cat_standalone_smooth.m $HOME + +Make sure that the specified path is mounted to the container (more +information on this can be found below) and that you have write access +to this path! + +To copy all available batch files, use the 'all' argument: + +singularity run container.simg copy all $HOME + + +-- Running CAT -- + +Run the CAT analysis with the following command: +singularity run --cleanenv + +To use a default batch file, use one of the files included in the +container ('/batch'): +singularity run --cleanenv container.simg \ + -b /batch/cat_standalone_segment.m \ + T1.nii + +To use your own, customised batch file, simply specify its path: +singularity run --cleanenv container.simg \ + -b $HOME/cat_standalone_segment.m \ + T1.nii + + +-- Bind paths -- + +Please note that most of the host files remain inaccessible from within +the container. By default the following directories are mounted within +the container: '$HOME', '/tmp', '/proc', '/sys', '/dev', and '$PWD' +(see the Singularity documentation for more details). + +If you want the container to be able to access other locations, +specify a bind path of your choice. For instance, to make the contents +of the '/data' folder on your computer available in the '/mnt' folder +inside the container, specify the mount point in the following way: + +singularity run --cleanenv --bind /data:/mnt container.simg \ + -b /batch/cat_standalone_segment.m \ + /mnt/T1.nii + + +EXAMPLES: + +CAT12 segmentation batch: +singularity run --cleanenv container.simg \ + -b cat_standalone_segment.m \ + T1.nii + +CAT12 simple processing batch: +singularity run --cleanenv container.simg \ + -b cat_standalone_simple.m \ + T1.nii + +CAT12 resample & smooth batch: +singularity run --cleanenv container.simg \ + -b cat_standalone_resample.m \ + -a1 "12" -a2 "1" \ + lh.thickness.T1 + +CAT12 volume smoothing batch: +singularity run --cleanenv container.simg \ + -b cat_standalone_smooth.m \ + -a1 "[6 6 6]" -a2 "'s6'" \ + T1.nii + + + +Contact information: + +Any problems or concerns regarding this container should be reported +to Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) and regarding +CAT12 to Christian Gaser (christian.gaser@uni-jena.de) + + +Acknowledgements: + +The CAT toolbox (http://www.neuro.uni-jena.de/cat) is developed by +Christian Gaser and Robert Dahnke (Jena University Hospital, +Departments of Psychiatry and Neurology) and is free but copyright +software, distributed under the terms of the GNU General Public +Licence. + +The SPM software (https://www.fil.ion.ucl.ac.uk/spm/) is developed by +the Wellcome Trust Centre for Neuroimaging and is free but copyright +software, distributed under the terms of the GNU General Public +Licence (GPL). + +GNU Octave is a freely redistributable software under the terms of +the GPL as published by the Free Software Foundation. diff --git a/Singularity_MCR.def b/Singularity_MCR.def index 595cb09..0799a47 100644 --- a/Singularity_MCR.def +++ b/Singularity_MCR.def @@ -1 +1,375 @@ -/annex/objects/MD5E-s16982--97fcbeaf066ad61012381ffe82b98551.def +Bootstrap: docker +From: debian:buster-slim + +%setup + mkdir -p ${SINGULARITY_ROOTFS}/batch + mkdir -p ${SINGULARITY_ROOTFS}/code + mkdir -p ${SINGULARITY_ROOTFS}/downloads + + install -m 755 ./code/* ${SINGULARITY_ROOTFS}/code + +%post + apt-get update + apt-get -y install wget unzip libxext6 libxt6 moreutils + + # download software & unzip + MCRURL="https://ssd.mathworks.com/supportfiles/downloads/R2017b/deployment_files/R2017b/installers/glnxa64/MCR_R2017b_glnxa64_installer.zip" + SPMURL="http://www.neuro.uni-jena.de/cat12/CAT12.8.1_r2042_R2017b_MCR_Linux.zip" + + cd /downloads + wget "${MCRURL}" && unzip -d /downloads/MCR MCR_R2017b_glnxa64_installer.zip + wget "${SPMURL}" && unzip -d /code/SPM CAT12.8.1_r2042_R2017b_MCR_Linux.zip + + # install MCR + /downloads/MCR/install -mode silent -agreeToLicense yes + + # generalize CAT12 version + mv /code/SPM/CAT12.8.1_r2042_R2017b_MCR_Linux/ /code/SPM/MCR_Linux/ + + # install SPM + /code/SPM/MCR_Linux/run_spm12.sh /usr/local/MATLAB/MATLAB_Runtime/v93 quit + cd /code/SPM/MCR_Linux && chmod +rx run_spm12.sh spm12.sh spm12 spm12.ctf + + # install CAT standalone interface + STANDALONE="/code/SPM/MCR_Linux/standalone" + cd ${STANDALONE} && chmod +rx *.sh + cd /code && ln -s ${STANDALONE}/*.sh . + cd /batch && ln -s ${STANDALONE}/*.m . + + # set permissions + find /code -type f -print0 | xargs -0 chmod +r + find /code/SPM/MCR_Linux/spm12_mcr/ -name 'CAT.glnx86' -print0 | xargs -0 chmod +rx -R + + rm -fr /downloads + + apt-get clean + apt-get autoremove + +%environment + export SPMROOT=/code/SPM/MCR_Linux + export MCRROOT=/usr/local/MATLAB/MATLAB_Runtime/v93 + export MCR_INHIBIT_CTF_LOCK=1 + +%runscript + exec /code/main "$@" + +%labels + Authors Malgorzata Wierzba (m.wierzba@fz-juelich.de) + Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) + Version 1.1 + +%help + +This container allows to run the standalone, compiled version of the +Computational Anatomy Toolbox (CAT), which is an extension to SPM +software. Using the container does not require the availability of a +MATLAB licence. + +The container includes: + +- MATLAB Compiler Runtime (R2017b, 9.3) +- Standalone version of SPM software (SPM12, r7771) +- Computational Anatomy Toolbox (CAT12.8 r2042) +- CAT interface scripts (cat_standalone.sh, cat_parallelize.sh). + +For more details on the exact version of the software used in this +container, please refer to the README file. + + +HOW TO USE: + +In principle this container allows you to perform the very same types +of analysis that are possible with the standalone version of CAT. It +is assumed that the user is familiar with the content of the batch +files dedicated for the use with the standalone version of CAT +(cat_standalone_segment.m, cat_standalone_simple.m, +cat_standalone_resample.m, cat_standalone_smooth.m) and can modify +their content according to his/her needs. For more details, please +refer to the CAT12 documentation and manual. + + +-- Available batch files -- + +The content of the batch files can be explored by using the 'view' and +'copy' subcommands: + +singularity run + +To view a batch file, use the 'view' subcommand: + +singularity run container.simg view cat_standalone_smooth.m + +To copy a batch file to your computer, use the 'copy' subcommand and +specify destination path as an additional argument: + +singularity run container.simg copy cat_standalone_smooth.m $HOME + +Make sure that the specified path is mounted to the container (more +information on this can be found below) and that you have write access +to this path! + +To copy all available batch files, use the 'all' argument: + +singularity run container.simg copy all $HOME + + +-- Running CAT -- + +Run the CAT analysis with the following command: +singularity run --cleanenv + +To use a default batch file, use one of the files included in the +container ('/batch'): +singularity run --cleanenv container.simg \ + -b /batch/cat_standalone_segment.m \ + T1.nii + +To use your own, customised batch file, simply specify its path: +singularity run --cleanenv container.simg \ + -b $HOME/cat_standalone_segment.m \ + T1.nii + + +-- Bind paths -- + +Please note that most of the host files remain inaccessible from within +the container. By default the following directories are mounted within +the container: '$HOME', '/tmp', '/proc', '/sys', '/dev', and '$PWD' +(see the Singularity documentation for more details). + +If you want the container to be able to access other locations, +specify a bind path of your choice. For instance, to make the contents +of the '/data' folder on your computer available in the '/mnt' folder +inside the container, specify the mount point in the following way: + +singularity run --cleanenv --bind /data:/mnt container.simg \ + -b /batch/cat_standalone_segment.m \ + /mnt/T1.nii + + +EXAMPLES: + +USAGE: + cat_standalone.sh filename(s) [-s spm_standalone_folder] [-m mcr_folder] [-b batch_file] + [-a1 additional_argument1] [-a2 additional_argument2] + [-a add_to_batch] + + -s | --spm SPM12 folder of standalone version (can be also defined by SPMROOT) + -m | --mcr Matlab Compiler Runtime (MCR) folder (can be also defined by MCRROOT) + -b | --batch batch file to execute + -a1 | --arg1 1st additional argument (otherwise use defaults or batch) + -a2 | --arg2 2nd additional argument (otherwise use defaults or batch) + -a | --add add option to batch file + + The first occurrence of the parameter "" in the batch file will be replaced by the + list of input files. You can use the existing batch files in this folder or create your own batch + file with the SPM12 batch editor and leave the data field undefined. Please note that for creating + your own batch file CAT12 has to be called in expert mode because the CAT12 standalone installation + will only run in expert mode to allow more options. + See cat_standalone_segment.m for an example. + + You can also define one or two optional arguments to change other parameters that are indicated by + "" in the batch file. Please take care of the order of the "" fields in the + batch file! If no additional arguments are defined the default values are used. + Also, you must use multiple quotes if the argument is a string (e.g. " 'your_string' "). + + If you use a computer cluster it is recommended to use the batch files to only process one data set + and use a job or queue tool to call the (single) jobs on the cluster. + +PURPOSE: + Command line call of (CAT12) batch files for SPM12 standalone installation + +EXAMPLES + ----------------------------------------------------------------------------------------------- + Segmentation + -a1 TPM + -a2 Shooting template + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_segment.m sTRIO0001.nii + Preprocess (segment) the single file sTRIO0001.nii using the default CAT12 preprocessing batch. + SPM12 standalone version is located in $SPMROOT and Matlab Compiler Runtime in + /Applications/MATLAB/MATLAB_Runtime/v93. + + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_segment.m sTRIO000*.nii.gz \ + -a1 " '${cat12_dir}/templates_MNI152NLin2009cAsym/TPM_Age11.5.nii' " \ + -a2 " '${cat12_dir}/templates_MNI152NLin2009cAsym/Template_0_GS1mm.nii' " + Unzip and preprocess (segment) the files sTRIO0001.nii.gz using the default CAT12 preprocessing + batch, but use the children TPM provided with CAT12 and a 1mm Shooting template (not provided + with CAT12). Please note that zipped file can only be handled with this standalone batch and also + note the multiple quotes for parameter a1 and a2. + + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_segment.m sTRIO0001.nii \ + -a "matlabbatch{1}.spm.tools.cat.estwrite.output.surface = 0;" + Preprocess (segment) the single file sTRIO0001.nii using the default CAT12 preprocessing batch, + but skip surface estimation. + + ----------------------------------------------------------------------------------------------- + Longitudinal Segmentation + -a1 longitudinal model (0 - developmental; 1 - plasticity/learning; 2 - aging; 3 - save models 1 and 2) + -a2 TPM + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_segment_long.m sTRIO000*.nii \ + -a1 "2" + Preprocess (segment) the files sTRIO000*.nii with the longitudinal pipeline optimized for + detecting aging/developmental effects. In order to choose the longitudinal model optimized for + detecting small changes due to plasticity/learning change the a1 parameter to "1". + + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_segment_long.m sTRIO000*.nii \ + -a1 "1" -a2 " '${cat12_dir}/templates_MNI152NLin2009cAsym/TPM_Age11.5.nii' " + Preprocess (segment) the files sTRIO000*.nii with the longitudinal pipeline optimized for + detecting plasticity/learning effects and use the children TPM provided with CAT12. + Please note the multiple quotes for parameter a2. + + ----------------------------------------------------------------------------------------------- + Segmentation (Simple Mode) + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_simple.m sTRIO0001.nii + Process the single file sTRIO0001.nii using the simple processing batch. + + ----------------------------------------------------------------------------------------------- + Resample & Smooth Surfaces + -a1 smoothing filter size surface values + -a2 use 32k mesh from HCP (or 164k mesh from Freesurfer) + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_resample.m lh.thickness.sTRIO0001 \ + -a1 "12" -a2 "1" + Resample and smooth the single thickness file lh.thickness.sTRIO0001 with 12mm and save the + resampled mesh as 32k mesh (HCP conform mesh). Only the left surface file has to be defined. + The right hemisphere is processed automatically. + + ----------------------------------------------------------------------------------------------- + Smoothing + -a1 smoothing filter size + -a2 prepending string for smoothed file (e.g. 's6') + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_smooth.m sTRIO*nii \ + -a1 "[6 6 6]" -a2 " 's6' " + Smooth the volume files sTRIO*nii with 6mm and prepend the string "s6" to the smoothed files. + Please note the multiple quotes for parameter a2. + + ----------------------------------------------------------------------------------------------- + Dicom Import + -a1 directory structure + -a2 output directory + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_dicom2nii.m *.dcm \ + -a1 " 'patid_date' " -a2 "{'converted'}" + Import DICOM files *.dcm and save converted nifti files in directory "converted" with structure + ./// + Other options for directory structure are: + 'flat' No directory hierarchy + 'series' ./ + 'patid_date' ./// + 'patid' .// + 'date_time' .// + Please note the multiple quotes for parameter a1. + + ----------------------------------------------------------------------------------------------- + De-Facing + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_deface.m sTRIO*.nii + Apply de-facing to sTRIO*.nii and save the files prefixed by "anon_". + + ----------------------------------------------------------------------------------------------- + Estimate and Save Quality Measures for Volumes or Surfaces + -a1 csv output filename + -a2 enable global scaling with TIV (only for volumes meaningful) + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_get_quality.m mwp1sTRIO*nii \ + -a1 " 'Quality_measures.csv' " -a2 "1" + Estimate mean z-scores using global scaling with TIV for the files mwp1sTRIO*nii and save quality + measures in Quality_measures.csv for external analysis. Processing of surface meshes is also + supported. + Please note the multiple quotes for parameter a1. + + ----------------------------------------------------------------------------------------------- + Estimate mean/volume inside ROI + -a1 output-file string + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_get_ROI_values.m catROI_*.xml \ + -a1 " 'ROI' " + Save mean volume values in mL (e.g. GM volume) or the mean surface values (e.g. thickness) for + all data catROI_*.xml in a csv-file. The csv-file is named "ROI_" followed by the atlas name + and the name of the measure (e.g. Vgm). + Please note the multiple quotes for parameter a1. + + ----------------------------------------------------------------------------------------------- + TFCE Statistical Estimation + -a1 contrast number + -a2 number of permutations + ----------------------------------------------------------------------------------------------- + cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 \ + -b ${cwd}/cat_standalone_tfce.m SPM.mat \ + -a1 "2" -a2 "20000" + Call estimation of TFCE statistics for the given SPM.mat file for contrast number 2 with 20000 + permutations. + + ----------------------------------------------------------------------------------------------- + Parallelization + ----------------------------------------------------------------------------------------------- + cat_parallelize.sh -p 8 -l /tmp \ + -c "cat_standalone.sh -s $SPMROOT -m /Applications/MATLAB/MATLAB_Runtime/v93 -b ${cwd}/cat_standalone_segment.m" sTRIO*.nii + Parallelize CAT12 preprocessing by splitting all sTRIO*.nii files into 8 jobs + (processes) and save log file in /tmp folder. + + The parameters SPMROOT and MCRROOT have to be defined (exported) to skip the use of the flags -s -m. + +INPUT: + nifti files or surface data + +OUTPUT: + processed images and optionally surfaces according to settings in cat_standalone_*.m + +USED FUNCTIONS: + cat_parallelize.sh + SPM12 standalone version (compiled) + CAT12 toolbox (compiled within SPM12 if installed) + MATLAB Compiler Runtime R2017b (Version 9.3) + +This script was written by Christian Gaser (christian.gaser@uni-jena.de). +This is ${version}. + + +Known issues: + +- Parallelization with cat_parallelize.sh is not implemented yet. +- Longitudinal segmentation with cat_standalone_segment_long.m + is not tested yet. + + +Contact information: + +Any problems or concerns regarding this container should be reported +to Malgorzata Wierzba (m.wierzba@fz-juelich.de), Michael Hanke +(m.hanke@fz-juelich.de) or Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de) + + +Acknowledgements: + +The CAT toolbox (http://www.neuro.uni-jena.de/cat) is developed by +Christian Gaser and Robert Dahnke (Jena University Hospital, +Departments of Psychiatry and Neurology) and is free but copyright +software, distributed under the terms of the GNU General Public +Licence. + +The SPM software (https://www.fil.ion.ucl.ac.uk/spm/) is developed by +the Wellcome Trust Centre for Neuroimaging and is free but copyright +software, distributed under the terms of the GNU General Public +Licence. + +MATLAB Compiler Runtime +(https://uk.mathworks.com/products/compiler/matlab-runtime.html) is +developed by the The MathWorks, Inc. and is subject to the MATLAB +Runtime licence. From 958c72089459a64840f4372cbf8466e7f290244e Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 1 Aug 2024 12:23:06 +0200 Subject: [PATCH 11/13] fix --- .dockerignore | 8 +++++ .github/workflows/docker.yml | 4 +-- .gitignore | 3 +- Dockerfile_1 | 64 +++++++++++++++--------------------- README.md | 21 ++++++++++++ 5 files changed, 58 insertions(+), 42 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..df26397 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +# ignoring this might speed up build +# by preventing passing extra content to the docker daemon + +.github +tests + +*.simg +*.def diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ba24487..0784d74 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -29,6 +29,6 @@ jobs: docker build . --file ${{ matrix.image }} --tag cat12 docker images - name: help - run: docker run --rm -it cat12_mcr + run: docker run --rm cat12 - 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 + run: docker run -v ${PWD}/tests/data/MoAEpilot:/data --rm cat12 /data/sub-01/anat/sub-01_T1w.nii -b cat_standalone_segment.m diff --git a/.gitignore b/.gitignore index b867ad4..48c8bba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ .simg -tests/data/raw -tests/data/MoAEpilot +tests/data diff --git a/Dockerfile_1 b/Dockerfile_1 index 278841d..1c94074 100644 --- a/Dockerfile_1 +++ b/Dockerfile_1 @@ -3,15 +3,35 @@ FROM ubuntu:22.04 ENV LANG="en_US.UTF-8" \ LC_ALL="en_US.UTF-8" \ - ND_ENTRYPOINT="/neurodocker/startup.sh" + ND_ENTRYPOINT="/neurodocker/startup.sh" \ + FORCE_SPMMCR="1" \ + SPM_HTML_BROWSER="0" \ + MCR_INHIBIT_CTF_LOCK="1" \ + MCR_VERSION="2017b" +ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/opt/MCR-${MCR_VERSION}/v93/runtime/glnxa64:/opt/MCR-${MCR_VERSION}/v93/bin/glnxa64:/opt/MCR-${MCR_VERSION}/v93/sys/os/glnxa64:/opt/MCR-${MCR_VERSION}/v93/extern/bin/glnxa64" \ + MATLABCMD="/opt/MCR-${MCR_VERSION}/v93/toolbox/matlab" \ + XAPPLRESDIR="/opt//opt/MCR-${MCR_VERSION}/v93/x11/app-defaults" \ + MCRROOT="/opt/MCR-${MCR_VERSION}/v93" \ + CAT_VERSION=".8.1_r2042_R${MCR_VERSION}" +ENV SPMROOT="/opt/CAT12${CAT_VERSION}" \ + PATH="/opt/CAT12${CAT_VERSION}:$PATH" \ + STANDALONE="/opt/CAT12${CAT_VERSION}/standalone" RUN export ND_ENTRYPOINT="/neurodocker/startup.sh" \ && apt-get update -qq \ && apt-get install -y -q --no-install-recommends \ apt-utils \ + bc \ bzip2 \ ca-certificates \ curl \ + dbus-x11 \ + libncurses5 \ + libxext6 \ + libxmu6 \ + libxpm-dev \ + libxt6 \ locales \ + openjdk-8-jre \ 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 \ @@ -26,45 +46,14 @@ RUN export ND_ENTRYPOINT="/neurodocker/startup.sh" \ && 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 \ +RUN echo "Downloading MATLAB Compiler Runtime ..." \ + && export TMPDIR="$(mktemp -d)" \ + && curl -o "$TMPDIR/mcr.zip" https://ssd.mathworks.com/supportfiles/downloads/R${MCR_VERSION}/deployment_files/R${MCR_VERSION}/installers/glnxa64/MCR_R${MCR_VERSION}_glnxa64_installer.zip \ && unzip -q "$TMPDIR/mcr.zip" -d "$TMPDIR/mcrtmp" \ - && "$TMPDIR/mcrtmp/install" -destinationFolder /opt/MCR-2017b -mode silent -agreeToLicense yes \ + && "$TMPDIR/mcrtmp/install" -destinationFolder /opt/MCR-${MCR_VERSION} -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 ..." \ +RUN 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 \ @@ -73,7 +62,6 @@ RUN apt-get update -qq \ && 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 diff --git a/README.md b/README.md index 712bc3b..fd126d4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,24 @@ # CAT-12 container Docker and Apptainer image for [CAT12](https://neuro-jena.github.io/cat/). + +CAT12 8.1 r2042 +SPM12, version 7771 (standalone) +MATLAB, version 9.3.0.713579 (R2017b) + + +## Usage notes + + +### Example + +```bash +docker build . --tag cat12 +``` + +```bash +docker run -v ${PWD}/tests/data/MoAEpilot:/data \ + --rm -it cat12 \ + /data/sub-01/anat/sub-01_T1w.nii \ + -b cat_standalone_segment.m +``` From 30021063c7ba68e147ecdf2602e4dfc0ef091d47 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 1 Aug 2024 12:45:26 +0200 Subject: [PATCH 12/13] fix command --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0784d74..3276ee4 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -29,6 +29,6 @@ jobs: docker build . --file ${{ matrix.image }} --tag cat12 docker images - name: help - run: docker run --rm cat12 + run: docker run --rm cat12 view cat_standalone_segment.m - name: test run: docker run -v ${PWD}/tests/data/MoAEpilot:/data --rm cat12 /data/sub-01/anat/sub-01_T1w.nii -b cat_standalone_segment.m From f51d4ea064dc7912bbb34c62650bbcd070cee281 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 1 Aug 2024 12:57:08 +0200 Subject: [PATCH 13/13] rm older dockrfiles --- .github/workflows/docker.yml | 6 +- CHANGELOG.md | 22 +++++++ Dockerfile | 112 ++++++++++++++++++++--------------- Dockerfile_1 | 72 ---------------------- dockerfile_MCR | 61 ------------------- 5 files changed, 86 insertions(+), 187 deletions(-) delete mode 100644 Dockerfile_1 delete mode 100644 dockerfile_MCR diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3276ee4..a9812c5 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -13,10 +13,6 @@ concurrency: jobs: build: - strategy: - matrix: - image: [Dockerfile_1] - fail-fast: false runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -26,7 +22,7 @@ jobs: run: make tests/data/MoAEpilot - name: Build the Docker image run: | - docker build . --file ${{ matrix.image }} --tag cat12 + docker build . --tag cat12 docker images - name: help run: docker run --rm cat12 view cat_standalone_segment.m diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..f94d986 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1,22 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + + +## [Unreleased] diff --git a/Dockerfile b/Dockerfile index 2b3e370..06270f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,58 +1,72 @@ -FROM debian:bookworm-slim@sha256:5f7d5664eae4a192c2d2d6cb67fc3f3c7891a8722cd2903cc35aa649a12b0c8d +FROM ubuntu:22.04@sha256:340d9b015b194dc6e2a13938944e0d016e57b9679963fdeb9ce021daac430221 -LABEL org.opencontainers.image.authors="fil.spm@ucl.ac.uk, Malgorzata Wierzba (m.wierzba@fz-juelich.de), Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de)" +LABEL org.opencontainers.image.authors="fil.spm@ucl.ac.uk, Malgorzata Wierzba (m.wierzba@fz-juelich.de), Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de), Remi Gau (remi.gau@gmail.com)" LABEL org.opencontainers.image.source="https://gin.g-node.org/felixh/cat12-container" -LABEL org.opencontainers.image.version="v1.1" - -ARG DEBIAN_FRONTEND="noninteractive" - -ENV CATversion="r2560" -ENV STANDALONE="/opt/spm12/toolbox/cat12/standalone" - -RUN apt-get update -qq && \ - apt-get -qq -y --no-install-recommends install \ - build-essential \ - ca-certificates \ - curl \ - unzip \ - liboctave-dev \ - libxext6 \ - libxt6 \ - moreutils \ - octave \ - wget \ - && apt-get clean \ - && rm -rf \ - /tmp/hsperfdata* \ - /var/*/apt/*/partial \ - /var/lib/apt/lists/* \ - /var/log/apt/term* - -# install SPM12 -RUN mkdir /opt/spm12 \ - && curl -fsSL --retry 5 https://github.com/spm/spm12/archive/r7771.tar.gz | tar -xzC /opt/spm12 --strip-components 1 \ - && curl -fsSL --retry 5 https://raw.githubusercontent.com/spm/spm-octave/main/spm12_r7771.patch | patch -p0 \ - && make -C /opt/spm12/src PLATFORM=octave distclean \ - && make -C /opt/spm12/src PLATFORM=octave \ - && make -C /opt/spm12/src PLATFORM=octave install \ - && ln -s /opt/spm12/bin/spm12-octave /usr/local/bin/spm12 +LABEL org.opencontainers.image.version="v1.1dev" +LABEL org.opencontainers.image.licenses="MIT" +LABEL org.opencontainers.image.title="cat12-container" + +ENV LANG="en_US.UTF-8" \ + LC_ALL="en_US.UTF-8" \ + FORCE_SPMMCR="1" \ + SPM_HTML_BROWSER="0" \ + MCR_INHIBIT_CTF_LOCK="1" \ + MCR_VERSION="2017b" +ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/opt/MCR-${MCR_VERSION}/v93/runtime/glnxa64:/opt/MCR-${MCR_VERSION}/v93/bin/glnxa64:/opt/MCR-${MCR_VERSION}/v93/sys/os/glnxa64:/opt/MCR-${MCR_VERSION}/v93/extern/bin/glnxa64" \ + MATLABCMD="/opt/MCR-${MCR_VERSION}/v93/toolbox/matlab" \ + XAPPLRESDIR="/opt//opt/MCR-${MCR_VERSION}/v93/x11/app-defaults" \ + MCRROOT="/opt/MCR-${MCR_VERSION}/v93" \ + CAT_VERSION=".8.1_r2042_R${MCR_VERSION}" +ENV SPMROOT="/opt/CAT12${CAT_VERSION}" \ + PATH="/opt/CAT12${CAT_VERSION}:$PATH" \ + STANDALONE="/opt/CAT12${CAT_VERSION}/standalone" + +RUN export ND_ENTRYPOINT="/neurodocker/startup.sh" \ + && apt-get update -qq \ + && apt-get install -y -q --no-install-recommends \ + apt-utils \ + bc \ + bzip2 \ + ca-certificates \ + curl \ + dbus-x11 \ + libncurses5 \ + libxext6 \ + libxmu6 \ + libxpm-dev \ + libxt6 \ + locales \ + openjdk-8-jre \ + 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 + +RUN echo "Downloading MATLAB Compiler Runtime ..." \ + && export TMPDIR="$(mktemp -d)" \ + && curl -o "$TMPDIR/mcr.zip" https://ssd.mathworks.com/supportfiles/downloads/R${MCR_VERSION}/deployment_files/R${MCR_VERSION}/installers/glnxa64/MCR_R${MCR_VERSION}_glnxa64_installer.zip \ + && unzip -q "$TMPDIR/mcr.zip" -d "$TMPDIR/mcrtmp" \ + && "$TMPDIR/mcrtmp/install" -destinationFolder /opt/MCR-${MCR_VERSION} -mode silent -agreeToLicense yes \ + && rm -rf "$TMPDIR" \ + && unset TMPDIR + +RUN 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 -# install CAT12 -RUN mkdir -p /batch \ - && mkdir -p /downloads \ - && cd /downloads \ - && wget http://www.neuro.uni-jena.de/cat12/cat12_${CATversion}.zip && unzip -d /opt/spm12/toolbox/ cat12_${CATversion}.zip \ - && rm -fr /downloads \ - && cd ${STANDALONE} && chmod +rx *.sh \ - && cd /code && ln -s ${STANDALONE}/*.sh . \ - && cd /batch && ln -s ${STANDALONE}/*.m . - -# clean -RUN rm -f /opt/spm12/src/*.{mex,o,a} +WORKDIR ${STANDALONE} -ENTRYPOINT ['/code/main "$@"'] +ENTRYPOINT ["/code/main"] diff --git a/Dockerfile_1 b/Dockerfile_1 deleted file mode 100644 index 1c94074..0000000 --- a/Dockerfile_1 +++ /dev/null @@ -1,72 +0,0 @@ -# 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" \ - FORCE_SPMMCR="1" \ - SPM_HTML_BROWSER="0" \ - MCR_INHIBIT_CTF_LOCK="1" \ - MCR_VERSION="2017b" -ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/opt/MCR-${MCR_VERSION}/v93/runtime/glnxa64:/opt/MCR-${MCR_VERSION}/v93/bin/glnxa64:/opt/MCR-${MCR_VERSION}/v93/sys/os/glnxa64:/opt/MCR-${MCR_VERSION}/v93/extern/bin/glnxa64" \ - MATLABCMD="/opt/MCR-${MCR_VERSION}/v93/toolbox/matlab" \ - XAPPLRESDIR="/opt//opt/MCR-${MCR_VERSION}/v93/x11/app-defaults" \ - MCRROOT="/opt/MCR-${MCR_VERSION}/v93" \ - CAT_VERSION=".8.1_r2042_R${MCR_VERSION}" -ENV SPMROOT="/opt/CAT12${CAT_VERSION}" \ - PATH="/opt/CAT12${CAT_VERSION}:$PATH" \ - STANDALONE="/opt/CAT12${CAT_VERSION}/standalone" -RUN export ND_ENTRYPOINT="/neurodocker/startup.sh" \ - && apt-get update -qq \ - && apt-get install -y -q --no-install-recommends \ - apt-utils \ - bc \ - bzip2 \ - ca-certificates \ - curl \ - dbus-x11 \ - libncurses5 \ - libxext6 \ - libxmu6 \ - libxpm-dev \ - libxt6 \ - locales \ - openjdk-8-jre \ - 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 -RUN echo "Downloading MATLAB Compiler Runtime ..." \ - && export TMPDIR="$(mktemp -d)" \ - && curl -o "$TMPDIR/mcr.zip" https://ssd.mathworks.com/supportfiles/downloads/R${MCR_VERSION}/deployment_files/R${MCR_VERSION}/installers/glnxa64/MCR_R${MCR_VERSION}_glnxa64_installer.zip \ - && unzip -q "$TMPDIR/mcr.zip" -d "$TMPDIR/mcrtmp" \ - && "$TMPDIR/mcrtmp/install" -destinationFolder /opt/MCR-${MCR_VERSION} -mode silent -agreeToLicense yes \ - && rm -rf "$TMPDIR" \ - && unset TMPDIR -RUN 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/dockerfile_MCR b/dockerfile_MCR deleted file mode 100644 index 7fe586a..0000000 --- a/dockerfile_MCR +++ /dev/null @@ -1,61 +0,0 @@ -FROM debian:bookworm-slim@sha256:5f7d5664eae4a192c2d2d6cb67fc3f3c7891a8722cd2903cc35aa649a12b0c8d - -LABEL org.opencontainers.image.authors="fil.spm@ucl.ac.uk, Malgorzata Wierzba (m.wierzba@fz-juelich.de), Felix Hoffstaedter (f.hoffstaedter@fz-juelich.de)" -LABEL org.opencontainers.image.source="https://gin.g-node.org/felixh/cat12-container" -LABEL org.opencontainers.image.version="v1.1" - -ARG DEBIAN_FRONTEND="noninteractive" - -ENV CATversion="r2042" -ENV STANDALONE="/code/SPM/MCR_Linux/standalone" -ENV SPMROOT="/code/SPM/MCR_Linux" -ENV MCRROOT="/usr/local/MATLAB/MATLAB_Runtime/v93" -ENV MCR_INHIBIT_CTF_LOCK="1" - - -RUN apt-get update -qq && \ - apt-get -qq -y --no-install-recommends install \ - build-essential \ - ca-certificates \ - curl \ - unzip \ - liboctave-dev \ - libxext6 \ - libxt6 \ - moreutils \ - wget \ - && apt-get clean \ - && rm -rf \ - /tmp/hsperfdata* \ - /var/*/apt/*/partial \ - /var/lib/apt/lists/* \ - /var/log/apt/term* - -# install MCR -RUN mkdir -p /downloads/MCR \ - && curl -fsSL --retry 5 https://ssd.mathworks.com/supportfiles/downloads/R2017b/deployment_files/R2017b/installers/glnxa64/MCR_R2017b_glnxa64_installer.zip | tar -xzC /downloads/MCR MCR_R2017b_glnxa64_installer.zip --strip-components 1 \ - && bash /downloads/MCR/install -mode silent -agreeToLicense yes - -# transfer code and set permission -RUN mkdir -p /code -COPY ./code /code -RUN ls /code && find /code -type f -print0 | xargs -0 chmod +r - -# install CAT12 -RUN mkdir -p /batch \ - && mkdir -p /downloads \ - && cd /downloads \ - && wget http://www.neuro.uni-jena.de/cat12/CAT12.8.1_${CATversion}_R2017b_MCR_Linux.zip && unzip -d //code/SPM CAT12.8.1_${CATversion}_R2017b_MCR_Linux.zip \ - && rm -fr /downloads \ - && /code/SPM/MCR_Linux/run_spm12.sh /usr/local/MATLAB/MATLAB_Runtime/v93 quit \ - && cd /code/SPM/MCR_Linux \ - && chmod +rx run_spm12.sh spm12.sh spm12 spm12.ctf \ - && cd ${STANDALONE} && chmod +rx *.sh \ - && cd /code && ln -s ${STANDALONE}/*.sh . \ - && cd /batch && ln -s ${STANDALONE}/*.m . - - -# clean -RUN rm -f /downloads - -ENTRYPOINT ['/code/main "$@"']