Test chunk_duration.
(first_samp)
| 300 | |
| 301 | @first_samps |
| 302 | def test_chunk_duration(first_samp): |
| 303 | """Test chunk_duration.""" |
| 304 | # create dummy raw |
| 305 | raw = RawArray( |
| 306 | data=np.empty([10, 10], dtype=np.float64), |
| 307 | info=create_info(ch_names=10, sfreq=1.0), |
| 308 | first_samp=first_samp, |
| 309 | ) |
| 310 | with raw.info._unlock(): |
| 311 | raw.info["meas_date"] = _handle_meas_date(0) |
| 312 | raw.set_annotations( |
| 313 | Annotations(description="foo", onset=[0], duration=[10], orig_time=None) |
| 314 | ) |
| 315 | assert raw.annotations.orig_time == raw.info["meas_date"] |
| 316 | assert_allclose(raw.annotations.onset, [first_samp]) |
| 317 | |
| 318 | # expected_events = [[0, 0, 1], [0, 0, 1], [1, 0, 1], [1, 0, 1], .. |
| 319 | # [9, 0, 1], [9, 0, 1]] |
| 320 | expected_events = np.atleast_2d(np.repeat(range(10), repeats=2)).T |
| 321 | expected_events = np.insert(expected_events, 1, 0, axis=1) |
| 322 | expected_events = np.insert(expected_events, 2, 1, axis=1) |
| 323 | expected_events[:, 0] += first_samp |
| 324 | |
| 325 | events, events_id = events_from_annotations( |
| 326 | raw, chunk_duration=0.5, use_rounding=False |
| 327 | ) |
| 328 | assert_array_equal(events, expected_events) |
| 329 | |
| 330 | # test chunk durations that do not fit equally in annotation duration |
| 331 | expected_events = np.zeros((3, 3)) |
| 332 | expected_events[:, -1] = 1 |
| 333 | expected_events[:, 0] = np.arange(0, 9, step=3) + first_samp |
| 334 | events, events_id = events_from_annotations(raw, chunk_duration=3.0) |
| 335 | assert_array_equal(events, expected_events) |
| 336 | |
| 337 | |
| 338 | def test_events_from_annotation_orig_time_none(): |
nothing calls this directly
no test coverage detected