├── matlab_version ├── pe.m ├── cumulativeFunc.m ├── multiScale.m ├── triangle_MF.m ├── trapezoidal_MF.m ├── MFDE.m ├── MDE.m ├── MCRDE.m ├── MSE_mu.m ├── FuzzyDisEn_NCDF.m ├── FuzzyDisEn_NCDF_ms.m ├── main_feature_extraction.m ├── DisEn_NCDF_ms.m └── DisEn_NCDF.m ├── python_version ├── entropy │ ├── __pycache__ │ │ ├── MCRDE.cpython-38.pyc │ │ ├── Multi.cpython-38.pyc │ │ ├── DisEn_NCDF.cpython-38.pyc │ │ ├── DisEn_NCDF_ms.cpython-38.pyc │ │ └── cumulativeFunc.cpython-38.pyc │ ├── cumulativeFunc.py │ ├── Multi.py │ ├── MCRDE.py │ ├── DisEn_NCDF_ms.py │ └── DisEn_NCDF.py └── main.py ├── README.md └── LICENSE /matlab_version/pe.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClustProject/KWUFeatureExtraction/HEAD/matlab_version/pe.m -------------------------------------------------------------------------------- /python_version/entropy/__pycache__/MCRDE.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClustProject/KWUFeatureExtraction/HEAD/python_version/entropy/__pycache__/MCRDE.cpython-38.pyc -------------------------------------------------------------------------------- /python_version/entropy/__pycache__/Multi.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClustProject/KWUFeatureExtraction/HEAD/python_version/entropy/__pycache__/Multi.cpython-38.pyc -------------------------------------------------------------------------------- /python_version/entropy/__pycache__/DisEn_NCDF.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClustProject/KWUFeatureExtraction/HEAD/python_version/entropy/__pycache__/DisEn_NCDF.cpython-38.pyc -------------------------------------------------------------------------------- /python_version/entropy/__pycache__/DisEn_NCDF_ms.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClustProject/KWUFeatureExtraction/HEAD/python_version/entropy/__pycache__/DisEn_NCDF_ms.cpython-38.pyc -------------------------------------------------------------------------------- /python_version/entropy/__pycache__/cumulativeFunc.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClustProject/KWUFeatureExtraction/HEAD/python_version/entropy/__pycache__/cumulativeFunc.cpython-38.pyc -------------------------------------------------------------------------------- /matlab_version/cumulativeFunc.m: -------------------------------------------------------------------------------- 1 | function output = cumulativeFunc(pdf) 2 | 3 | Len = length(pdf); 4 | output = zeros(1,Len); 5 | 6 | for i=1:Len 7 | output(i) = sum( pdf(1:i)); 8 | end 9 | 10 | end 11 | 12 | -------------------------------------------------------------------------------- /matlab_version/multiScale.m: -------------------------------------------------------------------------------- 1 | function scaledDt = multiScale(Data, s) 2 | %MULTISCALE 이 함수의 요약 설명 위치 3 | % 자세한 설명 위치 4 | 5 | L = length(Data); 6 | J = fix(L/s); 7 | 8 | for i= 1:J 9 | scaledDt(1,i) = mean(Data((i-1)*s+1:i*s)); 10 | end 11 | 12 | end 13 | 14 | -------------------------------------------------------------------------------- /matlab_version/triangle_MF.m: -------------------------------------------------------------------------------- 1 | function u = triangle_MF(k, z) 2 | % Triangle Membership function 3 | % if not k==1 and k==c apply Trapezoidal Membership function 4 | % 5 | % Inputs: 6 | % z: series which time series y mapped 7 | % k: interger close to z 8 | % 9 | % Output: 10 | % u: the degree of membership of z 11 | 12 | if(z>k+1) 13 | u = 0; 14 | elseif((z>=k) && (z<=k+1)) 15 | u = k+1-z; 16 | elseif((z>=k-1) && (z<=k)) 17 | u = z-k+1; 18 | elseif(z2) 14 | u = 0; 15 | elseif((z>=1) && (z<=2)) 16 | u = 2-z; 17 | elseif(z<1) 18 | u = 1; 19 | end 20 | 21 | elseif(k==nc) 22 | if(z>nc) 23 | u = 1; 24 | elseif((z>=nc-1) && (z<=nc)) 25 | u = z-nc+1; 26 | elseif(z ## **main_feature_extraction.m** ## 7 | + **MDE.m** 8 | - DisEn_NCDF.m 9 | - DisEn_NCDF_ms.m 10 | 11 | + **MCRDE.m** 12 | - DisEn_NCDF.m 13 | - DisEn_NCDF_ms.m 14 | - CumulativeFunc.m 15 | 16 | + **MSE_mu.m** 17 | 18 | + **pe.m** 19 | - multiScale.m 20 | 21 | + **MFDE.m** 22 | - FuzzyDisEn_NCDF.m 23 | - FuzzyDisEn_NCDF_ms.m 24 | - triangle_MF.m 25 | - trapezoidal_MF.m 26 | 27 | -------------------------------------------------------------------------------- /python_version/entropy/Multi.py: -------------------------------------------------------------------------------- 1 | 2 | ############################################################################ 3 | 4 | # generate the consecutive coarse-grained time series 5 | # Input: Data: time series; 6 | # S: the scale factor 7 | # Output: 8 | # M_Data: the coarse-grained time series at the scale factor S 9 | 10 | ############################################################################ 11 | 12 | import numpy as np 13 | from math import floor 14 | from math import ceil 15 | 16 | def Multi(Data, S): 17 | 18 | J = 0 19 | M_Data = [] 20 | L = len(Data) 21 | 22 | if L/S > 0 : 23 | J = floor(L/S) 24 | elif L/S < 0 : 25 | J = ceil(L/S) 26 | else: 27 | J = 0 28 | 29 | for i in range(J): 30 | M_Data = np.append(M_Data, np.mean(Data[i*S:(i+1)*S])) 31 | 32 | return M_Data 33 | 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 CLUST-consortium 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /matlab_version/MFDE.m: -------------------------------------------------------------------------------- 1 | function [Out_MFDE Out_pdf] =MFDE(x,m,c,tau,Scale) 2 | % 3 | % This function calculates the multiscale fuzzy dispersion entropy (MFDE) of a univariate signal x 4 | % 5 | % Inputs: 6 | % 7 | % x: univariate signal - a vector of size 1 x N (the number of sample points) 8 | % m: embedding dimension 9 | % c: number of classes (it is usually equal to a number between 3 and 9 - we used c=6 in our studies) 10 | % tau: time lag (it is usually equal to 1) 11 | % Scale: number of scale factors 12 | % 13 | %Outputs: 14 | % 15 | % Out_MFDE: a vector of size 1 * Scale - the MFDE of x 16 | 17 | Out_MFDE=NaN*ones(1,Scale); 18 | Out_MFDE(1)=FuzzyDisEn_NCDF(x,m,c,tau,0); 19 | 20 | sigma=std(x); 21 | mu=mean(x); 22 | 23 | for j=2:Scale 24 | xs = Multi(x,j); 25 | Out_MFDE(j) =FuzzyDisEn_NCDF_ms(xs,m,c,mu,sigma,tau,0); 26 | end 27 | 28 | 29 | function M_Data = Multi(Data,S) 30 | % generate the consecutive coarse-grained time series 31 | % Input: Data: time series; 32 | % S: the scale factor 33 | % Output: 34 | % M_Data: the coarse-grained time series at the scale factor S 35 | 36 | L = length(Data); 37 | J = fix(L/S); 38 | 39 | for i=1:J 40 | M_Data(i) = mean(Data((i-1)*S+1:i*S)); 41 | end -------------------------------------------------------------------------------- /python_version/entropy/MCRDE.py: -------------------------------------------------------------------------------- 1 | 2 | ######################################################################################## 3 | 4 | # This function calculates the multiscale cumulative residual dispersion entropy (MCRDE) of a univariate signal x 5 | 6 | # Inputs: 7 | 8 | # x: univariate signal - a vector of size 1 x N (the number of sample points) 9 | # m: embedding dimension 10 | # c: number of classes (it is usually equal to a number between 3 and 9 - we used c=6 in our studies) 11 | # tau: time lag (it is usually equal to 1) 12 | # Scale: number of scale factors 13 | 14 | # Outputs: 15 | 16 | # Out_MCRDE: a vector of size 1 * Scale - the MCRDE of x 17 | 18 | ######################################################################################## 19 | 20 | 21 | import numpy as np 22 | from .DisEn_NCDF import DisEn_NCDF 23 | from .DisEn_NCDF_ms import DisEn_NCDF_ms 24 | from .Multi import Multi 25 | 26 | def MCRDE(x,m,c,tau,scale): 27 | 28 | Out_MCRDE = np.nan * np.ones((1,scale)) 29 | 30 | # When Scale=1, MCRDE value 31 | Out_MCRDE[0][0] = DisEn_NCDF(x,m,c,tau,1) 32 | 33 | sigma = np.std(x) 34 | mu = np.mean(x) 35 | 36 | # MultiScale Entropy(coarse-graining mean) 37 | for j in range(1,scale): 38 | xs = Multi(x,j+1) 39 | Out_MCRDE[0][j] = DisEn_NCDF_ms(xs,m,c,mu,sigma,tau,1) 40 | 41 | return Out_MCRDE -------------------------------------------------------------------------------- /matlab_version/MDE.m: -------------------------------------------------------------------------------- 1 | function [Out_MDE Out_pdf] =MDE(x,m,c,tau,Scale) 2 | % 3 | % This function calculates the multiscale dispersion entropy (MDE) of a univariate signal x 4 | % 5 | % Inputs: 6 | % 7 | % x: univariate signal - a vector of size 1 x N (the number of sample points) 8 | % m: embedding dimension 9 | % c: number of classes (it is usually equal to a number between 3 and 9 - we used c=6 in our studies) 10 | % tau: time lag (it is usually equal to 1) 11 | % Scale: number of scale factors 12 | % 13 | %Outputs: 14 | % 15 | % Out_MDE: a vector of size 1 * Scale - the MDE of x 16 | % 17 | % Ref: 18 | % [1] H. Azami, M. Rostaghi, D. Abasolo, and J. Escudero, "Refined Composite Multiscale Dispersion Entropy and its Application to Biomedical 19 | % Signals", IEEE Transactions on Biomedical Engineering, 2017. 20 | % [2] M. Rostaghi and H. Azami, "Dispersion Entropy: A Measure for Time-Series Analysis", IEEE Signal Processing Letters. vol. 23, n. 5, pp. 610-614, 2016. 21 | % 22 | % If you use the code, please make sure that you cite references [1] and [2]. 23 | % 24 | % Hamed Azami and Javier Escudero Rodriguez 25 | % Emails: hamed.azami@ed.ac.uk and javier.escudero@ed.ac.uk 26 | % 27 | % 20-January-2017 28 | %% 29 | 30 | Out_MDE=NaN*ones(1,Scale); 31 | Out_MDE(1)=DisEn_NCDF(x,m,c,tau,0); 32 | 33 | sigma=std(x); 34 | mu=mean(x); 35 | 36 | for j=2:Scale 37 | xs = Multi(x,j); 38 | Out_MDE(j) =DisEn_NCDF_ms(xs,m,c,mu,sigma,tau,0); 39 | end 40 | 41 | 42 | function M_Data = Multi(Data,S) 43 | % generate the consecutive coarse-grained time series 44 | % Input: Data: time series; 45 | % S: the scale factor 46 | % Output: 47 | % M_Data: the coarse-grained time series at the scale factor S 48 | 49 | L = length(Data); 50 | J = fix(L/S); 51 | 52 | for i=1:J 53 | M_Data(i) = mean(Data((i-1)*S+1:i*S)); 54 | end -------------------------------------------------------------------------------- /matlab_version/MCRDE.m: -------------------------------------------------------------------------------- 1 | function [Out_MCRDE Out_pdf] =MCRDE(x,m,c,tau,Scale) 2 | % 3 | % This function calculates the multiscale cumulative residual dispersion entropy (MCRDE) of a univariate signal x 4 | % 5 | % Inputs: 6 | % 7 | % x: univariate signal - a vector of size 1 x N (the number of sample points) 8 | % m: embedding dimension 9 | % c: number of classes (it is usually equal to a number between 3 and 9 - we used c=6 in our studies) 10 | % tau: time lag (it is usually equal to 1) 11 | % Scale: number of scale factors 12 | % 13 | %Outputs: 14 | % 15 | % Out_MCRDE: a vector of size 1 * Scale - the MCRDE of x 16 | % 17 | % Ref: 18 | % [1] H. Azami, M. Rostaghi, D. Abasolo, and J. Escudero, "Refined Composite Multiscale Dispersion Entropy and its Application to Biomedical 19 | % Signals", IEEE Transactions on Biomedical Engineering, 2017. 20 | % [2] M. Rostaghi and H. Azami, "Dispersion Entropy: A Measure for Time-Series Analysis", IEEE Signal Processing Letters. vol. 23, n. 5, pp. 610-614, 2016. 21 | % 22 | % If you use the code, please make sure that you cite references [1] and [2]. 23 | % 24 | % Hamed Azami and Javier Escudero Rodriguez 25 | % Emails: hamed.azami@ed.ac.uk and javier.escudero@ed.ac.uk 26 | % 27 | % 20-January-2017 28 | %% 29 | 30 | Out_MCRDE=NaN*ones(1,Scale); 31 | Out_MCRDE(1)=DisEn_NCDF(x,m,c,tau,1); 32 | 33 | sigma=std(x); 34 | mu=mean(x); 35 | 36 | for j=2:Scale 37 | xs = Multi(x,j); 38 | Out_MCRDE(j) =DisEn_NCDF_ms(xs,m,c,mu,sigma,tau,1); 39 | end 40 | 41 | 42 | function M_Data = Multi(Data,S) 43 | % generate the consecutive coarse-grained time series 44 | % Input: Data: time series; 45 | % S: the scale factor 46 | % Output: 47 | % M_Data: the coarse-grained time series at the scale factor S 48 | 49 | L = length(Data); 50 | J = fix(L/S); 51 | 52 | for i=1:J 53 | M_Data(i) = mean(Data((i-1)*S+1:i*S)); 54 | end -------------------------------------------------------------------------------- /matlab_version/MSE_mu.m: -------------------------------------------------------------------------------- 1 | function Out_MSE = MSE_mu(x,m,r,tau,Scale) 2 | % 3 | % This function calculates the multiscale sample entropy (MSE) whose coarse-graining uses mean (MSE_mu) 4 | % 5 | % 6 | % Inputs: 7 | % 8 | % x: univariate signal - a vector of size 1 x N (the number of sample points) 9 | % m: embedding dimension 10 | % r: threshold (it is usually equal to 0.15 of the standard deviation of a signal - because we normalize signals to have a standard deviation of 1, here, r is usually equal to 0.15) 11 | % tau: time lag (it is usually equal to 1) 12 | % Scale: the number of scale factors 13 | % 14 | % 15 | % Outputs: 16 | % 17 | % Out_MSE: a vector showing the MSE_mu of x 18 | % 19 | % Ref: 20 | % [1] H. Azami and J. Escudero, "Refined Multiscale Fuzzy Entropy based on Standard Deviation for Biomedical Signal Analysis", Medical & Biological Engineering & 21 | % Computing, 2016. 22 | % [2] M. Costa, A. Goldberger, and C.K. Peng, "Multiscale Entropy Analysis of Complex Physiologic Time Series", Physical review letters, vol. 89, no. 6, p. 068102, 2002. 23 | % 24 | % 25 | % If you use the code, please make sure that you cite references [1] and [2]. 26 | % 27 | % Hamed Azami and Javier Escudero Rodriguez 28 | % hamed.azami@ed.ac.uk and javier.escudero@ed.ac.uk 29 | % 30 | % 7-September-16 31 | %% 32 | 33 | % Signal is centered and normalised to standard deviation 1 34 | % x = x-mean(x); 35 | % x = x./std(x); 36 | 37 | Out_MSE=NaN*ones(1,Scale); 38 | 39 | Out_MSE(1)=SampEn(x,m,r,tau); 40 | 41 | for j=2:Scale 42 | xs = Multi_mu(x,j); 43 | Out_MSE(j)=SampEn(xs,m,r,tau); 44 | end 45 | 46 | 47 | function M_Data = Multi_mu(Data,S) 48 | 49 | % the coarse-graining process based on mean 50 | % Input: Data: time series; 51 | % S: the scale factor 52 | 53 | % Output: 54 | % M_Data: the coarse-grained time series at the scale factor S 55 | 56 | L = length(Data); 57 | J = fix(L/S); 58 | 59 | for i=1:J 60 | M_Data(i) = mean(Data((i-1)*S+1:i*S)); 61 | end 62 | -------------------------------------------------------------------------------- /matlab_version/FuzzyDisEn_NCDF.m: -------------------------------------------------------------------------------- 1 | function [Out_FuzzyDisEn, npdf]=FuzzyDisEn_NCDF(x,m,nc,tau,type) 2 | % 3 | % This function calculates Fuzzy dispersion entropy (FuzzyDisEn) of a univariate 4 | % signal x, using normal cumulative distribution function (NCDF) 5 | % 6 | % Inputs: 7 | % 8 | % x: univariate signal - a vector of size 1 x N (the number of sample points) 9 | % m: embedding dimension 10 | % nc: number of classes (it is usually equal to a number between 3 and 9 - we used c=6 in our studies) 11 | % tau: time lag (it is usually equal to 1) 12 | % type : select MFDE or MCRFDE (MFDE : 0, MCRFDE : 1) 13 | % 14 | % Outputs: 15 | % 16 | % Out_FuzzyDisEn: scalar quantity - the FuzzyDisEn of x 17 | % npdf: a vector of length nc^m, showing the normalized number of disersion patterns of x 18 | 19 | 20 | N=length(x); 21 | sigma=std(x); 22 | mu=mean(x); 23 | 24 | y=normcdf(x,mu,sigma); 25 | 26 | for i_N=1:N 27 | if y(i_N)==1 28 | y(i_N)=1-(1e-10); 29 | end 30 | 31 | if y(i_N)==0 32 | y(i_N)=(1e-10); 33 | end 34 | end 35 | 36 | z = y*nc+0.5; 37 | 38 | for k=1:nc 39 | if(k==1 || k==nc) 40 | for r=1:N 41 | u_M(k,r) = trapezoidal_MF(k, z(r), nc); 42 | end 43 | else 44 | for r=1:N 45 | u_M(k,r) = triangle_MF(k, z(r)); 46 | end 47 | end 48 | end 49 | 50 | v=nan*ones(nc^m,m); 51 | u=1; 52 | for k=1:m 53 | a = repmat(1:nc,nc^(k-1),1); 54 | temp_a = reshape(a,[],1); 55 | v(:,m-k+1) = repmat(temp_a,nc^(m-k),1); 56 | end 57 | 58 | u_pi = ones(nc^m,N-(m-1)*tau); 59 | for s=1:nc^m 60 | for j=1:N-(m-1)*tau 61 | for i=1:m 62 | u_pi(s,j) = u_pi(s,j) * u_M(v(s,i),j+(i-1)*tau); 63 | end 64 | end 65 | end 66 | 67 | u_pi_sum = zeros(1,nc^m); 68 | for s=1:nc^m 69 | u_pi_sum(s) = sum(u_pi(s,:)); 70 | end 71 | 72 | npdf = u_pi_sum / (N-(m-1)*tau); 73 | 74 | 75 | switch sign(type) 76 | case 0 77 | p=npdf(npdf~=0); 78 | Out_FuzzyDisEn = -sum(p .* log(p)); 79 | case 1 80 | cmf = cumulativeFunc(npdf); 81 | rsd_cmf = zeros(1,length(cmf)); 82 | rsd_cmf = 1-cmf(1:end); 83 | rsd = rsd_cmf(rsd_cmf ~= 0); 84 | % save npdf; 85 | Out_FuzzyDisEn = -sum(rsd .* log(rsd)); 86 | %Out_DisEn 87 | otherwise 88 | fprint('ERROR : Used undefined type') 89 | end 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /matlab_version/FuzzyDisEn_NCDF_ms.m: -------------------------------------------------------------------------------- 1 | function [Out_FuzzyDisEn, npdf]=FuzzyDisEn_NCDF_ms(x,m,nc,mu,sigma,tau,type) 2 | % 3 | % This function calculates Fuzzy dispersion entropy (FuzzyDisEn) 4 | % of a univariate using normal cumulative distribution function (NCDF) with defined mean (mu) and standard deviation (sigma) values. 5 | % 6 | % Inputs: 7 | % 8 | % x: univariate signal - a vector of size 1 x N (the number of sample points) 9 | % m: embedding dimension 10 | % nc: number of classes (it is usually equal to a number between 3 and 9 - we used c=6 in our studies) 11 | % tau: time lag (it is usually equal to 1) 12 | % type : select MFDE or MCRFDE (MFDE : 0, MCRFDE : 1) 13 | % 14 | % Outputs: 15 | % 16 | % Out_FuzzyDisEn: scalar quantity - the FuzzyDisEn of x 17 | % npdf: a vector of length nc^m, showing the normalized number of disersion patterns of x 18 | 19 | 20 | %% 21 | % 22 | N=length(x); 23 | y=normcdf(x,mu,sigma); 24 | 25 | for i_N=1:N 26 | if y(i_N)==1 27 | y(i_N)=1-(1e-10); 28 | end 29 | 30 | if y(i_N)==0 31 | y(i_N)=(1e-10); 32 | end 33 | end 34 | 35 | z = y*nc+0.5; 36 | 37 | for k=1:nc 38 | if(k==1 || k==nc) 39 | for r=1:N 40 | u_M(k,r) = trapezoidal_MF(k, z(r), nc); 41 | end 42 | else 43 | for r=1:N 44 | u_M(k,r) = triangle_MF(k, z(r)); 45 | end 46 | end 47 | end 48 | 49 | v=nan*ones(nc^m,m); 50 | u=1; 51 | for k=1:m 52 | a = repmat(1:nc,nc^(k-1),1); 53 | temp_a = reshape(a,[],1); 54 | v(:,m-k+1) = repmat(temp_a,nc^(m-k),1); 55 | end 56 | 57 | u_pi = ones(nc^m,N-(m-1)*tau); 58 | for s=1:nc^m 59 | for j=1:N-(m-1)*tau 60 | for i=1:m 61 | u_pi(s,j) = u_pi(s,j) * u_M(v(s,i),j+(i-1)*tau); 62 | end 63 | end 64 | end 65 | 66 | u_pi_sum = zeros(1,nc^m); 67 | for s=1:nc^m 68 | u_pi_sum(s) = sum(u_pi(s,:)); 69 | end 70 | 71 | npdf = u_pi_sum / (N-(m-1)*tau); 72 | 73 | 74 | switch sign(type) 75 | case 0 76 | p=npdf(npdf~=0); 77 | Out_FuzzyDisEn = -sum(p .* log(p)); 78 | case 1 79 | cmf = cumulativeFunc(npdf); 80 | rsd_cmf = zeros(1,length(cmf)); 81 | rsd_cmf = 1-cmf(1:end); 82 | rsd = rsd_cmf(rsd_cmf ~= 0); 83 | % save npdf; 84 | Out_FuzzyDisEn = -sum(rsd .* log(rsd)); 85 | %Out_DisEn 86 | otherwise 87 | fprint('ERROR : Used undefined type') 88 | end 89 | 90 | 91 | -------------------------------------------------------------------------------- /matlab_version/main_feature_extraction.m: -------------------------------------------------------------------------------- 1 | %% Extract Features using various entropy methods 2 | 3 | scale = 25; 4 | 5 | % Set parameters for entropy functions 6 | m=3; % Embedded dimension 7 | c=6; % Num of class 8 | tau = 1; % Num of delay hyperparameter 9 | dim =3; % Embedded Dim of Permutation Entropy 10 | 11 | % CHF 12 | for i=1:size(RRIs_CHF,1) 13 | 14 | %Dispersion Entropy 15 | mdeCHF(i,:) = MDE(RRIs_CHF(i,1:pts),m,c,tau,scale); 16 | %Cumulative Residual Dispersion Entropy 17 | mcrdeCHF(i,:) = MCRDE(RRIs_CHF(i,1:pts),m,c,tau,scale); 18 | %Sample Entropy 19 | mseCHF(i,:) = MSE_mu(RRIs_CHF(i,1:pts),2, 0.015,tau,scale); 20 | %Permutation Entropy 21 | for sc = 1:scale 22 | scaledDt = multiScale(RRIs_CHF(i,1:pts), sc); 23 | mpeCHF(i,sc) = pe(scaledDt, dim, tau); 24 | end 25 | end 26 | 27 | avg_mde_chf = mean(mdeCHF,1); err_mde_chf = std(mdeCHF,0,1); 28 | avg_mcrde_chf = mean(mcrdeCHF,1); err_mcrde_chf = std(mcrdeCHF,0,1); 29 | avg_mse_chf = mean(mseCHF,1); err_mse_chf = std(mseCHF,0,1); 30 | avg_mpe_chf = mean(mpeCHF,1); err_mpe_chf = std(mpeCHF,0,1); 31 | 32 | % AF 33 | for i=1:size(RRIs_AF,1) 34 | %Dispersion Entropy 35 | mdeAF(i,:) = MDE(RRIs_AF(i,1:pts),m,c,tau,scale); 36 | %Cumulative Residual Dispersion Entropy 37 | mcrdeAF(i,:) = MCRDE(RRIs_AF(i,1:pts),m,c,tau,scale); 38 | %Sample Entropy 39 | mseAF(i,:) = MSE_mu(RRIs_AF(i,1:pts),2, 0.015,tau,scale); 40 | %Permutation Entropy 41 | for sc = 1:scale 42 | scaledDt = multiScale(RRIs_AF(i,1:pts), sc); 43 | mpeAF(i,sc) = pe(scaledDt, dim, tau); 44 | end 45 | end 46 | 47 | avg_mde_af = mean(mdeAF,1); err_mde_af = std(mdeAF,0,1); 48 | avg_mcrde_af = mean(mcrdeAF,1); err_mcrde_af = std(mcrdeAF,0,1); 49 | avg_mse_af = mean(mseAF,1); err_mse_af = std(mseAF,0,1); 50 | avg_mpe_af = mean(mpeAF,1); err_mpe_af = std(mpeAF,0,1); 51 | 52 | % HEALTHY 53 | for i=1:size(RRIs_HEALTHY,1) 54 | %Diseprsion Entropy 55 | mdeHEALTHY(i,:) = (MDE(RRIs_HEALTHY(i,1:pts),m,c,tau,scale)); 56 | %Cumulative Residual Diseprsion Entropy 57 | mcrdeHEALTHY(i,:) = (MCRDE(RRIs_HEALTHY(i,1:pts),m,c,tau,scale)); 58 | %Sample Entropy 59 | mseHEALTHY(i,:) = MSE_mu(RRIs_HEALTHY(i,1:pts),2, 0.015,tau,scale); 60 | %Permutation Entropy 61 | for sc = 1:scale 62 | scaledDt = multiScale(RRIs_HEALTHY(i,1:pts), sc); 63 | mpeHEALTHY(i,sc) = pe(scaledDt, dim, tau); 64 | end 65 | end 66 | 67 | avg_mde_healthy = mean(mdeHEALTHY,1); err_mde_healthy = std(mdeHEALTHY,0,1); 68 | avg_mcrde_healthy = mean(mcrdeHEALTHY,1); err_mcrde_healthy = std(mcrdeHEALTHY,0,1); 69 | avg_mse_healthy = mean(mseHEALTHY,1); err_mse_healthy = std(mseHEALTHY,0,1); 70 | avg_mpe_healthy = mean(mpeHEALTHY,1); err_mpe_healthy = std(mpeHEALTHY,0,1); 71 | -------------------------------------------------------------------------------- /matlab_version/DisEn_NCDF_ms.m: -------------------------------------------------------------------------------- 1 | function [Out_DisEn, npdf]=DisEn_NCDF_ms(x,m,nc,mu,sigma,tau,type) 2 | % 3 | % This function calculates dispersion entropy (DisEn) using normal cumulative distribution function (NCDF) with defined mean (mu) and standard deviation (sigma) values. 4 | % 5 | % Inputs: 6 | % 7 | % x: univariate signal - a vector of size 1 x N (the number of sample points) 8 | % m: embedding dimension 9 | % nc: number of classes (it is usually equal to a number between 3 and 9 - we used c=6 in our studies) 10 | % tau: time lag (it is usually equal to 1) 11 | % type : select MDE or MCRDE (MDE : 0, MCRDE : 1) 12 | % 13 | % Outputs: 14 | % 15 | % Out_DisEn: scalar quantity - the DisEn of x 16 | % npdf: a vector of length nc^m, showing the normalized number of disersion patterns of x 17 | % 18 | % Ref: 19 | % 20 | % [1] H. Azami, M. Rostaghi, D. Abasolo, and J. Escudero, "Refined Composite Multiscale Dispersion Entropy and its Application to Biomedical 21 | % Signals", IEEE Transactions on Biomedical Engineering, 2017. 22 | % [2] M. Rostaghi and H. Azami, "Dispersion Entropy: A Measure for Time-Series Analysis", IEEE Signal Processing Letters. vol. 23, n. 5, pp. 610-614, 2016. 23 | % 24 | % If you use the code, please make sure that you cite references [1] and [2]. 25 | % 26 | % Hamed Azami, Mostafa Rostaghi, and Javier Escudero Rodriguez 27 | % hamed.azami@ed.ac.uk, rostaghi@yahoo.com, and javier.escudero@ed.ac.uk 28 | % 29 | % 20-January-2017 30 | %% 31 | N=length(x); 32 | 33 | y=normcdf(x,mu,sigma); 34 | 35 | for i_N=1:N 36 | if y(i_N)==1 37 | y(i_N)=1-(1e-10); 38 | end 39 | 40 | if y(i_N)==0 41 | y(i_N)=(1e-10); 42 | end 43 | end 44 | 45 | z=round(y*nc+0.5); 46 | 47 | all_patterns=[1:nc]'; 48 | 49 | for f=2:m 50 | temp=all_patterns; 51 | all_patterns=[]; 52 | j=1; 53 | for w=1:nc 54 | [a,b]=size(temp); 55 | all_patterns(j:j+a-1,:)=[temp,w*ones(a,1)]; 56 | j=j+a; 57 | end 58 | end 59 | 60 | for i=1:nc^m 61 | key(i)=0; 62 | for ii=1:m 63 | key(i)=key(i)*10+all_patterns(i,ii); 64 | end 65 | end 66 | % key 67 | % key = sort(key); 68 | 69 | embd2=zeros(N-(m-1)*tau,1); 70 | for i = 1:m, 71 | embd2=[z(1+(i-1)*tau:N-(m-i)*tau)]'*10^(m-i)+embd2; 72 | end 73 | 74 | pdf=zeros(1,nc^m); 75 | 76 | for id=1:nc^m 77 | [R,C]=find(embd2==key(id)); 78 | pdf(id)=length(R); 79 | end 80 | 81 | npdf=pdf/(N-(m-1)*tau); 82 | 83 | switch sign(type) 84 | case 0 85 | p=npdf(npdf~=0); 86 | Out_DisEn = -sum(p .* log(p)); 87 | case 1 88 | cmf = cumulativeFunc(npdf); 89 | rsd_cmf = zeros(1,length(cmf)); 90 | rsd = rsd_cmf(rsd_cmf ~= 0); 91 | rsd2 = rsd(rsd ~=1); 92 | % save npdf; 93 | Out_DisEn = -sum(rsd2 .* log(rsd2)); 94 | otherwise 95 | fprint('ERROR : Used undefined type') 96 | end 97 | 98 | -------------------------------------------------------------------------------- /matlab_version/DisEn_NCDF.m: -------------------------------------------------------------------------------- 1 | function [Out_DisEn, npdf]=DisEn_NCDF(x,m,nc,tau,type) 2 | % 3 | % This function calculates dispersion entropy (DisEn) of a univariate 4 | % signal x, using normal cumulative distribution function (NCDF) 5 | % 6 | % Inputs: 7 | % 8 | % x: univariate signal - a vector of size 1 x N (the number of sample points) 9 | % m: embedding dimension 10 | % nc: number of classes (it is usually equal to a number between 3 and 9 - we used c=6 in our studies) 11 | % tau: time lag (it is usually equal to 1) 12 | % type : select MDE or MCRDE (MDE : 0, MCRDE : 1) 13 | % 14 | % Outputs: 15 | % 16 | % Out_DisEn: scalar quantity - the DisEn of x 17 | % npdf: a vector of length nc^m, showing the normalized number of disersion patterns of x 18 | % 19 | % Ref: 20 | % 21 | % [1] H. Azami, M. Rostaghi, D. Abasolo, and J. Escudero, "Refined Composite Multiscale Dispersion Entropy and its Application to Biomedical 22 | % Signals", IEEE Transactions on Biomedical Engineering, 2017. 23 | % [2] M. Rostaghi and H. Azami, "Dispersion Entropy: A Measure for Time-Series Analysis", IEEE Signal Processing Letters. vol. 23, n. 5, pp. 610-614, 2016. 24 | % 25 | % If you use the code, please make sure that you cite references [1] and [2]. 26 | % 27 | % Hamed Azami, Mostafa Rostaghi, and Javier Escudero Rodriguez 28 | % hamed.azami@ed.ac.uk, rostaghi@yahoo.com, and javier.escudero@ed.ac.uk 29 | % 30 | % 20-January-2017 31 | 32 | %% 33 | % 34 | N=length(x); 35 | sigma=std(x); 36 | mu=mean(x); 37 | y=normcdf(x,mu,sigma); 38 | 39 | for i_N=1:N 40 | if y(i_N)==1 41 | y(i_N)=1-(1e-10); 42 | end 43 | 44 | if y(i_N)==0 45 | y(i_N)=(1e-10); 46 | end 47 | end 48 | 49 | z=round(y*nc+0.5); 50 | 51 | all_patterns=[1:nc]'; 52 | 53 | for f=2:m 54 | temp=all_patterns; 55 | all_patterns=[]; 56 | j=1; 57 | for w=1:nc 58 | [a,b]=size(temp); 59 | all_patterns(j:j+a-1,:)=[temp,w*ones(a,1)]; 60 | j=j+a; 61 | end 62 | end 63 | 64 | for i=1:nc^m 65 | key(i)=0; 66 | for ii=1:m 67 | key(i)=key(i)*10+all_patterns(i,ii); 68 | end 69 | end 70 | 71 | 72 | embd2=zeros(N-(m-1)*tau,1); 73 | for i = 1:m, 74 | embd2=[z(1+(i-1)*tau:N-(m-i)*tau)]'*10^(m-i)+embd2; 75 | end 76 | 77 | pdf=zeros(1,nc^m); 78 | 79 | for id=1:nc^m 80 | [R,C]=find(embd2==key(id)); 81 | pdf(id)=length(R); 82 | end 83 | 84 | 85 | npdf=pdf/(N-(m-1)*tau); 86 | 87 | switch sign(type) 88 | case 0 89 | p=npdf(npdf~=0); 90 | Out_DisEn = -sum(p .* log(p)); 91 | case 1 92 | cmf = cumulativeFunc(npdf); 93 | rsd_cmf = zeros(1,length(cmf)); 94 | rsd_cmf = cmf(end)-cmf(1:end); 95 | rsd = rsd_cmf(rsd_cmf ~= 0); 96 | rsd2 = rsd(rsd ~=1); 97 | % save npdf; 98 | Out_DisEn = -sum(rsd2 .* log(rsd2)); 99 | otherwise 100 | fprint('ERROR : Used undefined type') 101 | end 102 | 103 | -------------------------------------------------------------------------------- /python_version/entropy/DisEn_NCDF_ms.py: -------------------------------------------------------------------------------- 1 | ######################################################################################## 2 | 3 | # This function calculates dispersion entropy (DisEn) of a univariate 4 | # signal x, using normal cumulative distribution function (NCDF) 5 | # 6 | # Inputs: 7 | # 8 | # x: univariate signal - a vector of size 1 x N (the number of sample points) 9 | # m: embedding dimension 10 | # nc: number of classes (it is usually equal to a number between 3 and 9 - we used c=6 in our studies) 11 | # tau: time lag (it is usually equal to 1) 12 | # type : select MDE or MCRDE (MDE : 0, MCRDE : 1) 13 | # 14 | # Outputs: 15 | # 16 | # Out_DisEn: scalar quantity - the DisEn of x 17 | # npdf: a vector of length nc^m, showing the normalized number of disersion patterns of x 18 | 19 | ######################################################################################## 20 | 21 | import numpy as np 22 | from scipy.stats import norm 23 | from .cumulativeFunc import cumulativeFunc 24 | 25 | 26 | def DisEn_NCDF_ms(x,m,nc,mu,sigma,tau,Type): 27 | 28 | N = len(x) 29 | # x mapping NCDF 30 | y = norm.cdf(x, loc=mu, scale=sigma) 31 | 32 | for i_N in range(N): 33 | 34 | if y[i_N] == 1: 35 | y[i_N] = 1 - np.exp(-10) 36 | if y[i_N] == 0: 37 | y[i_N] = np.exp(-10) 38 | 39 | z = np.rint(y*nc + 0.5) 40 | l = np.arange(1,nc+1) 41 | all_patterns = l[:,np.newaxis] 42 | 43 | 44 | for f in range(1,m): 45 | temp = all_patterns 46 | all_patterns = np.array([]) 47 | j=0 48 | for w in range(nc): 49 | [a,b] = temp.shape 50 | if w==0: 51 | all_patterns = np.append(temp, (w+1)*np.ones((a,1)), axis=1) 52 | else: 53 | all_patterns = np.append(all_patterns, 54 | np.append(temp, (w+1)*np.ones((a,1)), axis=1), 55 | axis=0) 56 | j = j+a 57 | 58 | 59 | key = [] 60 | for i in range(nc**m): 61 | key = np.append(key, 0) 62 | for i_r in range(m): 63 | key[i] = key[i]*10 + all_patterns[i,i_r] 64 | 65 | embd2 = np.zeros((N-(m-1)*tau,1)) 66 | for i in range(m): 67 | a = z[i*tau:N-(m-i-1)*tau] 68 | a_T = a[:,np.newaxis] 69 | embd2 = a_T * 10**(m-i-1) + embd2 70 | 71 | 72 | pdf = np.zeros((1,nc**m)) 73 | 74 | for id in range(nc**m): 75 | [R,C] = np.where(embd2==key[id]) 76 | pdf[0][id] = len(R) 77 | 78 | npdf = pdf / (N-(m-1)*tau) 79 | 80 | Out_DisEn = 0 81 | # if type=0, MDE 82 | if np.sign(Type) == 0: 83 | p = npdf[npdf != 0] 84 | Out_DisEn = -np.sum(np.dot(p,np.log(p))) 85 | 86 | # if type=1, MCRDE 87 | elif np.sign(Type) == 1: 88 | cmf = cumulativeFunc(npdf) 89 | rsd_cmf = np.zeros((1,len(cmf))) 90 | rsd_cmf = 1 - cmf[0][:] 91 | rsd = rsd_cmf[rsd_cmf != 0] 92 | # save npdf 93 | Out_DisEn = -np.sum(np.dot(rsd,np.log(np.abs(rsd)))) 94 | else: 95 | print('Error: Undefined type') 96 | 97 | 98 | return Out_DisEn -------------------------------------------------------------------------------- /python_version/entropy/DisEn_NCDF.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Nov 17 01:30:26 2021 4 | 5 | ######################################################################################## 6 | """ 7 | # This function calculates dispersion entropy (DisEn) of a univariate 8 | # signal x, using normal cumulative distribution function (NCDF) 9 | # 10 | # Inputs: 11 | # 12 | # x: univariate signal - a vector of size 1 x N (the number of sample points) 13 | # m: embedding dimension 14 | # nc: number of classes (it is usually equal to a number between 3 and 9 - we used c=6 in our studies) 15 | # tau: time lag (it is usually equal to 1) 16 | # type : select MDE or MCRDE (MDE : 0, MCRDE : 1) 17 | # 18 | # Outputs: 19 | # 20 | # Out_DisEn: scalar quantity - the DisEn of x 21 | # npdf: a vector of length nc^m, showing the normalized number of disersion patterns of x 22 | 23 | ######################################################################################## 24 | 25 | import numpy as np 26 | from scipy.stats import norm 27 | from .cumulativeFunc import cumulativeFunc 28 | 29 | 30 | def DisEn_NCDF(x,m,nc,tau,Type): 31 | 32 | N = len(x) 33 | sigma = np.std(x) 34 | mu = np.mean(x) 35 | 36 | # x mapping NCDF 37 | y = norm.cdf(x, loc=mu, scale=sigma) 38 | 39 | for i_N in range(N): 40 | 41 | if y[i_N] == 1: 42 | y[i_N] = 1 - np.exp(-10) 43 | if y[i_N] == 0: 44 | y[i_N] = np.exp(-10) 45 | 46 | z = np.rint(y*nc + 0.5) 47 | l = np.arange(1,nc+1) 48 | all_patterns = l[:,np.newaxis] 49 | 50 | 51 | for f in range(1,m): 52 | temp = all_patterns 53 | all_patterns = np.array([]) 54 | j=0 55 | for w in range(nc): 56 | [a,b] = temp.shape 57 | if w==0: 58 | all_patterns = np.append(temp, (w+1)*np.ones((a,1)), axis=1) 59 | else: 60 | all_patterns = np.append(all_patterns, 61 | np.append(temp, (w+1)*np.ones((a,1)), axis=1), 62 | axis=0) 63 | j = j+a 64 | 65 | key = [] 66 | for i in range(nc**m): 67 | key = np.append(key, 0) 68 | for i_r in range(m): 69 | key[i] = key[i]*10 + all_patterns[i,i_r] 70 | 71 | embd2 = np.zeros((N-(m-1)*tau,1)) 72 | for i in range(m): 73 | a = z[i*tau:N-(m-i-1)*tau] 74 | a_T = a[:,np.newaxis] 75 | embd2 = a_T * 10**(m-i-1) + embd2 76 | 77 | 78 | pdf = np.zeros((1,nc**m)) 79 | 80 | for id in range(nc**m): 81 | [R,C] = np.where(embd2==key[id]) 82 | pdf[0][id] = len(R) 83 | 84 | npdf = pdf / (N-(m-1)*tau) 85 | 86 | Out_DisEn = 0 87 | 88 | # if type=0, MDE 89 | if np.sign(Type) == 0: 90 | p = npdf[npdf != 0] 91 | Out_DisEn = -np.sum(np.dot(p,np.log(p))) 92 | 93 | # if type=1, MCRDE 94 | elif np.sign(Type) == 1: 95 | cmf = cumulativeFunc(npdf) 96 | rsd_cmf = np.zeros((1,len(cmf))) 97 | rsd_cmf = 1 - cmf[0][:] 98 | rsd = rsd_cmf[rsd_cmf != 0] 99 | # save ncpdf 100 | Out_DisEn = -np.sum(np.dot(rsd,np.log(np.abs(rsd)))) 101 | else: 102 | print('Error: Undefined type') 103 | 104 | return Out_DisEn -------------------------------------------------------------------------------- /python_version/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from scipy import io 3 | from scipy.stats import ranksums 4 | 5 | from MCRDE.MCRDE import MCRDE 6 | 7 | from utils.plot_Entropy import plot_Entropy 8 | from utils.write_txt import write_txt 9 | 10 | 11 | RRIs_CHF_path = './sample_data/RRIs_CHF_1000' # CHF(= Congestive Heart Failure) -> 울혈성 심부전 피험자 14명의 RRIs data 12 | RRIs_HEALTHY_path = './sample_data/RRIs_HEALTHY_1000' # HEALTHY -> 건강한 피험자 14명 RRIs data 13 | 14 | avg_mcrde_chf_path = './results/avg_mcrde_chf.txt' # path of CHF subjects MCRDE avg data 15 | avg_mcrde_healthy_path = './results/avg_mcrde_healthy.txt' # path of HEALTHY subjects MCRDE avg data 16 | std_mcrde_chf_path = './results/std_mcrde_chf.txt' # path of CHF subjects MCRDE std data 17 | std_mcrde_healthy_path = './results/std_mcrde_healthy.txt' # path of HEALTHY subjects MCRDE std data 18 | 19 | # MCRDE parameters 20 | N = 1000 # RRIs data length 21 | m = 3 # embeding dimension 22 | c = 6 # number of class 23 | tau = 1 # delay factor 24 | scale = 25 # scale factor 25 | 26 | # plot parameters 27 | show_fig = True # plot draw flag 28 | subject = np.array(['CHF', 'HEALTHY']) # 비교군: CHF, Healthy subject 29 | plt_color = np.array(['red','blue']) # CHF MCRDE plot: 빨간색, Healthy MCRDE plot: 파란색 30 | 31 | ### Sample data 32 | 33 | # Load RRIs data(type:numpy array, row:subjects, col:RRIs data of subjects) 34 | # CHF data 35 | RRIs_CHF_data = io.loadmat(RRIs_CHF_path) 36 | RRIs_CHF_1000 = RRIs_CHF_data['RRIs_CHF_1000'] # Load RRIs data of CHF(length=1000) 37 | 38 | # Healthy data 39 | RRIs_HEALTHY_data = io.loadmat(RRIs_HEALTHY_path) 40 | RRIs_HEALTHY_1000 = RRIs_HEALTHY_data['RRIs_HEALTHY_1000'] # Load RRIs data of HEALTHY(length=1000) 41 | 42 | n_s = len(RRIs_CHF_1000[:,0]) # number of subject(CHF,HEALTHY) 43 | 44 | ### output data 45 | 46 | # MCRDE about RRIs datas of CHF subjects 47 | mcrde_chf = np.zeros((n_s, scale)) # row: subject, col: scale 48 | # MCRDE about RRIs datas of Healthy subjects 49 | mcrde_healthy = np.zeros((n_s, scale)) # row: subject, col: scale 50 | 51 | 52 | ### Calculate MultiScale Entropy, p-value(Wilcoxon rank sum test) 53 | for i in range(n_s): 54 | 55 | # Calculate MCRDE about RRIs data of CHF subjects 56 | mcrde_chf[i] = MCRDE(RRIs_CHF_1000[i, :N], m, c, tau, scale) 57 | # Calculate MCRDE about RRIs data of Healthy subjects 58 | mcrde_healthy[i] = MCRDE(RRIs_HEALTHY_1000[i, :N], m, c, tau, scale) 59 | 60 | 61 | # Calculate MCRDE average value 62 | avg_mcrde_chf = np.mean(mcrde_chf, axis=0) 63 | avg_mcrde_healthy = np.mean(mcrde_healthy, axis=0) 64 | 65 | 66 | # Calculate MCRDE std value 67 | std_mcrde_chf = np.std(mcrde_chf, axis=0) 68 | std_mcrde_healthy = np.std(mcrde_healthy, axis=0) 69 | 70 | 71 | # Calculate p-value(between CHF and Healthy subjects) 72 | # p-value<0.05은 두 데이터(CHF, Healthy)가 서로 독립적인(=유의미한) 데이터라는 것을 보여준다. 73 | pCHF_HT = np.zeros(scale) # p-value between CHF and Healthy subjects(scale 1~25) 74 | for i in range(scale): 75 | s, pCHF_HT[i] = ranksums(mcrde_chf[:,i],mcrde_healthy[:,i]) 76 | 77 | 78 | 79 | ### MCRDE 평균, 표준편차 출력 파일을 text 파일에 저장한다. 80 | # CHF, Healthy subjects는 각각 모두 14명이다. 81 | # MultiScale Entropy method를 통해 scale(1~25)에서의 14명의 Entropy 평균, 표준 편차를 구한다. 82 | # 사용한 Entropy 기법은 MultiScale Cumulative Residual Dispersion Entropy이다. 83 | # index: scale, data: avg, std 84 | 85 | write_txt(avg_mcrde_chf_path, avg_mcrde_healthy_path, 86 | std_mcrde_chf_path, std_mcrde_healthy_path, 87 | avg_mcrde_chf, avg_mcrde_healthy, 88 | std_mcrde_chf, std_mcrde_healthy ) 89 | 90 | # show the result figure 91 | if show_fig == True: 92 | Entropy = plot_Entropy(subject,plt_color, 93 | avg_mcrde_chf, 94 | avg_mcrde_healthy, 95 | std_mcrde_chf, 96 | std_mcrde_healthy, 97 | scale, 98 | pCHF_HT) 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | --------------------------------------------------------------------------------