Greetings,

I’m doing a project using MEG and I have been trying to find a reliable way to convert STIM channel signals to events to properly filter my epochs based on more than 1 event code at the same time.

I have checked the MNE tutorial about it and some posts here on the forum, but I’m still unsure how to address it due to the way that my event codes were sent to the recording machine.

Instead of using the composite channel as the reference for all event ID’s as in the example in the tutorial page, my event codes are organized in the following pattern:

STI001 to STI008: Each of the channels has a unique event recorded. All events have the same event IDs but represent different event codes.(Event ID value 5, event codes 1,2,4,8,16…) Event codes are independent for each channel.

STI009 to STI016: The events from all channels together work as a composite channel to give a single number.

Since I’m not using a single composite channel, I’m using a different way to get my event IDs (code shared below).

Using the code below, I have been having some issues with other MNE functions since I also have to adapt it for all of them.

I wonder if anybody else had the same issue. Using MNE tools, Is there a better option to filter my epochs using multiple event IDs from different channels at the same time?

Thank you.

```
####################################################################
# Code to read events.
events = []
for i in range(9):
tmp = mne.find_events(raw, stim_channel='STI00'+str(i+1))
events.append(np.delete(tmp,1,1))
for i in range(9,16):
tmp = mne.find_events(raw, stim_channel='STI0'+str(i+1))
events.append(np.delete(tmp,1,1))
ts = np.array([0,0])
for channel in events:
ts=np.concatenate((ts,channel[:,0]))
ts=np.sort(np.unique(ts))
composite = np.zeros_like(range(17))
empty_row = np.zeros_like(range(16))
for t in ts:
for counter,channel in enumerate(events):
if t in channel:
empty_row[counter]=1
composite=np.vstack((composite,np.concatenate(([t],empty_row))))
empty_row.fill(0)
factor = np.array([1,2,4,8,16,32,64,128,1,2,4,8,16,32,64,128])
comp2 = np.array([0,0,0])
for row in composite:
tmp = np.array([0,0,0])
tmp = [row[0],np.matmul(row[1:9],factor[0:8]),np.matmul(row[9:17],factor[8:16])]
comp2 = np.vstack((comp2,tmp))
del tmp, composite,channel,counter,empty_row,factor,t,ts,events,i,row
```