[solved] Why is the display time about 100ms longer on average than I set?
Hi,
I have been designing programs with opensesame, but meet some problem and need your help.
In this program, the stimulus will be shown for 600ms, and at the same time, I want to collect respose time data from the begining of the stimulus. So I used the parallel module. Since I want to keep the whole time of a trial for a fixed value of 2300ms, and not jitters because of the variance of response_time, I add another fixation(fixation2) for 900ms;so that the time of one trial=stimulus(600ms)+fixation2(900ms)+fixation3(800ms)=2300ms. The procedure is as following:
The problem is: the time of fixation2 I collected was not 900ms but about 1000ms. I calculated by minusing [time_fixation3]-[time_fixation2] in the data. However, the time of fixation2 is the same as I set.
The data I have used is like this:
Why is the result? Is there any mistake in my design?
Thank you very much.
The code is as following:
# Generated by OpenSesame 2.9.0 (Hesitant Heisenberg)
# Wed Dec 24 23:28:46 2014 (nt)
# <http://www.cogsci.nl/opensesame>
set foreground "white"
set font_bold "no"
set font_size "18"
set description "Default description"
set mouse_backend "legacy"
set compensation "0"
set title "New experiment"
set background "black"
set subject_parity "even"
set coordinates "relative"
set canvas_backend "legacy"
set start "experiment"
set sampler_backend "legacy"
set width "1024"
set font_italic "no"
set bidi "no"
set subject_nr "0"
set keyboard_backend "legacy"
set height "768"
set font_family "chinese-japanese-korean"
set synth_backend "legacy"
define sequence __sequence
run stimulus "always"
run fixation2 "always"
define feedback _feedback
set duration "keypress"
define loop _loop
set repeat "5"
set item "_sequence"
set break_if "never"
set column_order "stimulus;correct_response"
set cycles "2"
set order "random"
setcycle 0 stimulus "A"
setcycle 0 correct_response "f"
setcycle 1 stimulus "B"
setcycle 1 correct_response "j"
run _sequence
define sequence _sequence
run parallel "always"
run fixation3 "always"
run logger "always"
define sequence experiment
run welcome "always"
run fixation1 "always"
run loop "always"
define feedback feedback
set duration "keypress"
set reset_variables "yes"
set description "Provides feedback to the participant"
draw textline 0 -128 "End of block" center=1 color="white" font_family="mono" font_size=18 font_bold="no" font_italic="no" html="yes" z_index=0 show_if="always"
draw textline 0 -64 "Your average response time was [avg_rt]ms" center=1 color="white" font_family="mono" font_size=18 font_bold="no" font_italic="no" html="yes" z_index=0 show_if="always"
draw textline 0 0 "Your accuracy was [acc]%" center=1 color="white" font_family="mono" font_size=18 font_bold="no" font_italic="no" html="yes" z_index=0 show_if="always"
draw textline 0 64 "Press any key to continue..." center=1 color="white" font_family="mono" font_size=18 font_bold="no" font_italic="no" html="yes" z_index=0 show_if="always"
define sketchpad fixation1
set duration "1700"
set reset_variables "no"
draw rect -100 -120 200 240 fill=1 color="grey" penwidth=1 z_index=0 show_if="always"
draw line 0 -10 0 10 color="white" penwidth=3 z_index=0 show_if="always"
draw line -10 0 10 0 color="white" penwidth=3 z_index=0 show_if="always"
define sketchpad fixation2
set duration "900"
set reset_variables "no"
draw rect -100 -120 200 240 fill=1 color="grey" penwidth=1 z_index=0 show_if="always"
draw line 0 -10 0 10 color="white" penwidth=3 z_index=0 show_if="always"
draw line -10 0 10 0 color="white" penwidth=3 z_index=0 show_if="always"
define sketchpad fixation3
set duration "800"
set reset_variables "no"
draw rect -100 -120 200 240 fill=1 color="grey" penwidth=1 z_index=0 show_if="always"
draw line 0 -10 0 10 color="white" penwidth=3 z_index=0 show_if="always"
draw line -10 0 10 0 color="white" penwidth=3 z_index=0 show_if="always"
define keyboard_response keyboard_response
set allowed_responses "f;j"
set description "Collects keyboard responses"
set timeout "1500"
set flush "yes"
define logger logger
set ignore_missing "yes"
set auto_log "no"
set use_quotes "yes"
log "time_stimulus"
log "time_fixation1"
log "time_fixation2"
log "time_fixation3"
log "time_stimulus"
log "time_keyboard_response"
log "response"
log "response_time"
log "acc"
log "stimulus"
log "correct_response"
define loop loop
set repeat "1"
set item "sequence"
set break_if "never"
set column_order ""
set cycles "1"
set order "random"
run sequence
define parallel parallel
run keyboard_response "always"
run __sequence "always"
define reset_feedback reset_feedback
define sequence sequence
run reset_feedback "always"
run _loop "always"
run feedback "always"
define sketchpad stimulus
set duration "600"
set reset_variables "no"
set description "Displays stimuli"
draw rect -100 -120 200 240 fill=1 color="grey" penwidth=1 z_index=0 show_if="always"
draw textline 0 0 "[stimulus]" center=1 color="red" font_family="sans" font_size=32 font_bold="no" font_italic="no" html="yes" z_index=0 show_if="always"
define sketchpad welcome
set duration "keypress"
set reset_variables "no"
set description "Displays stimuli"
set start_response_interval "no"
draw textline 0 0 "Please <br />respond to A with KEY F; <br />respond to B with KEY J." center=1 color="white" font_family="chinese-japanese-korean" font_size=32 font_bold="no" font_italic="no" html="yes" z_index=0 show_if="always"
Comments
Hi,
With this setup, fixation3 is presented after the parallel item is finished (and by extension all the items within it). Apparently there is some delay in there, which is not surprising in itself. If you want to control the timing of the
sketchpad
s better, it's best to put them in the same sequence. So, in this case, that would mean appending fixation3 to __sequence. Once you do that, the timing should be exactly as you've specified.For more information about timing and the way that items are prepared, see:
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thanks a lot. But I got further questions.
I want to use Opensesame to run an ERP study, which for me the time course is very important. Therefore, I chose the PsychoPy and Xpyriment back-ends. However, the two back-ends seems to be not compatible with the parallel item in fullscreen display.
I have changed part of my experiment, like this:
Short discription of my design:
Particularly in the prac1_seq_seq sequence, I want to display a stimulus in the prac2_sketchpad for 600ms, but I need to response from the beginning of the stimulus display. So I used a parallel item, to load the key_response simultaneously with the prac1_sketchpad. Here I set the timeout of the key_response to 1500ms. To assure a constant trial length, a fix2 for 900ms was added. In the meantime, I wanted to send marker to the ERP machine, so I added the response marker (i.e., correct and wrong) and stimulus marker (i.e., marker_stimulus).
My question:
1. To get the correct response time, I have to put the key_response outside and before the sequence of prac1_parallel_sequence. To send marker exactly after the response was made, I have to put the triger correct and wrong after the key_response sequentially but not parallelly. The two sequences here would make the actual time longer than I set, but I still don't know how to optimize it. Could you give me some recommendations?
2. When I run the exam in window or in quick-test modes, everything goes well. However, problem comes when I run it in fullscreen. In detail, the Psycho back-end just showed a fixation and got stuck, after which I press the ESC button but the computer crashed. While in the Expyriment back-end, after displaying a fixation the program exit with no data. No error was reported, however.
I guess it might because the key_response goes ahead of the prac1_sketchpad. So I transposed the two sequences. The program ran successfully, but the response_time was all 1500ms, and all responses were not correct, which means the response was not recorded. I don’t know why the two sequences runs one after another when they are in the same parallel.
But I really want to run it in a fullscreen mode with Psycho or Xpyriment back-ends, and get the accurate response time. How could I achieve this?
Basic computer environment:
My system is 64-bit windows 7 and the version of Opensesame is 2.9.7. The flush rate of my screen is 60Hz.
My codes are here. There are some Chinese words for instruction but you don’t need to know their meaning. Any help would be greatly appreciated.
to be continued...
Hi,
Do I understand correctly that the reason you are using the parallel plugin is that you need the
keyboard
take a reaction time from an item that is not directly preceding thekeyboard
?If so, it might be (a lot) easier, if you take another approach. You could place an
inline_script
at the position in yoursequence
from which you want to measure the time and typestart_time = self.time()
in it. Later, instead of thekeyboard
item, you put anotherinline_script
at the position, at which the reaction time should be measured and type following in it:followed by the logger. Does this do the trick?
Eduard
Thank you~
The key problem is the parallel plugin itself. I could use my codes I pasted upside quite well in a legacy backend, but as you know, the legacy backend is not very good for a time-critical experiment. So you are right to use inline script.
I finally rewrited nearly all the function defined by plugins with inline script, and it really works very well, since I don't need to use a parallel and two sequences. I really loves the inline scripts now. Haha.
To make anybody that may have the same question, I would like to paste my newest scripts here(I changed the stimulus to English words in order to make it more friendly). And if there is anything wrong or anything that could be improved, I am glad to get the feedback.