Skip to content

semantics for events with duration #2665

Closed

Description

@jasmainak

This relates partly to reproducing the brainstorm results in #2587. Currently, mne-python does not have the semantics to handle annotations with durations. One usecase is to visualize bad segments in the raw data using raw.plot(). I am opening the issue so that the API can be discussed.

cc @jaeilepp @agramfort @dengemann

Activity

  1. agramfort commented on Dec 2, 2015

    @agramfort
    SponsorMember
  2. jasmainak commented on Dec 2, 2015

    @jasmainak
    MemberAuthor

    can you give an example how it would look if there were more than one segment + a few experiment-related events? Would you allow for overlapping events?

  3. jasmainak commented on Dec 2, 2015

    @jasmainak
    MemberAuthor

    what happens when you have some events which have a duration and others which don't have a duration?

  4. dengemann commented on Dec 2, 2015

    @dengemann
    Member

    what happens when you have some events which have a duration and others which don't have a duration?

    we could have lists of arrays or 3D arrays

    Would you allow for overlapping events?

    open to the user, you can put in your array whatever you want

    consequence is that it's not obvious if it's a bad segment or not, unless
    for example we say that if the event id is negative it is bad segment.

    we could have a user defined bads tag or as you say negative

  5. larsoner commented on Dec 2, 2015

    @larsoner
    Member

    I was thinking:

    100 200 1
    

    i.e., onset-offset-kind.

  6. dengemann commented on Dec 2, 2015

    @dengemann
    Member

    i.e., onset-offset-kind.

    but how do you then combine this with the exisiting approach?

  7. jasmainak commented on Dec 2, 2015

    @jasmainak
    MemberAuthor

    @Eric89GXL : the documentation currently says:

    The first column contains the event time in samples and the third column contains the event id. For output = 'onset' or 'step', the second column contains the value of the stim channel immediately before the the event/step.

    The second column does not agree with what you propose

  8. larsoner commented on Dec 2, 2015

    @larsoner
    Member

    How we save and load the annotations is to me a mostly separate issue from how we use them. I'd prefer to have an annotation format that is compact and simple to understand, ideally requiring no new IO functions (onset-offset-kind fits this), and then work on how to use that annotation in a nice way from an API standpoint.

    But since you asked, I originally implemented a function that worked on epochs to eliminate any epochs that were considered "bad". I don't think that's the best approach, though. Instead we could "attach" them to raw objects (in memory only for now), then:

    1. They can easily be plotted with raw.plot
    2. When Epochs get constructed, they can be aware of the annotations attached to the Raw instance and drop any events (+/- tmin/tmax) that live in "bad" segments. Maybe the user needs to then pass bad_id in addition to event_id to mark which annotated segments are not to be used using key, value pairs, and we can mark in the drop log the right reason using the bad_id value.

    This to me is pretty simple from a user perspective, and also shouldn't be too difficult to implement from an API perspective.

  9. larsoner commented on Dec 2, 2015

    @larsoner
    Member

    The other nice thing about onset-offset-kind is that one can easily get to this format from other readers/annotation software, since it can be easily written out as plain test and read using our read_events function.

  10. larsoner commented on Dec 2, 2015

    @larsoner
    Member

    @jasmainak I know. It wouldn't be an "event" or -eve file anymore but an "annotation" or -ann file or so. I don't see a problem with redefining what the columns mean here.

  11. dengemann commented on Dec 2, 2015

    @dengemann
    Member

    I like this proposal a lot @Eric89GXL

  12. dengemann commented on Dec 2, 2015

    @dengemann
    Member

    It would be terribly useful to generate new raw files from sleep annotations(!) and so on.

  13. larsoner commented on Dec 2, 2015

    @larsoner
    Member

    Does anyone use annotation software, or work with anyone who does? It might be good to know what their saving formats look like. My guess is that it's onset, offset, and some form of text entry that allows the user to say what the event is. We'd be pretty close to that, only we'd force people to construct the bad_id dict, which I don't think is a bad thing.

  14. dengemann commented on Dec 2, 2015

    @dengemann
    Member

    why bad_id? why not annotation_id?

  15. jasmainak commented on Dec 2, 2015

    @jasmainak
    MemberAuthor

    @Eric89GXL , the problem is that you are going to break a lot of scripts if you redefine what it means

  16. 5 remaining items

  17. agramfort commented on Dec 2, 2015

    @agramfort
    SponsorMember
  18. jaeilepp commented on Dec 3, 2015

    @jaeilepp
    Contributor

    I like Eric's proposal too. I'm just wondering how to handle cropped data. With Eric's system it doesn't matter if the end part of the segment gets cut off, but if the beginning gets cut off, the segmentation data is lost.

    One option would be to use negative values for segments in combination with Alex's solution. This way it would be possible to infer the segments, but I'm not sure how it would behave with overlapping events without looking into the code.

  19. larsoner commented on Dec 3, 2015

    @larsoner
    Member

    @jaeilepp I'm not sure I follow. My system and Alex's system contain the same information, but just represent it differently. So if you e.g. add an annotation and crop the raw data, I don't see any problem with having / converting to negative times in the representation, and thus preserving the information.

  20. jaeilepp commented on Dec 3, 2015

    @jaeilepp
    Contributor

    Yeah, that was a mistake on my part. Realized it myself too after writing the comment.

  21. dengemann commented on Dec 3, 2015

    @dengemann
    Member

    We should use a new parameter with a clean annotation semantics. Combining events and annotations is than easy as semantics are clear defined (and separated from another). I'm afraid of a new objects here and the maintenance they bring with, let's stick with numpy arrays and simple structures. My 2 cents.

  22. jaeilepp commented on Dec 10, 2015

    @jaeilepp
    Contributor

    Yeah, I agree with Denis now. I noticed that when reading events from kit files (with files for testing), the second column has some data. So there are already semantics tied to it.

  23. dgwakeman commented on Dec 11, 2015

    @dgwakeman
    Contributor

    fwiw, I already do this on my neuromag system. I simply raise a trigger when a stimulus appears and don't lower it until the stimulus disappears. Thus the length of presentation is present in the file directly.

  24. agramfort commented on Dec 11, 2015

    @agramfort
    SponsorMember
  25. dgwakeman commented on Dec 11, 2015

    @dgwakeman
    Contributor

    It works fine in my cases. If my event is code 1 and the button response is code 255. I can still separate them using the "ignore" feature in the C code, or just deconvolving the signal into their binary values. Then I get the length of all.

  26. jaeilepp commented on Dec 12, 2015

    @jaeilepp
    Contributor

    The overlapping events can be masked out in MNE, so basically this is a question of where and how we want to separate the triggers. It would be nice to have separate annotations for events and segments, so it would be easier to deal with them separately (visualization, rejection etc.)

  27. added this to the 0.12 milestone on Dec 24, 2015
  28. larsoner commented on Feb 3, 2016

    @larsoner
    Member

    Closing, we have this now. Thanks @jaeilepp

  29. choldgraf commented on Feb 4, 2016

    @choldgraf
    Contributor

    Hey all - I know this issue has been closed and it looks like people's needs have been met here. That said, I just wanted to share a code snippet for an Events class that I've been using to keep track of metadata, trial lengths, etc for my trials. I've found it useful for quickly generating MNE events arrays using different kinds of trial types etc. Maybe somebody will find it useful :)

    https://github.com/choldgraf/ecogtools/blob/master/mneutils.py#L35

    If you guys think there's any place in the MNE repo for this, then I'm happy to contribute, but it sounds like people are satisfied already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions