Psychopy Setup with NNL SyncBox 3T fMRI

Psychopy ver. 2024.2.4
OS: Windows
SyncBox: Nordic NeuroLab
Machine: 3T Philips Ingenia

Dear Community,

I’ve built an fMRI experiment using Builder and code components. Currently, I’m in the process of preparing to run a phantom session with the fMRI scanner. I am using Psychopy version 2022.2.4 on a Microsoft Surface Pro connected via USB to the Nordic NeuroLab (NNL) SyncBox. I’ve downloaded the NNL SyncBox script from the provided GitHub repository and placed it in my project folder. Then, following the “Welcome” (“Benvenuto” in the attached screenshot) routine and preceding the stimulus presentation, I’ve included a routine to synchronize the SyncBox with the task. Specifically, within the “Begin Experiment” tab:

from NordicNeuroLab import SyncBox

sync_box = SyncBox(
num_volumes = 400,
num_slices = 1,
trigger_slice = 1,
trigger_volume = 1,
optional_trigger_slice = 0,
optional_trigger_volume = 0,
simulation = False
)

Then, on the Begin Routine tab:

sync_box.start()

And, finally, on the Each Frame tab:

def trigger_update():
    trigger = sync_box.getTrigger(timeout = 0.01)
    if trigger == "s":
        continueRoutine=True
    else:
        continueRoutine=False

if continueRoutine:
    win.callOnFlip(trigger_update)

This was done following NNL instructions: https://info.nordicneurolab.com/NL-100-0104-02_PsychoPy-Setup-with-NordicNeuroLab-fMRI-Hardware.pdf

After powering on the SyncBox and configuring it to “Serial” mode, I encountered an issue where attempting to start the experiment resulted in failure. I suspect the problem lies either in the code I’ve pasted or in the communication between the SyncBox and the task, as the task operates smoothly otherwise (i.e., without attempting to set up Psychopy with the NNL hardware).

The only error message that I get is the following: Alert 4210: JavaScript Syntax Error in the ‘Begin JS Experiment’ tab. It indicates an unexpected token at Line 1. Strangely, this error only surfaced today; it wasn’t present yesterday, and no modifications were made in between. Additionally, I found a thread suggesting that this error should typically affect online experiments rather than local ones like mine (anyway, adopting the proposed solution does not solve the error): Alert 4210: JavaScript Syntax Error in 'Begin JS Experiment' tab. See 'Line 1: Unexpected token' in the 'Begin JS Experiment' tab

If anyone has advice to offer or if there might be an error in the pasted code (I’m particularly uncertain about the Each Frame tab), I would greatly appreciate it. Thank you in advance for any insights you can provide.