forked from BIC-MNI/mni_autoreg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_model.in
153 lines (130 loc) · 3.92 KB
/
make_model.in
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#! /bin/sh
# This script is used to create the blurred intensity and gradient
# volumes needed to make up the volumetric features for a general
# set of model files needed for fitting with mritotal and nlfit.
#
# All model files MUST be voxel-matched to _mask.mnc volume
#
# Before running this script, the mni_autoreg package should be
# installed.
# get program name
me=`basename $0`
MINC_COMPRESS_ORIG=${MINC_COMPRESS}
# check args
if [ $# -eq 0 ] ; then
echo "usage: $me <base_filename>"
echo " $me -version"
echo ""
exit 1
fi
if [ $1 = "-version" ];
then
echo "Package @PACKAGE_NAME@, version @VERSION@"
echo ""
exit 0
fi
BASE=$1
echo "Using base filename $BASE"
echo "Note that your input volume *must* be in Talairach space for this to work"
# check for the input files
HIRES=$BASE.mnc
if [ ! -e $HIRES ];
then
echo "Couldn't find input volume $HIRES"
echo ""
exit 1
fi
# subsample and pad onto a 2mm volume
PAD=${BASE}_pad.mnc
if [ -e $PAD ];
then
echo "$PAD exists already..."
else
echo "** Making $PAD from $HIRES by resampling on 2mm grid and padding by 16mm"
export MINC_COMPRESS=0
autocrop -clobber $HIRES $PAD -isostep 2 -isoexpand 16mm
export MINC_COMPRESS=${MINC_COMPRESS_ORIG}
fi
# build the 16mm FWHM feature volumes.
BLURBASE=${BASE}_16
BLUR=${BLURBASE}_blur.mnc
MASK=${BLURBASE}_mask.mnc
if [ -e $BLUR -a -e $MASK ];
then
echo "$BLUR and $MASK exist already..."
else
echo "** Building 16mm data for $BASE"
export MINC_COMPRESS=0
mincblur -clobber $PAD tmp_16 -fwhm 16.0
autocrop -clobber tmp_16_blur.mnc $BLUR -extend -16mm,-16mm -16mm,-16mm -36mm,-36mm
export MINC_COMPRESS=${MINC_COMPRESS_ORIG}
mincresample -clobber -nearest ${BASE}_mask.mnc ${MASK} -like ${BLUR}
rm -f tmp_16*
fi
# build the 8mm FWHM feature volumes.
BLURBASE=${BASE}_8
BLUR=${BLURBASE}_blur.mnc
GRAD=${BLURBASE}_dxyz.mnc
MASK=${BLURBASE}_mask.mnc
if [ -e $BLUR -a -e $GRAD -a -e $MASK ];
then
echo "$BLUR, $GRAD, and $MASK exist already..."
else
echo "** Building 8mm data for $BASE"
export MINC_COMPRESS=0
mincblur -clobber $PAD tmp_8 -fwhm 8.0 -gradient
autocrop -clobber tmp_8_blur.mnc $BLUR -extend -16mm,-16mm -16mm,-16mm -26mm,-26mm
autocrop -clobber tmp_8_dxyz.mnc $GRAD -extend -16mm,-16mm -16mm,-16mm -26mm,-26mm
export MINC_COMPRESS=${MINC_COMPRESS_ORIG}
mincresample -clobber -nearest ${BASE}_mask.mnc ${MASK} -like ${BLUR}
rm -f tmp_8*
fi
# pad by 4mm
PAD4=${BASE}_pad4.mnc
if [ -e $PAD4 ];
then
echo "$PAD4 exists already..."
else
echo "** Making $PAD4 from $HIRES by padding by 4mm"
export MINC_COMPRESS=0
autocrop -clobber $HIRES $PAD4 -isoexpand 4mm
export MINC_COMPRESS=${MINC_COMPRESS_ORIG}
fi
# build the 4mm FWHM feature volume
BLURBASE=${BASE}_4
BLUR=${BLURBASE}_blur.mnc
GRAD=${BLURBASE}_dxyz.mnc
MASK=${BLURBASE}_mask.mnc
if [ -e $BLUR -a -e $GRAD -a -e $MASK ];
then
echo "$BLUR, $GRAD, and $MASK exist already..."
else
echo "** Building 4mm data for $BASE"
export MINC_COMPRESS=0
mincblur -clobber $PAD4 tmp_4 -fwhm 4.0 -gradient
autocrop -clobber tmp_4_blur.mnc $BLUR -isoexpand -9mm
autocrop -clobber tmp_4_dxyz.mnc $GRAD -isoexpand -9mm
export MINC_COMPRESS=${MINC_COMPRESS_ORIG}
mincresample -clobber -nearest ${BASE}_mask.mnc ${MASK} -like ${BLUR}
rm -f tmp_4*
fi
# build the 2mm FWHM feature volume
BLURBASE=${BASE}_2
BLUR=${BLURBASE}_blur.mnc
GRAD=${BLURBASE}_dxyz.mnc
MASK=${BLURBASE}_mask.mnc
if [ -e $BLUR -a -e $GRAD -a -e $MASK ];
then
echo "$BLUR, $GRAD, and $MASK exist already..."
else
echo "** Building 2mm data for $BASE"
export MINC_COMPRESS=0
mincblur -clobber $PAD4 tmp_2 -fwhm 2.0 -gradient
autocrop -clobber tmp_2_blur.mnc $BLUR -isoexpand -7mm
autocrop -clobber tmp_2_dxyz.mnc $GRAD -isoexpand -7mm
export MINC_COMPRESS=${MINC_COMPRESS_ORIG}
mincresample -clobber -nearest ${BASE}_mask.mnc ${MASK} -like ${BLUR}
rm -f tmp_2*
fi
# cleanup temporary files
rm -f $PAD $PAD4