brainbox.spike_features
Functions that compute spike features from spike waveforms.
Functions
Gets n_ch channels around a unit's channel of max amplitude, extracts all unit spike waveforms from binary datafile for these channels, and for each spike, computes the dot products of waveform by unit template for those channels, and computes center-of-mass of these dot products to get spike depth estimates. |
- depth(ephys_file, spks_b, clstrs_b, chnls_b, tmplts_b, unit, n_ch=12, n_ch_probe=385, sr=30000, dtype='int16', car=False)[source]
Gets n_ch channels around a unit’s channel of max amplitude, extracts all unit spike waveforms from binary datafile for these channels, and for each spike, computes the dot products of waveform by unit template for those channels, and computes center-of-mass of these dot products to get spike depth estimates.
- Parameters:
ephys_file (string) – The file path to the binary ephys data.
spks_b (bunch) – A spikes bunch containing fields with spike information (e.g. cluster IDs, times, features, etc.) for all spikes.
clstrs_b (bunch) – A clusters bunch containing fields with cluster information (e.g. amp, ch of max amp, depth of ch of max amp, etc.) for all clusters.
chnls_b (bunch) – A channels bunch containing fields with channel information (e.g. coordinates, indices, etc.) for all probe channels.
tmplts_b (bunch) – A unit templates bunch containing fields with unit template information (e.g. template waveforms, etc.) for all unit templates.
unit (numeric) – The unit for which to return the spikes depths.
n_ch (int (optional)) – The number of channels to sample around the channel of max amplitude to compute the depths.
sr (int (optional)) – The sampling rate (hz) that the ephys data was acquired at.
n_ch_probe (int (optional)) – The number of channels of the recording.
dtype (str (optional)) – The datatype represented by the bytes in ephys_file.
car (bool (optional)) – A flag to perform common-average-referencing before extracting waveforms.
- Returns:
d – The estimated spike depths for all spikes in unit.
- Return type:
ndarray
See also
io.extract_waveforms
Examples
- Get the spike depths for unit 1.
>>> import numpy as np >>> import brainbox as bb >>> import alf.io as aio >>> import ibllib.ephys.spikes as e_spks (*Note, if there is no 'alf' directory, make 'alf' directory from 'ks2' output directory): >>> e_spks.ks2_to_alf(path_to_ks_out, path_to_alf_out) # Get the necessary alf objects from an alf directory. >>> spks_b = aio.load_object(path_to_alf_out, 'spikes') >>> clstrs_b = aio.load_object(path_to_alf_out, 'clusters') >>> chnls_b = aio.load_object(path_to_alf_out, 'channels') >>> tmplts_b = aio.load_object(path_to_alf_out, 'templates') # Compute spike depths. >>> unit1_depths = bb.spike_features.depth(path_to_ephys_file, spks_b, clstrs_b, chnls_b, tmplts_b, unit=1)