Пример #1
0
def test_eeglab_annotations(fname):
    """Test reading annotations in EEGLAB files."""
    _check_h5(fname)
    annotations = read_annotations_eeglab(fname)
    assert len(annotations) == 154
    assert set(annotations.description) == set(['rt', 'square'])
    assert np.all(annotations.duration == 0.)
Пример #2
0
def test_eeglab_annotations(fname):
    """Test reading annotations in EEGLAB files."""
    _check_h5(fname)
    annotations = read_annotations_eeglab(fname)
    assert len(annotations) == 154
    assert set(annotations.description) == set(['rt', 'square'])
    assert np.all(annotations.duration == 0.)
Пример #3
0
def test_eeglab_annotations():
    """Test reading annotations in EEGLAB files"""
    for fname in [raw_fname_onefile, raw_fname]:
        annotations = read_annotations_eeglab(fname)
        assert len(annotations) == 154
        assert set(annotations.description) == set(['rt', 'square'])
        assert np.all(annotations.duration == 0.)
Пример #4
0
def test_read_annotations_eeglab():
    """Test annotations onsets are timestamps (+ validate some)."""
    annotations = read_annotations_eeglab(raw_fname_mat)
    validation_samples = [0, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
    expected_onset = np.array([1.00, 1.69, 2.08, 4.70, 7.71, 11.30, 17.18,
                               20.20, 26.12, 29.14, 35.25, 44.30, 47.15])
    assert annotations.orig_time is None
    assert_array_almost_equal(annotations.onset[validation_samples],
                              expected_onset, decimal=2)
Пример #5
0
def test_read_annotations_eeglab():
    """Test annotations onsets are timestamps (+ validate some)."""
    annotations = read_annotations_eeglab(raw_fname_mat)
    validation_samples = [0, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
    expected_onset = np.array([
        1.00, 1.69, 2.08, 4.70, 7.71, 11.30, 17.18, 20.20, 26.12, 29.14, 35.25,
        44.30, 47.15
    ])
    assert annotations.orig_time is None
    assert_array_almost_equal(annotations.onset[validation_samples],
                              expected_onset,
                              decimal=2)
Пример #6
0
def test_eeglab_event_from_annot(recwarn):
    """Test all forms of obtaining annotations."""
    base_dir = op.join(testing.data_path(download=False), 'EEGLAB')
    raw_fname_mat = op.join(base_dir, 'test_raw.set')
    raw_fname = raw_fname_mat
    montage = op.join(base_dir, 'test_chans.locs')
    event_id = {'rt': 1, 'square': 2}
    raw1 = read_raw_eeglab(input_fname=raw_fname, montage=montage,
                           event_id=event_id, preload=False)

    events_a = find_events(raw1)
    events_b = read_events_eeglab(raw_fname, event_id=event_id)
    annotations = read_annotations_eeglab(raw_fname)
    assert raw1.annotations is None
    raw1.set_annotations(annotations)
    events_c, _ = events_from_annotations(raw1, event_id=event_id)

    assert_array_equal(events_a, events_b)
    assert_array_equal(events_a, events_c)
Пример #7
0
def test_eeglab_event_from_annot(recwarn):
    """Test all forms of obtaining annotations."""
    base_dir = op.join(testing.data_path(download=False), 'EEGLAB')
    raw_fname_mat = op.join(base_dir, 'test_raw.set')
    raw_fname = raw_fname_mat
    montage = op.join(base_dir, 'test_chans.locs')
    event_id = {'rt': 1, 'square': 2}
    raw1 = read_raw_eeglab(input_fname=raw_fname,
                           montage=montage,
                           event_id=event_id,
                           preload=False)

    events_a = find_events(raw1)
    events_b = read_events_eeglab(raw_fname, event_id=event_id)
    annotations = read_annotations_eeglab(raw_fname)
    assert len(raw1.annotations) == 154
    raw1.set_annotations(annotations)
    events_c, _ = events_from_annotations(raw1, event_id=event_id)

    assert_array_equal(events_a, events_b)
    assert_array_equal(events_a, events_c)