patrk / pypte Goto Github PK
View Code? Open in Web Editor NEWPythonic implementation of the Phase Transfer Entropy method using NumPy and SciPy
License: GNU General Public License v3.0
Pythonic implementation of the Phase Transfer Entropy method using NumPy and SciPy
License: GNU General Public License v3.0
Current situation
Delay estimation is a heuristic method suggested by Hillebrand, which computes an overall delay estimate across all channels in a measurement. This method calculates a single scalar value representing the delay based on the phase of the signals.
Goals
To improve delay estimation should explore additional metrics beyond the current heuristic.
Suggested metrics or concepts include:
AC:
Hi, thanks for implementing this.
I often get:
yPTE.py:153: RuntimeWarning: divide by zero encountered in log2
Would it be sensible here to add an infinitesimal for numerical stability?
self-explanatory
Hello,
Do you have any methods for implementing permutation testing to determine significance?
I saw the matrix_wilcoxon() function, but this appears run a single significance test between two connectivity matrices after the PTE has already been calculated.
Perhaps I misunderstand how the PTE is calculated, and shuffling is not necessary?
Thanks!
Refactor examples
Create notebook for all examples including explanations and visualize results
Thanks for the great code!
I just wanted to point out that the documentation incorrectly specifies the shape of input data to be (channels,samples), whereas all functions seem to expect the opposite; i.e. an array of shape (samples,channels).
A new version can be generated locally, but the release job in gh action does nothing
semantic release is run with poetry and is configured in pyproject.toml
Invite collaborators to review changes
Publish on PyPi
It seems that the program might throw out "IndexError" when calling np.add.at in pyPTE.PTE.
Just like:
line 143, in compute_PTE
np.add.at(P_y_x, [y, x], 1)
IndexError: index 4 is out of bounds for axis 0 with size 4
I printed the matrix, and found out this would happen when y and x didn't share the same maximum value that P_y_x was not square.
My numpy version is 1.26.0.
NMM Examples: include examples using Neural Mass Models to show how PTE can reproduce connectivity.
Significance Testing for PTE: make PTE results more reliable, implement significance testing. this will help users know if the connectivity patterns they see are statistically meaningful.
Expanded Sanity Testing: add more sanity tests to make sure new updates don't break anything. Use simple synthetic data with know expected results, kuramoto models, NMMs and / or open source brain connectivity data
Im trying to use your PTE calculation. At the entrance I have 19 channel array with 1000 elements each. I
m expecting to return 2 arrays 19x19 each with normalized/non normalized TE between each channel. But instead of this I have 2 arrays 1000x1000 elements each. Could you help me, what I`m doing wrong?
Attaching link to git https://github.com/Ku4eruk/tests_with_eeg/blob/main/test.py
Thanks
"Kernel-Based Phase Transfer Entropy with Enhanced Feature Relevance Analysis for Brain Computer Interfaces" - This paper introduces a method that combines kernel-based TE estimator and Renyi’s entropy. It’s designed for better feature relevance analysis in EEG signals. Could be a solid addition for more nuanced connectivity analysis.
"Measurement of information transfer based on phase increment transfer entropy (PITE)" - PITE offers a novel twist on assessing the information transfer by focusing on the phase increments, which could provide a more robust analysis in non-linear signal scenarios. This approach might shine new light on ADHD EEG signal analysis, offering a fresh perspective on information transfer.
"A modified phase transfer entropy for cross-frequency directed coupling estimation in brain network" - This paper suggests an improved PTE method that considers cross-frequency interactions, addressing multivariable effects and the curse of dimensionality. It’s something that could greatly benefit the analysis of complex cognitive processes.
def get_binsize(phase, c = 3.49):
"""
Computes the bin size for the phase binning
Parameters
----------
c : float
phase : numpy.ndarray
m x n ndarray : m: number of channels, n: number of samples
Returns
-------
bincount : float
"""
m, n = phase.shape
binsize = c * np.mean(np.std(phase, axis=0, ddof=1)) * m ** (-1.0 / 3)
return binsize
Hi,I want to confirm with you the definition of the bin width in your code. In paper “Phase transfer entropy: A novel phase-based measure for directed connectivity in networks coupled by oscillatory interactions”, the bin width is defined as h_j=3.5ϑ_j/N^(1/3) (Chapter: Method, Section: phase transfer entropy), and the N is defined as the number of samples. but in your code N is the number of channel. Could you please check this definition again and tell the reason?
Refactor code - object oriented
Introduce Abstract Base Class which enforces overriding delay calculation
Include default delay calculation in constructor
Currently, the docstrings and the logic of compute_PTE expect the data to be of shape (n_channels, n_samples). However, the rest of the code assumes that the data is (n_samples, n_channels). This usually results in an error.
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.