NeuralEnsemble / elephant

Elephant is the Electrophysiology Analysis Toolkit
http://www.python-elephant.org
BSD 3-Clause "New" or "Revised" License
201 stars 92 forks source link

[Doc] Spike Extraction parameters #415

Open myagmur01 opened 3 years ago

myagmur01 commented 3 years ago

Hi @mdenker

I am using elephant.spike_train_generation.spike_extraction function for my MEA 96-channel signal. I have following questions:

  1. Why default values are selected as [-2ms, 4ms]

  2. What is exactly the time_interval here? When I set it to [-10 ms,10 ms] or [0 ms, 10 ms] or [5 ms,15 ms] I get the same results of spike times as below. Could you explain me if I am doing something wrong?

spikes for [-10 ms,10 ms] =  [0.4288     5.9382     6.91823333 6.91963333 6.9386     7.71603333
 7.73576667 8.18213333 8.29553333 8.3024     8.30493333 8.31963333] s 

spikes for [0 ms, 10 ms] = [0.4288     5.9382     6.91823333 6.91963333 6.9386     7.71603333
 7.73576667 8.18213333 8.29553333 8.3024     8.30493333 8.31963333] s 

spikes for [5 ms,15 ms] = [0.4288     5.9382     6.91823333 6.91963333 6.9386     7.71603333
 7.73576667 8.18213333 8.29553333 8.3024     8.30493333 8.31963333] s 

Thank you

mdenker commented 3 years ago

Hi @mytrjp ,

both questions relate to the spike waveforms which are extracted from the signal, i,e., the cutout of the signal around each spike.

The time_interval specifies the cut-out interval around each spike. -2 and 4 is of course somewhat arbitrary, however, many spike sorting tools choose values in this range: the spike is about 1-2 ms in length, and then you take a bit before the spike peak, and a bit more after the spike peak (to catch the dynamics after the spike).

If you set the time_stamps to None, peaks are extracted using numpy's peak finder. Therefore, the spike times will always be the same. However, the waveforms stored in the spike train (in spikes.waveforms, an NxM matrix for the N spikes, each row containing a waveform) should be different: In the first example, they should range from -10ms to 10ms, in the last example they should be from 5 to 15 ms. Thus, as an example, if the sampling frequency is 10KHz, and 123 spikes where detected, then spikes.waveforms should be size 123x200 for the first example.

I hope this helps. Thanks for asking this, I will keep this issue open as a reminder to augment the documentation to better explain this.