-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
FIX: Correctly set the calibration factor in Nihon Kohden reader #13468
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
402e662 to
f7cc86f
Compare
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.
Any chance this affects some test data file so you could update a test? Ideally the test change would fail if you ran it on main but pass on this PR
|
... and by "some test data file" I mean one in mne-testing-data already. If not then we could add https://github.com/user-attachments/files/23185821/DA00100E.zip to mne-testing-data and then a test could be updated |
|
... there appears to be one failing test already Can you look? |
Hi! @larsoner Thanks for your review. I am trying to figure out why it failed right now. |
|
Turns out the test failure is caused by channel $A2 and $A1: Before: After: I will do some debugging to see if I can resolve it. |
|
OK. I think I’ve fixed the unit test. In the .21E file, each electrode corresponds to a unique code, which is also how NK identifies electrode types. From the following link, we can see that the electrode codes for And mne-python/mne/io/nihon/nihon.py Line 390 in 610ebe5
A similar logic can also be found in nk2edf — treating 76 and 77 as DC channels. Before this patch, In this patch, the initial argument passed to In the latest commit, by passing the electrode code definitions returned by Some possible improvements: Instead of: def _read_nihon_header(fname):
# Read the Nihon Kohden EEG file header
fname = _ensure_path(fname)
_chan_labels = _read_21e_file(fname)
header = {}
...
return header, _chan_labelsperhaps it would be better to do this: def _read_nihon_header(fname, _chan_labels):
# Read the Nihon Kohden EEG file header
fname = _ensure_path(fname)
header = {}
...
return headerThat is, call
|
|
Feel free to implement whichever of the enhancements above you think will make the code more understandable next time we need to change/fix it For the question about which channels to handle as DC, do you have any test files where you could load them in some NK software and look at them, like you did for M1 and M2 in the top comment? |
|
Hi! @larsoner |
|
Hi @larsoner I have just created a PR: mne-tools/mne-testing-data#126 . |
4645a70 to
586eb7f
Compare
If the .21E file does not exist, issue a warning. Co-authored-by: Eric Larson <[email protected]>
for more information, see https://pre-commit.ci
|
OK. I’ve made another commit to indicate that it can fix this issue. In addition, since the .21E file contains the correct electrode definitions, I think a warning should be issued when this file is missing. |
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 couple of small things, otherwise LGTM!
Co-authored-by: Eric Larson <[email protected]>
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.
Looks good, marking for merge-when-green. Thanks in advance @myd7349 !
* upstream/main: (230 commits) FIX: Fix ICA.apply when fitted including marked bad channels (mne-tools#13478) FIX: Correctly set the calibration factor in Nihon Kohden reader (mne-tools#13468) [pre-commit.ci] pre-commit autoupdate (mne-tools#13479) MAINT: Update code credit (mne-tools#13477) Fix `versionadded` directive formatting (mne-tools#13471) typo in mailmap (mne-tools#13475) FIX: Fix _plot_topomap channel names plotting when using a mask (mne-tools#13470) FIX: Handle an Eyelink File with blank lines injected throughout file (mne-tools#13469) ENH: adds annotation filtering to raw and ica source figures (mne-tools#13460) MAINT: Restore VTK nightly wheel on Linux and bump changelog checker (mne-tools#13436) [pre-commit.ci] pre-commit autoupdate (mne-tools#13465) FIX: Fix add_reference_channels for passing two channels names (mne-tools#13466) ENH: Add on_missing for combine_channels (mne-tools#13463) Bump the actions group with 2 updates (mne-tools#13464) Move development dependencies into a dependency group (no more extra) (mne-tools#13452) ENH: add on_missing for rename_channels (mne-tools#13456) add advisory board to website (mne-tools#13462) ENH: Support Nihon Kohden EEG-1200A V01.00 (mne-tools#13448) MAINT: Update dependency specifiers (mne-tools#13459) ENH: Add encoding parameter to Nihon Kohden reader (mne-tools#13458) ...
* upstream/main: (85 commits) FIX: Fix ICA.apply when fitted including marked bad channels (mne-tools#13478) FIX: Correctly set the calibration factor in Nihon Kohden reader (mne-tools#13468) [pre-commit.ci] pre-commit autoupdate (mne-tools#13479) MAINT: Update code credit (mne-tools#13477) Fix `versionadded` directive formatting (mne-tools#13471) typo in mailmap (mne-tools#13475) FIX: Fix _plot_topomap channel names plotting when using a mask (mne-tools#13470) FIX: Handle an Eyelink File with blank lines injected throughout file (mne-tools#13469) ENH: adds annotation filtering to raw and ica source figures (mne-tools#13460) MAINT: Restore VTK nightly wheel on Linux and bump changelog checker (mne-tools#13436) [pre-commit.ci] pre-commit autoupdate (mne-tools#13465) FIX: Fix add_reference_channels for passing two channels names (mne-tools#13466) ENH: Add on_missing for combine_channels (mne-tools#13463) Bump the actions group with 2 updates (mne-tools#13464) Move development dependencies into a dependency group (no more extra) (mne-tools#13452) ENH: add on_missing for rename_channels (mne-tools#13456) add advisory board to website (mne-tools#13462) ENH: Support Nihon Kohden EEG-1200A V01.00 (mne-tools#13448) MAINT: Update dependency specifiers (mne-tools#13459) ENH: Add encoding parameter to Nihon Kohden reader (mne-tools#13458) ...


Reference issue (if any)
Fixes #13467 .
What does this implement/fix?
See #13467 .
Additional information
Considering that M1 and M2 only replace A1 and A2 in certain cases, they will not appear simultaneously. Therefore, when A1 and A2 are already in _default_chan_labels, adding M1 and M2 is not appropriate (they should be placed at the same position in the channel list).
_map_ch_to_specsshould not use_default_chan_labels. Instead, it should use the electrode definitions read from the .21E file. If the .21E file does not exist, it can fall back to_default_chan_labels.