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
Make ch_type reading more robust & support RESP #482
Conversation
If mapping of channel types from BIDS to MNE fails, retry with all-uppercase channel types. Closes mne-toolsGH-481. I anticipate this will only be a temporary thing and therefore didn't add a dedicated test for this. This commit also adds support for mapping respiratory channels between BIDS and MNE.
Codecov Report
@@ Coverage Diff @@
## master #482 +/- ##
=======================================
Coverage 93.70% 93.70%
=======================================
Files 11 11
Lines 1762 1763 +1
=======================================
+ Hits 1651 1652 +1
Misses 111 111
Continue to review full report at Codecov.
|
Why did you remove defaultdict? |
I thought we had discussed that in #481 in the top comment, but actually I only posted a followup comment and talked about this with @agramfort on Slack. From #481:
Quoting my followup comment:
So what happened in my was that I somehow, silently, ended up with incorrect channel assignments due to the default dict (how exactly this happened I would still need to investigate) @sappelhoff @adam2392 I would love to hear your view on this too :) |
mmmh yes, it sounds like defaultdict is a dangerous code practice here. We should handle our cases explicitly and fail/warn early. |
doc/whats_new.rst
Outdated
@@ -33,6 +33,8 @@ Changelog | |||
- :func:`write_raw_bids` now adds citations to the README, by `Alex Rockhill`_ (`#463 <https://github.com/mne-tools/mne-bids/pull/463>`_) | |||
- :func:`make_dataset_description` now has an additional parameter ``dataset_type`` to set the recommended field ``DatasetType`` (defaults to ``"raw"``), by `Stefan Appelhoff`_ (`#472 <https://github.com/mne-tools/mne-bids/pull/472>`_) | |||
- :func:`mne_bids.copyfiles.copyfile_brainvision` now has an ``anonymize`` parameter to control anonymization, by `Stefan Appelhoff`_ (`#475 <https://github.com/mne-tools/mne-bids/pull/475>`_) | |||
- :func:`mne_bids.read_raw_bids` and :func:`mne_bids.write_raw_bids` now map respiratory (``RESP``) channel types, by `Richard Höchenberger` (`#482 <https://github.com/mne-tools/mne-bids/pull/482>`_) | |||
- :func:`mne_bids.read_raw_bids` now tries to correctly map channel types that are not in all-uppercase letters. Since this is in violation of BIDS, a warning is raised, by `Richard Höchenberger` (`#482 <https://github.com/mne-tools/mne-bids/pull/482>`_) |
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.
not sure if I would say this in the changelog ... i'd rather treat it silently. --> but let's see, we are not done discussing anyway, with Mainak's point that BIDS is agnostic at best, ambiguous at worst about casing
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.
Another (temporary?) solution for MNE-BIDS could also be to always convert to uppercase when reading BIDS channel types, i.e.,
for ch_name, ch_type in zip(ch_names_tsv, ch_types_json):
updated_ch_type = bids_to_mne_ch_types.get(ch_type.upper(), None) # <-- !!!
if updated_ch_type is not None:
channel_type_dict[ch_name] = updated_ch_type
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.
@jasmainak WDYT?
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.
@sappelhoff
I've dropped this changelog entry.
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.
I think we need to decide: 1) how specification treats the cases, 2) whether the validator is an accurate reflection of the specification, and 3) what we do in MNE-BIDS about it?
From a user perspective, I think it's nicer if the cases are taken care of in MNE-BIDS without complaining. E.g., through blah.upper()
or blah.lower()
. You have a similar situation with email addresses: you expect people to use the same casing but actually it doesn't matter. I would still have the validator be more whiny so that we are more forgiving to downstream applications that are not as careful as MNE-BIDS.
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.
merge when you're happy here.
I am really happy to see that actually using more and more BIDS dataset to do automatic processing we find all these issues !
@sappelhoff or @jasmainak feel free to merge |
thanks a ton @hoechenberger ! |
PR Description
If mapping of channel types from BIDS to MNE fails, retry with all-uppercase channel types. Closes GH-481.
I anticipate this will only be a temporary thing and therefore didn't add a dedicated test for this. – However, it does come with a breaking change: we're not using a
defaultdict
for the mapping anymore.This commit also adds support for mapping respiratory channels between BIDS and MNE.
Merge checklist
Maintainer, please confirm the following before merging: