Tips & Tricks
Setup bash shell environment
Mac:
Change default shell from zsh to bash: chsh -s /bin/bash
Edit .bash_profile in the home folder: nano ~/.bash_profile
Linux: edit .bashrc
Use the following to create shortcut for usual command in bash:
alias my_shortcut='ssh -Y username@cluster.uq.edu.au'
Troubleshot AFNI on Mac
If you get the error message below when running AFNI:
dyld: Library not loaded: /usr/local/lib/libgcc_s.1.dylib
Just add the following setting in .bash_profile
export DYLD_FALLBACK_LIBRARY_PATH=/path/afni
export DYLD_LIBRARY_PATH=/opt/X11/lib/flat_namespace
Update AFNI
@update.afni.binaries -d
Install ANTs
Download the pre-compiled binary (ver 2.1.0) for Mac, Linux or Windows
Create a folder "ants" in your home path
Move the extracted "bin" folder to "ants"
Add the following to your bash setup file
export ANTSPATH=${HOME}/ants/bin
export PATH=${ANTSPATH}:$PATH
Compile ANTs on Mac
Follow the instructions here to install tools and ANTs source codes.
Before running ccmake, update CMake to version > 3.10 using:
brew upgrade cmake
Homebrew doesn't update the link to the new version so have to do it manually:
rm /usr/local/bin/cmake /usr/local/bin/ccmake
ln -s /usr/local/Cellar/cmake/[Version Number]/bin/cmake /usr/local/bin/cmake
ln -s /usr/local/Cellar/cmake/[Version Number]/bin/ccmake /usr/local/bin/ccmake
Speedup FSL
Parallelize FSL: here is a customized installation to make use of multi-core.
Here has some useful tricks to speed it up without cluster engine, such as:
Use faster zlib to speedup data compression:
Get optimized zlib code: git clone https://github.com/cloudflare/zlib.git
cd zlib
./configure
make test
make install
Use a customized fsl_sub to automatically make use of multi-core for commands that can run on grid without the need to install a grid engine.
Recompile FSL to make use of your latest CPU features
Install FSL or AFNI in Windows without virtual machine
Windows 10 has native support for Linux as a subsystem, called Windows Linux Subsystem (WLS). Follow this instruction to enable this function
Install the latest Linux distribution (Ubuntu) directly from Microsoft App Store.
Here is a comprehensive guide to install AFNI or FSL in WLS.
Here are FAQ on how to access Windows folder from WLS
For FSL 6, follow the very clear instructions on FSL website, including the X Windows server for GUI.
FSL is ready to use!
Your data stored in C:\ drive under Windows can be accessed at /mnt/c/Users/account_name
To use FSLview
install libmng:
sudo apt-get install libmng2
sudo ln -s /usr/lib/x86_64-linux-gnu/libmng.so.2 /usr/lib/x86_64-linux-gnu/libmng.so.1
install libjpeg
sudo apt-get install libjpeg-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so.8 /usr/lib/x86_64-linux-gnu/libjpeg.so.62
install libpng: follow this guide
type fslview_deprecated to run fslview
To use FSLeyes
reinstall fsleyes:
sudo /usr/local/fsl/fslpython/bin/conda install -c conda-forge fsleyes
Start the X Window server using "One large window" mode, instead of "Multiple window" mode. Alternatively, try Multiple window mode but disable the "Native opengl" option. Otherwise, there will be error like:
The program 'fsleyes' received an X Window System error.
This probably reflects a bug in the program.
The error was 'GLXBadContext'.
type fsleyes
Install ANTs
Install pre-compiled version from https://github.com/ANTsX/ANTs/releases/tag/v2.1.0
Note: Recommend to install the linux version on Windows using the WLS. That allows fully streamlined pipeline with FSL and AFNI on Windows.
Edit the startup file to add ANTs to the path. In Mac, type 'nano .bash_profile'. In Linux, type 'nano .bashrc'.
export ANTSPATH=${HOME}/ants/bin (or where you installed ANTs)
export PATH=${ANTSPATH}:$PATH
Run SPM on Matlab for Apple Silicon M1/M2
SPM doesn't recognize MEX file (*.mexmaca64) needed for ARM64 Matlab. So first need to compile MEX files. Go to the SPM path, eg, $HOME/spm12/src
set up Matlab command path: export PATH=/Applications/MATLAB_R2023b.app/bin:$PATH
compile MEX file: make distclean && make && make install
copy the compiled MEX to spm12 folder: mv *.mexmaca64 ../
edit spm_platform.m to make SPM recognize Mac's ARM64 CPU by replacing 'MACI64' with 'MACA64'
now you can run spm.
Compile with openmp support on MacOS (Apple Silicon)
brew install gcc llvm libomp
Follow this to add path into the CMakeList.txt file.
Run cmake by specifying gcc as the compiler:
cmake -D CMAKE_C_COMPILER=/opt/homebrew/opt/gcc/bin/gcc-14 -D CMAKE_CXX_COMPILER=/opt/homebrew/opt/gcc/bin/g++-14
Note:
To avoid error "Could NOT find Threads (missing: Threads_FOUND)", follow this to add commands into the CMakeList.txt file.