Skip to content

Commit

Permalink
Create functions to read Neuroscan formats
Browse files Browse the repository at this point in the history
  • Loading branch information
withmywoessner committed Jan 28, 2024
1 parent 2040898 commit 6d802e9
Show file tree
Hide file tree
Showing 3 changed files with 400 additions and 6 deletions.
2 changes: 1 addition & 1 deletion mne/io/cnt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright the MNE-Python contributors.
"""CNT data reader."""

from .cnt import read_raw_cnt
from .cnt import read_raw_cnt, read_epochs_cnt, read_evoked_cnt
19 changes: 18 additions & 1 deletion mne/io/cnt/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ def _read_teeg(f, teeg_offset):
)


EpochHeader = namedtuple(
"EpochHeader",
(
"Accept Ttype Correct Rt Response Reserved"
),
)
# char Accept; /* accept byte */
# short Ttype; /* trial type */
# short Correct; /* accuracy */
# float Rt; /* reaction time */
# short Response; /* response type */
# short Reserved; /* not used */


def _get_event_parser(event_type):
if event_type == 1:
event_maker = CNTEventType1
Expand All @@ -83,8 +97,11 @@ def _get_event_parser(event_type):
elif event_type == 3:
event_maker = CNTEventType3
struct_pattern = "<HBclhhfccc" # Same as event type 2
elif event_type == 'epoch':
event_maker = EpochHeader
struct_pattern = "<chhfh"
else:
raise ValueError("unknown CNT even type %s" % event_type)
raise ValueError("unknown CNT header type %s" % event_type)

def parser(buffer):
struct = Struct(struct_pattern)
Expand Down
Loading

0 comments on commit 6d802e9

Please sign in to comment.