@stim_analyze_modern 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #!/bin/tcsh
  2. # try to find reasonable random event related timing given the experimental
  3. # parameters
  4. # ---------------------------------------------------------------------------
  5. # some experiment parameters (most can be inserted directly into the
  6. # make_random_timing.py command)
  7. # ---------------------------------------------------------------------------
  8. # execution parameters
  9. set iterations = 10 # number of iterations to compare
  10. set seed = 1234567 # initial random seed
  11. set outdir = stim_results # directory that all results are under
  12. set LCfile = NSD_sums # file to store norm. std. dev. sums in
  13. # set pattern = LC # search pattern for LC[0], say
  14. set pattern = 'norm. std.' # search pattern for normalized stdev vals
  15. # ===========================================================================
  16. # start the work
  17. # ===========================================================================
  18. # ------------------------------------------------------------
  19. # recreate $outdir each time
  20. if ( -d $outdir ) then
  21. echo "** removing output directory, $outdir ..."
  22. \rm -fr $outdir
  23. endif
  24. echo "++ creating output directory, $outdir ..."
  25. mkdir $outdir
  26. if ( $status ) then
  27. echo "failure, cannot create output directory, $outdir"
  28. exit
  29. endif
  30. # move into the output directory and begin work
  31. cd $outdir
  32. # create empty LC file
  33. echo -n "" > $LCfile
  34. echo -n "iteration (of $iterations): 0000"
  35. # ------------------------------------------------------------
  36. # run the test many times
  37. foreach iter (`count -digits 4 1 $iterations`)
  38. # make some other random seed
  39. @ seed = $seed + 1
  40. # create randomly ordered stimulus timing files
  41. # (consider: -tr_locked -save_3dd_cmd tempfile)
  42. make_random_timing.py -num_runs 4 -run_time 690 \
  43. -tr 2 \
  44. -pre_stim_rest 0 -post_stim_rest 10 \
  45. -rand_post_stim_rest no \
  46. -add_timing_class stim 12 \
  47. -add_timing_class tnull 10 \
  48. -add_timing_class rest 0.5 1.5 4 dist=decay_fixed \
  49. -add_stim_class NMA 10 stim rest \
  50. -add_stim_class NMS 10 stim rest \
  51. -add_stim_class HMA 10 stim rest \
  52. -add_stim_class HMS 10 stim rest \
  53. -add_stim_class NULL 14 tnull INSTANT \
  54. -prefix threat_app.$iter \
  55. # \
  56. # might not need to edit below here... \
  57. -write_event_list events.$iter.txt \
  58. -show_timing_stats \
  59. -seed $seed \
  60. -save_3dd_cmd cmd.3dd.$iter.txt >& out.mrt.$iter
  61. # consider: sed 's/GAM/"TENT(0,15,7)"/' tempfile > cmd.3dd.$iter
  62. # rm -f tempfile
  63. # now evaluate the stimulus timings
  64. tcsh cmd.3dd.$iter.txt >& out.3dD.$iter
  65. # save the sum of the 3 LC values
  66. set nums = ( `awk -F= '/'"$pattern"'/ {print $2}' out.3dD.${iter}` )
  67. # make a quick ccalc command
  68. set sstr = $nums[1]
  69. foreach num ( $nums[2-] )
  70. set sstr = "$sstr + $num"
  71. end
  72. set num_sum = `ccalc -expr "$sstr"`
  73. echo -n "$num_sum = $sstr : " >> $LCfile
  74. echo "iteration $iter, seed $seed" >> $LCfile
  75. echo -n "\b\b\b\b$iter"
  76. end
  77. echo ""
  78. echo "done, results are in '$outdir', LC sums are in '$LCfile'"
  79. echo consider the command: "sort -n $outdir/$LCfile | head -1"
  80. # note that if iter 042 seems to be the best, consider these commands:
  81. #
  82. # cd stim_results
  83. # set iter = 042
  84. # timing_tool.py -multi_timing stimes.${iter}_0* \
  85. # -run_len $run_lengths -multi_stim_dur $stim_durs \
  86. # -multi_show_isi_stats
  87. # tcsh cmd.3dd.$iter
  88. # 1dplot X.xmat.1D'[6..$]'
  89. # 1dplot sum_ideal.1D
  90. #
  91. # - timing_tool.py will give useful statistics regarding ISI durations
  92. # (should be similar to what is seen in output file out.mrt.042)
  93. # - run cmd.3dd.$iter to regenerate that X martix (to create actual regressors)
  94. # - the first 1dplot command will show the actual regressors
  95. # (note that 6 = 2*$num_runs)
  96. # - the second will plot the sum of the regressor (an integrity check)
  97. # (note that sum_ideal.1D is produced by cmd.3dd.$iter, along with X.xmat.1D)