Skip to content

Commit

Permalink
plot_evoked_field: fix not being able to tweak the vmin/vmax of…
Browse files Browse the repository at this point in the history
… the field lines when `plot_density=False` (#13048)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
wmvanvliet and pre-commit-ci[bot] authored Jan 8, 2025
1 parent df35021 commit 6bc7dfb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 39 deletions.
1 change: 1 addition & 0 deletions doc/changes/devel/13048.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix input boxes for the max value not showing when plotting fieldlines with :func:`~mne.viz.plot_evoked_field` when ``show_density=False``, by `Marijn van Vliet`_.
69 changes: 30 additions & 39 deletions mne/viz/evoked_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,45 +380,36 @@ def _configure_dock(self):
# Fieldline configuration
layout = r._dock_add_group_box("Fieldlines")

if self._show_density:
r._dock_add_label(value="max value", align=True, layout=layout)

@_auto_weakref
def _callback(vmax, kind, scaling):
self.set_vmax(vmax / scaling, kind=kind)

for surf_map in self._surf_maps:
if surf_map["map_kind"] == "meg":
scaling = DEFAULTS["scalings"]["grad"]
else:
scaling = DEFAULTS["scalings"]["eeg"]
rng = [0, np.max(np.abs(surf_map["data"])) * scaling]
hlayout = r._dock_add_layout(vertical=False)

self._widgets[f"vmax_slider_{surf_map['map_kind']}"] = (
r._dock_add_slider(
name=surf_map["map_kind"].upper(),
value=surf_map["map_vmax"] * scaling,
rng=rng,
callback=partial(
_callback, kind=surf_map["map_kind"], scaling=scaling
),
double=True,
layout=hlayout,
)
)
self._widgets[f"vmax_spin_{surf_map['map_kind']}"] = (
r._dock_add_spin_box(
name="",
value=surf_map["map_vmax"] * scaling,
rng=rng,
callback=partial(
_callback, kind=surf_map["map_kind"], scaling=scaling
),
layout=hlayout,
)
)
r._layout_add_widget(layout, hlayout)
r._dock_add_label(value="max value", align=True, layout=layout)

@_auto_weakref
def _callback(vmax, kind, scaling):
self.set_vmax(vmax / scaling, kind=kind)

for surf_map in self._surf_maps:
if surf_map["map_kind"] == "meg":
scaling = DEFAULTS["scalings"]["grad"]
else:
scaling = DEFAULTS["scalings"]["eeg"]
rng = [0, np.max(np.abs(surf_map["data"])) * scaling]
hlayout = r._dock_add_layout(vertical=False)

self._widgets[f"vmax_slider_{surf_map['map_kind']}"] = r._dock_add_slider(
name=surf_map["map_kind"].upper(),
value=surf_map["map_vmax"] * scaling,
rng=rng,
callback=partial(_callback, kind=surf_map["map_kind"], scaling=scaling),
double=True,
layout=hlayout,
)
self._widgets[f"vmax_spin_{surf_map['map_kind']}"] = r._dock_add_spin_box(
name="",
value=surf_map["map_vmax"] * scaling,
rng=rng,
callback=partial(_callback, kind=surf_map["map_kind"], scaling=scaling),
layout=hlayout,
)
r._layout_add_widget(layout, hlayout)

hlayout = r._dock_add_layout(vertical=False)
r._dock_add_label(
Expand Down

0 comments on commit 6bc7dfb

Please sign in to comment.