-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Improve metadata tutorial #12931
Improve metadata tutorial #12931
Conversation
Thanks @cbrnr, I might be able to take a look later today or tomorrow (I think I initially wrote a larger part of this very tutorial) |
I checked and it shows the correct output in the rendered documentation up until MNE-Python 1.6: For newer versions, it generates an empty table, like you observed. I'll try to look into this. |
Yes this is to be expected, there were 400 stimuli but 402 button presses. In our analysis, we wish to only consider the first button press following a stimulus. This is directly related to your previous question / observation. |
Ok I found the problem. MWE: # %%
import mne
data_dir = mne.datasets.erp_core.data_path()
infile = data_dir / "ERP-CORE_Subject-001_Task-Flankers_eeg.fif"
raw = mne.io.read_raw(infile, preload=True)
raw.filter(l_freq=0.1, h_freq=40)
all_events, all_event_id = mne.events_from_annotations(raw)
metadata_tmin, metadata_tmax = -1.5, 0
row_events = ["response/left", "response/right"]
keep_last = ["stimulus", "response"]
metadata, events, event_id = mne.epochs.make_metadata(
events=all_events,
event_id=all_event_id,
tmin=metadata_tmin,
tmax=metadata_tmax,
sfreq=raw.info["sfreq"],
row_events=row_events,
keep_last=keep_last,
)
# %%
metadata.loc[metadata["last_stimulus"] == "", :] The cells with missing values are populated with empty strings. But there should be @larsoner Any idea about this? It worked back with MNE-Python 1.6, and was broken in our rendered docs starting with 1.7. I'm not sure if it's anything we have changed, or if it's related to Pandas. |
Also, didn't we agree to keep the actual authors in all tutorials and examples? Currently, this document just contains
|
I just tried with MNE 1.6 and I get the expected result. Switching to |
Just to clarify the MWE, the output works for current versions (after the change), because it searches for |
I think we decided that people can opt-in to adding their names in tutorials and examples if they are so inclined. Sounds like the author(s) of that tutorial haven't done that yet! |
ax[0].xaxis.set_visible(False) | ||
ax[1].xaxis.set_visible(False) | ||
|
||
fig |
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.
Can we not show the figure using plt.show()
? Depending on where people execute this code, just typing fig
might not actually show the figure.
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.
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.
But note that the tutorials are meant for interactive use and grouped into IPython cells, so …
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.
Well, this wouldn't work in the standard Python interactive interpreter (unless interactive Matplotlib mode is enabled), it only works in a notebook. I was just wondering if plt.show()
would be the canonical way to show a figure in both a regular interpreter and a notebook.
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.
Whatever our expectation is, maybe worth clarifying that explicitly here? https://mne.tools/stable/auto_tutorials/index.html
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.
I would use plt.show()
in sphinx-gallery generated tutorials.
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.
I'm happy with either as long as it works. can you make a suggestion or push a change?
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 to be clear, you are also relying on a notebook when you do
metadata
This will output an HTML table, so we cannot replace it with print(metadata)
(and certainly we don't want to replace it with IPython.display.display()
). So it's probably OK to assume we're in a notebook I guess (but we should clarify this on the tutorials and examples main pages)?
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.
I would use plt.show() in sphinx-gallery generated tutorials.
I think this is what we've done elsewhere, or just remove the fig
line
I think this is ready for a final review I'll be withdrawing from this PR as I'm super busy with other stuff |
ax[0].xaxis.set_visible(False) | ||
ax[1].xaxis.set_visible(False) | ||
|
||
fig |
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.
I would use plt.show() in sphinx-gallery generated tutorials.
I think this is what we've done elsewhere, or just remove the fig
line
Co-authored-by: Clemens Brunner <[email protected]>
fd8d376
to
e2cbabb
Compare
This is now finally ready for review and merge! Thanks @hoechenberger for addressing my comments! |
Failures are just from scikit-learn/scikit-learn#30237 so in it goes, thanks @cbrnr ! |
I might have found some things that could be improved in the excellent metadata tutorial:
Closes #12939