File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -528,15 +528,20 @@ def calc_adc_params(self):
528
528
else :
529
529
gain = 1 / pmin
530
530
baseline = 0
531
- # Regular mixed signal case
532
- # Todo:
531
+ # Regular varied signal case. Map pmax->dmax, pmin->dmin
533
532
else :
533
+ # The equation is: p = (d - b) / g
534
+ # pmax maps to dmax, and pmin maps to dmin. Gradient
535
+ # will be close to delta(d) / delta(p), since intercept
536
+ # baseline has to be an integer.
534
537
gain = (dmax - dmin ) / (pmax - pmin )
535
538
baseline = dmin - gain * pmin
536
-
537
- # What about roundoff error? Make sure values don't map to beyond
538
- # range.
539
- baseline = int (baseline )
539
+ # The baseline needs to be an integer
540
+ baseline = np .floor (baseline )
541
+ # Adjust the gain to map pmin to dmin. This is to ensure
542
+ # there is no overshoot of dmax. Now pmax will map to
543
+ # dmax or dmax-1 which is also fine.
544
+ gain = (dmin - baseline / pmin )
540
545
541
546
# WFDB library limits...
542
547
if abs (gain )> 214748364 or abs (baseline )> 2147483648 :
You can’t perform that action at this time.
0 commit comments