def test_inst_source(): """Test DigSource.""" from mne.gui._file_traits import DigSource tempdir = _TempDir() inst = DigSource() assert inst.inst_fname == '-' inst.file = inst_path assert inst.inst_dir == op.dirname(inst_path) lpa = array([[-7.13766068e-02, 0.00000000e+00, 5.12227416e-09]]) nasion = array([[3.72529030e-09, 1.02605611e-01, 4.19095159e-09]]) rpa = array([[7.52676800e-02, 0.00000000e+00, 5.58793545e-09]]) assert_allclose(inst.lpa, lpa) assert_allclose(inst.nasion, nasion) assert_allclose(inst.rpa, rpa) montage = read_dig_montage(fif=inst_path) # test reading DigMontage montage_path = op.join(tempdir, 'temp_montage.fif') montage.save(montage_path) inst.file = montage_path assert_allclose(inst.lpa, lpa) assert_allclose(inst.nasion, nasion) assert_allclose(inst.rpa, rpa)
def test_coreg_gui_automation(): """Test that properties get properly updated.""" from mne.gui._file_traits import DigSource from mne.gui._fiducials_gui import MRIHeadWithFiducialsModel from mne.gui._coreg_gui import CoregModel subject = 'sample' hsp = DigSource() hsp.file = raw_path mri = MRIHeadWithFiducialsModel(subjects_dir=subjects_dir, subject=subject) model = CoregModel(mri=mri, hsp=hsp) # gh-7254 assert not (model.nearest_transformed_high_res_mri_idx_hsp == 0).all() model.fit_fiducials() model.icp_iterations = 2 model.nasion_weight = 2. model.fit_icp() model.omit_hsp_points(distance=5e-3) model.icp_iterations = 2 model.fit_icp() errs_icp = np.median(model._get_point_distance()) assert 2e-3 < errs_icp < 3e-3 info = mne.io.read_info(raw_path) errs_nearest = np.median( dig_mri_distances(info, fname_trans, subject, subjects_dir)) assert 1e-3 < errs_nearest < 2e-3
def test_inst_source(): """Test DigSource""" from mne.gui._file_traits import DigSource inst = DigSource() assert_equal(inst.inst_fname, '-') inst.file = inst_path assert_equal(inst.inst_dir, os.path.dirname(inst_path)) lpa = array([[-7.13766068e-02, 0.00000000e+00, 5.12227416e-09]]) nasion = array([[3.72529030e-09, 1.02605611e-01, 4.19095159e-09]]) rpa = array([[7.52676800e-02, 0.00000000e+00, 5.58793545e-09]]) assert_allclose(inst.lpa, lpa) assert_allclose(inst.nasion, nasion) assert_allclose(inst.rpa, rpa)
def test_digitization_source(tmpdir): """Test DigSource.""" from mne.gui._file_traits import DigSource tempdir = str(tmpdir) inst = DigSource() assert inst.inst_fname == '-' inst.file = inst_path assert inst.inst_dir == op.dirname(inst_path) # FIFF lpa = array([[-7.13766068e-02, 0.00000000e+00, 5.12227416e-09]]) nasion = array([[3.72529030e-09, 1.02605611e-01, 4.19095159e-09]]) rpa = array([[7.52676800e-02, 0.00000000e+00, 5.58793545e-09]]) assert_allclose(inst.lpa, lpa) assert_allclose(inst.nasion, nasion) assert_allclose(inst.rpa, rpa) # DigMontage montage = read_dig_fif(inst_path) montage_path = op.join(tempdir, 'temp_montage.fif') montage.save(montage_path) inst.file = montage_path assert_allclose(inst.lpa, lpa) assert_allclose(inst.nasion, nasion) assert_allclose(inst.rpa, rpa) # EGI MFF inst.file = op.join(data_path, 'EGI', 'test_egi.mff') assert len(inst.points) == 0 assert len(inst.eeg_points) == 130 assert_allclose(inst.lpa * 1000, [[-67.1, 0, 0]], atol=0.1) assert_allclose(inst.nasion * 1000, [[0.0, 103.6, 0]], atol=0.1) assert_allclose(inst.rpa * 1000, [[67.1, 0, 0]], atol=0.1) # CTF inst.file = op.join(data_path, 'CTF', 'testdata_ctf.ds') assert len(inst.points) == 0 assert len(inst.eeg_points) == 8 assert_allclose(inst.lpa * 1000, [[-74.3, 0.0, 0.0]], atol=0.1) assert_allclose(inst.nasion * 1000, [[0.0, 117.7, 0.0]], atol=0.1) assert_allclose(inst.rpa * 1000, [[84.9, -0.0, 0.0]], atol=0.1)