Thank you for your speedy reply. I've played a bit with the above code, and modified it (see below), a bit, but there are a several problems.
1. The loop loses time, each cycle. If it was regular, I could take an average and shorten the loop time, but it is not.
2. In related news,the flashes do not seem perfectly regular. It would probably be more obvious with tones. Further, if I "misbehave" and tap very fast (multiple times per cycle), it very obviously affects the flashing stimulus.
3. I cannot capture "anticipatory" clicks.
4. I cannot capture
all of the clicks.
I'm not entirely certain that you understood what I want, and I'm beginning to wonder whether this is possible. I hope I'm missing something.
I want to be able to catch response time
before or after the stimulus (before = anticipating, because the stimulus is at a regular frequency). Because the readkey function only captures the RT after, and then won't capture a second click, if it's within the same timeout period (which would be an anticipatory click), there are "timeouts" that aren't really missed clicks.
I'm attaching spreadsheets with a couple of data sets. In the second, I ran the script with 1000-ms cycles, and counted clicks. In each of these, I clicked 28 or 29 times during the 30 seconds of flashing, but the data only shows ~21. I believe that these cases are when I was wrapping around from anticipatory to responsive, and therefore there were more than 1000 ms between my clicks. This is borne out by the often short RT values immediately following a timeout, but does not capture all of the clicks. Also, it's not always a short RT.
I started to theorize that the more timeouts there were, the greater would be the looptime delay, but that also is not always the case.
I am pretty stumped as to how to proceed, and whether this will even work. Your input is greatly appreciated.
task tapping
keys space
show text "Use the spacebar to tap along with the beat for 30 seconds" 0 -200 100 100 100
show rectangle 0 0 50 50 0 255 0 # show a green rectangle at screen center
timestamp Stim
set $stim_time timestamp-diff this_is_start_time Stim
readkey 1 50 # maximum time is 50 ms
if STATUS != TIMEOUT
clear -1
set $reaction_time RT
fi
if STATUS == TIMEOUT
clear -1
readkey 1 450
set $reaction_time expression RT + 50 # we add 50, because key not pressed before first timeout
fi
set $remaining_time expression 500 - $reaction_time
timestamp the_time_now # update a time stamp every tap
set $time_so_far timestamp-diff this_is_start_time the_time_now
save $stim_time $time_so_far $reaction_time STATUS $remaining_time
delay $remaining_time
if $time_so_far > 30000
end tasklist # this jumps out of the tasklist when time limit of 30 seconds passed
fi
block test
timestamp this_is_start_time # set a time stamp start point
tasklist
tapping 10000
end