neuralib.suite2p.core.Suite2PResult

final class neuralib.suite2p.core.Suite2PResult[source]

Bases: object

suite2p result container

Dimension parameters:

N: number of neurons

F: number pf frames

W: image width

H: image height

__init__(directory, f_raw, f_neu, spks, stat, ops, iscell, cell_prob_thres, redcell=None, redcell_threshold=None, runtime_frate_check=None)
Parameters:
  • directory (Path)

  • f_raw (ndarray)

  • f_neu (ndarray)

  • spks (ndarray)

  • stat (ndarray)

  • ops (Suite2pGUIOptions)

  • iscell (ndarray)

  • cell_prob_thres (float | None)

  • redcell (ndarray | None)

  • redcell_threshold (float | None)

  • runtime_frate_check (float | None)

Return type:

None

Methods

__init__(directory, f_raw, f_neu, spks, ...)

get_neuron_id_mapping()

Retrieves a mapping between neuron IDs and their corresponding raw indices based on whether the cell detection probabilities meet a specified threshold.

get_rois_pixels()

ROIs pixel (N, 2)

load(directory[, cell_prob_thres, ...])

Load suite2p result from directory

load_total_neuron_number(directory[, cell_prob])

Load number of neuron based on iscell.npy

Attributes

cell_prob

probability that the ROI is a cell based on the default classifier.

fs

suite2p approximate frame rate per plane, exact value should be checked in .sbx or .mat

has_chan2

if has a second channel

image_height

image height (in pixel)

image_mean

mean image for chan0(1st).

image_mean_ch2

mean image for chan1(2nd).

image_width

image width (in pixel)

indicator_tau

The timescale of the sensor (in seconds)

n_frame

number of frame number

n_neurons

number of neurons after load.

n_plane

number of optical plane

n_red_neuron

number of identified neuron based on red cell threshold

neucoeff

neuropil coefficient, normally should be ~0.7

nonrigid_x_offsets

(frames, block_size).

nonrigid_xy_offsets

Array[float, F]

nonrigid_y_offsets

Array[float, F]

prctile_baseline

percentile of trace to use as baseline if ops['baseline'] = constant_percentile

red_cell_prob

red cell probability, Array[float, N]

redcell

Red cell probability 2D array.

redcell_threshold

Red cell probability threshold

rigid_x_offsets

x-shifts of recording at each timepoint.

rigid_xy_offset

peak of phase correlation between frame and reference image at each timepoint.

rigid_y_offsets

y-shifts of recording at each timepoint.

runtime_frate_check

If not None, check frame rate lower bound

signal_baseline

Gaussian filter width in seconds

window_baseline

window for max/min filter in seconds

directory

Directory contain all the s2p output files

f_raw

Fluorescence traces 2D array.

f_neu

Neuropil fluorescence traces 2D array.

spks

Deconvolved activity 2D array.

stat

GUI imaging after registration, i.e., x, ypixel., etc.

ops

GUI options

iscell

Cell probability for each ROI.

cell_prob_thres

Cell probability threshold for loading the data

directory: Path

Directory contain all the s2p output files

f_raw: ndarray

Fluorescence traces 2D array. Array[float, [N, F]]

f_neu: ndarray

Neuropil fluorescence traces 2D array. Array[float, [N, F]]

spks: ndarray

Deconvolved activity 2D array. Array[float, [N, F]]

stat: ndarray

GUI imaging after registration, i.e., x, ypixel., etc. Array[Suite2pRoiStat, N]

ops: Suite2pGUIOptions

GUI options

iscell: ndarray

Cell probability for each ROI. Array[float, [N, 2]]

cell_prob_thres: float | None

Cell probability threshold for loading the data

redcell: ndarray | None = None

Red cell probability 2D array. Array[float, [N, 2]]

redcell_threshold: float | None = None

Red cell probability threshold

runtime_frate_check: float | None = None

If not None, check frame rate lower bound

