Extract (spike_sort.core.extract)

This module is a collection of functions for pre-processing of raw recordings (filtering and upsampling), detecting spikes and extracting spikes based on detected spike times.

align_spikes(spike_data, spt_dict, sp_win[, …]) Aligns spike waves and returns corrected spike times
detect_spikes(spike_data[, thresh, edge, …]) Detects spikes in extracellular data using amplitude thresholding.
extract_spikes(spike_data, spt_dict, sp_win) Extract spikes from recording.
filter_proxy
merge_spikes(spike_waves1, spike_waves2) Merges two sets of spike waves
merge_spiketimes(spt1, spt2[, sort]) Merges two sets of spike times
remove_spikes(spt_dict, remove_dict, tolerance) Remove spikes with given spike times from the spike time
resample_spikes(spikes_dict, FS_new) Upsample spike waveforms using spline interpolation
split_cells(spikes, idx[, which]) Return the spike features splitted into separate cells

Reference

spike_sort.core.extract.align_spikes(spike_data, spt_dict, sp_win, type='max', resample=1, contact=0, remove=True)

Aligns spike waves and returns corrected spike times

Parameters:

spike_data : dict

spt_dict : dict

sp_win : list of int

type : {‘max’, ‘min’}, optional

resample : int, optional

contact : int, optional

remove : bool, optiona

Returns:

ret_dict : dict

spike times of aligned spikes

spike_sort.core.extract.detect_spikes(spike_data, thresh='auto', edge='rising', contact=0)

Detects spikes in extracellular data using amplitude thresholding.

Parameters:

spike_data : dict

extracellular waveforms

thresh : float or ‘auto’

threshold for detection. if thresh is ‘auto’ it will be estimated from the data.

edge : {‘rising’, ‘falling’}

which edge to trigger on

contact : int, optional

index of tetrode contact to use for detection, defaults to first contact

Returns:

spt_dict : dict

dictionary with ‘data’ key which contains detected threshold crossing in miliseconds

spike_sort.core.extract.extract_spikes(spike_data, spt_dict, sp_win, resample=1, contacts='all')

Extract spikes from recording.

Parameters:

spike_data : dict

extracellular data (see raw_recording)

spt : dict

spike times structure (see Spike times)

sp_win : list of int

temporal extent of the wave shape

Returns:

wavedict : dict

spike waveforms structure (see Spike waveforms)

spike_sort.core.extract.filter_spt(spike_data, spt_dict, sp_win)
spike_sort.core.extract.merge_spikes(spike_waves1, spike_waves2)

Merges two sets of spike waves

Parameters:

spike_waves1 : dict

spike_waves2 : dict

spike wavefroms to merge; both spike wave sets must be defined within the same time window and with the same sampling frequency

Returns:

spike_waves : dict

merged spike waveshapes

clust_idx : array

labels denoting to which set the given spike originally belonged to

spike_sort.core.extract.merge_spiketimes(spt1, spt2, sort=True)

Merges two sets of spike times

Parameters:

spt1 : dict

spt2 : dict

sort : bool, optional

False if you don’t want to be the spike times sorted.

Returns:

spt : dict

dictionary with merged spike time arrrays under data key

clust_idx : array

labels denoting to which set the given spike originally belonged to

spike_sort.core.extract.remove_doubles(spt_dict, tol)
spike_sort.core.extract.remove_spikes(spt_dict, remove_dict, tolerance)

Remove spikes with given spike times from the spike time structure

spike_sort.core.extract.resample_spikes(spikes_dict, FS_new)

Upsample spike waveforms using spline interpolation

spike_sort.core.extract.split_cells(spikes, idx, which='all')

Return the spike features splitted into separate cells