neuralib.imaging.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.imaging.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.imaging.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.imaging.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
dffand 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 (ndarray) – The observed calcium fluorescence trace. Array[float, [N, F]|F]
v (ndarray) – A 1D array that will store the estimated deconvolved signal.
w (ndarray) – A 1D array that tracks the weights for merging steps
t (ndarray) – A 1D array that stores the indices of time steps
ll (ndarray) – A 1D array that tracks the weights for merging steps.
s (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