question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Brainvision marker parser fails w/ [] characters

See original GitHub issue

I have a (perhaps poorly chosen) marker in a file I received,

Mk9=Comment,Discontinuit? [B] 4156 ms,136544,1,0

which at brainvision.py:269 is being found with

items = re.findall(r"^Mk\d+=(.*)", mk_txt, re.MULTILINE)

but this regex stops completely at the [ character, not finding the rest of the line nor the markers which follow.

I’m not a regex ninja but if I manage to fix, I’ll send a PR. In the meantime, I will change remove the offending characters in the file and move on.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sappelhoffcommented, Aug 6, 2018

You are right @maedoc: https://github.com/mne-tools/mne-python/blob/18755d22c3752b767dd493ffb4ffa5360bd322b4/mne/io/brainvision/brainvision.py#L305-L312

The r"\[.*\]" part is being used to find the line where a new section begins like [Marker Infos] or [Common Infos]

Actually, this points to a very simple fix. Instead of m = re.search(r"\[.*\]", mk_txt) we can use ^ and $ to get: m = re.search(r"^\[.*\]$", mk_txt). This asserts that [Marker Infos] and other section headers are always written isolated and on a single line (which is true in BrainVision format). Then even your weird markers should be captured 😉

see: #5412

0reactions
maedoccommented, Jul 31, 2018

@sappelhoff indeed. I just realized that a few lines up from there, there’s a regex for r"\[.*\]" that may be the culprit.

Read more comments on GitHub >

github_iconTop Results From Across the Web

BrainVision Analyzer - TSG Doc
The new Analyzer Automation Reference Manual now includes an extensive theoretical chap- ter that uses short examples to familiarize you with important basic ......
Read more >
Brain Vision Analyzer User Manual Version 1.05
The Brain Vision Analyzer software, frequently abbreviated to ... all markers with the same sequence of characters are handled in the.
Read more >
All you ever wanted to know about markers in BrainVision ...
Investigating electrophysiological effects requires precisely timed markers. Here is how to manage, edit and process them in Analyzer 2.
Read more >
Import Data from Brain Vision Analyzer into Matlab - YouTube
Import Data from Brain Vision Analyzer into Matlab. 865 views 1 year ago. Jonah Kember. Jonah Kember. 127 subscribers. Subscribe.
Read more >
mne-python/brainvision.py at main - GitHub
Get annotations from marker file ... Not sure why we special-handle the "," character here, ... likely exported from BrainVision Analyzer?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found