From af934b43618ad446c251811cc08b5221d26e7aff Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 7 Apr 2022 13:12:16 +0200 Subject: [PATCH 1/4] Add common tools for MATLAB and Python testing Common base for the matlab and python testing branch to minimize merge conflicts down the line --- .gitignore | 11 ++-- .pre-commit-config.yaml | 7 +++ CONTRIBUTING.md | 56 +++++++++++++++++++ Makefile | 116 ++++++++++++++++++++++++++++++++++++++++ README.md | 35 ++++++------ requirements_dev.txt | 11 ++++ 6 files changed, 217 insertions(+), 19 deletions(-) create mode 100644 .pre-commit-config.yaml create mode 100644 CONTRIBUTING.md create mode 100644 Makefile create mode 100644 requirements_dev.txt diff --git a/.gitignore b/.gitignore index 7c82424..7bd97a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ -# +# vscode files .vscode/ +# test related +tests/outputs/ -# data folder +# data folders data/ # example output folders @@ -13,6 +15,9 @@ figures/ report.html ##*.png +# pyenv +Pipfile + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -54,6 +59,7 @@ pip-delete-this-directory.txt htmlcov/ .tox/ .coverage +coverage_html .coverage.* .cache nosetests.xml @@ -153,4 +159,3 @@ codegen/ # Octave session info octave-workspace - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..e9f04ad --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,7 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: check-yaml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..baaa794 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,56 @@ +# CONTRIBUTING + +Information for anyone who would like to contribute to this repository. + +## Repository map + +```bash +├── .git +├── .github +│ └── workflows # Github continuous integration set up +├── examples +│ ├── data +│ ├── example1outputs +│ ├── example2outputs +├── glmsingle # Python implementation +│ ├── cod +│ ├── design +│ ├── gmm +│ ├── hrf +│ ├── ols +│ ├── ssq +│ └── utils +├── matlab # Matlab implementation +│ ├── examples +│ ├── fracridge +│ └── utilities +└── tests # Python and Matlab tests + └── data + +``` + +## Generic + +### Makefile + +### pre-commit + +## Matlab + +### Style guide + +### Tests + +#### Demos + +### Continuous integration + +## Python + +### Style guide + +### Tests + +#### Demos + +### Continuous integration \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..75e39ce --- /dev/null +++ b/Makefile @@ -0,0 +1,116 @@ +.DEFAULT_GOAL := help + +BROWSER := python -c "$$BROWSER_PYSCRIPT" + +# TODO make more general to use the local matlab version +MATLAB = /usr/local/MATLAB/R2017a/bin/matlab +MATLAB_ARG = -nodisplay -nosplash -nodesktop + +define BROWSER_PYSCRIPT +import os, webbrowser, sys + +from urllib.request import pathname2url + +webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) +endef +export BROWSER_PYSCRIPT + +# determines what "make help" will show +define PRINT_HELP_PYSCRIPT +import re, sys + +for line in sys.stdin: + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) + if match: + target, help = match.groups() + print("%-20s %s" % (target, help)) +endef +export PRINT_HELP_PYSCRIPT + +################################################################################ +# GENERIC +.PHONY: help clean clean-test lint install_dev + +help: + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) +clean: clean-build clean-pyc clean-test ## remove all build, test, coverage artifacts + +clean-test: ## remove test and coverage artifacts + rm -rf .tox/ + rm -rf .coverage + rm -rf htmlcov/ + rm -rf .pytest_cache + rm -rf tests/data + rm -rf test/outputs + +install_dev: ## install for both matlab and python developpers + pip install -e . + pip install -r requirements_dev.txt + +lint: lint/black lint/flake8 lint/miss_hit ## check style + +test: test-matlab test-python + +tests/data/nsdcoreexampledataset.mat: + mkdir tests/data + curl -fsSL --retry 5 -o "tests/data/nsdcoreexampledataset.mat" https://osf.io/k89b2/download + +################################################################################ + +################################################################################ +# MATLAB + +.PHONY: lint/miss_hit + +lint/miss_hit: ## lint and checks matlab code + mh_style --fix tests && mh_metric --ci tests && mh_lint tests + +test-matlab: tests/data/nsdcoreexampledataset.mat + $(MATLAB) $(MATLAB_ARG) -r "run_tests; exit()" + +coverage-matlab: test-matlab + $(BROWSER) coverage_html/index.html + +################################################################################ + +################################################################################ +# PYTHON + +.PHONY: clean-build clean-pyc coverage-python install lint/flake8 lint/black + +clean-build: ## remove build artifacts + rm -fr build/ + rm -fr dist/ + rm -fr .eggs/ + find . -name '*.egg-info' -exec rm -fr {} + + find . -name '*.egg' -exec rm -f {} + + +clean-pyc: ## remove Python file artifacts + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + find . -name '__pycache__' -exec rm -fr {} + + +lint/flake8: ## check style with flake8 + flake8 tests +lint/black: ## check style with black + black tests + +test-python: tests/data/nsdcoreexampledataset.mat ## run tests quickly with the default Python + pytest + +test-notebooks: + pytest --nbmake --nbmake-timeout=3000 "./examples" +test-all: ## run tests on every Python version with tox + tox + +coverage-python: ## check code coverage quickly with the default Python + coverage run --source glmsingle -m pytest + coverage report -m + coverage html + $(BROWSER) htmlcov/index.html + +install: clean ## install the package to the active Python's site-packages + python setup.py install + +################################################################################ \ No newline at end of file diff --git a/README.md b/README.md index 1cc319e..336ed01 100644 --- a/README.md +++ b/README.md @@ -33,20 +33,6 @@ This will also clone [`fracridge`](https://github.com/nrdg/fracridge) as a submo To use the GLMsingle toolbox, add it and `fracridge` to your MATLAB path by running the `setup.m` script. -## Example scripts - -We provide a number of example scripts that demonstrate usage of GLMsingle. You can browse these example scripts here: - -(Python Example 1 - event-related design) https://htmlpreview.github.io/?https://github.com/kendrickkay/GLMsingle/blob/main/examples/example1.html - -(Python Example 2 - block design) https://htmlpreview.github.io/?https://github.com/kendrickkay/GLMsingle/blob/main/examples/example2.html - -(MATLAB Example 1 - event-related design) https://htmlpreview.github.io/?https://github.com/kendrickkay/GLMsingle/blob/main/matlab/examples/example1preview/example1.html - -(MATLAB Example 2 - block design) https://htmlpreview.github.io/?https://github.com/kendrickkay/GLMsingle/blob/main/matlab/examples/example2preview/example2.html - -If you would like to run these example scripts, the Python versions are available in `/GLMsingle/examples`, and the MATLAB versions are available in `/GLMsingle/matlab/examples`. Each notebook contains a full walkthrough of the process of loading an example dataset and design matrix, estimating neural responses using GLMsingle, estimating the reliability of responses at each voxel, and comparing those achieved via GLMsingle to those achieved using a baseline GLM. - ## Python To install: @@ -63,12 +49,25 @@ Running the demos requires: pip install jupyterlab ``` -Code dependencies: see requirements.txt +Code dependencies: see [requirements.txt](./requirements.txt) Notes: -* Please note that GLMsingle is not (yet) compatible with Python 3.9 (due to an incompatibility between scikit-learn and Python 3.9). Please use Python 3.8 or earlier. * Currently, numpy has a 4GB limit for the pickle files it writes; thus, GLMsingle will crash if the file outputs exceed that size. One workaround is to turn off "disk saving" and instead get the outputs of GLMsingle in your workspace and save the outputs yourself to HDF5 format. +## Example scripts + +We provide a number of example scripts that demonstrate usage of GLMsingle. You can browse these example scripts here: + +(Python Example 1 - event-related design) https://htmlpreview.github.io/?https://github.com/kendrickkay/GLMsingle/blob/main/examples/example1.html + +(Python Example 2 - block design) https://htmlpreview.github.io/?https://github.com/kendrickkay/GLMsingle/blob/main/examples/example2.html + +(MATLAB Example 1 - event-related design) https://htmlpreview.github.io/?https://github.com/kendrickkay/GLMsingle/blob/main/matlab/examples/example1preview/example1.html + +(MATLAB Example 2 - block design) https://htmlpreview.github.io/?https://github.com/kendrickkay/GLMsingle/blob/main/matlab/examples/example2preview/example2.html + +If you would like to run these example scripts, the Python versions are available in `/GLMsingle/examples`, and the MATLAB versions are available in `/GLMsingle/matlab/examples`. Each notebook contains a full walkthrough of the process of loading an example dataset and design matrix, estimating neural responses using GLMsingle, estimating the reliability of responses at each voxel, and comparing those achieved via GLMsingle to those achieved using a baseline GLM. + ## Additional information For additional information, please visit the Wiki page associated with this @@ -80,6 +79,10 @@ If you use GLMsingle in your research, please cite the following paper: * [Prince, J.S., Charest, I., Kurzawski, J.W., Pyles, J.A., Tarr, M.J., Kay, K.N. GLMsingle: a toolbox for improving single-trial fMRI response estimates. bioRxiv (2022).](https://www.biorxiv.org/content/10.1101/2022.01.31.478431v1) +## Contributing + +If you want to contribute to GLMsingle see the [contributing](./CONTRIBUTING.md) documentation to help you know what is where and how to set things up. + ## Change history * 2021/10/12 - Version 1.0 of GLMsingle is now released. A git tag has been added to the repo. diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..8bf205e --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,11 @@ +# Matlab dev +miss_hit + +# Python dev +flake8 +tox +coverage +pytest +black +nbmake +pytest-cov From 5dfcecdcd4016846c2858e0483cb034abd25a1d7 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 7 Apr 2022 13:31:02 +0200 Subject: [PATCH 2/4] pin minimum python and dependencies versions --- requirements.txt | 16 ++++++++-------- setup.py | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/requirements.txt b/requirements.txt index b0de2fa..6daf04e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -numpy -scipy -sklearn -matplotlib -tqdm -fracridge -nibabel -h5py +fracridge>=1.4.3 +h5py>=3.1.0 +matplotlib>=3.3.4 +nibabel>=3.2.2 +numpy>=1.17.0 +scikit-learn>=0.23.2 +scipy>=1.5.4 +tqdm>=4.63.1 \ No newline at end of file diff --git a/setup.py b/setup.py index 731c9c2..3847fc8 100644 --- a/setup.py +++ b/setup.py @@ -28,5 +28,6 @@ packages=find_packages(), include_package_data=True, zip_safe=False, - install_requires=requires + install_requires=requires, + python_requires='>=3.6' ) From 0b5004a1ee8e0f65317268c67a686f3dbbb8c84c Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Mon, 11 Apr 2022 14:57:24 +0200 Subject: [PATCH 3/4] add Dockerfile --- Dockerfile | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 31 ++++++++++++- 2 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ec1eb30 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,127 @@ +# Generated by: Neurodocker version 0.7.0+0.gdc97516.dirty +# Latest release: Neurodocker version 0.8.0 +# Timestamp: 2022/04/11 12:55:39 UTC +# +# Thank you for using Neurodocker. If you discover any issues +# or ways to improve this software, please submit an issue or +# pull request on our GitHub repository: +# +# https://github.com/ReproNim/neurodocker + +FROM python:3.9.12-slim-buster + +USER root + +ARG DEBIAN_FRONTEND="noninteractive" + +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 \ + && apt-get clean \ + && 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 + +ENTRYPOINT ["/neurodocker/startup.sh"] + +RUN apt-get update -qq \ + && apt-get install -y -q --no-install-recommends \ + build-essential \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY ["glmsingle", "setup.py", "MANIFEST.in", "README.md", "requirements.txt", "/glmsingle/"] + +WORKDIR /glmsingle + +RUN pip install . + +RUN pip install jupyterlab + +EXPOSE 8888 + +RUN test "$(getent passwd neuro)" || useradd --no-user-group --create-home --shell /bin/bash neuro +USER neuro + +WORKDIR /home/neuro + +COPY ["examples", "/home/neuro/examples"] + +RUN echo '{ \ + \n "pkg_manager": "apt", \ + \n "instructions": [ \ + \n [ \ + \n "base", \ + \n "python:3.9.12-slim-buster" \ + \n ], \ + \n [ \ + \n "install", \ + \n [ \ + \n "build-essential" \ + \n ] \ + \n ], \ + \n [ \ + \n "copy", \ + \n [ \ + \n "glmsingle", \ + \n "setup.py", \ + \n "MANIFEST.in", \ + \n "README.md", \ + \n "requirements.txt", \ + \n "/glmsingle/" \ + \n ] \ + \n ], \ + \n [ \ + \n "workdir", \ + \n "/glmsingle" \ + \n ], \ + \n [ \ + \n "run", \ + \n "pip install ." \ + \n ], \ + \n [ \ + \n "run", \ + \n "pip install jupyterlab" \ + \n ], \ + \n [ \ + \n "expose", \ + \n [ \ + \n "8888" \ + \n ] \ + \n ], \ + \n [ \ + \n "user", \ + \n "neuro" \ + \n ], \ + \n [ \ + \n "workdir", \ + \n "/home/neuro" \ + \n ], \ + \n [ \ + \n "copy", \ + \n [ \ + \n "examples", \ + \n "/home/neuro/examples" \ + \n ] \ + \n ] \ + \n ] \ + \n}' > /neurodocker/neurodocker_specs.json diff --git a/Makefile b/Makefile index 75e39ce..73cd3b9 100644 --- a/Makefile +++ b/Makefile @@ -113,4 +113,33 @@ coverage-python: ## check code coverage quickly with the default Python install: clean ## install the package to the active Python's site-packages python setup.py install -################################################################################ \ No newline at end of file +################################################################################ + +################################################################################ +# DOCKER + +.PHONY: Dockerfile +Dockerfile: + docker run --rm repronim/neurodocker:0.7.0 generate docker \ + --base python:3.9.12-slim-buster \ + --pkg-manager apt \ + --install "build-essential" \ + --copy glmsingle setup.py MANIFEST.in README.md requirements.txt /glmsingle/ \ + --workdir /glmsingle \ + --run "pip install ." \ + --run "pip install jupyterlab" \ + --expose 8888 \ + --user neuro \ + --workdir /home/neuro \ + --copy examples /home/neuro/examples > Dockerfile + +docker_build: Dockerfile + docker build . -t glmsingle:latest + +docker_run: docker_build + mkdir -p $$PWD/tmp + docker run -it --rm \ + --publish 8888:8888 \ + --volume $$PWD/tmp:/home/neuro/tmp \ + glmsingle:latest \ + jupyter-lab --no-browser --ip 0.0.0.0 \ No newline at end of file From 0e6062befa48447ccb9d4f42757ddaa60cc2cfd3 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 28 Apr 2022 18:12:20 +0200 Subject: [PATCH 4/4] add singularity recipe --- Makefile | 19 +++++++- Singularity | 113 ++++++++++++++++++++++++++++++++++++++++++++ glmsingle.def | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 257 insertions(+), 2 deletions(-) create mode 100644 Singularity create mode 100644 glmsingle.def diff --git a/Makefile b/Makefile index 73cd3b9..da543b0 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ install: clean ## install the package to the active Python's site-packages ################################################################################ # DOCKER -.PHONY: Dockerfile +.PHONY: Dockerfile glmsingle.def Dockerfile: docker run --rm repronim/neurodocker:0.7.0 generate docker \ --base python:3.9.12-slim-buster \ @@ -142,4 +142,19 @@ docker_run: docker_build --publish 8888:8888 \ --volume $$PWD/tmp:/home/neuro/tmp \ glmsingle:latest \ - jupyter-lab --no-browser --ip 0.0.0.0 \ No newline at end of file + jupyter-lab --no-browser --ip 0.0.0.0 + +glmsingle.def: + docker run --rm repronim/neurodocker:0.7.0 generate singularity \ + --base python:3.9.12-slim-buster \ + --pkg-manager apt \ + --install "build-essential" \ + --copy glmsingle setup.py MANIFEST.in README.md requirements.txt /home/glmsingle/ \ + --workdir /glmsingle \ + --run "pip install ." \ + --user neuro \ + --workdir /home/neuro \ + --copy examples /home/neuro/examples > glmsingle.def + +singularity_build: glmsingle.def + sudo singularity build glmsingle.sif glmsingle.def \ No newline at end of file diff --git a/Singularity b/Singularity new file mode 100644 index 0000000..c883429 --- /dev/null +++ b/Singularity @@ -0,0 +1,113 @@ +# Generated by: Neurodocker version 0.7.0+0.gdc97516.dirty +# Latest release: Neurodocker version 0.8.0 +# Timestamp: 2022/04/28 15:50:25 UTC +# +# Thank you for using Neurodocker. If you discover any issues +# or ways to improve this software, please submit an issue or +# pull request on our GitHub repository: +# +# https://github.com/ReproNim/neurodocker + +FROM python:3.9.12-slim-buster + +USER root + +ARG DEBIAN_FRONTEND="noninteractive" + +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 \ + && apt-get clean \ + && 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 + +ENTRYPOINT ["/neurodocker/startup.sh"] + +RUN apt-get update -qq \ + && apt-get install -y -q --no-install-recommends \ + build-essential \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY ["glmsingle", "setup.py", "MANIFEST.in", "README.md", "requirements.txt", "/glmsingle/"] + +WORKDIR /glmsingle + +RUN pip install . + +RUN test "$(getent passwd neuro)" || useradd --no-user-group --create-home --shell /bin/bash neuro +USER neuro + +WORKDIR /home/neuro + +COPY ["examples", "/home/neuro/examples"] + +RUN echo '{ \ + \n "pkg_manager": "apt", \ + \n "instructions": [ \ + \n [ \ + \n "base", \ + \n "python:3.9.12-slim-buster" \ + \n ], \ + \n [ \ + \n "install", \ + \n [ \ + \n "build-essential" \ + \n ] \ + \n ], \ + \n [ \ + \n "copy", \ + \n [ \ + \n "glmsingle", \ + \n "setup.py", \ + \n "MANIFEST.in", \ + \n "README.md", \ + \n "requirements.txt", \ + \n "/glmsingle/" \ + \n ] \ + \n ], \ + \n [ \ + \n "workdir", \ + \n "/glmsingle" \ + \n ], \ + \n [ \ + \n "run", \ + \n "pip install ." \ + \n ], \ + \n [ \ + \n "user", \ + \n "neuro" \ + \n ], \ + \n [ \ + \n "workdir", \ + \n "/home/neuro" \ + \n ], \ + \n [ \ + \n "copy", \ + \n [ \ + \n "examples", \ + \n "/home/neuro/examples" \ + \n ] \ + \n ] \ + \n ] \ + \n}' > /neurodocker/neurodocker_specs.json diff --git a/glmsingle.def b/glmsingle.def new file mode 100644 index 0000000..e90f83f --- /dev/null +++ b/glmsingle.def @@ -0,0 +1,127 @@ +# Generated by: Neurodocker version 0.7.0+0.gdc97516.dirty +# Latest release: Neurodocker version 0.8.0 +# Timestamp: 2022/04/28 16:02:27 UTC +# +# Thank you for using Neurodocker. If you discover any issues +# or ways to improve this software, please submit an issue or +# pull request on our GitHub repository: +# +# https://github.com/ReproNim/neurodocker + +Bootstrap: docker +From: python:3.9.12-slim-buster + +%post +su - root + +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 +apt-get clean +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 + +apt-get update -qq +apt-get install -y -q --no-install-recommends \ + build-essential +apt-get clean +rm -rf /var/lib/apt/lists/* + +cd /glmsingle + +pip install . + +test "$(getent passwd neuro)" || useradd --no-user-group --create-home --shell /bin/bash neuro +su - neuro + +cd /home/neuro + +echo '{ +\n "pkg_manager": "apt", +\n "instructions": [ +\n [ +\n "base", +\n "python:3.9.12-slim-buster" +\n ], +\n [ +\n "user", +\n "root" +\n ], +\n [ +\n "_header", +\n { +\n "version": "generic", +\n "method": "custom" +\n } +\n ], +\n [ +\n "install", +\n [ +\n "build-essential" +\n ] +\n ], +\n [ +\n "copy", +\n [ +\n "glmsingle", +\n "setup.py", +\n "MANIFEST.in", +\n "README.md", +\n "requirements.txt", +\n "/home/glmsingle/" +\n ] +\n ], +\n [ +\n "workdir", +\n "/glmsingle" +\n ], +\n [ +\n "run", +\n "pip install ." +\n ], +\n [ +\n "user", +\n "neuro" +\n ], +\n [ +\n "workdir", +\n "/home/neuro" +\n ], +\n [ +\n "copy", +\n [ +\n "examples", +\n "/home/neuro/examples" +\n ] +\n ] +\n ] +\n}' > /neurodocker/neurodocker_specs.json + +%environment +export LANG="en_US.UTF-8" +export LC_ALL="en_US.UTF-8" +export ND_ENTRYPOINT="/neurodocker/startup.sh" + +%files +glmsingle setup.py +examples /home/neuro/examples + +%runscript +/neurodocker/startup.sh "$@"