buzsakilab / buzcode

Code for internal lab sharing - polishing has started but is by no means complete
http://www.buzsakilab.com/
GNU General Public License v3.0
119 stars 128 forks source link

Question of PSS using on NREM (ClusterStates_GetMetrics.m) #422

Open lizijie-cmu opened 10 months ago

lizijie-cmu commented 10 months ago

Hello. I find in ClusterStates_GetMetrics.m section Calculate broadbandslowwave metric you using PSS at the frequency range of 4-90Hz as default for NREM slow wave detection. I have two questions: 1 Why you use this frequency range, have you mentioned this in any research paper? 2 Why you don't use the frequency range 0 - 4 Hz ? I think it's a usual detection frequency range for NREM.

Best Wishes!

dlevenstein commented 10 months ago

Hi there. Both questions should be answered in the series of papers that describe the current approach:

-Watson et al 2016 (https://www.cell.com/neuron/fulltext/S0896-6273(16)30056-3) -Levenstein et al 2019 (https://www.nature.com/articles/s41467-019-10327-5) -Levenstein et al 2021 (https://www.biorxiv.org/content/10.1101/2021.09.20.461152v3)

Briefly: -in Watson et al 2016 we found that the first PC of the log-frequency spectrogram predominantly corresponded to NREM vs WAKE (better than any individual frequency bands or single range). Note that the weights vary continuously from positive weight at low frequencies to negative weight at high frequencies, indicating that this component predominantly reflects the slope of the (log-log) power spectrum, AKA the 1/f exponent of the linear spectrum. -in Levenstein et al 2019 (methods) we replaced PC1 with a weighted sum of powers, using the average weights derived from the original dataset. This improved robustness of the algorithm to shorter recordings with less time in the homecage, and those with lots of broadband noise. -finally, in Levenstein et al 2021 (methods), we replaced the weighted sum with an explicit calculation of the power spectrum slope, which corresponded to findings of the relationship of the slope with sleep/wake state in human patients, and we found was significantly more robust on recordings from a range of different brain regions. The range for calculating the slope was chosen because it gave the best match of state designation between hippocampus and cortical recordings, and allowed calculating the slope in small (2s, sliding) windows.

All of these options are now able to be used with optional inputs to the SSM function, however in our hands the (default) PSS approach is by far the most reliable/robust.

Hope that helps! Dan

brendonw1 commented 10 months ago

Thanks to Dan for replying! I was also starting to reply

First off "broadbandslowave" is now badly named. Initially it was 1-20Hz or so to capture delta-spindle band, as you implied would make sense. But then Dan found that power spectral slope (PSS) is better than lowfrequency power alone. PSS is based on the idea that there is an inverse relationship between the power of a frequency band in brain recordings and the frequency of that band (often called 1/f slope). And essentially when you're awake your slope goes up, when you're asleep or drowsy, it becomes more negative. In addition to what Dan already mentioned, the Voytek lab at UCSD did some initial work on this. https://voyteklab.com/publications

So again, now we actually use the SLOPE from 1-90hz, not the power. So we capture, for example both an increase in delta, but also a decrease in gamma in one measure. This seems to work best.

Finally, please be sure to use the "dev" branch of this code.

@Dan Levenstein @.***> what do you think of just migrating dev to master at this point?

B

Brendon Watson, MD-PhD Assistant Professor in Psychiatry, Bioinformatics and Biomedical Engineering Biomedical Sciences Research Building, Room 5059 University of Michigan 109 Zina Pitcher Place Ann Arbor, MI 48109-5720 Lab Website: http://watsonneurolab.org Clinical phone: 734-764-0231

On Thu, Nov 16, 2023 at 12:13 PM Dan Levenstein @.***> wrote:

Hi there. Both questions should be answered in the series of papers that describe the current approach:

-Watson et al 2016 ( https://www.cell.com/neuron/fulltext/S0896-6273(16)30056-3) -Levenstein et al 2019 (https://www.nature.com/articles/s41467-019-10327-5 ) -Levenstein et al 2021 ( https://www.biorxiv.org/content/10.1101/2021.09.20.461152v3)

Briefly: -in Watson et al 2016 we found that the first PC of the log-frequency spectrogram predominantly corresponded to NREM vs WAKE (better than any individual frequency bands or single range). Note that the weights vary continuously from positive weight at low frequencies to negative weight at high frequencies, indicating that this component predominantly reflects the slope of the (log-log) power spectrum, AKA the 1/f exponent of the linear spectrum. -in Levenstein et al 2019 (methods) we replaced PC1 with a weighted sum of powers, using the average weights derived from the original dataset. This improved robustness of the algorithm to shorter recordings with less time in the homecage, and those with lots of broadband noise. -finally, in Levenstein et al 2021 (methods), we replaced the weighted sum with an explicit calculation of the power spectrum slope, which corresponded to findings of the relationship of the slope with sleep/wake state in human patients, and we found was significantly more robust on recordings from a range of different brain regions. The range for calculating the slope was chosen because it gave the best match of state designation between hippocampus and cortical recordings, and allowed calculating the slope in small (2s, sliding) windows.

All of these options are now able to be used with optional inputs to the SSM function, however in our hands the (default) PSS approach is by far the most reliable/robust.

Hope that helps! Dan

— Reply to this email directly, view it on GitHub https://github.com/buzsakilab/buzcode/issues/422#issuecomment-1814880969, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA26WTLZ2MMJ6Z6HIYG5TPLYEZCSNAVCNFSM6AAAAAA7OERDPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJUHA4DAOJWHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

dlevenstein commented 10 months ago

TBH I'm not using buzcode anymore. Have completely switched over to python/pynapple 😅. So I wouldn't be the best one to ask re: dev->master.

We don't yet have a python implementation of SleepScoreMaster et al, but it's in the works. The lab here basically only uses Matlab to sleep score, but I think they have a local version which I don't think they're keeping up to date with the GitHub repo.

brendonw1 commented 10 months ago

I'm gonna just migrate dev to master Nobody uses Master

Brendon Watson, MD-PhD Assistant Professor in Psychiatry, Bioinformatics and Biomedical Engineering Biomedical Sciences Research Building, Room 5059 University of Michigan 109 Zina Pitcher Place Ann Arbor, MI 48109-5720 Lab Website: http://watsonneurolab.org Clinical phone: 734-764-0231

On Thu, Nov 16, 2023 at 12:41 PM Dan Levenstein @.***> wrote:

TBH I'm not using buzcode anymore. Have completely switched over to python/pynapple 😅. So I wouldn't be the best one to ask re: dev->master.

We don't yet have a python implementation of SleepScoreMaster et al, but it's in the works. The lab here basically only uses Matlab to sleep score, but I think they have a local version which I don't think they're keeping up to date with the GitHub repo.

— Reply to this email directly, view it on GitHub https://github.com/buzsakilab/buzcode/issues/422#issuecomment-1814929463, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA26WTM423XSKTXX2XQQPE3YEZF4RAVCNFSM6AAAAAA7OERDPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJUHEZDSNBWGM . You are receiving this because you commented.Message ID: @.***>

lizijie-cmu commented 10 months ago

@brendonw1 @dlevenstein I'm glad both experts could respond to me. This is my first time participating in discussions on GitHub, and I have understood the part about PSS. I also have a small question about the freqeuncy of SLOPE. You said that you actually use the SLOPE from 1-90hz, while in Dldev branch line 114 and 115, the code is here [specslope,spec] = bz_PowerSpectrumSlope(lfp,window,window-noverlap,'frange',[4 90],'IRASA',IRASA); broadbandSlowWave = -specslope.data; %So NREM is higher as opposed to lower It means you use frequency range 4 - 90 Hz, or I misunderstand it or I choose the wrong branch?
Link: https://github.com/dlevenstein/buzcode/blob/DLdev/detectors/detectStates/SleepScoreMaster/ClusterStates_GetMetrics.m

Tank you very much and best Wishes!

brendonw1 commented 10 months ago

Slope for 4-90Hz Not power of that range

Brendon Watson, MD-PhD Assistant Professor in Psychiatry, Bioinformatics and Biomedical Engineering Biomedical Sciences Research Building, Room 5059 University of Michigan 109 Zina Pitcher Place Ann Arbor, MI 48109-5720 Lab Website: http://watsonneurolab.org Clinical phone: 734-764-0231

On Sun, Nov 19, 2023 at 10:20 PM lizijie-cmu @.***> wrote:

Reopened #422 https://github.com/buzsakilab/buzcode/issues/422.

— Reply to this email directly, view it on GitHub https://github.com/buzsakilab/buzcode/issues/422#event-11005815476, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA26WTN3AUON42IV4M66YZ3YFLEAXAVCNFSM6AAAAAA7OERDPGVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJRGAYDKOBRGU2DONQ . You are receiving this because you were mentioned.Message ID: @.***>