def test_fiducials_io(tmpdir): """Test fiducials i/o.""" pts, coord_frame = read_fiducials(fiducials_fname) assert pts[0]['coord_frame'] == FIFF.FIFFV_COORD_MRI assert pts[0]['ident'] == FIFF.FIFFV_POINT_CARDINAL temp_fname = tmpdir.join('test.fif') write_fiducials(temp_fname, pts, coord_frame) pts_1, coord_frame_1 = read_fiducials(temp_fname) assert coord_frame == coord_frame_1 for pt, pt_1 in zip(pts, pts_1): assert pt['kind'] == pt_1['kind'] assert pt['ident'] == pt_1['ident'] assert pt['coord_frame'] == pt_1['coord_frame'] assert_array_equal(pt['r'], pt_1['r']) # test safeguards pts[0]['coord_frame'] += 1 pytest.raises(ValueError, write_fiducials, temp_fname, pts, coord_frame)
def test_fiducials_io(): """Test fiducials i/o""" pts, coord_frame = read_fiducials(fiducials_fname) assert_equal(pts[0]['coord_frame'], FIFF.FIFFV_COORD_MRI) assert_equal(pts[0]['ident'], FIFF.FIFFV_POINT_CARDINAL) temp_fname = op.join(tempdir, 'test.fif') write_fiducials(temp_fname, pts, coord_frame) pts_1, coord_frame_1 = read_fiducials(temp_fname) assert_equal(coord_frame, coord_frame_1) for pt, pt_1 in zip(pts, pts_1): assert_equal(pt['kind'], pt_1['kind']) assert_equal(pt['ident'], pt_1['ident']) assert_equal(pt['coord_frame'], pt_1['coord_frame']) assert_array_equal(pt['r'], pt_1['r']) # test safeguards pts[0]['coord_frame'] += 1 assert_raises(ValueError, write_fiducials, temp_fname, pts, coord_frame)
def test_fiducials_io(): """Test fiducials i/o.""" tempdir = _TempDir() pts, coord_frame = read_fiducials(fiducials_fname) assert pts[0]['coord_frame'] == FIFF.FIFFV_COORD_MRI assert pts[0]['ident'] == FIFF.FIFFV_POINT_CARDINAL temp_fname = op.join(tempdir, 'test.fif') write_fiducials(temp_fname, pts, coord_frame) pts_1, coord_frame_1 = read_fiducials(temp_fname) assert coord_frame == coord_frame_1 for pt, pt_1 in zip(pts, pts_1): assert pt['kind'] == pt_1['kind'] assert pt['ident'] == pt_1['ident'] assert pt['coord_frame'] == pt_1['coord_frame'] assert_array_equal(pt['r'], pt_1['r']) # test safeguards pts[0]['coord_frame'] += 1 pytest.raises(ValueError, write_fiducials, temp_fname, pts, coord_frame)
def test_fiducials_io(): """Test fiducials i/o.""" tempdir = _TempDir() pts, coord_frame = read_fiducials(fiducials_fname) assert_equal(pts[0]["coord_frame"], FIFF.FIFFV_COORD_MRI) assert_equal(pts[0]["ident"], FIFF.FIFFV_POINT_CARDINAL) temp_fname = op.join(tempdir, "test.fif") write_fiducials(temp_fname, pts, coord_frame) pts_1, coord_frame_1 = read_fiducials(temp_fname) assert_equal(coord_frame, coord_frame_1) for pt, pt_1 in zip(pts, pts_1): assert_equal(pt["kind"], pt_1["kind"]) assert_equal(pt["ident"], pt_1["ident"]) assert_equal(pt["coord_frame"], pt_1["coord_frame"]) assert_array_equal(pt["r"], pt_1["r"]) # test safeguards pts[0]["coord_frame"] += 1 assert_raises(ValueError, write_fiducials, temp_fname, pts, coord_frame)
def test_fiducials_io(tmp_path): """Test fiducials i/o.""" pts, coord_frame = read_fiducials(fiducials_fname) assert pts[0]['coord_frame'] == FIFF.FIFFV_COORD_MRI assert pts[0]['ident'] == FIFF.FIFFV_POINT_CARDINAL temp_fname = tmp_path / 'test.fif' write_fiducials(temp_fname, pts, coord_frame) pts_1, coord_frame_1 = read_fiducials(temp_fname) assert coord_frame == coord_frame_1 for pt, pt_1 in zip(pts, pts_1): assert pt['kind'] == pt_1['kind'] assert pt['ident'] == pt_1['ident'] assert pt['coord_frame'] == pt_1['coord_frame'] assert_array_equal(pt['r'], pt_1['r']) assert isinstance(pt, DigPoint) assert isinstance(pt_1, DigPoint) # test safeguards pts[0]['coord_frame'] += 1 with pytest.raises(ValueError, match='coord_frame entries that are incom'): write_fiducials(temp_fname, pts, coord_frame, overwrite=True)
RAS_lpa = vox2ras.dot(lpa_fs) print('LEFT_EAR: {} '.format(RAS_lpa)) RAS_rpa = vox2ras.dot(rpa_fs) print('RIGHT_EAR: {}'.format(RAS_rpa)) # FIFF.FIFFV_POINT_LPA = 1 # FIFF.FIFFV_POINT_NASION = 2 # FIFF.FIFFV_POINT_RPA = 3 # Write new fiducial points to fsaverage-fiducials fiducials = [{'kind': FIFF.FIFFV_POINT_CARDINAL, 'ident': FIFF.FIFFV_POINT_LPA, 'r': np.float32(RAS_lpa)/1000}, {'kind': FIFF.FIFFV_POINT_CARDINAL, 'ident': FIFF.FIFFV_POINT_NASION, 'r': np.float32(RAS_nas)/1000}, {'kind': FIFF.FIFFV_POINT_CARDINAL, 'ident': FIFF.FIFFV_POINT_RPA, 'r': np.float32(RAS_rpa)/1000}] fiducials_file = op.join(sbj_dir, sbj_FS, 'bem', sbj_FS + '-fiducials.fif') write_fiducials(fiducials_file, fiducials, FIFF.FIFFV_COORD_MRI) print('fsaverage fiducial points \n {} saved in \n {}'.format( fiducials, fiducials_file)) else: print('!!! No Freesurfer folder for {}'.format(sbj_FS)) else: print('!!! No DS folder for {}'.format(sbj_FS))