lkorczowski / Tinnitus-n-Sleep

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

Sometimes no possible estimation for power ratio estimation #89

Closed RobinGuillard closed 4 years ago

RobinGuillard commented 4 years ago

Here is the error I get while trying to run the bruxism inter subject script on 1DA15_nuit son:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~\Documents\acou_sommeil_HD_ENS\Tinnitus-n-Sleep\compute_results.py in <module>
    209                                                       time_interval=window_length_bruxism,
    210                                                       delim=delim, n_adaptive=n_adaptive_bruxism, log=log,
--> 211                                                       generate_report=generate_bruxism_report)
    212                     print(f"done)", end=" ")
    213                 else:

~\Documents\acou_sommeil_HD_ENS\Tinnitus-n-Sleep\tinnsleep\reports.py in reporting(epochs, valid_labels, THR_classif, time_interval, delim, n_adaptive, log, generate_report)
    258 
    259         report = generate_report(labels, time_interval, delim)
--> 260         report["Power Ratio"] = power_ratio(epochs[valid_labels], labels)
    261 
    262         labels = fuse_with_classif_result(np.invert(valid_labels),

~\Documents\acou_sommeil_HD_ENS\Tinnitus-n-Sleep\tinnsleep\signal.py in power_ratio(epochs, labels, axis)
     64     nb_epochs = len(labels)
     65     if (nb_num == 0) or (nb_num == nb_epochs):
---> 66         raise ValueError("labels should have at least one True and one False")
     67 
     68     pow = mean_power(epochs, axis=axis)

ValueError: labels should have at least one True and one False

This is not so surprising : we should expect that sometimes no events are spotted (although it is weird). It should work anyway. I'm going to put a condition for the calculus of the power ratio : return "nan" if there is always true or false.