You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for these wonderful tools. I've been experimenting with your LFP pre-processing on my own data, and found a couple things that might be useful to you. Here is my understanding of your process:
Segment data into ~26s (2^16 samples) chunks with ~0.5s (~2^10 sample) overlap. Then, for each chunk...
1. 2-200Hz 3rd order butter bandpass, applied with filtfilt
2. "Destriping"
2.1 2 Hz 3rd order butter highpass, applied with filtfilt (redundant but harmless)
2.2 Dephasing (shift data in frequency domain to correct for 1/12 sample delay between ADCs)
2.3 Interpolation of bad channels (inside brain only)
2.4 CAR
2.4.1 "Automatic gain control".
2.4.2 (Spatial) median subtraction
3. Decimation (10x)
3.1 Uses FIR anti-aliasing filter w/ phase correction
4. Isolate the samples unique to this chunk and append to file as float32.
I applied the same chunked decimation, dephasing, and interpolation with good results. I opted not to use the butterworth filters. I noticed that dephasing took the majority of the time, so I wondered if the dephasing and decimation operations were commutative. It turns out that I can decimate (I do 4x, to ~625 Hz), and then apply the dephasing afterward by simply taking the original sample shifts and dividing them by the decimation factor (because shift is now 1/48th of a "virtual sample" after decimating). This decimated-first LFP agrees with the dephased-first LFP to within a picovolt. I looked at pairwise (channel pairs) gamma phase-lag across the whole probe, which clearly shows a correlation-structure before dephasing and is a good way to assess if the procedure was successful (also yes! the 1/12 sample delay can affect phase-lag correlations at <100Hz, I guess because of aliasing). The decimated-first LFP and dephased-first LFP have identical (i.e. clean, decorrelated) phase-lag profiles (also identical pairwse gamma coherence, etc). So, long story short, I think you can decimate before dephasing without any loss, and this cuts computation time by the decimation factor--a huge gain.
Also, I just wanted to say that this may not apply based on how your LFPs are originally referenced, and where you're recording from, but I have found that CAR on neuropixel LFPs is generally dangerous because, unlike with the AP band where it is safe to assume that the average reflects common mode noise, it is often the case that the LFP average/median reflects real signal. Especially when recording from both hippocampus and thalamus, where the former has LFPs that are an order of magnitude larger than the latter. The HC can easily dominate the average/median and distort the other LFPs quite a lot.
Thanks again! Really appreciate you making these tools public.
The text was updated successfully, but these errors were encountered:
Hello,
Those are two very good points, thanks for your feedback !
Yes decimation and shift are commutative. In my case I use the decimation on specific applications only as some may want to keep more signal (as you do).
It may be naive but I wonder what kind of time domain response the rephasing filters have. If the response is not too long and stable, maybe I should compute them and apply through time-domain convolution (filtfilt), that would speed this up greatly. It will still be faster after decimation.
In our case we are aiming towards Current Source Density estimation, which implicitly implies a common average rejection, so that doesn't have any impact on the remaining of the processing. But to stick with LFP this is indeed not a recommended way. Maybe I should make it explicit by not having the CAR by default ?
The most important and novel parts of the pre-processing is the rephasing for Neuropixel and the faulty channel removal and interpolation, I'm glad that you find those useful !
Thanks for these wonderful tools. I've been experimenting with your LFP pre-processing on my own data, and found a couple things that might be useful to you. Here is my understanding of your process:
I applied the same chunked decimation, dephasing, and interpolation with good results. I opted not to use the butterworth filters. I noticed that dephasing took the majority of the time, so I wondered if the dephasing and decimation operations were commutative. It turns out that I can decimate (I do 4x, to ~625 Hz), and then apply the dephasing afterward by simply taking the original sample shifts and dividing them by the decimation factor (because shift is now 1/48th of a "virtual sample" after decimating). This decimated-first LFP agrees with the dephased-first LFP to within a picovolt. I looked at pairwise (channel pairs) gamma phase-lag across the whole probe, which clearly shows a correlation-structure before dephasing and is a good way to assess if the procedure was successful (also yes! the 1/12 sample delay can affect phase-lag correlations at <100Hz, I guess because of aliasing). The decimated-first LFP and dephased-first LFP have identical (i.e. clean, decorrelated) phase-lag profiles (also identical pairwse gamma coherence, etc). So, long story short, I think you can decimate before dephasing without any loss, and this cuts computation time by the decimation factor--a huge gain.
Also, I just wanted to say that this may not apply based on how your LFPs are originally referenced, and where you're recording from, but I have found that CAR on neuropixel LFPs is generally dangerous because, unlike with the AP band where it is safe to assume that the average reflects common mode noise, it is often the case that the LFP average/median reflects real signal. Especially when recording from both hippocampus and thalamus, where the former has LFPs that are an order of magnitude larger than the latter. The HC can easily dominate the average/median and distort the other LFPs quite a lot.
Thanks again! Really appreciate you making these tools public.
The text was updated successfully, but these errors were encountered: