From a71aa3929c38299120000f8460aa048cf5c6c2c1 Mon Sep 17 00:00:00 2001 From: marsipu Date: Tue, 1 Aug 2023 06:28:21 +0200 Subject: [PATCH 01/14] change width to 2 --- mne_qt_browser/_pg_figure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index 88eb208f..e3308c99 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -1381,7 +1381,7 @@ class VLine(InfiniteLine): """Marker to be placed inside the Trace-Plot.""" def __init__(self, mne, pos, bounds): - super().__init__(pos, pen='g', hoverPen='y', + super().__init__(pos, pen={"color": "g", "width": 2}, hoverPen='y', movable=True, bounds=bounds) self.mne = mne self.label = VLineLabel(self) From f279c8c96377e576f7d9120f2dae76c96701c749 Mon Sep 17 00:00:00 2001 From: marsipu Date: Tue, 1 Aug 2023 06:28:33 +0200 Subject: [PATCH 02/14] also change label color on hover --- mne_qt_browser/_pg_figure.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index e3308c99..e67e1d16 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -1386,6 +1386,12 @@ def __init__(self, mne, pos, bounds): self.mne = mne self.label = VLineLabel(self) + def setMouseHover(self, hover): + super().setMouseHover(hover) + # Also change color of label + self.label.fill = self.currentPen.color() + self.label.border = self.currentPen + def _q_font(point_size, bold=False): font = QFont() From 3e95392c30aaf86594b54b6ce45bb20d542c3eb9 Mon Sep 17 00:00:00 2001 From: marsipu Date: Tue, 1 Aug 2023 06:36:23 +0200 Subject: [PATCH 03/14] hover also working on label --- mne_qt_browser/_pg_figure.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index e67e1d16..58481294 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -1376,6 +1376,9 @@ def valueChanged(self): self.setText(self.format.format(value=value)) self.updatePosition() + def hoverEvent(self, ev): + self.line.hoverEvent(ev) + class VLine(InfiniteLine): """Marker to be placed inside the Trace-Plot.""" From a2534c6150a76028eede7e5f1d99954432ba4af4 Mon Sep 17 00:00:00 2001 From: marsipu Date: Tue, 1 Aug 2023 07:03:37 +0200 Subject: [PATCH 04/14] make color a bit darker --- mne_qt_browser/_pg_figure.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index 58481294..d2f08346 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -1340,7 +1340,7 @@ class VLineLabel(InfLineLabel): def __init__(self, vline): super().__init__(vline, text='{value:.3f} s', position=0.98, - fill='g', color='b', movable=True) + fill=(0, 191, 0), color='k', movable=True) self.cursorOffset = None def mouseDragEvent(self, ev): @@ -1384,7 +1384,7 @@ class VLine(InfiniteLine): """Marker to be placed inside the Trace-Plot.""" def __init__(self, mne, pos, bounds): - super().__init__(pos, pen={"color": "g", "width": 2}, hoverPen='y', + super().__init__(pos, pen={"color": (0, 191, 0), "width": 2}, hoverPen='y', movable=True, bounds=bounds) self.mne = mne self.label = VLineLabel(self) @@ -3419,6 +3419,7 @@ def __init__(self, **kwargs): del self.mne.keyboard_shortcuts["t"] # disable histogram of epoch PTP amplitude del self.mne.keyboard_shortcuts["h"] + self._add_vline(3) def _hidpi_mkPen(self, *args, **kwargs): kwargs['width'] = self._pixel_ratio * kwargs.get('width', 1.) From deed173b3287bbc69483f6b6fdd42ce4f8ec65f2 Mon Sep 17 00:00:00 2001 From: marsipu Date: Tue, 1 Aug 2023 11:22:28 +0200 Subject: [PATCH 05/14] fix CI-error --- mne_qt_browser/_pg_figure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index d2f08346..32975147 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -4719,7 +4719,7 @@ def closeEvent(self, event): _disconnect(vl.sigPositionChangeFinished) self.mne.vline.clear() else: - _disconnect(self.mne.vline.sigPositionChangeFinished) + _disconnect(self.mne.vline.sigPositionChangeFinished, allow_error=True) if getattr(self, 'load_thread', None) is not None: self.load_thread.clean() self.load_thread = None From e5d4ff0426c14681cf33b9e2debab32e2fda0121 Mon Sep 17 00:00:00 2001 From: marsipu Date: Tue, 1 Aug 2023 11:25:15 +0200 Subject: [PATCH 06/14] fix ruff --- mne_qt_browser/_pg_figure.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index 32975147..55d1ca31 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -4719,7 +4719,8 @@ def closeEvent(self, event): _disconnect(vl.sigPositionChangeFinished) self.mne.vline.clear() else: - _disconnect(self.mne.vline.sigPositionChangeFinished, allow_error=True) + _disconnect(self.mne.vline.sigPositionChangeFinished, + allow_error=True) if getattr(self, 'load_thread', None) is not None: self.load_thread.clean() self.load_thread = None From 9da75def88c2e820f2159531bcfdd4541cbfc10a Mon Sep 17 00:00:00 2001 From: marsipu Date: Tue, 1 Aug 2023 11:32:36 +0200 Subject: [PATCH 07/14] less clumsy solution --- mne_qt_browser/_pg_figure.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index 55d1ca31..eed3eabf 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -1377,7 +1377,7 @@ def valueChanged(self): self.updatePosition() def hoverEvent(self, ev): - self.line.hoverEvent(ev) + _methpartial(self.line.hoverEvent)(ev) class VLine(InfiniteLine): @@ -2005,7 +2005,7 @@ def closeEvent(self, event): # noqa: D102 # MNE >= 1.0 self.channel_fig.lasso.callbacks.clear() for chkbx in self.chkbxs.values(): - _disconnect(chkbx.clicked, allow_error=True) + _disconnect(chkbx.clicked) main = self.weakmain() if main is not None: main.close() From 3844af33f8a10bb9dc43d5723369581d695304d9 Mon Sep 17 00:00:00 2001 From: marsipu Date: Tue, 1 Aug 2023 11:33:52 +0200 Subject: [PATCH 08/14] less clumsy solution part 2 --- mne_qt_browser/_pg_figure.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index eed3eabf..2b6c19e4 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -4719,8 +4719,7 @@ def closeEvent(self, event): _disconnect(vl.sigPositionChangeFinished) self.mne.vline.clear() else: - _disconnect(self.mne.vline.sigPositionChangeFinished, - allow_error=True) + _disconnect(self.mne.vline.sigPositionChangeFinished) if getattr(self, 'load_thread', None) is not None: self.load_thread.clean() self.load_thread = None From f87b0588805a32e5041e5fae5ae1bc3e326cbf58 Mon Sep 17 00:00:00 2001 From: marsipu Date: Tue, 1 Aug 2023 11:49:55 +0200 Subject: [PATCH 09/14] remove demo vline --- mne_qt_browser/_pg_figure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index 2b6c19e4..9fd73709 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -3419,7 +3419,7 @@ def __init__(self, **kwargs): del self.mne.keyboard_shortcuts["t"] # disable histogram of epoch PTP amplitude del self.mne.keyboard_shortcuts["h"] - self._add_vline(3) + def _hidpi_mkPen(self, *args, **kwargs): kwargs['width'] = self._pixel_ratio * kwargs.get('width', 1.) From ead91150a5fa396f57c3668b05077dae366912ba Mon Sep 17 00:00:00 2001 From: marsipu Date: Tue, 1 Aug 2023 11:50:31 +0200 Subject: [PATCH 10/14] revert wrong change --- mne_qt_browser/_pg_figure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index 9fd73709..3dbeed42 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -2005,7 +2005,7 @@ def closeEvent(self, event): # noqa: D102 # MNE >= 1.0 self.channel_fig.lasso.callbacks.clear() for chkbx in self.chkbxs.values(): - _disconnect(chkbx.clicked) + _disconnect(chkbx.clicked, allow_error=True) main = self.weakmain() if main is not None: main.close() From 95801f542257488726d425b96144bbfe6ac12c1c Mon Sep 17 00:00:00 2001 From: marsipu Date: Tue, 1 Aug 2023 11:55:20 +0200 Subject: [PATCH 11/14] try adding weakref to .line-attribute of VLineLabel --- mne_qt_browser/_pg_figure.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index 3dbeed42..1ca1b4b8 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -1339,6 +1339,7 @@ class VLineLabel(InfLineLabel): """Label of the vline displaying the time.""" def __init__(self, vline): + vline = weakref.ref(vline) super().__init__(vline, text='{value:.3f} s', position=0.98, fill=(0, 191, 0), color='k', movable=True) self.cursorOffset = None From ad43ff75e6d62414cdacd14b6a16daa0ac1c1559 Mon Sep 17 00:00:00 2001 From: marsipu Date: Tue, 1 Aug 2023 12:12:19 +0200 Subject: [PATCH 12/14] can't find better fix --- mne_qt_browser/_pg_figure.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index 1ca1b4b8..e6d1b218 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -1339,7 +1339,6 @@ class VLineLabel(InfLineLabel): """Label of the vline displaying the time.""" def __init__(self, vline): - vline = weakref.ref(vline) super().__init__(vline, text='{value:.3f} s', position=0.98, fill=(0, 191, 0), color='k', movable=True) self.cursorOffset = None @@ -4717,10 +4716,10 @@ def closeEvent(self, event): if getattr(self.mne, 'vline', None) is not None: if self.mne.is_epochs: for vl in self.mne.vline: - _disconnect(vl.sigPositionChangeFinished) + _disconnect(vl.sigPositionChangeFinished, allow_error=True) self.mne.vline.clear() else: - _disconnect(self.mne.vline.sigPositionChangeFinished) + _disconnect(self.mne.vline.sigPositionChangeFinished, allow_error=True) if getattr(self, 'load_thread', None) is not None: self.load_thread.clean() self.load_thread = None From 89a6b93c6febece394e5f618374a1fdd0bd66f09 Mon Sep 17 00:00:00 2001 From: marsipu Date: Wed, 2 Aug 2023 13:17:50 +0200 Subject: [PATCH 13/14] fix ruff --- mne_qt_browser/_pg_figure.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index e6d1b218..9d393deb 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -4719,7 +4719,8 @@ def closeEvent(self, event): _disconnect(vl.sigPositionChangeFinished, allow_error=True) self.mne.vline.clear() else: - _disconnect(self.mne.vline.sigPositionChangeFinished, allow_error=True) + _disconnect(self.mne.vline.sigPositionChangeFinished, + allow_error=True) if getattr(self, 'load_thread', None) is not None: self.load_thread.clean() self.load_thread = None From 2dbcbe823db196b629a8fedc558f10b635e48408 Mon Sep 17 00:00:00 2001 From: marsipu Date: Wed, 2 Aug 2023 15:04:11 +0200 Subject: [PATCH 14/14] make color constant --- mne_qt_browser/_pg_figure.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index 9d393deb..8d4d12f2 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -96,6 +96,8 @@ (0, 255, 255): (0, 139, 139), # 'darkcyan' } +_vline_color = (0, 191, 0) + def _get_color(color_spec, invert=False): """Wrap mkColor to accept all possible matplotlib color-specifiers.""" @@ -1340,7 +1342,7 @@ class VLineLabel(InfLineLabel): def __init__(self, vline): super().__init__(vline, text='{value:.3f} s', position=0.98, - fill=(0, 191, 0), color='k', movable=True) + fill=_vline_color, color='k', movable=True) self.cursorOffset = None def mouseDragEvent(self, ev): @@ -1384,7 +1386,7 @@ class VLine(InfiniteLine): """Marker to be placed inside the Trace-Plot.""" def __init__(self, mne, pos, bounds): - super().__init__(pos, pen={"color": (0, 191, 0), "width": 2}, hoverPen='y', + super().__init__(pos, pen={"color": _vline_color, "width": 2}, hoverPen='y', movable=True, bounds=bounds) self.mne = mne self.label = VLineLabel(self)