From 4f9d2b4dbc26c843ea7a51c1c1e92921e60b74c4 Mon Sep 17 00:00:00 2001 From: Patryk Mikulski Date: Fri, 5 Apr 2024 19:26:25 +0200 Subject: [PATCH] fix: adjust zero-crossing detection: shift by 1, include all data points (#19) --- pyPTE/core/pyPTE.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyPTE/core/pyPTE.py b/pyPTE/core/pyPTE.py index 9f8c582..4d7c053 100644 --- a/pyPTE/core/pyPTE.py +++ b/pyPTE/core/pyPTE.py @@ -20,9 +20,9 @@ def get_delay(phase: npt.NDArray) -> int: """ phase = phase m, n = phase.shape - c1 = n * (m - 2) - r_phase = np.roll(phase, 2, axis=0) - phase_product = np.multiply(phase, r_phase)[1:-1] + c1 = n * m + r_phase = np.roll(phase, 1, axis=0) + phase_product = np.multiply(phase, r_phase) c2 = (phase_product < 0).sum() delay = int(np.round(c1 / c2))