slicesignal
biosigpy.tools.slicesignal.slicesignal ¶
slicesignal(signal: ArrayLike, window_length: int, overlap: int, sampling_frequency: float | None = None, *, use_last: bool = False) -> np.ndarray | tuple[np.ndarray, np.ndarray]
Slice a signal into rows with optional overlapping samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal | array_like | Nonempty real vector. Existing NaNs and infinities are preserved. | required |
window_length | int | Positive window length in samples. | required |
overlap | int | Number of shared samples, from zero to window_length minus one. | required |
sampling_frequency | float | Finite positive sampling frequency in Hz. If supplied, also return one time center per window, in seconds from the first input sample. | None |
use_last | bool | Pad an uncovered tail on the right with NaNs. A nonempty signal shorter than one window is then returned as one padded window. | False |
Returns:
| Name | Type | Description |
|---|---|---|
windows | ndarray | Array of shape (number of windows, window_length). |
time_centers | (ndarray, optional) | Returned together with windows only when sampling_frequency is supplied. Each center refers to the nominal window, including padding. |
Source code in src/biosigpy/tools/slicesignal.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |