forrestbao / pyeeg Goto Github PK
View Code? Open in Web Editor NEWPython + EEG/MEG = PyEEG
License: GNU General Public License v3.0
Python + EEG/MEG = PyEEG
License: GNU General Public License v3.0
Seeing below issue. Has anybody seen this issue before with largest_lyauponov_exponent.py after running "$ python setup.py test" and would be able to share a solution if one was found? I haven't been able to figure it out..
largest_lyauponov_exponent.py:119: FutureWarning: rcond
parameter will change to the default of machine precision times max(M, N)
where M and N are the input matrix dimensions.
To use the future default and silence this warning we advise to pass rcond=None
, to keep using the old, explicitly pass rcond=-1
.
[m, c] = numpy.linalg.lstsq(X, mean_d)[0]
FAIL
test_permutation_entropy (tests.test_permutation_entropy.PermutationEntropyTests.test_permutation_entropy) ... ok
test_sampen_against_original_c_test_data (tests.test_sampen.SampEnTests.test_sampen_against_original_c_test_data)
Use test data from ... ok
test_sampen_against_predictable_sequence (tests.test_sampen.SampEnTests.test_sampen_against_predictable_sequence) ... ok
======================================================================
FAIL: test_largest_lyauponov_exponent (tests.test_largest_lyauponov_exponent.LLETests.test_largest_lyauponov_exponent)
\pyeeg\tests\test_largest_lyauponov_exponent.py", line 11, in test_largest_lyauponov_exponent
self.assertAlmostEqual(
AssertionError: nan != 0.18771136179353307 within 12 places (nan difference)
Ran 8 tests in 1.857s
FAILED (failures=1)
Test failed: <unittest.runner.TextTestResult run=8 errors=0 failures=1>
error: Test failed: <unittest.runner.TextTestResult run=8 errors=0 failures=1>
Maybe this is a question out of pyeeg's scope...
Approximate entropy is a new concept to me and I'm having several NaN values in my data.
audio_ap_entropy_7days activity_ap_entropy_7days
1 NaN NaN
2 -0.085044 -0.085044
4 -0.096893 -0.096893
5 -0.088628 -0.088628
7 -0.110994 -0.110994
8 NaN NaN
9 -0.086203 -0.086203
10 -0.085044 -0.085044
12 -0.085044 -0.085044
14 NaN NaN
15 NaN NaN
16 -0.088628 -0.088628
17 NaN NaN
18 NaN NaN
19 NaN NaN
22 NaN NaN
24 -0.169545 -0.169545
25 NaN NaN
27 -0.085044 -0.085044
30 NaN NaN
32 NaN NaN
33 NaN NaN
41 NaN NaN
43 NaN NaN
46 NaN NaN
49 -0.085044 -0.085044
52 NaN NaN
54 NaN NaN
57 -0.085044 -0.085044
59 -0.085044 -0.085044
Is this a normal behavior in approximate entropy, or do you think there's something wrong?
Luis
When I try to run the example code for Information Based Similarity it returns:
information_based_similarity(test1, test2, 8)
Traceback (most recent call last):
File "", line 1, in
information_based_similarity(test1, test2, 8)
File "/home/tfv21/anaconda3/lib/python3.6/site-packages/pyeeg/init.py", line 955, in information_based_similarity
Wm.append(embed_seq(SymbolicSeq[0], 1, n).tolist())
File "/home/tfv21/anaconda3/lib/python3.6/site-packages/pyeeg/init.py", line 161, in embed_seq
shape = (X.size - Tau * (D - 1), D)
AttributeError: 'list' object has no attribute 'size'
I tried changing X.size to len(X), but that threw the same error in the same function (list object has no attribute 'itemsize.'
Please advise.
Hi, I received the following error when testing after installation:
$python setup.py test
running test
running egg_info
writing pyeeg.egg-info/PKG-INFO
writing dependency_links to pyeeg.egg-info/dependency_links.txt
writing requirements to pyeeg.egg-info/requires.txt
writing top-level names to pyeeg.egg-info/top_level.txt
reading manifest file 'pyeeg.egg-info/SOURCES.txt'
writing manifest file 'pyeeg.egg-info/SOURCES.txt'
running build_ext
test_embedded_sequence_1_4 (tests.test_embedded_sequence.EmbeddedSequenceTests) ... ok
test_embedded_sequence_2_3 (tests.test_embedded_sequence.EmbeddedSequenceTests) ... ok
test_embedded_sequence_4_1 (tests.test_embedded_sequence.EmbeddedSequenceTests) ... ok
test_information_based_similarity (tests.test_information_based_similarity.InformationBasedSimilarityTests) ... ok
test_largest_lyauponov_exponent (tests.test_largest_lyauponov_exponent.LLETests) ... ERROR
test_permutation_entropy (tests.test_permutation_entropy.PermutationEntropyTests) ... ok
test_sampen_against_original_c_test_data (tests.test_sampen.SampEnTests)
Use test data from ... ok
test_sampen_against_predictable_sequence (tests.test_sampen.SampEnTests) ... ok
Traceback (most recent call last):
File "/Users/ross/Desktop/Documents/Research/contrasting_6_meditation_practices_EEG/pyeeg/tests/test_largest_lyauponov_exponent.py", line 12, in test_largest_lyauponov_exponent
LLE(data, 2, 4, 1, 1),
File "/Users/ross/Desktop/Documents/Research/contrasting_6_meditation_practices_EEG/pyeeg/pyeeg/largest_lyauponov_exponent.py", line 75, in LLE
from embedded_sequence import embed_seq
ModuleNotFoundError: No module named 'embedded_sequence'
Ran 8 tests in 3.996s
FAILED (errors=1)
Test failed: <unittest.runner.TextTestResult run=8 errors=1 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=8 errors=1 failures=0>
Hi,
I issued a pull request
to
https://github.com/jbergantine/pyeeg
from
https://github.com/mfeit/pyeeg
it is possible to merge the pull request to this repository or do I need to create a new pull request ?
Hi, first thanks a lot for this valuable module that you provide and make it available for us
secondary, would you please help me by answering my question.
this is my question:
in the code the input of function is x
such in calculating entropy in function one of the input or parameter as you explain is "x" and was introduced time series, a question arise in my brain :what's your meaning of this statement " x:time series"
a: your meaning is the EEG signal that export to ascii format (numerical format)
b: we should use time series analysis and make a time series from the EEG signal
beside my evaluation EEG signal can be considered as a time series when it export to ascii format(numerical format)
Would you please help me? it is so emergency and vital for me and I should to solve this problem as soon as possible
def hfd(X, Kmax):
""" Compute Hjorth Fractal Dimension of a time series X, kmax
is an HFD parameter
"""
**try:**
L = []
x = []
N = len(X)
for k in range(1, Kmax):
Lk = []
for m in range(0, k):
Lmk = 0
for i in range(1, int(numpy.floor((N - m) / k))):
Lmk += abs(X[m + i * k] - X[m + i * k - k])
Lmk = Lmk * (N - 1) / numpy.floor((N - m) / float(k)) / k
Lk.append(Lmk)
**if numpy.mean(Lk) != 0:
L.append(numpy.log(numpy.mean(Lk)))
x.append([numpy.log(float(1) / k), 1])
(p, r1, r2, s) = numpy.linalg.lstsq(x, L)
return p[0]
else:
return 0**
**except Exception as e:
return 0**
I have installed pyeeg using pip. This is my line in requirements.txt:
-e git+https://github.com/forrestbao/pyeeg.git#egg=pyeeg
When I use pyeeg.ap_entropy I am encountering the following error:
NameError: global name 'np' is not defined
I have numpy installed, I'm importing it as np, and it works fine.
Do you have any idea what this might be?
Thanks!
from numpy import cumsum, log, polyfit, sqrt, std, subtract
from numpy.random import randn
def hurst(ts):
"""Returns the Hurst Exponent of the time series vector ts"""
# Create the range of lag values
lags = range(2, 100)
# Calculate the array of the variances of the lagged differences
tau = [sqrt(std(subtract(ts[lag:], ts[:-lag]))) for lag in lags]
# Use a linear fit to estimate the Hurst Exponent
poly = polyfit(log(lags), log(tau), 1)
# Return the Hurst exponent from the polyfit output
return poly[0]*2.0
# Create a Gometric Brownian Motion, Mean-Reverting and Trending Series
gbm = log(cumsum(randn(100000))+1000)
mr = log(randn(100000)+1000)
tr = log(cumsum(randn(100000)+1)+1000)
# Output the Hurst Exponent for each of the above series
# and the price of Google (the Adjusted Close price) for
# the ADF test given above in the article
print "Hurst(GBM): %s" % hurst(gbm)
print "Hurst(MR): %s" % hurst(mr)
print "Hurst(TR): %s" % hurst(tr)
I compared with the results of pyeeg.hurst
and they are quite different.
I you want I can do a pull request to update the method
Hello, first thank you for this module!
For the calculation of Hjorth mobility and complexity, I got NaN returned.
It was because I was working with big numbers, TP has became negative and as a sqrt function is applied later on, the calculation was impossible.
I have solved the problem by adding "dtype = object" when declaring numpy array so I have enough space to store those numbers.
I hope it will help some poeple running this code!
Code of fisher information https://github.com/forrestbao/pyeeg/blob/master/pyeeg/fisher_info.py#L32-L37 and svd entropy
https://github.com/forrestbao/pyeeg/blob/master/pyeeg/entropy.py#L269-L274 is identical.
Hi,
Thanks for this module and I am going to use it in my project.
I think there should be a pyeeg.py
in the pyeeg/
folder, and write a new __init__.py
file to manually import all the relevant module. like
__all__ = ['hurst', 'lle']
from .pyeeg import hurst, lle
it's more python and follows the >3.3 standard
Hi, i`m using python 3.5 and there is error when installing under home directory. Using GIT Bash and python 3.5. Thanks
line 500 name not is "Y = Embed_seq(X, Tau, DE)"
fix Y = embed_seq(X, Tau, DE)
Edit: never mind, I apparently need to go back and re-take Algebra 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.