Forums
Bpod becomes slower and slower as task code running - Printable Version

+- Forums (https://sanworks.io/forum)
+-- Forum: Bpod (https://sanworks.io/forum/forumdisplay.php?fid=1)
+--- Forum: Software (https://sanworks.io/forum/forumdisplay.php?fid=6)
+--- Thread: Bpod becomes slower and slower as task code running (/showthread.php?tid=758)



Bpod becomes slower and slower as task code running - CharlesYin - 02-25-2020

Hi Josh,

I'm using Bpod r2. I found my Bpod becomes slower and slower as the task code running. After 2 hours of running, there is an obvious gap between touching the sensor port and the start of the trial, which affects animal performance a lot. I'm wondering is this because of the problem inside Bpod or computer memory? How should I fix it?

Thanks,
Charles


RE: Bpod becomes slower and slower as task code running - Josh - 02-26-2020

Hi Charles,

The delay is likely caused by your protocol saving the current data structure after each trial. As the session proceeds, the data structure becomes larger and takes longer to write to disk.

There are two options:
1. Change how often you save (e.g. once every 100 trials)
2. Restructure your protocol to use TrialManager (also see example protocol here). This allows you to save data, update plots, etc. while the next trial is running.

-Josh


RE: Bpod becomes slower and slower as task code running - CharlesYin - 02-26-2020

(02-26-2020, 01:50 AM)Josh Wrote: Hi Charles,

The delay is likely caused by your protocol saving the current data structure after each trial. As the session proceeds, the data structure becomes larger and takes longer to write to disk.

There are two options:
1. Change how often you save (e.g. once every 100 trials)
2. Restructure your protocol to use TrialManager (also see example protocol here). This allows you to save data, update plots, etc. while the next trial is running.

-Josh
Hi Josh,

I changed the way of data saving today. It saves all the data when the task is turned off (BpodSystem.Status.BeingUsed == 0). However, the delay problem keeps the same. After running 1000 trials, the gap between touching the sensor and starting the new trial can be 1~2 seconds.

Charles


RE: Bpod becomes slower and slower as task code running - George - 05-22-2020

G'day, I also had the problem of increasing time between trials and I found the issue by logging times at different points in the protocol.

Code:
for currentTrial = 1:1000
    times(currentTrial,1) = now;
    % the thing you're suspicious about
    times(currentTrial,2) = now;
    % that other thing you're suspicious about
    times(currentTrial,3) = now;
end

At the end of the protocol save times and then you can plot the difference between the times across trials.

Using this I found that it was my poorly written custom outcome plot that was causing the lag.

I hope this helps.