-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_process.sh
executable file
·60 lines (52 loc) · 1.39 KB
/
run_process.sh
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
#!/bin/bash
#
# This is a wrapper to processing scripts, that loops across subjects.
#
# Usage:
# ./run_process.sh <script>
#
# Example:
# ./run_process.sh prepare_data.sh
#
# Note:
# Make sure to edit the file parameters.sh with the proper variables.
#
# NB: add the flag "-x" after "!/bin/bash" for full verbose of commands.
# Julien Cohen-Adad 2019-03-13
# Exit if user presses CTRL+C (Linux) or CMD+C (OSX)
trap "echo Caught Keyboard Interrupt within script. Exiting now.; exit" INT
# Initialization
unset SUBJECTS
time_start=$(date +%x_%r)
# Load config file
if [ -e "parameters.sh" ]; then
source parameters.sh
else
printf "\n${Red}${On_Black}ERROR: The file parameters.sh was not found. You need to create one for this pipeline to work. Please see README.md.${Color_Off}\n\n"
exit 1
fi
# build syntax for process execution
PATH_PROCESS=`pwd`/$1
# Create results folder
if [ ! -d ${PATH_RESULTS} ]; then
mkdir ${PATH_RESULTS}
fi
# Loop across subjects
for subject in ${SUBJECTS[@]}; do
# Display stuff
echo "Processing subject: ${subject}"
# go to subject folder
cd ${PATH_DATA}/${subject}/${SUBFOLDER}
# create processing folder
if [ ! -d ${FOLDER_PROC} ]; then
mkdir ${FOLDER_PROC}
fi
# go to processing folder
cd ${FOLDER_PROC}
# run process
$PATH_PROCESS ${subject}
done
# Display stuff
echo "FINISHED :-)"
echo "Started: $time_start"
echo "Ended : $(date +%x_%r)"