sloperange
biosigpy.ecg.sloperange.SlopeRangeResult ¶
Bases: NamedTuple
Named, unpackable result of :func:sloperange.
Attributes:
| Name | Type | Description |
|---|---|---|
edr | ndarray | ECG-derived respiration amplitudes aligned with R-wave times, in the same arbitrary amplitude unit as |
upslopes | ndarray | Signal-aligned derivative ECG values inside complete upslope windows, with |
downslopes | ndarray | Signal-aligned derivative ECG values inside complete downslope windows, with |
upslope_max_positions | ndarray | Zero-based positions of selected upslope maxima aligned with R-wave times, in samples, with |
downslope_min_positions | ndarray | Zero-based positions of selected downslope minima aligned with R-wave times, in samples, with |
Source code in src/biosigpy/ecg/sloperange.py
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 | |
biosigpy.ecg.sloperange.sloperange ¶
sloperange(decg: ArrayLike, r_wave_times: ArrayLike, sampling_frequency: float) -> SlopeRangeResult
Estimate respiration from derivative ECG morphology around R waves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
decg | array_like | One-dimensional derivative ECG signal with at least two finite real samples. | required |
r_wave_times | array_like | Finite R-wave occurrence times in seconds. Values must form a non-empty, strictly increasing one-dimensional sequence and map inside the derivative ECG sample grid. | required |
sampling_frequency | float | Positive finite sampling frequency in Hz. | required |
Returns:
| Type | Description |
|---|---|
SlopeRangeResult | Named result containing five one-dimensional arrays. |
Raises:
| Type | Description |
|---|---|
TypeError | If an input expected to be numeric contains non-numeric or complex data. |
ValueError | If an input has an invalid shape, length, finite-value constraint, order, sample-grid mapping, or sampling frequency. |
Notes
Extrema positions use the zero-based Python and canonical Biosiglib sample grid. Beats contribute to both diagnostic slope vectors only when both analysis windows are complete. The earliest sample is selected when an extreme value is tied.
Examples:
>>> import numpy as np
>>> from biosigpy.ecg import sloperange
>>> decg = np.zeros(40)
>>> decg[[9, 10]] = 3.0
>>> decg[[13, 14]] = -2.0
>>> result = sloperange(decg, [0.1], 100.0)
>>> result.edr
array([5.])
>>> result.upslope_max_positions
array([9.])
>>> edr, upslopes, downslopes, upmaxpos, downminpos = result
Source code in src/biosigpy/ecg/sloperange.py
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |