iSTTC Notebook: Function & Code Documentation
This notebook was developed to estimate intrinsic neural timescales (ITs) from single-unit recordings spanning the entire mouse brain. Timescales are defined as the decay time constant of the autocorrelation function of spontaneous neural activity, and reflect how neural circuits integrate information over time (Murray et al., 2014; Pochinok et al., 2025).
The notebook integrates two complementary approaches: (1) computation of the autocorrelation function using the iSTTC method developed by Pochinok et al. (2025), and (2) multi-exponential model fitting as defined by Shi et al. (2025).
Spike Train Tiling Coefficient adapted for intrinsic timescales. Reduces systematic bias in ACF estimation — particularly under low firing rates and bursty dynamics.
ACF modeled as a sum of M exponential components (M = 1–4) selected by BIC. Captures multiple linear slopes in single-neuron autocorrelations that single-exponential models miss.
IBL Neuropixels dataset — 115 mice, 223 brain regions. The same brain-wide recording dataset used in Shi et al. (2025) (IBL, 2023).
Designed to run in Google Colab. Mounts Google Drive, installs ONE-api, numpy, scipy, numba, joblib.
Setup & Dependencies
The first cell mounts Google Drive and installs all required packages. The working directory is set to the shared drive hosting the IBL dataset. Dependencies include:
ONE-api— IBL's open data access librarynumpy,scipy— numerical and optimization routinesnumba— JIT compilation for the iSTTC kerneljoblib— parallelized session-level processingmatplotlib— single-neuron visualization
iSTTC Implementation
The iSTTC computes the autocorrelation-like function directly on spike times, avoiding binary representations or binning. All inner functions are JIT-compiled via Numba's @njit decorator for maximum efficiency.
Computes the tiling proportion term (T_A) from the STTC formula: the fraction of the total recording duration that falls within Δt of any spike in the spike train. Following Pochinok et al. (2025), Equation 5:
The function accepts spike times array, valid window boundaries (start, end), the Δt window width, total recording duration, and a time shift. Critically, this implementation operates directly on spike times without requiring binary representation or binning — a key distinction from conventional ACF approaches.
Computes the P_A|B term: the fraction of spikes in train A that fall within Δt of any spike in train B. A binary search algorithm is used for efficient neighborhood queries over the reference spike train for each test spike.
As demonstrated by Pochinok et al. (2025), this approach yields substantially lower relative estimation error (REE) compared to binned ACF methods, particularly under low firing rate and high excitation strength conditions (Figure 2 of that paper).
The core iSTTC computation function. Following Pochinok et al. (2025), Equation 6, the original spike train is split into two segments for each lag k:
- Spike train A: spikes occurring after lag k (shifted)
- Spike train B: spikes occurring before lag k (unshifted)
The STTC formula is then applied using the computed T_A, T_B, P_A|B, and P_B|A terms at each lag:
A critical implementation detail: zero-padded intervals are excluded when computing the T term. This allows iSTTC to be applied without bias to epoched data — overcoming a fundamental limitation of PearsonR-based approaches.
The user-facing interface function. Sorts spike times and casts them to np.float64 before calling the JIT-compiled kernel. Default parameters are:
- Δt = 5 ms — tiling window width
- n_lags = 1200 — number of lags computed
- lag_shift = 5 ms — consistent with Pochinok et al. (2025), Section 7.4
Multi-Exponential Model Fitting
Implements the autocorrelation model defined in Shi et al. (2025), Equation 2:
The model was developed to capture the multiple linear slopes observed in single-neuron autocorrelations, which a single exponential is insufficient to describe.
Implements the multi-timescale estimation procedure described in Shi et al. (2025). Exponential models with M = 1, 2, 3, 4 components are fit using nonlinear least squares via scipy.optimize.curve_fit. Initial parameters are spaced on a logarithmic scale; lower bound = 5 ms (physiological minimum), upper bound = maximum measured lag.
BIC Model Selection
The optimal number of components is selected using the Bayesian Information Criterion:
A constraint requires each timescale component to contribute at least 1% of the total autocorrelation: cᵢ ≥ 0.01 · Σⱼ cⱼ.
Effective Timescale
The effective timescale is computed following Shi et al. (2025), Equation 3:
This enables direct comparison across neurons with differing numbers of fitted timescales, and represents the overall temporal persistence — equivalent in area to a single exponential decay with timescale τ_eff.
Confidence Interval
A 95% CI for τ_eff is computed by applying error propagation to the covariance matrix, using Student's t distribution to account for small sample sizes.
Local Variance (Lv)
Local Variance (Lv) is computed following Shinomoto et al. (2009):
Pochinok et al. (2025) demonstrated that Lv correlates tightly with the excitation strength parameter of the Hawkes process, and thus serves as an experimentally observable proxy for excitation strength.
Poisson firing dynamics — random inter-spike intervals
Regular, oscillatory firing — more predictable ISI structure
Bursty firing — clusters of spikes followed by long silences
iSTTC advantage is most pronounced under Lv > 1 — the bursty, low-rate regime characteristic of neocortical activity
Quality Control Criteria
Implements the inclusion criteria reported in Pochinok et al. (2025), Section 2.5, and in the Methods of Shi et al. (2025). Four criteria are assessed:
The iSTTC function must decline monotonically within the 50–200 ms window. Coefficient estimate = −0.946, p < 10⁻¹⁶ as a predictor of REE (Pochinok et al., 2025).
The 95% CI of the estimated τ_eff must exclude zero. Coefficient estimate = −1.325, p < 10⁻¹⁶ as a predictor of REE.
Model fit must satisfy R² ≥ 0.5. Consistent with Shi et al. (2025) and prior single-neuron timescale studies (Cavanagh et al., 2016; Wasmuht et al., 2018).
Neuron must contain ≥ 100 spikes. Guards against unreliable estimates from neurons that only fire briefly.
Pochinok et al. (2025) demonstrated that iSTTC increases the proportion of neurons meeting all criteria on epoched data by approximately 7–8% relative to PearsonR (Figure 5E).
Spontaneous Activity Window
Extracts the temporal boundaries of the IBL spontaneous activity recording epoch. Following Shi et al. (2025), spontaneous activity was recorded during a 10-minute passive period at the end of each session, during which head-fixed mice remained stationary in the rig in a dark environment with no visual stimuli or reward delivery.
Neural activity during this passive period was used as a proxy for spontaneous activity to estimate intrinsic timescales.
Single Neuron & Session Analysis
The end-to-end analysis function for a single neuron. It sequentially:
- Computes the iSTTC autocorrelation function
- Fits the multi-exponential model with BIC-based model selection
- Evaluates all four quality control criteria
- Computes firing rate and Lv metrics
The output includes τ_eff, individual τᵢ and cᵢ values, fit quality metrics, and the raw autocorrelation and fitted curves for each neuron.
The unit of work for each individual neuron cluster. It validates neural unit quality via IBL quality control labels (retaining only well-isolated single units with label ≥ 2), checks the minimum spike count threshold, calls analyze_single_neuron, and merges results with session-level metadata (session ID, probe name, cluster ID, brain region coordinates).
Performs the full analysis of a single IBL session. It downloads neural data via the ONE API, identifies the spontaneous activity window using get_spontaneous_window, filters spike times to that window, and runs _process_cluster in parallel across all clusters using joblib.Parallel. This parallelized design enables efficient processing of sessions with large numbers of neurons.
Visualization
Produces a two-panel output for a single neuron:
- Left panel: raw iSTTC autocorrelation points (blue) and the multi-exponential fit curve (red), along with fit information (number of components, τ_eff, R²) and the 50–200 ms quality control window.
- Right panel: a summary of neuron metrics — firing rate, Lv, spike count, individual timescales and mixing coefficients, confidence intervals, and quality control outcomes.
Batch Processing Infrastructure
These three functions constitute the coordination infrastructure for distributed data processing across team members:
get_next_pids— retrieves the next unprocessed PIDs assigned to a given team member from a CSV registry file.mark_isttc_done— updates the registry upon successful completion of a session.run_batch— connects to the IBL ONE API, processes the specified number of sessions sequentially, saves results incrementally to a CSV file after each session, and updates the registry. Incremental saving minimizes data loss during long-running analyses.
Parameter Summary
| Parameter | Value | Source |
|---|---|---|
| Δt (iSTTC window) | 25 ms | Pochinok et al. (2025), Section 7.4 |
lag_shift | 5–10 ms | Pochinok et al. (2025) |
| n_lags | 600–1200 | This notebook |
| Maximum components | 4 | Shi et al. (2025) |
| Min. component contribution | 1% | Shi et al. (2025) |
| R² threshold | ≥ 0.5 | Pochinok et al. (2025); Shi et al. (2025) |
| Min. spike count | 100 | This notebook |
| Spontaneous activity duration | ~10 min | Shi et al. (2025) |
Methodological Rationale
This notebook integrates two complementary methodological frameworks. As demonstrated by Pochinok et al. (2025), the iSTTC method reduces systematic biases in the autocorrelation estimation step, yielding approximately 8% lower REE compared to ACF — particularly under low firing rates and bursty dynamics.
When compared to epoched data, IT estimates derived from continuous recordings with iSTTC show approximately ten-fold lower REE, underscoring the importance of using continuous spontaneous activity recordings whenever possible.
The multi-timescale model of Shi et al. (2025), in turn, captures the multiple linear slopes observed in single-neuron autocorrelations that standard single-exponential approaches fail to describe — as the majority of neurons in that study (51%) were best described by a two-component model. This aligns with the 59% two-component prevalence observed in the present dataset.
References
- Cavanagh SE, Wallis JD, Kennerley SW, Hunt LT (2016). Autocorrelation structure at rest predicts value correlates of single neurons during reward-guided choice. eLife 5:e18937.
- International Brain Laboratory (2023). A brain-wide map of neural activity during complex behaviour. bioRxiv.
- Murray JD, Bernacchia A, Freedman DJ et al. (2014). A hierarchy of intrinsic timescales across primate cortex. Nature Neuroscience 17:1661–1663.
- Pochinok I, Hanganu-Opatz IL, Chini M (2025). iSTTC: a robust method for accurate estimation of intrinsic neural timescales from single-unit recordings. bioRxiv. doi.org/10.1101/2025.08.01.668071
- Shi Y-L, Zeraati R, International Brain Laboratory, Levina A, Engel TA (2025). Brain-wide organization of intrinsic timescales at single-neuron resolution. bioRxiv. doi.org/10.1101/2025.08.30.673281
- Shinomoto S, Kim H, Shimokawa T et al. (2009). Relating neuronal firing patterns to functional differentiation of cerebral cortex. PLoS Computational Biology 5:e1000433.
- Wasmuht DF, Spaak E, Buschman TJ, Miller EK, Stokes MG (2018). Intrinsic neuronal dynamics predict distinct functional roles during working memory. Nature Communications 9:3499.