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