Howdy, Stranger!

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

Supported by

How to time visual stimuli correctly

Hi there,

I am running some timing tests with Expyriment. I am using a LabJack to fire a TTL pulse and then measuring the time it takes for the stimuli to appear on screen (using a Black Box Tool Kit). Here is the minimal code - note, stimuli[0] is a blank screen, and stimuli[1] is a rectangle stimulus:

# Preload blank screen
trial.stimuli[0].preload()
expLabJack.writeRegister(6004, 0)
trial.stimuli[0].present(clear=False, update=False) 
# Preload stim
trial.stimuli[1].preload()
exp.clock.wait(300)

# Fire TTL pulse
expLabJack.writeRegister(6004, 1)
# present stim
trial.stimuli[1].present(clear=False, update=False)
exp.clock.wait(200)
expLabJack.writeRegister(6004, 0)

The problem I am having: Using this method, it takes approximately 28ms for the visual stimuli to be detected onscreen (visual stimuli onset - TTL pulse onset), so onset times of the stimuli are overshooting by at least a frame. Is there a better way of controlling the presentation of stimuli?

Comments

  • Hi,

    in your example, nothing should be shown on the screen, since you explicitely set update=False.
    What are the results of the visual presentation test in the test suite for you? Maybe we can go from there.

  • Thanks for the response. Apologies, that is a typo. The stimuli itself does not have an arg passed to the update parameter. Will get the test suite results now.

  • Here is the output of the test suite (had to cut some of the list entries due to character limit). If you would like it in a different format please let me know:

    hardware_audio_card:
    hardware_cpu_architecture: AMD64
    hardware_cpu_details: Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz
    hardware_cpu_type: Intel64 Family 6 Model 62 Stepping 4, GenuineIntel
    hardware_disk_space_free: 44015 MB
    hardware_disk_space_total: 244196 MB
    hardware_internet_connection: Yes
    hardware_memory_free: 25342 MB
    hardware_memory_total: 32683 MB
    hardware_ports_parallel: []
    hardware_ports_parallel_driver: None
    hardware_ports_serial: []
    hardware_video_card: RDPDD Chained DD
    os_architecture: 64bit
    os_details: SP1
    os_name: Windows
    os_platform: Windows
    os_release: 7
    os_version: 6.1.7601
    python_expyriment_build_date: Thu Mar 9 13:48:59 2017 +0100
    python_expyriment_revision: c4963ac
    python_expyriment_version: 0.9.0
    python_mediadecoder_version:
    python_numpy_version:
    python_pil_version:
    python_pygame_version: 1.9.4
    python_pyopengl_version: 3.1.0
    python_pyparallel_version:
    python_pyserial_version:
    python_sounddevice_version:
    python_version: 3.6.5
    settings_folder: None
    testsuite_visual_flipping_user: 1
    testsuite_visual_opengl: 2
    testsuite_visual_opengl_extensions: ['GL_AMD_multi_draw_indirect', 'GL_ARB_arrays_of_arrays', 'GL_ARB_base_instance', 'GL_ARB_blend_func_extended', 'GL_ARB_buffer_storage', 'GL_ARB_clear_buffer_object', 'GL_ARB_clear_texture', 'GL_ARB_color_buffer_float', 'GL_ARB_compatibility', 'GL_ARB_compressed_texture_pixel_storage', 'GL_ARB_conservative_depth', 'GL_ARB_compute_shader', 'GL_ARB_compute_variable_group_size', 'GL_ARB_copy_buffer', 'GL_ARB_copy_image', 'GL_ARB_debug_output', 'GL_ARB_depth_buffer_float', 'GL_ARB_depth_clamp', 'GL_ARB_depth_texture', 'GL_ARB_draw_buffers', 'GL_ARB_draw_buffers_blend', 'GL_ARB_draw_indirect', 'GL_ARB_draw_elements_base_vertex', 'GL_ARB_draw_instanced', 'GL_ARB_enhanced_layouts', ...[DELETED ENTRIES DUE TO CHAR LIMIT]]
    testsuite_visual_opengl_renderer: b'NVS 310/PCIe/SSE2'
    testsuite_visual_opengl_vendor: b'NVIDIA Corporation'
    testsuite_visual_opengl_version: b'4.4.0'
    testsuite_visual_pygame_driver: windib
    testsuite_visual_pygame_screensize: (1920, 1080)
    testsuite_visual_sync_refresh_rate: 60.0 Hz
    testsuite_visual_timing_actual: [16.57459940179251, 33.29449532611761, 50.0559045758564, 16.66592866240535, 66.72127972706221, 33.18213266902603, 16.6681426926516, 33.33130379905924, 16.694434452801943, 33.220601675566286, 50.06171643617563, 16.662054069456644, 16.67976642784197, 33.33462486625649, 16.68281073216349, 49.99916972883511, 49.88210223382339, 66.64960009220522, 16.666482159052975, 16.66482162545435, 49.99833946931176, 66.6969252488343, ...]
    testsuite_visual_timing_delay_histogram: {16: 5, 2: 9, 13: 13, 6: 8, 9: 12, 4: 9, 11: 12, 14: 11, 0: 12, 7: 12, 3: 9, 5: 9, 8: 12, 12: 12, 1: 10, 17: 1, 10: 13, 15: 11}
    testsuite_visual_timing_delayed: 2.22 %
    testsuite_visual_timing_inaccuracy: 0 ms
    testsuite_visual_timing_todo: [0, 31, 37, 10, 57, 29, 5, 19, 17, 26, 47, 11, 8, 30, 5, 45, 36, 54, 9, 15, 41, 59, 25, 34, 33, 9, 28, 39, 44, 59, 48, 30, 11, 44, 54, 27, 2, 9, 43, 57, 18, 27, 8, 28, 26, 18, 7, 22, 20, 42, 31, 0, 34, 42, 39, 40, 4, 40, 1, 12, 52, 45, 22, 33, 52, 12, 50, 38, 21, 7, 16, 53, 5, 0, 46, 29, 7, 6, 40, 25, 23, 41, 19, 55, 56, 45, 17, 54, 56, 33, 49, 14, 2, 20, 12, 1, 37, 39, 4, 10, 6, 46, 35, 10, 46, 31, 13, 24, 2, 16, 53, 4, 11, 3, 20, 19, 48, 32, 49, 22, 27, 58, 32, 8, 59, 55, 17, 58, 14, 51, 24, 57, 3, 16, 43, 3, 34, 15, 6, 51, 23, 24, 36, 25, 37, 35, 1, 50, 56, 15, 13, 29, 52, 21, 53, 42, 48, 41, 51, 43, 30, 28, 47, 58, 50, 35, 55, 38, 36, 18, 47, 13, 23, 38, 26, 44, 49, 21, 14, 32]

  • The code without typo:

    # Preload blank screen
    trial.stimuli[0].preload()
    expLabJack.writeRegister(6004, 0)
    trial.stimuli[0].present(clear=False) 
    # Preload stim
    trial.stimuli[1].preload()
    exp.clock.wait(300)
    
    # Fire TTL pulse
    expLabJack.writeRegister(6004, 1)
    # present stim
    trial.stimuli[1].present(clear=False)
    exp.clock.wait(200)
    expLabJack.writeRegister(6004, 0)
    
  • Ok, turns out the TTL should be fired after the call to present the stimuli. With that, I can achieve screen latencies of 11ms. Thanks for reading.

Sign In or Register to comment.