Howdy, Stranger!

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

Supported by

[open] EEG parallel port trigger for MAC

edited May 2014 in OpenSesame

Hi,

Opensesame is working like a charm for our behavioral studies, so now I would like to use it for our EEG (EGI system) experiments as well. Only the EGI system runs on a Mac, the computer for opensesame is windows operated.
The parallel port trigger plug-in available runs for windows only. Is there also a Mac compatible solution?

thank you,
Mona

Comments

  • edited 7:53AM

    Hi Mona,

    Actually, the parallel port plug-in works on Linux as well, using the parallel module (or an onboard modified version). This might just work on OS X, as the architecture is pretty similar. I don't have any experience on this, though (frankly, I didn't even know there are still Macs out there with a parallel port!).

    Good luck!

    Edwin

  • edited 7:53AM

    Dear Edwin,

    thank you for your reply. I see, for E-prime we created a new port specifically for Eprime in the network section of the Mac, but we used the Mac IP address for the configuration with Eprime on the PC. The opensesame parallel module is asking for a port (and obviously gives an error if I fill in the IP address of the Mac). How shall I best establish the connection?

    Our system (Mac EEG recording unit and windows pc on which the behavioral tasks are done) is sufficiently set up and connected, and I am familiar with setting up the configurations between both computers for Eprime, but I would like to introduce opensesame to our lab and for that I need to enable simultaneous EEG recording.

    As I see it, I need to add a port in the Mac to allow connection with opensesame (you have a default port name?) and need to allow opensesame to connect with the Mac with a similar module as the parallel except that it allows an IP input.

    Maybe this has been tried out before?

    thank you, Mona

  • edited 7:53AM

    Hi Mona,

    Some bad news, I'm afraid: I don't think anyone has used such a setup before, and I don't see a readymade solution.

    It sounds like it's configured via ethernet rather than via the parallel port. In any way, it's not going to be possible to establish a connection using the existing plug-ins. I would suggest either sticking with your current solution (without OpenSesame), running a virtual machine or native Windows installation (if you can configure your EEG equipment to work via Windows), or to use Python's socket module in an inline_script (see here for an example).

    If you manage to work something out, please do report back on the forum. Other might benefit :)

    Good luck!

  • edited 7:53AM

    Hi Mona,

    Edwin's right. What you're dealing with is not a parallel port, but an ethernet connection, and more specifically a UDP (datagram) connection. (Or at least I suspect that's what it is, there's a slight chance that it's TCP/IP.) It's not that hard to get this working though.

    Basically, you can create a socket at the start of your experiment with the script below. You need to specify the IP address of the Mac recorder computer. And in the Mac you need to indicate which you port you used (or change the port in the script to match the one specified in the Mac recorder computer).

    import socket
    # The IP address of the recorder PC
    ip = '127.0.0.1'
    # The communication port, which can probably be anything as long as it's
    # the same in OpenSesame and the recorder PC
    port = 40008
    # Initialize a socket object
    print('Opening socket')
    my_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    print('Socket opened on ip %s and port %d' % (ip, port))
    

    Once you've done this, you can send a trigger (I'm assuming a 0-255 byte trigger here, because that's what's usually done in EEG) with the following script:

    trigger_value = 255
    print('Sending trigger %d' % trigger_value)
    my_socket.sendto(chr(trigger_value), (ip, port))
    print('Trigger sent!')
    

    Something like this should do the trick. UDP communication is really not that hard, and you can read more about it here:

    Cheers!
    Sebastiaan

  • edited 7:53AM

    YES! thank you! that was the right direction! We managed to also get a 'start & stop EEG recording' impulse and triggers.

    As soon as it is a bit polished I will post it here in case anyone is in a similar position.

    Soon our whole lab will be geared up for open sesame! Thank you for this amazing program and your nice & fast responses!

    Mona

  • edited 7:53AM

    Soon our whole lab will be geared up for open sesame!

    Good to hear!

  • edited 7:53AM

    I actually found a whole website dedicated to EGI-netstation communication for future users:

    https://code.google.com/p/pynetstation/

    Enjoy! :)

Sign In or Register to comment.