online#

The online plot: what is happening in a session while the mouse does the task, updated after every trial (in the village, on a Raspberry Pi).

It is drawn from the raw trials of the session (Task.session_df), not from prepared data, and it is made to be cheap: the figure and its artists are made once, and each update only changes their data (no ax.clear(), no seaborn, no tight_layout). What is computed from each trial (its outcome, the side the mouse chose…) is computed once, when the trial is new, so an update takes about the same time at trial 10 and at trial 1000.

Use it from the task’s online_plot.py:

from lecilab_behavior_analysis.plots.online import OnlineSessionFigure

class OnlinePlot(OnlinePlotBase):
def create_figure_and_axes(self):

self.online = OnlineSessionFigure() self.fig = self.online.fig

def update_plot(self, df):

self.online.update(df)

Functions

online_trials_table

trial_row for every trial of a session: a row per trial with TABLE_COLUMNS.

trial_row

What the online plot needs from one raw trial (a row of Task.session_df).

win_stay_lose_switch

(win_stay, lose_switch, n_wins, n_losses) of consecutive trials, as in metrics.choices.get_win_stay_lose_switch_df: after a correct trial, did the mouse choose the same side? After an error with a choice, the other?

Classes

OnlineSessionFigure([fig, last_trials, ...])

The figure of the online plot: