AFNI Message Board

Dear AFNI users-

We are very pleased to announce that the new AFNI Message Board framework is up! Please join us at:

https://discuss.afni.nimh.nih.gov

Existing user accounts have been migrated, so returning users can login by requesting a password reset. New users can create accounts, as well, through a standard account creation process. Please note that these setup emails might initially go to spam folders (esp. for NIH users!), so please check those locations in the beginning.

The current Message Board discussion threads have been migrated to the new framework. The current Message Board will remain visible, but read-only, for a little while.

Sincerely, AFNI HQ

History of AFNI updates  

|
June 05, 2018 04:57AM
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
Subject Author Posted

foreach error in @stim_analyze script

Laura Verga May 02, 2018 11:13AM

Re: foreach error in @stim_analyze script

rick reynolds May 02, 2018 05:31PM

Re: foreach error in @stim_analyze script Attachments

Laura Verga May 08, 2018 10:56AM

Re: foreach error in @stim_analyze script

rick reynolds May 14, 2018 10:12AM

Re: foreach error in @stim_analyze script

rick reynolds May 14, 2018 10:40AM

Re: foreach error in @stim_analyze script

Laura Verga June 04, 2018 08:39AM

Re: foreach error in @stim_analyze script

Laura Verga June 05, 2018 04:57AM

Re: foreach error in @stim_analyze script

rick reynolds June 05, 2018 04:34PM

Re: foreach error in @stim_analyze script

Laura Verga June 06, 2018 04:45AM

Re: foreach error in @stim_analyze script

rick reynolds June 08, 2018 09:12AM

Re: foreach error in @stim_analyze script

Laura Verga June 15, 2018 11:24AM