def test_meas_date_orig_time(): """Test the relation between meas_time in orig_time.""" # meas_time is set and orig_time is set: # clips the annotations based on raw.data and resets the annotation based # on raw.info['meas_date] raw = _raw_annot(1, 1.5) assert raw.annotations.orig_time == 1 assert raw.annotations.onset[0] == 1 # meas_time is set and orig_time is None: # Consider annot.orig_time to be raw.frist_sample, clip and reset # annotations to have the raw.annotations.orig_time == raw.info['meas_date] raw = _raw_annot(1, None) assert raw.annotations.orig_time == 1 assert raw.annotations.onset[0] == 1.5 # meas_time is None and orig_time is set: # Raise error, it makes no sense to have an annotations object that we know # when was acquired and set it to a raw object that does not know when was # it acquired. with pytest.raises(RuntimeError, match='Ambiguous operation'): _raw_annot(None, 1.5) # meas_time is None and orig_time is None: # Consider annot.orig_time to be raw.first_sample and clip raw = _raw_annot(None, None) assert raw.annotations.orig_time is None assert raw.annotations.onset[0] == 0.5 assert raw.annotations.duration[0] == 0.2
def test_meas_date_orig_time(): """Test the relation between meas_time in orig_time.""" # meas_time is set and orig_time is set: # clips the annotations based on raw.data and resets the annotation based # on raw.info['meas_date] raw = _raw_annot(1, 1.5) assert raw.annotations.orig_time == _stamp_to_dt((1, 0)) assert raw.annotations.onset[0] == 1 # meas_time is set and orig_time is None: # Consider annot.orig_time to be raw.frist_sample, clip and reset # annotations to have the raw.annotations.orig_time == raw.info['meas_date] raw = _raw_annot(1, None) assert raw.annotations.orig_time == _stamp_to_dt((1, 0)) assert raw.annotations.onset[0] == 1.5 # meas_time is None and orig_time is set: # Raise error, it makes no sense to have an annotations object that we know # when was acquired and set it to a raw object that does not know when was # it acquired. with pytest.raises(RuntimeError, match='Ambiguous operation'): _raw_annot(None, 1.5) # meas_time is None and orig_time is None: # Consider annot.orig_time to be raw.first_sample and clip raw = _raw_annot(None, None) assert raw.annotations.orig_time is None assert raw.annotations.onset[0] == 1.5 assert raw.annotations.duration[0] == 0.2
def test_events_from_annot_onset_alingment(): """Test events and annotations onset are the same.""" raw = _raw_annot(meas_date=1, orig_time=1.5) # sec 0 1 2 3 # raw . |--------XXXXXXXXX # annot . |---XX # raw.annot . |--------XX # latency . 0 1 2 # . 0 0 assert raw.annotations.orig_time == 1 assert raw.annotations.onset[0] == 1 assert raw.first_samp == 10 event_latencies, event_id = events_from_annotations(raw) assert event_latencies[0, 0] == 10 assert raw.first_samp == event_latencies[0, 0]