lkorczowski / Tinnitus-n-Sleep

Detecting events in sleeping tinnitus patients
MIT License
1 stars 0 forks source link

Tricky case when merging valid_labels #65

Closed RobinGuillard closed 4 years ago

RobinGuillard commented 4 years ago

When dealing with valid_labels merges, here is one important pytesting I've done:

dealing with tricky case 1:

    v_lab = merge_preprocess_labels([[True, True], [True, True, False, True]], 2)
    npt.assert_equal(v_lab, [True, False])

dealing with tricky case 2:

    v_lab = merge_preprocess_labels([[True, True], [True, True, True, False]], 2)
    npt.assert_equal(v_lab, [True, False])`

Unhappily the algo returns [True, True] for first test and [True False] for second, so the first assert fails. There should be a "domination" of false over True that makes both cases go in the same direction.

Again, it's just a singular case as in practise we never go in the direction of downsampling.

lkorczowski commented 4 years ago

I don't know how you do your resampling

OPTION 1 using panda

https://stackoverflow.com/questions/24920516/downsize-series-containing-boolean-data-with-resample

with something like ds = ts.resample('0.25ms', how=np.any) if you want to say that any positive within 250ms

OPTION 2 using scipy

e.g. scipy.signal.resample_poly maybe overkill but it should we if the up or downsampling factor is a multiple of the number of epochs (but usually, it won't). Maybe worse a try.

OPTION 3: simple moving average (or reverse moving average)

lkorczowski commented 4 years ago

closed by #66