Analysis¶
Post-hoc metric extraction from a SimulationResult. The members below are
documented from the neuroclamp.analysis subpackage.
neuroclamp.analysis ¶
Analysis subpackage for neuroclamp.
Provides tools for extracting quantitative metrics from simulation results.
Modules:
| Name | Description |
|---|---|
ap_metrics |
Action potential detection and metric extraction. |
burst_metrics |
Burst detection and burst-metric extraction. |
calcium_transients |
Calcium transient detection and decay-τ fitting. |
derivatives |
General-purpose derivative utilities (e.g. dV/dt). |
fi_curve |
F-I curve construction from current clamp multi-sweep results. |
hyperpolarization |
Sag and rebound analysis from hyperpolarization sweeps. |
impedance |
Impedance-profile analysis from a chirp current-clamp run. |
inactivation |
Steady-state inactivation (h∞) curve from a two-pulse VC run. |
iv_curve |
I-V curve construction from voltage clamp multi-sweep results. |
membrane_test |
Dedicated membrane test for passive property characterisation. |
passive_properties |
Passive membrane property extraction (R_in, τₘ, Cₘ). |
sfa |
Spike-frequency adaptation curves and adaptation index. |
tau_v |
Activation/inactivation time-constant fits from voltage-clamp sweeps. |
APAnalysisResult
dataclass
¶
Complete action potential analysis of a voltage trace.
Attributes:
| Name | Type | Description |
|---|---|---|
spike_count |
int
|
Number of detected spikes. |
spikes |
list[SpikeMetrics]
|
Per-spike metrics for each detected spike. |
isis |
list[float]
|
Inter-spike intervals in ms (length = spike_count - 1). |
mean_threshold_voltage |
float | None
|
Mean threshold voltage across all spikes (mV),
or |
mean_peak_voltage |
float | None
|
Mean peak voltage across all spikes (mV), or
|
mean_rise_time |
float | None
|
Mean rise time across all spikes (ms), or |
mean_half_width |
float | None
|
Mean half-width across all spikes (ms), or |
mean_ahp_depth |
float | None
|
Mean AHP depth across spikes that have a measurable
trough (mV), or |
mean_isi |
float | None
|
Mean inter-spike interval (ms), or |
firing_rate |
float | None
|
Mean firing rate in Hz ( |
Source code in neuroclamp/analysis/ap_metrics.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
SpikeMetrics
dataclass
¶
Metrics for a single detected action potential.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
Zero-based spike number within the trace. |
threshold_voltage |
float
|
Membrane voltage at spike onset (mV), defined as the point where dV/dt first exceeds the detection threshold. |
threshold_time |
float
|
Time of threshold crossing (ms). |
peak_voltage |
float
|
Maximum membrane voltage during the spike (mV). |
peak_time |
float
|
Time of peak voltage (ms). |
rise_time |
float
|
Duration from threshold crossing to peak (ms). |
half_width |
float
|
Spike duration measured at the half-amplitude level between threshold voltage and peak voltage (ms). |
ahp_depth |
float | None
|
Minimum membrane voltage after the spike trough (mV).
|
Source code in neuroclamp/analysis/ap_metrics.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
BurstAnalysisResult
dataclass
¶
Complete burst analysis of a spike train.
Attributes:
| Name | Type | Description |
|---|---|---|
burst_count |
int
|
Number of detected bursts. |
bursts |
list[BurstMetrics]
|
Per-burst metrics. |
unburst_spike_count |
int
|
Number of spikes that were not assigned to any burst because they were isolated by long inter-spike intervals. |
mean_spikes_per_burst |
float | None
|
Mean |
mean_intra_burst_frequency |
float | None
|
Mean |
mean_inter_burst_interval |
float | None
|
Mean gap between the end of one burst and
the start of the next (ms), or |
duty_cycle |
float | None
|
Fraction of the recording window spent inside a burst
( |
isi_threshold_ms |
float
|
The inter-spike interval threshold (ms) used to separate intra-burst ISIs from inter-burst gaps. Always set, even when no bursts were detected, so downstream consumers can display the threshold that was applied. |
threshold_method |
str
|
How :attr: |
Source code in neuroclamp/analysis/burst_metrics.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
BurstMetrics
dataclass
¶
Metrics for a single detected burst.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
Zero-based burst number within the trace. |
start_time |
float
|
Peak time of the first spike in the burst (ms). |
end_time |
float
|
Peak time of the last spike in the burst (ms). |
duration |
float
|
|
spike_count |
int
|
Number of spikes contained in the burst. |
intra_burst_frequency |
float | None
|
Mean firing rate within the burst (Hz),
computed as |
mean_intra_burst_isi |
float | None
|
Mean of the inter-spike intervals inside the
burst (ms). |
Source code in neuroclamp/analysis/burst_metrics.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
CalciumTransient
dataclass
¶
Metrics for a single detected calcium transient.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
Zero-based transient number within the trace. |
onset_time |
float
|
Time at which the rise from baseline begins (ms). |
peak_time |
float
|
Time of peak [Ca²⁺]ᵢ (ms). |
peak_concentration |
float
|
Peak [Ca²⁺]ᵢ (µM). |
baseline_concentration |
float
|
Per-transient baseline [Ca²⁺]ᵢ (µM), measured
in a small window before |
amplitude |
float
|
|
time_to_peak |
float
|
Duration from onset to peak (ms). |
decay_tau |
float | None
|
Decay time constant from the exponential fit (ms), or
|
decay_fit_converged |
bool
|
|
Source code in neuroclamp/analysis/calcium_transients.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
CalciumTransientAnalysisResult
dataclass
¶
Complete calcium-transient analysis of a [Ca²⁺]ᵢ trace.
Attributes:
| Name | Type | Description |
|---|---|---|
transient_count |
int
|
Number of detected transients. |
transients |
list[CalciumTransient]
|
Per-transient metrics. |
baseline_concentration |
float | None
|
Global pre-stimulus mean [Ca²⁺]ᵢ (µM), or
|
mean_peak_concentration |
float | None
|
Mean peak [Ca²⁺]ᵢ across detected transients
(µM), or |
mean_time_to_peak |
float | None
|
Mean time-to-peak across detected transients (ms),
or |
mean_decay_tau |
float | None
|
Mean decay τ across transients with a usable τ (ms),
or |
mean_amplitude |
float | None
|
Mean |
Source code in neuroclamp/analysis/calcium_transients.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
FIAnalysisResult
dataclass
¶
Complete F-I analysis from a multi-sweep current clamp simulation.
Points are stored in ascending order of current step. The convenience
properties current_steps, mean_firing_rates,
initial_firing_rates, and steady_state_firing_rates extract the
corresponding field from each point on demand.
Attributes:
| Name | Type | Description |
|---|---|---|
points |
list[FIPoint]
|
Per-step measurements, one entry per current step, sorted by ascending current amplitude. |
Source code in neuroclamp/analysis/fi_curve.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
mean_firing_rates
property
¶
mean_firing_rates
Mean firing rate at each step (Hz), or None for silent steps.
initial_firing_rates
property
¶
initial_firing_rates
Initial firing rate at each step (Hz), or None for silent steps.
steady_state_firing_rates
property
¶
steady_state_firing_rates
Steady-state firing rate at each step (Hz), or None for silent steps.
FIPoint
dataclass
¶
Firing rate measurements for a single current step in an F-I protocol.
Attributes:
| Name | Type | Description |
|---|---|---|
current_step |
float
|
Injected current amplitude during the step (µA/cm²). |
spike_count |
int
|
Number of spikes detected within the stimulus window. |
mean_firing_rate |
float | None
|
Mean firing rate in Hz ( |
initial_firing_rate |
float | None
|
Initial firing rate in Hz ( |
steady_state_firing_rate |
float | None
|
Steady-state firing rate in Hz
( |
Source code in neuroclamp/analysis/fi_curve.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
BoltzmannFit
dataclass
¶
Fitted parameters for a two-parameter Boltzmann sigmoid.
The fit uses the function 1 / (1 + exp(-(V - v_half) / k)).
Attributes:
| Name | Type | Description |
|---|---|---|
v_half |
float
|
Half-activation voltage (mV). |
k |
float
|
Slope factor (mV). Larger values mean shallower activation. |
converged |
bool
|
|
Source code in neuroclamp/analysis/gv_curve.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
GVAnalysisResult
dataclass
¶
Complete g-V analysis from a multi-sweep voltage clamp simulation.
Points are sorted in ascending order of voltage step. The convenience
properties voltage_steps, conductances, and g_normalized_values
extract the corresponding field from each point on demand.
Attributes:
| Name | Type | Description |
|---|---|---|
points |
list[GVPoint]
|
Per-step conductance records, sorted by ascending voltage. |
boltzmann |
BoltzmannFit
|
Fitted Boltzmann parameters (may have |
reversal_potential |
float
|
Reversal potential used for conductance computation (mV). |
Source code in neuroclamp/analysis/gv_curve.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
GVPoint
dataclass
¶
Conductance measurement for a single voltage step in a g-V protocol.
Attributes:
| Name | Type | Description |
|---|---|---|
voltage_step |
float
|
Command voltage applied during the step (mV). |
conductance |
float
|
Chord conductance at this step (mS/cm²). |
g_normalized |
float
|
Conductance normalized to G/G_max (dimensionless, 0–1). |
Source code in neuroclamp/analysis/gv_curve.py
32 33 34 35 36 37 38 39 40 41 42 43 44 | |
HyperpolarizationAnalysisResult
dataclass
¶
Complete hyperpolarization analysis from a multi-sweep simulation.
Points are stored in ascending order of current step (most negative first). Convenience properties extract each field across all points.
Attributes:
| Name | Type | Description |
|---|---|---|
points |
list[SagPoint]
|
Per-step measurements, one entry per sweep, sorted by ascending (most negative) current amplitude. |
Source code in neuroclamp/analysis/hyperpolarization.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
SagPoint
dataclass
¶
Sag and rebound measurements for a single hyperpolarizing current step.
Attributes:
| Name | Type | Description |
|---|---|---|
current_step |
float
|
Injected current amplitude during the step (µA/cm², negative). |
peak_voltage |
float
|
Most negative membrane voltage reached during the step (mV). |
steady_state_voltage |
float
|
Mean membrane voltage over the last 50 ms of the step (mV). |
sag_amplitude |
float
|
Depolarizing drift during the step in mV
( |
rebound_spike_count |
int
|
Number of action potentials detected in the
|
Source code in neuroclamp/analysis/hyperpolarization.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
ImpedanceProfile
dataclass
¶
Membrane impedance profile from a chirp current-clamp run.
The per-area spectra (magnitude) and the band-maximum impedance
(max_impedance) are always populated. When area_cm2 is supplied to
:func:analyze_impedance, the absolute counterparts (magnitude_mohm,
max_impedance_mohm, peak_impedance_mohm) are filled in too —
analogous to the per-area / absolute split in
:class:~neuroclamp.analysis.passive_properties.PassiveProperties.
resonance_frequency, peak_impedance and quality_factor are all
None together unless |Z(f)| has a genuine resonance — an interior
peak that both rises meaningfully above the low-frequency reference and
has a half-power (−3 dB) width that can be bracketed inside the analysis
band and is at least one FFT bin wide. A passive low-pass cell, or one
whose mild interior bump has no bracketable bandwidth, reports None for
all three; its max_impedance (the band-edge value, ≈ the input
impedance) is still available.
Attributes:
| Name | Type | Description |
|---|---|---|
frequencies |
list[float]
|
Analysis-band frequency axis in Hz, ascending. |
magnitude |
list[float]
|
|
phase |
list[float]
|
|
max_impedance |
float
|
The maximum of |
resonance_frequency |
float | None
|
Frequency of the |
peak_impedance |
float | None
|
|
quality_factor |
float | None
|
Dimensionless |
magnitude_mohm |
list[float] | None
|
|
max_impedance_mohm |
float | None
|
|
peak_impedance_mohm |
float | None
|
Absolute peak impedance in MΩ when |
area_cm2 |
float | None
|
Membrane surface area in cm² used for the absolute
conversion. |
f_start |
float
|
Lower edge of the requested analysis band in Hz. |
f_end |
float
|
Upper edge of the requested analysis band in Hz. |
analyzed_window_ms |
float | None
|
|
Source code in neuroclamp/analysis/impedance.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
InactivationAnalysisResult
dataclass
¶
Complete steady-state inactivation analysis from a two-pulse simulation.
Points are sorted in ascending order of prepulse voltage. The convenience
properties prepulse_voltages, peak_inward_currents, and
h_normalized_values extract the corresponding field from each point on
demand.
The fitted Boltzmann parameterizes a decreasing sigmoid
h∞(V) = 1 / (1 + exp((V - v_half) / k)) with k > 0 — equivalently
boltzmann(V, v_half, -k) using the shared
:func:~neuroclamp.analysis.gv_curve.boltzmann function (which is the
increasing activation form). Callers reconstructing the fit curve must
therefore negate k.
Attributes:
| Name | Type | Description |
|---|---|---|
points |
list[InactivationPoint]
|
Per-prepulse availability records, sorted by ascending prepulse voltage. |
boltzmann |
BoltzmannFit
|
Fitted Boltzmann parameters (may have |
Source code in neuroclamp/analysis/inactivation.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
prepulse_voltages
property
¶
prepulse_voltages
Conditioning prepulse voltages in mV, sorted ascending.
peak_inward_currents
property
¶
peak_inward_currents
Test-pulse peak inward currents in µA/cm² at each prepulse.
h_normalized_values
property
¶
h_normalized_values
h∞ availability values (dimensionless, 0–1) at each prepulse.
InactivationPoint
dataclass
¶
Availability measurement for a single conditioning prepulse voltage.
Attributes:
| Name | Type | Description |
|---|---|---|
prepulse_voltage |
float
|
Conditioning prepulse voltage held before the fixed test pulse (mV). |
peak_inward_current |
float
|
Most negative (inward) current measured during the test pulse for this prepulse (µA/cm²). |
h_normalized |
float
|
Availability normalized to h∞ = I_peak / I_peak_max, where I_peak_max is the most negative peak across all prepulses (dimensionless, clamped to 0–1). |
Source code in neuroclamp/analysis/inactivation.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
IVAnalysisResult
dataclass
¶
Complete I-V analysis from a multi-sweep voltage clamp simulation.
Points are stored in ascending order of voltage step. The convenience
properties voltage_steps, peak_inward_currents,
peak_outward_currents, and steady_state_currents extract the
corresponding field from each point on demand.
Attributes:
| Name | Type | Description |
|---|---|---|
points |
list[IVPoint]
|
Per-step measurements, one entry per voltage step, sorted by ascending voltage. |
Source code in neuroclamp/analysis/iv_curve.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
IVPoint
dataclass
¶
Current measurements for a single voltage step in an I-V protocol.
Attributes:
| Name | Type | Description |
|---|---|---|
voltage_step |
float
|
Command voltage applied during the step (mV). |
peak_inward_current |
float
|
Most negative (inward) current during the step (µA/cm²). |
peak_outward_current |
float
|
Most positive (outward) current during the step (µA/cm²). |
steady_state_current |
float
|
Mean current over the last 10% of the stimulus window (µA/cm²). |
Source code in neuroclamp/analysis/iv_curve.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
PassiveProperties
dataclass
¶
Passive membrane properties extracted from a subthreshold current clamp step.
The per-area density values (input_resistance, membrane_capacitance)
are always populated. When area_cm2 is supplied to
:func:analyze_passive_properties, the absolute counterparts
(input_resistance_mohm, membrane_capacitance_pf) are filled in too.
time_constant is the same numeric value in both modes — τₘ = R · C is
invariant to the per-area / absolute conversion.
Attributes:
| Name | Type | Description |
|---|---|---|
input_resistance |
float
|
Input resistance in kΩ·cm² (R_in = ΔV / ΔI where ΔV is in mV and ΔI is in µA/cm²). |
time_constant |
float
|
Membrane time constant in ms from exponential fit. Numerically identical regardless of whether area is supplied. |
membrane_capacitance |
float | None
|
Derived C_m = τ_m / R_in in µF/cm², or |
fit_converged |
bool
|
|
input_resistance_mohm |
float | None
|
Absolute input resistance in MΩ when
|
membrane_capacitance_pf |
float | None
|
Absolute membrane capacitance in pF when
|
area_cm2 |
float | None
|
Membrane surface area in cm² used to compute the absolute
values. |
Source code in neuroclamp/analysis/passive_properties.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
SFAAnalysisResult
dataclass
¶
Spike-frequency adaptation analysis, possibly across multiple sweeps.
Attributes:
| Name | Type | Description |
|---|---|---|
curves |
list[SFACurve]
|
One :class: |
Source code in neuroclamp/analysis/sfa.py
40 41 42 43 44 45 46 47 48 49 | |
SFACurve
dataclass
¶
Instantaneous-frequency curve for a single current clamp sweep.
Attributes:
| Name | Type | Description |
|---|---|---|
spike_indices |
list[int]
|
Zero-based index for each ISI pair (0, 1, 2, …).
Length equals |
instantaneous_frequencies |
list[float]
|
Instantaneous firing frequency in Hz
( |
adaptation_index |
float
|
|
label |
str
|
Optional display label for multi-sweep overlay (e.g.
|
Source code in neuroclamp/analysis/sfa.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
DoubleExponentialFit
dataclass
¶
Fitted parameters for the two-exponential decay model.
The model is A_fast * exp(-t/τ_fast) + A_slow * exp(-t/τ_slow) + C,
with the convention τ_fast <= τ_slow enforced by
:func:compute_tau_v_point after fitting.
Attributes:
| Name | Type | Description |
|---|---|---|
amplitude_fast |
float
|
Fast component pre-exponential. |
tau_fast_ms |
float
|
Faster of the two time constants (ms). |
amplitude_slow |
float
|
Slow component pre-exponential. |
tau_slow_ms |
float
|
Slower of the two time constants (ms). |
offset |
float
|
Baseline / asymptote |
converged |
bool
|
|
rss |
float
|
Residual sum of squares of the fit. |
Source code in neuroclamp/analysis/tau_v.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
ExponentialFit
dataclass
¶
Fitted parameters for a single exponential model.
Attributes:
| Name | Type | Description |
|---|---|---|
amplitude |
float
|
Pre-exponential coefficient |
tau_ms |
float
|
Time constant τ in ms. |
offset |
float
|
Baseline / asymptote |
converged |
bool
|
|
rss |
float
|
Residual sum of squares of the fit; used to compare against
the double-exponential fit. |
Source code in neuroclamp/analysis/tau_v.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
TauVAnalysisResult
dataclass
¶
Aggregate τ-V analysis from a multi-sweep voltage clamp simulation.
Points are sorted in ascending order of voltage step.
Attributes:
| Name | Type | Description |
|---|---|---|
points |
list[TauVPoint]
|
Per-step time constants, sorted by ascending voltage. |
Source code in neuroclamp/analysis/tau_v.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
tau_activation_values
property
¶
tau_activation_values
Activation τ (ms) at each voltage step (None for skipped/failed fits).
tau_inactivation_values
property
¶
tau_inactivation_values
Inactivation τ (ms) at each voltage step (None for skipped/failed fits).
When a double-exponential fit was accepted at a step, this is the
fast component; the slow component is in
:attr:tau_inactivation_slow_values.
tau_inactivation_slow_values
property
¶
tau_inactivation_slow_values
Slow inactivation τ (ms) at each step where a double-exp fit was accepted.
TauVPoint
dataclass
¶
Time-constant measurements for a single voltage step.
All τ fields are None when the corresponding fit was skipped (window
too short, no inactivation phase observed, etc.) or did not converge.
The *_converged flags distinguish between "skipped" (τ is None
and converged is False) and "fit succeeded" (τ is a float and
converged is True).
Attributes:
| Name | Type | Description |
|---|---|---|
voltage_step |
float
|
Command voltage applied during the step (mV). |
tau_activation_ms |
float | None
|
Time constant of the rising phase (ms), or
|
tau_inactivation_ms |
float | None
|
Fast time constant of the decaying phase
(ms), or |
tau_inactivation_slow_ms |
float | None
|
Slow time constant of the decaying phase
(ms). Populated only when |
activation_converged |
bool
|
|
inactivation_converged |
bool
|
|
inactivation_is_double |
bool
|
|
Source code in neuroclamp/analysis/tau_v.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
analyze_aps ¶
analyze_aps(time, voltage, dvdt_threshold=20.0, min_spike_height=-20.0)
Extract action potential metrics from a voltage trace.
Spikes are detected by finding upward crossings of dvdt_threshold in
the dV/dt signal. For each candidate crossing the subsequent voltage peak
is located. Candidates are rejected when the peak is below
min_spike_height or when they fall within a refractory window after
the previous accepted spike.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Time array in ms, shape |
required |
voltage
|
ndarray
|
Membrane voltage in mV, shape |
required |
dvdt_threshold
|
float
|
dV/dt value (mV/ms) used to identify spike onset. The default of 20 mV/ms is standard for HH-type models. |
20.0
|
min_spike_height
|
float
|
Minimum peak voltage (mV) for a candidate event to be classified as a spike. Subthreshold oscillations typically peak well below 0 mV. |
-20.0
|
Returns:
| Name | Type | Description |
|---|---|---|
An |
APAnalysisResult
|
class: |
APAnalysisResult
|
aggregate summary statistics. |
Source code in neuroclamp/analysis/ap_metrics.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
analyze_aps_from_result ¶
analyze_aps_from_result(result, dvdt_threshold=20.0, min_spike_height=-20.0)
Extract AP metrics from a :class:~neuroclamp.SimulationResult.
Convenience wrapper around :func:analyze_aps that pulls the "time"
and "voltage" fields from the structured array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
SimulationResult
|
A structured NumPy array returned by
:func: |
required |
dvdt_threshold
|
float
|
dV/dt threshold for spike onset detection (mV/ms). |
20.0
|
min_spike_height
|
float
|
Minimum peak voltage for a valid spike (mV). |
-20.0
|
Returns:
| Name | Type | Description |
|---|---|---|
An |
APAnalysisResult
|
class: |
Source code in neuroclamp/analysis/ap_metrics.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
analyze_bursts ¶
analyze_bursts(ap_result, *, total_duration_ms, isi_threshold_ms=None, min_spikes_per_burst=_DEFAULT_MIN_SPIKES_PER_BURST, _trace_end_time_ms=None)
Group detected spikes into bursts and compute burst metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ap_result
|
APAnalysisResult
|
AP analysis from :func: |
required |
total_duration_ms
|
float
|
Length of the recording window (ms). Used as the
denominator of :attr: |
required |
isi_threshold_ms
|
float | None
|
Optional user-supplied threshold (ms). When
|
None
|
min_spikes_per_burst
|
int
|
Minimum spike count for a group to count as a
burst. Defaults to 2; isolated spikes are tracked via
:attr: |
_DEFAULT_MIN_SPIKES_PER_BURST
|
_trace_end_time_ms
|
float | None
|
Last time point of the recording (ms), used as
the quiescent-window reference for the LTS termination check
when an oversized cluster ends at the last spike. When
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
BurstAnalysisResult
|
class: |
Source code in neuroclamp/analysis/burst_metrics.py
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | |
analyze_bursts_from_result ¶
analyze_bursts_from_result(result, *, isi_threshold_ms=None, min_spikes_per_burst=_DEFAULT_MIN_SPIKES_PER_BURST, dvdt_threshold=20.0, min_spike_height=-20.0)
Extract burst metrics from a :class:SimulationResult.
Convenience wrapper that runs :func:analyze_aps_from_result to obtain
the spike list and then forwards to :func:analyze_bursts. Callers
that have already run :func:~neuroclamp.analyze_aps (or
:func:~neuroclamp.analyze_aps_from_result) on the same trace should
prefer :func:analyze_bursts directly to avoid re-detecting spikes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
SimulationResult
|
A structured NumPy array returned by
:func: |
required |
isi_threshold_ms
|
float | None
|
Optional user-supplied threshold (ms). |
None
|
min_spikes_per_burst
|
int
|
Minimum spike count for a burst. |
_DEFAULT_MIN_SPIKES_PER_BURST
|
dvdt_threshold
|
float
|
dV/dt threshold passed to spike detection (mV/ms). |
20.0
|
min_spike_height
|
float
|
Minimum peak voltage for spike detection (mV). |
-20.0
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
BurstAnalysisResult
|
class: |
Source code in neuroclamp/analysis/burst_metrics.py
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 | |
analyze_calcium_transients ¶
analyze_calcium_transients(time, ca_i, *, prominence_uM=_DEFAULT_PROMINENCE_UM, min_separation_ms=_DEFAULT_MIN_SEPARATION_MS, max_decay_window_ms=_MAX_DECAY_WINDOW_MS)
Detect calcium transients and extract peak, time-to-peak, and decay τ.
Transients are detected with :func:scipy.signal.find_peaks using a
prominence criterion expressed in µM; this is robust to slow baseline
drift and does not require an absolute height threshold. For each
detected peak the function locates the rise onset, computes a
per-transient baseline from a short pre-onset window, and fits a
single-exponential decay to the falling phase using
:func:scipy.optimize.curve_fit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Time array in ms, shape |
required |
ca_i
|
ndarray
|
Intracellular [Ca²⁺] in mM, shape |
required |
prominence_uM
|
float
|
Minimum peak prominence in µM. Defaults to 0.05 µM (50 nM), which sits well above typical resting fluctuations and below typical AP-evoked transient amplitudes. |
_DEFAULT_PROMINENCE_UM
|
min_separation_ms
|
float
|
Minimum spacing between detected peaks in ms. |
_DEFAULT_MIN_SEPARATION_MS
|
max_decay_window_ms
|
float
|
Cap on the decay-fit window in ms. |
_MAX_DECAY_WINDOW_MS
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
CalciumTransientAnalysisResult
|
class: |
CalciumTransientAnalysisResult
|
aggregate metrics in µM and ms. |
Source code in neuroclamp/analysis/calcium_transients.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | |
analyze_calcium_transients_from_result ¶
analyze_calcium_transients_from_result(result, *, prominence_uM=_DEFAULT_PROMINENCE_UM, min_separation_ms=_DEFAULT_MIN_SEPARATION_MS, max_decay_window_ms=_MAX_DECAY_WINDOW_MS)
Extract calcium transient metrics from a :class:SimulationResult.
Convenience wrapper around :func:analyze_calcium_transients that pulls
the "time" and "ca_i" fields from the structured array. Returns
None when ca_i is absent (i.e. calcium dynamics were not active
during the simulation).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
SimulationResult
|
A structured NumPy array returned by
:func: |
required |
prominence_uM
|
float
|
Minimum peak prominence in µM. |
_DEFAULT_PROMINENCE_UM
|
min_separation_ms
|
float
|
Minimum spacing between detected peaks in ms. |
_DEFAULT_MIN_SEPARATION_MS
|
max_decay_window_ms
|
float
|
Cap on the decay-fit window in ms. |
_MAX_DECAY_WINDOW_MS
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
CalciumTransientAnalysisResult | None
|
class: |
CalciumTransientAnalysisResult | None
|
otherwise |
Source code in neuroclamp/analysis/calcium_transients.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
compute_dvdt ¶
compute_dvdt(time, voltage)
Compute dV/dt from time and voltage arrays.
Uses np.gradient (central differences) so the output length matches
the input length, avoiding the off-by-one issue of np.diff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ArrayLike
|
Time array in ms (length N). |
required |
voltage
|
ArrayLike
|
Membrane voltage array in mV (length N). |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Returns:
| Type | Description |
|---|---|
ndarray
|
|
ndarray
|
If |
Source code in neuroclamp/analysis/derivatives.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
analyze_fi ¶
analyze_fi(time, voltages, current_steps, stim_start_ms, stim_end_ms)
Compute F-I curve from a multi-sweep current clamp simulation.
Calls :func:compute_fi_point for each sweep and assembles the results,
sorted in ascending order of current step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Shared time axis in ms (same for all sweeps). |
required |
voltages
|
list[ndarray]
|
List of membrane voltage arrays (mV), one per sweep. |
required |
current_steps
|
list[float]
|
Injected current amplitude (µA/cm²) for each sweep,
parallel to |
required |
stim_start_ms
|
float
|
Start of the stimulus window in ms. |
required |
stim_end_ms
|
float
|
End of the stimulus window in ms. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
An |
FIAnalysisResult
|
class: |
FIAnalysisResult
|
current amplitude. |
Source code in neuroclamp/analysis/fi_curve.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
compute_fi_point ¶
compute_fi_point(time, voltage, current_step, stim_start_ms, stim_end_ms)
Compute F-I metrics for a single current step sweep.
Detects spikes using :func:~neuroclamp.analysis.ap_metrics.analyze_aps
and delegates to :func:_fi_point_from_ap_result for the rate computation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Time axis array in ms. |
required |
voltage
|
ndarray
|
Membrane voltage array in mV, same length as |
required |
current_step
|
float
|
Injected current amplitude during the step (µA/cm²). |
required |
stim_start_ms
|
float
|
Start of the stimulus window in ms. |
required |
stim_end_ms
|
float
|
End of the stimulus window in ms. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
An |
FIPoint
|
class: |
FIPoint
|
this current step. |
Source code in neuroclamp/analysis/fi_curve.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
estimate_rheobase ¶
estimate_rheobase(fi_result)
Estimate the rheobase from F-I analysis results.
The rheobase is the minimum injected current that elicits at least one action potential. It is identified as the lowest current step with a non-zero spike count. A single spike qualifies as suprathreshold even though it produces no ISI-derived firing rate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fi_result
|
FIAnalysisResult
|
F-I analysis result. Points may be in any order. |
required |
Returns:
| Type | Description |
|---|---|
float | None
|
The rheobase current in µA/cm² (the |
float | None
|
class: |
float | None
|
sweep produced a spike. |
Source code in neuroclamp/analysis/fi_curve.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
boltzmann ¶
boltzmann(V, v_half, k)
Evaluate the two-parameter Boltzmann sigmoid.
Computes the standard voltage-dependent activation function::
f(V) = 1 / (1 + exp(-(V - v_half) / k))
Accepts either a scalar float or a NumPy array for V, which allows the
function to be used directly with scipy.optimize.curve_fit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
V
|
float | ndarray
|
Membrane voltage in mV. May be a scalar or a 1-D NumPy array. |
required |
v_half
|
float
|
Half-activation voltage (mV). |
required |
k
|
float
|
Slope factor (mV). |
required |
Returns:
| Type | Description |
|---|---|
float | ndarray
|
Sigmoid value in [0, 1]. Returns a NumPy array when V is an array, |
float | ndarray
|
or a float when V is a scalar. |
Source code in neuroclamp/analysis/gv_curve.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
compute_gv ¶
compute_gv(iv_result, reversal_potential, driving_force_threshold=5.0)
Compute normalized conductance vs. voltage from I-V analysis results.
For each voltage step the chord conductance is::
g(V) = I_peak_inward / (V - E_rev)
where E_rev is the supplied reversal potential. Points where the
absolute driving force |V - E_rev| is below driving_force_threshold
are excluded to avoid division-by-near-zero artefacts. Points that
produce non-positive conductances (physically implausible for the inward
activation curve) are also excluded.
The retained conductances are normalized to G/G_max, then a Boltzmann
sigmoid is fitted via scipy.optimize.curve_fit. If the fit does not
converge, :attr:BoltzmannFit.converged is False and the parameter
values are 0.0 and 1.0 respectively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iv_result
|
IVAnalysisResult
|
Pre-computed I-V analysis result containing per-step peak inward currents. |
required |
reversal_potential
|
float
|
Reversal potential used to compute driving force (mV). Typically the Nernst potential for the dominant inward current carrier (e.g. E_Na). |
required |
driving_force_threshold
|
float
|
Minimum absolute driving force (mV) required
for a point to be included. Defaults to |
5.0
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
GVAnalysisResult
|
class: |
GVAnalysisResult
|
and Boltzmann fit parameters. |
Source code in neuroclamp/analysis/gv_curve.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
analyze_hyperpolarization ¶
analyze_hyperpolarization(time, voltages, current_steps, stim_start_ms, stim_end_ms, rebound_window_ms=50.0)
Compute sag and rebound metrics from a multi-sweep hyperpolarization run.
Calls :func:compute_sag_point for each sweep and assembles the results,
sorted in ascending order of current step (most negative first). Rebound
spike counts are mechanism-agnostic; see the module docstring for the
mechanisms that contribute in different neuron models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Shared time axis in ms (same for all sweeps). |
required |
voltages
|
list[ndarray]
|
List of membrane voltage arrays (mV), one per sweep. |
required |
current_steps
|
list[float]
|
Injected current amplitude (µA/cm²) for each sweep,
parallel to |
required |
stim_start_ms
|
float
|
Start of the current step in ms. |
required |
stim_end_ms
|
float
|
End of the current step in ms. |
required |
rebound_window_ms
|
float
|
Duration of the post-step window in which rebound spikes are counted (ms). |
50.0
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
HyperpolarizationAnalysisResult
|
class: |
HyperpolarizationAnalysisResult
|
sorted by current amplitude (most negative first). |
Source code in neuroclamp/analysis/hyperpolarization.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
compute_sag_point ¶
compute_sag_point(time, voltage, current_step, stim_start_ms, stim_end_ms, rebound_window_ms=50.0, steady_state_fraction=0.15)
Compute sag and rebound metrics for a single hyperpolarizing sweep.
Peak voltage is the minimum of the voltage trace during the step.
Steady-state voltage is the mean over the last steady_state_fraction of
the step duration. Rebound spikes are action potentials whose peak time
falls within [stim_end_ms, stim_end_ms + rebound_window_ms]. The count
is mechanism-agnostic: ICaT de-inactivation, Ih overshoot, and HH anode-break
excitation all contribute equally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Time axis array in ms. |
required |
voltage
|
ndarray
|
Membrane voltage array in mV, same length as |
required |
current_step
|
float
|
Injected current amplitude during the step (µA/cm²). |
required |
stim_start_ms
|
float
|
Start of the current step in ms. |
required |
stim_end_ms
|
float
|
End of the current step in ms. |
required |
rebound_window_ms
|
float
|
Duration of the post-step window in which rebound spikes are counted (ms). |
50.0
|
steady_state_fraction
|
float
|
Fraction of the step duration used to compute the steady-state voltage (trailing portion of the step). |
0.15
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
SagPoint
|
class: |
Source code in neuroclamp/analysis/hyperpolarization.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
analyze_impedance ¶
analyze_impedance(time, voltage, injected_current, stim_start_ms, stim_end_ms, f_start, f_end, area_cm2=None)
Compute the membrane impedance profile from a chirp current-clamp run.
Extracts the chirp window from the traces, removes the DC component from
both signals, takes the real FFT of each (numpy.fft.rfft), forms
Z(f) = V̂(f) / Î(f) over the swept band [f_start, f_end] (keeping
only the longest contiguous run of FFT bins where the chirp has usable
spectral power), and reports the magnitude and phase spectra, the
band-maximum impedance, plus — when a genuine resonance is present — the
resonance frequency and quality factor. A genuine resonance requires an
interior |Z| maximum that clears the prominence margin over the
low-frequency reference and has a half-power (−3 dB) width that is both
bracketable inside the band and at least one FFT bin wide;
resonance_frequency, peak_impedance and quality_factor are
otherwise all None.
Membrane impedance is a linear, small-signal quantity, so spike transients
are excluded: when the windowed response contains spikes the analysis falls
back to the longest contiguous spike-free sub-window (a linear chirp's
frequency is time-dependent, so the recovered profile then covers only a
sub-band of [f_start, f_end] — surfaced via
:attr:ImpedanceProfile.analyzed_window_ms). The analysis bails out
(returns None) when no such spike-free segment is long enough — see
:func:impedance_unavailable_reason for the user-facing reason.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Time axis in ms, assumed uniformly sampled (the FFT frequency axis is derived from the mean sample interval). |
required |
voltage
|
ndarray
|
Membrane voltage response in mV. |
required |
injected_current
|
ndarray
|
Injected chirp current in µA/cm². |
required |
stim_start_ms
|
float
|
Start of the chirp stimulus window in ms. |
required |
stim_end_ms
|
float
|
End of the chirp stimulus window in ms. |
required |
f_start
|
float
|
Starting frequency of the chirp sweep in Hz. |
required |
f_end
|
float
|
Ending frequency of the chirp sweep in Hz. |
required |
area_cm2
|
float | None
|
Optional membrane surface area in cm². When supplied, the
absolute MΩ counterparts ( |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
An |
ImpedanceProfile | None
|
class: |
ImpedanceProfile | None
|
inconsistent (mismatched lengths, non-finite values), the band is |
|
ImpedanceProfile | None
|
invalid ( |
|
ImpedanceProfile | None
|
shorter than :data: |
|
ImpedanceProfile | None
|
chirp (no spike-free segment of at least :data: |
|
ImpedanceProfile | None
|
stimulus has no spectral power in the band, or fewer than |
|
ImpedanceProfile | None
|
data: |
Source code in neuroclamp/analysis/impedance.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | |
impedance_unavailable_reason ¶
impedance_unavailable_reason(time, voltage, injected_current, stim_start_ms, stim_end_ms, f_start, f_end)
Return a human-readable reason impedance analysis can't proceed, or "".
Returns the empty string when the cheap pre-FFT checks pass (so the
analysis would proceed past the windowing / suprathreshold guards), letting
callers use the result directly as UI copy. Only those pre-FFT failure
modes are reported — when this returns "" and :func:analyze_impedance
still returns None, the caller should fall back to a generic "too little
usable signal in the band" message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Time axis in ms. |
required |
voltage
|
ndarray
|
Membrane voltage response in mV. |
required |
injected_current
|
ndarray
|
Injected chirp current in µA/cm². |
required |
stim_start_ms
|
float
|
Start of the chirp stimulus window in ms. |
required |
stim_end_ms
|
float
|
End of the chirp stimulus window in ms. |
required |
f_start
|
float
|
Starting frequency of the chirp sweep in Hz. |
required |
f_end
|
float
|
Ending frequency of the chirp sweep in Hz. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A single-sentence reason string, or |
str
|
pass. |
Source code in neuroclamp/analysis/impedance.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
compute_inactivation ¶
compute_inactivation(iv_result)
Compute normalized availability vs. prepulse voltage from I-V results.
Each :class:~neuroclamp.analysis.iv_curve.IVPoint in iv_result is assumed
to come from one sweep of a two-pulse inactivation protocol: its
voltage_step is the conditioning prepulse voltage and its
peak_inward_current is the most negative current measured during the
fixed test pulse. Availability is::
h∞(V) = I_peak(V) / I_peak_max
where I_peak_max is the most negative peak across all prepulses; the
ratio is clamped to [0, 1] (a non-negative test-pulse peak — full
inactivation, possibly net outward — maps to 0.0).
A decreasing Boltzmann sigmoid h∞(V) = 1 / (1 + exp((V - v_half) / k))
is then fitted via scipy.optimize.curve_fit. When the fit does not
converge, :attr:BoltzmannFit.converged is False and the parameter
values are 0.0 and 1.0 respectively. The returned k is positive
and the fit curve is reconstructed as boltzmann(V, v_half, -k).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iv_result
|
IVAnalysisResult
|
Pre-computed I-V analysis result whose stimulus window is the two-pulse protocol's fixed test pulse, with one point per conditioning prepulse voltage. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
An |
InactivationAnalysisResult
|
class: |
InactivationAnalysisResult
|
availability records and Boltzmann fit parameters. |
|
InactivationAnalysisResult
|
only when iv_result itself is empty. |
Source code in neuroclamp/analysis/inactivation.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
analyze_iv ¶
analyze_iv(time, currents, voltage_steps, stim_start_ms, stim_end_ms)
Compute I-V curve from a multi-sweep voltage clamp simulation.
Calls :func:compute_iv_point for each sweep and assembles the results,
sorted in ascending order of voltage step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Shared time axis in ms (same for all sweeps). |
required |
currents
|
list[ndarray]
|
List of total ionic current arrays (µA/cm²), one per sweep. |
required |
voltage_steps
|
list[float]
|
Command voltage (mV) for each sweep, parallel to
|
required |
stim_start_ms
|
float
|
Start of the stimulus window in ms. |
required |
stim_end_ms
|
float
|
End of the stimulus window in ms. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
An |
IVAnalysisResult
|
class: |
IVAnalysisResult
|
voltage. |
Source code in neuroclamp/analysis/iv_curve.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
compute_iv_point ¶
compute_iv_point(time, current, voltage_step, stim_start_ms, stim_end_ms)
Compute I-V metrics for a single voltage step sweep.
The stimulus window is identified using the provided timing boundaries. Peak inward current is the minimum (most negative) value in the window; peak outward current is the maximum (most positive) value. Steady-state current is the mean of the last 10% of the stimulus window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Time axis array in ms. |
required |
current
|
ndarray
|
Total ionic current array in µA/cm², same length as |
required |
voltage_step
|
float
|
Command voltage applied during the step (mV). |
required |
stim_start_ms
|
float
|
Start of the stimulus window in ms. |
required |
stim_end_ms
|
float
|
End of the stimulus window in ms. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
An |
IVPoint
|
class: |
IVPoint
|
current measurements for this voltage step. |
Source code in neuroclamp/analysis/iv_curve.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
run_membrane_test ¶
run_membrane_test(neuron)
Run a dedicated membrane test on the given neuron and extract passive properties.
Constructs a passive-only copy of the neuron — only ungated channels are
retained, and v_rest is set to the leak equilibrium (E_L) — to simulate
the equivalent of pharmacological channel block (TTX + TEA). This ensures
the step response is a clean single exponential driven by the passive RC
circuit, giving an accurate R_in, τ_m, and C_m rather than values
contaminated by K⁺ channel deactivation sag.
Passive channels are identified by ch.gating_variables == (); their
g_max (along with the neuron's C_m, ion concentrations, and
temperature) is preserved so R_in = 1 / Σ g_max and C_m match the
configured membrane parameters.
When neuron.area_cm2 is set, the returned :class:PassiveProperties
carries absolute MΩ / pF counterparts alongside the per-area density
values. When it is None, only density values are populated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neuron
|
Neuron
|
A fully configured :class: |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
PassiveProperties | None
|
class: |
PassiveProperties | None
|
instance when extraction succeeds, or |
|
PassiveProperties | None
|
converge (should not occur for a pure RC circuit). |
Source code in neuroclamp/analysis/membrane_test.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
analyze_passive_properties ¶
analyze_passive_properties(time, voltage, current_amplitude, stim_start_ms, stim_end_ms, max_fit_window_ms=_MAX_FIT_WINDOW_MS, area_cm2=None)
Extract input resistance and membrane time constant from a CC step response.
Returns None when the sweep is suprathreshold (contains spikes) or when
current_amplitude is zero (R_in cannot be computed). Also returns
None when the stimulus duration is shorter than
:data:_MIN_STIM_DURATION_MS.
R_in is computed as ΔV / ΔI where ΔV is the steady-state voltage
deflection from baseline and ΔI is current_amplitude. The result is
in kΩ·cm² (mV / µA·cm⁻²).
τₘ is obtained by fitting V(t) = V_ss + A·exp(-t/τ) to the rising
(or falling) phase of the response using
:func:scipy.optimize.curve_fit. If the fit fails, a fallback estimate
based on the 63.2%-deflection crossing time is used and
fit_converged is set to False.
Cₘ is derived as τₘ / R_in. When R_in is zero, membrane_capacitance
is None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Time array in ms, shape |
required |
voltage
|
ndarray
|
Membrane voltage in mV, shape |
required |
current_amplitude
|
float
|
Injected current step amplitude in µA/cm². Must be non-zero for a meaningful R_in estimate. |
required |
stim_start_ms
|
float
|
Time at which the current step begins (ms). |
required |
stim_end_ms
|
float
|
Time at which the current step ends (ms). |
required |
max_fit_window_ms
|
float
|
Maximum duration of the exponential fit window in ms.
Defaults to :data: |
_MAX_FIT_WINDOW_MS
|
area_cm2
|
float | None
|
Optional membrane surface area in cm². When supplied, the
returned :class: |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
PassiveProperties | None
|
class: |
PassiveProperties | None
|
not applicable. |
Source code in neuroclamp/analysis/passive_properties.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | |
density_to_absolute_c_m ¶
density_to_absolute_c_m(c_m_uf_cm2, area_cm2)
Convert per-area membrane capacitance (µF/cm²) to absolute pF.
Derivation: C [pF] = C_m [µF/cm²] × area [cm²] × 1e6.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c_m_uf_cm2
|
float | None
|
Per-area membrane capacitance in µF/cm². |
required |
area_cm2
|
float | None
|
Total membrane surface area in cm². |
required |
Returns:
| Type | Description |
|---|---|
float | None
|
Absolute capacitance in pF, or |
float | None
|
or |
Source code in neuroclamp/analysis/passive_properties.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
density_to_absolute_r_in ¶
density_to_absolute_r_in(input_resistance_kohm_cm2, area_cm2)
Convert per-area input resistance (kΩ·cm²) to absolute MΩ.
Derivation: R_in [kΩ·cm²] / area [cm²] = R_n [kΩ] = R_n [MΩ] × 1000,
so R_n [MΩ] = R_in / area / 1000.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_resistance_kohm_cm2
|
float
|
Per-area input resistance in kΩ·cm². |
required |
area_cm2
|
float | None
|
Total membrane surface area in cm². |
required |
Returns:
| Type | Description |
|---|---|
float | None
|
Absolute input resistance in MΩ, or |
float | None
|
|
Source code in neuroclamp/analysis/passive_properties.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
is_subthreshold ¶
is_subthreshold(time, voltage, dvdt_threshold=20.0, min_spike_height=-20.0)
Return True when a voltage trace contains no detected action potentials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Time array in ms, shape |
required |
voltage
|
ndarray
|
Membrane voltage in mV, shape |
required |
dvdt_threshold
|
float
|
dV/dt value (mV/ms) used to identify spike onset. |
20.0
|
min_spike_height
|
float
|
Minimum peak voltage (mV) for a candidate event to be classified as a spike. |
-20.0
|
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in neuroclamp/analysis/passive_properties.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
longest_subthreshold_run ¶
longest_subthreshold_run(time, voltage, *, dvdt_threshold=20.0, min_spike_height=-20.0)
Find the longest contiguous spike-free span of a voltage trace.
Runs :func:analyze_aps to locate spikes, excises a guard-padded window
around each one — from :data:_SPIKE_GUARD_PRE_MS before its threshold
crossing to :data:_SPIKE_GUARD_POST_MS after its peak, so the
after-hyperpolarization transient is removed too — and returns the widest
remaining gap. When the trace contains no spikes the whole trace is
returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Time array in ms, shape |
required |
voltage
|
ndarray
|
Membrane voltage in mV, shape |
required |
dvdt_threshold
|
float
|
dV/dt value (mV/ms) used to identify spike onset. |
20.0
|
min_spike_height
|
float
|
Minimum peak voltage (mV) for a candidate event to be classified as a spike. |
-20.0
|
Returns:
| Type | Description |
|---|---|
tuple[int, int] | None
|
Half-open index bounds |
tuple[int, int] | None
|
|
tuple[int, int] | None
|
spikes), or |
tuple[int, int] | None
|
inside a guard window. |
Source code in neuroclamp/analysis/passive_properties.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
analyze_sfa ¶
analyze_sfa(ap_results, labels=None)
Compute spike-frequency adaptation curves for multiple sweeps.
Calls :func:compute_sfa for each sweep and collects the non-None
results. Sweeps with fewer than two spikes are silently excluded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ap_results
|
list[APAnalysisResult]
|
List of AP analysis results, one per sweep. |
required |
labels
|
list[str] | None
|
Optional parallel list of display labels, aligned with
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
An |
SFAAnalysisResult
|
class: |
SFAAnalysisResult
|
entry per sweep that had at least two spikes. |
Source code in neuroclamp/analysis/sfa.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
compute_sfa ¶
compute_sfa(ap_result, label='')
Compute an instantaneous-frequency curve from a pre-computed AP analysis.
Reuses ap_result.isis directly; no additional spike detection is run.
Returns None when fewer than two spikes were detected (zero ISIs).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ap_result
|
APAnalysisResult
|
AP analysis result whose |
required |
label
|
str
|
Display label for multi-sweep overlay (e.g. current step). Defaults to an empty string. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
An |
SFACurve | None
|
class: |
Source code in neuroclamp/analysis/sfa.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
analyze_tau_v ¶
analyze_tau_v(time, currents, voltage_steps, stim_start_ms, stim_end_ms, *, fit_inactivation=True)
Compute τ-V from a multi-sweep voltage clamp simulation.
Calls :func:compute_tau_v_point for each sweep and assembles the points
sorted in ascending order of voltage step. Failed individual fits do
not raise; they surface as None τ values on their respective
:class:TauVPoint.
Caveat — total-current vs. isolated-channel kinetics:
When currents is the total membrane current (rather than an
isolated channel current obtained via, e.g. TTX subtraction), the
recovered τ values reflect the dominant channel at each voltage.
At strong depolarizations of an HH-style neuron the total current is
dominated by the much larger sustained K⁺ outward current, which
masks the brief inward Na⁺ inactivation; the τ_inactivation values
at those voltages should not be interpreted as the isolated Na⁺
inactivation time constant. For unambiguous channel-specific
kinetics, run this analysis on a pharmacologically isolated current.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Shared time axis in ms (same for all sweeps). |
required |
currents
|
list[ndarray]
|
List of total ionic current arrays (µA/cm²), one per sweep. |
required |
voltage_steps
|
list[float]
|
Command voltage (mV) for each sweep, parallel to
|
required |
stim_start_ms
|
float
|
Start of the stimulus window in ms. |
required |
stim_end_ms
|
float
|
End of the stimulus window in ms. |
required |
fit_inactivation
|
bool
|
When |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
TauVAnalysisResult
|
class: |
TauVAnalysisResult
|
voltage. |
Source code in neuroclamp/analysis/tau_v.py
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 | |
compute_tau_v_point ¶
compute_tau_v_point(time, current, voltage_step, stim_start_ms, stim_end_ms, *, fit_inactivation=True)
Fit activation and inactivation exponentials for one voltage-clamp sweep.
The stimulus window is split at the absolute-value peak of the current.
The rising segment (start → peak) is fit with :func:single_exp_rise to
extract τ_activation; the decaying segment (peak → end) is fit with
:func:single_exp_decay and, when fit_inactivation is True, also
with :func:double_exp_decay. The double-exponential fit is preferred
only when
- its residual sum of squares improves on the single-exponential fit by
at least :data:
_DOUBLE_FIT_IMPROVEMENT(10%), and - its two τ values differ by at least :data:
_DOUBLE_TAU_RATIO(a factor of 3),
so that a marginal second component does not displace the simpler model.
Failed or skipped fits surface as None τ values; this function never
raises on bad data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Shared time axis in ms (full sweep, not just the step window). |
required |
current
|
ndarray
|
Total ionic current array in µA/cm², same length as |
required |
voltage_step
|
float
|
Command voltage applied during the step (mV). |
required |
stim_start_ms
|
float
|
Start of the stimulus window in ms. |
required |
stim_end_ms
|
float
|
End of the stimulus window in ms. |
required |
fit_inactivation
|
bool
|
When |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
TauVPoint
|
class: |
TauVPoint
|
time constants for this step. |
Source code in neuroclamp/analysis/tau_v.py
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | |
double_exp_decay ¶
double_exp_decay(t, A1, tau1, A2, tau2, C)
Evaluate a two-exponential decay toward an asymptote.
Computes A1 * exp(-t / tau1) + A2 * exp(-t / tau2) + C. Used to
capture inactivation processes with two distinct kinetic components
(e.g. a fast and a slow inactivation gate).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float | ndarray
|
Time in ms (scalar or 1-D array). |
required |
A1
|
float
|
First component amplitude. |
required |
tau1
|
float
|
First component time constant (ms). |
required |
A2
|
float
|
Second component amplitude. |
required |
tau2
|
float
|
Second component time constant (ms). |
required |
C
|
float
|
Asymptote. |
required |
Returns:
| Type | Description |
|---|---|
float | ndarray
|
The model evaluated at |
Source code in neuroclamp/analysis/tau_v.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
single_exp_decay ¶
single_exp_decay(t, A, tau, C)
Evaluate a single-exponential decay toward an asymptote.
Computes A * exp(-t / tau) + C.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float | ndarray
|
Time in ms (scalar or 1-D array, with |
required |
A
|
float
|
Initial amplitude above the asymptote. |
required |
tau
|
float
|
Inactivation time constant (ms). |
required |
C
|
float
|
Asymptote that the trace approaches. |
required |
Returns:
| Type | Description |
|---|---|
float | ndarray
|
The model evaluated at |
Source code in neuroclamp/analysis/tau_v.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
single_exp_rise ¶
single_exp_rise(t, A, tau, C)
Evaluate a single-exponential rise to a plateau.
Computes A * (1 - exp(-t / tau)) + C.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float | ndarray
|
Time in ms (scalar or 1-D array, with |
required |
A
|
float
|
Plateau amplitude. |
required |
tau
|
float
|
Activation time constant (ms). |
required |
C
|
float
|
Baseline / starting offset. |
required |
Returns:
| Type | Description |
|---|---|
float | ndarray
|
The model evaluated at |
Source code in neuroclamp/analysis/tau_v.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |