LazyRegularTimeSeries#
- class torch_brain.data.LazyRegularTimeSeries(**kwargs)[source]#
Bases:
torch_brain.data.regular_ts.RegularTimeSeriesLazy variant of
RegularTimeSeries. The data is not loaded until it is accessed. This class is meant to be used when the data is too large to fit in memory, and is intended to be intantiated via.LazyRegularTimeSeries.from_hdf5.Note
To access an attribute without triggering the in-memory loading use self.__dict__[key] otherwise using self.key or getattr(self, key) will trigger the lazy loading and will automatically convert the h5py dataset to a numpy array as well as apply any outstanding masks.
- slice(start, end, reset_origin=True, eps=1e-09)[source]#
Returns a new
RegularTimeSeriesobject that contains the data between the start (inclusive) and end (exclusive) times (i.e., [start, end)).startandendare snapped up to the next grid point (the next multiple of1/sampling_rate).Gap-filled samples at the start or end of the result are trimmed, so returned data always begins and ends on real samples.
Gaps in the middle of the window are preserved as-is and remain filled with the gap value.
Slices that fall fully outside the domain or entirely within a gap return empty data.
- Parameters:
start (
float) – Start time.end (
float) – End time.reset_origin (
bool) – IfTrue, all time attributes will be updated to be relative to the new start time. Defaults toTrue.eps (
float) – A tiny ‘rounding buffer’ to handle floating-point noise when computing indices. If your sampling rate is very high, you may need to increase this (e.g., to 1e-7) to avoid off-by-one errors.
- Returns:
A new instance of the same class containing a subset of the data. The new object will have a modified
Intervaldomain reflecting the actual sampled boundaries.- Return type:
- to_hdf5(file)[source]#
Saves the data object to an HDF5 file.
- Parameters:
file – HDF5 file.
import h5py from torch_brain.data import RegularTimeSeries data = RegularTimeSeries( raw=np.zeros((1000, 128)), sampling_rate=250., ) with h5py.File("data.h5", "w") as f: data.to_hdf5(f)
- classmethod from_gappy_timeseries(*_args, **_kwargs)[source]#
Not implemented for
LazyRegularTimeSeries.Use
RegularTimeSeries.from_gappy_timeseries()instead.