MRG: Clean up and unify _prepare_forward #5999
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR should not change any outputs, but internally it:
_prepare_forwardand_check_loose_forwardto greatly simplify the logic they use, and deduplicate checks/flows across MNE and sparse solvers.orderedargument topick_channelsandpick_channels_forward, which is something that I have often wanted. Eventually we can probably simplify a lot of our code usingordered=True, as there are a lot of places we do the same picking-with-order logic instead of picking-as-set logic.compute_depth_priorin favor of a cleaner,Forward-based method.scannoin the inv round-trip test (should not matter, and I think our result is now possibly more correct because it resetsscannoto match the number of entries in info)These are important for #5881, and are hopefully the last steps we need (along with #5979) before having easy, unified, drop-in lead-field normalization across all solvers (!).
Ready for review/merge from my end @agramfort