How to use the neurokit2.signal.signal_filter function in neurokit2

To help you get started, we’ve selected a few neurokit2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neuropsychology / NeuroKit / neurokit2 / eda / eda_clean.py View on Github external
def _eda_clean_neurokit(eda_signal, sampling_rate=1000):

    # Filtering
    filtered = signal_filter(eda_signal, sampling_rate=sampling_rate, highcut=3, method="butterworth", order=4)

    return filtered
github neuropsychology / NeuroKit / neurokit2 / ecg / ecg_clean.py View on Github external
def _ecg_clean_nk(ecg_signal, sampling_rate=1000):

    # Remove slow drift and dc offset with highpass Butterworth.
    clean = signal_filter(signal=ecg_signal, sampling_rate=sampling_rate, lowcut=0.5, method="butterworth", order=5)

    clean = signal_filter(signal=clean, sampling_rate=sampling_rate, method="powerline", powerline=50)
    return clean
github neuropsychology / NeuroKit / neurokit2 / ppg / ppg_clean.py View on Github external
def _ppg_clean_elgendi(ppg_signal, sampling_rate):

    filtered = signal_filter(
        ppg_signal, sampling_rate=sampling_rate, lowcut=0.5, highcut=8, order=3, method="butter_ba"
    )
    return filtered
github neuropsychology / NeuroKit / neurokit2 / rsp / rsp_clean.py View on Github external
"""
    The algorithm is based on (but not an exact implementation of) the "Zero-crossing algorithm with amplitude
    threshold" by `Khodadad et al. (2018)

    `_.

    """
    # Slow baseline drifts / fluctuations must be removed from the raw
    # breathing signal (i.e., the signal must be centered around zero) in order
    # to be able to reliable detect zero-crossings.

    # Remove baseline by applying a lowcut at .05Hz (preserves breathing rates
    # higher than 3 breath per minute) and high frequency noise by applying a
    # highcut at 3 Hz (preserves breathing rates slower than 180 breath per
    # minute).
    clean = signal_filter(
        rsp_signal, sampling_rate=sampling_rate, lowcut=0.05, highcut=3, order=2, method="butterworth_ba"
    )

    return clean
github neuropsychology / NeuroKit / neurokit2 / eeg / eeg_gfp.py View on Github external
def _eeg_gfp_smoothing(gfp, sampling_rate=None, window_size=0.02):
    """Smooth the Global Field Power Curve
    """
    if sampling_rate is None:
        raise ValueError("NeuroKit error: eeg_gfp(): You requested to smooth the GFP, for which ",
                         "we need to know the sampling_rate. Please provide it as an argument.")
    window = int(window_size * sampling_rate)
    if window > 2:
        gfp = signal_filter(gfp, method="savgol", order=2, window_size=window)

    return gfp
github neuropsychology / NeuroKit / neurokit2 / eog / eog_clean.py View on Github external
def _eog_clean_agarwal2019(eog_signal, sampling_rate=1000):
    """Agarwal, M., & Sivakumar, R.

    (2019). Blink: A Fully Automated Unsupervised Algorithm for Eye-Blink Detection in EEG Signals. In 2019 57th
    Annual Allerton Conference on Communication, Control, and Computing (Allerton) (pp. 1113-1121). IEEE.

    """
    return signal_filter(
        eog_signal, sampling_rate=sampling_rate, method="butterworth", order=4, lowcut=None, highcut=10
    )
github neuropsychology / NeuroKit / neurokit2 / rsp / rsp_rate.py View on Github external
sin_wave = np.sin(2 * np.pi * frequency * t)
            # Calculate cross-correlation
            _xcorr = np.corrcoef(norm_diff, sin_wave)[0, 1]
            xcorr.append(_xcorr)

        # Find frequency with the highest xcorr with diff
        max_frequency_idx = np.argmax(xcorr)
        max_frequency = np.arange(5/60, 30.25/60, 0.25/60)[max_frequency_idx]
        # Append max_frequency to rsp_rate - instanteneous rate
        rsp_rate.append(max_frequency)

    x = np.arange(len(rsp_rate))
    y = rsp_rate
    rsp_rate = signal_interpolate(x, y, x_new=len(rsp_cleaned), method=interpolation_method)
    # Smoothing
    rsp_rate = signal_filter(rsp_rate, highcut=0.1, order=4, sampling_rate=sampling_rate)

    # Convert to Brpm
    rsp_rate = np.multiply(rsp_rate, 60)

    return np.array(rsp_rate)