Howdy, Stranger!

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

Supported by

[open] Triggers in loop

edited June 2013 in OpenSesame

I try to use OpenSesame for ERP. So I decided to start with chess pattern. Here is my code for it:

# Generated by OpenSesame 0.27.3~pre1 (Frisky Freud)
# Tue Jun 11 15:04:49 2013 (nt)
# <http://www.cogsci.nl/opensesame>

set foreground "white"
set subject_parity "even"
set font_size "18"
set description "Default description"
set title "New experiment"
set transparent_variables "no"
set font_bold "no"
set coordinates "relative"
set height "768"
set mouse_backend "xpyriment"
set width "1024"
set compensation "0"
set sampler_backend "legacy"
set font_italic "no"
set background "black"
set subject_nr "0"
set keyboard_backend "legacy"
set start "experiment"
set font_family "mono"
set synth_backend "legacy"
set canvas_backend "xpyriment"

define sketchpad Chess2
    set duration "0"
    set description "Displays stimuli"
    draw image 0 0 "Chess2max8.jpg" scale=1 center=1 show_if="always"

define sequence experiment
    run trigger "always"
    run loop "always"
    run __inline_script "always"

define sketchpad Chess1
    set duration "0"
    set description "Displays stimuli"
    draw image 0 0 "Chess1max8.jpg" scale=1 center=1 show_if="always"

define sequence sequence
    run Chess1 "always"
    run inline_script "always"
    run Chess2 "always"
    run _inline_script "always"

define inline_script _inline_script
    ___run__
    exp.serial_port.write(chr(2))
    self.sleep(1000)
    __end__
    set _prepare ""
    set description "Executes Python code"

define inline_script trigger
    ___run__
    import serial
    exp.serial_port = serial.Serial('COM4')
    __end__
    set _prepare ""
    set description "Executes Python code"

define inline_script inline_script
    ___run__
    exp.serial_port.write(chr(1))
    self.sleep(1000)
    __end__
    set _prepare ""
    set description "Executes Python code"

define inline_script __inline_script
    set _run "exp.serial_port.close()"
    set _prepare ""
    set description "Executes Python code"

define loop loop
    set repeat "1"
    set description "Repeatedly runs another item"
    set skip "0"
    set item "sequence"
    set column_order ""
    set cycles "50"
    set order "sequential"
    run sequence

Unfortunately ERP I am gating are blurred.
May be it is because delay between trigger 1 and trigger 2 is less than between trigger 2 and trigger 1. So addition time appears when new cycle of loop is started. How can I rewrite my code to solve this problem?
Also please find attached OpenSesame experiment archive and pictures: https://docs.google.com/file/d/0Bykc8rJ1UD74cERBdThOdXdHQkk/edit?usp=sharing

Comments

  • edited 12:27PM

    Unfortunately ERP I am gating are blurred.

    I'm not sure what you mean by this?

    If the problem is that the interval between trigger 1 and trigger 2 (same trial) is not the same as that between trigger 2 of one trial and trigger 1 of the next trial, then you're essentially looking for "non-slip" or "absolute" timing. In that case, this post should get you started:

  • edited 12:27PM

    image
    Let me show what I mean. On this picture ERP was registered with two programs. You can see that peak №1 is very sharp with first one, and latency of peak №1 is approximately 100 ms. And this correct form and latency.
    With OpenSesame I have slightly different results. Peak №1 is not sharp and latency is longer a bit. I think it's because of not very stable duration between stimuli and triggers. Can you give any suggestions how rewrite code to fix it.
    My script: https://docs.google.com/file/d/0Bykc8rJ1UD74cXN2ai13TzlWaDQ/edit?usp=sharing

  • edited June 2013

    Ah, I see. In principle your code is fine. One thing that you could do to optimize the code is create the canvas object in an inline_script (i.e. not use a sketchpad) and send the trigger immediately after (not before!) the display is shown.

    my_canvas.show()
    exp.serial_port.write(chr(triger))
    

    Realistically though, the timing difference with the sketchpad approach that you use now should be negligible. Of course I cannot vouch for the timing on your specific system, but I have tested both the serial port and the display presentation (of PsychoPy) on other systems, and this should be extremely accurate, particularly when implemented well.

    Looking at your graph, I would like to point out something that suggests, or might suggest, that it's actually the timing of Presentation that's off. As you say, OpenSesame gives higher latencies of the ERP components, which obviously means that the trigger is registered before the trigger sent by Presentation. This strongly suggests that the Presentation trigger is registered too late, at least on average.

    I'm not an EEG expert, so I cannot say too much about it. Just that in principle the approach that you are using now should be very accurate, although you will have to benchmark your system to know whether it works well in practice—which is difficult. Furthermore, I wouldn't rely too much on the shape of the ERP signal, or on the assumption that Presentation is a golden standard.

    Good luck!

    Cheers!

  • edited 12:27PM

    Personally, I think the idea that Presentation's timing is worse than that of a free experiment builder quite hilarious and I do hope Sebastiaan is right on this one (although I do hope this does not mean EEG-data collected using Presentation is compromised). On their website, I found the following quote:

    "The port code is sent at the logged time of the picture event (the time of a picture stimulus is the start of the first vertical scan that contains the picture), and is bound to the uncertainty of the picture presentation (see Help Guide : Stimuli : Visual Stimuli : Picture Stimuli : Picture Timing Accuracy). As for testing, you could use a photometer to send a code to the recorder (while Presentation does the same), to check if the delays for receiving the codes are the same. In LCD monitors especially, there may be a delay between the onset of a new scan and the appearance of the stimuli." (see this thread)

    From this, I would conclude that Presentation basically does the same thing OpenSesame does, although I would not know what exactly the 'picture uncertainty' is that the guy from Neurobehavioral Systems mentions (I do not have the Help Guide he refers to). As far as I know, the source code for Presentation is not available, so we're pretty much in the dark about what exactly is going on anyhow.

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games