def test_time_slicer(): "Test linked time axes" ds = datasets.get_uts(True) p1 = plot.Butterfly(ds['utsnd'], show=False) p2 = plot.Array('utsnd', 'A', ds=ds, show=False) p1.link_time_axis(p2) p1._set_time(.1, True) eq_(p2._current_time, .1) eq_(p2._time_fixed, True) p2._set_time(.2) eq_(p1._current_time, .2) eq_(p1._time_fixed, False) p1 = plot.TopoButterfly(ds['utsnd'], show=False) p2 = plot.Array('utsnd', 'A', ds=ds, show=False) p2.link_time_axis(p1) p1._set_time(.1, True) eq_(p2._current_time, .1) eq_(p2._time_fixed, True) p2._set_time(.2) eq_(p1._current_time, .2) eq_(p1._time_fixed, False)
def test_time_slicer(): "Test linked time axes" ds = datasets.get_uts(True) p1 = plot.Butterfly(ds['utsnd']) p2 = plot.Array('utsnd', 'A', ds=ds) p1.link_time_axis(p2) p1._set_time(.1, True) assert p2._current_time == .1 assert p2._time_fixed == True p2._set_time(.2) assert p1._current_time == .2 assert p1._time_fixed == False p1 = plot.TopoButterfly(ds['utsnd']) p2 = plot.Array('utsnd', 'A', ds=ds) p2.link_time_axis(p1) p1._set_time(.1, True) assert p2._current_time == .1 assert p2._time_fixed == True # merge another p3 = plot.TopoButterfly(ds[0, 'utsnd']) p3.link_time_axis(p2) p2._set_time(.2) assert p1._current_time == .2 assert p1._time_fixed == False
def test_plot_results(): "Test plotting test results" ds = datasets.get_uts(True) # ANOVA res = testnd.anova('utsnd', 'A*B*rm', match='rm', ds=ds, samples=0, pmin=0.05) p = plot.Array(res, show=False) p.close() res = testnd.anova('utsnd', 'A*B*rm', match='rm', ds=ds, samples=2, pmin=0.05) p = plot.Array(res, show=False) p.close() # Correlation res = testnd.corr('utsnd', 'Y', 'rm', ds=ds) p = plot.Array(res, show=False) p.close() res = testnd.corr('utsnd', 'Y', 'rm', ds=ds, samples=10, pmin=0.05) p = plot.Array(res, show=False) p.close()
def test_corr(): "Test testnd.corr()" plot.configure_backend(False, False) ds = datasets.get_rand(True) # add correlation Y = ds['Y'] utsnd = ds['utsnd'] utsnd.x.shape utsnd.x[:, 3:5, 50:65] += Y.x[:, None, None] res = testnd.corr('utsnd', 'Y', 'rm', ds=ds) repr(res) p = plot.Array(res) p.close() res = testnd.corr('utsnd', 'Y', 'rm', ds=ds, samples=10, pmin=0.05) p = plot.Array(res) p.close() # persistence string = pickle.dumps(res, protocol=pickle.HIGHEST_PROTOCOL) res_ = pickle.loads(string) assert_equal(repr(res_), repr(res)) assert_dataobj_equal(res.p_uncorrected, res_.p_uncorrected) assert_dataobj_equal(res.p, res_.p) # NaN r = _testnd._corr(np.arange(10), np.zeros(10)) assert_equal(r, 0)
def test_plot_array(): "Test plot.Array" ds = datasets.get_uts(utsnd=True) p = plot.Array('utsnd', 'A%B', ds=ds, show=False) p.close() p = plot.Array('utsnd', ds=ds, show=False) p.close()
def test_plot_array(): "Test plot.Array" plot.configure_backend(False, False) ds = datasets.get_rand(utsnd=True) p = plot.Array('utsnd', 'A%B', ds=ds) p.close() p = plot.Array('utsnd', ds=ds) p.close()
def test_plot_mne_epochs(): "Test plotting epochs from the mne sample dataset" epochs = datasets.get_mne_epochs() # grand average p = plot.Array(epochs) p.close() # with model p = plot.Array(epochs, np.arange(2).repeat(8)) p.close()
def test_plot_array(): "Test plot.Array" ds = datasets.get_uts(utsnd=True) p = plot.Array('utsnd', ds=ds) p.close() p = plot.Array('utsnd', 'A%B', ds=ds) assert p._layout.nax == 4 p.close() p = plot.Array('utsnd', 'A', sub='B=="b1"', ds=ds) assert p._layout.nax == 2 p.close() # Categorial dimension ds = datasets._get_continuous() p = plot.Array(ds['x2'], interpolation='none') assert len(p.figure.axes[0].get_yticks()) == 2
def test_plot_array(): "Test plot.Array" ds = datasets.get_uts(utsnd=True) p = plot.Array('utsnd', ds=ds, show=False) p.close() p = plot.Array('utsnd', 'A%B', ds=ds, show=False) eq_(p._layout.nax, 4) p.close() p = plot.Array('utsnd', 'A', sub='B=="b1"', ds=ds, show=False) eq_(p._layout.nax, 2) p.close() # Categorial dimension ds = datasets._get_continuous() p = plot.Array(ds['x2'], interpolation='none', show=False) eq_(len(p.figure.axes[0].get_yticks()), 2)
def test_plot_mne_evoked(): "Test plotting evoked from the mne sample dataset" data_path = mne.datasets.sample.data_path() evoked_path = os.path.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif') evoked = Evoked(evoked_path, setno="Left Auditory") p = plot.Array(evoked) p.close()
def test_plot_mne_epochs(): "Test plotting epochs from the mne sample dataset" # find paths data_path = mne.datasets.sample.data_path() raw_path = os.path.join(data_path, 'MEG', 'sample', 'sample_audvis_filt-0-40_raw.fif') events_path = os.path.join(data_path, 'MEG', 'sample', 'sample_audvis_filt-0-40_raw-eve.fif') # read epochs raw = Raw(raw_path) events = mne.read_events(events_path) idx = np.logical_or(events[:, 2] == 5, events[:, 2] == 32) events = events[idx] epochs = mne.Epochs(raw, events, None, -0.1, 0.3) # grand average p = plot.Array(epochs) p.close() # with model p = plot.Array(epochs, events[:, 2]) p.close()
def test_plot_mne_evoked(): "Test plotting evoked from the mne sample dataset" evoked = datasets.get_mne_evoked() p = plot.Array(evoked) p.close()
def test_anova(): "Test testnd.anova()" plot.configure_backend(False, False) ds = datasets.get_rand(True) testnd.anova('utsnd', 'A*B', ds=ds) for samples in (0, 2): logger.info("TEST: samples=%r" % samples) testnd.anova('utsnd', 'A*B', ds=ds, samples=samples) testnd.anova('utsnd', 'A*B', ds=ds, samples=samples, pmin=0.05) testnd.anova('utsnd', 'A*B', ds=ds, samples=samples, tfce=True) res = testnd.anova('utsnd', 'A*B*rm', ds=ds, samples=0, pmin=0.05) repr(res) p = plot.Array(res) p.close() res = testnd.anova('utsnd', 'A*B*rm', ds=ds, samples=2, pmin=0.05) repr(res) p = plot.Array(res) p.close() # persistence string = pickle.dumps(res, protocol=pickle.HIGHEST_PROTOCOL) res_ = pickle.loads(string) assert_equal(repr(res_), repr(res)) # threshold-free res = testnd.anova('utsnd', 'A*B*rm', ds=ds, samples=10) repr(res) assert_in('A clusters', res.clusters.info) assert_in('B clusters', res.clusters.info) assert_in('A x B clusters', res.clusters.info) # no clusters res = testnd.anova('uts', 'B', sub="A=='a1'", ds=ds, samples=5, pmin=0.05, mintime=0.02) repr(res) assert_in('v', res.clusters) assert_in('p', res.clusters) # all effects with clusters res = testnd.anova('uts', 'A*B*rm', ds=ds, samples=5, pmin=0.05, tstart=0.1, mintime=0.02) assert_equal(set(res.clusters['effect'].cells), set(res.effects)) # some effects with clusters, some without res = testnd.anova('uts', 'A*B*rm', ds=ds, samples=5, pmin=0.05, tstart=0.37, mintime=0.02) string = pickle.dumps(res, pickle.HIGHEST_PROTOCOL) res_ = pickle.loads(string) assert_dataobj_equal(res.clusters, res_.clusters) # test multi-effect results (with persistence) # UTS res = testnd.anova('uts', 'A*B*rm', ds=ds, samples=5) repr(res) string = pickle.dumps(res, pickle.HIGHEST_PROTOCOL) res = pickle.loads(string) tfce_clusters = res._clusters(pmin=0.05) peaks = res.find_peaks() assert_equal(tfce_clusters.eval("p.min()"), peaks.eval("p.min()")) unmasked = res.f[0] masked = res.masked_parameter_map(effect=0, pmin=0.05) assert_array_equal(masked.x <= unmasked.x, True)