open-ephys / GUI

Archived source code for the Open Ephys GUI
https://github.com/open-ephys/plugin-GUI
126 stars 282 forks source link

Spikesorting & waveform quantization errors #130

Closed shayo closed 10 years ago

shayo commented 10 years ago

Hi,

I noticed today that something is off. It was quite apparent that spike sorting (box mode) sorted spikes even when they fell completely outside the box. I managed to trace the problem down to incorrect way of reconstructing the uV signal from the uint16.

Usually, wave forms are encoded the following way: s->data[currentIndex] = uint16(value / channels[chan]->bitVolts + 32768); And then converted back to uV using the following equation: float value2 = (s->data[currentIndex]-32768) /float(s->gain[currentChannel])_1000.0f; where gain is defined: s->gain[currentChannel] = (int)(1.0f / channels[chan]->bitVolts)_1000;

However, due to quantization errors (gain is 16 bit uint), you don't get back the original value. This can lead to significant errors in the uV estimation.

I am going to modify the SpikeObject and get this fixed by converting the gain from uint16 to float.

shayo commented 10 years ago

Fixed in spike sorting branch. Notice version upgrade in file saving/reading mechanism.