Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is to fix the issue #173.
GrangerAnalyzer
put its outputs in the upper triangle only, whichwould be removed by
drawmatrix_channels()
which takes only the lowertriangle, creating an array of all nans.
This fix changes the
drawmatrix_channels()
to let it take the uppertriangle instead, then transpose the matrix before plotting.
Another possible fix is to transposes outputs of
GrangerAnalyzer
into thelower triangle. However this would break with the old behavior including
failing unit tests (
test_granger.py
).Another reason to change the
drawmatrix_channels()
instead is thatother similar functions, including
CorrelationAnalyzer.xcorr
,CoherenceAnalyzer.coherence
all computes the upper triangle first,then transpose to fill the lower, e.g.
But granger is a bit different in that it is not symmetrical so we don't
just mirror the upper triangle into the low.
Another reason to keep the upper triangle in granger is that the
indices of pairs argument (
ij
) of theGrangerAnalyzer.__init__()
translates more naturally to the upper triangle indices, e.g. pair
(0, 1)
-> (row-0, column-1),(2, 4)
-> (row-2, column-4).If feels more intuitive (to me at least) to preserve this, rather than doing a
transpose here. This also helps pass the
test_granger.py
unit test.Related changes needed:
in
doc/examples/multi_taper_coh.py
, I have to change the nestedfor
loopso the results are put into the upper triangle. The old
for
loop:New:
This is also consistent with
CoherenceAnalyzer
etc..I've tested all scripts in the
doc/examples
folder that involve thedrawmatrix_channels()
function. All figures look good.