LazyIrregularTimeSeries#
- class torch_brain.data.LazyIrregularTimeSeries(**kwargs)[source]#
Bases:
torch_brain.data.irregular_ts.IrregularTimeSeriesLazy variant of
IrregularTimeSeries. 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.LazyIrregularTimeSeries.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.
- select_by_mask(mask)[source]#
Index all arrays with a boolean mask and return a copy.
Lazy attributes will remain lazy, and masking will be applied to them upon access.
- Parameters:
mask (
ndarray) – Boolean array used for masking. The mask needs to be 1-dimensional, and of equal length as the object itself.
- slice(start, end, reset_origin=True)[source]#
Returns a new
IrregularTimeSeriesobject that contains the data between the start and end times. The end time is exclusive, the slice will only include data in \([\textrm{start}, \textrm{end})\).If
reset_originisTrue, all time attributes are updated to be relative to the new start time. The domain is also updated accordingly.Warning
If the time series is not sorted, it will be automatically sorted in place.
- to_hdf5(file)[source]#
Saves the data object to an HDF5 file.
- Parameters:
file – HDF5 file.
Warning
If the time series is not sorted, it will be automatically sorted in place.
import h5py from torch_brain.data import IrregularTimeseries data = IrregularTimeseries( unit_index=[0, 0, 1, 0, 1, 2], timestamps=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], waveforms=np.zeros((6, 48)), domain="auto", ) with h5py.File("data.h5", "w") as f: data.to_hdf5(f)