EtienneCmb / visbrain

A multi-purpose GPU-accelerated open-source suite for brain data visualization
http://visbrain.org
Other
241 stars 65 forks source link

Spectrogram updates #8

Closed neergaard closed 6 years ago

neergaard commented 6 years ago

I would suggest the possibility of doing spectrograms for the segment length that is chosen - if the user is viewing a 30 s epoch, then the corresponding spectrogram should also be made available.

Furthermore, there is an issue with the spectogram changing when the view is changing to the next epoch. The spectrogram cannot be reapplied without changing eg. the Method:

screen shot 2017-10-03 at 17 57 12 screen shot 2017-10-03 at 17 57 26
raphaelvallat commented 6 years ago

Thanks again for your suggestion Alexander. It is possible to display the spectrogram & hypnogram only by epoch of selected time window (default 30 sec) just by activating the zoom mode (Z key) as you did in the second screenshot. In that case, for a better definition and if your dataset is not too large, I would recommend changing the spectrogram parameters to 10 seconds with an overlap of 0.9. Please note that you then have to deactivate and reactivate the zoom mode to see the changes.

e.g. https://user-images.githubusercontent.com/25703792/31161911-98672a8c-a8da-11e7-97b7-d300cd61df48.png

I believe that this answer should also apply to your second point, although I am not fully sure to understand it. Please let me know if you have any questions. Thanks. Raphaël.

neergaard commented 6 years ago

Thank you, that bit about the zoom mode helped my understanding of how the visualizer works to be better.

Playing around with the settings, I found that if I am viewing, say 5 seconds of data at a time, and I would like a spectrogram for those 5 seconds of data with 2 s windows with 90% overlap, then I get a warning stating: "Error drawing visual <Image name=spectrogram at 0x154a855cc88>" .

I assume this is because the spectrogram is pre-calculated for performance reasons and then zoomed on for the selected time window, which would crash when generating a whole-night spectrogram with that small windows. However, it limits the functionality of the spectrogram a bit.

raphaelvallat commented 6 years ago

Thank you for your feedback! Another issue to take into consideration that might be related to yours is that the length of the spectrogram NFFT should at least be two times higher than the minimum frequency of the spectrogram. For instance, let's say you want to plot a spectrogram from 0.5 to 20 Hz (default behavior), the length of the NFFT should be at least 1/0.5Hz = 2 sec * 2 = 4 sec. In fact, we recommend that the window of the spectrogram be at minimum set to 10 seconds (and you could still play with the overlap setting if you want a higher resolution). Hope this helps!

neergaard commented 6 years ago

Hmm... That doesn't make sense to me. If I use a window length of time T, then the minimum frequency resolution becomes 1/T, no? Unless you're using some other form of time-frequency method instead of STFT?