ibllib.plots.figures

Module that produces figures, usually for the extraction pipeline

Functions

dlc_qc_plot

ephys_bad_channels

load_pawstates_qc_data

Load raw data required for the pawstates QC plot.

lp_qc_plot

pawstates_qc_plot

Run data manipulation and create the pawstates behavioral QC figure.

pose_qc_plot

Creates DLC QC plot.

raw_destripe

remove_axis_outline

Function to remove outline of empty axis

set_axis_label_size

Function to normalise size of all axis labels

Classes

ApPlots

Plots AP RMS plots

BadChannelsAp

Plots raw electrophysiology AP band task = BadChannelsAp(pid, one=one=one)

BehaviourPlots

Behavioural plots.

HistologySlices

Plots coronal and sagittal slice showing electrode locations.

LfpPlots

Plots LFP spectrum and LFP RMS plots

SpikeSorting

Plots raw electrophysiology AP band

set_axis_label_size(ax, labels=14, ticklabels=12, title=14, cmap=False)[source]

Function to normalise size of all axis labels

Parameters:
  • ax

  • labels

  • ticklabels

  • title

  • cmap

Returns:

remove_axis_outline(ax)[source]

Function to remove outline of empty axis

Parameters:

ax

Returns:

class BehaviourPlots(eid, session_path=None, one=None, **kwargs)[source]

Bases: ReportSnapshot

Behavioural plots.

property signature

The signature of the task specifies inputs and outputs for the given task. For some tasks it is dynamic and calculated. The legacy code specifies those as tuples. The preferred way is to use the ExpectedDataset input and output constructors.

I = ExpectedDataset.input O = ExpectedDataset.output signature = {

‘input_files’: [

I(name=’extract.me.npy’, collection=’raw_data’, required=True, register=False, unique=False),

], ‘output_files’: [

O(name=’look.atme.npy’, collection=’shiny_data’, required=True, register=True, unique=False)

]} is equivalent to: signature = {

‘input_files’: [(‘extract.me.npy’, ‘raw_data’, True, True)], ‘output_files’: [(‘look.atme.npy’, ‘shiny_data’, True)], }

Returns:

class HistologySlices(pid, session_path=None, one=None, brain_regions=None, brain_atlas=None, **kwargs)[source]

Bases: ReportSnapshotProbe

Plots coronal and sagittal slice showing electrode locations.

get_probe_signature()[source]
class LfpPlots(pid, session_path=None, one=None, brain_regions=None, brain_atlas=None, **kwargs)[source]

Bases: ReportSnapshotProbe

Plots LFP spectrum and LFP RMS plots

get_probe_signature()[source]
class ApPlots(pid, session_path=None, one=None, brain_regions=None, brain_atlas=None, **kwargs)[source]

Bases: ReportSnapshotProbe

Plots AP RMS plots

get_probe_signature()[source]
class SpikeSorting(pid, session_path=None, one=None, brain_regions=None, brain_atlas=None, **kwargs)[source]

Bases: ReportSnapshotProbe

Plots raw electrophysiology AP band

Parameters:
  • session_path – session path

  • probe_id – str, UUID of the probe insertion for which to create the plot

  • **kwargs

    keyword arguments passed to tasks.Task

get_probe_signature()[source]
get_signatures(**kwargs)[source]

This is the default but should be overwritten for each task :return:

class BadChannelsAp(pid, session_path=None, one=None, brain_regions=None, brain_atlas=None, **kwargs)[source]

Bases: ReportSnapshotProbe

Plots raw electrophysiology AP band task = BadChannelsAp(pid, one=one=one)

Parameters:
  • session_path – session path

  • probe_id – str, UUID of the probe insertion for which to create the plot

  • **kwargs

    keyword arguments passed to tasks.Task

get_probe_signature()[source]
ephys_bad_channels(raw, fs, channel_labels, channel_features, h=None, channels=None, title='ephys_bad_channels', save_dir=None, destripe=False, eqcs=None, br=None, pid_info=None, plot_backend='matplotlib')[source]
raw_destripe(raw, fs, t0, i_plt, n_plt, fig=None, axs=None, savedir=None, detect_badch=True, SAMPLE_SKIP=200, DISPLAY_TIME=0.05, N_CHAN=384, MIN_X=-0.00011, MAX_X=0.00011)[source]
Parameters:
  • raw – raw ephys data, Ns x Nc, x-axis: time (s), y-axis: channel

  • fs – sampling freq (Hz) of the raw ephys data

  • t0 – time (s) of ephys sample beginning from session start

  • i_plt – increment of plot to display image one (start from 0, has to be < n_plt)

  • n_plt – total number of subplot on figure

  • fig – figure handle

  • axs – axis handle

  • savedir – filename, including directory, to save figure to

  • detect_badch – boolean, to detect or not bad channels

  • SAMPLE_SKIP – number of samples to skip at origin of ephsy sample for display

  • DISPLAY_TIME – time (s) to display

  • N_CHAN – number of expected channels on the probe

  • MIN_X – max voltage for color range

  • MAX_X – min voltage for color range

Returns:

fig, axs

dlc_qc_plot(session_path, one=None, device_collection='raw_video_data', cameras=('left', 'right', 'body'), trials_collection='alf')[source]
lp_qc_plot(session_path, one=None, device_collection='raw_video_data', cameras=('left', 'right', 'body'), trials_collection='alf')[source]
pose_qc_plot(session_path, one=None, device_collection='raw_video_data', cameras=('left', 'right', 'body'), trials_collection='alf', tracker=None)[source]

Creates DLC QC plot. Data is searched first locally, then on Alyx. Panels that lack required data are skipped.

Required data to create all panels

‘raw_video_data/_iblrig_bodyCamera.raw.mp4’, ‘raw_video_data/_iblrig_leftCamera.raw.mp4’, ‘raw_video_data/_iblrig_rightCamera.raw.mp4’, ‘alf/_ibl_bodyCamera.{tracker}.pqt’, ‘alf/_ibl_leftCamera.{tracker}.pqt’, ‘alf/_ibl_rightCamera.{tracker}.pqt’, ‘alf/_ibl_bodyCamera.times.npy’, ‘alf/_ibl_leftCamera.times.npy’, ‘alf/_ibl_rightCamera.times.npy’, ‘alf/_ibl_leftCamera.features.pqt’, ‘alf/_ibl_rightCamera.features.pqt’, ‘alf/rightROIMotionEnergy.position.npy’, ‘alf/leftROIMotionEnergy.position.npy’, ‘alf/bodyROIMotionEnergy.position.npy’, ‘alf/_ibl_trials.choice.npy’, ‘alf/_ibl_trials.feedbackType.npy’, ‘alf/_ibl_trials.feedback_times.npy’, ‘alf/_ibl_trials.stimOn_times.npy’, ‘alf/_ibl_wheel.position.npy’, ‘alf/_ibl_wheel.timestamps.npy’, ‘alf/licks.times.npy’,

Params session_path:

Path to session data on disk

Params one:

ONE instance, if None is given, default ONE is instantiated

Returns:

Matplotlib figure

pawstates_qc_plot(data, camera, paw, tracker, session_id=None)[source]

Run data manipulation and create the pawstates behavioral QC figure.

Accepts the raw data dict returned by load_pawstates_qc_data, runs extract_pawstate_plot_data to compute derived quantities, then renders all panels. Panels that lack required data display a placeholder message rather than raising an error.

Parameters:
  • data

    dict of raw loaded data with the following keys (any key set to None skips the dependent panels): - 'frame': np.ndarray, shape (H, W), dtype uint8 — single grayscale video frame used as background for

    paw position scatter plots (panels A-D).

    • '{tracker}': pd.DataFrame — pose estimates from the tracker (e.g., lightningPose), with at least columns {paw}_x and {paw}_y.

    • 'times': np.ndarray, shape (n_frames,) — camera timestamps in seconds.

    • 'pawstates': pd.DataFrame — paw state predictions; columns must include per-paw state probabilities ({paw}_{state}_prob) and ensemble variance ({paw}_*_ens_var).

    • 'fps': float — camera frame rate in Hz.

    • 'trials': pd.DataFrame or None — trials table with columns intervals_0, intervals_1, firstMovement_times, stimOn_times, feedback_times, feedbackType. Set to None to skip trial panels N-O and raster panels P-Q.

    • 'wheel': Bunch or None — wheel object with attributes timestamps (np.ndarray, shape (n,)) and position (np.ndarray, shape (n,)). Set to None to zero-fill wheel velocity.

  • camera – Camera view (‘left’ or ‘right’)

  • paw – Paw identifier (‘paw_l’ or ‘paw_r’)

  • tracker – Tracker type (e.g., ‘dlc’, ‘lightningPose’)

  • session_id – Optional session UUID shown in the figure title

Returns:

Matplotlib figure

load_pawstates_qc_data(session_path, one=None, camera='left', paw='paw_l', tracker='lightningPose', device_collection='raw_video_data', trials_collection='alf')[source]

Load raw data required for the pawstates QC plot.

Data is searched first locally, then downloaded from Alyx via ONE. Returns the raw data dict and session eid; pass both to plot_pawstates_qc to run manipulation and plotting.

Datasets loaded:

‘{device_collection}/_iblrig_{camera}Camera.raw.mp4’, ‘alf/_ibl_{camera}Camera.{tracker}.pqt’, ‘alf/_ibl_{camera}Camera.times.npy’, ‘alf/lightningaction/_ibl_{camera}Camera.pawstates.pqt’, ‘{trials_collection}/_ibl_trials.table.pqt’, ‘{trials_collection}/_ibl_wheel.position.npy’, ‘{trials_collection}/_ibl_wheel.timestamps.npy’,

Parameters:
  • session_path – Path to session data on disk

  • one – ONE instance, if None is given, default ONE is instantiated

  • camera – Camera view (‘left’ or ‘right’)

  • paw – Paw identifier (‘paw_l’ or ‘paw_r’)

  • tracker – Tracker type (e.g., ‘dlc’, ‘lightningPose’)

  • device_collection – Collection name for video data

  • trials_collection – Collection name for trials data

Returns:

data dict