Skip to content

Commit

Permalink
BUG: Fix bug in label picking (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
marsipu authored Apr 1, 2024
1 parent 98623fa commit f2f3808
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions mne_pipeline_hd/gui/parameter_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,8 +1255,6 @@ def __init__(
# Title text
self.add_text(0, 0.9, "", color="w", font_size=14, name="title")

self.show_view(roll=0, elevation=60, azimuth=70)

self._set_annotations(parcellation)
self._init_picking()

Expand Down Expand Up @@ -1504,7 +1502,6 @@ def _subject_changed(self):
self._selected_parc_labels += [
lb for lb in old_selected_parc if lb in all_labels_exept_other
]
self.parc_label_list.content_changed()

# Update pickers if open
if self._parc_picker is not None and not self._parc_picker.isclosed():
Expand All @@ -1528,6 +1525,8 @@ def _parc_changed(self):
lb.name for lb in self._fsmri.labels[self._parcellation]
]

self.parc_label_list.content_changed()

if self._parc_picker is not None and not self._parc_picker.isclosed():
self._parc_picker._set_annotations(self._parcellation)
for label_name in [
Expand Down
12 changes: 6 additions & 6 deletions mne_pipeline_hd/tests/test_parameter_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def test_label_gui(qtbot, controller):
assert "postcentral-lh" in dlg._parc_picker._shown_labels
# Add label by clicking on plot
qtbot.mouseClick(parc_plot, Qt.LeftButton, pos=parc_plot.rect().center(), delay=100)
assert "superiorfrontal-rh" in dlg._selected_parc_labels
assert "supramarginal-rh" in dlg._selected_parc_labels
# Remove label by clicking on plot
qtbot.mouseClick(parc_plot, Qt.LeftButton, pos=parc_plot.rect().center(), delay=100)
assert "superiorfrontal-rh" not in dlg._selected_parc_labels
Expand All @@ -220,20 +220,20 @@ def test_label_gui(qtbot, controller):
assert "lh.BA1-lh" in dlg._extra_picker._shown_labels

# Change parcellation
dlg.parcellation_cmbx.setCurrentText("aparc.a2009s")
dlg.parcellation_cmbx.setCurrentText("aparc_sub")
dlg._parc_changed() # Only triggered by mouse click with .activated
# Add label by clicking on plot
qtbot.mouseClick(parc_plot, Qt.LeftButton, pos=parc_plot.rect().center(), delay=100)
assert "G_front_sup-rh" in dlg._selected_parc_labels
assert "supramarginal_9-rh" in dlg._selected_parc_labels
# Add label by selecting from list
toggle_checked_list_model(dlg.parc_label_list.model, value=1, row=0)
assert "G_Ins_lg_and_S_cent_ins-lh" in dlg._selected_parc_labels
assert "bankssts_1-lh" in dlg._selected_parc_labels

final_selection = [
"insula-lh",
"postcentral-lh",
"G_front_sup-rh",
"G_Ins_lg_and_S_cent_ins-lh",
"supramarginal_9-rh",
"bankssts_1-lh",
"lh.BA1-lh",
]
# Check display widget
Expand Down

0 comments on commit f2f3808

Please sign in to comment.