load_nwb_timeseries#
- class braintools.file.load_nwb_timeseries(path, name)#
Read a regularly sampled NWB
TimeSeriesby name.- Parameters:
- Return type:
- Returns:
data (numpy.ndarray or Quantity) – The samples, time on axis 0, with the series’
conversionandoffsetapplied (data * conversion + offset). A Quantity when the NWB unit string is a unit brainunit can parse (NWB spellings such as"volts"are recognised); a plain array for"n/a"and similar, or with aUserWarningfor an unknown unit string.dt (Quantity) – Sampling interval in seconds, from the series’
rate, or from uniformly spacedtimestamps.
- Raises:
FileNotFoundError – If
pathdoes not exist.KeyError – If no
TimeSeriescallednameexists (the message lists the available names).ValueError – If the series has irregular timestamps (no single
dt).ImportError – If
pynwbis not installed (pip install braintools[nwb]).
See also
save_nwb_timeseriesWrite a series.
Notes
Host-only (not under
jax.jit/jax.vmap). The data is read fully into memory.Examples
>>> import os, tempfile >>> import brainunit as u >>> import numpy as np >>> from braintools.file._nwb import save_nwb_timeseries, load_nwb_timeseries >>> path = os.path.join(tempfile.mkdtemp(), 'i.nwb') >>> save_nwb_timeseries(path, np.arange(4.), 1e-3, 'counts') >>> data, dt = load_nwb_timeseries(path, 'counts') >>> data, dt (array([0., 1., 2., 3.]), Quantity(0.001, "s"))