Esempio n. 1
0
                y,
                fs,
                nperseg=2048,
            )
            envelope = np.abs(hilbert(fft_filter(y, fs, mu_band)))
            threshold = coef * x_f_median
            lengths, x_copy = compute_lengths(envelope > threshold,
                                              fs * max_gap,
                                              fs * min_sate_duration)
            heights = compute_heights(envelope, x_copy)
            dots[0, jj] = envelope.mean()
            dots[1, jj] = sum(x_copy) / (len(envelope)) * 100
            dots[2, jj] = len(lengths) / (len(envelope) / fs / 60)
            dots[3, jj] = lengths.mean() / fs
            dots[4, jj] = heights.mean()
            dots[5, jj] = find_lag(signal[key][:, 0], envelope, fs,
                                   show=False) / fs
            for k in range(6):
                axes[k].plot([jj + 1], dots[k, jj], 'o', c=cm(key))

        import seaborn as sns
        for k in range(6):
            sns.regplot(np.arange(1,
                                  len(keys) + 1),
                        dots[k],
                        ax=axes[k],
                        color=cm('Baseline'),
                        line_kws={'alpha': 0.4},
                        ci=None)
            sns.regplot(np.arange(1,
                                  len(keys) + 1),
                        dots[k],
Esempio n. 2
0
        keys = [key for key in raw.keys() if 'FB' in key or 'Baseline' in key]

        dots = np.zeros((6, len(keys)))
        for jj, key in enumerate(keys):
            y = np.dot(raw[key], spatial)
            f, Pxx = welch(y, fs, nperseg=2048, )
            envelope = np.abs(hilbert(fft_filter(y, fs, mu_band)))
            threshold = coef * x_f_median
            lengths, x_copy = compute_lengths(envelope > threshold, fs*max_gap, fs*min_sate_duration)
            heights = compute_heights(envelope, x_copy)
            dots[0, jj] = envelope.mean()
            dots[1, jj] = sum(x_copy) / (len(envelope)) * 100
            dots[2, jj] = len(lengths)/(len(envelope)/fs/60)
            dots[3, jj] = lengths.mean()/fs
            dots[4, jj] = heights.mean()
            dots[5, jj] = find_lag(signal[key][:,0], envelope, fs, show=False)/fs
            for k in range(6):
                axes[k].plot([jj + 1], dots[k, jj], 'o', c=cm(key))

        import seaborn as sns
        for k in range(6):
            sns.regplot(np.arange(1, len(keys)+1), dots[k], ax=axes[k], color=cm('Baseline'),
                        line_kws={'alpha':0.4}, ci=None)
            sns.regplot(np.arange(1, len(keys)+1), dots[k], ax=axes[k], color=cm('FB'),
                        line_kws={'alpha':0.4}, ci=None)
            sns.regplot(np.arange(2, 7), dots[k,1:6], ax=axes[k], color=cm('FB'),
                        line_kws={'alpha': 0.7}, ci=None, truncate=True)
            if len(keys) == 7:
                axes[k].plot([1, 7], dots[k,[0,6]], c=cm('Baseline'), alpha=0.7, linewidth=3)

        titles = ['Mean envelope', 'Time in % for all mu-states', 'Number of mu-states per minute', 'Mean mu-state length [s]',