Skip to content

Commit

Permalink
Add test and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
withmywoessner committed Jan 29, 2024
1 parent 368d911 commit 32cae77
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions mne/io/cnt/cnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ def _get_cnt_info(input_fname, eog, ecg, emg, misc, data_format, date_format, he
)
n_bytes = 2
n_samples = data_size // (n_bytes * n_channels)
# See: PR #12393
annotations = _read_annotations_cnt(input_fname, data_format="int16")
if annotations.onset[-1] * sfreq > n_samples:
n_bytes = 4
Expand Down
11 changes: 11 additions & 0 deletions mne/io/cnt/tests/test_cnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

data_path = testing.data_path(download=False)
fname = data_path / "CNT" / "scan41_short.cnt"
# Contains bad spans and could not be read properly before PR #12393
fname_bad_spans = data_path / "CNT" / "test_CNT_events_mne_JWoess_clipped.cnt"


Expand Down Expand Up @@ -86,6 +87,16 @@ def test_compare_events_and_annotations():
assert "STI 014" not in raw.info["ch_names"]


@testing.requires_testing_data
def verify_reading_bytes():
raw_16 = read_raw_cnt(fname, preload=True)
raw_32 = read_raw_cnt(fname_bad_spans, preload=True)

# Verify that the number of bytes read is correct
assert len(raw_16) == 3070
assert len(raw_32) == 90000


@testing.requires_testing_data
def test_bad_spans():
"""Test reading raw cnt files with bad spans."""
Expand Down

0 comments on commit 32cae77

Please sign in to comment.