Comments (6)
Hillebrand 2016 in fact states:
prediction delay δ was set as (Ns x Nch)/N±, with Ns and Nch the number of samples and channels (ROIs), respectively, and N± the number of times the phase changes sign across time and channels.
It seems to be a classical case of a magic number, which should have been documented. I will update the docs.
So, I shifted the time series by two, and dropped the first and last data point for the multiplication. For that reason, the number of samples is also reduced by 2. At this moment, it might be questionable what happens if a zero crossing appears right at the boundaries.
from pypte.
Perhaps it is advisable to look into other ways to compute the delay.
A convenience class will be provided by #3
from pypte.
But why shift it by 2 instead of 1?
from pypte.
You are right. The choice of the shift interval seems to be random. Bolzano's theorem says there is at least one zero-crossing if the signs of the interval boundaries differs.
The code was inspired by Hillebrand's Matlab implementation :
%% Compute delay (if required)
if isempty(delay)
% delay is based on the number of times the phase flips across time and channels, as in Brainwave (C.J. Stam)
counter1 = 0; counter2 = 0;
for j=1:N
for i=2:L-1
counter1 = counter1 + 1;
if (phase_data(i-1,j)-pi)*(phase_data(i+1,j)-pi)<0, % make sure phase is in range [-pi pi]
counter2 = counter2 + 1;
end; %if
end; %for
end; %for
delay = round(counter1/counter2);
end; %if;
I will leave this implementation, which conforms to Hillebrand and implement another zero-crossing method, additionally.
Thank you for pointing this out.
from pypte.
This will be picked up and unit-tests should be provided.
from pypte.
Shifting by 2 doesn't actually lead to double-counting zero-crossings, but I get why it's a bit off. I’m planning to switch it up to shifting by 1 to stick closer to what's generally expected for zero-crossing detection. Also, I'll stop dropping the first and last data points. It looks like the original method by Hillebrand dropped those points for simplicity's sake
from pypte.
Related Issues (17)
- Dimensions switched in documentation of code HOT 2
- Divide by zero in entropy calculations HOT 7
- Raise awareness on delay calculation HOT 1
- Raise awareness on issues and drawbacks by examples HOT 2
- Make use of numpy iterators in PTE calculation
- Update Readme, Documentation, gh-pages
- Publish code on PyPi
- Correctness of TE calculation
- Permutation testing? HOT 2
- IndexError HOT 3
- the definition of bin width HOT 7
- Delay Estimation Methods to Support Per-Channel Analysis and Explore More Robust Metrics
- Explore / implement more approaches to phase based TE
- Enhancements: NMM Examples, PTE Significance Testing, and More Sanity Checks
- Bug: Axes are switched HOT 8
- Semantic Release does not work in GH Actions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pypte.