Handling probe information

In order to properly spike sort, you may need to load information related to the probe you are using.

SpikeInterface internally uses ProbeInterface to handle probe or probe groups for recordings.

Depending on the dataset, the Probe object can be already included or needs to be set manually.

Here’s how!

import numpy as np
import spikeinterface.extractors as se
Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/checkouts/0.98.0/examples/modules_gallery/core/plot_3_handle_probe_info.py", line 15, in <module>
    import spikeinterface.extractors as se
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/conda/0.98.0/lib/python3.9/site-packages/spikeinterface/extractors/__init__.py", line 1, in <module>
    from .extractorlist import *
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/conda/0.98.0/lib/python3.9/site-packages/spikeinterface/extractors/extractorlist.py", line 15, in <module>
    from .neoextractors import *
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/conda/0.98.0/lib/python3.9/site-packages/spikeinterface/extractors/neoextractors/__init__.py", line 1, in <module>
    from .alphaomega import AlphaOmegaRecordingExtractor, AlphaOmegaEventExtractor, read_alphaomega, read_alphaomega_event
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/conda/0.98.0/lib/python3.9/site-packages/spikeinterface/extractors/neoextractors/alphaomega.py", line 3, in <module>
    from .neobaseextractor import NeoBaseRecordingExtractor, NeoBaseEventExtractor
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/conda/0.98.0/lib/python3.9/site-packages/spikeinterface/extractors/neoextractors/neobaseextractor.py", line 332, in <module>
    class NeoBaseSortingExtractor(_NeoBaseExtractor, BaseSorting):
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/conda/0.98.0/lib/python3.9/site-packages/spikeinterface/extractors/neoextractors/neobaseextractor.py", line 480, in NeoBaseSortingExtractor
    def _infer_t_start_from_signal_stream(self, segment_index: int, stream_id: Optional[str] = None) -> float | None:
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

First, let’s create a toy example:

recording, sorting_true = se.toy_example(duration=10, num_channels=32, seed=0, num_segments=2)
print(recording)

This generator already contain a probe object that you can retrieve directly an plot:

probe = recording.get_probe()
print(probe)

from probeinterface.plotting import plot_probe

plot_probe(probe)

You can also overwrite the probe. In that case you need to manually make the wiring (e.g. virtually connect each electrode to the recording device). Let’s use a probe from Cambridge Neurotech with 32 channels:

from probeinterface import get_probe

other_probe = get_probe('cambridgeneurotech', 'ASSY-37-E-1')
print(other_probe)

other_probe.set_device_channel_indices(np.arange(32))
recording_2_shanks = recording.set_probe(other_probe, group_mode='by_shank')
plot_probe(recording_2_shanks.get_probe())

Now let’s check what we have loaded. The group_mode=’by_shank’ automatically set the ‘group’ property depending on the shank id. We can use this information to split the recording in two sub recordings:

print(recording_2_shanks)
print(recording_2_shanks.get_property('group'))

rec0, rec1 = recording_2_shanks.split_by(property='group')
print(rec0)
print(rec1)

Note that some formats (MEArec, SpikeGLX) automatically handle the probe geometry. For almost all other formats the probe and the wiring have to be set manually using the probeinterface library.

Total running time of the script: ( 0 minutes 0.002 seconds)

Gallery generated by Sphinx-Gallery