pymovements.Events.merge_subsequent_close_events#
- Events.merge_subsequent_close_events(name: str = 'fixation', max_gap: int | float = 50, verbose: bool = False) None[source]#
Merge subsequent events if they are separated by a gap smaller than a threshold.
- Parameters:
Examples
Let’s create some example events first:
>>> events = Events( ... name='fixation', ... onsets=[0, 2, 5, 13, 21, 22, 30, 40, 53, 73], ... offsets=[1, 3, 10, 20, 22, 29, 35, 49, 70, 90], ... ) >>> events.frame.shape (10, 4)
Merging all events with particular name with a gap smaller than 10 ms:
>>> events.merge_subsequent_close_events(name='fixation', max_gap=10) >>> events.frame shape: (1, 4) ┌──────────┬───────┬────────┬──────────┐ │ name ┆ onset ┆ offset ┆ duration │ │ --- ┆ --- ┆ --- ┆ --- │ │ str ┆ i64 ┆ i64 ┆ i64 │ ╞══════════╪═══════╪════════╪══════════╡ │ fixation ┆ 0 ┆ 90 ┆ 90 │ └──────────┴───────┴────────┴──────────┘
This combined all the smaller events into a single event with longer duration.