def test_meg_inverse(): """Test plotting of MEG inverse solution.""" _set_backend() brain = Brain(*std_args) stc_fname = os.path.join(data_dir, 'meg_source_estimate-lh.stc') stc = io.read_stc(stc_fname) vertices = stc['vertices'] colormap = 'hot' data = stc['data'] data_full = (brain.geo['lh'].nn[vertices][..., np.newaxis] * data[:, np.newaxis]) time = np.linspace(stc['tmin'], stc['tmin'] + data.shape[1] * stc['tstep'], data.shape[1], endpoint=False) def time_label(t): return 'time=%0.2f ms' % (1e3 * t) for use_data in (data, data_full): brain.add_data(use_data, colormap=colormap, vertices=vertices, smoothing_steps=1, time=time, time_label=time_label) brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True) assert_equal(brain.data_dict['lh']['time_idx'], 0) brain.set_time(.1) assert_equal(brain.data_dict['lh']['time_idx'], 2) # viewer = TimeViewer(brain) # multiple data layers assert_raises(ValueError, brain.add_data, data, vertices=vertices, time=time[:-1]) brain.add_data(data, colormap=colormap, vertices=vertices, smoothing_steps=1, time=time, time_label=time_label, initial_time=.09) assert_equal(brain.data_dict['lh']['time_idx'], 1) data_dicts = brain._data_dicts['lh'] assert_equal(len(data_dicts), 3) assert_equal(data_dicts[0]['time_idx'], 1) assert_equal(data_dicts[1]['time_idx'], 1) # shift time in both layers brain.set_data_time_index(0) assert_equal(data_dicts[0]['time_idx'], 0) assert_equal(data_dicts[1]['time_idx'], 0) brain.set_data_smoothing_steps(2) # add second data-layer without time axis brain.add_data(data[:, 1], colormap=colormap, vertices=vertices, smoothing_steps=2) brain.set_data_time_index(2) assert_equal(len(data_dicts), 4) # change surface brain.set_surf('white') # remove all layers brain.remove_data() assert_equal(brain._data_dicts['lh'], []) brain.close()
def test_meg_inverse(): """Test plotting of MEG inverse solution.""" _set_backend() brain = Brain(*std_args) stc_fname = os.path.join(data_dir, 'meg_source_estimate-lh.stc') stc = io.read_stc(stc_fname) vertices = stc['vertices'] colormap = 'hot' data = stc['data'] data_full = (brain.geo['lh'].nn[vertices][..., np.newaxis] * data[:, np.newaxis]) time = np.linspace(stc['tmin'], stc['tmin'] + data.shape[1] * stc['tstep'], data.shape[1], endpoint=False) def time_label(t): return 'time=%0.2f ms' % (1e3 * t) for use_data in (data, data_full): brain.add_data(use_data, colormap=colormap, vertices=vertices, smoothing_steps=1, time=time, time_label=time_label) brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True) assert brain.data_dict['lh']['time_idx'] == 0 brain.set_time(.1) assert brain.data_dict['lh']['time_idx'] == 2 # viewer = TimeViewer(brain) # multiple data layers pytest.raises(ValueError, brain.add_data, data, vertices=vertices, time=time[:-1]) brain.add_data(data, colormap=colormap, vertices=vertices, smoothing_steps=1, time=time, time_label=time_label, initial_time=.09) assert brain.data_dict['lh']['time_idx'] == 1 data_dicts = brain._data_dicts['lh'] assert len(data_dicts) == 3 assert data_dicts[0]['time_idx'] == 1 assert data_dicts[1]['time_idx'] == 1 # shift time in both layers brain.set_data_time_index(0) assert data_dicts[0]['time_idx'] == 0 assert data_dicts[1]['time_idx'] == 0 brain.set_data_smoothing_steps(2) # add second data-layer without time axis brain.add_data(data[:, 1], colormap=colormap, vertices=vertices, smoothing_steps=2) brain.set_data_time_index(2) assert len(data_dicts) == 4 # change surface brain.set_surf('white') # remove all layers brain.remove_data() assert brain._data_dicts['lh'] == [] brain.close()
def test_meg_inverse(): """Test plotting of MEG inverse solution.""" mlab.options.backend = 'test' brain = Brain(*std_args) stc_fname = os.path.join(data_dir, 'meg_source_estimate-lh.stc') stc = io.read_stc(stc_fname) data = stc['data'] vertices = stc['vertices'] time = np.linspace(stc['tmin'], stc['tmin'] + data.shape[1] * stc['tstep'], data.shape[1], endpoint=False) colormap = 'hot' def time_label(t): return 'time=%0.2f ms' % (1e3 * t) brain.add_data(data, colormap=colormap, vertices=vertices, smoothing_steps=10, time=time, time_label=time_label) brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True) assert_equal(brain.data_dict['lh']['time_idx'], 0) brain.set_time(.1) assert_equal(brain.data_dict['lh']['time_idx'], 2) # viewer = TimeViewer(brain) # multiple data layers assert_raises(ValueError, brain.add_data, data, vertices=vertices, time=time[:-1]) brain.add_data(data, colormap=colormap, vertices=vertices, smoothing_steps=10, time=time, time_label=time_label, initial_time=.09) assert_equal(brain.data_dict['lh']['time_idx'], 1) data_dicts = brain._data_dicts['lh'] assert_equal(len(data_dicts), 2) assert_equal(data_dicts[0]['time_idx'], 1) assert_equal(data_dicts[1]['time_idx'], 1) # shift time in both layers brain.set_data_time_index(0) assert_equal(data_dicts[0]['time_idx'], 0) assert_equal(data_dicts[1]['time_idx'], 0) # remove all layers brain.remove_data() assert_equal(brain._data_dicts['lh'], []) brain.close()