Git Product home page Git Product logo

Comments (14)

Xunius avatar Xunius commented on July 29, 2024 1

@arokem It seems that the fix is failing the test_granger.py test. Now I actually think that proposed fix is not ideal, it would break with old behavior. We need to be more careful.

from nitime.

arokem avatar arokem commented on July 29, 2024

Thanks for spotting this. Looks like a lot of nan's in the results from Granger Causality calculation. Since it's been a while since the docs were built, I'll probably need to bisect back in history to see where this happened. Unfortunately, it might take me a little while to get to it.

from nitime.

justbennet avatar justbennet commented on July 29, 2024

from nitime.

arokem avatar arokem commented on July 29, 2024

from nitime.

justbennet avatar justbennet commented on July 29, 2024

Thanks. Just curious because the issue got closed but the problem seems to remain...? There is also a question on the Neuroimaging mailing list about it,

Subject: [Neuroimaging] GC analysis with nitime
Date: Fri, Jul 5, 2019 at 7:37 PM

Should the issue be reopened until it gets addressed?

from nitime.

arokem avatar arokem commented on July 29, 2024

Clearly.

from nitime.

hvannieuwenh avatar hvannieuwenh commented on July 29, 2024

Hi, I had the same issue when trying to run the Granger causality example for fMRI on my own computer. I tried rolling back to older versions of nitime (0.7, 0.6, and 0.5) but they had their own problems with dependent packages. Is there any way on my end to make the Granger causality module functional? It is exactly the tool I am looking for in my research. Thanks.

from nitime.

Xunius avatar Xunius commented on July 29, 2024

Hi all,
I spotted the same issue. Although being totally ignorant about the inner maths about Granger, I think I figured out where the problem lies.

The GrangerAnalyzer puts its outputs in the upper triangle:

        if ij is None:
            # The following gets the full list of combinations of
            # non-same i's and j's:
            x, y = np.meshgrid(np.arange(self._n_process),
                               np.arange(self._n_process))
            self.ij = list(zip(x[tril_indices_from(x, -1)],
                          y[tril_indices_from(y, -1)]))

Note the order is x then y, so self.ij indexes into the upper triangle.

While in making the plot, drawmatrix_channels() leaves only the lower triangle:

    # Null the upper triangle, so that you don't get the redundant and the
    # diagonal values:
    idx_null = triu_indices(m.shape[0])
    m[idx_null] = np.nan

So we ended up with nothing.

I suppose the fix is to transpose the ordering in GrangerAnalyzer like so:

           self.ij = list(zip(y[tril_indices_from(y, -1)],
                          x[tril_indices_from(x, -1)]))

This gives the following image for the fig03 in the tutorial:

Figure_3

fig04 is like this:

Figure_4

But, I'm not familiar with the plotting conventions people use in such like of analyses. Do we assume the plot in fig03 is the "causality" from row to column, or the other way around? Please help verity the proposed fix.

from nitime.

arokem avatar arokem commented on July 29, 2024

Thanks for figuring this out! I think that the best fix would probably be to alter the behavior of drawmatrix_channels. Do you want to try to make a PR for that?

from nitime.

Xunius avatar Xunius commented on July 29, 2024

@arokem I'm not sure what exact changes to make to drawmatrix_channels(), because it's working fine for other plots and only fails for Granger. How to change it so we don't break compatibility with other tutorials and with older versions?

from nitime.

arokem avatar arokem commented on July 29, 2024

Gotcha. Yeah - I think that your original solution makes more sense then. Arguably, this is the design we should have implemented to begin with. Could you make a PR with that implemeted?

from nitime.

arokem avatar arokem commented on July 29, 2024

Yes - we need to adjust the test and warn about the break to backwards compatibility.

If you reopen the PR, we can discuss that there.

from nitime.

Xunius avatar Xunius commented on July 29, 2024

I made some back-n-forth changes, hopefully not creating too much confusion to the git history.
In the latest PR I changed the drawmatrix_channels() instead to use the upper triangle but transpose it to lower before plotting. This doesn't affect other tutorials because coherence, correlation etc. are all symmetrical. I've tested all scripts in examples that calls drawmatrix_channels() and the figures all look good.

from nitime.

arokem avatar arokem commented on July 29, 2024

Closed through #193

from nitime.

Related Issues (20)

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.