aind_ephys_utils.standards.validate module¶
Validation utilities for canonical ephys xarray objects.
aind_ephys_utils expects a small set of canonical DataArray “kinds” (ragged spikes, binned spikes, continuous signals, events). This module provides helpers to infer and validate those conventions.
- exception aind_ephys_utils.standards.validate.EphysValidationError¶
Bases:
ValueErrorRaised when an object does not conform to ephysexplorer conventions.
- class aind_ephys_utils.standards.validate.ValidationResult(ok: bool, kind: str, message: str = '')¶
Bases:
objectStructured result returned by validate.
- ok¶
True if validation succeeded.
- Type:
bool
- kind¶
Inferred kind (e.g. “spikes_ragged”, “binned”, “continuous”, “events”).
- Type:
str
- message¶
Human-readable status string.
- Type:
str
- kind: str¶
- message: str = ''¶
- ok: bool¶
- aind_ephys_utils.standards.validate.infer_kind(da: DataArray) str¶
Infer the canonical kind of a DataArray.
- Parameters:
da – DataArray to classify.
- Returns:
One of: “spikes_ragged”, “binned”, “continuous”, “events”, or “unknown”.
- Return type:
str
- aind_ephys_utils.standards.validate.is_binned_spikes(da: DataArray) bool¶
- Binned spikes convention:
numeric
dims include (trial, unit, time)
- aind_ephys_utils.standards.validate.is_continuous(da: DataArray) bool¶
- Continuous convention:
has a numeric dtype (int/float/complex)
has a time dimension
often has trial plus one of unit/channel/feature/etc.
- aind_ephys_utils.standards.validate.is_events(da: DataArray) bool¶
- Events convention:
dims are (trial, event, bound)
dtype is numeric
bound coordinate has [“start”, “end”]
each event has start/end times (instantaneous events have start==end)
- aind_ephys_utils.standards.validate.is_ragged_spikes(da: DataArray) bool¶
- Ragged spikes convention:
dims include (trial, unit)
dtype is object
each element is a 1D array-like of spike times (seconds)
- aind_ephys_utils.standards.validate.validate(da: DataArray, *, kind: str | None = None, require_time_coord: bool = True, check_ragged_contents: bool = True) ValidationResult¶
Validate that a DataArray conforms to the conventions expected by .ephys.
- Parameters:
da – The DataArray to validate.
kind – If provided, require that the DataArray matches this inferred kind. One of: “spikes_ragged”, “continuous”, “binned”, “events”.
require_time_coord – If True, require a ‘time’ coordinate whenever there is a time dimension.
check_ragged_contents – If True, sample-check ragged spike contents for basic shape/dtype sanity.
- Return type: