neuralib.imaging.suite2p.core
- typeddict neuralib.imaging.suite2p.core.Suite2pGUIOptions[source]
Suite2p GUI setting.
- Optional Keys:
look_one_level_down (
float)fast_disk (
str)delete_bin (
bool)mesoscan (
bool)bruker (
bool)h5py (
list)h5py_key (
str)save_path0 (
str)save_folder (
str)subfolders (
list)move_bin (
bool)nplanes (
int)nchannels (
int)functional_chan (
int)tau (
float)fs (
float)force_sktiff (
bool)frames_include (
int)multiplane_parallel (
float)preclassify (
float)save_mat (
bool)save_NWB (
float)combined (
float)aspect (
float)do_bidiphase (
bool)bidiphase (
float)bidi_corrected (
bool)do_registration (
int)two_step_registration (
float)keep_movie_raw (
bool)nimg_init (
int)batch_size (
int)maxregshift (
float)align_by_chan (
int)reg_tif (
bool)reg_tif_chan2 (
bool)subpixel (
int)smooth_sigma_time (
float)smooth_sigma (
float)th_badframes (
float)norm_frames (
bool)force_refImg (
bool)pad_fft (
bool)nonrigid (
bool)block_size (
tuple[int,int])snr_thresh (
float)maxregshiftNR (
float)oneP_reg (
bool)spatial_hp (
int)spatial_hp_reg (
float)spatial_hp_detect (
int)pre_smooth (
float)spatial_taper (
float)roidetect (
bool)spikedetect (
bool)anatomical_only (
float)sparse_mode (
bool)diameter (
float)spatial_scale (
float)connected (
bool)nbinned (
int)max_iterations (
int)threshold_scaling (
float)max_overlap (
float)high_pass (
float)denoise (
bool)soma_crop (
bool)neuropil_extract (
bool)inner_neuropil_radius (
float)min_neuropil_pixels (
int)lam_percentile (
float)allow_overlap (
bool)use_builtin_classifier (
bool)classifier_path (
int)chan2_thres (
float)baseline (
str)win_baseline (
float)sig_baseline (
float)prctile_baseline (
float)neucoeff (
int)suite2p_version (
str)data_path (
list[str])sbx_ndeadcols (
int)input_format (
str)save_path (
str)ops_path (
str)reg_file (
str)filelist (
list[str])nframes_per_folder (
ndarray)sbx_ndeadrows (
int)meanImg (
ndarray)meanImg_chan2 (
ndarray)nframes (
int)Ly (
int)Lx (
int)date_proc (
datetime)refImg (
ndarray)rmin (
int)rmax (
int)yblock (
list[ndarray])xblock (
list[ndarray])nblocks (
list[int])NRsm (
ndarray)yoff (
ndarray)xoff (
ndarray)corrXY (
ndarray)yoff1 (
ndarray)xoff1 (
ndarray)corrXY1 (
ndarray)badframes (
ndarray)yrange (
list[int])xrange (
list[int])tPC (
ndarray)regPC (
ndarray)regDX (
ndarray)Lyc (
int)Lxc (
int)max_proj (
ndarray)Vmax (
ndarray)ihop (
ndarray)Vsplit (
ndarray)Vcorr (
ndarray)Vmap (
list[ndarray])spatscale_pix (
ndarray)meanImgE (
ndarray)timing (
dict[str,float])
- typeddict neuralib.imaging.suite2p.core.Suite2pRoiStat[source]
Suite2p GUI imaging.
- Optional Keys:
ypix (
ndarray)xpix (
ndarray)lam (
ndarray)med (
list[int,int])footprint (
float)mrs (
float)mrs0 (
float)compact (
float)solidity (
float)npix (
int)npix_soma (
int)soma_crop (
ndarray)overlap (
ndarray)radius (
float)aspect_ratio (
float)npix_norm_no_crop (
float)npix_norm (
float)skew (
float)std (
float)
- final class neuralib.imaging.suite2p.core.Suite2PResult[source]
suite2p result container
Dimension parameters:
N: number of neurons
F: number pf frames
W: image width
H: image height
- 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
Red cell probability 2D array. Array[float, [N, 2]]
- redcell_threshold: float | None
Red cell probability threshold
- runtime_frate_check: float | None
If not None, check frame rate lower bound
- classmethod launch_gui(directory)[source]
DEPRECATED. launch the suite2p GUI
- Parameters:
directory (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader) – directory contain all the s2p output files. e.g., <SUITE2P_OUTPUT>/suite2p/plane<P>
- Returns:
- Return type:
None
- classmethod load(directory, cell_prob_thres=0.5, red_cell_threshold=0.65, channel=0, runconfig_frate=30.0)[source]
Load suite2p result from directory
- Parameters:
directory (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader) – 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 outputred_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
runconfig_frate (float | None) – if not None, check frame rate lower-bound to make sure the s2p runconfig
- Returns:
- 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]]
- __init__(directory, f_raw, f_neu, spks, stat, ops, iscell, cell_prob_thres, redcell=None, redcell_threshold=None, runtime_frate_check=None)
Method generated by attrs for class Suite2PResult.
- 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
- 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_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
- neuralib.imaging.suite2p.core.get_s2p_coords(s2p, neuron_list, plane_index, factor)[source]
Get the suite2p coordinates of all cells.
- Parameters:
s2p (Suite2PResult) –
Suite2PResultneuron_list (int | list[int] | slice | ndarray | None) – neuron index or index list/arr. If None, then load all neurons
plane_index (int) – optic plane index
factor (float) – pixel to mm factor
- Returns:
CellularCoordinates- Return type: