EtienneCmb / visbrain

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

[Sleep] Facilitate scoring of long recordings #64

Open TomBugnon opened 4 years ago

TomBugnon commented 4 years ago

Hi @raphaelvallat @EtienneCmb ,

When scoring long recordings (24h in this example), the "current time" indicator is extremely thin

Screen Shot 2020-02-26 at 1 23 09 PM

and sometimes even disappears image

It is now very impractical and error prone to use Sleep with long recordings, because it's hard to navigate to specific parts of data or to see what periods have been scored already or not (all the more since the default hypnogram value for unscored periods is "wake" rather than "artifact" or left unspecified).

In the Sleepscore software, there's a way to display the hypnogram for only, say 1h segments of data at a time.

What would you think about updating Sleep with the following: 1- set a minimum size of the "current time" marker so that it doesn't become too small for long recording 2- Add another kind of "Zoom" mode that would let the user display in the hypnogram and spectrogram only the 1h period surrounding the current time. 3- Format the displayed Cursor time (and possibly the Go-To?) in hh:mm:ss format rather than seconds 4- (Possibly in a separate update): Set the default hypnogram value to 'artifact' rather than wake to avoid including unscored periods in further analysis. User can set it back to wake manually easily in the Scoring panel

Cheers, Tom

TomBugnon commented 4 years ago

By the way, another quite serious limitation I think is that ...

Sleep is actually quite SLOW to change from one epoch to the next for long recording.. This is very limiting, is there anything we can do about that besides reducing the sampling rate?

Example code for a 24h dummy dataset :

import numpy as np
from visbrain.gui import Sleep

nchan = 10
sf = 100
tEnd = 24 * 60 * 60 #24h
nsamples = tEnd * sf

data = np.random.rand(nchan, nsamples)

Sleep(
    data=data,
    sf=sf,
).show()
raphaelvallat commented 4 years ago

Thanks @TomBugnon! We've only worked with human sleep data so far, which are rarely longer than 12 hours, and thus I've never experienced any of these two issues (marker and speed). On the latter, I think @EtienneCmb will know better since he's the VisPy expert. Have you installed pyopengl_accelerate?

On the former, I'd prefer not overloading the main interface, but if you think this would make the user experience better, than please feel free to submit a PR. I wonder if we should consider creating two branches, i..e human vs animal? Though it may become a bit hard to synchronize everything with the master branch.

EtienneCmb commented 4 years ago

Hello @TomBugnon and @raphaelvallat ,

There's several reasons why it's slow :

EtienneCmb commented 4 years ago

About your four points, 2 and 3 are for me the most important ones. An other thing we could add is in the time axis, a simple line made of 0 and 1 reflecting epochs that have been edited (1) or not (0: default). May be this would avoid changing the default hypnogram value (4 -)

skjerns commented 4 years ago

@EtienneCmb is there anything that can be done about increasing/optimising the speed of displaying the next epoch?

Even with normal length sleep recordings I sometimes find it a bit slow (compared to commercial software, which is almost instantaneous). This is especially a problem if there are clear longer phases that I can quickly skim over. I don't know where the bottle neck is, but it seems to be dependent on the data size. If you point me to where the loading is done I can have a look (I already tried to find it, but was a bit lost in the code). Maybe some pre-loading can be done before the next epoch is requested.

Additionally I'd add a +1 to not set Wake as default for not-scored. This makes it quite hard in the end to know what has been scored and what not.

EtienneCmb commented 4 years ago

commercial software, which is almost instantaneous

Is it Python softwares?

TomBugnon commented 4 years ago

Thanks for the quick response @raphaelvallat @EtienneCmb.

About creating two branches, I guess it depends how much you guys want to be bothered with extending the software, how much "cluttering" of the default GUI is acceptable, and how much the "animal" and "human" versions of Sleep would differ. The two main things required for animal scoring are the shorter scoring window in https://github.com/EtienneCmb/visbrain/pull/53 which clutter a bit but not too much the human data scoring I think, and the flexible definition of stages suggested here https://github.com/EtienneCmb/visbrain/issues/35 which doesn't affect the GUI cluttering and is also useful for Human scoring (eg epileptic patients). We starting to use Sleep for animal scoring already so there's the incentive to put some work in on our side anyway, but your decision what to make of it :) (I think we can a single version suited for all uses)

In the case of the updates we're discussing here, I think they would make sense for both human and animal scoring (even though they're not indispensable for humans):

raphaelvallat commented 4 years ago

These are all great ideas @TomBugnon @EtienneCmb. But I guess we would also need to export the "edited" binary time series to some sort of a text file so that users can keep track of multiple scoring sessions. An alternative would be to create a new integer value (e.g. -2) to the hypnogram to represent "unscored" data. This new value would be the default for not-scored data.

skjerns commented 4 years ago

commercial software, which is almost instantaneous

Is it Python softwares?

Most likely not (Alice Sleepware, REMLogic, Domino, etc)

still, might it be possible somehow to speed it up?

EtienneCmb commented 4 years ago

@raphaelvallat @TomBugnon if you both think that adding an "unscored" label to the hyprogram, I'm in too. However, from what I remember, this is going to require many modifications in the code because the states we used with Raph are really deeply integrated inside Sleep and I'm not sure the code is smart enough to just support adding a step. But if @TomBugnon thinks he can do it, and dig in, all good for me !

@skjerns when coding Sleep with Raph we had to choose between two GUI strategies :

I think if you want to compare the performance of Sleep, you've to do it with a programming language that have performances that are relatively comparable (clearly not C/C++).

One thing to speed up navigation is to hide the visual indicators. Those are really slowing down. For sure, this is one point that can be improved.

TomBugnon commented 4 years ago

If we decide that adding an "unscored" label is a better option than the binary "edited" indicator, then it might be worth delaying this update until Sleep supports flexible state definition via config files. (I'm hoping to see this change happen or make it happen at some point). I think the 'unscored' label is a better option regarding speed, GUI simplicity, and interpretation of the exported hypnogram. Moreover the "edited or not" information provided by the binary indicator will be visible straight from the hypnogram.

I'll try and get the 1h-zoom done first. What do you guys think about the hh:mm:ss formatting?

Regarding speed, the visual indicators do make a serious difference indeed

grahamfindlay commented 4 years ago

Re. the speed of moving from one epoch to the next, it is hard to overstate how important this is. I have been trying to encourage the adoption of Sleep in my laboratory for several (6+) months now. I went and installed it on several people's computers, showed them how to use it, etc. Everyone looked at it and said, "Wow, this is great, I'd love to switch." And yet everyone went back to their original software (SleepSign, mostly), and the primary reason was always speed. It is a deal-breaker.

I agree that it is usually unfair to compare the performance of Python to C/C++, but at the same time, I use a Phy (a Python tool based on VisPy) to jump around massive datasets with hundreds of channels all the time, so I feel like it should be possible to get performance to a level that is good enough. Of course, I am completely ignorant of Sleep's internal architecture, and I appreciate that it would probably be a massive undertaking to make the necessary changes. But I just wanted to say that performance really did hinder adoption, at least here in Wisconsin.