-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundleFEAT
More file actions
executable file
·187 lines (142 loc) · 4.21 KB
/
bundleFEAT
File metadata and controls
executable file
·187 lines (142 loc) · 4.21 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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/sh
#
# Copyright (C) Eugene Duff 2013 University of Oxford
#
# SHCOPYRIGHT
Usage() {
function=`basename $0`
echo $function [options] featdir outputdir
echo Takes a FEAT directory and bundles all essential data of all levels of analysis into a single directory.
echo
echo -tar featdir outputdir - tar final directory into single file
echo -untar ouputdir newbasedir - untars directory and updates directory locations
echo
echo Requires setFEAT,cleanupFEAT,queryFEAT
exit 1
}
[ "$1" = "" ] && Usage
firstchar=`echo $1 | head -c 1`
while [[ $firstchar == '-' ]]
do
if [[ $1 == -tar ]]
then tar=1
else
tar=''
fi
if [[ $1 == -untar ]]
then untar=1
else
untar=''
fi
shift 1
firstchar=`echo $1 | head -c 1`
done
echo $1 $untar
if [[ $untar == 1 ]];
then
echo Extracting..
echo tar -xcf $1
tar -xvf $1
echo Refreshing output directories
oldoutput=`grep "feat_files(1)" design.fsf | grep -o \".*\" | sed 's/\"//g;s/[^\/]*feat//g'`
newoutput=`pwd`
for a in `find . -name design.fsf`;
do setFEAT $a $a -replace $oldoutput $newoutput
done
exit
fi
featdir=$1
outputdir=$2
if [ ! -e $featdir ];
then echo $outputdir does not exist!
exit
fi
if [[ $# == 2 ]];
then
echo Making copy of directory
if [ -e $outputdir ];
then echo $outputdir is already a directory!
exit
fi
cp -rL $featdir $outputdir
else outputdir=$featdir
fi
# backup old design file
designfile=$outputdir/design.fsf
cp $designfile $outputdir/design_orig.fsf
level=`queryFEAT $designfile -level`
fsfile=`cat $outputdir/design.fsf`
case $outputdir in
/*) outputfulldir=$outputdir ;;
~*) outputfulldir=$outputdir ;;
*) outputfulldir=`pwd`/$outputdir
esac
setFEAT $designfile $designfile -outputfulldir $outputdir
cnt=1
infiles=`grep feat_files $designfile | grep -o \".*\" | sed 's/\"//g'`
if [[ $level == 2 ]];
then
echo Copying input dirs
for b in $infiles;
do
newdir=$outputfulldir/input_$cnt.feat
echo Copying $b to $newdir
echo Bundling lower level directory $b as $newdir
bundleFEAT $b $newdir
setFEAT -i $designfile -replace $b $newdir
cleanupFEAT -r -thr $newdir
let cnt=$cnt+1
done
for c in threshmask; do
fsf_settings=`grep $c $designfile | grep -o \".*\" | sed 's/\"//g'`
if [[ ! $fsf_settings == '' ]];then
echo Copying and updating $c
fi
cnt=1
for d in $fsf_settings;do
newfile=$outputfulldir/${c}_${cnt}
if [ `imtest $d` == 1 ];
then imcp $d $newfile
else
imcp $d $newfile
fi
setFEAT -i $designfile -replace $d $newfile
let cnt=cnt+1
done
done
# copy design.fsf to cope.feat dirs
for copedir in $outputfulldir/cope*feat;do
cp $designfile $copedir;
done
else
for c in custom highres_files initial_highres init_highres unwarp_files unwarp_files_mag feat_files st_file motionevsbeta scriptevsbeta threshmask regstandard alternative_example_func alternative_mask init_initial_highres init_highres init_standard; do
fsf_settings=`grep $c $designfile | grep -o \".*\" | sed 's/\"//g'`
if [[ ! $fsf_settings == '' ]];then
echo Copying and updating $c
fi
cnt=1
for d in $fsf_settings;do
newfile=$outputfulldir/${c}_${cnt}
# copy file, testing if image and "_brain" image
echo $d
if [ `imtest $d` == 1 ] && [ ${d/_brain/} == ${d} ];
then imcp $d $newfile
elif [ `imtest $d` == 1 ];
then
imcp ${d/_brain/} $newfile
newfile=${newfile}_brain
imcp $d $newfile
else
cp $d $newfile
fi
setFEAT -i $designfile -replace $d $newfile
let cnt=cnt+1
done
done
fi
cleanupFEAT -r -thr $outputdir
if [[ ! $tar == '' ]]; then
echo Creating tar file
tar -cvf ${outputdir}.tar $outputdir
fi
# create rerun script