-
Notifications
You must be signed in to change notification settings - Fork 3
/
chb-fs-old
executable file
·143 lines (110 loc) · 4.61 KB
/
chb-fs-old
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
#ensure 'getopts' works with 'source' command
OPTIND=1
G_VERSION="stable"
G_REVISION=""
Gb_revisionSet=0
G_SYNOPSIS="
NAME
chb-fs
SYNOPSIS
chb-fs [<version>] [<revision>]
ARGS
<version> (Default \"$G_VERSION\")
Source the FreeSurfer environment for the given version.
<revision> (No default)
Specify an optional revision of the version. This is only necessary when
multiple revisions of a given version exist, for example in the case of
the 'stable' version there might be revision '5.0.0', '5.1.0', and '5.2'
installed concurrently on the system. If the <revision> is not
specified, the environment will default to whatever has been configured
as the default revsion for a given version. This default will have been
setup by the system administrator.
DESCRIPTION
'chb-fs' is a simple script to easily source different environments
for FreeSurfer.
If called without any arguments, it will setup the current default
version of FreeSurfer for this system, which has been
configured here as \"$G_VERSION$G_REVISION\".
NB!
To have variables set by this script to be valid in the caller (i.e.
parent's scope), this script *must* be sourced and not executed. That
means instead of typing:
$>chb-fs stable
to setup the FreeSurfer stable enviroment, you have to type:
$>. chb-fs stable
note the dot '.' at the beginning! Without this dot, the specified
FreeSurfer environment will NOT be initialized.
HISTORY
May 30 2012
o Initial development.
Mar 05 2013
o Add logic for PICES local use.
"
function synopsis_show
{
# ARGS
# $1 in (opt) if passed, exit to shell
# passing code $1.
echo "USAGE:"
echo "$G_SYNOPSIS"
if (( $# == 1 )) ; then exit $1 ; fi
}
# This handles the following:
# -x : show help and exit
# 1st command ling arg : set G_VERSION
# if exist 2nd arg : set G_REVISION
# additional args : show help and exit
if (( $# <= 2 )) ; then
if [[ $1 == "-x" ]] ; then synopsis_show 1; fi
if (( ${#1} )) ; then G_VERSION=$1; fi
if (( $#==2 )) ; then G_REVISION=$2; fi
else
synopsis_show 1
fi
echo "version: $G_VERSION"
if [[ $G_VERSION == "dev" ]] ; then
echo "+----------+"
echo "| WARNING! |____________________________________________"
echo "+------------------------------------------------------+"
echo "| You have chosen the FreeSurfer developer version. |"
echo "| Be aware that this version of FreeSurfer might be |"
echo "| possibly unstable, with new and untested features. |"
echo "| The 'dev' version also changes without announcement. |"
echo "| |"
echo "| Do NOT use this version for production or analysis |"
echo "| work. |"
echo "| |"
echo "| Unless you are a developer writing FreeSurfer code |"
echo "| you probably don't want to use this. Use the |"
echo "| 'stable' version instead. |"
echo "+------------------------------------------------------+"
echo ""
fi
if (( ${#G_REVISION} )) ; then
echo "revision: $G_REVISION"
G_REVISION="-$G_REVISION" # This is because installs on the filesystem
# are <version>-<revision>.
else
echo "revision: -system default-"
fi
OS=$(uname -a | awk '{print $1}')
echo "Host type is $HOSTTYPE-${OS}"
# Check if we are on a PICES host (names start with 'rc')
RC=$(hostname | awk -F \- '{print $1}')
if [[ $RC == "rc" ]] ; then
export PACKAGEDIR=/chb/pices/arch/${HOSTTYPE}-${OS}/packages
else
export PACKAGEDIR=/chb/freesurfer/${HOSTTYPE}-${OS}/packages
fi
export FSL_DIR=${PACKAGEDIR}/fsl/current
export SUBJECTS_DIR=$(pwd)
source ${PACKAGEDIR}/freesurfer/${G_VERSION}${G_REVISION}/SetUpFreeSurfer.sh
source ${FSL_DIR}/etc/fslconf/fsl.sh
unset TCLLIBPATH
unset TCL_LIBRARY
unset TK_LIBRARY
unset TIX_LIBRARY
OS=$(uname -a | awk '{print $1}')
export PROMPTPREFIX="[$name:${HOSTTYPE}-${OS}-chb-fs-${G_VERSION}${G_REVISION}]"
export PATH=$PATH:/chb/freesurfer/${HOSTTYPE}-${OS}/packages/mricron:/chb/freesurfer/${HOSTTYPE}-${OS}/packages/dtk