Code Monkey home page Code Monkey logo

pyhht's People

Contributors

cadair avatar irpagnossin avatar jaidevd avatar justinshenk avatar khider avatar kingjr avatar maurotoro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyhht's Issues

Write a tutorial.

Hi,

First of all thank you very much for providing such a package.
I'm currently working on EEG signals and wanted to try the EMD method to classify them.
So my data is an array of time series. I want to have the imfs of each time serie so I use the tutorial.emd function but it sometimes (I mean on some time series) returns me an error of type "TypeError: m > k must hold" which I don't understand. Maybe you know what this problem is related to.
Ask for any further precision,
Thank you in advance for your answer

Use definition of residue for testing

Testing monotonicity is a bad way of testing the residual output. Much better to just use the classic definition of the residue from the original paper.

Python3 and Docstrings

Dear Jaidevd,

I'm interested on using your work and I really appreciate the effort that you took on making the library. I'm forking it to start using it, I did some minor changes on my branch to make it work on python3, still not everything tested, but it seems that adding parenthesis to the print statements is enough. Also, imports from the library needed to be pyhht.LIB2IMPORT, VG in emd.py the line 15 reads: from utils import ....., needs to be from pyhht.utils import ....
Will comment on my results on the docstrings, that also seem to have a problem with python3, at least in spyder I don't see them on the object inspector.
Mucha Suerte!

stop_sifting(m) and 'fixe' problem

Hello,

whenever I'm trying to set fixed number of sifting ('fixe' parameter) OR when checking the stopping criteria for the current mode I get:
TypeError: mean_and_amplitude() takes exactly 2 arguments (1 given)

although I don't understands what am I doing wrong:

decomp_data = pyhht.emd.EMD(np.asarray(data))
decomp_data.stop_sifting(np.asarray(data))
OR
decomp_data = pyhht.emd.EMD(np.asarray(data), fixe=9)
decomp_data.decompose()

Could you please advice? Thank you!

bivariate EMD has some bugs

Hello, when I applied the code to complex list for bivariate EMD, the result is not cosistent with matlab's.

more meaningful representation of orthogonality

Hi,

I was thinking that in roder to provide a more meaningful orthogonality measure it might be useful for instance, to normalise the ortogonality (io()) by the N of IMFs combinations of which is computed (you can use for instance scipy comb)

what do you think? -- maybe we should ask to a broader audience ...

some data don't work

this code can't work

from pyhht.emd import EMD
from pyhht.visualization import plot_imfs
import numpy as np

x = [2275.4, 2274.6, 2274.6, 2274.4, 2274.0, 2273.6, 2272.8, 2273.6, 2274.0, 2273.4, 2273.0, 2272.8, 2272.4, 2272.4, 2272.6, 2271.8, 2269.4, 2269.8, 2270.0, 2269.6, 2269.0, 2267.4, 2267.6, 2268.0, 2268.4, 2268.0, 2268.2, 2268.0, 2267.6, 2267.8, 2267.6, 2265.2, 2265.0, 2264.0, 2263.2, 2262.4, 2263.8, 2263.2, 2263.0, 2261.4, 2263.0, 2263.0, 2262.8, 2262.4, 2262.4, 2263.6, 2262.8, 2262.6, 2261.2, 2258.2, 2258.8, 2258.4, 2259.4, 2258.4, 2258.0, 2257.0, 2257.0, 2257.0, 2256.8, 2255.4, 2256.2, 2256.2, 2256.8, 2255.4, 2256.6, 2256.2, 2255.0, 2256.0, 2256.4, 2257.0, 2255.8, 2256.6, 2257.0, 2255.6, 2254.0, 2253.6, 2255.0, 2255.2, 2254.2, 2255.2, 2255.0, 2256.4, 2256.2, 2256.8, 2256.2, 2256.4, 2257.0, 2256.6, 2256.2, 2256.6, 2256.4, 2256.0, 2255.2, 2254.6, 2254.2, 2254.4, 2253.4, 2251.6, 2250.4, 2251.6, 2252.6, 2252.6, 2252.8, 2251.4, 2252.4, 2253.2, 2252.6, 2252.8, 2253.0, 2253.2, 2253.8, 2253.2, 2253.4, 2253.4, 2253.4, 2254.8, 2253.8, 2253.4, 2253.8, 2254.0, 2253.4, 2253.0, 2253.8, 2253.4, 2253.2, 2253.4, 2253.8, 2253.0, 2252.4, 2252.2, 2252.0, 2251.2, 2252.4, 2253.8, 2254.0, 2253.6, 2253.2, 2251.8, 2251.0, 2251.6, 2251.6, 2250.4, 2252.0, 2250.6, 2251.0, 2251.4, 2251.2, 2251.6, 2252.2, 2252.0, 2252.0, 2252.4, 2252.6, 2252.4, 2251.4, 2251.8, 2251.0, 2251.4, 2252.2, 2252.0, 2253.0, 2252.6, 2253.4]
x = np.array(x)
t = np.array([i for i in range(len(x))])
decomposer = EMD(x)
imfs = decomposer.decompose()

plot_imfs(x, imfs, t)

y labels rotation

Hi,

it would be maybe nice to rotate by 90 degrees the y-labels, to avoid overlaps as the ones shown in the attached screenshot

screen shot 2018-08-16 at 17 54 45

Thanks again for the support.

I got some negative instantaneous frequencies

I have a negative value when calculating the instantaneous frequency of imf, and of course I have similar results when using matlab. After checking the data of imf, no negative maxima or positive minima were found. Is this normal? How do I deal with those negative values?
29b5adbbdadcbb8fd1eba06925714ef

Regarding Intrinsic Mode Function estimation for pulse-type time series

Hi,
First I am really thankful for your code, it has solved a lot of problems, given that no package exists for EMD in python.

The issue I am having currently is that my time series data when pre-processed yields a time series which is of the form of pulse train, where in consecutive elements are same for a few number of elements and then it shifts to another value.
Ex: [1 1 1 1 0 0 0 2 2 2 2 -1 -1 -1 ...]
For such a time series, the function is throwing an error.

If you could kindly look into this.

Thank you

Clarification of boundary_conditions() example

Thank you for your work on pyhht.

I have been working with the code and do not understand some results I am seeing.

When working through the boundary_conditions() example I got:

>>> from pyhht.utils import boundary_conditions
>>> import numpy as np
>>> signal = np.array([-1, 1, -1, 1, -1])
>>> tmin, tmax, vmin, vmax = boundary_conditions(signal, np.arange(5))
>>> tmin
array([-2,  2,  6])
>>> tmax
array([-3, -1,  1,  3,  5,  7])
>>> vmin
array([-1, -1, -1])
>>> vmax
array([1, 1, 1, 1, 1, 1])

Which agrees with your example.

I would have thought that tmin should be [-2, 0, 2, 4, 6] and vmin should be [-1, -1, -1, -1, -1] - am I misunderstanding?

how to produce more imfs?

I try some seismic signal use this EMD cannot yield same imfs solution as emd in MATLAB
and I do not know why ?
Why this emd tool usually only produce 2 imfs component but emd in MATLAB can produce 8~9 imfs?

Put EEMD and CEEMD into pyhht

Hi, Jaidevd. I am Dongwei Chen. It's nice to leave a message here. It's great to put EEMD and CEEMD into pyhht module successfully, which will contribute to python community. Thanks for your work!

problem with emd function in EMD.py.

When the size of data is even number, emd function can run correctly. If the size is odd number, the emd function cannot run. I run the default configure.

Here are the error information

signals[0:base / 2, 0] = data[::-1][base / 2:]
ValueError: could not broadcast input array from shape (2039) into shape (2038)

By the way, I test the matlab emd, which can handle any size of data.

Instantaneous frequencies are not consistent with the plot of HHT

I calculated the IMFs using pyhht then I extracted the instantaneous frequencies using the method in this package. The values that I always got were 100 and 200 Hz regardless of which IMF I used. After that, I switched to Matlab and I plotted the Hilbert space using the IMFs I got from this package, but it gave me different (more reasonable) results as shown below. Why is that happening?

image

According to which article

sx = np.abs(envmoy) / amp
stop = not(((np.mean(sx > self.threshold_1) > self.alpha) or
np.any(sx > self.threshold_2)) and np.all(nem > 2))
Which paper did this stop rule come from?

thanks!

problem with tutorials

Thanks for your effort in making such a package, it's the most popular package I found on GitHub implementing HHT. But I got some problems with tutorials, the file intro_pyhht.rst only has the title, but the content is missing. Maybe you can help fix it? Thanks a million!

Options for bivariate EMD

The initialization and use of attributes of the EMD class that are used exclusively for bivariate EMD should be clearly separated from the other attributes.

Local maximum and local minimum by spline

I reviewed your codes and thought that local maximum and local minimum should be spline function's local maximum and local minimum , not array index nor array value of original data unless the samples of signal is dense enough for this.
your original code is faster but rough solution.
I'll add another option on the function if you agree.

EEMD algorithm

Excuse me, does pyhht package include the EEMD algorithm?

preserving the decomposition memory

Is there any way to preserve the decomposition memory?
For example I have data from Jan 2016 - Feb 2017
the first time I decompose until on Jan 2017
second time decompose until on feb 2017
But the value on imfs and residual is not the same in the two decomposition given the same number of imfs and the same date

Force stopping for complex signals

Hi,

I'd really like to try your package, but there seems to be a problem handling complex valued inputs. I created several (simple) complex signals, and for each I receive:
Force stopping EMD: amplitude too small.

example code:
n = 1000
fc = 0.25
t = np.linspace(0, 1, n)
x = np.exp(2.0j * np.pi * fc * t)

X = np.fft.fftshift(np.fft.fft(x))
X /= np.max(X)
plt.plot(np.linspace(-0.5, 0.5, len(X)), np.abs(X) ** 2)
plt.show()

decomposer = EMD(x, is_mode_complex=True)
imfs = decomposer.decompose()
plot_imfs(x, imfs, t)

Any insight you may have would be very helpful. Thanks.

EMD not stable while data rolling on

Hi, I am testing pyhht to do rolling emd decomposition to de-trend time series. however, I find there are two issues, 1) with rolling test progress on, sometimes the residual emd's shape completely changed, and sometime later it could revert back to earlier one, this makes the de-trended data not stable and thus not usable. 2) with test rolling on, sometimes the number of imfs increase, sometimes decrease. I am using the default configuration, except set n_imfs = 5.
Is there a way control the two issues above?

Thanks and really appreciate sharing pyhht to community!

Docs do not build with Sphinx 4.0.2

I'm trying to build the docs and it throws this error. I think it must be a version thing, i.e., the add_javascript method probably went away with Sphinx v4.x

pyhht/docs $ make singlehtml
sphinx-build -b singlehtml -d build/doctrees   source build/singlehtml
Running Sphinx v4.0.2
making output directory... done

Exception occurred:
  File "/Users/jdm/Dropbox/Tools/Software/Python/pyhht/docs/source/conf.py", line 282, in setup
    app.add_javascript("https://docs.python.org/2/_static/copybutton.js")
AttributeError: 'Sphinx' object has no attribute 'add_javascript'
The full traceback has been saved in /var/folders/cs/lqjsdh5s69dd7csnhrxwmbgm0000gn/T/sphinx-err-gnmyqxeg.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
make: *** [singlehtml] Error 2

And the log file shows this:

pyhht/docs $ more /var/folders/cs/lqjsdh5s69dd7csnhrxwmbgm0000gn/T/sphinx-err-gnmyqxeg.log
# Sphinx version: 4.0.2
# Python version: 3.8.8 (CPython)
# Docutils version: 0.17.1 release
# Jinja2 version: 2.11.3
# Last messages:

# Loaded extensions:
Traceback (most recent call last):
  File "/Applications/anaconda3/lib/python3.8/site-packages/sphinx/cmd/build.py", line 276, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
  File "/Applications/anaconda3/lib/python3.8/site-packages/sphinx/application.py", line 257, in __init__
    self.config.setup(self)
  File "/Users/jdm/Dropbox/Tools/Software/Python/pyhht/docs/source/conf.py", line 282, in setup
    app.add_javascript("https://docs.python.org/2/_static/copybutton.js")
AttributeError: 'Sphinx' object has no attribute 'add_javascript'

emd.py divide by zero & other uncaught exceptions

in stop_sifting() the line: "sx = np.abs(envmoy) / amp" sometimes causes a divide by zero error.

also, I notice that right above this line (currently 376) there are some try/except checks for the return values of self.mean_and_amplitude(), but ONLY for two very specific errors. seems there should be an unconditional "except" too.

what's the right fix here?

-- jdm

"ValueError: setting an array element with a sequence," and array size too big?

I am coming across a specific error, "ValueError: setting an array element with a sequence." It shows up after the 2000th iteration, which I know is the set default. I tried changing the default number of iterations in the emd.py file for a quick fix, but it continues to just do 2000 iterations as a max.

My main issue is not the number of iterations, but rather why I am getting the error, "ValueError: setting an array element with a sequence." The main difference between the GitHub example and my analysis was that I was reading my signal data from a csv file.

I made sure the data sets were put into arrays, similar to the example involving modes=sin(2_pi_5_t)+sin(2_pi_10_t). Could it be that there are too many points in the csv file for "pyhht" to handle? The length of the array created by the CSV file is about 38200.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.