Skip to content

Commit 04285a0

Browse files
authored
[ENH] add Apptainer definition (#1254)
* add definition file for apptainer * start updating doc
1 parent 89780f3 commit 04285a0

File tree

7 files changed

+175
-81
lines changed

7 files changed

+175
-81
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: apptainer build
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: eWaterCycle/setup-apptainer@v2
22+
with:
23+
apptainer-version: 1.3.0
24+
- name: build sif image
25+
run: apptainer build bidspm.sif bidspm.def

bidspm.def

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
BootStrap: docker
2+
From: bids/base_validator
3+
4+
%post
5+
apt-get -qq update
6+
DEBIAN_FRONTEND=noninteractive apt-get --yes --quiet install \
7+
build-essential \
8+
software-properties-common \
9+
apt-utils \
10+
ca-certificates \
11+
git \
12+
curl \
13+
python3 \
14+
python3-pip \
15+
fonts-freefont-otf \
16+
ghostscript \
17+
gnuplot-x11 \
18+
libcurl4-gnutls-dev \
19+
octave \
20+
liboctave-dev \
21+
octave-common \
22+
octave-io \
23+
octave-image \
24+
octave-signal \
25+
octave-statistics && \
26+
apt-get clean && \
27+
rm -rf \
28+
/tmp/hsperfdata* \
29+
/var/*/apt/*/partial \
30+
/var/lib/apt/lists/* \
31+
/var/log/apt/term*
32+
33+
mkdir /opt/spm12
34+
curl -fsSL --retry 5 https://github.com/spm/spm12/archive/r7771.tar.gz | tar -xzC /opt/spm12 --strip-components 1
35+
curl -fsSL --retry 5 https://raw.githubusercontent.com/spm/spm-octave/main/spm12_r7771.patch | patch -p0
36+
make -C /opt/spm12/src PLATFORM=octave distclean
37+
make -C /opt/spm12/src PLATFORM=octave
38+
make -C /opt/spm12/src PLATFORM=octave install
39+
ln -s /opt/spm12/bin/spm12-octave /usr/local/bin/spm12
40+
41+
mkdir /opt/bidspm
42+
git clone --recurse-submodules https://github.com/cpp-lln-lab/bidspm.git /opt/bidspm
43+
pip install --no-cache-dir --upgrade pip && \
44+
pip3 --no-cache-dir install /opt/bidspm && \
45+
octave --no-gui --eval "addpath('/opt/spm12/'); savepath ('/usr/share/octave/site/m/startup/octaverc');" && \
46+
octave --no-gui --eval "addpath('/opt/bidspm/'); savepath('/usr/share/octave/site/m/startup/octaverc'); bidspm(); path"
47+
48+
%runscript
49+
bidspm "$@"
50+
51+
%help
52+
This is a bidspm container.
53+
Please see the documentation for more instructions:
54+
https://bidspm.readthedocs.io/en/latest/

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
# List of patterns, relative to source directory, that match files and
5454
# directories to ignore when looking for source files.
5555
# This pattern also affects html_static_path and html_extra_path.
56-
exclude_patterns = ["examples", "defaults", "demo", "images/*.md", "lib/CPP_ROI"]
56+
exclude_patterns = ["examples", "defaults", "demo", "images/*.md", "lib/CPP_ROI/**"]
5757

5858
suppress_warnings = ["myst.header", "myst.xref_missing"]
5959

@@ -69,7 +69,7 @@
6969
source_suffix = ".rst"
7070

7171
intersphinx_mapping = {
72-
"bids-matlab": ("https://bids-matlab.readthedocs.io/en/latest", None)
72+
"bids-matlab": ("https://bids-matlab.readthedocs.io/en/main", None)
7373
}
7474

7575
coverage_show_missing_items = True

docs/source/containers.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Docker / Apptainer
2+
3+
## Docker
4+
5+
### Get image from docker hub
6+
7+
```bash
8+
docker pull cpplab/bidspm:latest
9+
```
10+
11+
### Build the docker image locally
12+
13+
If you want to build the docker image locally and not pull it from the docker hub:
14+
15+
```bash
16+
docker build . -f docker/Dockerfile -t cpplab/bidspm:latest
17+
```
18+
19+
This will create an image with the tag name `bidspm:latest`.
20+
21+
Running `make build_image` will also build the `stable` version
22+
and a version tagged image.
23+
24+
### Run the docker image
25+
26+
The following command would pull from our
27+
[docker hub](https://hub.docker.com/repository/docker/cpplab/bidspm)
28+
and start the docker image::
29+
30+
```bash
31+
docker run -it --rm cpplab/bidspm:latest
32+
```
33+
34+
The following command would do do the same,
35+
but it would also map 2 folders from your computer
36+
and run preprocessing on your dataset
37+
(assuming there is a task called `auditory`):
38+
39+
```bash
40+
bids_dir=fullpath_to_bids_dataset
41+
output_dir=fullpath_to_your_output_folder
42+
43+
docker run -it --rm \
44+
-v $bids_dir:/raw \
45+
-v $output_dir:/derivatives \
46+
cpplab/bidspm:latest \
47+
/raw \
48+
/derivatives \
49+
subject \
50+
--task auditory \
51+
--action preprocess \
52+
--fwhm 8
53+
```
54+
55+
Similarly this would run the statistics provided you give a bids stats model file
56+
and the path to the preprocessed data.
57+
58+
```bash
59+
bids_dir=fullpath_to_bids_dataset
60+
output_dir=fullpath_to_your_output_folder
61+
model=fullpath_to_your_bids_stats_model
62+
63+
docker run -it --rm \
64+
-v $bids_dir:/raw \
65+
-v $output_dir:/derivatives \
66+
-v $model:/models/smdl.json \
67+
cpplab/bidspm:latest \
68+
/raw \
69+
/derivatives \
70+
subject \
71+
--action stats \
72+
--preproc_dir /derivatives/bidspm-preproc \
73+
--model_file /models/smdl.json \
74+
--fwhm 8
75+
```
76+
77+
## Apptainer
78+
79+
If you are plaaning to use [Apptainer](https://apptainer.org/) (formerly Singularity) to run bidspm,
80+
a definition file is provided in the repository.
81+
82+
```bash
83+
apptainer build bidspm.sif bidspm.def
84+
```

docs/source/docker.rst

Lines changed: 0 additions & 78 deletions
This file was deleted.

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Welcome to bidspm documentation!
2626
fieldmaps
2727
quality_analysis
2828
mancoreg
29-
docker
29+
containers
3030
CHANGELOG
3131
links_and_references
3232
CONTRIBUTING

docs/source/installation.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ You can also remove bidspm from the path with:
7171
Installation on a computing cluster
7272
===================================
7373

74+
.. warning::
75+
76+
If you are planning to use bidspm on a compute cluster,
77+
it may be easier to use a containerized version of it.
78+
The repository includes an Apptainer ``bidspm.def`` definition file
79+
to help.
80+
81+
Please see the containers section of the documentation.
82+
7483
..
7584
7685
For stand alone download

0 commit comments

Comments
 (0)