neuralib.calimg.spikes.oasis

OASIS

Fast online deconvolution of calcium imaging dat

Method source

This script adapted from suite2p.suite2p.extraction.dcnv (Copyright © 2023 Howard Hughes Medical Institute, Authored by Carsen Stringer and Marius Pachitariu)

Example of usage

from neuralib.calimg.spikes.oasis import oasis_dcnv

# 2D dF/F array. Array[float, [nNeurons, nFrames]] or Array[float, nFrames]
dff = ...

tau = 1.5  # time constant of the calcium indicator (ms)
fs = 30  # sampling frequency of the calcium imaging data (hz)
spks = oasis_dcnv(dff, tau, fs)
neuralib.calimg.spikes.oasis.oasis_dcnv(dff, tau, fs, batch_size=300)[source]

Computes non-negative deconvolution (no sparsity constraints)

Parameters:
  • dff (ndarray) – The observed calcium fluorescence trace in 2D numpy array(multiple neurons) or 1D numpy array(single cell). Array[float, [N, F]|F]

  • tau (float) – The time constant of the calcium indicator in ms

  • fs (float) – The sampling frequency of the calcium imaging data in hz

  • batch_size (int) – number of frames processed per batch

Returns:

Deconvolved fluorescence. Array[float, [N,F]|F]

Return type:

ndarray

neuralib.calimg.spikes.oasis.oasis_matrix(dff, v, w, t, ll, s, tau, fs)[source]

Performs spike deconvolution for a single neuron’s calcium imaging trace using a greedy method

Iterates through each time point in the observed fluorescence signal dff and enforces a non-negative and non-increasing constraint on the estimated signal. When a violation of this constraint is detected, the function merges the current segment with the previous one, updating the estimated signal accordingly. Finally, it computes the inferred spikes by calculating the difference between successive segments in the deconvolved signal.

Parameters:
  • dff (np.ndarray) – The observed calcium fluorescence trace. Array[float, [N, F]|F]

  • v (np.ndarray) – A 1D array that will store the estimated deconvolved signal.

  • w (np.ndarray) – A 1D array that tracks the weights for merging steps

  • t (np.ndarray) – A 1D array that stores the indices of time steps

  • ll (np.ndarray) – A 1D array that tracks the weights for merging steps.

  • s (np.ndarray) – A 1D array that will store the inferred spikes

  • tau (float) – The time constant of the calcium indicator

  • fs (float) – The sampling frequency of the calcium imaging data