Recommended offline filter and params for spike detection/clustering (phase is important)

318 views
Skip to first unread message

ap...@nu.edu.kz

unread,
May 17, 2018, 11:39:38 AM5/17/18
to Open Ephys
Hello,

I wanted to ask advice on what offline band pass filter should I use if phase is important for my further analysis (I plan to do spike -LFP phase locking). I am currently saving bandpass filtered data from Openephys but  wanted to switch to using raw data and doing offline filtering. I use Kilosort for spike detection/clustering. I noticed that waveforms look different after using band-pass filtered data from OpenEphys and  raw data filtered in Matlab (I tried butter, bandpass, order 2, 3, and 4). I am not sure which one is a better approach.

I can do filtering in both Python (during binary file generation) and Matlab (pre clustering), so recommendations of the filter implementation on both platforms are welcome.

Thanks, 

Jon Newman

unread,
May 17, 2018, 1:05:36 PM5/17/18
to ap...@nu.edu.kz, Open Ephys
Read this:


Michael Okun does the brave work of admitting his own mistakes in this analysis process and what to do about it. Basically, it comes down to being very careful that you are using filtering methods the do not have frequency-dependent phase effects or at least you account for those effects. Causal filtering in your acquisition system will also need to be accounted for offline -- many systems have analog implementations of e.g. Butterworth filters that have large frequency-dependent phase effects.

- Jon

--
You received this message because you are subscribed to the Google Groups "Open Ephys" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-ephys+unsubscribe@googlegroups.com.
To post to this group, send email to open-...@googlegroups.com.
Visit this group at https://groups.google.com/group/open-ephys.
To view this discussion on the web visit https://groups.google.com/d/msgid/open-ephys/556d22e3-71bc-4a08-9ff0-ddda5d3a3d8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jonathan Newman
Postdoctoral Fellow, MIT

ap...@nu.edu.kz

unread,
May 17, 2018, 4:51:29 PM5/17/18
to Open Ephys
Thanks for a quick reply. I read the paper and it provides great insight into the issue. We are recording with silicon probes, so phase distortion should not be as big. But I will probably try the correction script for OE recordings.


On Thursday, May 17, 2018 at 1:05:36 PM UTC-4, Jon Newman wrote:
Read this:


Michael Okun does the brave work of admitting his own mistakes in this analysis process and what to do about it. Basically, it comes down to being very careful that you are using filtering methods the do not have frequency-dependent phase effects or at least you account for those effects. Causal filtering in your acquisition system will also need to be accounted for offline -- many systems have analog implementations of e.g. Butterworth filters that have large frequency-dependent phase effects.

- Jon
On Thu, May 17, 2018 at 11:39 AM, <ap...@nu.edu.kz> wrote:
Hello,

I wanted to ask advice on what offline band pass filter should I use if phase is important for my further analysis (I plan to do spike -LFP phase locking). I am currently saving bandpass filtered data from Openephys but  wanted to switch to using raw data and doing offline filtering. I use Kilosort for spike detection/clustering. I noticed that waveforms look different after using band-pass filtered data from OpenEphys and  raw data filtered in Matlab (I tried butter, bandpass, order 2, 3, and 4). I am not sure which one is a better approach.

I can do filtering in both Python (during binary file generation) and Matlab (pre clustering), so recommendations of the filter implementation on both platforms are welcome.

Thanks, 

--
You received this message because you are subscribed to the Google Groups "Open Ephys" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-ephys+...@googlegroups.com.

Jon Newman

unread,
May 17, 2018, 8:07:44 PM5/17/18
to ap...@nu.edu.kz, Open Ephys
Although the analog characteristics of your probe do matter in this regard, I'm referring to standard amplification an filtering steps that occur both before and after digitization. Your probe has nothing to do with that.

To unsubscribe from this group and stop receiving emails from it, send an email to open-ephys+unsubscribe@googlegroups.com.

To post to this group, send email to open-...@googlegroups.com.
Visit this group at https://groups.google.com/group/open-ephys.

For more options, visit https://groups.google.com/d/optout.

Samuel Garcia

unread,
May 18, 2018, 4:15:14 AM5/18/18
to open-...@googlegroups.com
Hello,
for offline spike sorting to avoid phase distortion problem, a trick is to use the "filtfilt" function present both in python an matlab.
It basically do a forward and then a backward filter on the signal : this cancel the phase distortion what ever type of filter design you choose.
I don't known if kilosort do this "filtfilt".

If you want to try : tridesclous do the filtfilt both offline both also online (with a short latency due to the trick). So phase problem are avoided.
See Pre processing here for more details.
I also point out that in tridesclous, this filtfilt is implemented also in OpenCL so if you have long recordings with high channels counts, you can filtered signals in a very efficient way.


best

Samuel

ap...@nu.edu.kz

unread,
May 22, 2018, 1:05:12 PM5/22/18
to Open Ephys
Hello,

I think Kilosort uses "filter" (probbaly IIR) and does both forward and reverse filtering in pre processing step. I posted a question regarding "filtfilt" on github page. But I will definitely try it myself,

Thanks for suggestion,
Reply all
Reply to author
Forward
0 new messages