8000 Allow lasso selection sensors in a plot_evoked_topo by wmvanvliet · Pull Request #12071 · mne-tools/mne-python · GitHub
[go: up one dir, main page]

Skip to content

Allow lasso selection sensors in a plot_evoked_topo #12071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2c307fe
First working version of lasso select in plot_evoked_topo
wmvanvliet Oct 4, 2023
6170c63
Merge branch 'main' of github.com:mne-tools/mne-python into sensorselect
wmvanvliet Nov 11, 2023
f6738e7
Fix bug
wmvanvliet Nov 14, 2023
a83b8fd
Fix more renames
wmvanvliet Nov 14, 2023
3bfe2a5
Don't draw patches for channels that do not exist
wmvanvliet Nov 14, 2023
2e94752
Move the ChannelsSelect ui-event one abstraction layer higher
wmvanvliet Nov 14, 2023
3c6b73c
Some more fixes
wmvanvliet Nov 14, 2023
9b6bd60
select_many should not notify()
wmvanvliet Nov 14, 2023
8796836
Merge branch 'main' into sensorselect
wmvanvliet Nov 14, 2023
573 8000 cb40
Add "select" parameter to enable/disable the lasso selection tool
wmvanvliet Nov 14, 2023
facd394
Add select parameter to relevant methods
wmvanvliet Nov 14, 2023
a0069d8
Update test
wmvanvliet Nov 15, 2023
56ebda7
Merge branch 'main' into sensorselect
wmvanvliet Jul 24, 2024
d913fff
fix bugs (thanks vulture!)
wmvanvliet Jul 24, 2024
65fb86b
Merge branch 'main' of github.com:mne-tools/mne-python into sensorselect
wmvanvliet Oct 8, 2024
9b6b06a
Merge branch 'sensorselect' of github.com:wmvanvliet/mne-python into …
wmvanvliet Oct 8, 2024
bcef66e
attempt to fix tests
wmvanvliet Oct 8, 2024
8efcb8c
further attempts to fix tests
wmvanvliet Oct 22, 2024
87f72e2
Add what's new entry
wmvanvliet Oct 22, 2024
6601235
Merge branch 'main' into sensorselect
wmvanvliet Oct 22, 2024
871e15a
Merge branch 'sensorselect' of github.com:wmvanvliet/mne-python into …
wmvanvliet Oct 22, 2024
bea101d
Update unit tests for lasso select
wmvanvliet Jan 7, 2025
2ae07bf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 7, 2025
f55028d
Merge branch 'main' into sensorselect
wmvanvliet Jan 20, 2025
49c9d0b
Merge branch 'sensorselect' of github.com:wmvanvliet/mne-python into …
wmvanvliet Jan 20, 2025
e857a2e
Move large lasso test to test_utils.py and have smaller tests in test…
wmvanvliet Jan 20, 2025
822f761
select from proper list of channels
wmvanvliet Jan 20, 2025
51efe6c
fix version
wmvanvliet Jan 20, 2025
e806634
more versionadded annotations
wmvanvliet Jan 20, 2025
dbabf05
Properly implement and test single channel picking
wmvanvliet Jan 22, 2025
e90887d
Add logging message
wmvanvliet Jan 22, 2025
fbfa161
small fix
wmvanvliet Jan 22, 2025
735b9c2
remove print()
wmvanvliet Jan 22, 2025
6f00a75
fix hasattr()
wmvanvliet Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mne/epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,7 @@ def plot_topo_image(
fig_facecolor="k",
fig_background=None,
font_color="w",
select=False,
show=True,
):
return plot_topo_image_epochs(
Expand All @@ -1371,6 +1372,7 @@ def plot_topo_image(
fig_facecolor=fig_facecolor,
fig_background=fig_background,
font_color=font_color,
select=select,
show=show,
)

Expand Down
2 changes: 2 additions & 0 deletions mne/evoked.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ def plot_topo(
background_color="w",
noise_cov=None,
exclude="bads",
select=False,
show=True,
):
"""
Expand All @@ -638,6 +639,7 @@ def plot_topo(
background_color=background_color,
noise_cov=noise_cov,
exclude=exclude,
select=select,
show=show,
)

Expand Down
2 changes: 1 addition & 1 deletion mne/viz/_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def _create_ch_location_fig(self, pick):
# highlight desired channel & disable interactivity
fig.lasso.selection_inds = np.isin(fig.lasso.names, [ch_name])
fig.lasso.disconnect()
fig.lasso.alpha_other = 0.3
fig.lasso.alpha_nonselected = 0.3
fig.lasso.linewidth_selected = 3
fig.lasso.style_objects()

Expand Down
3 changes: 3 additions & 0 deletions mne/viz/evoked.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,9 @@ def plot_evoked_topo(
``fig.lasso.selection``.

.. versionadded:: 1.9.0
exclude : list of str | ``'bads'``
Channels names to exclude from the plot. If ``'bads'``, the
bad channels are excluded. By default, exclude is set to ``'bads'``.
show : bool
Show figure if True.

Expand Down
10 changes: 5 additions & 5 deletions mne/viz/tests/test_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,10 +1102,10 @@ def test_plot_sensors(raw):
_fake_click(fig, ax, (0, 1), xform="ax")
fig.canvas.draw()
assert fig.lasso.selection == []
_fake_click(fig, ax, (0.65, 1), xform="ax", kind="motion")
_fake_click(fig, ax, (0.65, 0.7), xform="ax", kind="motion")
_fake_click(fig, ax, (-0.11, 0.14), xform="data", kind="motion")
_fake_click(fig, ax, (-0.11, 0.065), xform="data", kind="motion")
_fake_keypress(fig, "shift")
_fake_click(fig, ax, (0, 0.7), xform="ax", kind="release", key="shift")
_fake_click(fig, ax, (-0.15, 0.065), xform="data", kind="release", key="shift")
assert fig.lasso.selection == ["MEG 0121"]

# check that point appearance changes
Expand All @@ -1114,11 +1114,11 @@ def test_plot_sensors(raw):
assert (fc[:, -1] == [0.5, 1.0, 0.5]).all()
assert (ec[:, -1] == [0.25, 1.0, 0.25]).all()

_fake_click(fig, ax, (0.7, 1), xform="ax", kind="motion", key="shift")
_fake_click(fig, ax, (-0.11, 0.065), xform="data", kind="motion", key="shift")
xy = ax.collections[0].get_offsets()
_fake_click(fig, ax, xy[2], xform="data", key="shift") # single sel
assert fig.lasso.selection == ["MEG 0121", "MEG 0131"]
_fake_click(fig, ax, xy[2], xform="data", key="shift") # deselect
_fake_click(fig, ax, xy[2], xform="data", key="alt") # deselect
assert fig.lasso.selection == ["MEG 0121"]
plt.close("all")

Expand Down
2 changes: 1 addition & 1 deletion mne/viz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@ def select_one(self, ind):

def select_many(self, inds):
"""Select many sensors using indices (for predefined selections)."""
self.selected_inds = inds
self.selection_inds = inds
self.selection = [self.names[i] for i in self.selection_inds]
self.style_objects()

Expand Down
Loading
0