cogpy.base

Core schemas and thin wrappers.

This module introduces a minimal, project-local schema for common neural signals. For now the focus is ECoG/iEEG grids represented as xarray.DataArray.

Why a schema?

Many CogPy utilities assume a few conventions: - a time dimension named "time" - for grid ECoG: spatial dimensions named "AP" and "ML" - a sampling rate available as sig.fs (either as a 0D coordinate named

"fs" or an attribute attrs["fs"])

This file provides small helpers to standardize/validate those conventions and an optional thin wrapper class that makes common preprocessing operations discoverable as methods while still delegating to the existing functional APIs.

Functions

ensure_fs(sig, *[, fs, schema])

Ensure sig has an accessible sampling rate (sig.fs).

ensure_time_coord(sig, *[, fs, schema])

Ensure sig has a numeric time coordinate in seconds.

get_fs(sig, *[, schema])

Return sampling rate in Hz from a signal (coordinate or attrs).

standardize_ecog(sig, *[, kind, fs, schema])

Return a signal with ensured fs (and time coord if possible).

validate_ecog(sig, *[, kind, require_fs, schema])

Validate that a DataArray follows the minimal ECoG schema.

Classes

ECoG(sig, *[, kind, fs, schema])

Thin wrapper around xr.DataArray with schema-aware methods.

ECoGSchema([time, ap, ml, ch, fs])

Dimension/coordinate names used across the codebase.