@@ -101,6 +101,7 @@ def read_raw_egi(
101101 channel_naming = "E%d" ,
102102 * ,
103103 events_as_annotations = True ,
104+ event_key = None ,
104105 verbose = None ,
105106) -> "RawEGI" :
106107 """Read EGI simple binary as raw object.
@@ -141,6 +142,15 @@ def read_raw_egi(
141142 The default will change from False to True in version 1.9.
142143
143144 .. versionadded:: 1.8.0
145+ event_key : str | None
146+ The MFF event key whose value is appended to annotation descriptions and extras
147+ when ``events_as_annotations=True``, and to stim channel names when
148+ ``events_as_annotations=False``. For example, ``event_key='cel#'`` will convert
149+ an MFF event code ``'stim'`` with ``cel#=1`` to ``'stim_1'``. These will also
150+ appear as ``'event_key_cel#': 1`` in annotations.extras
151+ Only supported for MFF files.
152+
153+ .. versionadded:: 1.11.0
144154 %(verbose)s
145155
146156 Returns
@@ -155,22 +165,31 @@ def read_raw_egi(
155165
156166 Notes
157167 -----
158- When ``events_from_annotations =True``, event codes on stimulus channels like
168+ When ``events_as_annotations =True``, event codes on stimulus channels like
159169 ``DIN1`` are stored as annotations with the ``description`` set to the stimulus
160170 channel name.
161171
162- When ``events_from_annotations =False`` and events are present on the included
163- stimulus channels, a new stim channel ``STI014 `` will be synthesized from the
172+ When ``events_as_annotations =False`` and events are present on the included
173+ stimulus channels, a new stim channel ``STI 014 `` will be synthesized from the
164174 events. It will contain 1-sample pulses where the Netstation file had event
165175 timestamps. A ``raw.event_id`` dictionary is added to the raw object that will have
166176 arbitrary sequential integer IDs for the events. This will fail if any timestamps
167177 are duplicated. The ``event_id`` will also not survive a save/load roundtrip.
168178
169179 For these reasons, it is recommended to use ``events_as_annotations=True``.
180+
181+ MFF event track XML files can store additional metadata in a
182+ ``<keys>`` child element of each ``<event>`` element. This corresponds to
183+ the ECI Event Data Stream "Key List" described in the
184+ `EGI Amp Server Pro SDK User Guide
185+ <https://www.egi.com/images/stories/manuals/amp-server-pro-sdk-3-0-network-apis-user-guide-rev-01.pdf>`__.
186+ For example, E-Prime driven experiments sometimes store the experimental condition
187+ in a ``'cel#'`` event key.
170188 """
171189 _validate_type (input_fname , "path-like" , "input_fname" )
172190 input_fname = str (input_fname )
173191 _validate_type (events_as_annotations , bool , "events_as_annotations" )
192+ _validate_type (event_key , (str , None ), "event_key" )
174193
175194 if input_fname .rstrip ("/\\ " ).endswith (".mff" ): # allows .mff or .mff/
176195 return _read_raw_egi_mff (
@@ -182,8 +201,10 @@ def read_raw_egi(
182201 preload ,
183202 channel_naming ,
184203 events_as_annotations = events_as_annotations ,
204+ event_key = event_key ,
185205 verbose = verbose ,
186206 )
207+
187208 return RawEGI (
188209 input_fname ,
189210 eog ,
0 commit comments