Configuring your shell

If you have used the FSL installer your shell will have already been setup for running the FSL tools. However, there are situations where you may need to carry out this configuration by hand, for example when installing FSL on a multi-user computer. How you do this will depend on what shell you are using (see what shell am I using?).

The instructions below will ask you to add lines of code to shell initialisation files. When doing this, make sure you are using a plain text editor, such as nano, gedit, or emacs. For example, if you are using the bash shell, you can edit the configuration file by typing nano ~/.bash_profile into a terminal.

Take Care

Modifying your locale globally (e.g. in .bash_profile) may result in issues with other scripts on your system - change with care!

BASH/zsh/sh/ksh

Depending on the shell you are using, the FSL configuration commands will need to be added to a specific file:

Shell

Configuration file

bash

~/.bash_profile

zsh

~/.zprofile

sh

~/.profile

ksh

~/.profile

To configure FSL, you need to edit (or create) this file to add the following lines:

# Change the value for FSLDIR if you have 
# installed FSL into a different location
FSLDIR=/usr/local/fsl
. ${FSLDIR}/etc/fslconf/fsl.sh
PATH=${FSLDIR}/bin:${PATH}
export FSLDIR PATH

csh/tcsh

User shell setup is stored in a file called .cshrc (csh and tcsh) or .tcsh (tcsh only) in your home folder (eg ~/.cshrc), you need to edit (or create) this file to add the following lines:

# Change the value for FSLDIR if you have 
# installed FSL into a different location
setenv FSLDIR /usr/local/fsl
source ${FSLDIR}/etc/fslconf/fsl.csh
setenv PATH ${FSLDIR}/bin:${PATH}

Customising FSL behaviour

You can change various aspects of FSL behaviour by using environment variables. You can find a list of all of the environment variables that FSL understands on this page.

When the FSL configuration commands in your shell profile are run, default settings are applied. You can override these default settings simply by specifying different values for the relevant environment variable.

Perhaps the easiest method for customising FSL is to add your custom variable values to your shell initialisation script (see above).

For example, if you are using the bash shell, and you wish to change the output file format of the FSL tools to uncompressed NIFTI images (.nii images, instead of the default .nii.gz), open ~/.bash_profile in a plain text editor, and change the FSL configuration lines to this:

# Change the value for FSLDIR if you have 
# installed FSL into a different location
FSLDIR=/usr/local/fsl
. ${FSLDIR}/etc/fslconf/fsl.sh
PATH=${FSLDIR}/bin:${PATH}
export FSLDIR PATH

# My custom values for FSL environment variables
export FSLOUTPUTTYPE=NIFTI

There are other places you could store your custom values for controlling FSL - look inside the $FSLDIR/etc/fslconf/fsl.sh file for more details.

System-wide setup

You have several options for automatically setting up FSL for all users on the computer, all beyond the scope of this document, but here are some suggestions on how you might go about this.

  1. Change the template used for new user accounts (look in /etc/skel on Linux or /System/Library/User Template/English.lproj/ on Mac OS X). New users will then get a suitably modified settings file.

  2. Store the settings in an NFS shared folder. You could ensure that the default settings file looks for and sources a settings file on an NFS server. This is useful for a compute cluster as you only have to edit one file to have it change everywhere.
  3. Modify the system-wide .profile or .cscrc file. On Mac OS X the files /etc/profile and /etc/csh.cshrc control this for all users, on Linux you can create files fsl.sh and fsl.csh in /etc/profile.d containing the settings. If you are using the fsl_installer.sh script then you can carry out this configuration by running the script with the -E option (Linux only).

Take Care

Be careful what you put in these files as you could stop people logging in!

Localisation problems

FSL programs generally require a period to be used as the decimal separator ( e.g. 10.4 0.235 etc ). If your environment is configured to use a different character such as a comma then this may cause problems. Two potential fixes are to change the LC_NUMERIC variable value by: (i) typing the following lines into a terminal locally each time you want to run FSL, or (ii) globally modifying all terminals by adding the following lines to the .bash_profile ( or equivalent ):

LC_NUMERIC=en_GB.UTF-8
export LC_NUMERIC
 

FslInstallation/ShellSetup (last edited 13:40:16 05-03-2021 by PaulMcCarthy)