示例#1
0
        # band pass filter
        lfp_band = ut.band_pass_iir(y=lfp_pre,
                                    fs=fs,
                                    band=beta_bands[subject_idx])
        # remove potential ringing artifacts
        idx_167ms = int((fs / 1000) * 167)
        lfp_band = lfp_band[idx_167ms:-idx_167ms]
        lfp_band -= lfp_band.mean()

        lfp_pre = lfp_pre[idx_167ms:-idx_167ms]
        lfp_pre -= lfp_pre.mean()

        # For plotting figure 3
        if plot_figure3_poster:
            # find lfp band zeros
            zeros_rising, zeros_falling, zeros = ut.find_rising_and_falling_zeros(
                lfp_band)

            # find the peaks in between the zeros, USING THE RAW DATA!
            analysis_lfp = lfp_pre
            peaks, troughs, extrema, extrema_kind = ut.find_peaks_and_troughs_cole(
                analysis_lfp,
                zeros=zeros,
                rising_zeros=zeros_rising,
                falling_zeros=zeros_falling)
            rise_steepness, fall_steepness, steepness_indices, steepness_values = ut.calculate_rise_and_fall_steepness(
                analysis_lfp, extrema)

            plot_ratio_illustration_for_poster(fs,
                                               lfp_pre,
                                               lfp_band,
                                               zeros,
示例#2
0
        lfp_band = lfp_band[lfp_cutoff * fs:-lfp_cutoff * fs]
        lfp_band -= lfp_band.mean()
        lfp_pre = lfp_pre[lfp_cutoff * fs:-lfp_cutoff * fs]

        # look at the spectogram to select time periods of higher beta
        t, burst_mask = ut.select_time_periods_of_high_power(data=lfp_pre,
                                                             band=band)
        # burst_mask = np.logical_not(np.zeros_like(lfp_pre))
        # plt.plot(t, lfp_pre)
        # plt.fill_between(t, np.min(lfp_pre), np.max(lfp_pre), where=burst_mask, alpha=.4, color='red')
        # plt.show()

        # find rising and falling zero crossings using the filtered data

        # calculate zero crossings on band data
        zeros_rising, zeros_falling, zeros = ut.find_rising_and_falling_zeros(
            lfp_band[burst_mask])

        # find the peaks in between the zeros: use the RAW DATA for this step.
        analysis_lfp = lfp_pre[burst_mask]
        peaks, troughs, extrema = ut.find_peaks_and_troughs(
            analysis_lfp, zeros)

        # calculate peak sharpness:
        peak_sharpness = ut.calculate_peak_sharpness(analysis_lfp,
                                                     peaks,
                                                     fs=fs)
        trough_sharpness = ut.calculate_peak_sharpness(analysis_lfp,
                                                       troughs,
                                                       fs=fs)
        mean_peak_sharpness = np.mean(peak_sharpness)
        mean_trough_sharpness = np.mean(trough_sharpness)