GithubHelp home page GithubHelp logo

Is get_delay correct? about pypte HOT 6 CLOSED

jshanna100 avatar jshanna100 commented on June 12, 2024
Is get_delay correct?

from pypte.

Comments (6)

patrk avatar patrk commented on June 12, 2024

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.

patrk avatar patrk commented on June 12, 2024

Perhaps it is advisable to look into other ways to compute the delay.

A convenience class will be provided by #3

from pypte.

jshanna100 avatar jshanna100 commented on June 12, 2024

But why shift it by 2 instead of 1?

from pypte.

patrk avatar patrk commented on June 12, 2024

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.

patrk avatar patrk commented on June 12, 2024

This will be picked up and unit-tests should be provided.

from pypte.

patrk avatar patrk commented on June 12, 2024

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)

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.