Entity Collection: Expected Schemas
This document proposes a small collection of named entities with explicit schemas (dims/coords/attrs).
These entities are not file formats; they are in-memory objects used by cogpy.plot.* and future GUIs.
Design goals
Predictable: explicit dims + coordinate names (avoid silent transposes).
Composable: entities can be bundled into GUI dev fixtures.
Deterministic: generators accept a
seedand are stable over time.Small + large modes: same schema, different sizes.
Self-documenting failures: runtime validators raise clear
ValueErrors with hints (seecogpy.datasets.schemas).Coercion at boundaries: a
coerce_*layer fixes “almost-right” inputs (dim permutations, missingfs) before validating.
Non-goals (for this layer)
No disk IO, no BIDS/BIDS-iEEG conventions here.
No attempt to represent every dataset type; start with what GUIs need.
Entity: IEEGGridTimeSeries
Grid-aware time series for a 2D electrode array.
Type
xarray.DataArray
Dims (canonical)
("time", "ML", "AP")
Coords
time: seconds, 1D, strictly increasingML: physical coordinate (e.g., mm), 1D, lengthn_mlAP: physical coordinate (e.g., mm), 1D, lengthn_ap
Name
name: recommended"ieeg"or"val"(avoid long names in plot titles)
Attrs (recommended)
fs(float): sampling rate in Hz (optional but strongly recommended)units(str): e.g."uV"(optional)
Notes
This matches the implemented example generator
cogpy.datasets.entities.example_ieeg_grid(...).When you need consistent row-major flattening aligned to
ChannelGrid(AP rows, ML cols), use a derived view:sig_apml = sig.transpose("time","AP","ML")flattening convention:
flat = ap * n_ml + mlstacking:
sig_apml.stack(channel=("AP","ML"))
NeuroScope
.lfpfiles are MATLAB-native and typically stored column-major; when interpreting a file-ordered(time, channel)matrix as a grid, the natural flattening is:flat = ml * n_ap + ap(col-major over the grid plane)
Entity: MultichannelTimeSeries
Channel-unaware multichannel time series (no grid semantics).
Type
xarray.DataArray
Dims
("channel", "time")(canonical)
Coords
channel: strings or ints, 1Dtime: seconds, 1D, strictly increasing
Attrs (recommended)
fs(float),units(str)
Entity: IEEGTimeChannel (stacked view for viewers)
Time × channel representation derived from IEEGGridTimeSeries for stacked-trace viewers.
Type
xarray.DataArray
Dims (canonical for cogpy.datasets.gui_bundles.ieeg_grid_bundle)
("time", "channel")
Coords
time: seconds, 1DCanonical (recommended):
channelis a flat integer coordinate andAPandMLare 1D coords aligned tochannel(created viastack(...).reset_index("channel")).Allowed fallback:
channelis a MultiIndex over(AP, ML)when created viastack(channel=("AP","ML")).
Runtime helpers
validate_ieeg_time_channel(da)validates either canonical form.coerce_ieeg_time_channel(da)converts MultiIndex to the canonical reset-index form.
Entity: GridSpectrogram4D
Time–frequency representation for a 2D grid (orthoslicer-friendly).
Type
xarray.DataArray
Dims (canonical; matches existing toy tensors)
("ml", "ap", "time", "freq")
Coords
ml,ap: physical coords (or normalized 0..1), 1Dtime: seconds, 1Dfreq: Hz, 1D, strictly increasing
Name
"val"(recommended)
Notes
This matches
make_dataset(...)andAROscillatorGrid.spectrogramincode/lib/cogpy/src/cogpy/datasets/tensor.py.Mapping convention for orthoslicers / GUI overlays:
ml -> x,ap -> y,time -> t,freq -> z
Entity: GridWindowedSpectrum
Time–frequency representation for a 2D grid (compute-oriented, uppercase spatial dims).
Type
xarray.DataArray
Dims (canonical)
("time_win", "AP", "ML", "freq")
Coords
time_win: window-center seconds, 1D, strictly increasingAP: physical coordinate (e.g., mm), 1DML: physical coordinate (e.g., mm), 1Dfreq: Hz, 1D, strictly increasing
Relationship to GridSpectrogram4D
GridSpectrogram4Duses lowercase("ml", "ap", "time", "freq")for orthoslicer/GUI use.GridWindowedSpectrumuses uppercase("time_win", "AP", "ML", "freq")for compute pipelines, matching the spatial measure batch convention(..., AP, ML).
Runtime helpers
validate_grid_windowed_spectrum(da)validates dims, coord monotonicity.coerce_grid_windowed_spectrum(da)acceptsspectrogramx()output("ML", "AP", "freq", "time"), lowercaseml/apvariants, or any permutation, and transposes/renames to canonical form.
Entity: BurstPeaksTable
Tabular peak/burst annotations aligned to GridSpectrogram4D (or similar).
Type
pandas.DataFrame
Required columns
burst_id(int)x(float): ML coordinate (same units asml)y(float): AP coordinate (same units asap)t(float): time in seconds (same units astime)z(float): frequency in Hz (same units asfreq)value(float): amplitude/score
Optional columns
index-space helpers (useful for debugging):
i_ml,i_ap,i_time,i_freq
Notes
This matches
detect_bursts_hmaxima(...)output schema incode/lib/cogpy/src/cogpy/datasets/tensor.py.
Entity: AtlasImageOverlay (optional)
An anatomical background image intended to sit behind ChannelGridWidget.
Type
np.ndarrayof shape(H, W, 3)or(H, W, 4)uint8
Associated metadata (bundle-level)
physical extent / scaling parameters required to place the image in AP/ML space.