Hello AFNI experts,
I am encountering an issue when attempting to run a script based on @stim_analyze.
More specifically, when I run the script I get the following message:
** removing output directory, stim_results …
++ creating output directory, stim_results …
iteration (of 100): 0000nums: Subscript out of range.
The directory stim_results gets created, but I think the issue has to do with the foreach loop, as when I try to run: iter(count -digits 4 1 $iterations
)
I get the error: Badly placed ()'s
Any idea what I am doing wrong?
Thanks a lot for your help!
Laura
++++++++++++++AFNI version++++++++++++++++
Precompiled binary linux_ubuntu_16_64: Apr 18 2018 (Version AFNI_18.1.05)
++++++++++++++ script +++++++++++++++++++++
/bin/tcsh
set num_stim = 4
set num_runs = 4
set pre_rest = 4 # min rest before first stim (for magnet steady state)
set post_rest = 10 # min rest after last stim (for trailing BOLD response)
set min_rest = 0.5 # minimum rest after each stimulus
set tr = 2.0 # used in 3dDeconvolve, if not make_random_timing.py
set stim_durs = 10
set stim_reps = 40
set run_lengths = 54
set labels = “cond1 cond2 cond3 cond4”
---------------------------------------------------------------------------
execution parameters
set iterations = 100 # number of iterations to compare
set seed = 1234567 # initial random seed
set outdir = stim_results # directory that all results are under
set LCfile = NSD_sums # file to store norm. std. dev. sums in
set pattern = LC # search pattern for LC[0], say
set pattern = ‘norm. std.’ # search pattern for normalized stdev vals
===========================================================================
start the work
===========================================================================
------------------------------------------------------------
recreate $outdir each time
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 and begin work
cd $outdir
create empty LC file
echo -n “” > $LCfile
echo -n “iteration (of $iterations): 0000”
------------------------------------------------------------
run the test many times
foreach iter(count -digits 4 1 $iterations
)
# make some other random seed
@ seed = $seed + 1
# create randomly ordered stimulus timing files
# (consider: -tr_locked -save_3dd_cmd tempfile)
make_random_timing.py -num_stim $num_stim -stim_dur $stim_durs \
-num_runs $num_runs # -run_time $run_lengths \
-num_reps $stim_reps -prefix stimes.$iter \
-pre_stim_rest $pre_rest -post_stim_rest $post_rest \
-min_rest $min_rest \
-stim_labels $labels \
-seed $seed \
-tr $tr \
-show_timing_stats \
-save_3dd_cmd cmd.3dd.$iter \
>& out.mrt.$iter
# consider: sed 's/GAM/"TENT(0,15,7)"/' tempfile > cmd.3dd.$iter
# rm -f tempfile
# now evaluate the stimulus timings
tcsh cmd.3dd.$iter >& out.3dD.$iter
# save the sum of the 3 LC values
set nums = ( `awk -F= '/'"$pattern"'/ {print $2}' out.3dD.${iter}` )
# make a quick ccalc command
set sstr = $nums[1]
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 consider the command: “sort -n $outdir/$LCfile | head -1”