Howdy, Stranger!

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

Supported by

[solved] Sending Trigger

edited August 2012 in OpenSesame

Dear All, we are currently moving away from presentation towards opensesame for our EEG experiments. I am currently starting a new series of experiments and would rather not have to start with presentation and change over to opensesame during the experiment series. However, the only problem for me right now is that we don't have experience in programming python for the sending of the triggers. Therefore I was wondering if anybody has used it to send triggers during an EEG and if so, does it seem to be software dependent? Maybe somebody has a script already that I could try to integrate into my presentation. We are working with BrainAmp and BrainVision. I would be very grateful for any feedback!
Christiane

Comments

  • edited 1:36AM

    Hi Christiane,

    Thank you for your interest in OpenSesame!

    Yes, that's certainly possible. On the documentation website you can find some example scripts that you can integrate into your experiment. Please note that this solution is Windows only. If you use a different platform, let us know.

    Good luck and don't hesitate to post any further questions!

    Cheers,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited 1:36AM

    Hi Lotje, thank you so much for getting back to me. I will have a look at it today. Right now I am working on a mac but in the lab we record our signals on a PC so that it is probably better to have the presentation protocol also on a PC. If there is a Mac version available or you have any suggestions regarding alternations in the script, I would be happy to learn. So again THANK YOU VERY MUCH!!
    Christiane

  • edited 1:36AM

    Hi Christiane,

    You could use the script on your Mac as well: it will not crash but it won't do anything either. (You'll just see a warning message in your debug window.)
    So you can test your experiment with the trigger code on your Mac, but make sure to double-check it when you run it on the Windows PC that you use for the actual experiment.

    I wouldn't recommend running the actual experiment on a Mac at the moment because the Mac packages are still a work-in-progress. But for building and testing the experiment it's fine, of course!

    Cheers,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited August 2012

    Hi Lotje,

    I'm a colleague of Christiane. We have some trouble getting this to work. We copied the dlportio.dll file to the OpenSesame folder (inside the Programs folder) as written on the linked page. But when we start our test experiment an error message appears saying that the dlportio.sys file was not found an the io-command therefore has no output.
    I tried to install the driver via the install.exe included in the zip archive but this didn't work at all on our Windows 7 PC.
    Is there any trick we're missing here? Or does it work only under XP?

    Thanks a lot for your help,

    Johannes

  • edited 1:36AM

    Hi Johannes and Christiane,

    Yes, you're right! It appears to be Windows 7. We found a version of DLPortIO for 64-bit/ Windows 7:

    And, what we forgot to mention in the documentation is that you need to run the installer as well. So thanks for pointing that out!

    Could you please let us know whether this works for you so that we can include it in the documentation?

    Best wishes,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited August 2012

    Hi Lotje,

    Thanks for the link. I managed to install the driver. It was a little complicated (some passages of the readme file included with the driver are hard to understand), therefore I repeat the necessary steps here (maybe one could include this in the wiki):

    1) Download the DLPortIO x64 driver from http://real.kiev.ua/avreal/download/#DLPORTIO_TABLE and uncompress the zip archive.

    2) As Windows 7 has a strengthened security system (at least compared to XP) one cannot simply install the DLPortIO x64 driver. This won't work as Windows 7 will block all attempts of installing a not officially signed (by Microsoft) driver. Good for the security of an average user -- bad for us.

    To bypass this restriction one has to use a little helper program called "Digital Signature Enforcement Overrider" (DSEO) which can be downloaded here: http://www.ngohq.com/home.php?page=dseo (of course there are other possible ways to do this but this program is mentioned in the DLPortIO-64-readme.txt and one does not have to dive deeper into MS Windows 7 architecture specialities).

    3) Start DSEO with administrator privileges (right click on dseo13b.exe, select "run as administrator"). Now the DSEO window pops up. It just presents a list of options which operation to run next.

    4) Choose the option "sign driver/sys-file" and press ok. Now another window appears where you have to type in the absolute path to the DLPortIO.sys file (only this one, not the dll!). Remember to escape spaces in the path if you have any (don't ask how long that took me) otherwise your files will not be found. Pressing ok will sign the sys-file.

    5) Back in the DSEO list choose "enable test mode" and press ok. Then choose "exit" and restart your PC. (Windows 7 wrongly complains that DSEO might not be installed correctly -- just click on "yes, the software is installed correctly").

    6) After boot up is completed you'll see that something like "Windows 7 test mode built #number#" is written on the desktop just above the clock in the starter-bar. That's necessary. You have to be in test mode to run this unofficially signed driver.

    7) Now run DLPortIO_install.bat with administrator privileges (in Windows Explorer, right click the file, ...). Answer "yes" if Windows warns you about registry changes.

    8) Reboot

    9) Copy the DLPortIO.dll file to the folder containing opensesame.exe.

    That's it.
    Of course, although this worked for me, I cannot guarantee that this will work or even will not harm your system in any way. It's your own risk.

    Now I can execute my test experiment with the bits of python code from the documentation and no error or exception is raised in the debug window.

    However, I tested this in our lab and no triggers appear in the BrainVision-Recorder Window. Obviously the triggers are a) not sent or b) don't get recognized by BrainVision-Recorder. At least I can say that everything is connected correctly because sending triggers with Presentation works.

    Has somebody a hint how to proceed or even some experience with OpenSesame and BrainAmp/BrainVision?

    Best wishes,

    Johannes

  • edited 1:36AM

    Hi Johannes,

    Thank you very much for your step-by-step explanation on how to install DLPortIo on Windows 7. That's really helpful! It sounds like you did everything correctly.

    The most obvious thing that comes to mind is that you may not have specified the correct port. In the example it's set to 0x387 (=888) but you'll probably have to change it according to your set-up. If you specify the wrong port nothing will happen, but you won't get an error message either. You should be able to find the right port in Presentation.

    Also, for testing it's best to send a series of two different triggers because the EEG apparatus will only notice a trigger change. The format of the trigger should not depend on the specific EEG apparatus you're using (as far as we know), so you don't have to worry about that.

    Finally, if you tried all of the above and you still don't get it to work, you may want to have a look at the following post on the PsychoPy mailinglist, where someone reported success with the same issue:

    PsychoPy uses Python just like OpenSesame, so this solution should work for OpenSesame as well.

    Good luck and let us know how it goes.

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited August 2012

    Hi Lotje,

    Thank you! It works! Yes!! :)>-

    I had already found out that the port number was 0x4cf8 for our PC (it's a Laptop with a parallel express card, that's why it has that non standard number), so that was correct.

    Your hint with sending two triggers did the trick. When I do this, both triggers appear in the EEG recording window.

    Wow, I'm really happy that I got this working.
    Thanks again for your help!

    Best wishes,

    Johannes

    P.S.: Now some follow up question comes into my mind. But I will start a new thread for this as the basic trigger sending problem is solved.

  • edited August 2012

    Hi Johannes,

    I'm very glad to hear that!

    It's the change from one byte to another that is used as the trigger event by the EEG apparatus, not the byte itself. That's why the code should always be
    alternating between the to-be-time-stamped events.

    I just wanted to give you two hints for the proceeding of your EEG experiment:

    • It's recommended to use the Psycho back-end (using PsychoPy) instead of the legacy back-end (using PyGame) for your experiment. This is because PsychoPy takes the
      refresh rate of the monitor into account when returning time stamps, whereas PyGame does not. (PyGame does wait for the vertical refresh too, but this is not reflected in the time stamps.)

    • Send the trigger code right after (instead of just before) the presentation of your stimulus (assuming that it's the stimulus onset you want to mark).
      By doing so you'll make sure that the time stamp is as accurately as possible and will not suffer from a small random jitter due to your monitor's refresh rate.

    Cheers,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited 1:36AM

    Hi everyone:

    Is it a must to install the DLPortIO thing to use the parallel port trigger plug-in or is it only needed for the inline_script way of sending trigger?

    Is it a problem to have the parallel port integrated in the motherboard? How can i get to know the right port address?

    I'am checking the output with a polymeter and I don't get any voltage variation in any of the pins in relation to the ground pin (0 volts all the time). Maybe I need to use the DLPortIO...

    Thanks,

  • edited 1:36AM

    Is it a must to install the DLPortIO thing to use the parallel port trigger plug-in or is it only needed for the inline_script way of sending trigger? (...) Maybe I need to use the DLPortIO...

    Yes, you do. Under Windows, you will need to use some special driver to gain access to the parallel port. DLPortIO is one of those, and probably the easiest.

    Is it a problem to have the parallel port integrated in the motherboard?

    That should be fine.

    How can i get to know the right port address?

    If I remember correctly, you can find the port address via the device manager under Windows.

    Cheers!
    Sebastiaan

  • edited 1:36AM

    Sorry for digging up this corpse but I am trying your solution absurd. It works perfectly. However, once I exit the test mode it doesn't anymore. Does this mean I have to start the computer in test mode all the time when I want to run experiments or is there a way to install the .dll-file "permanently"?

  • edited 1:36AM

    Hi Michif,

    Managed to get this working without using test mode by downloading the Binaries only from http://www.highrez.co.uk/downloads/inpout32

    Unpacking the Win32 folder.

    Running InstallDriver.exe as Admin

    Copy the file inpout32.dll from Win32 to c:\Windows\SysWOW64\ and rename it to dlportio.dll

    Best, Jarik

    I tested this on Windows 7 64 bit with OpenSesame 3.0.7 using inline script: http://osdoc.cogsci.nl/devices/triggers/#using-dportiodll-in-a-python-inline-script-windows-only

  • edited 1:36AM

    I can confirm that this works also for Open Sesame 2.9.7 (i.e. older versions). Thanks Jarik!

  • Nice, a new driver install method. Don't like the testing method either. Gonna try to test it today (or else next week), if it works then I will update the documentation.
    How is the plugin working so far?

  • Hi all,

    I retested and updated the little how-to below:

    Managed to get LPT triggers working without using test mode by:

    • Downloading the Binaries only from http://www.highrez.co.uk/downloads/inpout32
    • Unpacking the Win32 folder (drag it in some temp folder for example).
    • Run InstallDriver.exe as an administrator.
    • Copy the file inpout32.dll from Win32 folder to c:\Windows\SysWOW64\ and rename it to dlportio.dll

    Best, Jarik

    I tested this on Windows 7 64 bit with OpenSesame 3.1.2 using inline script: http://osdoc.cogsci.nl/3.1/manual/devices/parallel/#using-dportiodll-in-a-python-inline-script-windows-only
    It worked both for the onboard LPT (port = 0x378) as a StartTech PEX1PLP PCI Express Parallel port card (port = 0xD010)

    Sadly it did not work with the parallel_port_trigger plugin v4.0

  • Hi all

    The dll does not need to be installed or placed in the windows folder, you can place it in the experiment folder or anyother folder, and then use the LoadLibrary function. i.e. windll.LoadLibrary( path + '/inpout32.dll) instead of windll.inpout32. You don't have to rename it either.

    Note Windows uses backslash \ in its paths whilst python uses slash/.
    All the best

    Gary

  • Hi Gary,

    Thanks! I integrated your method into the plugin.

    Best,
    Bob

  • Hi Bob,

    Thanks so much! Should the plugin now work even while not in test mode? Should one follow the instructions from absurd or those from Jarik or some combination?

    Best,
    -Jonathan

  • P.S. - for Johannes' method, I can't find "DLPortIO_install.bat"

  • Hi jtpar,

    Just extract v5.0 of the plugin in the plugin folder and it should work out of the box now. I added the dll in the plugin.

    Best,
    Bob

  • Huzzah! I did as you instructed and the plugin does appear and it does work!!! Thanks so much!!

    It seems that I need to send a "0" trigger at the beginning in order for the first "real" trigger to work---is that right? And the parallel port init item should anywhere above the first trigger? Or can it only be in certain places? Right now I have it at the very top of my "experiment" trial sequence.

  • Hi jtpar,

    Good to hear. It seems the reset / 0 got lost over time. It is back again in v6.0.

  • Hi _Bob,

    Is it possible somehow to read data from the parallel port (instead of sending triggers to it)?

    Thanks!
    Noa

  • edited May 2019

    Hi Noa,


    I know this is a very late answer and hopefully you managed to find a solution, but for everyone who is still looking for a way of reading the parallel port date, this is how I managed to do it on windows 7&10 (64bit).


    def readPort(port):
       try:
          dev = windll.inpout32
          val = dev.Inp32(port)
          print "Read %d from port %d" % (val, port)
       except:
          print "Reading the parallel port failed"
    
  • Hi everyone,


    i'm trying to use Johannes' method, but i have some problems. I have followed all his steps, but triggers don't appear.

    Specifically the system doesn't show any error (in the debug window triggers seem to be sent), but no triggers appear in the BrainVision-Recorder Window.

    1) I'm sure that the port number is correct (indeed triggers appear using "parallel_port_trigger plugin").

    2) i'm already sending a series of two different triggers.


    Do you have any idea about?

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