neuralset.events.transforms.basic.AlignEvents

class neuralset.events.transforms.basic.AlignEvents(*, infra: Backend | None = None, trigger_type: str, trigger_field: str | tuple[str, ...], types_to_align: str | tuple[str, ...])[source][source]

Creates timelines where events (eg: Meg, FMRI) are aligned to a trigger (eg: Image / Word)

Parameters:
  • trigger_type (str) – event type that serves as trigger for aligning other events

  • trigger_field (str or tuple of str) – field that serves as hash for matching identical events (if tuple, the tuple of the fields will be used) Eg: Image: “filepath”, Word: “text”, chunked Video: (“filepath”, “offset”, “duration”)

  • types_to_align (str or tuple of str) – event types that must be aligned based on the trigger

Note

  • columns origin_index and origin_timeline will be added to the dataframe

  • there will be 1 trigger per created timeline, starting at start=0; other events will be shifted to match this timing

  • this transform can be used to perform average experiments, for example with a MEG extractor using aggregation="mean"

Example:

Timeline-1
MEG   m1-raw.fif start=0
Word  blublu     start=1
Word  bla        start=3
Timeline-2
MEG   m2-raw.fif start=0
Word  blublu     start=2

would produce the following events dataframe:

from the transform AlignEvents(trigger_type="Word", trigger_field="text", types_to_align="MEG"):

AlignEvents:blublu
Word  blublu     start=0
MEG   m1-raw.fif start=-1
MEG   m2-raw.fif start=-2
AlignEvents:bla
Word  bla        start=0
MEG   m1-raw.fif start=-3