Online plot#

While a mouse does the task, the village shows an online plot of the session, updated after every trial. The task (auditory-task-python, online_plot.py) draws it with plots.online.OnlineSessionFigure:

from lecilab_behavior_analysis.plots.online import OnlineSessionFigure
from village.custom_classes.online_plot_base import OnlinePlotBase


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)  # the trials of the session so far (Task.session_df)

Online plot

What it shows#

  • Trial by trial (the last 100 trials): the correct side, coloured by modality and darker for easier trials, with a dot on the side the mouse chose; below, the outcome: correct, error, timeout (no choice) or early withdrawal (the trial ended before the stimulus). Above, the % correct and the % of early withdrawals in the last 20 trials.

  • Summary: stage, trials (and in the last 10 minutes), time, water, % correct, errors, timeouts, early withdrawals and the current holding time.

  • Choices: the probability of choosing left by correct side and difficulty, a line per modality, with its standard error.

  • % correct on each side, with the number of trials and of timeouts.

  • Win-stay / lose-switch of the session (as in the reports), and a line through blocks of 50 trials.

Timeouts count as errors, as in the reports (see data_format_changes.py). In habituation (no correct side) the strip shows the side the mouse went to, and the other panels say that they are not used.

Made to be fast#

It runs on the Raspberry Pi of the village, after every trial:

  • the figure and its artists are made once; an update only changes their data (no ax.clear(), no seaborn, no tight_layout);

  • each trial is read once, when it is new (its outcome, the side chosen…), so an update costs about the same at trial 10 and at trial 1000;

  • a panel that fails shows why, and the others are still drawn.

On a laptop, an update takes about 30 ms and drawing the figure about 130 ms (the old online plot: about 200 ms and 90 ms).