-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add support for BrainVision ahdr/amrk format, as produced by the V-AMP #10515
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
Conversation
|
Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴🏽♂️ |
agramfort
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Lychfindel can you look into the flake8/pep8 errors?
agramfort
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Lychfindel can you add an entry in the file latest.inc to document the enhancement? 🙏
|
Sure, here it is! |
sappelhoff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great PR, looks good to me!
Maybe a (personal) nitpick -- but I would appreciate it in the docstr you wouldn't talk about v/amrk and v/ahdr files. This makes searching the code harder/worse and might also be confusing for people who have never heard about amrk / ahdr.
What do others think?
Finally, (trivia question) for vhdr/vmrk I always thought this would mean "vision header" or "vision marker", as abbreviated from "brain vision" (the system by Brain Products, the company) ... was I wrong? Because I don't know what the "a" could possibly stand for in "ahdr" / "amrk"
cbrnr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than my nitpicks LGTM!
mne/annotations.py
Outdated
| This function reads a .fif, .fif.gz, .vmrk, .amrk .edf, .txt, .csv .cnt, | ||
| .cef, or .set file and makes an :class:`mne.Annotations` object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| This function reads a .fif, .fif.gz, .vmrk, .amrk .edf, .txt, .csv .cnt, | |
| .cef, or .set file and makes an :class:`mne.Annotations` object. | |
| This function reads a .fif, .fif.gz, .vmrk, .amrk .edf, .txt, .csv, .cnt, | |
| .cef, or .set file and makes an :class:`mne.Annotations` object. |
mne/io/brainvision/brainvision.py
Outdated
| ahdr_format = False | ||
| if ext == '.ahdr': | ||
| ahdr_format = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ahdr_format = False | |
| if ext == '.ahdr': | |
| ahdr_format = True | |
| ahdr_format = True if ext == '.ahdr' else False |
mne/io/brainvision/brainvision.py
Outdated
| ahdr_format = False | ||
| if ext == '.ahdr': | ||
| ahdr_format = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
mne/io/brainvision/brainvision.py
Outdated
| ch_names[n] = name | ||
| if resolution == "": | ||
| if not(unit): # For truncated vhdrs (e.g. EEGLAB export) | ||
| if not (unit): # For truncated vhdrs (e.g. EEGLAB export) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if not (unit): # For truncated vhdrs (e.g. EEGLAB export) | |
| if not unit: # For truncated vhdrs (e.g. EEGLAB export) |
mne/io/brainvision/brainvision.py
Outdated
| ch_dict[_AHDR_CHANNEL_NAME] = _AHDR_CHANNEL_NAME | ||
| ch_names[-1] = _AHDR_CHANNEL_NAME | ||
| orig_units[_AHDR_CHANNEL_NAME] = 'V' | ||
| cals[-1] = float(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| cals[-1] = float(1) | |
| cals[-1] = 1. |
|
Thank you for the reviews! About the naming I always thought that a stays for analyzer since officially it could be open only with the BrainVision Analyzer software… but it just my guess! |
|
@Lychfindel you need an update here too https://github.com/mne-tools/mne-python/blob/main/mne/io/_read_raw.py#L34 |
I'd write
Yes, good idea. |
Ok, then I will rename the functions. |
|
Since these are not public functions you can change their names without keeping the old names around. |
|
Ok great, I've updated all the names and the docs, except for the arguments of |
|
@Lychfindel can you merge the main branch here and see why CIs complain? 🙏 |
larsoner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not add a new file to tests/data, see above...
|
@Lychfindel do you need help here? |
|
Sorry @agramfort , last week was pretty busy. |
|
Can you try following the instructions here on how to add your tiny test file(s) to mne-testing-data? Then you should be able to update the tests here to use the files. |
larsoner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few tiny things (only one of which is strictly necessary to make CIs happy), otherwise LGTM! Will merge once you push a tiny commit to make CIs happy.
FYI if you want to make all of my suggested changes, on the "Files changed" screen you can "Add suggestion to batch" to all three of them and then commit all at once.
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
agramfort
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Thanks again @Lychfindel ! |
|
Thanks to you! Happy to contribute to the package! |
* upstream/main: MNT: dock area (mne-tools#10575) MNT: dialog box icon (mne-tools#10573) ENH: Add head_source option (mne-tools#10569) fix for broken subjdir (mne-tools#10574) MAINT: Add export functions to env (mne-tools#10563) Add support for BrainVision ahdr/amrk format, as produced by the V-AMP (mne-tools#10515)
Reference issue
Example: Fixes #6613
What does this implement/fix?
The PR implements the acquisition of BrainVision data in ahdr format. It also adjust the header regular expression to handle ahdr data saved with V-AMP.
Additional information
The ahdr format introduces a fake channel in the data as a kind of encryption, the rest of channels and unit can be trusted. Therefore, in the submitted code, the data are read considering one more channel, and after the initialization of the BrainVision object, this channel is dropped.