-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun
More file actions
executable file
·73 lines (59 loc) · 1.96 KB
/
run
File metadata and controls
executable file
·73 lines (59 loc) · 1.96 KB
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
#! /bin/bash
#
# This script is meant to evoke th QA algorithm without requiring any input arguments
#
#
# Built to flywheel-v0 spec.
FLYWHEEL_BASE=/flywheel/v0
CONTAINER="[scitran/qa-dtiprep]"
# Configure the ENV
chmod +x /etc/fsl/5.0/fsl.sh
source /etc/fsl/5.0/fsl.sh
export PATH=$PATH:/opt/DTIPrepPackage
# Make sure that /output directory is empty (all content will be removed later).
OUTPUT_DIR=$FLYWHEEL_BASE/output
INPUT_DIR=$FLYWHEEL_BASE/input
INPUT_NIFTI=$INPUT_DIR/nifti
INPUT_BVEC=$INPUT_DIR/bvec
INPUT_BVAL=$INPUT_DIR/bval
if [ "-d" "$OUTPUT_DIR" ]
then
if [ "$(ls -A $OUTPUT_DIR)" ]; then
echo -e "$OUTPUT_DIR is not Empty! Please provide an empty directory and mount at '$OUTPUT_DIR'."
exit 1
fi
else
echo "$OUTPUT_DIR not found. It will be created."
mkdir $OUTPUT_DIR
fi
# Check if the inputs are empty.
# If so, show example usage and prompt for help
if [[ -z $@ ]]
then
dwi_nifti=`find $INPUT_NIFTI -type f -name "*.nii*" | head -1`
dwi_bvec=`find $INPUT_BVEC -type f -name "*.bvec*" | head -1`
dwi_bval=`find $INPUT_BVAL -type f -name "*.bval*" | head -1`
if [[ -n $dwi_nifti ]]
then
echo -e "$CONTAINER Starting DTIPrep..."
$FLYWHEEL_BASE/qa-dtiprep.py --nifti "$dwi_nifti" --bval "$dwi_bval" --bvec "$dwi_bvec" 2>&1 | tee $OUTPUT_DIR/dtiprep_log.txt
else
echo "No inputs were provided and $INPUT_DIR has no valid input files!"
exit 1
fi
else
$FLYWHEEL_BASE/qa-dtiprep.py $@
fi
# Get a list of the files in the output directory
find $OUTPUT_DIR -type f -name "*.nrrd" -exec rm {} \;
outputs=`find $OUTPUT_DIR -type f`
# If outputs exist, then go on...
if [[ -z $outputs ]]; then
echo "No results found in output directory... Exiting(1)"
exit 1
else
chmod -R 777 $OUTPUT_DIR
$FLYWHEEL_BASE/metadata_create.py $OUTPUT_DIR $CONTAINER
echo -e "$CONTAINER Success!"
fi
exit 0