We have a parallel port input sending the pulse from the MR scanner to the computer.
Can anyone share how they managed to sync the parallel port input trigger with their code to start the task (and globalClock)?
Perhaps a simple question, I’ve only used launchScan waiting for an emulated button press (e.g. ‘5’) in the past, but it appears this new set-up only works with a serial input.
Many thanks in advance!
Where are you starting from? As in, do you know how to read parallel port pins in PsychoPy? Off the top of my head and assuming you have the correct pport driver installed, I’d write a routine that checks the pin corresponding to the scan trigger that only proceeds when it reads a 1 from that pin (indicating high). Here’s an implementation from another PsychoPy user similar to what I described - their trigger signal is coming from pin 13.
Thank you for the reply!
I’m afraid I’m at the very first step, as I don’t know how to read parallel port pins in PsychoPy.
I saw in the link you attached the user said the parallel port address is also configured in the settings, but I’m not sure how to do that?
Thanks again for your help!!
Hi there - no problem at all! Happy to help. What operating system are you using?
Windows XP psychopy v 1.82
And we also have a mac running osx 10.14 with a USB adapter (same psychopy version).
Check the parallel port address
- Find the Device Manager (usually you can get here through the Control Panel).
- Under Ports, you may have multiple Parallel Port entries (shorthand referred to as LPT1, LPT2, etc.). When you double-click these entries, the Resources tab should show you the I/O Range. The address is under Setting. In the example here, the parallel port address would be 0xB400 (the second range of addresses). Record this address.
- Repeat for all port entries - you may need to test each of these if you don’t know which parallel port you’ve plugged the trigger output into.
Check that you have the correct parallel port driver
Windows needs a parallel port driver to work with the parallel port. Under C:\Windows\SysWOW64, verify whether the file
inpout32.dll exists. If not, follow instructions from here to download and install.
In PsychoPy, test the port address
See the documentation here for the PsychoPy function library that interfaces with the parallel. You’ll need to look at the documentation for your stim console to figure out which pin the trigger signal is outputting to. Broadly, there are three steps:
- Import the library:
from psychopy import parallel
- Setup the port with one of the addresses you discovered:
port = parallel.ParallelPort(address=0xB400)
- Read the trigger pin:
trigger = port.readPin(pin)
- If you see an error at step 1 saying that a certain module is not found, the inpout32.dll driver may not be correctly installed. Ensure that Python and PsychoPy are both the same bit (both 32-bit or both 64-bit). If it’s the 64-bit, you may need to install the x64 compatibility in the link above.
- If you see an error at step 3 saying that port is a NoneType, then try copying the inpout32.dll file into the working directory of your PsychoPy code. Others have said that this helps.
This is just a rough set of steps - please let me know if you have any issues! Unfortunately, I’m not so sure about how things would go on a Mac, but happy to help after we get the Windows side working. Good luck.
Thank you so much for the detailed reply!
It works with the PC, now just needs to figure out the mac
Hi - maybe start with finding the parallel port addresses on the Mac, following directions as seen in this post.
I’m not 100% sure how parallel port to USB adapters work, but if the USB is somehow emulating the parallel port, then it may just work with the same code as before. It didn’t for that forum poster, but you should try it! Let me know how it goes.
Edit1: Actually, using the Parallel function library will throw an error because it’s designed for use with Windows and Linux. Will get back to you.
Edit2: Based on this post, these people were running a study that did involve an MRI parallel port connection on a Mac OS X, so I change my mind - do try using the parallel class, as it may just work.
Hi! Could you find a way to work it out on Mac?
Did you work it out,I myself also trying to get triggers from fMRI using MacBook.
Do you know of any working example available online?