-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
WIP, ENH: BrainVision impedance parsing #7771
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
The set of values / things that can be added to |
|
Thanks for the suggestion, I will look into this. |
|
Moved the parsed data into attributes of the RawBrainvision class |
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.
apparently they're two features here. The ability to read general metadata on channels and reading in averaged data ie Evoked objects in brainvision format.
mne/io/brainvision/brainvision.py
Outdated
| return len(markers_basename - bv_markers) == 0 | ||
|
|
||
|
|
||
| def parse_impedance(settings): |
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 should be a private function
| def parse_impedance(settings): | |
| def _parse_impedance(settings): |
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.
@honzaseda you forgot to make this method private as well
| SegmentationType=MARKERBASED | ||
| SegmentDataPoints=1100 | ||
| Averaged=YES | ||
| AveragedSegments=80 |
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.
does it mean it should be read as an Evoked dataset?
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.
Yes, if Averaged is set to YES, it means that the data file contains data that have been averaged across segments.
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 tells me that we should add a read_evoked_brainvision no?
I would rather not have raw_raw_brainvision read such a header without complaining
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.
Probably? I'm not really sure as i do not know the inner workings of MNE that well.
|
@sappelhoff or @cbrnr can you pitch in? |
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.
Hi @honzaseda, thanks for contributing these enhancements. --> might have been easier to try to include one at a time though :-)
I only had a look at the impedance parsing so far and that looks okay to me as it is. I am just not sure whether it's a good idea to make the impedances an attribute of raw, because BrainVision raw files will be the only files to have this attribute?
The alternative would be to optionally return the impedances as a data table at read time. e.g. raw, impedances = mne.io.read_raw_brainvision(path, return_impedances=True)
re: segmentation (not having checked the code yet) --> I never met somebody who used this feature of the BrainVision Recorder software :-) ... first time, yay.
|
There is |
I think this is okay. It will also be lost on FIF round-trip but that's also okay. If there are other readers that support impedances we can think about a more global way of storing them or something. As long as we pick a sensible attribute here we can always extend it to other readers later via a mixin or something.
This would also be okay, but it's not all that extensible of there are other attributes people will want from other readers. You end up with a bunch of
Users should not expect private attributes to be stable, they can be changed in a backward compatible way at any time during development with no warning. So we should not advertise that people store information they want in there, or make use of private attributes in general. BTW ideally / by design the only things that should actually live in |
|
Yes, if this should be used by users it's better not to rely on that private attribute. I'd vote for a simple |
|
one strategy could be to use the chs['loc'][6] entry for impedance.
We've come up with such a strategy to store wavelength for fNIRS data.
|
can we have unlimited space in the If it's bounded, using the limited space for impedance values would seem like a waste to me. If it's not bounded +1 Otherwise, with Eric's description I know also vote for a simple attribute. And I also vote for @honzaseda to split the two enhancements into 2 PRs =) |
|
chs pos is 12 values for all channels. for MEG is 3x3 rotation + 3
translation
for EEG it's 6 : location of channel + location of reference. So
technically we have 6 spare entries unused
… |
|
Removed the segmentation parsing, I will create a separate PR for this and leave only the impedance parsing here. Left the impedances as an attribute of the |
|
|
||
| Channels | ||
| -------- | ||
| # Name Phys. Chn. Resolution / Unit Low Cutoff [s] High Cutoff [Hz] Notch [Hz] Series Res. [kOhm] Gradient Offset |
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.
See comment in other PR, this should eventually be added to mne-testing-data
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.
for the sake of this PR you could add the impedances to one of the existing VHDR files in https://github.com/mne-tools/mne-python/tree/master/mne/io/brainvision/tests/data and then use that file for testing.
|
just a note, this PR could also come in handy for MNE-BIDS to automatically populate the We're having a short "unconference" at my institute soon, and maybe I'll find time there to finish this. Unless you have other plans @honzaseda ? |
I just went ahead and finished it, and included you in the credits. Thanks for making a start with this PR @honzaseda! See #7974 |
I was using the MNE tool for parsing BrainVision data files in a paper where we needed to parse all the information from the segmentation and impedance sections of a header file. As i did not find these informations in the current raw parsed data, an enhancement of the current parser was implemented that adds these sections to the raw info.
Considering a possible wider use case for these changes, we decided that this enhancement could be included in the tool directly.
Enhancements:
The function
parse_segmentationtakes any of the key-value pairs in the segmentation subsections of the BrainVision file starting withS e g m e n t a t i o n / A v e r a g i n g, as well as some of the added key-values in the Common Infos. The segmentation is stored in a new info itemsegmentation.The function
parse_impedancecreates adictof all the channel impedances from the header file. All of the channels in the raw info are iterated over, and if an impedance record exists, they are appended to the channel dict.The header file that these were tested on is in
mne/io/brainvision/tests/data/test_segmentation_impedance.vhdr(also used for the unit tests)Problems:
However, even though these changes work well in our local environment and the parsing of the values in itself works good, implementing these changes directly to MNE causes some of the already existing unit tests to fail, and I'm not really sure how to solve these issues. When i try to add any new attributes to the info structure, even an empty list.
These are the failing tests:
Any ideas where the problem could be for the existing tests and how this could be improved?