placecell.neural#
Neural data loading and deconvolution.
Functions
|
Build event index DataFrame from spike trains. |
|
Load traces from a Minian-style zarr store as a DataArray. |
|
Run OASIS deconvolution on calcium traces. |
- placecell.neural.load_calcium_traces(neural_path: Path, trace_name: str = 'C') DataArray#
Load traces from a Minian-style zarr store as a DataArray.
- Parameters:
neural_path (Path) – Directory containing
<trace_name>.zarr.trace_name (str) – Base name of the zarr group (e.g.
"C"or"C_lp"). Also used as the variable name if the zarr contains a Dataset.
- Returns:
DataArray with dimensions (‘unit_id’, ‘frame’).
- Return type:
xr.DataArray
- placecell.neural.run_deconvolution(C_da: Any, unit_ids: list[int], g: tuple[float, float], baseline: float | str, penalty: float, s_min: float, progress_bar: Any = None) tuple[list[int], list[ndarray], list[ndarray]]#
Run OASIS deconvolution on calcium traces.
- Parameters:
C_da (xarray.DataArray) – Calcium traces with dimensions (unit_id, frame).
unit_ids (list[int]) – List of unit IDs to process.
g (tuple[float, float]) – AR(2) coefficients for OASIS.
baseline (float or str) – Baseline correction. Use ‘pXX’ for percentile (e.g., ‘p10’) or numeric value.
penalty (float) – Sparsity penalty for OASIS.
s_min (float) – Minimum event size threshold.
progress_bar (optional) – tqdm progress bar wrapper (e.g., tqdm.notebook.tqdm).
- Returns:
good_unit_ids (list[int]) – Unit IDs that were successfully deconvolved.
S_list (list[np.ndarray]) – Spike trains.
- Return type:
tuple[list[int], list[ndarray], list[ndarray]]
- placecell.neural.build_event_index_dataframe(unit_ids: list[int], S_list: list[ndarray]) DataFrame#
Build event index DataFrame from spike trains.
- Parameters:
unit_ids (list[int]) – Unit IDs corresponding to each spike train.
S_list (list[np.ndarray]) – List of spike train arrays.
- Returns:
Event index with columns: unit_id, frame, s.
- Return type:
pd.DataFrame