Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.2.7 #901

Merged
merged 37 commits into from
Nov 6, 2023
Merged

0.2.7 #901

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
00f73cc
adjust delay
DominiqueMakowski Aug 29, 2023
1570a10
change coarsegraining
DominiqueMakowski Aug 30, 2023
a12ce58
entropy_sample: return phi in info dict
DominiqueMakowski Aug 31, 2023
820d0d9
return more info in entropy_sample
DominiqueMakowski Aug 31, 2023
487407d
Update utils_complexity_coarsegraining.py
DominiqueMakowski Sep 4, 2023
5768e51
0.2.7
DominiqueMakowski Sep 12, 2023
c5e95d3
Merge branch 'dev' into fix_entropymultiscale
DominiqueMakowski Sep 13, 2023
6fbef91
rename .utils to .utils_entropy
DominiqueMakowski Sep 15, 2023
aea7de4
complexity_decorrelation(): add 'show' argument
DominiqueMakowski Sep 16, 2023
731405c
linting
DominiqueMakowski Sep 16, 2023
41b923a
move entropy_approximate internals and add entropy_quadratic
DominiqueMakowski Sep 16, 2023
ec67af6
add to docs
DominiqueMakowski Sep 16, 2023
19d5487
Update entropy_svd.py
DominiqueMakowski Sep 16, 2023
f4b63f0
add makowski method LLE
DominiqueMakowski Sep 21, 2023
9af817e
Update complexity_lyapunov.py
DominiqueMakowski Sep 21, 2023
067f1cc
fix scikit-learn #910
DominiqueMakowski Sep 21, 2023
a7382fd
Update entropy_quadratic.py
DominiqueMakowski Sep 21, 2023
e424839
Merge pull request #892 from neuropsychology/fix_entropymultiscale
DominiqueMakowski Sep 22, 2023
763e419
Merge branch 'dev' into lyapunov
DominiqueMakowski Sep 22, 2023
97ef675
fix test
DominiqueMakowski Sep 22, 2023
9dffa6f
minor docs
DominiqueMakowski Sep 27, 2023
215f2fa
Update eda_plot.py
mperreir Oct 2, 2023
b05a700
Update eda_intervalrelated.py
mperreir Oct 2, 2023
379d219
Merge pull request #916 from mperreir/fix_plot_eda
DominiqueMakowski Oct 2, 2023
44959c6
Merge pull request #906 from neuropsychology/lyapunov
DominiqueMakowski Oct 2, 2023
beea596
Merge branch 'dev' into pr/917
DominiqueMakowski Oct 2, 2023
5a1d2ad
Update eda_intervalrelated.py
mperreir Oct 3, 2023
6d611c9
Merge branch 'fix_eda_intervalrelated' of https://github.com/mperreir…
mperreir Oct 3, 2023
984194a
minor renaming
DominiqueMakowski Oct 3, 2023
484dd7f
Merge pull request #917 from mperreir/fix_eda_intervalrelated
DominiqueMakowski Oct 9, 2023
d7120b4
comment off intervals_process example
DominiqueMakowski Oct 9, 2023
4cd82c6
add new detector
DominiqueMakowski Oct 24, 2023
b4a57f2
Update read_xdf.py
DominiqueMakowski Oct 24, 2023
323929f
Merge pull request #920 from neuropsychology/ecg_peak_manikandan
DominiqueMakowski Oct 25, 2023
7ab0277
fixed sklearn sanity checks for valid_metrics
stamate Nov 2, 2023
76a1efa
Merge branch 'dev' into pr/925
DominiqueMakowski Nov 2, 2023
c1e38e1
Merge pull request #925 from stamate/bugfix-sklearn_version_valid_met…
DominiqueMakowski Nov 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions docs/functions/complexity.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ Fractal Dimension
Entropy
^^^^^^^^^^^^^^^^^
*entropy_shannon()*
"""""""""""""""""""
"""""""""""""""""""""
.. autofunction:: neurokit2.complexity.entropy_shannon

*entropy_maximum()*
"""""""""""""""""""
"""""""""""""""""""""
.. autofunction:: neurokit2.complexity.entropy_maximum

*entropy_differential()*
Expand All @@ -103,6 +103,18 @@ Entropy
"""""""""""""""""""
.. autofunction:: neurokit2.complexity.entropy_renyi

*entropy_approximate()*
""""""""""""""""""""""""
.. autofunction:: neurokit2.complexity.entropy_approximate

*entropy_sample()*
""""""""""""""""""""
.. autofunction:: neurokit2.complexity.entropy_sample

