Development Paused - resource required is too high for limited time of usefulness on Rocket
fMRIPrep is a NiPreps (NeuroImaging PREProcessing toolS) application (www.nipreps.org) for the preprocessing of task-based and resting-state functional MRI (fMRI).
You do not need Docker or other container tools in order to use fMRIPrep. The installation is quite simple using standard Python venv tools, as available on our HPC facilities.
#!/bin/bash
DEST_DIR=/nobackup/njps3/fmriprep
# Load software modules needed to build
echo "Loading HPC software modules..."
module load Python/3.11.3-GCCcore-12.3.0
module load CMake
module load Autoconf
module load Automake
module load GCC
echo "- Ok"
echo ""
# Create virtual environment to install dependencies
echo "Creating installation folder..."
python -m venv ${DEST_DIR}
mkdir -p ${DEST_DIR}/downloads
echo "- Your fmriprep software will all be installed under: ${DEST_DIR}"
echo "- Downloads will all be stored under: ${DEST_DIR}/downloads"
echo ""
echo "Activate new installation folder environment..."
echo "- Before: python was `which python3`"
echo "- Before: pip was `which pip3`"
source ${DEST_DIR}/bin/activate
echo "- After: python is now `which python3`"
echo "- After: pip is now `which pip3`"
echo ""
# Install fmriprep dependencies
echo "Installing requirements..."
echo "- This may take a while......."
echo ""
############################################
# FSL
############################################
echo "Downloading FSL..."
cd ${DEST_DIR} ; wget -nc -q https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/releases/fslinstaller.py -O ${DEST_DIR}/downloads/fslinstaller.py
if [ -s "$DEST_DIR/downloads/fslinstaller.py" ]
then
echo "- Running FSL installation..."
echo "- Ok"
echo ""
else
echo "- ERROR - Cannot run FSL installation..."
exit 1
fi
############################################
# ANTS
############################################
echo "Downloading ANTs..."
cd ${DEST_DIR} ; git clone -q https://github.com/ANTsX/ANTs.git
if [ -d "${DEST_DIR}/ANTs" ]
then
echo "- Running ANTs installation..."
#mkdir ants-build
#cd ants-build
#cmake -DCMAKE_INSTALL_PREFIX=${DEST_DIR} ../ANTs
#make -j 4
#cd ANTS-build
#make install
echo "- Ok"
echo ""
else
echo "- ERROR - Cannot run ANTs installation..."
exit 1
fi
############################################
# Motif - needed for AFNI
############################################
echo "Downloading Motif..."
cd ${DEST_DIR} ; wget -nc -q https://sourceforge.net/projects/motif/files/Motif%202.3.8%20Source%20Code/motif-2.3.8.tar.gz/download -O ${DEST_DIR}/downloads/motif.tgz
if [ -s "${DEST_DIR}/downloads/motif.tgz" ]
then
if [ -s "${DEST_DIR}/lib/libXm.so.4.0.4" ]
then
echo "- Motif already installed at ${DEST_DIR}/lib/libXm.so.4.0.4"
echo "- Ok"
echo ""
else
if [ -s "${DEST_DIR}/motif-2.3.8/README" ]
then
echo "- Motif src already unpacked"
else
echo "- Unpacking Motif src..."
cd ${DEST_DIR} && tar xfz ${DEST_DIR}/downloads/motif.tgz
if [ "$?" = "0" ]
then
echo "- Ok"
echo ""
else
echo "- ERROR - Unpacking Motif src failed..."
exit 1
fi
fi
echo "- Installing Motif..."
module purge
module load Autoconf
module load GCC
module load make
module load X11
module load flex
cd ${DEST_DIR}/motif-2.3.8 && ./configure --prefix=${DEST_DIR}
# THe old Motif package has loads of bugs, here is one that stops it compiling:
# https://www.linuxquestions.org/questions/linux-enterprise-47/error-when-compling-motif-4175669180/
# https://bugs.gentoo.org/592868
# Inject "%option main" to the top of wmluiltok.l
# To fix the compile bug referenced above
grep "option main" tools/wml/wmluiltok.l 2>/dev/null
if [ "$?" = "0" ]
then
echo "- Already patched with compile fix..."
else
echo "- Adding compile fix patch..."
sed -i '1s/^/%option main\n /' tools/wml/wmluiltok.l
fi
make && make install
if [ "$?" = "0" ]
then
echo "- Ok"
echo ""
else
echo "- ERROR - installation failed..."
exit 1
fi
fi
else
echo "- ERROR - Cannot run Motif installation..."
exit 1
fi
############################################
# AFNI
############################################
echo "Downloading AFNI..."
cd ${DEST_DIR} ; wget -nc -q https://afni.nimh.nih.gov/pub/dist/tgz/afni_src.tgz -O ${DEST_DIR}/downloads/afni_src.tgz
if [ -s "${DEST_DIR}/downloads/afni_src.tgz" ]
then
if [ -s "${DEST_DIR}/bin/afni" ]
then
echo "- AFNI already installed at ${DEST_DIR}/bin/afni"
echo "- Ok"
echo ""
else
if [ -s "${DEST_DIR}/afni_src/Makefile.linux_openmp_64" ]
then
echo "- AFNI src already unpacked"
else
echo "- Unpacking AFNI src..."
cd ${DEST_DIR} && tar xfz ${DEST_DIR}/downloads/afni_src.tgz
if [ "$?" = "0" ]
then
echo "- Ok"
echo ""
else
echo "- ERROR - Unpacking AFI src failed..."
exit 1
fi
fi
echo "- Running AFNI installation..."
cd afni_src
module purge
module load GCC
module load make
module load X11
#module load motif
# The makefile is a bit broken.
# It has a hardcoded to call /usr/bin/gcc ...
# It has a non-standard parameter to gcc '-V'
cat Makefile.linux_openmp_64 | \
sed 's/\/usr\/bin\/gcc/gcc/g' | \
sed 's/\-V\ 34//g' > Makefile.rocket
make -f Makefile.rocket vastness
if [ "$?" = "0" ]
then
echo "- Ok"
echo ""
else
echo "- ERROR - installation failed..."
exit 1
fi
fi
else
echo "- ERROR - Cannot run AFNI installation..."
exit 1
fi
############################################
# Freesurfer
############################################
echo "Downloading Freesurfer (this takes a long time)..."
cd ${DEST_DIR} ; wget -nc -q https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer-linux-centos7_x86_64-7.4.1.tar.gz -O ${DEST_DIR}/downloads/freesurfer.tgz
if [ -s "${DEST_DIR}/downloads/freesurfer.tgz" ]
then
echo "- Running Freesurfer installation..."
if [ "$?" = "0" ]
then
echo "- Ok"
echo ""
else
echo "- ERROR - installation failed..."
exit 1
fi
else
echo "- ERROR - Cannot run Freesurfer installation..."
exit 1
fi
##########################################
# glibc_2.18 for deno
# deno has a dependency on >=glibc2.18 - which is
# newer than Rocket has. For Comet or other
# newer platforms, this is NOT needed.
##########################################
echo "Downloading glibc (for deno runtime)..."
cd ${DEST_DIR} ; wget -nc -q https://ftp.gnu.org/gnu/glibc/glibc-2.41.tar.gz -O ${DEST_DIR}/downloads/glibc-2.41.tar.gz
if [ -s "${DEST_DIR}/glibc-2.41.tar.gz" ]
then
if [ -s "${DEST_DIR}/lib/libc.so" ]
then
echo "- glibc is already installed at ${DEST_DIR}/lib/libc.so"
echo "- Ok"
echo ""
else
echo "- Running glibc installation..."
echo "- LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
echo "- PWD: `pwd`"
module purge
module load Python/3.11.3-GCCcore-12.3.0
module load CMake
module load Autoconf
module load Automake
module load GCC
module load make
tar xfz ${DEST_DIR}/downloads/glibc-2.41.tar.gz
cd ${DEST_DIR}/glibc-2.41
mkdir build
cd build
../configure --prefix=${DEST_DIR}/glibc
make -j4
make install
if [ "$?" = "0" ]
then
echo "- Ok"
echo ""
else
echo "- ERROR - installation failed..."
exit 1
fi
fi
else
echo "- ERROR - Cannot run glibc installation..."
exit 1
fi
##########################################
# deno
##########################################
echo "Downloading deno..." ; wget -nc -q https://github.com/denoland/deno/releases/download/v2.3.3/deno-x86_64-unknown-linux-gnu.zip -O ${DEST_DIR}/downloads/deno.zip
if [ -s "${DEST_DIR}/downloads/deno.zip" ]
then
if [ -x "${DEST_DIR}/bin/deno" ]
then
echo "- deno is already installed at ${DEST_DIR}/bin/deno"
echo "- Ok"
echo ""
else
echo "- Unzipping deno..."
cd ${DEST_DIR} && unzip ${DEST_DIR}/downloads/deno.zip && mv -fv ${DEST_DIR}/deno ${DEST_DIR}/bin/deno
chmod +x ${DEST_DIR}/bin/deno
if [ "$?" = "0" ]
then
echo "- Ok"
echo ""
else
echo "- ERROR - installation failed..."
exit 1
fi
fi
else
echo "- ERROR - Cannot unzip deno..."
exit 1
fi
##########################################
# bids-validator
###########################################
echo "Installing bids-validator..."
module purge
module load Python/3.11.3-GCCcore-12.3.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${DEST_DIR}/glibc
echo "- LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
pip3 install bids-validator-deno
if [ "$?" = "0" ]
then
echo "- Ok"
echo ""
else
echo "- ERROR - Cannot install bids-validator"
exit 1
fi
##########################################
# Connectome-workbench
##########################################
echo "Downloading connectome-workbench..."
cd ${DEST_DIR} ; wget -nc -q https://www.humanconnectome.org/storage/app/media/workbench/workbench-rh_linux64-v2.0.1.zip -O ${DEST_DIR}/downloads/workbench.zip
if [ -s "${DEST_DIR}/downloads/workbench.zip" ]
then
echo "- Running connectome-workbench installation..."
if [ "$?" = "0" ]
then
echo "- Ok"
echo ""
else
echo "- ERROR - installation failed..."
exit 1
fi
else
echo "- ERROR - Cannot run connectome-workbench installation..."
exit 1
fi