repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
NeuroKit | NeuroKit-master/neurokit2/complexity/entropy_maximum.py | import numpy as np
def entropy_maximum(signal):
"""**Maximum Entropy (MaxEn)**
Provides an upper bound for the entropy of a random variable, so that the empirical entropy
(obtained for instance with :func:`entropy_shannon`) will lie in between 0 and max. entropy.
It can be useful to normalize the em... | 1,037 | 23.714286 | 96 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/fractal_density.py | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scipy.stats
from .entropy_shannon import entropy_shannon
from .optim_complexity_tolerance import complexity_tolerance
from .utils_complexity_embedding import complexity_embedding
def fractal_density(signal, delay=1, tolerance="sd", bins=No... | 5,842 | 34.628049 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/information_fishershannon.py | import numpy as np
import scipy.integrate
from .entropy_power import entropy_power
def fishershannon_information(signal, **kwargs):
"""**Fisher-Shannon Information (FSI)**
The :func:`Shannon Entropy Power <entropy_power>` is closely related to another index, the
Fisher Information Measure (FIM). Their c... | 2,282 | 27.898734 | 98 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/entropy_spectral.py | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from ..signal.signal_psd import signal_psd
from .entropy_shannon import entropy_shannon
def entropy_spectral(signal, bins=None, show=False, **kwargs):
"""**Spectral Entropy (SpEn)**
Spectral entropy (SE or SpEn) treats the signal's norma... | 3,458 | 29.078261 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/complexity_rqa.py | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from ..misc import find_groups
from .entropy_shannon import entropy_shannon
from .optim_complexity_tolerance import complexity_tolerance
from .utils_recurrence_matrix import recurrence_matrix
def complexity_rqa(
signal, dimension=3, delay=1, ... | 12,320 | 37.503125 | 106 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/entropy_approximate.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from .optim_complexity_tolerance import _entropy_apen, complexity_tolerance
from .utils import _get_count
def entropy_approximate(signal, delay=1, dimension=2, tolerance="sd", corrected=False, **kwargs):
"""**Approximate entropy (ApEn) and its correc... | 5,130 | 33.904762 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/utils_complexity_attractor.py | import matplotlib.pyplot as plt
import numpy as np
import scipy
def complexity_attractor(
embedded="lorenz", alpha="time", color="last_dim", shadows=True, linewidth=1, **kwargs
):
"""**Attractor Graph**
Create an attractor graph from an :func:`embedded <complexity_embedding>` time series.
Parameters... | 10,479 | 30.95122 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/entropy_coalition.py | import numpy as np
import pandas as pd
import scipy.signal
from ..signal.signal_binarize import _signal_binarize_threshold
from ..signal.signal_detrend import signal_detrend
from .entropy_shannon import entropy_shannon
def entropy_coalition(signal, method="amplitude"):
"""**Amplitude Coalition Entropy (ACE) and ... | 6,380 | 34.45 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/information_fisher.py | import numpy as np
import pandas as pd
from .utils_complexity_embedding import complexity_embedding
def fisher_information(signal, delay=1, dimension=2):
"""**Fisher Information (FI)**
The Fisher information was introduced by R. A. Fisher in 1925, as a measure of "intrinsic
accuracy" in statistical esti... | 2,660 | 39.318182 | 112 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/fractal_hurst.py | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scipy.special
from .fractal_dfa import _fractal_dfa_findscales
def fractal_hurst(signal, scale="default", corrected=True, show=False):
"""**Hurst Exponent (H)**
This function estimates the Hurst exponent via the standard rescaled ... | 8,916 | 35.247967 | 124 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/fractal_petrosian.py | import numpy as np
import pandas as pd
from .utils_complexity_symbolize import complexity_symbolize
def fractal_petrosian(signal, symbolize="C", show=False):
"""**Petrosian fractal dimension (PFD)**
Petrosian (1995) proposed a fast method to estimate the fractal dimension by converting the
signal into a... | 3,975 | 38.366337 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/utils_complexity_embedding.py | # -*- coding: utf-8 -*-
from warnings import warn
import numpy as np
from ..misc import NeuroKitWarning
from ..signal import signal_sanitize
from .utils_complexity_attractor import (_attractor_equation,
complexity_attractor)
def complexity_embedding(signal, delay=1, dimensio... | 6,158 | 38.229299 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/entropy_rate.py | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from ..misc import find_knee
from .entropy_shannon import entropy_shannon
from .utils_complexity_embedding import complexity_embedding
from .utils_complexity_symbolize import complexity_symbolize
def entropy_rate(signal, kmax=10, symbolize="mean"... | 6,145 | 32.043011 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/utils_fractal_mandelbrot.py | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
def fractal_mandelbrot(
size=1000,
real_range=(-2, 2),
imaginary_range=(-2, 2),
threshold=4,
iterations=25,
buddha=False,
show=False,
):
"""**Mandelbrot (or a Buddhabrot) Fractal**
Vectorized function to ef... | 8,324 | 28.416961 | 101 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/entropy_symbolicdynamic.py | import numpy as np
import pandas as pd
from .utils_complexity_embedding import complexity_embedding
from .utils_complexity_symbolize import complexity_symbolize
def entropy_symbolicdynamic(signal, dimension=3, symbolize="MEP", c=6, **kwargs):
"""**Symbolic Dynamic Entropy (SyDyEn) and its Multiscale variants (MS... | 5,300 | 37.413043 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/complexity_lyapunov.py | # -*- coding: utf-8 -*-
from warnings import warn
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import sklearn.metrics.pairwise
from ..misc import NeuroKitWarning
from ..signal.signal_psd import signal_psd
from .utils_complexity_embedding import complexity_embedding
def complexity_lyapunov(... | 13,377 | 39.786585 | 106 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/entropy_multiscale.py | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from ..misc import copyfunction
from .complexity_lempelziv import complexity_lempelziv
from .entropy_approximate import entropy_approximate
from .entropy_cosinesimilarity import entropy_cosinesimilarity
from .entropy_increme... | 16,848 | 37.822581 | 103 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/entropy_permutation.py | import numpy as np
import pandas as pd
from .entropy_shannon import entropy_shannon
from .utils_complexity_ordinalpatterns import complexity_ordinalpatterns
def entropy_permutation(
signal, delay=1, dimension=3, corrected=True, weighted=False, conditional=False, **kwargs
):
"""**Permutation Entropy (PEn), it... | 7,257 | 37.606383 | 105 | py |
NeuroKit | NeuroKit-master/neurokit2/complexity/entropy_tsallis.py | import numpy as np
from .entropy_shannon import _entropy_freq
def entropy_tsallis(signal=None, q=1, symbolize=None, show=False, freq=None, **kwargs):
"""**Tsallis entropy (TSEn)**
Tsallis Entropy is an extension of :func:`Shannon entropy <entropy_shannon>` to the case where
entropy is nonextensive. It i... | 2,443 | 29.936709 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/bio/bio_process.py | # -*- coding: utf-8 -*-
import pandas as pd
from ..ecg import ecg_process
from ..eda import eda_process
from ..emg import emg_process
from ..eog import eog_process
from ..hrv import hrv_rsa
from ..misc import as_vector
from ..ppg import ppg_process
from ..rsp import rsp_process
def bio_process(
ecg=None, rsp=Non... | 7,646 | 33.60181 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/bio/bio_analyze.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from ..ecg import ecg_analyze
from ..eda import eda_analyze
from ..emg import emg_analyze
from ..eog import eog_analyze
from ..hrv import hrv_rsa
from ..ppg import ppg_analyze
from ..rsp import rsp_analyze
def bio_analyze(data, sampling_rate=1000, method... | 11,712 | 37.029221 | 114 | py |
NeuroKit | NeuroKit-master/neurokit2/bio/__init__.py | """Submodule for NeuroKit."""
from .bio_analyze import bio_analyze
from .bio_process import bio_process
__all__ = ["bio_process", "bio_analyze"]
| 148 | 17.625 | 40 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_simulate.py | # -*- coding: utf-8 -*-
import numpy as np
from ..misc import check_random_state, check_random_state_children
from ..signal import signal_distort, signal_merge
def eda_simulate(
duration=10,
length=None,
sampling_rate=1000,
noise=0.01,
scr_number=1,
drift=-0.01,
random_state=None,
ran... | 6,198 | 30.467005 | 112 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_fixpeaks.py | # -*- coding: utf-8 -*-
from ..signal.signal_formatpeaks import _signal_formatpeaks_sanitize
def eda_fixpeaks(peaks, onsets=None, height=None):
"""**Correct Skin Conductance Responses (SCR) peaks**
Low-level function used by ``"eda_peaks()"`` to correct the peaks found by
``"eda_findpeaks()"``. Doesn'... | 3,002 | 35.621951 | 111 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_analyze.py | # -*- coding: utf-8 -*-
import pandas as pd
from .eda_eventrelated import eda_eventrelated
from .eda_intervalrelated import eda_intervalrelated
def eda_analyze(data, sampling_rate=1000, method="auto"):
"""**EDA Analysis**
Perform EDA analysis on either epochs (event-related analysis) or on longer periods of... | 4,310 | 33.488 | 108 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_process.py | # -*- coding: utf-8 -*-
import pandas as pd
from ..misc.report import create_report
from ..signal import signal_sanitize
from .eda_clean import eda_clean
from .eda_peaks import eda_peaks
from .eda_phasic import eda_phasic
from .eda_methods import eda_methods
from .eda_plot import eda_plot
def eda_process(eda_signal,... | 4,800 | 35.930769 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_changepoints.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from ..signal import signal_changepoints
def eda_changepoints(eda_cleaned, penalty=10000, show=False):
"""**Calculate Number of Change Points**
Calculate the number of change points using of the skin conductance signal in terms of mean
and v... | 2,404 | 28.691358 | 109 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_eventrelated.py | # -** coding: utf-8 -*-
from warnings import warn
import numpy as np
from ..epochs.eventrelated_utils import (_eventrelated_addinfo,
_eventrelated_sanitizeinput,
_eventrelated_sanitizeoutput)
from ..misc import NeuroKitWarning
def eda... | 6,444 | 33.100529 | 105 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_phasic.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import scipy.linalg
import scipy.signal
from ..signal import signal_filter, signal_resample, signal_smooth
def eda_phasic(eda_signal, sampling_rate=1000, method="highpass", **kwargs):
"""**Electrodermal Activity (EDA) Decomposition into Phasic and To... | 25,798 | 32.856955 | 115 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_autocor.py | # -*- coding: utf-8 -*-
import pandas as pd
from ..signal import signal_autocor
def eda_autocor(eda_cleaned, sampling_rate=1000, lag=4):
"""**EDA Autocorrelation**
Compute the autocorrelation measure of raw EDA signal i.e., the correlation between the time
series data and a specified time-lagged version... | 2,357 | 29.230769 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_methods.py | # -*- coding: utf-8 -*-
import numpy as np
from ..misc.report import get_kwargs
from .eda_clean import eda_clean
from .eda_peaks import eda_peaks
from .eda_phasic import eda_phasic
def eda_methods(
sampling_rate=1000,
method="default",
method_cleaning="default",
method_peaks="default",
method_phas... | 6,621 | 45.307692 | 117 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_clean.py | # -*- coding: utf-8 -*-
from warnings import warn
import numpy as np
import pandas as pd
import scipy.signal
from ..misc import NeuroKitWarning, as_vector
from ..signal import signal_filter, signal_smooth
def eda_clean(eda_signal, sampling_rate=1000, method="neurokit"):
"""**Preprocess Electrodermal Activity (E... | 4,638 | 30.993103 | 106 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_peaks.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from ..misc import find_closest
from ..signal import signal_formatpeaks
from .eda_findpeaks import eda_findpeaks
from .eda_fixpeaks import eda_fixpeaks
def eda_peaks(eda_phasic, sampling_rate=1000, method="neurokit", amplitude_min=0.1):
"""**Find Sk... | 7,635 | 39.402116 | 125 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_findpeaks.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from ..signal import signal_filter, signal_findpeaks, signal_smooth, signal_zerocrossings
def eda_findpeaks(eda_phasic, sampling_rate=1000, method="neurokit", amplitude_min=0.1):
"""**Find Skin Conductance Responses (SCR) in Electrodermal Activity (... | 12,988 | 36.432277 | 114 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_intervalrelated.py | # -*- coding: utf-8 -*-
from warnings import warn
import numpy as np
import pandas as pd
from ..misc import NeuroKitWarning
from .eda_autocor import eda_autocor
from .eda_sympathetic import eda_sympathetic
def eda_intervalrelated(data, sampling_rate=1000, **kwargs):
"""**EDA Analysis on Interval-Related Data**
... | 5,246 | 33.071429 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/__init__.py | """Submodule for NeuroKit."""
from .eda_analyze import eda_analyze
from .eda_autocor import eda_autocor
from .eda_changepoints import eda_changepoints
from .eda_clean import eda_clean
from .eda_eventrelated import eda_eventrelated
from .eda_findpeaks import eda_findpeaks
from .eda_fixpeaks import eda_fixpeaks
from .ed... | 885 | 24.314286 | 52 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_sympathetic.py | # -*- coding: utf-8 -*-
from warnings import warn
import numpy as np
import pandas as pd
import scipy
from ..misc import NeuroKitWarning
from ..signal import signal_filter, signal_resample, signal_timefrequency
from ..signal.signal_power import _signal_power_instant_compute
from ..signal.signal_psd import _signal_psd... | 7,230 | 34.446078 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/eda/eda_plot.py | # -*- coding: utf-8 -*-
import matplotlib.collections
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
def eda_plot(eda_signals, sampling_rate=None, static=True):
"""**Visualize electrodermal activity (EDA) data**
Parameters
----------
eda_signals : DataFrame
DataFrame o... | 10,493 | 29.242075 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_delineate.py | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scipy.signal
from ..epochs import epochs_create, epochs_to_df
from ..signal import (
signal_findpeaks,
signal_formatpeaks,
signal_rate,
signal_resample,
signal_smooth,
signal_zerocrossings,
)
f... | 44,881 | 34.9056 | 127 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_simulate.py | # -*- coding: utf-8 -*-
import math
import numpy as np
import pandas as pd
import scipy
from ..misc import check_random_state, check_random_state_children
from ..signal import signal_distort, signal_resample
def ecg_simulate(
duration=10,
length=None,
sampling_rate=1000,
noise=0.01,
heart_rate=7... | 15,524 | 31.891949 | 119 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_eventrelated.py | # -*- coding: utf-8 -*-
from warnings import warn
from ..epochs.eventrelated_utils import (
_eventrelated_addinfo,
_eventrelated_rate,
_eventrelated_sanitizeinput,
_eventrelated_sanitizeoutput,
)
from ..misc import NeuroKitWarning
def ecg_eventrelated(epochs, silent=False):
"""**Event-related ana... | 5,943 | 34.171598 | 98 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_rsp.py | from ..signal import signal_filter
def ecg_rsp(ecg_rate, sampling_rate=1000, method="vangent2019"):
"""**ECG-Derived Respiration (EDR)**
Extract ECG-Derived Respiration (EDR), a proxy of a respiratory signal based on heart rate.
Different methods include:
* **vangent2019**: 0.1-0.4 Hz filter.
*... | 4,608 | 39.429825 | 153 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_findpeaks.py | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scipy.signal
import scipy.stats
from ..signal import (signal_findpeaks, signal_plot, signal_sanitize,
signal_smooth, signal_zerocrossings)
def ecg_findpeaks(ecg_cleaned, sampling_rate=1000, method="neurokit", show=Fal... | 40,059 | 31.998353 | 106 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_invert.py | import matplotlib.pyplot as plt
import numpy as np
from .ecg_clean import ecg_clean
def ecg_invert(ecg_signal, sampling_rate=1000, force=False, show=False):
"""**ECG signal inversion**
Checks whether an ECG signal is inverted, and if so, corrects for this inversion.
To automatically detect the inversion... | 3,388 | 35.44086 | 128 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_plot.py | # -*- coding: utf-8 -*-
import matplotlib.gridspec
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from ..ecg import ecg_peaks
from ..epochs import epochs_to_df
from ..signal import signal_fixpeaks
from ..stats import rescale
from .ecg_segment import ecg_segment
def ecg_plot(ecg_signals, rpeak... | 6,225 | 31.768421 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_segment.py | # - * - coding: utf-8 - * -
import matplotlib.pyplot as plt
import numpy as np
from ..epochs import epochs_create, epochs_to_df
from ..signal import signal_rate
from .ecg_peaks import ecg_peaks
def ecg_segment(ecg_cleaned, rpeaks=None, sampling_rate=1000, show=False):
"""**Segment an ECG signal into single heart... | 3,456 | 31.009259 | 103 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_phase.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from ..signal import signal_phase
from .ecg_delineate import ecg_delineate
from .ecg_peaks import ecg_peaks
def ecg_phase(ecg_cleaned, rpeaks=None, delineate_info=None, sampling_rate=None):
"""**Find the Cardiac Phase**
Compute cardiac phase (fo... | 4,697 | 36.584 | 112 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_process.py | # -*- coding: utf-8 -*-
import pandas as pd
from ..signal import signal_rate, signal_sanitize
from .ecg_clean import ecg_clean
from .ecg_delineate import ecg_delineate
from .ecg_peaks import ecg_peaks
from .ecg_phase import ecg_phase
from .ecg_quality import ecg_quality
def ecg_process(ecg_signal, sampling_rate=1000... | 4,986 | 40.907563 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_quality.py | # - * - coding: utf-8 - * -
from warnings import warn
import numpy as np
import scipy
from ..epochs import epochs_to_df
from ..misc import NeuroKitWarning
from ..signal import signal_interpolate
from ..signal.signal_power import signal_power
from ..stats import distance, rescale
from .ecg_peaks import ecg_peaks
from ... | 13,378 | 31.631707 | 105 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/__init__.py | """Submodule for NeuroKit."""
# Aliases
from ..signal import signal_rate as ecg_rate
from .ecg_analyze import ecg_analyze
from .ecg_clean import ecg_clean
from .ecg_delineate import ecg_delineate
from .ecg_eventrelated import ecg_eventrelated
from .ecg_findpeaks import ecg_findpeaks
from .ecg_intervalrelated import ec... | 969 | 23.871795 | 52 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_analyze.py | # -*- coding: utf-8 -*-
import pandas as pd
from .ecg_eventrelated import ecg_eventrelated
from .ecg_intervalrelated import ecg_intervalrelated
def ecg_analyze(data, sampling_rate=1000, method="auto"):
"""**Automated Analysis ECG**
Performs ECG analysis by computing relevant features and indices on either e... | 4,548 | 33.462121 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_intervalrelated.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from ..hrv import hrv
def ecg_intervalrelated(data, sampling_rate=1000):
"""**Interval-related analysis of ECG**
Performs ECG analysis on longer periods of data (typically > 10 seconds), such as resting-state
data.
Parameters
------... | 4,259 | 30.791045 | 105 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_peaks.py | from ..signal import signal_fixpeaks, signal_formatpeaks
from .ecg_findpeaks import ecg_findpeaks
def ecg_peaks(
ecg_cleaned, sampling_rate=1000, method="neurokit", correct_artifacts=False, **kwargs
):
"""**Find R-peaks in an ECG signal**
Find R-peaks in an ECG signal using the specified method. The meth... | 11,219 | 40.865672 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/ecg/ecg_clean.py | # -*- coding: utf-8 -*-
from warnings import warn
import numpy as np
import pandas as pd
import scipy.signal
from ..misc import NeuroKitWarning, as_vector
from ..signal import signal_filter
def ecg_clean(ecg_signal, sampling_rate=1000, method="neurokit", **kwargs):
"""**ECG Signal Cleaning**
Clean an ECG s... | 11,249 | 34.046729 | 114 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_fixpeaks.py | # -*- coding: utf-8 -*-
from ..signal.signal_formatpeaks import _signal_formatpeaks_sanitize
def rsp_fixpeaks(peaks, troughs=None):
"""**Correct RSP peaks**
Low-level function used by :func:`.rsp_peaks` to correct the peaks found
by :func:`.rsp_findpeaks`. Doesn't do anything for now for RSP.
See :f... | 2,410 | 32.957746 | 98 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_symmetry.py | # -*- coding: utf-8 -*-
from warnings import warn
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from ..misc import NeuroKitWarning, find_closest
from ..signal import signal_interpolate
from ..stats import rescale
from .rsp_fixpeaks import _rsp_fixpeaks_retrieve
def rsp_symmetry(
rsp_cle... | 6,702 | 36.238889 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_plot.py | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
def rsp_plot(rsp_signals, sampling_rate=None, figsize=(10, 10), static=True):
"""**Visualize respiration (RSP) data**
Parameters
----------
rsp_signals : DataFrame
DataFrame obtained from :func:`.rs... | 11,984 | 30.12987 | 88 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_rate.py | # -*- coding: utf-8 -*-
import numpy as np
from ..signal import (signal_filter, signal_interpolate, signal_rate,
signal_resample)
from .rsp_peaks import rsp_peaks
def rsp_rate(
rsp_cleaned,
troughs=None,
sampling_rate=1000,
window=10,
hop_size=1,
method="trough",
pea... | 5,651 | 36.430464 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_rvt.py | # -*- coding: utf-8 -*-
from warnings import warn
import matplotlib.pyplot as plt
import numpy as np
import scipy.signal
from ..misc import NeuroKitWarning
from ..signal import signal_interpolate
from ..stats import rescale
from .rsp_clean import rsp_clean
from .rsp_peaks import rsp_findpeaks
def rsp_rvt(
rsp_s... | 13,112 | 34.633152 | 120 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_amplitude.py | # -*- coding: utf-8 -*-
import numpy as np
from ..signal import signal_interpolate
from .rsp_fixpeaks import _rsp_fixpeaks_retrieve
def rsp_amplitude(
rsp_cleaned, peaks, troughs=None, method="standard", interpolation_method="monotone_cubic"
):
"""**Compute respiratory amplitude**
Compute respiratory a... | 4,516 | 39.330357 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_analyze.py | # -*- coding: utf-8 -*-
import pandas as pd
from .rsp_eventrelated import rsp_eventrelated
from .rsp_intervalrelated import rsp_intervalrelated
def rsp_analyze(data, sampling_rate=1000, method="auto"):
"""**RSP Analysis**
Performs RSP analysis on either epochs (event-related analysis) or on longer periods o... | 4,175 | 35.955752 | 124 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_simulate.py | # -*- coding: utf-8 -*-
import numpy as np
from ..misc import check_random_state, check_random_state_children
from ..signal import signal_distort, signal_simulate, signal_smooth
def rsp_simulate(
duration=10,
length=None,
sampling_rate=1000,
noise=0.01,
respiratory_rate=15,
method="breathmetr... | 14,964 | 37.87013 | 120 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_findpeaks.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import scipy.signal
def rsp_findpeaks(
rsp_cleaned,
sampling_rate=1000,
method="khodadad2018",
amplitude_min=0.3,
peak_distance=0.8,
peak_prominence=0.5,
):
"""**Extract extrema in a respiration (RSP) signal**
Low-level fu... | 8,895 | 35.760331 | 110 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_eventrelated.py | # -*- coding: utf-8 -*-
from warnings import warn
import numpy as np
from ..epochs.eventrelated_utils import (
_eventrelated_addinfo,
_eventrelated_rate,
_eventrelated_sanitizeinput,
_eventrelated_sanitizeoutput,
)
from ..misc import NeuroKitWarning, find_closest
def rsp_eventrelated(epochs, silent=... | 7,274 | 32.995327 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_phase.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from ..signal import signal_phase
from .rsp_fixpeaks import _rsp_fixpeaks_retrieve
def rsp_phase(peaks, troughs=None, desired_length=None):
"""**Compute respiratory phase (inspiration and expiration)**
Finds the respiratory phase, labelled as 1 ... | 2,746 | 35.626667 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_methods.py | # -*- coding: utf-8 -*-
import numpy as np
from ..misc.report import get_kwargs
from .rsp_clean import rsp_clean
from .rsp_peaks import rsp_peaks
from .rsp_rvt import rsp_rvt
def rsp_methods(
sampling_rate=1000,
method="khodadad",
method_cleaning="default",
method_peaks="default",
method_rvt="pow... | 8,824 | 41.427885 | 127 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/__init__.py | """Submodule for NeuroKit."""
# Aliases
# from ..signal import signal_rate as rsp_rate
from .rsp_amplitude import rsp_amplitude
from .rsp_analyze import rsp_analyze
from .rsp_clean import rsp_clean
from .rsp_eventrelated import rsp_eventrelated
from .rsp_findpeaks import rsp_findpeaks
from .rsp_fixpeaks import rsp_fix... | 1,055 | 24.142857 | 52 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_process.py | # -*- coding: utf-8 -*-
import pandas as pd
from ..misc import as_vector
from ..misc.report import create_report
from ..signal import signal_rate
from .rsp_amplitude import rsp_amplitude
from .rsp_clean import rsp_clean
from .rsp_methods import rsp_methods
from .rsp_peaks import rsp_peaks
from .rsp_phase import rsp_ph... | 5,438 | 34.090323 | 101 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_peaks.py | # -*- coding: utf-8 -*-
from ..signal import signal_formatpeaks
from .rsp_findpeaks import rsp_findpeaks
from .rsp_fixpeaks import rsp_fixpeaks
def rsp_peaks(rsp_cleaned, sampling_rate=1000, method="khodadad2018", **kwargs):
"""**Identify extrema in a respiration (RSP) signal**
This function runs :func:`.rs... | 3,310 | 38.416667 | 117 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_clean.py | # -*- coding: utf-8 -*-
from warnings import warn
import numpy as np
import pandas as pd
import scipy.signal
from ..misc import NeuroKitWarning, as_vector
from ..signal import signal_detrend, signal_filter
from ..stats import mad
def rsp_clean(rsp_signal, sampling_rate=1000, method="khodadad2018", **kwargs):
""... | 7,393 | 34.893204 | 113 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_intervalrelated.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from .rsp_rrv import rsp_rrv
def rsp_intervalrelated(data, sampling_rate=1000):
"""**Performs RSP analysis on longer periods of data (typically > 10 seconds), such as resting-state data**
Parameters
----------
data : DataFrame or dict
... | 5,657 | 34.810127 | 111 | py |
NeuroKit | NeuroKit-master/neurokit2/rsp/rsp_rrv.py | # -*- coding: utf-8 -*-
from warnings import warn
import matplotlib.patches
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from ..complexity import entropy_approximate, entropy_sample, fractal_dfa
from ..misc import NeuroKitWarning
from ..signal import signal_power, signal_rate
from ..signal.s... | 12,078 | 33.121469 | 109 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/progress_bar.py | import sys
def progress_bar(it, prefix="", size=40, verbose=True):
"""**Progress Bar**
Display a progress bar.
Parameters
----------
it : iterable
An iterable object.
prefix : str
A prefix to display before the progress bar.
size : int
The size of the progress bar... | 1,114 | 20.862745 | 74 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/parallel_run.py | def parallel_run(function, arguments_list, n_jobs=-2, **kwargs):
"""**Parallel processing utility function** (requires the ```joblib`` package)
Parameters
-----------
function : function
A callable function.
arguments_list : list
A list of dictionaries. The function will iterate thr... | 1,501 | 29.04 | 105 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/find_groups.py | import itertools
def find_groups(x):
"""**Find and group repeating (identical) values in a list**
Parameters
----------
x : list
The list to look in.
Returns
-------
list
A list of tuples corresponding to groups containing all the consecutive numbers.
Examples
--... | 537 | 16.933333 | 88 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/check_type.py | import numpy as np
import pandas as pd
def check_type(x, what="str"):
"""**Check type of input**
Creates a list of boolean values to check if the input is of the target type.
Parameters
----------
x : int, list, pd.DataFrame, pd.Series, np.ndarray
Target of checking
what : str
... | 1,198 | 22.057692 | 81 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/type_converters.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
def as_vector(x):
"""**Convert to vector**
Examples
--------
import neurokit2 as nk
x = nk.as_vector(x=range(3))
y = nk.as_vector(x=[0, 1, 2])
z = nk.as_vector(x=np.array([0, 1, 2]))
z
x = nk.as_vector(x=... | 1,159 | 23.680851 | 90 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/find_closest.py | import numpy as np
import pandas as pd
from .type_converters import as_vector
def find_closest(
closest_to, list_to_search_in, direction="both", strictly=False, return_index=False
):
"""**Find the closest number in the array from a given number x**
Parameters
----------
closest_to : float
... | 3,426 | 26.416 | 124 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/expspace.py | import numpy as np
def expspace(start, stop, num=50, out=int, base=1):
"""**Exponential range**
Creates a list of integer values (by default) of a given length from start to stop, spread by
an exponential function.
Parameters
----------
start : int
Minimum range values.
stop : in... | 1,270 | 24.938776 | 97 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/find_knee.py | import warnings
import matplotlib.pyplot as plt
import numpy as np
import scipy.interpolate
from ..stats import rescale
def find_knee(y, x=None, S=1, show=False, verbose=True):
"""**Find Knee / Elbow**
Find the knee / elbow in a curve using a basic adaptation of the *kneedle* algorithm.
Parameters
... | 2,830 | 28.185567 | 98 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/find_consecutive.py | import itertools
def find_consecutive(x):
"""**Find and group consecutive values in a list**
Parameters
----------
x : list
The list to look in.
Returns
-------
list
A list of tuples corresponding to groups containing all the consecutive numbers.
Examples
-------... | 568 | 17.966667 | 98 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/listify.py | # -*- coding: utf-8 -*-
def listify(**kwargs):
"""**Transforms arguments into lists of the same length**
Examples
--------
.. ipython:: python
import neurokit2 as nk
nk.listify(a=3, b=[3, 5], c=[3])
"""
args = kwargs
maxi = 1
# Find max length
for key, value in arg... | 854 | 19.853659 | 61 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/_warnings.py | # -*- coding: utf-8 -*-
# Note that this files starts with a '_' so that it's always on top of the order
# of loadings (preventing circular imports)
class NeuroKitWarning(RuntimeWarning):
"""Category for runtime warnings that occur within the NeuroKit library."""
| 271 | 29.222222 | 80 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/random.py | import copy
import numbers
import numpy as np
def check_random_state(seed=None):
"""**Turn seed into a random number generator**
Parameters
----------
seed : None, int, numpy.random.RandomState or numpy.random.Generator
Seed for the random number generator. If seed is None, a numpy.random.Ge... | 5,499 | 43.715447 | 115 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/report.py | # -*- coding: utf-8 -*-
import inspect
import matplotlib
import numpy as np
import pandas as pd
def create_report(file="myreport.html", signals=None, info={"sampling_rate": 1000}, fig=None):
"""**Reports**
Create report containing description and figures of processing.
This function is meant to be used ... | 7,440 | 34.433333 | 110 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/find_plateau.py | # -*- coding: utf-8 -*-
import matplotlib.gridspec as gs
import matplotlib.pyplot as plt
import numpy as np
import scipy.signal
from ..events.events_plot import events_plot
def find_plateau(values, show=True):
"""**Find the point of plateau in an array of values**
Parameters
----------
values : ndar... | 3,005 | 27.358491 | 90 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/__init__.py | """Submodule for NeuroKit.
isort:skip_file (since isort-ing the imports generates circular imports)
"""
from ._warnings import NeuroKitWarning
from .random import check_random_state, check_random_state_children, spawn_random_state
from .check_type import check_type
from .copyfunction import copyfunction
from .expspa... | 1,193 | 24.404255 | 87 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/find_outliers.py | import numpy as np
import scipy
from ..stats import standardize
def find_outliers(data, exclude=2, side="both", method="sd", **kwargs):
"""**Identify outliers (abnormal values)**
Extreme values identification using different methods, such as:
* **sd**: Data is :func:`standardized <.standardize>`, i.e.,... | 4,051 | 33.338983 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/replace.py | # -*- coding: utf-8 -*-
import numpy as np
def replace(data, replacement_dict):
"""**Replace values using a dictionary**
Parameters
----------
data : array
The data to replace values.
replacement_dict : dict
A replacement dictionary of the form ``{old_value: new_value}``.
Ret... | 932 | 20.204545 | 72 | py |
NeuroKit | NeuroKit-master/neurokit2/misc/copyfunction.py | import functools
def copyfunction(func, *args, **kwargs):
"""**Copy Function**
"""
partial_func = functools.partial(func, *args, **kwargs)
functools.update_wrapper(partial_func, func)
return partial_func
| 227 | 19.727273 | 59 | py |
NeuroKit | NeuroKit-master/neurokit2/hrv/hrv.py | # -*- coding: utf-8 -*-
import matplotlib.gridspec as gs
import matplotlib.pyplot as plt
import pandas as pd
from ..stats import summary_plot
from .hrv_frequency import _hrv_frequency_show, hrv_frequency
from .hrv_nonlinear import _hrv_nonlinear_show, hrv_nonlinear
from .hrv_rsa import hrv_rsa
from .hrv_time import hr... | 6,318 | 36.613095 | 139 | py |
NeuroKit | NeuroKit-master/neurokit2/hrv/hrv_frequency.py | # -*- coding: utf-8 -*-
from warnings import warn
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from ..misc import NeuroKitWarning
from ..signal.signal_power import _signal_power_instant_plot, signal_power
from ..signal.signal_psd import signal_psd
from .hrv_utils import _hrv_format_input
fro... | 10,410 | 33.819398 | 109 | py |
NeuroKit | NeuroKit-master/neurokit2/hrv/hrv_nonlinear.py | # -*- coding: utf-8 -*-
from warnings import warn
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scipy.stats
from ..complexity import (
complexity_lempelziv,
entropy_approximate,
entropy_fuzzy,
entropy_multiscale,
entropy_sample,
entropy_shannon... | 25,768 | 40.296474 | 118 | py |
NeuroKit | NeuroKit-master/neurokit2/hrv/intervals_to_peaks.py | import numpy as np
from .intervals_utils import _intervals_sanitize, _intervals_successive
def intervals_to_peaks(intervals, intervals_time=None, sampling_rate=1000):
"""**Convert intervals to peaks**
Convenience function to convert intervals to peaks, such as from R-R intervals to R-peaks of an
ECG sig... | 2,910 | 34.938272 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/hrv/hrv_rsa.py | # -*- coding: utf-8 -*-
from warnings import warn
import numpy as np
import pandas as pd
import scipy.linalg
from ..ecg.ecg_rsp import ecg_rsp
from ..misc import NeuroKitWarning
from ..rsp import rsp_process
from ..signal import (
signal_filter,
signal_interpolate,
signal_rate,
signal_resample,
si... | 23,322 | 38.13255 | 109 | py |
NeuroKit | NeuroKit-master/neurokit2/hrv/hrv_time.py | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scipy.stats
from ..stats import mad, summary_plot
from .hrv_utils import _hrv_format_input
from .intervals_utils import _intervals_successive
def hrv_time(peaks, sampling_rate=1000, show=False, **kwargs):
"""**C... | 13,478 | 44.846939 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/hrv/hrv_rqa.py | # -*- coding: utf-8 -*-
import numpy as np
import scipy.spatial
from ..complexity import complexity_rqa
from ..signal import signal_detrend
from .hrv_utils import _hrv_format_input
def hrv_rqa(
peaks,
sampling_rate=1000,
dimension=7,
delay=1,
tolerance="zimatore2021",
show=False,
**kwargs... | 3,397 | 30.174312 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/hrv/__init__.py | # -*- coding: utf-8 -*-
from .hrv import hrv
from .hrv_frequency import hrv_frequency
from .hrv_nonlinear import hrv_nonlinear
from .hrv_rqa import hrv_rqa
from .hrv_rsa import hrv_rsa
from .hrv_time import hrv_time
from .intervals_process import intervals_process
from .intervals_to_peaks import intervals_to_peaks
__a... | 481 | 21.952381 | 50 | py |
NeuroKit | NeuroKit-master/neurokit2/hrv/hrv_utils.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from .intervals_to_peaks import intervals_to_peaks
from .intervals_utils import _intervals_sanitize
def _hrv_get_rri(peaks=None, sampling_rate=1000):
if peaks is None:
return None, None, None
# Compute R-R intervals (also referred to as ... | 4,933 | 34.242857 | 112 | py |
NeuroKit | NeuroKit-master/neurokit2/hrv/intervals_process.py | # -*- coding: utf-8 -*-
from warnings import warn
import numpy as np
from ..misc import NeuroKitWarning
from ..signal import signal_detrend, signal_interpolate
from .intervals_utils import (
_intervals_sanitize,
_intervals_time_to_sampling_rate,
_intervals_time_uniform,
)
def intervals_process(
inte... | 5,060 | 37.340909 | 99 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.