-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
The order of raw1.info["bads"] should not matter when concatenating with raw0.info["bads"] #11501 #11502
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
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
|
Shit I got confused by git. I hope I didn't mess everything up. I think some files were moved to the cloud during a commit, that might be why there are so many file changes. How can I fix this? |
This reverts commit bff61e8.
|
Yikes, a ton of files deleted :) I looked through your commits and saw which one did this (bff61e8), and then did: Looks like the diff is now |
mne/io/base.py
Outdated
| bads_mismatch = bads0.symmetric_difference(badsi) | ||
| if bads_mismatch: | ||
| raise ValueError(f'raw[{i}][\'info\'][\'bads\'] do not match: ' | ||
| f'{sorted(bads_mismatch)}') | ||
| chs0 = set(raw[0].info['ch_names']) | ||
| chsi = set(raw[i].info['ch_names']) | ||
| ch_mismatch = chs0.symmetric_difference(chsi) |
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 code also could be more DRY -- it should exist in a loop like
for kind in ('bads', 'ch_names'):
... but this also now does a symmetric diff on the channel names, which I don't think we've discussed yet. I actually don't think this will work -- I'd expect the user to need to do a minual reorder_channels before being able to concat successfully/correctly. So for ch_names the order does actually matter...
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.
@moritz-gerster I think this comment has not been addressed. I do not think you should use set with channels like you do (now) for bads, so I think this chs part should be reverted / go back to old behavior, ideally with a test that fails if the channel orders do not match (it should IIRC!)
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.
@moritz-gerster I think this comment has not been addressed. I'll un-resolve it.
I noticed on this read through that it's a set check on main so you can ignore that part -- but I think it could still be more DRY by using a loop, right?
Thank you for your help! |
|
Dear @larsoner, are the changes good to go now? :) |
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.
diff looks good @moritz-gerster
any chance you can update or add a test for this?
@agramfort: Check ✅ |
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.
@moritz-gerster there is a already a place where concatenate_raws is tested. https://github.com/mne-tools/mne-python/blob/main/mne/io/fiff/tests/test_raw_fiff.py#L366
I know it's not the ideal place and it's there cause back in the days when this was added we were only supporting FIF files. Can you move your testing there to be consistent? Also rename your test test_concatenate_raws_bads_order
thanks
@agramfort done :) |
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.
Marking as requesting changes so we don't forget to undo the chs-as-set check
|
@larsoner is there more I should do? :) |
|
@moritz-gerster you need to fix conflicts |
@agramfort done ✅ |
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.
@larsoner I let you merge
|
@larsoner good to go now? Some tests are failing but they don't seem to be related to my changes. They only failed after I synchronized the code with the main branch |
|
@moritz-gerster lets wait for main to be green and lets merge this after its green again |
|
Thanks @moritz-gerster ! |
* upstream/main: Fix bug in new `mne.sys_info()` (mne-tools#11577) Remove legacy plot_psd* funcs/methods in our docs and codebase (mne-tools#11563) The order of raw1.info["bads"] should not matter when concatenating with raw0.info["bads"] mne-tools#11501 (mne-tools#11502) MAINT: Fixes for matplotlib and pandas (mne-tools#11574) Fix Circle [circle deploy] Fix export to EDF format with a set physical range smaller than the data range (mne-tools#11569) Slightly rework `mne.sys_info()` (mne-tools#11568)
Reference issue
Fixes #11501.
What does this implement/fix?
The order of bad channels no longer matters.
Note, that this is already correctly implemented in
_ensure_infos_match:mne-python/mne/io/meas_info.py
Lines 2903 to 2904 in 603a96d
It's only wrong in
_check_raw_compatibility(raw):mne-python/mne/io/base.py
Lines 2501 to 2513 in 603a96d