arista.viz
Publication figure builders. Sprint 8.
- class arista.viz.AdaptationTaus(cell_types=('CC', 'HC'), log_tau=True, figsize=(12, 5), dpi=200, strains=None, rng_seed=19, min_r_squared=None)[source]
Bases:
objectCallable wrapper holding default styling.
- Parameters:
- plot(data, *, stimulus_name=None, title=None, **overrides)[source]
- Parameters:
data (pd.DataFrame | sqlite3.Connection)
stimulus_name (str | None)
title (str | None)
- Return type:
Figure
- class arista.viz.GainComparison(cell_types=('CC', 'HC'), abs_gain=False, figsize=(12, 5), dpi=200, strains=None, rng_seed=13, min_steps=3)[source]
Bases:
objectCallable wrapper holding default styling.
Mirrors
arista.viz.response_curves.ResponseCurvesso the same orchestration pattern carries over to gain figures.- Parameters:
- plot(data, *, stimulus_name=None, title=None, **overrides)[source]
- Parameters:
data (pd.DataFrame | sqlite3.Connection)
stimulus_name (str | None)
title (str | None)
- Return type:
Figure
- class arista.viz.NompCDosage(cell_types=('CC', 'HC'), stimulus_names=('ascAmp', 'descAmp', 'ascAmpFlip', 'descAmpFlip'), abs_gain=True, figsize=(12, 5.5), dpi=200, rng_seed=23, connect_tiers=True)[source]
Bases:
objectCallable wrapper for batch reuse.
- Parameters:
- plot(data, *, title=None, **overrides)[source]
- Parameters:
data (pd.DataFrame | sqlite3.Connection)
title (str | None)
- Return type:
Figure
- class arista.viz.ResponseCurves(cell_types=('CC', 'HC'), by_x='delta_target_c', error='ci', figsize=(10, 5), dpi=200, strains=None)[source]
Bases:
objectCallable wrapper holding default styling.
Useful when rendering many figures (one per stimulus protocol) with consistent kwargs:
plotter = ResponseCurves(figsize=(12, 5)) for stim in ("ascAmp", "descAmp"): fig = plotter(conn, stimulus_name=stim) plotter.save(fig, output_dir / f"resp_{stim}.png")
- Parameters:
- plot(data, *, stimulus_name=None, title=None, **overrides)[source]
- Parameters:
data (pd.DataFrame | sqlite3.Connection)
stimulus_name (str | None)
title (str | None)
- Return type:
Figure
- class arista.viz.SessionOverview(figsize=(10, 5), use_drift_corrected=True, show_target=True, show_sensor=True, sensor_alpha=0.55, cell_linewidth=1.0, dpi=200)[source]
Bases:
objectCallable wrapper around
plot_session_overview().Useful when many sessions are rendered with the same styling (e.g. a batch script or the future DB-backed display layer):
plotter = SessionOverview(figsize=(12, 6), use_drift_corrected=True) for session_name, cells in sessions.items(): fig = plotter(cells, title=session_name) plotter.save(fig, output_dir / f"{session_name}.png")
Defaults stored on the instance are forwarded to every call unless overridden in the call’s kwargs.
- Parameters:
- plot(recordings, *, title=None, **overrides)[source]
Build the figure.
overrideswin over instance defaults.
- class arista.viz.SigmoidFits(cell_types=('CC', 'HC'), figsize=(10, 5), dpi=200, strains=None, n_curve=200, scatter_alpha=0.18, scatter_size=8.0)[source]
Bases:
objectCallable wrapper holding default styling.
Mirrors
arista.viz.response_curves.ResponseCurves.- Parameters:
- plot(data, *, stimulus_name=None, title=None, **overrides)[source]
- Parameters:
data (pd.DataFrame | sqlite3.Connection)
stimulus_name (str | None)
title (str | None)
- Return type:
Figure
- arista.viz.aggregate_response_data(df, *, by_x='delta_target_c', n_bootstrap=2000, confidence_level=0.95, rng_seed=42)[source]
Per (strain, cell_type, x) compute centre + spread + n.
The output carries enough columns to render any of the four supported error bands (
ci/iqr/sem/none) without re-aggregating:median, ci_low, ci_high— non-parametric default. CI is the percentile bootstrap CI of the median atconfidence_level(default 0.95). Resampledn_bootstraptimes (default 2000) from a seedednp.random.Generator.q25, q75— interquartile range (legacyerror="iqr"mode).mean, sem— for the parametricerror="sem"mode.shapiro_p— per-group Shapiro-Wilk p (NaN when n<3); used by the plot layer to gateerror="sem".n— recordings contributing to this (strain, cell_type, x) bucket.
- Parameters:
df (pandas.DataFrame) – Output of
fetch_response_data().by_x (str) –
"delta_target_c"(default, Kossen-style relative amplitude) or"target_temp_c"(absolute temperature).n_bootstrap (int) – Number of bootstrap resamples for the median CI.
confidence_level (float) – CI coverage (default 0.95).
rng_seed (int) – Seed for the bootstrap RNG (reproducibility).
- Return type:
- arista.viz.discover_adaptation_stimuli(conn)[source]
Stimuli that produced
adaptation_fitsrows.- Parameters:
conn (Connection)
- Return type:
- arista.viz.fetch_adaptation_taus(conn, *, stimulus_name=None, cell_types=('CC', 'HC'), strains=None, min_r_squared=None)[source]
Per-recording τ values joined with v_recordings metadata.
- Parameters:
conn (Connection) – Open SQLite connection to a populated
arista.db.stimulus_name (str | None) – Optional stimulus filter (one figure per stimulus in the typical batch workflow).
strains (tuple[str, ...] | None) – Optional strain whitelist.
min_r_squared (float | None) – Drop fits below this quality threshold;
Nonekeeps every fit.
- Returns:
DataFrame with one row per recording carrying
recording_id, researcher_name, strain_name, cell_type, hemisphere, stimulus_name, tau_s, amplitude, asymptote, r_squared, n_points.- Return type:
- arista.viz.fetch_dosage_gains(conn, *, stimulus_names=('ascAmp', 'descAmp', 'ascAmpFlip', 'descAmpFlip'), cell_types=('CC', 'HC'))[source]
Per-recording gains pooled across stimuli, canonicalised + dosage-tagged.
- Parameters:
conn (Connection) – Open SQLite connection to a populated
arista.db.stimulus_names (tuple[str, ...]) – Thermal_step protocols to pool. Defaults to all four ramp stimuli.
- Returns:
DataFrame with one row per (recording, stimulus) carrying the original gain columns plus
canonical_strainanddosage. Rows whose strain has no entry inNOMPC_DOSAGEare dropped.- Return type:
- arista.viz.fetch_recording_gains(conn, *, stimulus_name, cell_types=('CC', 'HC'), strains=None, min_steps=3)[source]
Per-recording gains from a populated
arista.db.- Returns:
DataFrame with one row per (recording, strain, cell_type, hemisphere) carrying
slope,intercept,r_squared,n_points.- Parameters:
- Return type:
- arista.viz.fetch_response_data(conn, *, stimulus_name, cell_types=('CC', 'HC'), strains=None, min_frames_in_window=50)[source]
JOIN
stimulus_responseswithv_recordingsand filter.- Parameters:
conn (Connection) – Open SQLite connection to a populated
arista.db.stimulus_name (str) – Canonical stimulus protocol name (
"ascAmp","descAmp", …).strains (tuple[str, ...] | None) – Optional whitelist of canonical strain names;
Nonemeans “every strain that has matching responses”.min_frames_in_window (int) – Drop rows that medianed over fewer than this many frames — filters Alex’s protocol-mismatch cases where the sensor barely touched a step’s target window.
- Returns:
DataFrame with one row per (recording, step).
- Return type:
- arista.viz.plot_adaptation_taus(data, *, stimulus_name=None, cell_types=('CC', 'HC'), strains=None, log_tau=True, figsize=(12, 5), title=None, rng_seed=19, min_r_squared=None)[source]
Raincloud of adaptation τ per strain × cell-type.
- Parameters:
data (pd.DataFrame | sqlite3.Connection) – Either an already-fetched τ frame (output of
fetch_adaptation_taus()) or a live SQLite connection.stimulus_name (str | None) – Mandatory when
datais a connection.cell_types (tuple[str, ...]) – Cell types to plot, one panel per.
strains (tuple[str, ...] | None) – Optional strain whitelist (display order).
log_tau (bool) – Plot τ on a log y-axis (default). τ is positively skewed and bounded below at zero so log is the natural view; toggle off for a linear inspection.
title (str | None) – Optional figure suptitle.
rng_seed (int) – Seed for the jitter RNG (reproducibility).
min_r_squared (float | None) – Forwarded to
fetch_adaptation_taus().
- Returns:
matplotlib.figure.Figure. Caller owns I/O.- Return type:
Figure
- arista.viz.plot_gain_comparison(data, *, stimulus_name=None, cell_types=('CC', 'HC'), strains=None, abs_gain=False, min_steps=3, figsize=(12, 5), title=None, rng_seed=13)[source]
Raincloud comparison of per-recording gain across strains.
- Parameters:
data (pd.DataFrame | sqlite3.Connection) – Either an already-computed gain frame (output of
fetch_recording_gains()/compute_gains_table()) or a live SQLite connection.stimulus_name (str | None) – Stimulus protocol (mandatory when
datais a connection).cell_types (tuple[str, ...]) – Cell types to plot, one panel per.
strains (tuple[str, ...] | None) – Optional strain whitelist (in display order). When
None, every strain present indatais plotted in sorted order.abs_gain (bool) – When
Trueplot|slope|instead of signed slope — useful for direct cross-cell-type comparison.min_steps (int) – Forwarded to
compute_gains_table()whendatais a connection.title (str | None) – Optional figure suptitle.
rng_seed (int) – Seed for the jitter RNG (reproducibility).
- Returns:
matplotlib.figure.Figure. Caller owns I/O.- Return type:
Figure
- arista.viz.plot_nompc_dosage(data, *, stimulus_names=('ascAmp', 'descAmp', 'ascAmpFlip', 'descAmpFlip'), cell_types=('CC', 'HC'), abs_gain=True, figsize=(12, 5.5), title=None, rng_seed=23, connect_tiers=True)[source]
One panel per cell type, raincloud per strain at its NompC dosage.
- Parameters:
data (pd.DataFrame | sqlite3.Connection) – Either an already-fetched dosage-gain frame (output of
fetch_dosage_gains()) or a live SQLite connection.stimulus_names (tuple[str, ...]) – Thermal-step protocols to pool when fetching from a connection.
cell_types (tuple[str, ...]) – Cell types to plot, one panel per.
abs_gain (bool) – Plot
|slope|(default, makes CC and HC comparable and reads as “how much does the cell care about temperature change”). SetFalseto preserve sign.title (str | None) – Optional suptitle.
rng_seed (int) – Seed for the raincloud jitter RNG.
connect_tiers (bool) – When
True, overlays a thin median-vs-dosage line connecting tier centres so the dose-response trend is visible at a glance.
- Returns:
matplotlib.figure.Figure. Caller owns I/O.- Return type:
Figure
- arista.viz.plot_response_curves(data, *, stimulus_name=None, strains=None, cell_types=('CC', 'HC'), by_x='delta_target_c', error='ci', figsize=(10, 5), title=None, shapiro_alpha=0.05)[source]
Two-panel response curve figure: one panel per cell type.
- Parameters:
data (pd.DataFrame | sqlite3.Connection) – Either an already-fetched DataFrame (output of
fetch_response_data()) or a live SQLite connection. When a connection is passedstimulus_namebecomes mandatory.stimulus_name (str | None) – Stimulus protocol name (when fetching from DB).
strains (tuple[str, ...] | None) – Optional strain whitelist.
cell_types (tuple[str, ...]) – Cell types to plot, one panel per.
by_x (str) –
"delta_target_c"(Kossen’s relative-amplitude axis, default) or"target_temp_c"(absolute).error (ErrorBand) – Error band mode.
"ci"(default, median + 95% bootstrap CI of the median),"iqr"(median + IQR),"sem"(mean + SEM, gated by per-x Shapiro-Wilk; falls back to"ci"with a warning on non-normality), or"none".title (str | None) – Figure suptitle. Auto-generated from
stimulus_namewhenNone.shapiro_alpha (float) – Normality rejection threshold for the
"sem"mode (default 0.05).
- Returns:
matplotlib.figure.Figure. The caller owns I/O.- Return type:
Figure
- arista.viz.plot_session_overview(recordings, *, title=None, figsize=(10, 5), use_drift_corrected=True, show_target=True, show_sensor=True, sensor_alpha=0.55, cell_linewidth=1.0)[source]
Plot one recording session as a dual-y-axis figure.
- Parameters:
recordings (dict[str, Recording]) – Mapping
cell_label → Recording. The label is the Fiji ROI filename stem (e.g."l_CC01","HC02"), used both for the legend and for inferring the cell type viaarista.constants.infer_cell_type_from_filename().title (str | None) – Figure suptitle. Typically the recording-directory path.
use_drift_corrected (bool) – If
True(default) and a recording carriesdfbf_drift_corrected, plot that; otherwise fall back to the rawdfbf.show_target (bool) – Plot the target (set-point) temperature trace.
show_sensor (bool) – Overlay the measured sensor temperature trace.
sensor_alpha (float) – Opacity of the sensor overlay.
cell_linewidth (float) – Stroke width of each cell’s ΔF/F trace.
- Returns:
The
matplotlib.figure.Figure. The caller is responsible forsavefig/plt.close— keeping I/O out of this function lets the same code run in batch scripts, notebooks, and the future GUI layer.- Raises:
ValueError – If
recordingsis empty.- Return type:
Figure
- arista.viz.plot_sigmoid_fits(data, *, stimulus_name=None, cell_types=('CC', 'HC'), strains=None, figsize=(10, 5), title=None, n_curve=200, scatter_alpha=0.18, scatter_size=8.0)[source]
One panel per cell type; one fitted sigmoid per strain.
- Parameters:
data (pd.DataFrame | sqlite3.Connection) – Either an already-fetched response frame (output of
fetch_response_data()) or a live SQLite connection.stimulus_name (str | None) – Mandatory when
datais a connection.cell_types (tuple[str, ...]) – Cell types to plot, one panel per.
strains (tuple[str, ...] | None) – Optional strain whitelist.
title (str | None) – Optional figure suptitle (auto from
stimulus_name).n_curve (int) – Number of x-samples in each plotted sigmoid line.
scatter_alpha (float) – Per-point alpha for the underlying scatter.
scatter_size (float) – Per-point marker area for the scatter.
- Returns:
matplotlib.figure.Figure. Caller owns I/O.- Return type:
Figure
Modules
Adaptation time-constant rainclouds. |
|
Compare ΔF/F-per-°C gain across strains and cell types. |
|
Phase 7d headline figure — |gain| (or signed gain) vs NompC dosage. |
|
Plot a multi-cell recording session as a dual-y-axis figure. |
|
Reproduce Kossen 2019 Fig 19 / 22-23: response curves per strain × cell-type. |
|
Sigmoid-fit overlay of the response curves. |