I am running a fMRI task experiment and I would like to receive trigger from MRI device so I can sync my MRI imaging device with my psychopy task.
our lab’s MRI device is from SIEMENS, it use serial port for sending trigger pulse to task computer.
in order to synchronize psychopy and MRI we need to Read code from serial port in our psychopy.
At the moment, I don’t have any idea how to add serial port library and write the related codes in psychopy.
P.S. #1 : As extra information, we use the following code for our task in psychtoolbox (which is MATLAB base)
IOPort(‘CloseAll’);
triger_config = ‘BaudRate=57600 StopBits=1 Parity=None DataBits=8’;
[triger_handle, errmsg] = IOPort(‘OpenSerialPort’, ‘COM3’, triger_config);
% wait_for_triger(triger_handle);
IOPort(‘Purge’, triger_handle);
triger_data = 0;
while (triger_data ~= 115)
if (IOPort(‘BytesAvailable’, triger_handle))
[triger_data, when, errmsg] = IOPort(‘Read’, triger_handle, 1, 1);
end
end
I know it´s been nearly a year since your answer, but i tried what you suggested and I always get this error message (see below). is this an old command that has been replaced by a newer one?
from psychopy.hardware.serial import SerialPort
ModuleNotFoundError: No module named ‘psychopy.hardware.serial’
################ Experiment ended with exit code 1 [pid:24256] #################