def _find_max_corrs(all_maps, target, threshold):
    all_corrs = [compute_corr(target, subj.T) for subj in all_maps]
    abs_corrs = [np.abs(a) for a in all_corrs]
    corr_polarities = [np.sign(a) for a in all_corrs]

    if threshold <= 1:
        max_corrs = [list(np.nonzero(s_corr > threshold)[0])
                     for s_corr in abs_corrs]
    else:
        max_corrs = [list(find_outliers(s_corr, threshold=threshold))
                     for s_corr in abs_corrs]

    am = [l[i] for l, i_s in zip(abs_corrs, max_corrs)
          for i in i_s]
    median_corr_with_target = np.median(am) if len(am) > 0 else 0

    polarities = [l[i] for l, i_s in zip(corr_polarities, max_corrs)
                  for i in i_s]

    maxmaps = [l[i] for l, i_s in zip(all_maps, max_corrs)
               for i in i_s]

    if len(maxmaps) == 0:
        return [], 0, 0, []
    newtarget = np.zeros(maxmaps[0].size)
    std_of_maps = np.std(np.asarray(maxmaps))
    mean_of_maps = np.std(np.asarray(maxmaps))
    for maxmap, polarity in zip(maxmaps, polarities):
        newtarget += (maxmap / std_of_maps - mean_of_maps) * polarity

    newtarget /= len(maxmaps)
    newtarget *= std_of_maps

    sim_i_o = np.abs(np.corrcoef(target, newtarget)[1, 0])

    return newtarget, median_corr_with_target, sim_i_o, max_corrs
Attempt to find the peaks in a 1-D array.
dataset/ETHPy150Open mne-tools/mne-python/mne/preprocessing/ica.py/_find_max_corrs--crossover with--dataset/ETHPy150Open scipy/scipy/scipy/signal/_peak_finding.py/find_peaks_cwt