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

Skip first "New Segment" BrainVision marker #13100

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

cbrnr
Copy link
Contributor

@cbrnr cbrnr commented Feb 4, 2025

Fixes #13095. This PR skips the first "New Segment" BrainVision marker, as it only contains the recording time (which is already available in info["meas_date"]). I decided to not do anything with subsequent "New Segment" markers, as such changes could be unexpected.

Copy link
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note that I did agree to this change under the assumption that "New Segment" markers are now interpreted as BAD_ACQ_SKIP events (see #13095 (comment)). Which would have been a principled way of interpreting "New Segment" markers.

However, with the current changes, we are just removing the first marker.

It makes me a bit uncomfortable that we are basically taking events that are in the file and deciding which ones are irrelevant and which ones aren't. This should be a user choice, and we have very straight forward ways of filtering which events to keep and which not (proper use of event_id).

There are also several other events that are commonly not used, like Mk2=Comment,ControlBox is not connected via USB,41,1,0, see for example https://gin.g-node.org/sappelhoff/mpib_ecomp_sourcedata/src/master/sub-01/dual/sub-01_stream-dual.vmrk#L13 -- why would we then not remove those, too?

@cbrnr
Copy link
Contributor Author

cbrnr commented Feb 5, 2025

I think the answer is simple: we are not discarding the information contained in this first New Segment marker (the recording time), whereas there would be no other place to store the information from that other example you're mentioning.

@cbrnr
Copy link
Contributor Author

cbrnr commented Feb 5, 2025

But yes, I'm also fine with converting all New Segment markers to BAD_ACQ_SKIP, but where would we store the datetime in those later markers then? We'd be losing information, which we should avoid.

@sappelhoff
Copy link
Member

yes, the logic is solid. Maybe this comes down to my personal preference of having the annotations in mne correspond to what I can see when opening my VMRK file in a code editor. But I realize that probably a minority of users feel this way, so ok from me to go ahead with it.

Names of channels or list of indices that should be designated
EOG channels. Values should correspond to the header file.
Default is ``('HEOGL', 'HEOGR', 'VEOGb')``.
eog : list or tuple of str
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert. This makes it sound like "list of str or tuple of str" but "list of int" is also supported

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied it from the function, so this should be changed there as well then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced it with something more explicit, I hope this is fine now. It's also in the description of the misc parameter now (which I didn't touch before).

mne/io/brainvision/brainvision.py Outdated Show resolved Hide resolved
mne/io/brainvision/brainvision.py Show resolved Hide resolved
onset = np.array(onset, dtype=float) / sfreq
duration = np.array(duration, dtype=float) / sfreq
if ignore_marker_types:
description = [d.split("/")[-1] for d in description]
Copy link
Member

@drammock drammock Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a maxsplit=1 here? Can the text after the market tour marker type ever contain a slash?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically both BrainVision marker types and descriptions can contain /, which would break our logic here. However, maxsplit=1 doesn't save us, because there could be one or more / in the description. Currently, we work under the assumption that neither the type nor the description of a marker contains a /. If we want to be on the safe side, we should replace all / before converting to annotations, after which maxsplit=1 is not necessary anymore. Do you want me to do this here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this be a possible regression then? The old way which did:

if not ignore_marker_types:
    description.append(mtype + "/" + mdesc)
else:
    description.append(mdesc)

didn't have a problem handling markers or descriptions that contained /

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely right! I implemented a more robust version, LMK if you're happy with it.

@cbrnr cbrnr force-pushed the brainvision-first-marker branch from 981a53d to 20cbdc5 Compare February 7, 2025 17:17
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

Successfully merging this pull request may close these issues.

Do not import first BrainVision datetime marker
4 participants