| Reference | Downloads | Github

Parallel port for TMS pulse

Hi everyone,

I’m tying to build a psychopy code to send TMS pulse during a Flanker Task. I used the parallel port fonction, that worked to send informations to the EMG but not to the TMS machin. The TMS pulses are sent in a randomly way, they seems to not follow the timing architecture of the script. In opposition of the EMG pairing follows perfectly the timing of the experience. Do someone had already experienced a similar issue?

Here is the script if you want to look at it.

Thanks in advance,

Victor (12.2 KB)

Hi Victor, there is a much higher probability of a useful response if, instead of just posting an entire script for people to look through, you include in your post more detail of what you have done to send each sort of pulse, and what the exact issue is.

i.e. rather than just describe it as “pulses are sent in a random way”, say exactly what you expected to happen, and exactly what does actually happen, and how this differs for the two sorts of pulse.

Supplement the explanation with snippets of specific code extract. To include readable code within your post:

Good luck.

Hi Michael, thank you of your reply.

Yes, in fact it’s not clear enough. To not enter in a lot of not necessary details, let me introduce the issue in an other way.
Here is a little script to send a TMS pulse every 10 secondes. I used the parallel port function. The first time it’s work and then it’s stop while the d printing continues.

# -*- coding: utf-8 -*-

from psychopy import event, core, visual, gui
import pandas as pd
import time, random, sys

from psychopy import parallel
print par

for i in range(300):

In advance, thank you!

Could you explain more fully what you mean here? There is only one place in the code where printing occurs, so it isn’t clear what it means when you say that the printing continues.

But in sending your pulse, you do this:


That sets some pins on the cable and then immediately resets them. The interval between these operations will be tiny (possibly microseconds), so it is likely that your receiving hardware will fail to detect the pulse at all. You need to check your hardware manual for how often if checks the parallel port and what minimum pulse duration it expects. e.g. you might need to pause for, say 10 ms, like this:

par.setData(199) # the data
core.wait(0.01) # the pulse width, to allow detection
par.setData(0) # reset

Thanks for your reply, now there is a pulse every 10 sec!

Sorry I was talking about a line that I added, print d, just to have an indication of each time I had to have a pulse.

The issue that I have now is the communication between the computer of the task and the EMG triggers and TMS triggers.
I would like to send triggers on EMG to mark the moment of the apparition of one stimuli on the screen and also when the subject responds on the keyboard.

I don’t get the logic of the number I have to put in the par.setData() to indicate sometimes that it codes for the TMS sometimes that it codes for the EMG.
For the moment I used (199) for the TMS pulses, that works but it is also sent to the EMG, it is not suppose to do that.
And the contrary happens too, I coded (222) to trigger the EMG that the subject push the left key, but this parallel port data also send trigger to the TMS machin and send a pulse.

Do you have informations or do you know where I can find informations about the way to choose the code of the par.setData function to distinguish when the trigger have to be sent to the EMG or to the TMS?

P.S.: I am sorry for my bad English.

You need to explain your hardware setup. Do you have two physically separate parallel ports, each with its own cable, going to two separate devices? Or are the two devices somehow connected to the same cable coming from the computer?