Skip to content

Commit 8faa7e1

Browse files
committed
fix all nans in GrangerAnalyzer by transposing into lower triangle
This is to fix issue #173 (comment). `GrangerAnalyzer` put its outputs in the upper triangle only, which would be removed by `drawmatrix_channels()` which takes only the lower triangle, creating an array of all `nan`s. This fix transposes outputs of `GrangerAnalyzer` into the lower triangle. This also implies that the element (i,j) in the `causality_xy` attribute denotes "causality" from row-i to column-j.
1 parent 16eaab6 commit 8faa7e1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

nitime/analysis/granger.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ def __init__(self, input=None, ij=None, order=None, max_order=10,
108108
# non-same i's and j's:
109109
x, y = np.meshgrid(np.arange(self._n_process),
110110
np.arange(self._n_process))
111-
self.ij = list(zip(x[tril_indices_from(x, -1)],
112-
y[tril_indices_from(y, -1)]))
111+
# index into the **lower** triangle. Then the element (i,j) stores
112+
# the causality from x to y, e.g. gc['gc_xy'][i, j] = f_x2y
113+
self.ij = list(zip(y[tril_indices_from(y, -1)],
114+
x[tril_indices_from(x, -1)]))
113115
else:
114116
self.ij = ij
115117

0 commit comments

Comments
 (0)