Thanks, Rick. Almost working! There is one error that I have gone over and over am not fixing.
0000nums: Subscript out of range.
It looks like this line is not properly saving:
-save_3dd_cmd cmd.3dd.$iter \
Meaning this line searches and finds nothing, leading to an error and it not iterating:
set nums = ( `awk -F= '/'"$pattern"'/ {print $2}' out.3dD.${iter}` )
But I do not know why it is not saving! I checked for extra spaces.
here is full script:
#!/bin/tcsh
set iterations = 100 # number of iterations to compare
set outdir = stim_results_uniform # directory that all results are under
set LCfile = NSD_sums # file to store normal standard dev sums (root mean square of the measurement error #variance for each condition for linear contrasts)
set seed = 1234567 # initial random seed
set pattern = 'norm. std.' # search pattern for normalized stdev vals
if ( -d $outdir ) then
echo "** removing output directory, $outdir ..."
\rm -fr $outdir
endif
echo "++ creating output directory, $outdir ..."
mkdir $outdir
if ( $status ) then
echo "failure, cannot create output directory, $outdir"
exit
endif
# move into the output directory
cd $outdir
# create empty LC file
echo -n "" > $LCfile
echo -n "iteration (of $iterations): 0000"
# iterate
foreach iter (`count -digits 4 1 $iterations`)
# make some other random seed
@ seed = $seed + 1
make_random_timing.py -num_runs 3 -run_time 760 \
-pre_stim_rest 20 -post_stim_rest 20 \
-rand_post_stim_rest no \
-add_timing_class stim 5 \
-add_timing_class rest 5 11 17 dist=uniform_rand \
-add_stim_class pos 15 stim rest \
-add_stim_class neg 15 stim rest \
-add_stim_class neu 15 stim rest \
-tr 1 \
-seed $seed -prefix uniformstimtimes \
-show_rest_events \
-show_timing_stats \
-write_event_list uniformevents \
-save_3dd_cmd cmd.3dd.$iter \
>& out.mrt.$iter
tcsh cmd.3dd.$iter >& out.3dD.$iter
# save the sum of the 3 Linear Contrast values
set nums = ( `awk -F= '/'"$pattern"'/ {print $2}' out.3dD.${iter}` )
echo -n "Before\n"
# make a quick ccalc command
set sstr = $nums[1]
echo -n "After\n"
foreach num ( $nums[2-] )
set sstr = "$sstr + $num"
end
set num_sum = `ccalc -expr "$sstr"`
echo -n "$num_sum = $sstr : " >> $LCfile
echo "iteration $iter, seed $seed" >> $LCfile
echo -n "\b\b\b\b$iter"
end
echo ""
echo "done, results are in '$outdir', LC sums are in '$LCfile'"
echo "sort -n $outdir/$LCfile | head -1"
Edited 2 time(s). Last edit at 09/27/2017 07:37PM by daisyburr.