neuralib.imaging.suite2p.signals

neuralib.imaging.suite2p.signals.get_neuron_signal(s2p, n=None, *, signal_type='df_f', normalize=True, dff=True, correct_neuropil=True, method='maximin')[source]

Select neuronal signals for analysis. For single cell (F,) OR multiple cells (N, F)

Parameters:
  • s2p (Suite2PResult) – suite 2p result

  • n (int | ndarray | list[int] | None) – neuron index (int) or index arraylike (Array[int, N]). If None, then use all neurons

  • signal_type (Literal['df_f', 'spks']) – signal type. SIGNAL_TYPE {‘df_f’, ‘spks’}

  • normalize (bool) – 01 normalization for each neuron

  • dff (bool) – normalize to the baseline fluorescence changed (dF/F)

  • correct_neuropil (bool) – do the neuropil correction

  • method (Literal['maximin', 'constant', 'constant_prctile']) – baseline calculation method {‘maximin’, ‘constant’, ‘constant_prctile’}

Returns:

tuple with (signal, baseline signal). Array[float, F|[N,F]]

Return type:

tuple[ndarray, ndarray]

neuralib.imaging.suite2p.signals.normalize_signal(s, axis=-1)[source]

do 0 1 normalization

Parameters:
  • s (ndarray) – signal

  • axis (int) – axis

Returns:

normalized signal

Return type:

ndarray

neuralib.imaging.suite2p.signals.normalize_signal_factor(s, axis=-1)[source]
Parameters:
  • s (ndarray)

  • axis (int)

Return type:

tuple[ndarray, ndarray]

class neuralib.imaging.suite2p.signals.DFFSignal[source]

Container for dF/F signal processing.

Dimension parameters:

N = number of neurons

F = number of frame

For single cell (F,) OR multiple cells (N, F)

s2p: Suite2PResult

Suite2PResult

f: ndarray

Fluorescence intensity. Array[float, F | [N,F]]

fneu: ndarray

Neuropil intensity. Array[float, F | [N,F]]

fcorr: ndarray

Fluorescence corrected by fneu that used for dff calculation. Array[float, F | [N,F]]

f0: ndarray

Background Fluorescence. Array[float, F | [N,F]]

dff: ndarray

dff after f0 normalization. Array[float, F | [N,F]]

static __new__(_cls, s2p, f, fneu, fcorr, f0, dff)

Create new instance of DFFSignal(s2p, f, fneu, fcorr, f0, dff)

Parameters:
  • s2p (Suite2PResult)

  • f (ndarray)

  • fneu (ndarray)

  • fcorr (ndarray)

  • f0 (ndarray)

  • dff (ndarray)

property dff_baseline: ndarray

baseline of dff, supposed to be 0

property baseline_fluctuation: ndarray

get the fluctuation of the fneu signal. Array[float, F | [N,F]]

Perhaps not fully corrected with physiological reason. used to get the baseline std (i.e., trial reliability metric)

neuralib.imaging.suite2p.signals.dff_signal(f, fneu, s2p, correct_neuropil=True, method='maximin')[source]

df_f signal normalization container

Parameters:
  • f (ndarray) – Fluorescence intensity. Array[float, F | [N,F]]

  • fneu (ndarray) – Neuropil intensity. Array[float, F | [N,F]]

  • s2p (Suite2PResult) – Suite2PResult

  • correct_neuropil (bool) – whether do the subtraction using neuropil

  • method (Literal['maximin', 'constant', 'constant_prctile']) – {‘maximin’, ‘constant’, ‘constant_prctile’}

Returns:

DFFSignal

Return type:

DFFSignal

neuralib.imaging.suite2p.signals.calc_signal_baseline(signal, s2p, method='maximin')[source]

f0 calculation

See also

source code from suite2p: suite2p.extraction.dcnv.preprocess

Parameters:
  • signal (ndarray) – signal activity. i.e., fcorr

  • s2p (Suite2PResult) – Suite2PResult

  • method (Literal['maximin', 'constant', 'constant_prctile']) – BASELINE_METHOD

Returns:

f0 baseline for the df/f calculation

Return type:

ndarray

neuralib.imaging.suite2p.signals.sync_s2p_rigevent(image_time, s2p, plane=0)[source]

Do the alignment to make the shape the same in hardware pulses (P,) & suite2p output files (F,)

* ASSUME both recordings are sync

* ASSUME sequential scanning pattern. i.e., 0, 1, 2, 3 ETL scanning order

Parameters:
  • image_time (ndarray) – imaging time hardware pulses. Array[float, P]

  • s2p (Suite2PResult) – Suite2PResult

  • plane (int | None) – number of optical plane

Returns:

image_time: with same len as s2p results Array[float, F]

Return type:

ndarray