Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cnt response #13007

Merged
merged 9 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion mne/io/cnt/cnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,22 @@ def _update_bad_span_onset(accept_reject, onset, duration, description):
np.array([e.KeyPad_Accept for e in my_events])
)

description = np.array([str(e.StimType) for e in my_events])
# Check to see if there are any button presses
description = []
for event in my_events:
# Extract the 4-bit fields
# Upper nibble (4 bits) currently not used
# accept = (event.KeyPad_Accept[0] & 0xF0) >> 4
# Lower nibble (4 bits) keypad button press
keypad = event.KeyPad_Accept[0] & 0x0F
if str(keypad) != "0":
description.append("KeyPad Response" + " " + str(keypad))
withmywoessner marked this conversation as resolved.
Show resolved Hide resolved
elif event.KeyBoard != 0:
description.append("Keyboard Response" + " " + str(event.KeyBoard))
withmywoessner marked this conversation as resolved.
Show resolved Hide resolved
else:
description.append(str(event.StimType))

description = np.array(description)

onset, duration, description = _update_bad_span_onset(
accept_reject, onset / sfreq, duration, description
Expand Down
3 changes: 2 additions & 1 deletion mne/io/cnt/tests/test_cnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def test_auto_data():
third = pytest.warns(RuntimeWarning, match="Omitted 6 annot")
with first, second, third:
raw = read_raw_cnt(input_fname=fname_bad_spans)

# Test that responses are read properly
assert "KeyPad Response 1" in raw.annotations.description
assert raw.info["bads"] == ["F8"]

with _no_parse, pytest.warns(RuntimeWarning, match="number of bytes"):
Expand Down
Loading