ibllib.plots.figures
Module that produces figures, usually for the extraction pipeline
Functions
Load raw data required for the pawstates QC plot. |
|
Run data manipulation and create the pawstates behavioral QC figure. |
|
Creates DLC QC plot. |
|
Function to remove outline of empty axis |
|
Function to normalise size of all axis labels |
Classes
Plots AP RMS plots |
|
Plots raw electrophysiology AP band task = BadChannelsAp(pid, one=one=one) |
|
Behavioural plots. |
|
Plots coronal and sagittal slice showing electrode locations. |
|
Plots LFP spectrum and LFP RMS plots |
|
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:
- class BehaviourPlots(eid, session_path=None, one=None, **kwargs)[source]
Bases:
ReportSnapshotBehavioural 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:
ReportSnapshotProbePlots coronal and sagittal slice showing electrode locations.
- class LfpPlots(pid, session_path=None, one=None, brain_regions=None, brain_atlas=None, **kwargs)[source]
Bases:
ReportSnapshotProbePlots LFP spectrum and LFP RMS plots
- class ApPlots(pid, session_path=None, one=None, brain_regions=None, brain_atlas=None, **kwargs)[source]
Bases:
ReportSnapshotProbePlots AP RMS plots
- class SpikeSorting(pid, session_path=None, one=None, brain_regions=None, brain_atlas=None, **kwargs)[source]
Bases:
ReportSnapshotProbePlots 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
- class BadChannelsAp(pid, session_path=None, one=None, brain_regions=None, brain_atlas=None, **kwargs)[source]
Bases:
ReportSnapshotProbePlots 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
- 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 forpaw position scatter plots (panels A-D).
'{tracker}': pd.DataFrame — pose estimates from the tracker (e.g., lightningPose), with at least columns{paw}_xand{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 columnsintervals_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 attributestimestamps(np.ndarray, shape (n,)) andposition(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