def test_io_dip(): """Test IO for .dip files """ time, pos, amplitude, ori, gof = read_dip(dip_fname) assert_true(pos.shape[1] == 3) assert_true(ori.shape[1] == 3) assert_true(len(time) == len(pos)) assert_true(len(time) == gof.size) assert_true(len(time) == amplitude.size)
def test_io_dipoles(): """Test IO for .dip files """ tempdir = _TempDir() out_fname = op.join(tempdir, 'temp.dip') with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') times, pos, amplitude, ori, gof = read_dip(fname_dip) assert_true(len(w) >= 1) assert_true(pos.shape[1] == 3) assert_true(ori.shape[1] == 3) assert_true(len(times) == len(pos)) assert_true(len(times) == gof.size) assert_true(len(times) == amplitude.size) dipole = Dipole(times, pos, amplitude, ori, gof, 'ALL') print(dipole) # test repr dipole.save(out_fname) dipole_new = read_dipole(out_fname) _compare_dipoles(dipole, dipole_new)
from mne.datasets import sample data_path = sample.data_path() fwd_fname = data_path + '/MEG/sample/sample_audvis-meg-oct-6-fwd.fif' dip_fname = data_path + '/MEG/sample/sample_audvis_set1.dip' bem_fname = data_path + '/subjects/sample/bem/sample-5120-bem-sol.fif' brain_surface = mne.read_bem_surfaces(bem_fname, add_geom=True)[0] points = brain_surface['rr'] faces = brain_surface['tris'] fwd = mne.read_forward_solution(fwd_fname) src = fwd['src'] # read dipoles time, pos, amplitude, ori, gof = mne.read_dip(dip_fname) print("Time (ms): %s" % time) print("Amplitude (nAm): %s" % amplitude) print("GOF (%%): %s" % gof) # only plot those for which GOF is above 50% pos = pos[gof > 50.] ori = ori[gof > 50.] time = time[gof > 50.] ############################################################################### # Show result on 3D source space try: from enthought.mayavi import mlab except:
print(__doc__) data_path = sample.data_path() fwd_fname = data_path + '/MEG/sample/sample_audvis-meg-oct-6-fwd.fif' dip_fname = data_path + '/MEG/sample/sample_audvis_set1.dip' bem_fname = data_path + '/subjects/sample/bem/sample-5120-bem-sol.fif' brain_surface = mne.read_bem_surfaces(bem_fname, add_geom=True)[0] points = brain_surface['rr'] faces = brain_surface['tris'] fwd = mne.read_forward_solution(fwd_fname) src = fwd['src'] # read dipoles time, pos, amplitude, ori, gof = mne.read_dip(dip_fname) print("Time (ms): %s" % time) print("Amplitude (nAm): %s" % amplitude) print("GOF (%%): %s" % gof) # only plot those for which GOF is above 50% pos = pos[gof > 50.] ori = ori[gof > 50.] time = time[gof > 50.] ############################################################################### # Show result on 3D source space try: from enthought.mayavi import mlab except: