Coder Social home page Coder Social logo

falseywinchnet / pyitd Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 3.0 200.04 MB

Intrinsic Time-Scale Decomposition

License: Other

Python 0.46% Jupyter Notebook 99.54%
decomposition knot numba numpy peak-detection python3 signal-processing trend-analysis emperical-analysis

pyitd's Introduction

PyITD Intrinsic Time-Scale Decomposition

Introduction

This is a Python implementation of Intrinsic Time-Scale Decomposition (ITD). ITD is a patented decomposition method developed under grant. NIH/NINDS grants nos. 1R01NS046602-01 and 1R43NS39240-01. This algorithm is patented US7966156B1 by Frei And Osorio, 2024-10-06 Adjusted expiration

"We introduce a new algorithm, the intrinsic time-scale decomposition (ITD), for efficient and precise time–frequency–energy (TFE) analysis of signals. The ITD method overcomes many of the limitations of both classical (e.g. Fourier transform or wavelet transform based) and more recent (empirical mode decomposition based) approaches to TFE analysis of signals that are nonlinear and/or non-stationary in nature. The ITD method decomposes a signal into (i) a sum of proper rotation components, for which instantaneous frequency and amplitude are well defined, and (ii) a monotonic trend. The decomposition preserves precise temporal information regarding signal critical points and riding waves, with a temporal resolution equal to the time-scale of extrema occurrence in the input signal. We also demonstrate how the ITD enables application of single-wave analysis and how this, in turn, leads to a powerful new class of real-time signal filters, which extract and utilize the inherent instantaneous amplitude and frequency/phase information in combination with other relevant morphological features." Authors: Mark Frei, Ivan Osorio (2007).

The Intrinsic Time-Scale Decomposition (ITD) is a purely algorithmic, non-lossy iterative decomposition of a time series {Y (i)}N i=1. At the first stage, the signal is decomposed into a proper rotation R1(i), an oscillating mode in which maxima and minima are positive and negative, respectively, and a residual B1(i) called baseline . The baseline B1 is now decomposed in the same fashion, producing a proper rotation R2 and a baseline B2 , and so on. The process stops when the resulting baseline has only two extrema, or is a constant.

B2 = B1 - R1, and so on. The decomposition mode is fully reversable with typically perfect reconstitution. The final output for the decomposition is a monotonic upward trend.

ITD avoids a priori assumptions about the content/morphology of the signal being analysed (e.g. make the decomposition ‘basis free’) ITD also performs the analysis in an efficient and rapid manner with O(n) computations

ITD provides: efficient signal decomposition into ‘proper rotation’ components, for which instantaneous frequency and amplitude are well defined, along with the underlying monotonic signal trend, without the need for laborious and ineffective sifting or splines, precise temporal information regarding instantaneous frequency and amplitude of component signals with a temporal resolution equal to the time-scale of occurrence of extrema in the input signal, a new class of real-time signal filters that utilize the newly available instantaneous amplitude and frequency/phase information together with additional features and morphology information obtained via single-wave analysis. Moreover, the resulting feature extraction and feature-based filtering can be performed in real-time and is easily adapted to extract feature signals of interest at the time-scales on which they naturally occur, while preserving their morphology and relative phases.

ITD overcomes certain limitations of Empirical Mode Decomposition(EMD) including: overshooting and and undershooting of the interpolating cubic splines generating spurious extrema distortion and relocation of existing extrema smearing of time-frequency-energy information inability or extreme difficulty in producing a correct rotation

https://arxiv.org/pdf/1404.3827v1.pdf good summary of the approach https://sci-hub.hkvisa.net/10.1098/rspa.2006.1761 original publication See these articles for more information.

Available splines

  • knot estimation

Available stopping criteria

  • knot count
  • Fixed number of iterations

Extrema detection

  • matplotlib findpeaks

Installation

No package available yet. Work in progress.

Notes

The repo contains a working ITD implementation in a ipython notebook, and an in progress numba optimized version

pyitd's People

Contributors

falseywinchnet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pyitd's Issues

itd function returns "out of time" error

I am using the following piece of code to try itd method but end up with 'out of time' error. The data looks ok with some trends. Appreciate if you could advise a solution. Thanks!
`
inputData2 = [170.825,171.293,168.477,168.117,170.145,170.675,170.765,175.049,176.100,179.441,178.031,179.526,179.962,180.870,184.388,184.747,182.109,181.969,181.240,180.045,179.321,183.274,184.428,183.728,184.778,185.228,186.217,186.986,189.306,186.577,188.546,188.596,188.616,188.831,190.214,188.191,186.442,189.046,189.086,190.282,188.346,188.686,184.638,182.000,181.879,182.429,182.469,184.488,183.249,184.313,186.986,187.886,186.716,187.706,187.396,187.626,180.950,179.161,179.261,179.351,178.724,178.406,178.391,174.133,171.755,172.928,172.186,170.965,170.755,170.245,172.635,171.825,172.185,172.635,172.140,172.315,171.715,170.065,171.425,173.396,172.495,171.775,171.905,172.125,171.985,176.513,176.542,177.152,177.612,177.209,179.032,176.897,170.535,168.079,166.620,165.139,164.600,162.510,161.181,158.462,158.342,158.802,159.891,158.942,157.923,156.993,154.454,154.439,153.215,152.896,153.305,154.634,152.986,150.187,151.536,150.357,150.239,150.232,150.856,139.045,135.070,133.711,133.766,134.277,137.779,139.293,137.462,139.891,139.872,137.924,136.461,136.774,136.394,135.675,136.449,137.254,135.948,134.826,135.075,134.576,134.426,134.336,135.895,135.335,136.055,137.585,137.105,136.989,138.655,138.755,137.705,138.225,138.245,139.864,143.223,143.443,144.023,144.133,144.093,143.483,143.833,144.533,143.353,142.409,143.320,144.083,143.663,145.013,137.075,134.796,134.396,134.091,134.196,133.133,131.276,130.767,131.196,130.996,131.706,130.620,130.048,131.246,131.761,128.097,129.537,130.367,130.597,129.617,129.257,127.307,128.946,129.457,129.817,129.327,130.875,131.956,132.781,133.996,131.766,132.876,132.621,132.846,133.786,132.476,134.056,134.641,133.089,130.687,131.827,131.726,133.321,133.877,135.025,135.275,136.651,139.139,132.576,127.597,125.748,125.948,126.269,125.958,125.198,125.578,123.346,124.458,123.988,123.878,123.538,122.799,125.128,125.738,124.349,124.131,123.338,122.474,123.918,122.249,125.968,126.758,124.718,123.528,123.268,124.158,124.098,125.848,126.318,127.277,125.508,125.818,126.638,127.327,122.394,121.630,122.229,121.152,120.009,120.138,122.169,123.533,125.747,124.798,124.088,122.819,122.329,121.359,122.519,124.598,124.317,124.448,125.388,126.253,125.088,129.337,132.086,132.036,130.322,130.567,131.516,131.636,127.988,126.668,128.793,130.142,130.507,131.966,132.056,134.826,134.426,132.506,132.756,133.191,131.628,131.266,124.808,124.209,122.949,122.534,121.898,121.239,120.729,116.430,114.646,116.563,115.151,117.470,116.890,116.670,113.701,113.441,116.820,117.580,117.390,114.981,115.830,115.510,113.621,115.870,115.569,115.091,115.278,114.971,110.927,113.561,118.840,118.120,119.429,119.777,119.569,115.750,114.311,113.321,113.081,113.874,113.980,112.241,117.410,116.130,118.659,118.510,118.950,118.900,118.850,120.879,118.750,117.990,118.540,120.119,118.810,119.639,118.828,121.019,121.619,120.059,119.919,119.909,120.479,125.585,127.388,126.080,123.818,122.574,121.967,121.909,122.199,120.789,122.673,122.789,124.445,124.059,124.628,122.619,123.308,125.053,125.008,125.238,126.068,125.958,130.576,130.637,131.856,132.026,131.506,132.286,132.576,130.657,131.866,132.946,130.897,130.077,129.987,128.927,131.896,134.196,132.246,132.486,132.811,132.270,131.726,134.301,134.446,136.105,137.315,136.885,137.125,138.305,135.120,133.636,135.085,134.811,135.795,135.515,134.935,137.635,136.065,137.595,136.845,136.338,136.850,135.395,140.031,139.504,138.440,137.785,138.225,136.795,132.156,130.187,136.725,134.975,135.725,134.211,135.195,134.176,139.617,140.874,138.075,138.305,137.275,140.109,141.524,140.564,141.444,140.721,141.192,141.144,142.639,142.973,146.393,146.223,147.492,147.332,144.476,144.473,145.983,140.374,139.194,139.424,139.659,138.125,137.995,137.725,149.732,150.162,152.892,152.391,154.809,155.220,157.460,158.529,160.349,160.149,160.659,161.919,163.538,163.228,160.754,162.998,163.733,163.598,164.548,164.908,162.908,168.907,166.427,167.867,168.827,165.538,166.887,166.617,161.269,159.219,161.269,161.745,160.899,160.889,159.059,159.109,159.679,159.329,159.329,157.710,156.730,156.730,156.290,153.331,153.601,151.541,152.191,152.931,154.051,153.051,153.071,153.432,152.051,153.161,153.051,153.131,153.777,157.852,158.489,157.575,158.769,158.879,160.339,163.358,164.258,162.628,161.529,162.893,164.448,165.148,164.091,163.518,163.658,162.798,162.658,163.003,160.408,161.015,160.157,159.579,158.999,158.230,157.615,157.728,156.970,156.870,156.700,156.591,156.350,156.870,157.540,158.738,157.580,161.720,164.560,169.230,171.624,170.720,170.570,171.092,171.980,172.170,171.350,165.450,165.855,166.790,166.050,166.820,168.160,168.760,168.140,168.638,167.880,166.830,166.185,165.760,166.100,161.990,160.220,160.550,160.620,160.840,159.090,159.870,158.700,160.420,159.650,159.965,160.360,160.723,161.200,163.000,167.490,167.882,168.350,169.069,170.240,171.690,172.000,174.940,175.060,173.942,173.040,173.339,170.010,171.030,170.870,171.644,171.570,172.005,173.370,175.350,186.170,182.410,180.644,178.470,179.520,179.696,180.720,180.980,180.519,180.310,179.008,181.160,175.660,176.740,168.810,168.083,168.403,167.910,168.030,170.570,169.520,168.950,165.900,165.250,164.880,165.649,166.350,165.710,162.635,162.940,162.088,164.100,163.010,162.510,162.540,162.670,162.095,161.295,161.034,161.130,161.360,160.850,163.335,165.280,164.640,165.260,165.460,165.600,165.010,157.210,153.880,150.830,150.630,149.973,151.450,153.390,149.870,150.725,151.520,151.630,151.044,151.560,152.060,145.730,145.857,144.170,143.270,142.585,141.410,141.210,140.946,139.451,140.070,141.540,141.330,140.430,140.360,144.645,145.400,146.350,146.430,145.825,145.230,146.030,144.320,143.965,144.652,144.970,144.170,144.050,146.140,145.427,143.370,141.390,141.977,142.620,143.110,143.150,145.380,144.010,146.690,146.490,147.685,147.695,147.490,143.235,141.920,141.990,142.568,143.590,143.830,142.650,140.940,145.390,147.030,146.620,147.960,149.431,148.590,157.140,158.933,159.846,160.061,158.443,158.110,156.280,157.150,157.690,157.095,156.740,157.330,158.571,159.090,157.147,156.235,157.570,158.070,158.440,158.671,160.010,156.475,159.320,160.960,164.400,165.840,165.530,165.110,164.720,167.670,165.660,166.620,167.650,167.845,168.990,173.490,174.770,175.261,175.600,176.830,176.690,177.020,177.310,175.130,174.625,174.030,174.405,174.950,173.770,170.544,169.430,168.170,168.600,169.451,169.613,167.650,169.735,169.190,173.244,174.770,176.340,177.760,178.390,185.015,188.070,189.775,189.840,191.845,190.225,191.930,191.390,192.290,192.560,190.475,191.220,192.170,192.650,188.675,188.020,189.010,188.933,191.125,192.688,193.230,195.880,193.540,194.510,196.639,196.640,197.582,198.020,198.940,199.970,200.792,203.510,205.380,205.008,203.650,199.246,196.050,196.389,194.455,194.180,194.080,191.620,190.575,196.160,194.030,195.143,194.935,194.870,195.390,200.220,199.390,200.660,201.210,201.260,207.320,209.430,212.475,213.510,212.470,216.840,219.393,213.220,217.090,215.370,214.931,214.620,213.790,212.360,211.190,211.000,212.630,212.430,213.410,212.150,211.535,212.479,210.890,213.161,213.805,216.625,220.680,214.370,219.188,221.730,226.235,222.090,223.620,225.015,223.900,222.233,222.050,227.150,229.950,229.274,226.300,226.420,224.360,223.370,216.370,213.310,210.200,211.310,210.371,211.325,212.650,216.130,216.360,219.021,218.855,218.971,218.116,217.880,225.800,223.785,224.680,226.274,228.388,229.110,229.710,222.965,222.590,225.620,225.904,226.450,226.490,227.640,222.180,222.820,223.175,224.050,225.146,224.240,220.020,215.210,211.640,211.720,210.810,211.890,214.930,213.880,211.860,210.730,208.950,210.409,208.930,207.500,206.550,208.250,206.160,207.685,209.160,208.824,206.660,207.540,237.150,235.463,232.695,234.187,236.760,236.571,236.640,231.040,230.431,233.680,231.430,232.270,233.707,232.860,237.950,235.491,236.390,236.530,237.880,236.250,235.010,234.756,234.248,235.470,237.050,237.760,235.780,232.160,229.960,227.215,227.240,227.630,227.200,226.890,226.980,227.020,227.453,226.980,228.310,230.847,232.100,233.140,233.260,232.619,232.580,235.360,236.230,238.125,238.900,238.210,241.930,240.310,238.080,236.921,236.920,235.540,237.420,236.375,239.578,240.200,235.390,233.540,232.917,237.470,238.295,239.954,239.040,238.220,239.732,241.810,243.650,241.357,241.090,239.805,237.112,236.817,234.360,228.890,233.440,232.638,230.750,228.730,230.100,229.650,227.910,229.090,231.690,229.075,230.165,231.745,229.660,238.020,239.510,241.610,241.430,238.690,237.760,240.620,235.660,235.420,236.219,235.320,238.310,241.860,242.300,243.080,246.500,251.670,252.525,251.750,252.692,255.410,261.247,259.745,258.500,257.745,259.520,258.830,257.171,252.740,256.260,255.400,257.730,259.940,259.000,259.000,262.945,259.000,255.690,259.090,260.914,262.630,261.990,268.870,269.100,271.042,269.390,270.650,272.098,264.680,273.220,273.010,273.275,273.010,270.520,269.690,271.910,268.175,265.254,266.840,265.319,264.980,266.315,267.790,268.360,267.140,264.110,265.370,265.950,266.670,265.310,259.280,260.212,262.599,261.960,261.781,261.985,264.100,270.280,267.060,269.230,267.780,268.366,269.380,269.840,272.850,274.310,273.670,273.200,272.310,273.505,273.830,275.140,274.440,275.724,277.200,277.320,276.310,277.770,275.899,276.170,275.165,273.829,274.950,277.180,279.657,276.508,277.511,276.735,276.939,276.911,274.745,274.530,267.690,264.610,266.680,265.160,266.280,267.505,268.810,266.350,267.550,270.100,268.150,269.820,269.710,270.370,268.448,271.650,273.790,274.960,274.540,275.705,275.790,274.120,271.764,272.720,273.120,274.000,273.510,271.690,267.190,266.110,268.880,269.425,268.500,266.475,264.950,265.420,266.550,267.430,267.270,268.320,267.452,264.630,268.305,265.740,265.200,263.870,264.920,266.721,267.580,267.265,267.753,265.860,265.910,265.944,267.750,270.020,277.900,278.718,278.130,278.400,276.900,274.391,276.670,275.674,276.835,277.150,278.080,278.350,278.312,279.310,278.740,277.260,276.565,276.730,276.550,273.970,271.040,267.600,269.460,270.620,270.490,270.485,269.950,271.190,272.240,268.760,267.212,269.270,269.836,270.810,270.420,268.060,266.605,264.950,264.545,264.345,263.715,262.410,270.149,270.360,272.540,271.430,271.960,269.605,269.560,266.895,268.026,268.090,269.955,271.120,271.382,272.260,271.970,273.140,274.788,275.574,275.360,275.760,277.490,282.370,286.320,286.350,287.730,289.241,289.342,289.100,285.120,281.960,282.410,282.670,283.950,283.570,282.100,276.770,279.034,278.850,279.290,280.240,281.785,278.020,277.300,275.495,276.630,277.120,276.470,274.680,275.620,280.874,283.890,283.730,284.136,286.060,287.210,286.800,284.770,286.545,289.250,289.727,289.870,291.835,291.510,287.100,285.950,284.960,286.323,286.830,287.030,285.705,288.850,287.840,289.240,288.090,286.070,288.374,288.850,285.441,284.080,286.510,286.157,285.290,286.084,285.780,285.760,282.930,283.480,281.590,281.500,282.040,283.400,282.590,283.622,287.329,288.110,288.205,288.725,289.530,292.795,293.060,296.115,298.159,295.570,295.270,292.130,295.410,297.780,297.890,298.870,300.585,300.054,301.780,307.970,311.340,316.300,314.920,312.730,316.710,316.780,312.479,309.865,312.632,313.322,312.250,312.979,312.640,312.800,313.660,312.508,312.400,313.338,313.320,311.760,311.825,309.940,308.705,307.780,307.840,307.293,306.880,301.720,298.640,299.745,300.000,300.630,300.425,305.380,379.490,381.755,385.300,387.179,384.892,382.030,379.815,380.010,385.519,386.495,388.215,388.880,388.530,389.460,409.590,408.560,412.115,404.715,400.095,402.697,401.110,396.110,391.761,386.870,381.925,387.728,384.670,378.380,391.490,390.725,394.200,396.275,398.655,398.945,397.700,392.810,398.230,396.140,393.707,393.447,392.430,393.270,389.340,392.325,391.630,392.288,389.649,390.600,391.710]

inputArray = np.asarray(inputData2)

itd=ITD()

rotations = itd.itd(inputArray)
`

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.