classmethod load(directory, cell_prob_thres=0.5, red_cell_threshold=0.65, channel=0, runtime_check_frame_rate=30.0)[source]

Load suite2p result from directory

Parameters:
  • directory (str | Path | PathLike[str]) – Directory contain all the s2p output files. e.g., */suite2p/plane[P]

  • cell_prob_thres (float | None) – Cell probability. If float type, mask for the value in iscell[:, 1]. If None, use the binary criteria in GUI output

  • red_cell_threshold (float) – Red cell threshold

  • channel (int) – channel (PMT) Number for the functional channel. i.e., 0 if GCaMP, 1 if jRGECO in scanbox setting

  • runtime_check_frame_rate (float | None) – if not None, check frame rate lower-bound to make sure the s2p runconfig

Returns:

Suite2PResult

Return type:

Self

property has_chan2: bool

if has a second channel

property n_neurons: int

number of neurons after load. could be less than GUI ROI number if use higher cell_prob in load()

property n_frame: int

number of frame number

property cell_prob: ndarray

probability that the ROI is a cell based on the default classifier. Array[float, N]

property n_red_neuron: int

number of identified neuron based on red cell threshold

property red_cell_prob: ndarray | None

red cell probability, Array[float, N]

property signal_baseline: float

Gaussian filter width in seconds

property window_baseline: float

window for max/min filter in seconds

property fs: float

suite2p approximate frame rate per plane, exact value should be checked in .sbx or .mat

property neucoeff: float

neuropil coefficient, normally should be ~0.7

property prctile_baseline: float

percentile of trace to use as baseline if ops[‘baseline’] = constant_percentile

property n_plane: int

number of optical plane

property image_width: int

image width (in pixel)

property image_height: int

image height (in pixel)

property image_mean: ndarray

mean image for chan0(1st). Array[float, [H, W]]

property image_mean_ch2: ndarray

mean image for chan1(2nd). Array[float, [H, W]]

property indicator_tau: float

The timescale of the sensor (in seconds)

property rigid_x_offsets: ndarray

x-shifts of recording at each timepoint. Array[int, F]

property rigid_y_offsets: ndarray

y-shifts of recording at each timepoint. Array[int, F]

property rigid_xy_offset: ndarray

peak of phase correlation between frame and reference image at each timepoint. Array[float, F]

property nonrigid_x_offsets: ndarray

(frames, block_size). Array[float, F]

property nonrigid_y_offsets: ndarray

Array[float, F]

property nonrigid_xy_offsets: ndarray

Array[float, F]

classmethod load_total_neuron_number(directory, cell_prob=0.5)[source]

Load number of neuron based on iscell.npy

Parameters:
  • directory (Path) – directory contains the iscell.npy

  • cell_prob (float | None) – cell probability, bool type: use the binary criteria in GUI output float type: value in iscell[:, 1]

Returns:

Number of neurons

Return type:

int

get_rois_pixels()[source]

ROIs pixel (N, 2)

Return type:

ndarray

get_neuron_id_mapping()[source]

Retrieves a mapping between neuron IDs and their corresponding raw indices based on whether the cell detection probabilities meet a specified threshold. If no cell detection probabilities are provided, the mapping assumes all indices are valid neurons.

Returns:

A Polars DataFrame containing two columns: neuron_id and raw_index.

Return type:

DataFrame

__init__(directory, f_raw, f_neu, spks, stat, ops, iscell, cell_prob_thres, redcell=None, redcell_threshold=None, runtime_frate_check=None)
Parameters:
  • directory (Path)

  • f_raw (ndarray)

  • f_neu (ndarray)

  • spks (ndarray)

  • stat (ndarray)

  • ops (Suite2pGUIOptions)

  • iscell (ndarray)

  • cell_prob_thres (float | None)

  • redcell (ndarray | None)

  • redcell_threshold (float | None)

  • runtime_frate_check (float | None)

Return type:

None