-
Notifications
You must be signed in to change notification settings - Fork 1
/
run
executable file
·89 lines (67 loc) · 2.25 KB
/
run
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
#! /bin/bash
#
#
CONTAINER="[vistalab/dwi-flip-bvec]"
echo -e "$CONTAINER Initiated"
# Built to flywheel-v0 spec.
FLYWHEEL_BASE=/flywheel/v0
MCR_ROOT=/opt/mcr/v92/
OUTPUT_DIR=$FLYWHEEL_BASE/output
# Make sure that /output directory exists
if [[ ! -d "$OUTPUT_DIR" ]]
then
echo "$CONTAINER $OUTPUT_DIR not found!"
exit 1
fi
# Set paths to input files
bvecFile=$(find $FLYWHEEL_BASE/input/bvec/ -type f -name "*.bvec*")
CONFIG_FILE=${FLYWHEEL_BASE}/config.json
# Check for required inputs
if [[ -z "$bvecFile" ]]; then
echo -e "$CONTAINER Bvec input file not found! Exiting!"
exit 1
fi
# Parse Config File
if [[ -f $CONFIG_FILE ]]; then
# Parse config from config.json
echo -e "$CONTAINER Loading configuration from ${CONFIG_FILE}"
xFlip=$(cat $CONFIG_FILE | jq -r '.config.xFlip')
yFlip=$(cat $CONFIG_FILE | jq -r '.config.yFlip')
zFlip=$(cat $CONFIG_FILE | jq -r '.config.zFlip')
echo "$CONTAINER xFlip has been set to $xFlip"
echo "$CONTAINER yFlip has been set to $yFlip"
echo "$CONTAINER zFlip has been set to $zFlip"
else
# Parse defaults from the manifest.json
CONFIG_FILE=$FLYWHEEL_BASE/manifest.json
echo -e "$CONTAINER Loading defaults from ${CONFIG_FILE}"
xFlip=$(cat $CONFIG_FILE | jq -r '.config.xFlip.default')
yFlip=$(cat $CONFIG_FILE | jq -r '.config.yFlip.default')
zFlip=$(cat $CONFIG_FILE | jq -r '.config.zFlip.default')
echo "$CONTAINER xFlip has been set to $xFlip"
echo "$CONTAINER yFlip has been set to $yFlip"
echo "$CONTAINER zFlip has been set to $zFlip"
fi
# Run the Matlab executable
time /msa/run_dwiflipbvec.sh "${MCR_ROOT}" "${bvecFile}" "${xFlip}" "${yFlip}" "${zFlip}" "${OUTPUT_DIR}"
# Check exit status
exit_status=$?
if [[ $exit_status != 0 ]]; then
echo -e "$CONTAINER An error occurred during execution of the Matlab executable. Exiting!"
exit 1
fi
# Get a list of the files in the output directory
outputs=$(find $OUTPUT_DIR/* -maxdepth 0 -type f)
# If outputs exist, generate metadata, and exit
if [[ -z $outputs ]]; then
echo "$CONTAINER No results found in output directory... Exiting"
exit 1
else
cd $OUTPUT_DIR
echo -e "$CONTAINER Wrote: `ls`"
echo -e "$CONTAINER Done!"
fi
# Handle permissions of the outputs
chmod -R 777 $OUTPUT_DIR
# Exit
exit 0