-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
FIX/ENH: loading EDF annotations #1234
Conversation
@t3on @christianbrodbeck I guess this is for you :) |
I've added a parser as a private member of RawEDF. Not sure how to expose the functionality, though. BTW, how do you get coveralls to automatically comment on PRs? :) |
we need the help of our EDF experts to review :) ping @t3on @christianbrodbeck I have no experience with this format... in the MNE way events are used to generate a stim channel that can be parsed with find_events function |
In that case I might have got it wrong. I thought the stim channel was specific to EDF. |
find_events works on an EDF raw? |
It does not work on data where events are stored as EDF+ annotations: http://www.edfplus.info/specs/edfplus.html#edfplusannotations |
@kazemakase Coveralls will automatically comment once the build is passing (it's currently not). But it's actually a bit better to rely on your own local nose/coverage output, though, since Travis only runs a subset of the full test suite. |
@t3on ? I've never worked with EDF either... |
@eric89gxl I was just wondering because i can't get coveralls to comment on PRs in the SCoT repo even when the build is passing. |
Ahh, for a different repo... you have to enable it on Assuming you've seen that option and enabled it, you also have to have |
Yep, that option is enabled and coveralls receives coverage information from travis. Good to know it doesn't work everywhere. Maybe it doesn't like capital letters in the repo name? :) I'll have another look at .travis.yml. |
sorry, just got notified. my email was silent on this ;) I am not clear on what the issue is. there is a private function, |
@t3on I assume you refer to the stim channel and event files as described here: http://martinos.org/mne/stable/manual/browse.html#events-and-annotations Everything is fine if the EDF files in question were created according to that specification. However, I am trying to load data recorded by someone who never even heard of MNE. There is no stim channel or annotation file. Instead, there is a channel that contains ascii encoded tags (see my link above), which the current implementation is unable to read correctly. |
@@ -234,7 +234,12 @@ def _read_segment(self, start=0, stop=None, sel=None, verbose=None, | |||
for i, samp in enumerate(n_samps): | |||
chan_data = data[i::n_chan] | |||
chan_data = np.hstack(chan_data) | |||
if samp != max_samp: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be deleted. this is used for when the sampling across different channels aren't unified. it does a resampling of the lower sampled channels to match the max sampling rate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not delete it entirely (see line 242). Instead, I added separate handling of the annotation channel (which I thought was stim_channel).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, sorry, my mistake, didn't see the elif.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, what happens if you resample the stim channel (assuming it is a correct MNE stim channel)? Wouldn't the implicit filter hurt it?
do you have an example of a file that has the text annotation as channel in the data? |
Sure, I was working with that file: http://www.physionet.org/physiobank/database/eegmmidb/S001/S001R06.edf |
If i got this right, MNE expects a certain stim_channel where events are encoded. There are two ways to obtain a stim_channel for an edf file: I have added a parameter Parsing the tal channel works already, but how are events encoded in the stim channel? |
Have a look at the find_events function for example |
Is there a way to encode simultaneous events in the stim channel? |
No. You need unique events |
If you need to, you can conceptually do something like this using a binary representation. Each event number If this is too annoying, you can also include multiple stim channels in a FIFF file, they just need different channel names. IIRC usually |
# don't resample tal_channel, | ||
# pad with zeros instead. | ||
chan_data = np.hstack([chan_data, | ||
[0]*int(max_samp-samp)*blocks]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespaces missing between operators
I made sure that the stim channel does not get resampled, and that the int16 values (each containing two characters) are not clamped.
Parsing the stim channel to get events of the form [onset, duration, 'annotation'] remains to be done.
I'm not sure where to store these events, though. Currently I consider not to store the events at all. Instead, a member function would simply parse and return the event list. Any thoughts?