Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] why the sketchpad last longer than I set?

edited December 2014 in OpenSesame

In my experiment, I set the sketchpad to show stimulus for 600ms, and the keyboard_response has a timeout of 2000ms. I put the keyboard_response next to the sketchpad. However, the sketchpad last obviously longer than 600ms, probably for 2600ms if I does not press any key. While if I press one key after 600ms, the sketchpad disappears at once; but if I press the key within 600ms, the stimulus last for about 2600ms again. I intended to let the stimulus display with a constant period and disappear regardless the response time. So what's the problem here? How could I do that? The codes are as follows. Thanks.

# Generated by OpenSesame 0.27.3 (Frisky Freud)
# Tue Mar 04 14:43:25 2014 (nt)
# <http://www.cogsci.nl/opensesame>

set mouse_backend "xpyriment"
set subject_parity "even"
set height "800"
set sound_buf_size "512"
set font_italic "no"
set custom_cursor "no"
set canvas_backend "xpyriment"
set synth_backend "legacy"
set sound_channels "2"
set title "Attentional capture for Android"
set psychopy_waitblanking "yes"
set coordinates "relative"
set start "experiment"
set sampler_backend "legacy"
set sound_sample_size "-16"
set font_family "sans"
set foreground "white"
set font_bold "no"
set sound_freq "48000"
set description "An attention capture paradigm, modified for the Android runtime"
set psychopy_monitor "testMonitor"
set background "black"
set font_size "18"
set enable_escape "no"
set keyboard_backend "legacy"
set transparent_variables "no"
set compensation "0"
set subject_nr "0"
set width "1280"

define sequence sequence
    run reset_feedback "always"
    run _loop "always"
    run _feedback "always"

define sequence _sequence
    run fixation_dot "always"
    run sketchpad "always"
    run keyboard_response "always"
    run logger "always"

define feedback _feedback
    set duration "keypress"
    set reset_variables "yes"
    set description "Provides feedback to the participant"
    draw textline 0 -128 "本部分结束" center=1 color=white font_family="sans" font_size=18 font_italic=no font_bold=no show_if="always"
    draw textline 0 -64 "你的反应时为[avg_rt]ms" center=1 color=white font_family="sans" font_size=18 font_italic=no font_bold=no show_if="always"
    draw textline 0 0 "你的正确率为[acc]%" center=1 color=white font_family="sans" font_size=18 font_italic=no font_bold=no show_if="always"
    draw textline 0 64 "按空格键继续..." center=1 color=white font_family="sans" font_size=18 font_italic=no font_bold=no show_if="always"

define loop _loop
    set repeat "2"
    set description "Repeatedly runs another item"
    set item "_sequence"
    set column_order "stimulus;correct_response"
    set cycles "2"
    set order "random"
    setcycle 0 stimulus "上"
    setcycle 0 correct_response "f"
    setcycle 1 stimulus "下"
    setcycle 1 correct_response "j"
    run _sequence

define sketchpad end_of_practice
    set duration "keypress"
    set description "Tell the participant that the practice phase is finished"
    set start_response_interval "no"
    draw textline 0 -64 "The practice phase is finished" center=1 color=white font_family="sans" font_size=18 font_italic=no font_bold=no show_if="always"
    draw textline 0 64 "Tap the screen to start the real experiment ..." center=1 color=white font_family="sans" font_size=18 font_italic=no font_bold=no show_if="always"

define sequence experiment
    set description "The main experimental sequence"
    run text_display "always"
    run _text_display "always"
    run loop "always"
    run end_of_practice "always"

define fixation_dot fixation_dot
    set foreground "white"
    set style "cross"
    set description "Presents a central fixation dot with a choice of various styles"
    set duration "1700"
    set background "black"
    set y "0"
    set x "0"
    set penwidth "4"

define logger logger
    set description "Logs experimental data"
    log "display_size"
    log "distractor"
    log "practice"
    log "condition"
    log "response"
    log "correct"
    log "response_time"

define text_display text_display
    set foreground "white"
    set font_size "36"
    set description "Presents a display consisting of text"
    set maxchar "50"
    set align "center"
    __content__

    欢迎参加实验!

    请仔细阅读接下来的实验说明。
    如有任何疑问,请及时联系主试人员。


    按空格键继续
    __end__
    set background "black"
    set duration "keypress"
    set font_family "sans"

define text_display _text_display
    set foreground "white"
    set font_size "36"
    set description "Presents a display consisting of text"
    set maxchar "50"
    set align "center"
    __content__

    练习一

    请对屏幕中央的文字做按键反应。

    如果看到了“上”,请左手食指按“F”键;
    如果看到了“下”,请右手食指按“J”键。

    请做到又快又准确的按键。

    明确了按空格键继续。
    __end__
    set background "black"
    set duration "keypress"
    set font_family "sans"

define sketchpad sketchpad
    set duration "600"
    set description "Displays stimuli"
    draw rect -100 -100 200 200 fill=1 penwidth=1 color=grey show_if="always"
    draw textline 0 0 "[stimulus]" center=1 color=red font_family="sans" font_size=54 font_italic=no font_bold=yes show_if="always"

define keyboard_response keyboard_response
    set description "Collects keyboard responses"
    set timeout "2000"
    set flush "yes"

define reset_feedback reset_feedback

define loop loop
    set repeat "1"
    set description "Repeatedly runs another item"
    set item "sequence"
    set column_order "practice"
    set cycles "1"
    set order "random"
    setcycle 0 practice "yes"
    run sequence

Comments

  • edited 3:56PM

    The key point to note here is that OpenSesame works purely serially. So what you've done is tell OpenSesame to present a sketchpad for 600 ms, and then (after these 600 ms have passed) start collecting a keyboard response with a timeout of 2000 ms. Since a keyboard_response does not change what's on the display, you'll see the sketchpad for 600 ms + response time. See also the 'Draw the target' of the step-by-step tutorial:

    In your case, what you could is the following.

    1. An inline_script with the following code: exp.set('response', 'None'). This will reset the response variable.
    2. Your target sketchpad with a duration of 0 ms
    3. A keyboard_response with a timeout of 600 ms
    4. A blank sketchpad with a duration of 0 ms
    5. Another keyboard_response with a timeout of 1400 ms and the following run-if statement: [response] = None

    What you basically do here is divide your response interval into two parts. The first part is while the target sketchpad is visible and lasts for 600 ms. The second part is while the target sketchpad is no longer visible and lasts for 1400 ms. Crucially, the run-if statement makes sure that the second part is only executed if no response was given during the first part.

    Does this make sense? Take some time to figure out the logic here, and you'll find that run-if statements give you a lot of flexibility!

    Cheers,
    Sebastiaan

  • edited 3:56PM

    Sorry for my forgetting to reply. Thanks so much for your answer. I have resolved that problem.

Sign In or Register to comment.