-
Notifications
You must be signed in to change notification settings - Fork 35
/
apptainer.def
96 lines (72 loc) · 3.81 KB
/
apptainer.def
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Bootstrap: docker
From: python:3.12-slim
Stage: builder
%post
apt update && apt -y install git build-essential cmake wget
# Install the latest dcm2niix release from the base repository (= typically outdated)
# apt update && apt -y install dcm2niix
# Install the latest dcm2niix from sources
git clone https://github.com/rordenlab/dcm2niix.git
cd dcm2niix; mkdir build && cd build
cmake -DZLIB_IMPLEMENTATION=Cloudflare -DUSE_JPEGLS=ON -DUSE_OPENJPEG=ON ..
make install
# Install the latest miniconda (needed for FSL install)
mkdir -p /opt/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /opt/miniconda3/miniconda.sh
bash /opt/miniconda3/miniconda.sh -b -u -p /opt/miniconda3
export PATH=/opt/miniconda3/bin:$PATH
conda init bash
conda config --set channel_priority strict # Needed for pngappend, see: https://github.com/NeuroDesk/neurocontainers/pull/598
. /root/.bashrc
# Create a conda env and install FSL tools needed for (me)deface and slicereport. NB: Keep the version the same as the Docker base image
conda create -n fsl python=3.10
conda install -n fsl -c https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/public/ -c conda-forge fsl-libvis fsl-avwutils fsl-flirt
# Pack the fsl environment into fsl.tar.gz and unpack it in /opt/fsl
conda install -c conda-forge conda-pack
conda pack -n fsl
mkdir /opt/fsl && tar -xzf fsl.tar.gz -C /opt/fsl
/opt/fsl/bin/conda-unpack
# Clone bidscoin
git clone https://github.com/Donders-Institute/bidscoin.git /opt/bidscoin
cd /opt/bidscoin
rm -rf docs tests .git
Bootstrap: docker
From: python:3.12-slim
Stage: final
%help
This BIDScoin Apptainer image includes:
* Debian stable,
* BIDScoin (see https://bidscoin.readthedocs.io)
* The latest versions of dcm2niix, pydeface, spec2nii and some FSL tools
The general form to run BIDScoin commands is:
apptainer exec bidscoin.sif <bidscoin_tool> <bidscoin_tool_args>
For more information run:
apptainer run bidscoin.sif
NB: 1) To run GUI applications (such as the bidseditor) you probably need to run `xhost +` first
2) In the commands above, Singularity users should replace `apptainer` with `singularity`
3) The current image does not include the Freesurfer/synthstrip software (needed for `skullstrip`)
%files from builder
# /opt/bidscoin /opt/bidscoin # Only needed for pip install from github
/usr/local/bin/dcm2niix /usr/local/bin/dcm2niix
/opt/fsl /opt/fsl
%environment
export FSLDIR=/opt/fsl FSLOUTPUTTYPE=NIFTI_GZ
export PATH=$PATH:/opt/fsl/bin
export PIP_NO_CACHE_DIR=off
%post
# Install curl (sometimes needed by dcm2niix) and pigz (to speed up dcm2niix)
apt update && apt -y --no-install-recommends install pigz curl
# Pre-install essential packages
# NOTE: PyQt is installed as Debian package to solve dependencies issues occurring when installed with pip
apt -y --no-install-recommends install python3-pyqt6 build-essential libgl1 libxcb-cursor0 dbus qt6-wayland && apt clean # Add build-essential for newer python:3-slim base images (pip needs gcc and wayland support is not yet provided for)
# Install BIDScoin
# pip install /opt/bidscoin[spec2nii2bids,deface]
# pip install bidscoin[spec2nii2bids,deface]==VERSION
pip install bidscoin[spec2nii2bids,deface]
# Uncomment the line below if you get errors like: ImportError: libQt5Core.so.5: cannot open shared object file: No such file or directory
# strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
# strip --remove-section=.note.ABI-tag libQt6Core.so.6
# Finally, create the necessary links and cache to the most recent shared libraries (= best practise)
ldconfig
%runscript
exec bidscoin