Skip to content

Commit aacf0cf

Browse files
Backport PR #13330 on branch maint/1.10 (MAINT: Dont set attribute on PolyData) (#13335)
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
1 parent cb385ee commit aacf0cf

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

mne/viz/_brain/_brain.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,6 @@ def __init__(
441441
name="curv",
442442
)
443443
self._layered_meshes[h] = mesh
444-
# add metadata to the mesh for picking
445-
mesh._polydata._hemi = h
446444
else:
447445
actor = self._layered_meshes[h]._actor
448446
self._renderer.plotter.add_actor(actor, render=False)
@@ -1248,12 +1246,12 @@ def _on_pick(self, vtk_picker, event):
12481246
return
12491247

12501248
# 3) Otherwise, pick the objects in the scene
1251-
try:
1252-
hemi = mesh._hemi
1253-
except AttributeError: # volume
1254-
hemi = "vol"
1249+
for hemi, this_mesh in self._layered_meshes.items():
1250+
assert hemi in ("lh", "rh"), f"Unexpected {hemi=}"
1251+
if this_mesh._polydata is mesh:
1252+
break
12551253
else:
1256-
assert hemi in ("lh", "rh")
1254+
hemi = "vol"
12571255
if self.act_data_smooth[hemi][0] is None: # no data to add for hemi
12581256
return
12591257
pos = np.array(vtk_picker.GetPickPosition())

mne/viz/_brain/tests/test_brain.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ def test_single_hemi(hemi, renderer_interactive_pyvistaqt, brain_gc):
774774
@pytest.mark.parametrize("interactive_state", (False, True))
775775
def test_brain_save_movie(tmp_path, renderer, brain_gc, interactive_state):
776776
"""Test saving a movie of a Brain instance."""
777+
pytest.importorskip("imageio")
777778
imageio_ffmpeg = pytest.importorskip("imageio_ffmpeg")
778779

779780
brain = _create_testing_brain(

0 commit comments

Comments
 (0)