Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error using trial manager object
Hi josh and users,
I'm trying to run a protocol using TrialManager object, and I get one of the following two errors :
Error while evaluating TimerFcn for timer 'timer-2'

Index exceeds matrix dimensions.
Error using ArCOMObject_Bpod/read (line 348)
Error: The serial port returned 0 bytes.

Error in TrialManagerObject/startTrial (line 95)
           TrialStartTimestampBytes =, 'uint8');
Error using TrialManagerObject/startTrial (line 93)
Error: The last state machine sent was not acknowledged by the Bpod device.

It occurs when I try to run a protocol that worked OK in the past, as well as another one that is under development. 
Any idea what can be the reason? 
Anything to do with  TrialManager object's timer? 

Hi Noa,

I have a hunch about what's wrong. If you're sending the next state machine description to the device while the current trial is running, try making the final state of the trial a bit longer, to ensure that the state machine is fully transmitted while the trial is still running. If this solves the issue, please let me know and I'll make sure it's fixed in the next update. If not, please send your task code to and I'll try to replicate the issue.

Hi Josh, 
Thanks for your replay!
I will preform some tests according to your suggestion to make that last state of a trial longer (currently the last state is 2 sec long, and the shortest possible trial is 3+ sec). I will let you know if it worked. 
However, in the meantime I tried to enlarge the TrialManager objects timer (for now I set it to 200 ms) and the problem was solved. In case it gives you any indication of what can be wrong...
That's odd - and good, that you found a solution.
Can you please tell more about your setup:

Operating system
MATLAB version
Psychtoolbox version (you can find this by typing PsychtoolboxVersion() at the command prompt)
Other programs running in parallel (e.g. camera acquisition, dropbox)

This will help to identify whether some platforms have more overhead on timer-driven calls to read serial port data. Longer interval = fewer calls, with more data read per call.

Hi Josh!
Sorry it took me a while, 
I have few Bpod systems, running on computers with different properties, 
The one I used for protocol development, where I encountered the problems have the following details: 
operating system: windows 10
CPU : Intel® Core™ i7-7700 CPU @ 3.60GHz 3.60 GHz
RAM : 32 GB
MATLAB version - R2017b
PsychToolbox version  - 3.0.14  (on the other computers we force using Java upon your recommendation since we had some problems in the past). 
Other programs in parallel: chrome, camera 

I haven't changed the protocol to have longer states since its working with the timer period set to 200 ms and its good enough at the moment.

Forum Jump: