Skip to content

Do not import first BrainVision datetime marker #13095

Closed

Description

@cbrnr

Currently, exporting to BrainVision creates an extra marker containing the meas_date. Usually, this datetime is stored as the first marker, which looks like this:

Mk1=New Segment,,1,1,0,20231207111507000000

Importing that file into MNE again therefore implies that there is an additional marker that was not present before. In addition, I think the reader parses the measurement date so that this marker is not necessary at all.

I'm not quite sure how to handle this situation, so I'd appreciate your input @sappelhoff @larsoner @drammock. I came up with the following options:

  1. Always ignore the first marker (if it is a New Segment).
  2. Always ignore all markers of type New Segment.
  3. Provide an option to ignore all New Segment markers.

I think a transparent solution without an additional parameter would be nice, WDYT?

Activity

  1. sappelhoff commented on Feb 3, 2025

    @sappelhoff
    Member

    The "New Segment" marker is not really an "experiment event", but rather information about the data. Continuous data will only have one of such markers (in the beginning) ... if you pause a recording in BV Recorder and then start it again, it will put another "New Segment" marker in at that point, as far as I know.

    I don't really understand the problem yet, I think. Is it the following?

    1. you have data with 3 markers A, B, C in some format
    2. you import this data into MNE and then export it to BrainVision
    3. the exported BrainVision data now has 4 markers: "New Segment", A, B, C
    4. the "New Segment" marker is breaking pipelines that did not expect this marker

    If this is the problem, then I don't think there is something to change, as the "New Segment" marker is sort of a normal BrainVision occurrence 🤔 if anything, I'd then opt for your proposal 3.

    But happy to hear more about it and change my opinion.

  2. cbrnr commented on Feb 3, 2025

    @cbrnr
    ContributorAuthor

    Yes, but for step 4 I would say:

    1. When importing the BrainVision file, there are now four markers, so this breaks the round-trip.

    If the first marker is a "New Segment", which only contains the recording date, we already parse this information and make it available in info["meas_date"]. There is no need to duplicate this information here (in an rather unexpected location). So I would rather go with my first option and drop the first marker if it is a "New Segment" (but of course provide the recording date in info["meas_date"]).

  3. sappelhoff commented on Feb 3, 2025

    @sappelhoff
    Member

    When importing the BrainVision file, there are now four markers, so this breaks the round-trip.

    Are you saying that when doing N operations of reading and then writing back to BV, we will add a new "New Segment" marker on each iteration? If yes, then I agree that this is off.

    If however we write to BV for the first time and there is no "New Segment" marker, then I think we need to write it as the first marker, and put the meas date into it (where else would you put the meas date?).

  4. cbrnr commented on Feb 3, 2025

    @cbrnr
    ContributorAuthor

    No, we're not adding a new marker on each iteration, but adding this one marker is still not right I think. Or rather, adding the marker is fine (because that's where you put the measurement date), but we should not import that marker as an annotation.

  5. hoechenberger commented on Feb 3, 2025

    @hoechenberger
    Member

    Maybe I don't grasp the gravity of this issue fully, but I'd be +1 for simply ignoring this marker. I always have to manually drop this one after import, which is annoying

  6. cbrnr commented on Feb 3, 2025

    @cbrnr
    ContributorAuthor

    Basically exactly what I'm proposing!

  7. drammock commented on Feb 3, 2025

    @drammock
    Member

    adding this one marker is still not right I think. Or rather, adding the marker is fine (because that's where you put the measurement date), but we should not import that marker as an annotation.

    Is the New Segment marker part of the file spec? I'm assuming yes, otherwise we wouldn't be adding it in the first place. If that's correct, then the "problem" is that it shouldn't be interpreted as an annotation span. +1 to special-case the description New Segment as something to be ignored when creating annotations (though perhaps only when it's at the very beginning of the file? If it occurs in the middle, we should probably convert it to BAD_ACQ_SKIP as that's how we handle discontinuities in raw data streams generally)

  8. sappelhoff commented on Feb 3, 2025

    @sappelhoff
    Member

    Or rather, adding the marker is fine (because that's where you put the measurement date), but we should not import that marker as an annotation.

    I'd be fine with that and Dan's extension above, as long as we also document it in the docstr of the function. 👍

  9. sappelhoff commented on Feb 3, 2025

    @sappelhoff
    Member

    Is the New Segment marker part of the file spec? I'm assuming yes, otherwise we wouldn't be adding it in the first place.

    Just for completeness: Yes, Section 6.1 here: https://www.brainproducts.com/support-resources/brainvision-core-data-format-1-0/

    Image

    And in the example in 6.3.2:

    Image

  10. cbrnr commented on Feb 3, 2025

    @cbrnr
    ContributorAuthor

    Perfect, I'll prepare a PR then! Thanks for your input!

  11. changed the title [-]Exporting to BrainVision creates extra marker[/-] [+]Do not import first BrainVision datetime marker[/+] on Feb 4, 2025
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions