MRI experiment: start routine by MRI pulse from parallel port

Hello everyone

OS : Windows 10 / XP
PsychoPy version: 1.84.1
Standard Standalone? (y/n) yes

What are you trying to achieve?:
I am trying to setting up an fMRI experiment. For this, I want the routine to start, when the MRI scanner starts to send TR pulses. The MRI pulses will be received by the parallel port.

What did you try to make it work?:
I created a routine with following code component.

Begin experiment:

from psychopy import parallel
parallel.setPortAddress(address=0xCFE9)
globalClock = core.Clock()
wait_msg=“waiting for scanner…”
msg = visual.TextStim(win, color=‘DarkGray’, text=wait_msg)

Begin routine:

msg.draw()
win.flip()
while True:
    if parallel.readPin(13) == 1:
        break
    globalClock.reset()
    logging.exp('parallel trigger: start of scan')
    win.flip()  # blank the screen on first sync pulse received

The parallel port address is also configured in the settings.

What specifically went wrong when you tried that?:
When I run the experiment I get this error message:

return PORT.readPin(pinNumber)
AttributeError: ‘NoneType’ object has no attribute ‘readPin’

What did I miss?
I hope this is enough information to help me with this problem.
I would be really happy for any advice so that I can run my fMRI experiment with no problems.

Thanks!!

Hello Stephan,

My first guess would be that the parallel port driver is not being properly loaded, since this is a common issue. Here’s a link to my response to someone (with a very similar name!) who was having problems.

That response contains a link to this answer I gave a while back on the same topic on psychopy’s old user forum:

https://groups.google.com/forum/#!topicsearchin/psychopy-users/author%243Ame/psychopy-users/MrGu-MPeFjU

Thank you very much for your answer.

This was exactly the problem. I put the inpout32.dll in the same location as the experiment.
I also found out, that the adress was not correct

Now my experiment runs without further problems!
Thanks!

Hi:

I am a beginner user of Psychopy. How can I include the “experiment” and “routine” section that you sent in your email, in a “psyexp” file? Do you have a complete example with that codes?

Sincerely,

Gonzalo Rojas Costa