vitabel.utils.signal¶
Signal processing utilities (derivatives, integrals, smoothing, gaps, resampling, signal features).
Functions¶
|
First derivative of |
|
Cumulative integral of |
|
Calculate a centered average mean of data over k elements. |
|
|
|
Fill the gaps found by |
Aligns two or more Channel objects by their time indices, ensuring |
|
|
Module Contents¶
- vitabel.utils.signal.deriv(time: numpy.typing.ArrayLike, data: numpy.typing.ArrayLike) numpy.typing.NDArray¶
First derivative of
datawith respect totime: central differences inside, forward / backward differences at the boundaries.- Parameters:
- time
x values, in increasing order (not necessarily equidistant).
- data
Corresponding y values.
- Returns:
- The derivative at every x value.
- vitabel.utils.signal.integrate(time: numpy.typing.ArrayLike, data: numpy.typing.ArrayLike) pandas.Series¶
Cumulative integral of
dataovertime(trapezoidal rule).- Parameters:
- time
Times in seconds (not necessarily equidistant).
- data
Data points.
- Returns:
- The integral from the first time to each time (starting at 0).
- vitabel.utils.signal.av_mean(k: int, data: numpy.typing.ArrayLike) numpy.typing.NDArray¶
Calculate a centered average mean of data over k elements.
The data is zero-padded at the boundaries.
- vitabel.utils.signal.determine_gaps_in_recording(time: numpy.typing.ArrayLike, data: numpy.typing.ArrayLike)¶
- vitabel.utils.signal.linear_interpolate_gaps_in_recording(time: numpy.typing.ArrayLike, data: numpy.typing.ArrayLike)¶
Fill the gaps found by
determine_gaps_in_recording()with points at the median time step, linearly interpolated between the samples around the gap. The result is sorted like the input.
- vitabel.utils.signal.resample_to_common_index(*channels: vitabel.timeseries.Channel) tuple[vitabel.typing.DataSlice, Ellipsis]¶
Aligns two or more Channel objects by their time indices, ensuring all are sampled at the same time points, including zero-crossings. Data are interpolated to a common time base within their overlapping range.
- Parameters:
- *channels
Two or more
Channelobjects to be aligned and interpolated.
- Returns:
- tuple[DataSlice, …]
A tuple of
DataSliceobjects representing the aligned channels.
- Raises:
- ValueError
If there is no overlapping time range between the two channels.
Notes
Zero-crossings are inserted to improve alignment, especially for strongly oscillating signals.
- vitabel.utils.signal.gaussian_kernel_regression_point(x0, x, y, sigma=1, max_width_factor=2)¶