lkorczowski / Tinnitus-n-Sleep

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

Refactoring fuse_with_classif_results #108

Open lkorczowski opened 3 years ago

lkorczowski commented 3 years ago

utils.fuse_with_classif_results has many flaws :

def fuse_with_classif_result(check_imp, labels):
    """Adds at the good indexes the missing elements of labels because of the use of check_RMS

    Parameters
    ----------
    check_imp : list of list , shape (nb_epochs, nb_electrodes)
         0s and 1s 0s marking bad channels for the designated epoch
    labels : ndarray, shape (n_trials - nb_bad_epochs,)
        array of the classification prediction results

    Returns
    -------
    mod_labels : ndarray, shape (n_trials,)
        Modified labels to fit a length of n_trials
    """
    if not isinstance(labels, list):
        labels = labels.tolist()
    for i in range(len(check_imp)):
        if np.mean(check_imp[i]) == 1:
            labels.insert(i, False)  # inserting False (neutral) values in the labels array where they were deleted
    return labels