aind_ephys_utils.ops.restrict module

Restrict operations for spike data.

aind_ephys_utils.ops.restrict.restrict(data: DataArray | ndarray | Sequence[object] | Sequence[Sequence[object]], *, window: Tuple[float, float], dim: str = 'time', dims: Sequence[str] | None = None, coords: Dict[str, object] | None = None, return_type: str = 'auto') DataArray | object

Restrict input data to a time window.

Parameters:
  • data – Input DataArray/NumPy array or ragged spikes.

  • window – (tmin, tmax) interval to keep.

  • dim – Time dimension name for dense data.

  • dims – Optional dimension names used when data is a dense NumPy array.

  • coords – Optional coordinate mapping used when constructing a DataArray from dense NumPy input.

  • return_type – Output type policy: "auto", "xarray", or "numpy". "auto" mirrors the input style.

Returns:

Cropped output with data restricted to window in the selected representation.

Return type:

xr.DataArray or object