![]() |
set a timer in the operant script - 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: set a timer in the operant script (/showthread.php?tid=3441) |
set a timer in the operant script - Samira - 08-31-2022 Hello everyone! I am a new Bpod user and would like to set a timer to end a session. Specifically, I am using the Bpod system in order to perform a sucrose preference test, so I need to know the number of licks of two Bpod systems. To do this I use the operant script but I would like to add a 30 minute timer for example. For now, I stopped the script manually... Thank you in advance for your help, Samira RE: set a timer in the operant script - George - 09-01-2022 Hello, you can use the tic and toc functions to measure time in Matlab like this: Code: tic % Store current time for reference with toc RE: set a timer in the operant script - Josh - 09-01-2022 Hello Samira, Another way is: Code: timeSinceSessionStart = now*100000 - BpodSystem.ProtocolStartTime; This will return the time in seconds since the protocol started. Note that this time is measured by MATLAB, not the state machine clock. The two clocks will drift slightly, but if the point is to automate session-end, it should work. This way of doing it will allow you to use tic/toc inside your code for debugging if necessary. -Josh |