pymovements.Events.map_to_aois#
- Events.map_to_aois(aoi_dataframe: TextStimulus, *, preserve_structure: bool = True, verbose: bool = True) None[source]#
Map events to AOIs, ignoring non-fixations.
This function computes AOI membership only for rows whose
namestarts with"fixation"(e.g.,"fixation","fixation_ivt"). Rows that are not fixations are left unchanged and receiveNonevalues for all AOI columns. The original order and number of rows are preserved.Schema handling:
If
preserve_structure=True(default), we mirror legacy behavior when a listlocationcolumn exists: derivelocation_x/location_yand droplocation. This keeps downstream expectations about flat component columns.If
preserve_structure=False, no unnesting/derivation occurs and the originallocationlist column is preserved. Coordinates are extracted per-row without altering the frame.
AOI columns used for trial/page keys in the stimulus (
trial_column/page_column) are not appended to the events, as they are dropped byTextStimulus.get_aoito avoid duplicate columns during concatenation.- Parameters:
aoi_dataframe (TextStimulus) – Text stimulus defining AOI rectangles.
preserve_structure (bool) – Control whether to derive component columns and drop the list column as described above. Default: True.
verbose (bool) – If
True, show a progress bar. (default: True)
- Raises:
ValueError – If
aoi_dataframedoes not have eitherwidth_columnorend_x_columndefined.ValueError – If the events frame is empty.