-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueryFEAT
executable file
·698 lines (499 loc) · 20.7 KB
/
queryFEAT
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
#!/bin/sh
#
# Copyright (C) Eugene Duff 2004 University of Oxford
#
# SHCOPYRIGHT
Usage() {
function=`basename $0`
echo Command-line visualisation of FSL design .\*fsf files
echo
echo $function inputfsffile -option optionparam [-option optionparam]
echo $function fsffiles -i fsffiles -option optionparam [-option optionparam] \*\* Replaces existing files
echo
echo -featwatcher x - set featwatcher off \(0\) or on \(1\)
echo -replace x y - basic global replace x with y \( e.g. Subj10/run2 Subj11/run3 \)
echo -analysis x - analysis type \(0 - reg/group 7 - full 1 - pre-stats 2 - stats 3 stats+post 4 post\)
echo -overwrite x - overwrite old dir 0 - yes 1 - no
echo -B0 x - B0 correction? 0 - no 1 - yes
echo -EPIes x - EPI echo spacing?
echo -EPIte x - EPI TE?
echo -structural x - sets structural image
echo -outputdir x \( level directory only \)
echo -outputfulldir x
echo -inputdirs x \(not working\)
echo -inputfulldir x y - sets input x
echo -smooth x - sets spatial smooth levels
echo -hpfilteron x - set highpass filter on/off \(1/0\)
echo -hpfilter x - set highpass filter to x
echo -motion x - add motion parameters to model
echo -confoundevs x - add confound evs file to model
echo -hilev x - sets high level analysis to x \(3 - FE, 0 - ME OLS, 1 - ME FLAME, 2 - ME FLAME 1+2 \)
echo -level x - first level \(1\) or higher-level \(2\)?
echo -outlier x - sets FLAME outlier detection
echo -highresdof x
echo -set FEAT watcher x
echo -MELODIC x
echo
echo -nevs_orig x - sets number of original EVs
echo -nevs_real x - sets number of real EVs
echo -tf x y temporal filtering for ev x on/off \(1/0\)
echo -td x y temporal derivative for ev x on/off \(1/0\) \(does not update contrasts\)
echo -evshape x y set shape of ev x to y 0: square 1: sinusoid 2: Custom \(1 entry per vol\) 3: Custom \(3 col\) 4: interaction 10: zeros
echo -evcustom x set custom ev filename
echo -evcustomfulldir x set custom ev full file location
echo -evconv x y set ev convolution 0-none 1-Gauss 2-gamma 3-dbl gamma 4-gamma basis
echo -evval x y z set higher level EV x val for input y to z
echo -evorth x y z orthogonalise ev x wrt y?
echo -evname x y set title for EV x to y
echo -evskip x y skip ev x in web report on/off \(1/0\)
echo
echo -ncontrasts_orig x - sets number of original contrasts
echo -ncontrasts_real x - sets number of real contrasts
echo -contrast_mode x - sets contrast mode real/orig
echo -contrast_orig x y z
echo -contrast_real x y z
echo -contrast_orig_name x y
echo -contrast_real_name x y
echo -contrast_orig_show x y
echo -contrast_real_show x y
echo
echo -FNIRT x - sets FNIRT nonlinear reg on/off \(1/0\)
echo -FNIRTwarpres x
echo -bgim x - sts background image 1- mean highres 2 - first highres 3 - mean functional 4 - first functional 5 -std space
echo -alt_example_func x - sets alternative example_func
exit
}
shiftpos() {
eval "pos=`echo $pos+1 | bc`"
}
[ "$1" = "" ] && Usage
firstchar=`echo $1 | head -c 1`
if [[ $firstchar == '-' ]]
then shift
firstchar=`echo $1 | head -c 1`
while [[ $firstchar != '-' ]] && [[ $firstchar != '' ]]
do inputdirs="$inputdirs $1"
shift
firstchar=`echo $1 | head -c 1`
done
outputdirs=$inputdirs
else inputdirs=$1
shift
fi
opts=$@
fsffile=`tmpnam`
cnt=1;
for input in $inputdirs;
do
cp $input $fsffile
fsffile=`cat $fsffile`
outfsffile=`echo $outputdirs | awk '{print $'$cnt'}'`
cnt=`echo $cnt + 1 | bc`
tempname=`tmpnam`
pos=1;
pos2=2;
pos3=3;
pos4=4;
in1=$(echo $opts | awk '{ print $'$pos'}')
in2=$(echo $opts | awk '{ print $'$pos2'}')
in3=$(echo $opts | awk '{ print $'$pos3'}')
in4=$(echo $opts | awk '{ print $'$pos4'}')
while [[ $in1 != '' ]]; do
if [[ $in1 == '-replace' ]]
then
# convert "/"
old=$(echo $in2 | sed 's/\//\\\//g')
new=$(echo $in3 | sed 's/\//\\\//g')
fsffile=$(echo "$fsffile" | grep "'$old'" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-hilev' ]]
then fsffile=$(echo "$fsffile" | grep "mixed_yn) [0123]" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-hilevel' ]]
then
fsffile=$(echo "$fsffile" | grep "mixed_yn) [0123]" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-level' ]]
then
fsffile=$(echo "$fsffile" | grep "level) [0123]" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-FNIRT' ]]
then
fsffile=$(echo "$fsffile" | grep "regstandard_nonlinear_yn) [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-FNIRTwarpres' ]]
then
fsffile=$(echo "$fsffile" | grep "regstandard_nonlinear_warpres) [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-highresdof' ]]
then
fsffile=$(echo "$fsffile" | grep "reghighres_dof) ." | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-bgim' ]]
then
fsffile=$(echo "$fsffile" | grep "bgimage) ." | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-FEATwatcher' ]]
then
fsffile=$(echo "$fsffile" | grep "watcher_yn) [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-MELODIC' ]]
then
fsffile=$(echo "$fsffile" | grep "melodic_yn) [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-nevs_orig' ]]
then
# determine original number of
fsffile=$(echo "$fsffile" | grep "evs_orig) [0-9].*" | grep -o "[^ ]*$")
npts=`echo "$fsffile" | grep -o 'npts).*' | sed 's/npts) //'`
for a in `seq $in2`; do
# Check if EVs exist
if echo "$fsffile" | grep -q "EV $a title" ;
# If exist, add extra bits
then
# Set orthogonalisation, EB
for b in `seq $in2`;do
# Check if orth exists:
if echo "$fsffile" | grep -q "ortho$a.$b)" ;
then :
else
txt=$txt"# Orthogonalise EV $a wrt EV $b\n\n"
txt=$txt" set fmri(ortho$a.$b) 0\n\n"
fi
done
# figure out where to put info
if echo "$fsffile" | grep -q "fmri(evg.*\.$a)" ;
then
lineno=`echo "$fsffile" | grep -n "evg.*\.$a)" | tail -n 1 | sed 's/:.*//'`
else
lineno=`echo "$fsffile" | wc -l | sed 's/ .*//'`
fi
fsffile=$(echo "$fsffile" | sed ''$lineno'a '"$txt"'')
txt=''
# Set EV values to 0
for b in `seq $npts`;do
# Check if EV exists
if echo "$fsffile" | grep -q "fmri(evg$b.$a)" ;
then :
else
txt=$txt"# Higher-level EV value for EV $a and input $b\n\n"
txt=$txt"set fmri(evg$b.$a) 0\n\n"
fi
done
# figure out where to put info
if echo "$fsffile" | grep -q "fmri(evg.*\.$a)" ;
then
lineno=`echo "$fsffile" | grep -n "evg.*\.$a)" | tail -n 1 | sed 's/:.*//'`
else
lineno=`echo "$fsffile" | wc -l | sed 's/ .*//'`
fi
if [[ $txt != '' ]]
then fsffile=$(echo "$fsffile" | sed ''$lineno'a '"$txt"'')
fi
else
# If not exist create extra orthogonalisation files
txt=$txt" # EV $a title\n"
txt=$txt" set fmri(evtitle$a) \"\"\n"
txt=$txt"\n"
txt=$txt" # Basic waveform shape (EV $a)\n"
txt=$txt" # 0 : Square\n"
txt=$txt" # 1 : Sinusoid\n"
txt=$txt" # 2 : Custom (1 entry per volume)\n"
txt=$txt" # 3 : Custom (3 column format)\n"
txt=$txt" # 4 : Interaction\n"
txt=$txt" # 10 : Empty (all zeros)\n"
txt=$txt" set fmri(shape$a) 2\n"
txt=$txt"\n"
txt=$txt" # Convolution (EV $a)\n"
txt=$txt" # 0 : None\n"
txt=$txt" # 1 : Gaussian\n"
txt=$txt" # 2 : Gamma\n"
txt=$txt" # 3 : Double-Gamma HRF\n"
txt=$txt" # 4 : Gamma basis functions\n"
txt=$txt" # 5 : Sine basis functions\n"
txt=$txt" # 6 : FIR basis functions\n"
txt=$txt" set fmri(convolve$a) 2\n"
txt=$txt"\n"
txt=$txt" # Convolve phase (EV $a)\n"
txt=$txt" set fmri(convolve_phase$a) 0\n"
txt=$txt"\n"
txt=$txt" # Apply temporal filtering (EV $a)\n"
txt=$txt" set fmri(tempfilt_yn$a) 0\n"
txt=$txt"\n"
txt=$txt" # Add temporal derivative (EV $a)\n"
txt=$txt" set fmri(deriv_yn$a) 0\n"
txt=$txt"\n"
txt=$txt" # Custom EV file (EV $a)\n"
txt=$txt" set fmri(custom$a) \"dummy\"\n"
txt=$txt"\n"
# Set orthogonalisation, EB
for b in `seq $in2`;do
txt=$txt"# Orthogonalise EV $a wrt EV $b\n\n"
txt=$txt" set fmri(ortho$a.$b) 0\n\n"
done
# figure out where to put info
lastev=`echo $a-1 | bc`
if echo "$fsffile" | grep -q "fmri(evg.*\.$lastev)" ;
then
lineno=`echo "$fsffile" | grep -n "evg.*\.$lastev)" | tail -n 1 | sed 's/:.*//'`
elif echo "$fsffile" | grep -q "confoundevs" ;
then
lineno=`echo "$fsffile" | grep -n "confoundevs" | tail -n 1 | sed 's/:.*//'`
else
lineno=`echo "$fsffile" | wc -l | sed 's/ .*//'`
fi
fsffile=$(echo "$fsffile" | sed ''$lineno'a '"$txt"'')
fi
txt=''
# Set EV values to 0
for b in `seq $npts`;do
txt=$txt"# Higher-level EV value for EV $a and input $b\n\n"
txt=$txt"set fmri(evg$b.$a) 0\n\n"
done
# figure out where to put info
lastev=`echo $a-1 | bc`
if echo "$fsffile" | grep -q "fmri(evg.*\.$lastev)" ;
then
lineno=`echo "$fsffile" | grep -n "evg.*\.$lastev)" | tail -n 1 | sed 's/:.*//'`
elif echo "$fsffile" | grep -q "confoundevs" ;
then
lineno=`echo "$fsffile" | grep -n "confoundevs" | tail -n 1 | sed 's/:.*//'`
else
lineno=`echo "$fsffile" | wc -l | sed 's/ .*//'`
fi
fsffile=$(echo "$fsffile" | sed ''$lineno'a '"$txt"'')
echo $fsffile;shiftpos
done
elif [[ $in1 == '-analysis' ]]
then
fsffile=$(echo "$fsffile" | grep "analysis) ." | grep -o "[^ ]*$")
if [[ $in2 == '1' ]];
then fsffile=$(echo "$fsffile" | grep "stats_yn) ." | grep -o "[^ ]*$")
fi
echo $fsffile;shiftpos
elif [[ $in1 == '-featwatcher' ]]
then
fsffile=$(echo "$fsffile" | grep "featwatcher_yn) ." | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-overwrite' ]]
then
fsffile=$(echo "$fsffile" | grep "newdir_yn) ." | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-B0' ]]
then
fsffile=$(echo "$fsffile" | grep "regunwarp_yn) ." | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-EPIes' ]]
then
fsffile=$(echo "$fsffile" | grep "dwell) .*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-EPIte' ]]
then
fsffile=$(echo "$fsffile" | grep "(te) .*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-nevs_real' ]]
then
fsffile=$(echo "$fsffile" | grep "evs_real) [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-td' ]]
then
fsffile=$(echo "$fsffile" | grep "deriv_yn'$in2') [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-tf' ]]
then
fsffile=$(echo "$fsffile" | grep "tempfilt_yn'$in2') [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-evskip' ]]
then
fsffile=$(echo "$fsffile" | grep "skip'$in2') [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-evshape' ]]
then
fsffile=$(echo "$fsffile" | grep "shape'$in2') [0-9].*" | grep -o "[^ ]*$")
# if 2 or 3, check if need to add lines to file
if [[ $in3 == 2 ]] || [[ $in3 == 3 ]]
then
if echo "$fsffile" | grep -q "custom$in2)" ;
then
txt=''
else
txt=$txt"# Custom EV file (EV $in2)\n\n"
txt=$txt"set fmri(custom$2) \"\""
# figure out where to put info
if echo "$fsffile" | grep -q "deriv_yn$2)" ;
then
lineno=`echo "$fsffile" | grep -n "deriv_yn$2)" | tail -n 1 | sed 's/:.*//'`
else
lineno=`echo "$fsffile" | wc -l | sed 's/ .*//'`
fi
echo $lineno
fsffile=$(echo "$fsffile" | sed ''$lineno'a '"$txt"'')
fi
fi
echo $fsffile;shiftpos
elif [[ $in1 == '-evname' ]]
then
fsffile=$(echo "$fsffile" | grep "evtitle'$in2') ".*"" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-evcustom' ]]
then
newdir=$(echo $in3 | sed 's/\//\\\//g')
fsffile=$(echo "$fsffile" | sed 's/custom'$in2') "\(.*\)"/custom'$in2') "\1\/'$newdir'"/g')
echo $fsffile;shiftpos
elif [[ $in1 == '-evcustomfulldir' ]]
then
newdir=$(echo $in3 | sed 's/\//\\\//g')
fsffile=$(echo "$fsffile" | grep "custom'$in2') ".*"" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-evval' ]]
then
fsffile=$(echo "$fsffile" | grep "evg'$in3'.'$in2') [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-evconv' ]]
then
fsffile=$(echo "$fsffile" | grep "convolve'$in2').*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-evorth' ]]
then
fsffile=$(echo "$fsffile" | grep "ortho'$in2'.'$in3') [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-contrast_mode' ]]
then
fsffile=$(echo "$fsffile" | grep "con_mode) [a-z].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-contrast_orig' ]]
then
fsffile=$(echo "$fsffile" | grep "con_orig'$in2'.'$in3') [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-contrast_real' ]]
then
fsffile=$(echo "$fsffile" | grep "con_real'$in2'.'$in3') [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-contrast_orig_show' ]]
then
fsffile=$(echo "$fsffile" | sed 's/conpic_orig\.'$in2') [0-9].*/conpic_orig\.'$in2') '$in3'/g')
echo $fsffile;shiftpos
elif [[ $in1 == '-contrast_orig_name' ]]
then
fsffile=$(echo "$fsffile" | sed 's/conname_orig\.'$in2') ".*"/conname_orig\.'$in2') "'$in3'"/g')
echo $fsffile;shiftpos
elif [[ $in1 == '-contrast_real_show' ]]
then
fsffile=$(echo "$fsffile" | sed 's/conpic_real\.'$in2') [0-9].*/conpic_real\.'$in2') '$in3'/g')
echo $fsffile;shiftpos
elif [[ $in1 == '-contrast_real_name' ]]
then
fsffile=$(echo "$fsffile" | sed 's/conname_real\.'$in2') ".*"/conname_real\.'$in2') "'$in3'"/g')
echo $fsffile;shiftpos
elif [[ $in1 == '-smooth' ]]
then
fsffile=$(echo "$fsffile" | grep "smooth) [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-hpfilteron' ]]
then
fsffile=$(echo "$fsffile" | grep "temphp_yn) [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-hpfilter' ]]
then
fsffile=$(echo "$fsffile" | grep "paradigm_hp) [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-motion' ]]
then
fsffile=$(echo "$fsffile" | grep "motionevs) [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-confoundevs' ]]
then
if [[ $in3 == '' ]]
then fsffile=$(echo "$fsffile" | grep "confound_evs) [0-9].*" | grep -o "[^ ]*$")
shiftpos;shiftpos
else
newdir=$(echo $in3 | sed 's/\//\\\//g')
fsffile=$(echo "$fsffile" | sed 's/\([^"]*confoundev_files(1) "\)\([^"]*\)"/\1'$newdir'"/g;s/confoundevs) [01].*/confoundevs) '$in2'/g' )
echo $fsffile;shiftpos
fi
elif [[ $in1 == '-outlier' ]]
then
fsffile=$(echo "$fsffile" | grep "robust_yn) [01].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-ncontrasts_orig' ]]
then
fsffile=$(echo "$fsffile" | grep "ncon_orig) [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-ncontrasts_real' ]]
then
fsffile=$(echo "$fsffile" | grep "ncon_real) [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-outputfulldir' ]]
then
newdir=$(echo $in2 | sed 's/\//\\\//g')
fsffile=$(echo "$fsffile" | sed 's/\([^"]*outputdir) "\)\([^"]*\)"/\1'$newdir'"/g' )
echo $fsffile;shiftpos
elif [[ $in1 == '-outputdir' ]]
then
# dir=`echo "$fsffile" | grep outputdir | sed 's/[^"]*"\([^"]*\)"/\1/g'`
dir=`echo "$fsffile" | grep outputdir | awk '{ print $NF }'`
firstchar=`echo $dir | head -c 1`
lastchar=`echo $dir | tail -c 1`
if [[ $dir == '' ]]
then newdir=$in2
elif [[ $lastchar == / ]]
then newdir=$dir/$in2
else newdir=`dirname $dir`/$in2
newdir=`echo $newdir | sed 's/^.\///g'`
fi
newdir=$(echo $newdir | sed 's/\//\\\//g')
fsffile=$(echo "$fsffile" | sed 's/\([^\"]*outputdir) "\)\([^\"]*\)\"/\1'$newdir'\"/g')
echo $fsffile;shiftpos
elif [[ $in1 == '-inputdirs' ]]
then
## not working
dir=`cat "$fsffile" | grep feat_files\(1\) | sed 's/[^"]*"\([^"]*\)"/\1/g'`
firstchar=`echo $dir | head -c 1`
lastchar=`echo $dir | tail -c 1`
if [[ $dir == '' ]]
then newdir=$in2
elif [[ $lastchar == / ]]
then newdir=$dir/$in2
else newdir=`dirname $dir`/$in2
newdir=$(echo $newdir | sed 's/^.\///g')
fi
newdir=$(echo $newdir | sed 's/\//\\\//g')
fsffile=$(echo "$fsffile" | sed 's/\([^\"]*feat_files(.) "\)\([^\"]*\)\"/\1'$newdir'\"/g')
echo $fsffile;shiftpos
elif [[ $in1 == '-inputfulldir' ]]
then
newdir=$(echo $in3 | sed 's/\//\\\//g')
fsffile=$(echo "$fsffile" | sed 's/\([^"]*feat_files('$in2') "\)\([^"]*\)"/\1'$newdir'"/g' )
# adjust timepoints and TR
npts=`fslval $in3 dim4 | grep -o "[0-9.]*"`
TR=`fslval $in3 pixdim4 | grep -o "[0-9.]*"`
fsffile=$(echo "$fsffile" | grep "tr) .*" | grep -o "[^ ]*$")
fsffile=$(echo "$fsffile" | grep "npts) .*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-ncopeinputs' ]]
then
fsffile=$(echo "$fsffile" | grep "ncopeinputs) [0-9].*" | grep -o "[^ ]*$")
echo $fsffile;shiftpos
elif [[ $in1 == '-structural' ]]
then
newdir=$(echo $in2 | sed 's/\//\\\//g')
fsffile=$(echo "$fsffile" | sed 's/\([^"]*highres_files(.) "\)\([^"]*\)"/\1'$newdir'"/g' )
echo $fsffile;shiftpos
elif [[ $in1 == '-alt_example_func' ]]
then
newdir=$(echo $in2 | sed 's/\//\\\//g')
fsffile=$(echo "$fsffile" | sed 's/\([^"]*alternative_example_func) "\)\([^"]*\)"/\1'$newdir'"/g' )
echo $fsffile;shiftpos
else
echo Error: no option $in1
exit
fi
pos2=$(echo $pos+1 | bc)
pos3=$(echo $pos+2 | bc)
pos4=$(echo $pos+3 | bc)
in1=$(echo $opts | awk '{ print $'$pos' }')
in2=$(echo $opts | awk '{ print $'$pos2' }')
in3=$(echo $opts | awk '{ print $'$pos3' }')
in4=$(echo $opts | awk '{ print $'$pos4' }')
done
done