*entropy_quadratic()*
""""""""""""""""""""""
.. autofunction:: neurokit2.complexity.entropy_quadratic

*entropy_cumulativeresidual()*
"""""""""""""""""""""""""""""""""
.. autofunction:: neurokit2.complexity.entropy_cumulativeresidual
Expand Down Expand Up @@ -155,14 +167,6 @@ Entropy
"""""""""""""""""""""""
.. autofunction:: neurokit2.complexity.entropy_ofentropy

*entropy_approximate()*
""""""""""""""""""""""""
.. autofunction:: neurokit2.complexity.entropy_approximate

*entropy_sample()*
""""""""""""""""""""
.. autofunction:: neurokit2.complexity.entropy_sample

*entropy_permutation()*
""""""""""""""""""""""""
.. autofunction:: neurokit2.complexity.entropy_permutation
Expand Down Expand Up @@ -274,4 +278,4 @@ Joint/Multivariate

.. .. automodule:: neurokit2.complexity
.. :members:
.. :exclude-members: complexity, complexity_delay, complexity_dimension, complexity_tolerance, complexity_k, fractal_katz, fractal_petrosian, fractal_sevcik, fractal_nld, fractal_psdslope, fractal_higuchi, fractal_correlation, entropy_shannon, entropy_maximum, entropy_differential, entropy_tsallis, entropy_renyi, entropy_cumulativeresidual, entropy_svd, entropy_spectral, entropy_phase, entropy_grid, entropy_attention, entropy_increment, entropy_slope, entropy_symbolicdynamic, entropy_dispersion, entropy_ofentropy, entropy_approximate, entropy_sample, entropy_permutation, entropy_bubble, entropy_range, entropy_fuzzy, entropy_multiscale, entropy_hierarchical, fisher_information, complexity_hjorth, complexity_lempelziv, complexity_relativeroughness, fractal_hurst, complexity_lyapunov, complexity_rqa, fractal_mandelbrot, complexity_simulate, complexity_attractor, complexity_symbolize, complexity_coarsegraining, complexity_ordinalpatterns, recurrence_matrix, entropy_shannon_joint, entropy_rate
.. :exclude-members: complexity, complexity_delay, complexity_dimension, complexity_tolerance, complexity_k, fractal_katz, fractal_petrosian, fractal_sevcik, fractal_nld, fractal_psdslope, fractal_higuchi, fractal_correlation, entropy_shannon, entropy_maximum, entropy_differential, entropy_tsallis, entropy_renyi, entropy_cumulativeresidual, entropy_svd, entropy_spectral, entropy_phase, entropy_grid, entropy_attention, entropy_increment, entropy_slope, entropy_symbolicdynamic, entropy_dispersion, entropy_ofentropy, entropy_approximate, entropy_sample, entropy_permutation, entropy_bubble, entropy_range, entropy_fuzzy, entropy_multiscale, entropy_hierarchical, fisher_information, complexity_hjorth, complexity_lempelziv, complexity_relativeroughness, fractal_hurst, complexity_lyapunov, complexity_rqa, fractal_mandelbrot, complexity_simulate, complexity_attractor, complexity_symbolize, complexity_coarsegraining, complexity_ordinalpatterns, recurrence_matrix, entropy_shannon_joint, entropy_rate, entropy_quadratic
2 changes: 1 addition & 1 deletion neurokit2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from .video import *

# Info
__version__ = "0.2.6"
__version__ = "0.2.7"


# Maintainer info
Expand Down
6 changes: 5 additions & 1 deletion neurokit2/complexity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from .entropy_permutation import entropy_permutation
from .entropy_phase import entropy_phase
from .entropy_power import entropy_power
from .entropy_quadratic import entropy_quadratic
from .entropy_range import entropy_range
from .entropy_rate import entropy_rate
from .entropy_renyi import entropy_renyi
Expand Down Expand Up @@ -96,7 +97,9 @@
complexity_rcmse = functools.partial(entropy_multiscale, method="RCMSEn")
complexity_fuzzymse = functools.partial(entropy_multiscale, fuzzy=True)
complexity_fuzzycmse = functools.partial(entropy_multiscale, method="CMSEn", fuzzy=True)
complexity_fuzzyrcmse = functools.partial(entropy_multiscale, method="RCMSEn", fuzzy=True)
complexity_fuzzyrcmse = functools.partial(
entropy_multiscale, method="RCMSEn", fuzzy=True
)


complexity_dfa = fractal_dfa
Expand Down Expand Up @@ -175,6 +178,7 @@
"entropy_symbolicdynamic",
"entropy_cumulativeresidual",
"entropy_approximate",
"entropy_quadratic",
"entropy_bubble",
"entropy_coalition",
"entropy_sample",
Expand Down
33 changes: 28 additions & 5 deletions neurokit2/complexity/complexity_decorrelation.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

from ..signal import signal_autocor


def complexity_decorrelation(signal):
def complexity_decorrelation(signal, show=False):
"""**Decorrelation Time (DT)**

The decorrelation time (DT) is defined as the time (in samples) of the first zero crossing of
Expand All @@ -17,6 +18,8 @@ def complexity_decorrelation(signal):
----------
signal : Union[list, np.array, pd.Series]
The signal (i.e., a time series) in the form of a vector of values.
show : bool
If True, will return a plot of the autocorrelation.

Returns
-------
Expand All @@ -36,11 +39,15 @@ def complexity_decorrelation(signal):

import neurokit2 as nk

# Simulate a signal with duration os 2s
signal = nk.signal_simulate(duration=2, frequency=[5, 9, 12])
# Simulate a signal
signal = nk.signal_simulate(duration=5, sampling_rate=100, frequency=[5, 6], noise=0.5)

# Compute DT
dt, _ = nk.complexity_decorrelation(signal)
@savefig p_complexity_decorrelation1.png scale=100%
dt, _ = nk.complexity_decorrelation(signal, show=True)
@suppress
plt.close()

dt

References
Expand All @@ -60,12 +67,28 @@ def complexity_decorrelation(signal):
)

# Unbiased autocor (see https://github.com/mne-tools/mne-features/)
autocor, _ = signal_autocor(signal, method="unbiased")
autocor, _ = signal_autocor(signal, unbiased=True)

# Get zero-crossings
zc = np.diff(np.sign(autocor)) != 0
if np.any(zc):
dt = np.argmax(zc) + 1
else:
dt = -1

if show is True:
# Max length of autocorrelation to plot
max_len = int(dt * 4)
if max_len > len(autocor):
max_len = len(autocor)

plt.plot(autocor[0:max_len])
plt.xlabel("Lag")
plt.ylabel("Autocorrelation")
plt.xticks(np.arange(0, max_len, step=dt).astype(int))
plt.axvline(dt, color="red", linestyle="--", label=f"DT = {dt}")
plt.axhline(0, color="black", linestyle="--")
plt.title("Decorrelation Time (DT)")
plt.legend()

return dt, {}
Loading
Loading