Hi afni experts,
I have three conditions in my new event-related fMRI experiment: exp1,exp2 & control. I am interested in two t-test pairs among these conditions: exp1-control & exp2-control. So I search the best experiment sequence use the method provided by @stim_analyze: generating sequence using make_random_timing.py, calculating NSD using 3dDeconvolve and choosing the sequence using the criteria with the sum of the NSD of the two t-test pairs.
But the best sequence is very weird. Some events in this sequence are too close in time and some other events’ ISI are too long.
The ISI statistics :
[size=small]data min mean max stdev
----------- ------- ------- ------- -------
pre-rest 4.000 9.000 14.000 4.163
post-rest 14.000 28.500 44.000 12.369
run #0 ISI 0.000 12.000 56.000 13.156
run #1 ISI 0.000 13.130 68.000 17.277
run #2 ISI 0.000 12.870 62.000 15.630
run #3 ISI 0.000 12.870 68.000 16.807
all runs ISI 0.000 12.717 68.000 15.542[/size]
Visualizing the sequence:
https://ww2.mathworks.cn/matlabcentral/answers/uploaded_files/116192/55.png
The code used was copied from @stim_analyze without big changes:
set num_stim = 3
set num_runs = 4
set pre_rest = 0
set post_rest = 6
set min_rest = 0
set tr = 2.0
set stim_durs = 2
set stim_reps = 8 # This specifies the number of repetitions of each stimulus type, per run
@ run_lengths = $post_rest + $pre_rest + 186 * `printf '%.f' "$tr"` # set the total time, per run (in seconds)
set iterations = 1000000 # number of iterations to compare
set seed = 123 # initial random seed
set outdir = optimal_results
set LCfile = NSD # file to store norm. std. dev. sums in
set datapath = optimal_results
set labels = "exp1 exp2 control"
# recreate $outdir each time
if ( -d $outdir ) then
echo "** removing output directory, $outdir ..."
\rm -fr $outdir
endif
echo "++ creating output directory, $outdir ..."
mkdir $outdir
cd $outdir
echo -n "" > $LCfile
echo -n "iteration (of $iterations): 000000000"
# HRF
#3dDeconvolve -num_stimts 1 -polort -1 -nodata 51 0.5 \
# -stim_times 1 '1D: 0' 'BLOCK5(1,1)' \
# -x1D stdout: | 1dplot -stdin -THICK -del 0.5 -jpeg bk5
# run the test many times
set numlen=`expr length $iterations`
foreach iter (`count -digits $numlen 1 $iterations`)
@ seed = $seed + 1
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 \
-tr_locked \
-max_consec 2 \
-show_timing_stats \
-save_3dd_cmd cmd.3dd.$iter \
>& out.mrt.$iter
3dDeconvolve \
-nodata 756 2.000 \
-polort 3 \
-concat '1D: 0 189 378 567' \
-num_stimts 3 \
-stim_times 1 stimes.${iter}_01_exp1.1D 'BLOCK5(1,1)' \
-stim_label 1 Global_constant \
-stim_times 2 stimes.${iter}_02_exp2.1D 'BLOCK5(1,1)' \
-stim_label 2 Scr_nature \
-stim_times 3 stimes.${iter}_03_control.1D 'BLOCK5(1,1)' \
-stim_label 3 Scr_constant \
-jobs 10 \
-gltsym 'SYM: exp1 -control' \
-glt_label 1 locals \
-gltsym 'SYM: exp2 -control' \
-glt_label 2 global \
-x1D X.xmat.1D >& out.3dD.$iter
set nums = ( `awk -F= '/LC/ {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
foreach i (`count -digit 1 1 $numlen`)
echo -n '\\b' >>tem.1D
end
set xxx=`cat tem.1D`
echo -n "${xxx}$iter"
rm -f *.1D cmd.3dd* out.*
end
echo ""
echo "done, results are in '$outdir', LC sums are in '$LCfile'"
sort -n $LCfile | head -20 > opt_results
I want to know what’s wrong with my code.
Thank you in advance!