From c4fa7cc48d57c59a8a6f19b188a2ccebfa5e0616 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Thu, 14 Jan 2021 14:09:46 +0000
Subject: [PATCH] RF: Clean up fsl.sh. Automatically add $FSLDIR/share/fsl/bin
 to $PATH if an official FSL installation is detected.

---
 etc/fslconf/fsl.sh | 70 +++++++++++++++++++++++++++++++++-------------
 1 file changed, 50 insertions(+), 20 deletions(-)

diff --git a/etc/fslconf/fsl.sh b/etc/fslconf/fsl.sh
index 3b90ac7..8f2ff43 100644
--- a/etc/fslconf/fsl.sh
+++ b/etc/fslconf/fsl.sh
@@ -1,6 +1,14 @@
 # FSL configuration file
 #  - to be sourced by the user, typically in .bashrc or equivalent
 #
+# $FSLDIR must be set before this script is called.
+#
+# Standard environment configuration for using FSL is:
+#   export FSLDIR=/usr/local/fsl
+#   source $FSLDIR/etc/fslconf/fsl.sh
+#
+# See fsl-devel.sh if you are a developer.
+#
 # Written by Mark Jenkinson
 #  FMRIB Analysis Group, University of Oxford
 
@@ -9,42 +17,64 @@
 
 #### Set up standard FSL user environment variables ####
 
+# If this is an official (fslinstaller-installed)
+# FSL installation, wrappers to FSL executables
+# will have been created in $FSLDIR/share/fsl/bin/
+# We add this to the $PATH, rather than adding
+# $FSLDIR/bin/ to the path, to avoid clobbering
+# the user's environment with other executalbes
+# that have been installed into $FSLDIR/bin/ (e.g.
+# python).
+#
+# The fslinstaller creates a file called
+# base_environment when it installs official
+# FSL installations.
+#
+# If this is a manually managed installation, it
+# is the user's responsibility to add $FSLDIR/bin
+# to the $PATH
+if [ -e $FSLDIR/share/fsl/base_environment ]; then
+  export PATH=$FSLDIR/share/fsl/bin:$PATH
+fi
+
 # The following variable selects the default output image type
-# Legal values are:  ANALYZE  NIFTI  NIFTI_PAIR  ANALYZE_GZ  NIFTI_GZ  NIFTI_PAIR_GZ
+# Legal values are:
+#   NIFTI
+#   NIFTI2
+#   NIFTI_PAIR
+#   NIFTI2_PAIR
+#   NIFTI_GZ
+#   NIFTI2_GZ
+#   NIFTI_PAIR_GZ
+#   NIFTI2_PAIR_GZ
+#
 # This would typically be overwritten in ${HOME}/.fslconf/fsl.sh if the user wished
-#  to write files with a different format
-FSLOUTPUTTYPE=NIFTI_GZ
-export FSLOUTPUTTYPE
+# to write files with a different format
+export FSLOUTPUTTYPE=NIFTI_GZ
 
 # Comment out the definition of FSLMULTIFILEQUIT to enable
-#  FSL programs to soldier on after detecting multiple image
-#  files with the same basename ( e.g. epi.hdr and epi.nii )
-FSLMULTIFILEQUIT=TRUE ; export FSLMULTIFILEQUIT
+# FSL programs to soldier on after detecting multiple image
+# files with the same basename ( e.g. epi.hdr and epi.nii )
+export FSLMULTIFILEQUIT=TRUE
 
 
 # The following variables specify paths for programs and can be changed
-#  or replaced by different programs ( e.g. FSLDISPLAY=open   for MacOSX)
-
-FSLTCLSH=$FSLDIR/bin/fsltclsh
-FSLWISH=$FSLDIR/bin/fslwish
+# or replaced by different programs
 
-export FSLTCLSH FSLWISH
+export FSLTCLSH=$FSLDIR/bin/fsltclsh
+export FSLWISH=$FSLDIR/bin/fslwish
 
 # The following variables are used for running code in parallel across
 #  several machines ( i.e. for FDT )
 
-FSLLOCKDIR=
-FSLMACHINELIST=
-FSLREMOTECALL=
-
-export FSLLOCKDIR FSLMACHINELIST FSLREMOTECALL
+export FSLLOCKDIR=
+export FSLMACHINELIST=
+export FSLREMOTECALL=
 
 # The following variables are used to configure CUDA capable queues - if you
 # are using Grid Engine then this queue will be used to enqueue tasks that
 # support execution on NVIDIA CUDA hardware.
-FSLGECUDAQ=cuda.q
-
-export FSLGECUDAQ
+export FSLGECUDAQ=cuda.q
 
 
 ###################################################
-- 
GitLab