# Authors: The MNE-Python contributors. # License: BSD-3-Clause # Copyright the MNE-Python contributors. from collections import namedtuple from datetime import datetime from math import modf from os import SEEK_END from struct import Struct import numpy as np from ...utils import warn def _read_teeg(f, teeg_offset): """ Read TEEG structure from an open CNT file. # from TEEG structure in http://paulbourke.net/dataformats/eeg/ typedef struct { char Teeg; /* Either 1 or 2 */ long Size; /* Total length of all the events */ long Offset; /* Hopefully always 0 */ } TEEG; """ # we use a more descriptive names based on TEEG doc comments Teeg = namedtuple("Teeg", "event_type total_length offset") teeg_parser = Struct("3 range 0-15 bit coded response pad */ # /* 4->7 values 0xd=Accept 0xc=Reject */ # long Offset; /* file offset of event */ # } EVENT1; CNTEventType2 = namedtuple( "CNTEventType2", ( "StimType KeyBoard KeyPad_Accept Offset Type " "Code Latency EpochEvent Accept2 Accuracy" ), ) # unsigned short StimType; /* range 0-65535 */ # unsigned char KeyBoard; /* range 0-11 corresponding to fcn keys +1 */ # char KeyPad_Accept; /* 0->3 range 0-15 bit coded response pad */ # /* 4->7 values 0xd=Accept 0xc=Reject */ # long Offset; /* file offset of event */ # short Type; # short Code; # float Latency; # char EpochEvent; # char Accept2; # char Accuracy; # needed for backward compat: EVENT type 3 has the same structure as type 2 CNTEventType3 = namedtuple( "CNTEventType3", ( "StimType KeyBoard KeyPad_Accept Offset Type " "Code Latency EpochEvent Accept2 Accuracy" ), ) def _get_event_parser(event_type): if event_type == 1: event_maker = CNTEventType1 struct_pattern = "