suite2p.extraction package

Submodules

suite2p.extraction.dcnv module

suite2p.extraction.dcnv.oasis(F, batch_size, tau, fs)[source]

computes non-negative deconvolution

no sparsity constraints

Parameters:
  • F (float, 2D array) – size [neurons x time], in pipeline uses neuropil-subtracted fluorescence

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

  • tau (float) – timescale of the sensor, used for the deconvolution kernel

  • fs (float) – sampling rate per plane

Return type:

ndarray

Returns:

  • S (float, 2D array) – size [neurons x time], deconvolved fluorescence

suite2p.extraction.dcnv.oasis_matrix(F, v, w, t, l, s, tau, fs)[source]

spike deconvolution on many neurons parallelized with prange

suite2p.extraction.dcnv.oasis_trace(F, v, w, t, l, s, tau, fs)[source]

spike deconvolution on a single neuron

suite2p.extraction.dcnv.preprocess(F, baseline, win_baseline, sig_baseline, fs, prctile_baseline=8)[source]

preprocesses fluorescence traces for spike deconvolution

baseline-subtraction with window “win_baseline”

Parameters:
  • F (float, 2D array) – size [neurons x time], in pipeline uses neuropil-subtracted fluorescence

  • baseline (str) – setting that describes how to compute the baseline of each trace

  • win_baseline (float) – window (in seconds) for max filter

  • sig_baseline (float) – width of Gaussian filter in frames

  • fs (float) – sampling rate per plane

  • prctile_baseline (float) – percentile of trace to use as baseline if using constant_prctile for baseline

Return type:

ndarray

Returns:

  • F (float, 2D array) – size [neurons x time], baseline-corrected fluorescence

suite2p.extraction.extract module

suite2p.extraction.masks module

suite2p.extraction.masks.create_cell_mask(stat, Ly, Lx, allow_overlap=False)[source]

creates cell masks for ROIs in stat and computes radii

Parameters:
  • stat (dictionary "ypix", "xpix", "lam") –

  • Ly (y size of frame) –

  • Lx (x size of frame) –

  • allow_overlap (whether or not to include overlapping pixels in cell masks) –

Return type:

Tuple[ndarray, ndarray]

Returns:

  • cell_masks (len ncells, each has tuple of pixels belonging to each cell and weights)

  • lam_normed

suite2p.extraction.masks.create_cell_pix(stats, Ly, Lx, lam_percentile=50.0)[source]

Returns Ly x Lx array of whether pixel contains a cell (1) or not (0).

lam_percentile allows some pixels with low cell weights to be used, disable with lam_percentile=0.0

Return type:

ndarray

suite2p.extraction.masks.create_masks(stats, Ly, Lx, ops={'1Preg': False, 'align_by_chan': 1, 'allow_overlap': False, 'anatomical_only': 0, 'aspect': 1.0, 'baseline': 'maximin', 'batch_size': 500, 'bidi_corrected': False, 'bidiphase': 0, 'block_size': [128, 128], 'bruker': False, 'bruker_bidirectional': False, 'cellprob_threshold': 0.0, 'chan2_thres': 0.65, 'classifier_path': '', 'combined': True, 'connected': True, 'delete_bin': False, 'denoise': False, 'diameter': 0, 'do_bidiphase': False, 'do_registration': True, 'fast_disk': [], 'flow_threshold': 1.5, 'force_refImg': False, 'force_sktiff': False, 'frames_include': -1, 'fs': 10.0, 'functional_chan': 1, 'h5py': [], 'h5py_key': 'data', 'high_pass': 100, 'ignore_flyback': [], 'inner_neuropil_radius': 2, 'keep_movie_raw': False, 'lam_percentile': 50.0, 'look_one_level_down': False, 'max_iterations': 20, 'max_overlap': 0.75, 'maxregshift': 0.1, 'maxregshiftNR': 5, 'mesoscan': False, 'min_neuropil_pixels': 350, 'move_bin': False, 'multiplane_parallel': False, 'nbinned': 5000, 'nchannels': 1, 'neucoeff': 0.7, 'neuropil_extract': True, 'nimg_init': 300, 'nonrigid': True, 'norm_frames': True, 'nplanes': 1, 'nwb_driver': '', 'nwb_file': '', 'nwb_series': '', 'pad_fft': False, 'prctile_baseline': 8.0, 'pre_smooth': 0, 'preclassify': 0.0, 'pretrained_model': 'cyto', 'reg_tif': False, 'reg_tif_chan2': False, 'roidetect': True, 'save_NWB': False, 'save_folder': [], 'save_mat': False, 'save_path0': [], 'sig_baseline': 10.0, 'smooth_sigma': 1.15, 'smooth_sigma_time': 0, 'snr_thresh': 1.2, 'soma_crop': True, 'sparse_mode': True, 'spatial_hp_cp': 0, 'spatial_hp_detect': 25, 'spatial_hp_reg': 42, 'spatial_scale': 0, 'spatial_taper': 40, 'spikedetect': True, 'subfolders': [], 'subpixel': 10, 'suite2p_version': '0.12.2.dev30+g828b5e2', 'tau': 1.0, 'th_badframes': 1.0, 'threshold_scaling': 1.0, 'two_step_registration': False, 'use_builtin_classifier': False, 'win_baseline': 60.0})[source]

create cell and neuropil masks

suite2p.extraction.masks.create_neuropil_masks(ypixs, xpixs, cell_pix, inner_neuropil_radius, min_neuropil_pixels, circular=False)[source]

creates surround neuropil masks for ROIs in stat by EXTENDING ROI (slower if circular)

Parameters:

cellpix (2D array) – 1 if ROI exists in pixel, 0 if not; pixels ignored for neuropil computation

Returns:

  • neuropil_masks (list) – each element is array of pixels in mask in (Ly*Lx) coordinates

Module contents