Closed jasmainak closed 7 years ago
A protection operator is being applied using fewer channels than were originally used to compute the projection vectors, which can be dangerous in some circumstances, thus the warning. Can we make the message clearer somehow?
In this case they are empty room / acquisition machine projection vectors, so it is probably okay.
okay, but why do we need to apply the projection vectors here? this is not something we do with EEG interpolation. To me, the user should apply it before in the pipeline.
One reason is that we are creating a minimum norm solution, so we apply proj when doing it just like we do in standard inversion. There could be good mathematical reasons for always doing that but we'll have to ask Matti if we're really curious. But I think the idea is that if the projectors are there, we assume they should be applied during inversion.
okay, I see. I am really curious :) The reason I ask is that when you compute a mapping matrix for 306 x 306 channels vs 305 x 1, it seems intuitive that they should be exactly the same if you drop the diagonal elements. That is, the quantity printed in the last two lines of this code:
from mne import io, pick_info
from mne.datasets import sample
from mne.forward import _map_meg_channels
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
raw = io.read_raw_fif(raw_fname, preload=True)
raw.pick_types(meg=True, stim=False, exclude=[])
info_from = raw.info.copy()
info_to = raw.info.copy()
mapping = _map_meg_channels(info_from, info_to, 'accurate')
info_from = pick_info(info_from, range(1, 306))
info_to = pick_info(info_to, [0])
mapping_slice = _map_meg_channels(info_from, info_to, 'accurate')
print(mapping_slice[0, :5])
print(mapping[0, 1:6])
mapping_slice[0, :5]
and mapping[0, 1:6]
should exactly be the same. However, this is the case only when I disable the proj in the MNE code.
what do you suggest? improving the doc? better warning?
I suggest getting rid of the warning since it's not clear what the warning means in the context of channel interpolation. Further, if I try to do epoch-wise interpolation, I'm being flooded by these warnings.
Maybe something like this would work? I don't seem to see any qualitative difference in the interpolation if I remove the proj ...
If you want to go that route you'll have to ask Matti why the projections are used (maybe just for denoising?)
It's probably okay to silence the warnings with verbose='error'
, but it seems a bit risky
@jasmainak try removing the projs from the info and see if it affects your results.
you can silence for you the warnings with verbose='error' indeed.
okay, sounds like doing verbose='error' could be a "fix". But it's not exposed for raw.interpolate_bads()
. I want to suppress the warnings only for this method, not everywhere.
Pass verbose='error' param only within some call inside interpolate_bads, probably make_projector or so
Actually a better fix is to call info.normalize_proj before passing it along
okay, so there is something to fix in MNE master? should I make a PR?
You could do it in your own code before calling the interpolation function for now. Not sure if we want it in master or not. Maybe?
Up for a PR @jasmainak?
@Eric89GXL did you change your mind whether this needs to be in master? I also see the problem if I pick channels after making epochs and then do epochs.plot()
Were you able to fix it in your own code by calling the normalization function? If so I guess we don't need a PR.
I haven't looked into yet because I've been working with data without proj. If you keep it open, I might get around to it when I'm hacking on MNE code. No strong feelings either way.
I'll go ahead and close this one, feel free to reopen if it comes up again/often @jasmainak
I get these warnings when I try to interpolate bad channels:
The code to reproduce is here:
It appears to be somehow related to this: https://github.com/mne-tools/mne-python/blob/master/mne/forward/_field_interpolation.py#L64-L65 but I'm not super sure what's going on. Any clues @Eric89GXL or @agramfort ?