Integral Pulse Frequency Modulation¶
biosigpy.hrv.ipfm ¶
Integral pulse frequency modulation heart-timing reconstruction.
IpfmResult ¶
Bases: NamedTuple
Named, unpackable result returned when the modulating signal is requested.
Attributes:
| Name | Type | Description |
|---|---|---|
ihr | ndarray | Uniformly sampled instantaneous heart rate in hertz. |
m | ndarray | Dimensionless TVIPFM modulating signal. |
Source code in src/biosigpy/hrv/ipfm.py
22 23 24 25 26 27 28 29 30 31 32 33 34 | |
ipfm ¶
ipfm(tn: ArrayLike, fs: float, spline_order: int = 14, *, return_m: bool = False) -> np.ndarray | IpfmResult
Reconstruct instantaneous heart rate from event timestamps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tn | array_like | Finite, strictly increasing event timestamps in seconds. At least two timestamps are required. | required |
fs | float | Positive output sampling frequency in hertz. When | required |
spline_order | int | Order of the canonical B-spline interpolation. It must be between 2 and the number of event timestamps plus 20, inclusive. | 14 |
return_m | bool | If true, also compute the TVIPFM modulating signal and return an :class: | False |
Returns:
| Type | Description |
|---|---|
ndarray or IpfmResult | Instantaneous heart rate alone, or the named |
Raises:
| Type | Description |
|---|---|
TypeError | If an input has an invalid numeric or boolean type. |
ValueError | If timestamps, sampling frequency, spline order, output-grid length, or a computed numerical result violates the Biosiglib contract. |
Notes
The cumulative beat-count spline uses the canonical aptknt knot sequence. The optional fourth-order 0.03 Hz Butterworth trend is applied forward and backward with the fixed MATLAB-compatible odd padding of 12 samples.
Examples:
>>> from biosigpy.hrv import ipfm
>>> ipfm([0, 1, 2, 3], 4).shape
(13,)
>>> result = ipfm([0, 1, 2, 3], 4, return_m=True)
>>> result.ihr.shape == result.m.shape
True
Source code in src/biosigpy/hrv/ipfm.py
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 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 | |