ezmsg.nwb.util#

Module Attributes

MEDIAN_SUBSAMPLE_MAX

Above this many values, interval_median() uses a strided subsample.

Functions

as_text(value)[source]#

One HDF5 value as text, whichever string flavour the writer used.

Which one you get depends on who wrote the file. pynwb stores text as variable-length UTF-8 and h5py hands it back as str; writers that declare their strings H5T_CSET_ASCII (aqnwb, and so every recording Orion writes) read back as bytes, because hdmf keys its decoding decision directly off the character set.

str(value) is not a safe substitute: on bytes it yields the repr "b'cond_0'", which compares equal to nothing and parses as no JSON – a corruption that no exception announces.

Return type:

str

Parameters:

value (Any)

as_text_array(values)[source]#

A whole string column as a unicode array. See as_text().

Return type:

ndarray

Parameters:

values (Any)

build_nwb_fname(metadata)[source]#

Build a default NWB filename from the session metadata.

Return type:

str

Parameters:

metadata (DeepDict)

interval_median(values)[source]#

Median of a set of inter-sample intervals, cheaply.

For intervals specifically, and not for residuals or other continuous quantities: timestamps arrive on a device’s quantisation grid, so their differences cluster onto that grid and the median snaps to a grid point a stride cannot move. On a real 7.09M-interval stream, strides of 16 through 1024 all return 3.3301000002e-05. That is what makes the shortcut exact here and not elsewhere – a median of fit residuals, say, is a continuous quantity with no grid to snap to, and subsampling it would genuinely change the answer.

Strided rather than random or head-of-array: a stride samples the whole recording, so a stream whose intervals differ between its start and its end is represented across the estimate rather than by whichever part was read.

Return type:

float

Parameters:

values (ndarray)

is_zarr_array(dset)[source]#

A zarr-backed array: what NWBZarrIO hands back where NWBHDF5IO hands back an h5py dataset (hdmf_zarr’s wrapper, or a bare zarr array).

Return type:

bool

Parameters:

dset (Any)

Classes

class ReferenceClockType(*values)[source]#

Bases: Enum

SYSTEM = 'system'#
MONOTONIC = 'monotonic'#
UNKNOWN = 'unknown'#