Skip to content

Conversation

@Lychfindel
Copy link
Contributor

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.

@Lychfindel Lychfindel requested a review from sappelhoff as a code owner April 12, 2022 09:16
@welcome
Copy link

welcome bot commented Apr 12, 2022

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

Copy link
Member

@agramfort agramfort left a 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?

Copy link
Member

@agramfort agramfort left a 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? 🙏

@Lychfindel
Copy link
Contributor Author

Sure, here it is!

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.

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"

Copy link
Contributor

@cbrnr cbrnr left a 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!

Comment on lines 1046 to 1047
This function reads a .fif, .fif.gz, .vmrk, .amrk .edf, .txt, .csv .cnt,
.cef, or .set file and makes an :class:`mne.Annotations` object.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.

Comment on lines 73 to 75
ahdr_format = False
if ext == '.ahdr':
ahdr_format = True
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ahdr_format = False
if ext == '.ahdr':
ahdr_format = True
ahdr_format = True if ext == '.ahdr' else False

Comment on lines 468 to 470
ahdr_format = False
if ext == '.ahdr':
ahdr_format = True
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if not (unit): # For truncated vhdrs (e.g. EEGLAB export)
if not unit: # For truncated vhdrs (e.g. EEGLAB export)

ch_dict[_AHDR_CHANNEL_NAME] = _AHDR_CHANNEL_NAME
ch_names[-1] = _AHDR_CHANNEL_NAME
orig_units[_AHDR_CHANNEL_NAME] = 'V'
cals[-1] = float(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cals[-1] = float(1)
cals[-1] = 1.

@Lychfindel
Copy link
Contributor Author

Thank you for the reviews!
I agree that the naming v/ahdris not good since it makes searching code worse. What do you suggest? Explicitly write vhdr or ahdr?
About naming there is also a problem in the functions like _read_vmrk, _aux_vhdr_info and _get_vhdr_info. I did not change it in order to avoid compatibility problems, but probably it would be more correct to rename these functions in just _read_mrk, _aux_hdr_info and _get_hdr_info.

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!

@agramfort
Copy link
Member

@cbrnr
Copy link
Contributor

cbrnr commented Apr 13, 2022

I agree that the naming v/ahdris not good since it makes searching code worse. What do you suggest? Explicitly write vhdr or ahdr?

I'd write vhdr/ahdr.

About naming there is also a problem in the functions like _read_vmrk, _aux_vhdr_info and _get_vhdr_info. I did not change it in order to avoid compatibility problems, but probably it would be more correct to rename these functions in just _read_mrk, _aux_hdr_info and _get_hdr_info.

Yes, good idea.

@Lychfindel
Copy link
Contributor Author

About naming there is also a problem in the functions like _read_vmrk, _aux_vhdr_info and _get_vhdr_info. I did not change it in order to avoid compatibility problems, but probably it would be more correct to rename these functions in just _read_mrk, _aux_hdr_info and _get_hdr_info.

Yes, good idea.

Ok, then I will rename the functions.
Should I keep an alias of the functions with the old names for backward compatibility, or since they are just internal it is not needed?

@cbrnr
Copy link
Contributor

cbrnr commented Apr 13, 2022

Since these are not public functions you can change their names without keeping the old names around.

@Lychfindel
Copy link
Contributor Author

Ok great, I've updated all the names and the docs, except for the arguments of RawBrainVision and read_raw_brainvision since they are public

@agramfort
Copy link
Member

@Lychfindel can you merge the main branch here and see why CIs complain? 🙏

Copy link
Member

@larsoner larsoner left a 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...

@sappelhoff sappelhoff changed the title Ahdr Add support for BrainVision ahdr/amrk format, as produced by the V-AMP Apr 18, 2022
@sappelhoff sappelhoff added the ENH label Apr 18, 2022
@sappelhoff sappelhoff added this to the 1.1 milestone Apr 18, 2022
@agramfort
Copy link
Member

@Lychfindel do you need help here?

@Lychfindel
Copy link
Contributor Author

Sorry @agramfort , last week was pretty busy.
I'm working on it now, but I don't understand how to add a test function that uses the new test set.
Could you help me if I provide you a test set and a test function?

@larsoner
Copy link
Member

Can you try following the instructions here on how to add your tiny test file(s) to mne-testing-data?

https://github.com/mne-tools/mne-testing-data#add-or-change-files-in-the-repo-for-use-with-mne

Then you should be able to update the tests here to use the files.

Copy link
Member

@larsoner larsoner 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 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>
Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

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

LGTM

+1 for MRG if CIs are green

thx @Lychfindel

@larsoner larsoner merged commit c4c100c into mne-tools:main Apr 26, 2022
@larsoner
Copy link
Member

Thanks again @Lychfindel !

@Lychfindel
Copy link
Contributor Author

Thanks to you! Happy to contribute to the package!

larsoner added a commit to larsoner/mne-python that referenced this pull request Apr 27, 2022
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New version of brain vision data

5 participants