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

Q: Cleaning stimulus channel without preloading everything #3914

Closed
kingjr opened this issue Jan 18, 2017 · 13 comments
Closed

Q: Cleaning stimulus channel without preloading everything #3914

kingjr opened this issue Jan 18, 2017 · 13 comments

Comments

@kingjr
Copy link
Member

kingjr commented Jan 18, 2017

Is there a way to clean a specific channel (e.g. stimulus channel) so as to do subsequent processing that do not require loading the entire dataset (e.g. find_events, Epochs etc) without having to preload the entire raw data?
e.g.

raw = Raw(raw_fname)
raw.pick_types(stim=True, meg=False)
stim_data = my_cleaning_function(raw.get_data())
events = find_events(stim_data)
epochs = Epochs(raw, events)
@larsoner
Copy link
Member

You have a call to find_events with an array, which I don't think we support (but could I guess), so you'd need something like:

raw = mne.io.read_raw_fif(...)
idx = raw.ch_names.index(stim_channel)
stim_data = my_cleaning_function(raw[idx][0])
raw_stim = mne.io.RawArray(stim_data, mne.create_info(1, raw.info['sfreq'], stim_channel)
events = mne.find_events(raw_stim)
events[:, 0] += raw.first_samp

@kingjr
Copy link
Member Author

kingjr commented Jan 18, 2017

Why can't we just pick channel type if data isn't loaded?

@larsoner
Copy link
Member

larsoner commented Jan 18, 2017

If that's the question, we should close as dup of #1766

To do it right it would complicate the logic inside the reader, and would take a decent amount of work. It's possible but not easy. A simple hack version can be constructed by returning a RawArray but this is not as clean and breaks class-specific functionality.

@larsoner
Copy link
Member

Actually now that #3896 by @jaeilepp is in, the right ideas are there at least. We'd want to generalize the code so it wasn't class-specific anymore, though, which would (again) take some thinking.

@kingjr
Copy link
Member Author

kingjr commented Jan 18, 2017

ok for closing in favour of #1766.

It may complicate the life of the header function, but frankly, here it's crazy. Cleaning trigger channel is eeg/ecog 101.

@kingjr kingjr closed this as completed Jan 18, 2017
@larsoner
Copy link
Member

Cleaning trigger channel is eeg/ecog 101.

I'm not sure what you mean? AFAIK people usually re-code events after extracting events from TTL voltages rather than change the TTL voltages to get appropriate events via event extraction.

@larsoner
Copy link
Member

... at least that's the MNE way

@kingjr
Copy link
Member Author

kingjr commented Jan 18, 2017

That's not trigger cleaning, it's event selection and (re)coding. It is common to have trigger artifacts that need signal processing.

@agramfort
Copy link
Member

agramfort commented Jan 18, 2017 via email

@kingjr
Copy link
Member Author

kingjr commented Jan 18, 2017 via email

@agramfort
Copy link
Member

agramfort commented Jan 18, 2017 via email

@kingjr
Copy link
Member Author

kingjr commented Jan 18, 2017 via email

@agramfort
Copy link
Member

agramfort commented Jan 18, 2017 via email

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

3 participants