Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating stimulus channel from scratch / adding events to the raw object #4208

Closed
ryscet opened this issue Apr 19, 2017 · 8 comments
Closed

Comments

@ryscet
Copy link

ryscet commented Apr 19, 2017

I have data from experiment in two different files, first and .edf file with EEG data and second a csv file with events. I would like to create a mne.Raw (mne.io.read_raw_edf()) object and afterwards add a stimulus channel to it.

From the csv file I created an array of events which I would like to add the the mne.Raw using raw.add_events(). This however requires a stimulus channel which is not there, so it needs to be created. I couldn't find an example or documentation describing how to create a stimulus channel from scratch or more generally on adding events from another file. Is events channel an array of 0's plus a value coding for event on all event indexes?

I understand I could create epochs data using the raw object created from edf file and events from csv file but for convenience I would like to store them in a single mne object, is there such possibility?

@jaeilepp
Copy link
Contributor

You can use add_channels

So the flow would be something like this:

info = mne.create_info(['STI'], raw.info['sfreq'], ['stim'])
stim_raw = mne.io.RawArray(stim_data, info)
raw.add_channels([stim_raw], force_update_info=True)

@ryscet
Copy link
Author

ryscet commented Apr 19, 2017

Okay, thanks! How should stim_data look like?

@jaeilepp
Copy link
Contributor

It should be 2d array. So something like

stim_data = np.zeros((1, len(raw.times))

@ryscet
Copy link
Author

ryscet commented Apr 19, 2017

Great, that worked. I didn't know what was the format of the stim_data, now it's clear. Perhaps this should go into documentation, I could make an example of how to add events from a separate file and a submit a pull request.

@ryscet ryscet closed this as completed Apr 19, 2017
@larsoner
Copy link
Member

That would be helpful @ryscet

@piotrdzwiniel
Copy link

It would be great to include in the documentation information about the required shape of raw objects send to add_channels function in add_list list parameter. When adding only one channel it is not clear to represent this one-dimensional channel as two-dimensional matrix n_channels, n_samples as for example (1, n_samples). It's not intuitive.

@girijesh97
Copy link

girijesh97 commented Feb 24, 2022

Hi @larsoner @ryscet @jaeilepp, I am working on a EEG data which is available here (https://git.scc.kit.edu/pd7949/brainwave-authentication). I am also stuck in the similar problem asked by @ryscet. I have three different files for each individual that contains EEG data, Events and time stamp. Likewise, I tried the method that has been mentioned here and here (https://mne.tools/stable/auto_tutorials/raw/20_event_arrays.html). But I am not able to understand how to read the events, and then merge with the raw data for further analysis. Sorry if this question appears to be naive because I am pretty new to brain signals, so any suggestion or help would be highly appreciated.

@larsoner
Copy link
Member

@girijesh97 this seems more like a question on usage, can you post it to https://mne.discourse.group ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants