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
Replace metadata eval with query #10705
Conversation
seams to work @cbrnr ! can you add a test with your toy example |
OK, but we might have a problem here, because what should happen if an import mne
import numpy as np
from pandas import DataFrame, Series, NA
metadata = DataFrame(
{"A": Series([True, True, True, False, False, NA], dtype="boolean")}
)
rng = np.random.default_rng()
epochs = mne.EpochsArray(
data=rng.standard_normal(size=(6, 8, 500)),
info=mne.create_info(8, 250, "eeg"),
event_id={"A": 1}, # event ID "A" has the same name as metainfo column "A"
metadata=metadata
)
# ambiguous: should epochs["A"] get epochs of type "A" or where metainfo["A"] matches?
assert len(epochs["A"]) == 3 # gets epochs for which column A == True
assert len(epochs["not A"]) == 2 # gets epochs for which column A == True
assert len(epochs["A.isna()"]) == 1 # gets epochs for NA in column A |
We should clearly document which one has precedence. IIRC in the code we try |
Ohohoh, I'd like to ensure this doesn't break the MNE-BIDS-Pipeline before we merge this |
@agramfort I was going to write a bit more compact test and haven't pushed it yet. Do you want to keep the test you added? |
feel free to adjust my test no pb
… Message ID: ***@***.***>
|
Alright, so if there is an So I guess this is already what we want? |
I have to say I'd like to avoid us having to make this kind of decision in the first place. Can we not raise a ValueError if the user tries to set metadata with column names equal to an event name? Or, allow me to go crazy here ... do everything via metadata internally, as in always create metadata with columns |
Or, allow me to go crazy here ... do *everything* via metadata
internally, as in always create metadata with columns event_id and
event_name.... Message ID: <mne-tools/mne-python/pull/10705/c1148439208@
github.com>
this means making pandas a hard dependency of mne as Epochs are everywhere
|
Building everything upon metadata would be cool, but this will be a huge change. It's probably not worth it unless someone really wants to do it. In any case, @hoechenberger you said you wanted to verify that everything still works with BIDS – did you have a chance to do that? We should wait for you before we merge this PR. |
Nope, will want to do that later today!! |
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.
Seems to be working with the pipeline, hence all good from my end!
Thanks @cbrnr and @agramfort! |
🎉 |
Fixes #10700. Let's see if all tests still pass.