Skip to content

Commit

Permalink
FIX: Make sure channel specific annot fills move after draggin an annot
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-huberty committed Sep 30, 2023
1 parent c1909b2 commit 899c6c5
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mne_qt_browser/_pg_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2225,20 +2225,25 @@ def _region_changed(self):
)
onset = np.min(regions_[:, 0])
offset = np.max(regions_[:, 1])
logger.debug(f"New {self.description} region: {onset:.2f} - {offset:.2f}")
# remove overlapping regions
for region in overlapping_regions:
self.weakmain()._remove_region(region, from_annot=False)
# re-set while blocking the signal to avoid re-running this function
with SignalBlocker(self):
self.setRegion((onset, offset))
self.update_label_pos()
# Update the FillBetweenItem shapes for channel specific annotations
if self.ch_annot_fills:
self._update_channel_annot_fills(onset, offset)

def _update_channel_annot_fills(self, start, stop):
"""Update the FillBetweenItems for channel specific annotations.
FillBetweenItems are used to highlight channels associated with an annotation.
Start and stop are time in seconds.
"""
logger.debug(f"moving {self.description} rectangles to {start} - {stop}")
for this_fill in self.ch_annot_fills:
# we have to update the upper and lower curves of the FillBetweenItem
_, upper_ypos = this_fill.curves[0].getData()
Expand Down Expand Up @@ -2313,7 +2318,7 @@ def select(self, selected):
self.label_item.fill = mkBrush(None)
logger.debug(
f"{'Selected' if self.selected else 'Deselected'} annotation: "
"{self.description}"
f"{self.description}"
)
self.label_item.update()

Expand Down Expand Up @@ -2668,6 +2673,7 @@ def _set_visible_region(self, state, *, description):
self.mne.visible_annotations[description] = bool(state)

def _select_annotations(self):
logger.debug("Annotation selected")
select_dlg = QDialog(self)
chkbxs = list()
layout = QVBoxLayout()
Expand Down Expand Up @@ -2731,7 +2737,8 @@ def _start_changed(self):
if start < stop:
self.mne.selected_region.setRegion((start, stop))
# Make channel specific fillBetweens stay in sync with annot region
sel_region._update_channel_annot_fills(start, stop)
if sel_region.ch_annot_fills:
sel_region._update_channel_annot_fills(start, stop)
else:
self.weakmain().message_box(
text="Invalid value!",
Expand All @@ -2748,7 +2755,8 @@ def _stop_changed(self):
if start < stop:
sel_region.setRegion((start, stop))
# Make channel specific fillBetweens stay in sync with annot region
sel_region._update_channel_annot_fills(start, stop)
if sel_region.ch_annot_fills:
sel_region._update_channel_annot_fills(start, stop)
else:
self.weakmain().message_box(
text="Invalid value!",
Expand Down

0 comments on commit 899c6c5

Please sign in to comment.