def test_read_raw_curry_rfDC(fname, tol): """Test reading CURRY files.""" # check data bti_rfDC = read_raw_bti(pdf_fname=bti_rfDC_file, head_shape_fname=None) raw = read_raw_curry(fname) # test on the eeg chans, since these were not renamed by curry eeg_names = [ch["ch_name"] for ch in raw.info["chs"] if ch["kind"] == FIFF.FIFFV_EEG_CH] assert_allclose(raw.get_data(eeg_names), bti_rfDC.get_data(eeg_names), rtol=tol)
def test_read_raw_curry_rfDC(fname, tol, mock_dev_head_t, tmpdir): """Test reading CURRY files.""" if mock_dev_head_t: if 'Curry 7' in fname: # not supported yet return # copy files to tmpdir base = op.splitext(fname)[0] for ext in ('.cdt', '.cdt.dpa'): src = base + ext dst = op.join(tmpdir, op.basename(base) + ext) copyfile(src, dst) if ext == '.cdt.dpa': with open(dst, 'a') as fid: fid.write(LM_CONTENT) fname = op.join(tmpdir, op.basename(fname)) with open(fname + '.hpi', 'w') as fid: fid.write(HPI_CONTENT) # check data bti_rfDC = read_raw_bti(pdf_fname=bti_rfDC_file, head_shape_fname=None) with catch_logging() as log: raw = read_raw_curry(fname, verbose=True) log = log.getvalue() if mock_dev_head_t: assert 'Composing device' in log else: assert 'Leaving device' in log assert 'no landmark' in log # test on the eeg chans, since these were not renamed by curry eeg_names = [ ch["ch_name"] for ch in raw.info["chs"] if ch["kind"] == FIFF.FIFFV_EEG_CH ] assert_allclose(raw.get_data(eeg_names), bti_rfDC.get_data(eeg_names), rtol=tol) assert bti_rfDC.info['dev_head_t'] is not None # XXX probably a BTI bug if mock_dev_head_t: assert raw.info['dev_head_t'] is not None assert_allclose(raw.info['dev_head_t']['trans'], WANT_TRANS, atol=1e-5) else: assert raw.info['dev_head_t'] is None # check that most MEG sensors are approximately oriented outward from # the device origin n_meg = n_eeg = n_other = 0 pos = list() nn = list() for ch in raw.info['chs']: if ch['kind'] == FIFF.FIFFV_MEG_CH: assert ch['coil_type'] == FIFF.FIFFV_COIL_CTF_GRAD t = _loc_to_coil_trans(ch['loc']) pos.append(t[:3, 3]) nn.append(t[:3, 2]) assert_allclose(np.linalg.norm(nn[-1]), 1.) n_meg += 1 elif ch['kind'] == FIFF.FIFFV_EEG_CH: assert ch['coil_type'] == FIFF.FIFFV_COIL_EEG n_eeg += 1 else: assert ch['coil_type'] == FIFF.FIFFV_COIL_NONE n_other += 1 assert n_meg == 148 assert n_eeg == 31 assert n_other == 15 pos = np.array(pos) nn = np.array(nn) rad, origin = _fit_sphere(pos, disp=False) assert 0.11 < rad < 0.13 pos -= origin pos /= np.linalg.norm(pos, axis=1, keepdims=True) angles = np.abs(np.rad2deg(np.arccos((pos * nn).sum(-1)))) assert (angles < 20).sum() > 100