arista.viz.gain_comparison

Compare ΔF/F-per-°C gain across strains and cell types.

This is the headline NompC-dosage figure: for each recording fit a line through the per-step (Δ target, ΔF/F) points, take the slope as the cell’s gain, and render a raincloud (half-violin + box + jittered strip) per (strain, cell-type) group. CLAUDE.md §7.3 — raincloud over bar — is honoured by construction.

Cell-type signs: CC slope is negative (cold stimuli drive positive response), HC slope is positive. The default panel layout keeps the signs as-is (one panel per cell type, y-axis crosses zero) so the direction is read directly off the figure. abs_gain=True switches to absolute slope magnitude when the goal is direct strain comparison across cell types.

Functions

fetch_recording_gains(conn, *, stimulus_name)

Per-recording gains from a populated arista.db.

plot_gain_comparison(data, *[, ...])

Raincloud comparison of per-recording gain across strains.

Classes

GainComparison([cell_types, abs_gain, ...])

Callable wrapper holding default styling.

class arista.viz.gain_comparison.GainComparison(cell_types=('CC', 'HC'), abs_gain=False, figsize=(12, 5), dpi=200, strains=None, rng_seed=13, min_steps=3)[source]

Bases: object

Callable wrapper holding default styling.

Mirrors arista.viz.response_curves.ResponseCurves so the same orchestration pattern carries over to gain figures.

Parameters:
abs_gain: bool = False
cell_types: tuple[str, ...] = ('CC', 'HC')
dpi: int = 200
figsize: tuple[float, float] = (12, 5)
min_steps: int = 3
plot(data, *, stimulus_name=None, title=None, **overrides)[source]
Parameters:
Return type:

Figure

rng_seed: int = 13
save(fig, path, *, dpi=None, close=True)[source]

Save fig as PNG. SVG sibling is written automatically.

Parameters:
  • fig (Figure)

  • path (Path | str)

  • dpi (int | None)

  • close (bool)

Return type:

Path

strains: tuple[str, ...] | None = None
arista.viz.gain_comparison.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:

pandas.DataFrame

arista.viz.gain_comparison.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 data is 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 in data is plotted in sorted order.

  • abs_gain (bool) – When True plot |slope| instead of signed slope — useful for direct cross-cell-type comparison.

  • min_steps (int) – Forwarded to compute_gains_table() when data is a connection.

  • figsize (tuple[float, float]) – (width, height) inches.

  • 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