Skip to content

Commit

Permalink
v2.0 Distribution (No Docs)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattWillFlood committed Apr 24, 2024
1 parent 1d55f68 commit bc1288b
Show file tree
Hide file tree
Showing 12 changed files with 1,427 additions and 59 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "EntropyHub"
uuid = "3938faea-3bfa-4bc3-8092-0c6746ff9af1"
authors = ["Matthew W. Flood <[email protected]>"]
version = "1.0.1"
version = "2.0"

[deps]
Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5"
Expand All @@ -13,6 +13,7 @@ FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
GroupSlices = "d853e229-7c7c-56e9-b6be-9a1acc5f13d9"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Expand All @@ -22,8 +23,8 @@ StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
[compat]
Clustering = "0.14.2"
Combinatorics = "1.0.2"
DataInterpolations = "4.6.0"
DSP = "0.6.8"
DataInterpolations = "4.6.0"
FFTW = "1.8"
GroupSlices = "0.0.3"
HTTP = "0.9.17"
Expand Down
108 changes: 58 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,27 @@ __*Julia Edition*__


## Latest Update
### v1.0
__*----- New entropy methods -----*__
Two new base entropy functions (and their multiscale versions) have been added:
> [Diversity Entropy](https://ieeexplore.ieee.org/document/9194995)
> [Range Entropy](https://www.mdpi.com/1099-4300/20/12/962)

__*----- New fuzzy membership functions -----*__
Several new fuzzy membership functions have been added to FuzzEn, XFuzzEn and FuzzEn2D to provide more options for mapping the degree of similarity between embedding vectors.
These include *trapezoidal*, *triangular* and *gaussian*, among others.
Further info on these membership functions can be found [here.](https://hal.science/hal-02267711/document)

__*----- Phase Permutation Entropy -----*__
A new variant - '*phase*' permutation entropy - has been added to PermEn.
This method employs a hilbert transformation of the data sequence, based on the methods outlined [here.](https://doi.org/10.1016/j.physa.2020.125686)

__*----- Cross-Entropy with different length sequences -----*__
EntropyHub v1.0 now allows for cross-entropy (and multiscale cross-entropy) estimation with different length signals (_except XCondEn and XPermEn_).
As a result, the new cross-entropy functions require a separate input for each sequence (Sig1, Sig2).

__*----- Refined-Composite Multiscale Fuzzy Entropy -----*__
In addition to the refined-composite multiscale sample entropy that was available in earlier versions, now one can estimate the refined-composite multiscale fuzzy entropy based on the method outlined [here.](https://link.springer.com/article/10.1007/s11517-017-1647-5)
What's more, refined-composite multicale cross-fuzzy entropy is also available, and both can be estimated using any of the fuzzy membership functions in FuzzEn or XFuzzEn.

__*----- Generalized Multiscale Entropy -----*__
Generaized multiscale entropy and generalized multiscale cross-entropy can now be estimated. Just choose the '*generalized*' as the graining procedure in MSEn or XMSEn.

__*----- Variance of sample entropy estimate -----*__
Based on the [method outlined by Lake et al.,](https://journals.physiology.org/doi/epdf/10.1152/ajpregu.00069.2002) it is now possible to obtain a measure of the variance in the sample entropy estimate.
This is achieved by approximating the number of overlapping embedding vectors.
To do so, just set the parameter '*Vcp*'==true in SampEn and XSampEn, but note that doing so requires *a lot* of computer memory.

*Several little bugs and inconsistencies have also been fixed in this release. We want to thank all of you who have identified and alerted us to these bugs.*
*Most of these bugs have been noted via the [GitHub issues portal](https://github.com/MattWillFlood/EntropyHub/issues).*

__*----- Bug fixes -----*__
- The DispEn2D function in python has now fixed [this issue](https://github.com/MattWillFlood/EntropyHub/issues/8).
- The type hint for FuzzEn in python has been updated [as requested](https://github.com/MattWillFlood/EntropyHub/issues/1).
- [Compatbility issues with EntropyHub.jl](https://github.com/MattWillFlood/EntropyHub.jl/issues/3) are now resolved.
- A bug in the K2En python function led to incorrect entropy estimates for data sequences with many equal values. This has been corrected.

__*----- Other Changes -----*__
- The *'equal'* method for discretizing data in DispEn and DispEn2D has been updated to be consistent across Python, MatLab and Julia. This is unlikely to have impacted any users previously.
- The zeroth dimension (m=0) estimate of ApEn and XApEn has been changed to -phi(1).
- The default radius threshold distance for XApEn, XSampEn and XK2En has been changed to use the *pooled* standard deviation [i.e. 0.2*SDpooled(X,Y)].
### v2.0
__*----- New multivariate methods -----*__
Five new multivariate entropy functions incorporating several method-specific variations
> [Multivariate Sample Entropy](https://journals.aps.org/pre/abstract/10.1103/PhysRevE.84.061918)
> [Multivariate Fuzzy Entropy](https://www.mdpi.com/1099-4300/19/1/2) [++ many fuzzy functions]
> [Multivariate Dispersion Entropy](https://www.mdpi.com/1099-4300/21/9/913) [++ many symbolic sequence transforms]
> [Multivariate Cosine Similarity Entropy](https://www.mdpi.com/1099-4300/24/9/1287)
> Multivariate Permutation Entropy [++ *amplitude-aware*, *edge*, *phase*, *weighted* and *modified* variants]

__*----- New multivariate multiscale methods -----*__
Two new multivariate multiscale entropy functions
> [Multivariate Multiscale Entropy](https://journals.aps.org/pre/abstract/10.1103/PhysRevE.84.061918) [++ coarse, modified and generalized graining procedures]
> [Composite and Refined-composite Multivariate Multiscale Entropy](https://link.springer.com/article/10.1007/s11517-017-1647-5)

__*----- Extra signal processing tools -----*__
**WindowData()** is a new function that allows users to segment data (univariate or multivariate time series) into windows with/without overlapping samples! This allows users to calculate entropy on subsequences of their data to perform analyses with greater time resolution.

*Other little fixes...*

__*----- Docs edits -----*__
- Examples in the www.EntropyHub.xyz documentation were updated to match the latest package syntax.


## Welcome
Expand Down Expand Up @@ -151,13 +128,16 @@ All information on the EntropyHub package is detailed in the *EntropyHub Guide*,

## Functions

EntropyHub functions fall into 5 categories:
EntropyHub functions fall into 8 categories:

* Base functions for estimating the entropy of a single univariate time series.
* Cross functions for estimating the entropy between two univariate time series.
* Bidimensional functions for estimating the entropy of a two-dimensional univariate matrix.
* Multiscale functions for estimating the multiscale entropy of a single univariate time series using any of the Base entropy functions.
* Multiscale Cross functions for estimating the multiscale entropy between two univariate time series using any of the Cross-entropy functions.
* Base functions for estimating the entropy of a single univariate time series.
* Cross functions for estimating the entropy between two univariate time series.
* Multivariate functions for estimating the entropy of a multivariate dataset.
* Bidimensional functions for estimating the entropy of a two-dimensional univariate matrix.
* Multiscale functions for estimating the multiscale entropy of a single univariate time series using any of the Base entropy functions.
* Multiscale Cross functions for estimating the multiscale entropy between two univariate time series using any of the Cross-entropy functions.
* Multivariate Multiscale functions for estimating the multivariate multiscale entropy of multivariate dataset using any of the Multivariate-entropy functions.
* Other Supplementary functions for various tasks related to EntropyHub and signal processing.

#### The following tables outline the functions available in the EntropyHub package.

Expand Down Expand Up @@ -206,6 +186,18 @@ Cross Kolmogorov Entropy | XK2En

_______________________________________________________________________

### Multivariate Entropies:

Entropy Type | Function Name
--|--
Multivariate Sample Entropy | MvSampEn
Multivariate Fuzzy Entropy | MvFuzzEn
Multivariate Permutation Entropy | MvPermEn
Multivariate Dispersion Entropy | MvDispEn
Multivariate Cosine Similarity Entropy | MvCoSiEn

_______________________________________________________________________

### Bidimensional Entropies

Entropy Type | Function Name
Expand Down Expand Up @@ -238,8 +230,24 @@ Composite/Refined-Composite Multiscale Cross-Entropy | cXMSEn
Refined Multiscale Cross-Entropy | rXMSEn
Hierarchical Multiscale Cross-Entropy | hXMSEn

_________________________________________________________________________

### Multivariate Multiscale Entropy Functions

Entropy Type | Function Name
--|--
Multivariate Multiscale Entropy | MvMSEn
Composite/Refined-Composite Multivariate Multiscale Entropy | cMvMSEn

_________________________________________________________________________

### Other Functions

Entropy Type | Function Name
--|--
Example Data Import Tool | ExampleData
Window Data Tool | WindowData
Multiscale Entropy Object | MSobject


## License and Terms of Use
Expand Down
46 changes: 45 additions & 1 deletion src/EntropyHub.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ export
XSpecEn,
XSampEn,

MvSampEn,
MvCoSiEn,
MvPermEn,
MvDispEn,
MvFuzzEn,

SampEn2D,
FuzzEn2D,
DistEn2D,
Expand All @@ -47,6 +53,8 @@ export
cXMSEn,
rXMSEn,
hXMSEn,
MvMSEn,
cMvMSEn,

EMD,
ExampleData,
Expand Down Expand Up @@ -105,6 +113,17 @@ include("./_DispEn2D.jl"),
include("./_PermEn2D.jl"),
include("./_EspEn2D.jl"),


include("./_MvSampEn.jl"),
include("./_MvFuzzEn.jl"),
include("./_MvDispEn.jl"),
include("./_MvPermEn.jl"),
include("./_MvCoSiEn.jl"),

include("./_MvMSEn.jl"),
include("./_cMvMSEn.jl"),


# Base Entropies:
using ._ApEn: ApEn
using ._AttnEn: AttnEn
Expand Down Expand Up @@ -137,6 +156,15 @@ using ._XPermEn: XPermEn
using ._XSampEn: XSampEn
using ._XSpecEn: XSpecEn


# Multivariate Entropies:
using ._MvSampEn: MvSampEn
using ._MvFuzzEn: MvFuzzEn
using ._MvCoSiEn: MvCoSiEn
using ._MvDispEn: MvDispEn
using ._MvPermEn: MvPermEn


# Bidimensional Entropies
using ._SampEn2D: SampEn2D
using ._DistEn2D: DistEn2D
Expand All @@ -145,7 +173,7 @@ using ._DispEn2D: DispEn2D
using ._PermEn2D: PermEn2D
using ._EspEn2D: EspEn2D

# (cross) Multiscale Entropies
# Multiscale Entropies
using ._MSobject: MSobject

using ._MSEn: MSEn, EMD
Expand All @@ -158,6 +186,11 @@ using ._cXMSEn: cXMSEn
using ._rXMSEn: rXMSEn
using ._hXMSEn: hXMSEn

using ._MvMSEn: MvMSEn
using ._cMvMSEn: cMvMSEn

# Other Functions

using ._ExampleData: ExampleData
using ._WindowData: WindowData

Expand Down Expand Up @@ -252,6 +285,15 @@ raw"""
Cross Spectral Entropy | XSpecEn
Cross Kolmogorov Entropy | XK2En
_________________________________________________________________________
Multivariate Entropies | Function Name
_____________________________________________________|___________________
Multivariate Sample Entropy | MvSampEn
Multivariate Fuzzy Entropy | MvFuzzEn
Multivariate Cosine Similarity Entropy | MvCoSiEn
Multivariate Dispersion Entropy | MvDispEn
Multivariate Permutation Entropy | MvPermEn
_________________________________________________________________________
Bidimensional Entropies | Function Name
_____________________________________________________|__________________
Expand Down Expand Up @@ -317,6 +359,8 @@ raw"""
Multiscale Cross-Conditional Entropy |
We kindly ask that if you use EntropyHub in your research, to please
include the following citation with the appropriate version number,
as well as original articles upon which functions are derived:
Expand Down
4 changes: 2 additions & 2 deletions src/_CoSiEn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ using LinearAlgebra: Diagonal, UpperTriangular
Num = Zm*transpose(Zm);
Mag = sqrt.(sum(Diagonal(Num),dims=1))[:]
Den = Mag*transpose(Mag)
AngDis = round.(acos.(round.(Num./Den,digits=6))/pi,digits=6)
AngDis = round.(acos.(round.(Num./Den,digits=8))/pi,digits=6)
if maximum(imag.(AngDis)) < (10^-5)
Bm = (sum(UpperTriangular(AngDis .< r))-Nx)/(Nx*(Nx-1)/2)
else
Bm = (sum(UpperTriangular(real.(AngDis) .< r))-Nx)/(Nx*(Nx-1)/2)
@warn("Complex values ignored.")
end
if Bm == 1 || Bm == 0
CoSi = 0
CoSi = NaN
else
CoSi = -(Bm*log(Logx, Bm)) - ((1-Bm)*log(Logx, 1-Bm))
end
Expand Down
19 changes: 15 additions & 4 deletions src/_MSobject.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,27 @@ export MSobject
`XDistEn` - Cross-Distribution Entropy \n
`XSpecEn` - Cross-Spectral Entropy \n
# See also `MSEn`, `XMSEn`, `rMSEn`, `cMSEn`, `hMSEn`, `rXMSEn`, `cXMSEn`, `hXMSEn`
# Multivariate Entropies:
------------------
`MvSampEn` - Multivariate Sample Entropy \n
`MvFuzzEn` - Multivariate Fuzzy Entropy \n
`MvPermEn` - Multivariate Permutation Entropy \n
`MvCoSiEn` - Multivariate Cosine Similarity Entropy \n
`MvDispEn` - Multivariate Dispersion Entropy \n
# See also `MSEn`, `XMSEn`, `MvMSEn`, `rMSEn`, `cMSEn`, `hMSEn`, `rXMSEn`, `cXMSEn`, `hXMSEn`, `cMvMSEn`
"""
function MSobject(EnType::Function=SampEn; kwargs...)
#function MSobject(EnType::Function= EntropyHub.SampEn; kwargs...)

Chk = ["ApEn";"SampEn";"FuzzEn";"K2En";"PermEn";"CondEn";"DistEn";"DivEn";
"DispEn";"SyDyEn";"IncrEn";"CoSiEn";"PhasEn";"SpecEn";"SlopEn";"RangEn";
"GridEn";"BubbEn";"EnofEn";"AttnEn";"XApEn";"XSampEn";"XFuzzEn";
"XPermEn";"XCondEn";"XDistEn";"XSpecEn";"XK2En"]
"GridEn";"BubbEn";"EnofEn";"AttnEn";
"XApEn";"XSampEn";"XFuzzEn";"XPermEn";
"XCondEn";"XDistEn";"XSpecEn";"XK2En";
"MvSampEn";"MvFuzzEn";"MvPermEn";
"MvCoSiEn";"MvDispEn"]
(String(Symbol(EnType)) in Chk) ? nothing :
error("EnType: must be a valid entropy function name.
For more info, type: julia> ? EntropyHub.MSobject")
Expand Down
Loading

0 comments on commit bc1288b

Please sign in to comment.