MockDataLab

Neuroscience & Physiology

Patch-clamp electrophysiology: cells → sweeps → points → fits

A voltage-step protocol produces four natural tables: one row per recorded cell, one per voltage step (sweep), one per sampled time point inside a sweep, and one per-cell fit summary. Conductance follows a Boltzmann activation curve, peak current is clipped at the amplifier range, and the saturation flag propagates up to the fit table.

cells (12) → sweeps (13 per cell) → points (20 per sweep); cells → fits (1 per cell)

Data structure

Activation curves are the textbook case where raw points, exclusions and fitted parameters must stay linked; journals increasingly ask for that source data.

cellsone row = one recorded cell
Genotype, true half-activation voltage V½, slope k, maximal conductance Gmax and reversal potential. Aggregates count sweeps and saturated sweeps.
sweepsone row = one voltage step
Command voltage from −80 to +40 mV in 10 mV steps, normalized conductance G/Gmax with measurement noise clipped to [0, 1], and peak current clipped at −2000 pA.
pointsone row = one sample of the current trace
Time course inside each sweep (0.25 ms sampling) with activation and inactivation kinetics, white noise and 1 pA ADC quantization.
fitsone row = one fit per cell
Fitted V½ with estimation error that grows with the number of excluded points, goodness of fit, and the number of saturated sweeps excluded.

Generate the electrophysiology (patch clamp) tables

The preset is a starting point: change any formula, noise step or row count and the preview, ER diagram and relation check update.

The relational generator loads as it scrolls into view…

Key relationships

  • G_norm = boltzmann(V_mV, parent.V_half_true, parent.k_slope)

    Each sweep reads its cell's parameters through the foreign key, so all 13 sweeps of a cell lie on one Boltzmann curve.

  • I_peak_pA = parent.G_max_nS * G_norm * (V_mV - parent.E_rev_mV)

    Ohmic driving force: nS × mV = pA. Noise is heteroscedastic (5 % of |I|) and the result is clipped at −2000 pA.

  • n_saturated = sum(sweeps.saturated)

    A child-table aggregate: the cell row counts how many of its sweeps hit the amplifier range.

Common pitfalls

  • Treating every sweep or sample point as an independent observation: the experimental unit is the cell (and often the animal), so n is the number of cells.
  • Fitting a Boltzmann curve to saturated points: clipped currents flatten the curve and bias V½ and k. Exclude them by a rule fixed in advance and log the exclusion.
  • Normalizing to the largest observed conductance instead of the fitted Gmax, which forces at least one point per cell to exactly 1.0.
  • Reporting V½ without the slope factor k or without the number of cells per genotype.

Typical analysis

Fit the Boltzmann function per cell (non-linear least squares), then compare V½ between genotypes with cells as the unit. If several cells come from one animal, add the animal as a random effect (nlme or a two-stage mixed model).

Python
import numpy as np, pandas as pd
from scipy.optimize import curve_fit

cells, sweeps = pd.read_csv("cells.csv", comment="#"), pd.read_csv("sweeps.csv", comment="#")
boltz = lambda v, vh, k: 1 / (1 + np.exp((vh - v) / k))
fits = []
for cid, g in sweeps[sweeps.saturated == 0].groupby("cell_id"):
    (vh, k), _ = curve_fit(boltz, g.V_mV, g.G_norm, p0=[-25, 6])
    fits.append({"cell_id": cid, "V_half": vh, "k": k})
fits = pd.DataFrame(fits).merge(cells[["cell_id", "genotype"]])
print(fits.groupby("genotype").V_half.describe())

Further reading

  • Lazic SE (2010). The problem of pseudoreplication in neuroscientific studies: is it affecting your analysis? BMC Neuroscience 11:5.
  • Hille B (2001). Ion Channels of Excitable Membranes, 3rd ed. Sinauer.

Other relational presets