You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Do not import first BrainVision datetime marker #13095
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:
Always ignore the first marker (if it is a New Segment).
Always ignore all markers of type New Segment.
Provide an option to ignore all New Segment markers.
I think a transparent solution without an additional parameter would be nice, WDYT?
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?
you have data with 3 markers A, B, C in some format
you import this data into MNE and then export it to BrainVision
the exported BrainVision data now has 4 markers: "New Segment", A, B, C
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.
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"]).
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?).
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.
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
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)
Reacted by Clemens Brunner, Stefan Appelhoff and Richard Höchenberger
Activity
sappelhoff commentedon Feb 3, 2025
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?
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.
cbrnr commentedon Feb 3, 2025
Yes, but for step 4 I would say:
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 ininfo["meas_date"]).sappelhoff commentedon Feb 3, 2025
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?).
cbrnr commentedon Feb 3, 2025
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.
hoechenberger commentedon Feb 3, 2025
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
cbrnr commentedon Feb 3, 2025
Basically exactly what I'm proposing!
drammock commentedon Feb 3, 2025
Is the
New Segmentmarker 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 descriptionNew Segmentas 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 toBAD_ACQ_SKIPas that's how we handle discontinuities in raw data streams generally)sappelhoff commentedon Feb 3, 2025
I'd be fine with that and Dan's extension above, as long as we also document it in the docstr of the function. 👍
sappelhoff commentedon Feb 3, 2025
Just for completeness: Yes, Section 6.1 here: https://www.brainproducts.com/support-resources/brainvision-core-data-format-1-0/
And in the example in 6.3.2:
cbrnr commentedon Feb 3, 2025
Perfect, I'll prepare a PR then! Thanks for your input!
[-]Exporting to BrainVision creates extra marker[/-][+]Do not import first BrainVision datetime marker[/+]