-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_grid.sh
executable file
·47 lines (35 loc) · 1.34 KB
/
run_grid.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
#!/bin/bash
if [ "$1" == "-h" -o "$1" == "--help" -o "$1" == "" ]; then
echo -e "\n Usage: `basename $0` grid (.mnc or .nii) [suffix_str] [alpha]"
echo -e "\n Runs 'my_MincLaplaceDist' on the given grid."
echo -e "\n Returns '_grid_123.nii.gz' & '_grid_123.mnc'.\n"
exit 0
fi
input_grid=$1
suffix=${2:-''}
alpha=${3:-0.1}
# String before patern '_grid'
outputname=${input_grid%_grid*}_minc${suffix}
filename="${input_grid%.*}"
#extension="${input_grid##*.}"
#if [ ${input_grid: -4} == ".nii" ]
if [ -f ${outputname}_RGB.nii.gz ]
then
echo -e "\n '${outputname}_RGB.nii.gz' already exists \n"
exit 1
fi
if [ ! -f ${filename}.mnc ] # if input isn't .mnc
then
echo -e "\n Converting '$input_grid' to .mnc format \n"
nii2mnc ${filename}.nii
fi
echo -e "\n Creating grid: '${outputname}' \n"
my_mincL=`dirname $0`"/my_MincLaplaceDist"
$my_mincL -i ${filename}.mnc -o ${outputname} -like ${filename}.mnc -alpha $alpha
echo "alpha weight = " $alpha
mnc2nii ${outputname}_GradX.mnc ${outputname}_GradX.nii
mnc2nii ${outputname}_GradY.mnc ${outputname}_GradY.nii
mnc2nii ${outputname}_GradZ.mnc ${outputname}_GradZ.nii
mrcat ${outputname}_GradX.nii ${outputname}_GradY.nii ${outputname}_GradZ.nii ${outputname}_RGB.nii.gz
gzip ${outputname}_GradX.nii; gzip ${outputname}_GradY.nii; gzip ${outputname}_GradZ.nii
gio trash ${outputname}_Grad*.mnc