Exemple #1
0
def test_calculate_head_pos_ctf():
    """Test extracting of cHPI positions from ctf data."""
    raw = read_raw_ctf(ctf_chpi_fname)
    quats = _calculate_head_pos_ctf(raw)
    mc_quats = read_head_pos(ctf_chpi_pos_fname)
    _assert_quats(quats, mc_quats, dist_tol=0.004, angle_tol=2.5)

    raw = read_raw_fif(ctf_fname)
    pytest.raises(RuntimeError, _calculate_head_pos_ctf, raw)
ds_fname = op.join(top_dir, 'MEG_Movie_20190319_09.ds')

raw = read_raw_ctf(ds_fname, preload=True)
#raw.set_channel_types({'EEG057': 'eog', 'EEG058': 'ecg'})
#raw.info['bads'] = []

if raw.compensation_grade != 3:
    raw.apply_gradient_compensation(3)

# muscle artifacts
mus_annot, mus_raw = annotate_muscle_artifacts(raw,
                                               art_thresh=2.5,
                                               return_stat_raw=True)

# motion artifacts
pos = _calculate_head_pos_ctf(raw)
mov_annot, raw_hpi = annotate_motion_artifacts(raw, pos, return_stat_raw=True)

#pick meg channels and filter
picks = pick_types(raw.info, meg='mag', eeg=False, eog=False, stim=False)
raw.notch_filter(np.arange(60, 241, 60), picks=picks, fir_design='firwin')
raw.filter(1, 100, picks=picks)

# muscle artifacts
gfp_annot, stat_raw = annotate_gfp_artifacts(raw, return_stat_raw=True)

art_raw = stat_raw.copy()
art_raw.add_channels([raw_hpi, mus_raw])
tresholds = {
    "gfp_thresh": 5,
    "motion_disp_thresh": 0.005,