Loading Spike Waveforms

Sample of spike waveforms extracted during spike sorting

Relevant Alf objects

  • _phy_spikes_subset

Loading

[2]:
from one.api import ONE
from brainbox.io.one import SpikeSortingLoader
from ibllib.atlas import AllenAtlas

one = ONE()
ba = AllenAtlas()
pid = 'da8dfec1-d265-44e8-84ce-6ae9c109b8bd'

# Load in the spikesorting
sl = SpikeSortingLoader(pid=pid, one=one, atlas=ba)
spikes, clusters, channels = sl.load_spike_sorting()
clusters = sl.merge_clusters(spikes, clusters, channels)

# Load the spike waveforms
spike_wfs = one.load_object(sl.eid, '_phy_spikes_subset', collection=sl.collection)
100%|██████████████████████████████████████████████████████████████████████████████████| 6/6.0 [00:03<00:00,  1.77it/s]

More details

Useful modules

  • COMING SOON

Exploring sample waveforms

Example 1: Finding the cluster ID for each sample waveform

[3]:
# Find the cluster id for each sample waveform
wf_clusterIDs = spikes['clusters'][spike_wfs['spikes']]

Example 2: Compute average waveform for cluster

[4]:
import numpy as np

# define cluster of interest
clustID = 2

# Find waveforms for this cluster
wf_idx = np.where(wf_clusterIDs == clustID)[0]
wfs = spike_wfs['waveforms'][wf_idx, :, :]

# Compute average waveform on channel with max signal (chn_index 0)
wf_avg_chn_max = np.mean(wfs[:, :, 0], axis=0)

Other relevant examples

  • COMING SOON