From bca1fe206cf0c636f02b109f76a1b8979a4e2b3b Mon Sep 17 00:00:00 2001 From: Miles Wells Date: Tue, 7 Nov 2023 13:10:57 +0200 Subject: [PATCH] Handle missing wheel data --- task_qc_viewer/ViewEphysQC.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/task_qc_viewer/ViewEphysQC.py b/task_qc_viewer/ViewEphysQC.py index 03de6e0..1bd7803 100644 --- a/task_qc_viewer/ViewEphysQC.py +++ b/task_qc_viewer/ViewEphysQC.py @@ -160,9 +160,12 @@ def tv_double_clicked(self): if self.wheel: idx = np.searchsorted(self.wheel['re_ts'], np.array([start - dt / 10, finish + dt / 10])) - max_val = np.max(self.wheel['re_pos'][idx[0]:idx[1]]) - min_val = np.min(self.wheel['re_pos'][idx[0]:idx[1]]) - self.wplot.canvas.ax2.set_ylim(min_val - 1, max_val + 1) + period = self.wheel['re_pos'][idx[0]:idx[1]] + if period.size == 0: + _logger.warning('No wheel data during trial #%i', ind.row()) + else: + min_val, max_val = np.min(period), np.max(period) + self.wplot.canvas.ax2.set_ylim(min_val - 1, max_val + 1) self.wplot.canvas.ax2.set_xlim(start - dt / 10, finish + dt / 10) self.wplot.canvas.ax.set_xlim(start - dt / 10, finish + dt / 10)