summaryrefslogtreecommitdiff
path: root/nitime/tests/test_viz.py
blob: 8406e4f9a56fc71a199cce402990580eeb5e09cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""

Smoke testing of the viz module.

"""

import numpy as np
import numpy.testing as npt

from nitime.timeseries import TimeSeries
from nitime.analysis import CorrelationAnalyzer
from nitime.viz import drawmatrix_channels, drawgraph_channels, plot_xcorr

try:
    import nx
    no_networkx = False
    no_networkx_msg = ''
except ImportError as e:
    no_networkx = True
    no_networkx_msg = e.args[0]

roi_names = ['a','b','c','d','e','f','g','h','i','j']
data = np.random.rand(10,1024)

T = TimeSeries(data, sampling_interval=np.pi)
T.metadata['roi'] = roi_names

#Initialize the correlation analyzer
C = CorrelationAnalyzer(T)

def test_drawmatrix_channels():
    fig01 = drawmatrix_channels(C.corrcoef, roi_names, size=[10., 10.], color_anchor=0)

def test_plot_xcorr():
    xc = C.xcorr_norm

    fig02 = plot_xcorr(xc,
                       ((0, 1),
                        (2, 3)),
                       line_labels=['a', 'b'])


@npt.dec.skipif(no_networkx, no_networkx_msg)
def test_drawgraph_channels():
    fig04 = drawgraph_channels(C.corrcoef, roi_names)