baselineremove
biosigpy.ecg.baselineremove.BaselineRemoveResult ¶
Bases: NamedTuple
Named, unpackable result of :func:baselineremove.
Source code in src/biosigpy/ecg/baselineremove.py
22 23 24 25 26 | |
biosigpy.ecg.baselineremove.BaselineRemoveWarning ¶
Bases: UserWarning
Structured Biosiglib diagnostic emitted by :func:baselineremove.
Source code in src/biosigpy/ecg/baselineremove.py
29 30 31 32 33 34 35 36 37 38 | |
biosigpy.ecg.baselineremove.baselineremove ¶
baselineremove(ecg: ArrayLike, fiducial_positions: ArrayLike, offset: int, window_size: int = 5) -> BaselineRemoveResult
Remove an ECG baseline estimated at supplied fiducial positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ecg | array_like | Non-empty one-dimensional finite real ECG signal. | required |
fiducial_positions | array_like | Non-empty positive finite positions on the canonical one-based sample grid. Fractional, unordered, and repeated positions are accepted. | required |
offset | int | Nonnegative sample offset subtracted before position rounding. | required |
window_size | int | Positive nominal averaging-window size. Even values produce a symmetric effective span of | 5 |
Returns:
| Type | Description |
|---|---|
BaselineRemoveResult | Named result containing the detrended ECG and estimated baseline as one-dimensional arrays aligned with |
Warns:
| Type | Description |
|---|---|
BaselineRemoveWarning | If no adjusted fiducial position lies inside the signal. The original ECG and an all-zero baseline are returned. |
Raises:
| Type | Description |
|---|---|
TypeError | If a vector is non-numeric or complex, or a scalar is not an integer. |
ValueError | If a vector is empty, has an invalid shape or nonfinite values, a scalar is outside its allowed range, or exactly one valid fiducial position remains. |
Notes
Positions are rounded half away from zero after subtracting offset. Two valid positions define a line, three define a quadratic, and four or more define a cubic not-a-knot spline. The end pieces extrapolate over ECG samples outside the first and last valid positions.
Examples:
>>> result = baselineremove([2, 4, 8, 16, 32], [1, 5], 0, 2)
>>> result.baseline
array([ 3. , 8.25, 13.5 , 18.75, 24. ])
Source code in src/biosigpy/ecg/baselineremove.py
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 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 | |