-
Notifications
You must be signed in to change notification settings - Fork 5
/
main
executable file
·109 lines (90 loc) · 3.48 KB
/
main
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
#!/bin/bash
## stuff from jobheader.sh
#PBS -N qsiprep
set -x
set -e
export FREESURFER_LICENSE="hayashis@iu.edu 29511 *CPmh9xvKQKHE FSg0ijTusqaQc"
echo $FREESURFER_LICENSE > license.txt
bl2bids
WORKDIRNAME=$(pwd)/qsipworkdir
outdir=$(pwd)/output
resolution=$(jq -r .output_resolution config.json)
space=$(jq -r .output_space config.json)
template=$(jq -r .template config.json)
#sub=$(jq -r '._inputs[] | select(.id == "t1w") | .meta.subject' config.json)
sub=$(jq -r '._inputs[0].meta.subject' config.json)
dwi=$(jq -r .dwi config.json)
skipbidsvalidation=$(jq -r .skipbidsvalidation config.json)
denoise_method=$(jq -r .denoise_method config.json)
distortion_group_merge=$(jq -r .distortion_group_merge config.json)
unringing_method=$(jq -r .unringing_method config.json)
hmc_transform=$(jq -r .hmc_transform config.json)
infant=$(jq -r .infant config.json)
syn_sdc=$(jq -r .syn_sdc config.json)
force_syn=$(jq -r .force_syn config.json) #keep to be back compatible
check_flip_bvecs=$(jq -r .check_flip_bvecs config.json)
#reconall=$(jq -r .reconall config.json)
optional=""
if [[ $dwi == *","* ]]; then
echo "Multi dwi input found. Distortion group merge option: ${distortion_group_merge}";
optional="$optional --distortion-group-merge ${distortion_group_merge}";
fi
if [[ $space == "MNI152NLin2009cAsym" ]]; then
echo "Sampling T1w, brain mask, and parcellation/volume to MNI152NLin2009cAsym space.";
optional="$optional --template MNI152NLin2009cAsym";
fi
# boolean options
[ $skipbidsvalidation == "true" ] && optional="$optional --skip-bids-validation"
[ $infant == "true" ] && optional="$optional --infant"
[ $syn_sdc == "true" ] && optional="$optional --use-syn-sdc --force-syn"
#[ $reconall == "true" ] && optional="$optional --do-reconall"
# remove if stuff already exists
rm -rf $WORKDIRNAME && mkdir -p $WORKDIRNAME
rm -rf $outdir && mkdir -p $outdir
## EXPERIMENTAL: try to use freesufer input
## removing the following since it's not used in the preprocessing workflow
#inFSDIR=`jq -r '.fsin' config.json`
#
#if [[ $inFSDIR != "null" ]] ; then
#
# #clean up previous freesurfer dir if it exists
# rm -rf $outdir/freesurfer
# mkdir -p $outdir/freesurfer
#
# #TODO - strip alphanumeric chars?
# cp -rH $inFSDIR $outdir/freesurfer/sub-$sub
# chmod -R +rw $outdir/freesurfer
# #run reconall to get the fsaverage folder -
# #it should recognize though the folder just created
# if $reconall == "false"; then
# optional="$optional --do-reconall"
# fi
#fi
# avoid templateflow problems on HPC's running singularity
mkdir -p templateflow
export SINGULARITYENV_TEMPLATEFLOW_HOME=$PWD/templateflow
# set FreeSurfer
[ -z "$FREESURFER_LICENSE" ] && echo "Please set FREESURFER_LICENSE in .bashrc" && exit 1;
# check and flip bvecs if needed (actually not needed since qsiprep should check it)
#if [[ $check_flip_bvecs == "true" ]]; then
# echo "check if bvecs need to be flipped - flip them if necessary"
# ./check_and_flip_bvecs.sh
#fi
# QSIPrep
time singularity exec -e \
docker://pennbbl/qsiprep:0.14.2 \
/usr/local/miniconda/bin/qsiprep \
--fs-license-file license.txt \
--output-resolution $resolution \
--denoise-method $denoise_method \
--unringing-method $unringing_method \
--hmc-transform $hmc_transform \
--nthreads 8 \
--verbose \
--work-dir $WORKDIRNAME \
bids $outdir participant \
$optional
echo "done with qsiprep! - now organizing output"
./qsiprep2bl.sh
rm -r $WORKDIRNAME # save lots of space
echo "all done!"