Skip to content

[MRG] DOC: inform about channel discrepancy in make_lcmv#12238

Merged
larsoner merged 7 commits intomne-tools:mainfrom
ctrltz:10918-dropping-channels
Dec 7, 2023
Merged

[MRG] DOC: inform about channel discrepancy in make_lcmv#12238
larsoner merged 7 commits intomne-tools:mainfrom
ctrltz:10918-dropping-channels

Conversation

@ctrltz
Copy link
Copy Markdown
Contributor

@ctrltz ctrltz commented Nov 25, 2023

Reference issue

Fixes #10918.

What does this implement/fix?

This PR adds a logger.info message if some channels apart from bads and reference had to be dropped during make_lcmv to ensure that forward, data_cov, and noise_cov have the same set of channels.

@welcome
Copy link
Copy Markdown

welcome bot commented Nov 25, 2023

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

@ctrltz ctrltz marked this pull request as draft November 25, 2023 13:42
@ctrltz ctrltz changed the title DOC: inform about channel discrepancy in make_lcmv [WIP] DOC: inform about channel discrepancy in make_lcmv Nov 25, 2023
@ctrltz ctrltz force-pushed the 10918-dropping-channels branch from 0b10a0b to 4790bfb Compare November 25, 2023 14:06
@ctrltz ctrltz force-pushed the 10918-dropping-channels branch from 4790bfb to 2ff25a2 Compare November 25, 2023 14:24
Copy link
Copy Markdown
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.

Thanks for looking into this! Just a minor suggestion to improve the message. Can you also add an entry to doc/changes/devel.rst using the :newcontrib: role to mention your enhancement?

@ctrltz
Copy link
Copy Markdown
Contributor Author

ctrltz commented Dec 3, 2023

Thanks for the review @larsoner! I fixed the points you mentioned.

  1. Below is the example output of make_lcmv in case info and forward contain MEG+EEG channels while covariance is only calculated on MEG. The new logger message is there but gets shown twice since _check_info_inv is currently called twice (once through _check_one_ch_type and once explicitly). There is a XXX note about this behavior in make_lcmv so I suppose that it is out of scope for the current issue/PR. Hopefully it is not too confusing for the user.
Excluding 59 channel(s) missing from the provided forward operator and/or covariance matrices
Excluding 59 channel(s) missing from the provided forward operator and/or covariance matrices
Computing rank from covariance with rank=None
    Using tolerance 3.5e-13 (2.2e-16 eps * 305 dim * 5.2  max singular value)
    Estimated rank (mag + grad): 302
    MEG: rank 302 computed from 305 data channels with 3 projectors
Computing rank from covariance with rank=None
    Using tolerance 3.3e-13 (2.2e-16 eps * 305 dim * 4.8  max singular value)
    Estimated rank (mag + grad): 302
    MEG: rank 302 computed from 305 data channels with 3 projectors
Making LCMV beamformer with rank {'meg': 302}
info["bads"] and noise_cov["bads"] do not match, excluding bad channels from both
Computing inverse operator with 305 channels.
    305 out of 366 channels remain after picking
Selected 305 channels
Whitening the forward solution.
    Created an SSP operator (subspace dimension = 3)
Computing rank from covariance with rank={'meg': 302}
    Setting small MEG eigenvalues to zero (without PCA)
Creating the source covariance matrix
Adjusting source covariance matrix.
Computing beamformer filters for 7498 sources
Filter computation complete
  1. Do I need to address the failing Windows CI checks somehow? The test runs locally on Ubuntu for me, but in CI log.getValue() is empty for some reason.

Feel free to suggest any other changes if needed.

Copy link
Copy Markdown
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.

The new logger message is there but gets shown twice since _check_info_inv is currently called twice (once through _check_one_ch_type and once explicitly).

One solution to this is to:

  1. Add the @verbose decorator to _check_info_inv
  2. Add verbose=None to the signature
  3. Inside _check_one_ch_type, call `_check_info_inv(..., erbose=_verbose_safe_false())

This will make it so that the message only shows up once, because it won't be shown in the _check_one_ch_type is called.

@larsoner
Copy link
Copy Markdown
Member

larsoner commented Dec 6, 2023

@ctrltz you have a conflict, and merging in main (or rebasing) should fix CIs. Let me know if you want help with this or the verbose stuff

@ctrltz
Copy link
Copy Markdown
Contributor Author

ctrltz commented Dec 6, 2023

Thanks for the help and sorry for the delayed reply @larsoner! Your idea with verbose sounds very nice to me, I will implement it by the end of the week.

@ctrltz
Copy link
Copy Markdown
Contributor Author

ctrltz commented Dec 7, 2023

I've updated the PR, it should be ready for merge now. The logger message is shown only once now, and failing CI checks are not related to the PR.

@ctrltz ctrltz marked this pull request as ready for review December 7, 2023 17:40
@ctrltz ctrltz changed the title [WIP] DOC: inform about channel discrepancy in make_lcmv [MRG] DOC: inform about channel discrepancy in make_lcmv Dec 7, 2023
Copy link
Copy Markdown
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.

Will wait for #12275 to land then merge into this PR to get it green, thanks in advance @ctrltz !

@larsoner larsoner enabled auto-merge (squash) December 7, 2023 19:42
@larsoner larsoner merged commit 06c90a7 into mne-tools:main Dec 7, 2023
snwnde pushed a commit to snwnde/mne-python that referenced this pull request Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] LCMV beamformer does not inform about channel discrepancies

2 participants