Greetings. We are trying to send event markers to Biopac through Labjack. And here is our main code component (the timer and labjack components has already been defined and imported before this). This code component was placed in the “Each Frame” section.
if timer.getTime > EventOnset:
lj.setFIOState(Channel,1)
if timer.getTime > EventOffset:
lj.setFIOState(Channel,0)
Here, “EventOnset”, “EventOffset” and “Channel” are variables read from excel files. What we are trying to do is when a given event occurs, we turn on channel number “Channel” after “EventOnset”, and turn it off after “EventOffset”.
We encounter two problems here:
The labjack function setFIOState does not seem to take variable “Channel” here. Error message:
When we hard code the channel (we put “1” instead of “Channel” there), it worked. But we want to use a variable here.
It does turn on the channel after “EventOnset”, but does not turn off the channel after “EventOffset”. There’s no error message. I could not tell from the code what’s wrong.
As the function works when you hard code it with an integer 1, what is the chance that your variable is somehow made up of strings?
Your code is fighting against itself: if the time of EventOffset has passed, so has the time of EventOnset, so both signals will be sent on every screen refresh once the EventOffset time has elapsed.
You should probably maintain some flags like onset_signal_sent and offset_signal_sent that are initialised to False at the start of the trial, and then used to decide whether to send their respective signals (only i.e. send the signal if the time has elapsed and the value is False, and then set them to be True, so the sending happens only once).