Skip to content

Commit

Permalink
Merge pull request #2024 from samuelgarcia/ephyviewer_plot_trace
Browse files Browse the repository at this point in the history
For connoisseur only: add a simple "ephyviewer" backend plot_traces().
  • Loading branch information
alejoe91 authored Sep 21, 2023
2 parents a04f212 + 36e197f commit 419e3cd
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 2 deletions.
Binary file added doc/images/plot_traces_ephyviewer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 41 additions & 1 deletion doc/modules/widgets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Since version 0.95.0, the :py:mod:`spikeinterface.widgets` module supports multi
* | :code:`sortingview`: web-based and interactive rendering using the `sortingview <https://github.com/magland/sortingview>`_
| and `FIGURL <https://github.com/flatironinstitute/figurl>`_ packages.
Version 0.100.0, also come with this new backend:
* | :code:`ephyviewer`: interactive Qt based using the `ephyviewer <https://ephyviewer.readthedocs.io/en/latest/>`_ package


Installing backends
-------------------
Expand Down Expand Up @@ -85,6 +88,28 @@ Finally, if you wish to set up another cloud provider, follow the instruction fr
`kachery-cloud <https://github.com/flatironinstitute/kachery-cloud>`_ package ("Using your own storage bucket").


ephyviewer
^^^^^^^^^^

This backend is Qt based with PyQt5, PyQt6 or PySide6 support. Qt is sometimes tedious to install.


For a pip-based installation, run:

.. code-block:: bash
pip install PySide6 ephyviewer
Anaconda users will have a better experience with this:

.. code-block:: bash
conda install pyqt=5
pip install ephyviewer
Usage
-----

Expand Down Expand Up @@ -215,6 +240,21 @@ For example, here is how to combine the timeseries and sorting summary generated
print(url)
ephyviewer
^^^^^^^^^^


The :code:`ephyviewer` backend is currently only available for the :py:func:`~spikeinterface.widgets.plot_traces()` function.


.. code-block:: python
plot_traces(recording, backend="ephyviewer", mode="line", show_channel_ids=True)
.. image:: ../images/plot_traces_ephyviewer.png



Available plotting functions
----------------------------
Expand All @@ -229,7 +269,7 @@ Available plotting functions
* :py:func:`~spikeinterface.widgets.plot_spikes_on_traces` (backends: :code:`matplotlib`, :code:`ipywidgets`)
* :py:func:`~spikeinterface.widgets.plot_template_metrics` (backends: :code:`matplotlib`, :code:`ipywidgets`, :code:`sortingview`)
* :py:func:`~spikeinterface.widgets.plot_template_similarity` (backends: ::code:`matplotlib`, :code:`sortingview`)
* :py:func:`~spikeinterface.widgets.plot_timeseries` (backends: :code:`matplotlib`, :code:`ipywidgets`, :code:`sortingview`)
* :py:func:`~spikeinterface.widgets.plot_traces` (backends: :code:`matplotlib`, :code:`ipywidgets`, :code:`sortingview`, :code:`ephyviewer`)
* :py:func:`~spikeinterface.widgets.plot_unit_depths` (backends: :code:`matplotlib`)
* :py:func:`~spikeinterface.widgets.plot_unit_locations` (backends: :code:`matplotlib`, :code:`ipywidgets`, :code:`sortingview`)
* :py:func:`~spikeinterface.widgets.plot_unit_summary` (backends: :code:`matplotlib`)
Expand Down
2 changes: 2 additions & 0 deletions src/spikeinterface/widgets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ def set_default_plotter_backend(backend):
"height_cm": "Height of the figure in cm (default 6)",
"display": "If True, widgets are immediately displayed",
},
"ephyviewer": {},
}

default_backend_kwargs = {
"matplotlib": {"figure": None, "ax": None, "axes": None, "ncols": 5, "figsize": None, "figtitle": None},
"sortingview": {"generate_url": True, "display": True, "figlabel": None, "height": None},
"ipywidgets": {"width_cm": 25, "height_cm": 10, "display": True},
"ephyviewer": {},
}


Expand Down
2 changes: 1 addition & 1 deletion src/spikeinterface/widgets/tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def setUpClass(cls):
else:
cls.we_sparse = cls.we.save(folder=cache_folder / "mearec_test_sparse", sparsity=cls.sparsity_radius)

cls.skip_backends = ["ipywidgets"]
cls.skip_backends = ["ipywidgets", "ephyviewer"]

if ON_GITHUB and not KACHERY_CLOUD_SET:
cls.skip_backends.append("sortingview")
Expand Down
24 changes: 24 additions & 0 deletions src/spikeinterface/widgets/traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,30 @@ def plot_sortingview(self, data_plot, **backend_kwargs):

self.url = handle_display_and_url(self, self.view, **backend_kwargs)

def plot_ephyviewer(self, data_plot, **backend_kwargs):
import ephyviewer
from ..preprocessing import depth_order

dp = to_attr(data_plot)

app = ephyviewer.mkQApp()
win = ephyviewer.MainViewer(debug=False, show_auto_scale=True)

for k, rec in dp.recordings.items():
if dp.order_channel_by_depth:
rec = depth_order(rec, flip=True)

sig_source = ephyviewer.SpikeInterfaceRecordingSource(recording=rec)
view = ephyviewer.TraceViewer(source=sig_source, name=k)
view.params["scale_mode"] = "by_channel"
if dp.show_channel_ids:
view.params["display_labels"] = True
view.auto_scale()
win.add_view(view)

win.show()
app.exec()


def _get_trace_list(recordings, channel_ids, time_range, segment_index, order=None, return_scaled=False):
# function also used in ipywidgets plotter
Expand Down

0 comments on commit 419e3cd

Please sign in to comment.