Splitting Event IDs

How can I select subsets of each event type? For example, I have 80 markers with event_id=1 and I want to select two subsets of these markers (maybe based on their index) and create two new marker types by changing their event_id. I hope it makes sense.

Kind regards,
Mostafa

The Events array is a NumPy array, where the first column is sample number and the last column is the associated event ID. So if you have a way of determining which events should be split off, you can modify the event array at those indices. For example, if you want to change the event ID of the events below:

orig_events_array = [
    [12345, 0, 1],
    [12377, 0, 1],  # <- this one
    [12421, 0, 1],
    [12493, 0, 1],  # <- and this one
    ...
]

Then you can use NumPy integer array indexing to assign new values to just the rows you want to change:

new_event_id = 3  # pick any integer you want
rows_to_change = [1, 3]
columns_to_change = [-1] * len(rows_to_change)  # always change only the last column
orig_events_array[(rows_to_change, columns_to_change)] = new_event_id

If you already have an event ID dictionary like dict(auditory=1, visual=2) then you’ll also want to update it to include an entry for your new event type.