Skip to content

Commit c4bf17e

Browse files
authored
Merge pull request #3819 from jakeswann1/dev
allow UnitWaveformsWidget to use probeinterface plot_probe
2 parents 4e90730 + 38801b6 commit c4bf17e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/spikeinterface/widgets/unit_waveforms.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from __future__ import annotations
22

3-
import numpy as np
3+
from packaging.version import parse
44
from warnings import warn
5+
import numpy as np
56

67
from .base import BaseWidget, to_attr
78
from .utils import get_unit_colors
@@ -383,8 +384,20 @@ def plot_matplotlib(self, data_plot, **backend_kwargs):
383384

384385
# plot channels
385386
if dp.plot_channels:
386-
# TODO enhance this
387-
ax.scatter(dp.channel_locations[:, 0], dp.channel_locations[:, 1], color="k")
387+
from probeinterface import __version__ as pi_version
388+
389+
if parse(pi_version) >= parse("0.2.28"):
390+
from probeinterface.plotting import create_probe_polygons
391+
392+
probe = dp.sorting_analyzer_or_templates.get_probe()
393+
contacts, _ = create_probe_polygons(probe, contacts_colors="w")
394+
ax.add_collection(contacts)
395+
else:
396+
ax.scatter(dp.channel_locations[:, 0], dp.channel_locations[:, 1], color="k")
397+
398+
# Apply axis_equal setting
399+
if dp.axis_equal:
400+
ax.set_aspect("equal")
388401

389402
if dp.same_axis and dp.plot_legend:
390403
if hasattr(self, "legend") and self.legend is not None:

0 commit comments

Comments
 (0)