Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

[solved] Sending Trigger

ChristianeChristiane Posts: 11
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

  • lvanderlindenlvanderlinden Posts: 292
    edited 12:47AM

    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

    Lotje van der Linden - http://www.cogsci.nl
    FACEBOOK

  • ChristianeChristiane Posts: 11
    edited 12:47AM

    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

  • lvanderlindenlvanderlinden Posts: 292
    edited 12:47AM

    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

    Lotje van der Linden - http://www.cogsci.nl
    FACEBOOK

  • absurdabsurd Posts: 54
    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

  • lvanderlindenlvanderlinden Posts: 292
    edited 12:47AM

    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

    Lotje van der Linden - http://www.cogsci.nl
    FACEBOOK

  • absurdabsurd Posts: 54
    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

  • lvanderlindenlvanderlinden Posts: 292
    edited 12:47AM

    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

    Lotje van der Linden - http://www.cogsci.nl
    FACEBOOK

  • absurdabsurd Posts: 54
    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.

  • lvanderlindenlvanderlinden Posts: 292
    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

    Lotje van der Linden - http://www.cogsci.nl
    FACEBOOK

  • rcabestrerorcabestrero Posts: 6
    edited 12:47AM

    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,

  • sebastiaansebastiaan Posts: 2,516
    edited 12:47AM

    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

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • MichifMichif Posts: 72
    edited 12:47AM

    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"?

  • JarikJarik Posts: 170
    edited 12:47AM

    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

  • MichifMichif Posts: 72
    edited 12:47AM

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

  • _Bob_Bob Posts: 19

    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?

  • JarikJarik Posts: 170

    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

    Thanked by 1Raluca_Szekely
  • garygary Posts: 9

    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

    Thanked by 1Jarik
  • _Bob_Bob Posts: 19

    Hi Gary,

    Thanks! I integrated your method into the plugin.

    Best,
    Bob

    Thanked by 1jtpar
  • jtparjtpar Posts: 33

    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

  • jtparjtpar Posts: 33

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

  • _Bob_Bob Posts: 19

    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

    Thanked by 1jtpar
  • jtparjtpar Posts: 33

    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.

  • _Bob_Bob Posts: 19

    Hi jtpar,

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

Sign In or Register to comment.