Dear Rick,
I tried to implement the make_random_timing script within the @stim_analyze script (see below), but when I run it I get the following message.
** removing output directory, /home/xxx/stim_results ...
++ creating output directory, /home/xxx/stim_results ...
iteration (of 5): 0000nums
nums: Subscript out of range.
What am I missing?
Thanks a lot!
___________________________________________________________
# /bin/tcsh
# try to find reasonable random event related timing given the experimental
# parameters
# ---------------------------------------------------------------------------
# some experiment
set num_stim = 4
set num_runs = 4
set pre_rest = 0 # 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 max_rest = 4 # max rest after each stimulus
set tr = 2.0 # used in 3dDeconvolve, if not make_random_timing.py
set stim_durs = "12 12 12 12"
set stim_reps = "10 10 10 10" # = 40 stimuli x condition
set run_lengths = "690 690 690 690"
set labels = "NMA NMS HMA HMS"
# ---------------------------------------------------------------------------
# execution parameters
set iterations = 5 # number of iterations to compare
set seed = 1234567 # initial random seed
set outdir = /home/xxx/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_runs $num_runs \
-run_time $run_lengths \
-tr $tr \
-pre_stim_rest $pre_rest \
-post_stim_rest $post_rest \
-rand_post_stim_rest no \
-add_timing_class stim 12 \
-add_timing_class tnull 10 \
-add_timing_class rest 0.5 1.5 4 dist=decay_fixed \
-add_stim_class NMA 10 stim rest \
-add_stim_class NMS 10 stim rest \
-add_stim_class HMA 10 stim rest \
-add_stim_class HMS 10 stim rest \
-add_stim_class NULL 14 tnull INSTANT \
-max_consec 2 2 2 2 1 \
-write_event_list events.$iter.txt \
-show_timing_stats \
-seed $seed \
-prefix threat_app.$iter \
-save_3dd_cmd cmd.3dd.$iter.txt \
>& 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"
echo check summary stats with timing_tool.py