Psychopy Freezes When Recording with LSL and Text Stimuli

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win 11
PsychoPy version (e.g. 2024.2.4 Py 3.8): 2024.2.4 Py 3.8
Standard Standalone Installation? (y/n) y
Do you want it to also run online? (y/n) n

Problem description

I am experiencing a random silent freeze in a PsychoPy Builder experiment. The setup consists of PsychoPy sending LSL markers, LabRecorder recording several streams (an Arduino-based physiological acquisition system (PPG/GSR, 250Hz) streaming through LSL, and a Brain Products LiveAmp EEG system connected via Bluetooth, 250Hz).

The freeze only occurs in one specific task where participants read text items and respond using a slider with the mouse (in a so called “response” routine), and importantly, the issue only occurs when a participant is connected to the physiological sensors (especifically the PPG/GSR system), and the EEG electrodes recording noisy data (electrodes are left on the table). This problem does not occur if the participant is not connected to the PPG/GSR system (but left recording noisy data). The experiment can run normally for several trials or several minutes before freezing without any error message, crash report, or Python exception.

The PsychoPy log consistently shows that the participant’s response is registered and the response trigger is sent successfully, but the next routine (a simple jitter/ITI screen before the trial ends) never starts. The freeze appears on random trials and is not linked to any specific stimulus.

A second task with a nearly identical structure, code, triggers, LSL setup, timing, and hardware configuration, but presenting images instead of text, has never shown this problem under the same experimental conditions (even recording everything at the same time).

Both tasks use the same LSL marker function (event_outlet.push_sample()), the same trial structure (fixation cross → stimulus → preparation cue → response → jitter), and the same logging approach. The freeze always occurs after a mouse response has been registered and after the response marker has been successfully logged. No Python exceptions, PsychoPy errors, or LabRecorder warnings are generated when the freeze happens.

The stimuli is presented twice in a trial, both in the stimulus routine and the response routine, calling the same row/column from the excel file. In the response routine, two triggers are sent: one at the beggining of the routine (using win.callOnFlip) and another one when the participant respond.

Things already tested

I have though there may be a problem with rendering text each trial. To isolate the cause, I have performed several tests. I replaced all Text components with TextBox components; the freeze still occurs, although it seems to take longer before appearing. The response routine code in the problematic task is almost identical to the image task, differing mainly in the stimulus type (text vs. images) and response categories.

Also, I modified the Arduino acquisition application so that it no longer runs at Windows HIGH_PRIORITY_CLASS and instead uses standar priority.

Apparently CPU and RAM usage remain normal during testing (21% and 70% each at maximum) in any case.

Freezing without an error message sounds like an infinite loop. Are there any loops in End Routine?

This sounds like there’s something in a thread going into a “tight loop”, so it locks up. I’m not familiar with this LSL marker function, but I’m guessing push_sample sends data from some kind of queue, so maybe in the task that freezes the queued data is different than in the task that doesn’t? Maybe it fails to send and tries again ad infinitum, or maybe under these conditions the data it sends is just very large and so takes a long time? This is just guesswork though