-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
WIP: Rework report – Looking for feedback! #9722
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
Conversation
| # xmin and xmax | ||
| vlines = [] if vlines is None else vlines | ||
| xticks = _trim_ticks(axes.get_xticks(), xmin, xmax) | ||
| xticks = _trim_ticks(axes.get_xticks(), round(xmin, 2), round(xmax, 2)) |
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.
This improves the X-axis visualization of the GFP plots.
|
|
Reports are awesome and I'm currently addicted to them. The screen shot above looks great, and I like the tags filter feature. It's unclear to me if you are proposing to depreciate |
|
Fantastic initiative! I second @rob-luke that I kind of like I almost never need any of the other functions except for |
|
The tags feature looks awesome :-) |
Should fix scrollspy issues
|
Hello @jasmainak and @rob-luke, thanks for the positive feedback! My goal is to retain backward-compatibility as much as possible, so my immediate next steps are
Does that sound okay to you? |
|
Sounds great. Let me know when you want me to give it a spin locally. |
sappelhoff
left a comment
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 haven't had the chance to use reports as much as I would have liked to, but the proposed changes sound good to me - and I'll try to give this a spin in my next project (couple of months/weeks from now though).
|
Looks very promising! We should definitely keep some variant of Currently the diff is a pain to look at because it shows up as |
Yes, I'm surprised it is that way though, I thought I've locally gotten While we're talking about this: |
I didn't even know those existed :) And based on what I assume they do, no, they are not. Scale and close can be done by the user when creating their figures. Replace maybe is useful but when scripting these things usually you don't need it. Really @wmvanvliet might have some opinion on these, though, since I know he worked on class persistence maybe |
|
I've now resurrected MWE: # %%
import mne
import matplotlib.pyplot as plt
r = mne.Report()
fig, ax = plt.subplots()
ax.plot([1,2,3], [1,2,3])
r.add_figs_to_section(
figs=fig,
captions='Old API, single fig',
section='old-api',
comments='this is a comment'
)
r.add_figs_to_section(
figs=[fig, fig],
captions=['Old API, multiple figs (1)',
'Old API, multiple figs (2)'],
section='old-api',
comments=['a comment', 'this is another comment']
)
# New API, multiple figs
r.add_figs(figs=[fig, fig],
titles=['New API (1)', 'New API (2)'],
captions=['A caption', 'Another caption'],
tags=('new-api',)
)
r.save('/tmp/report_figs.html', overwrite=True)Rendered HTML can be downloaded from my Google Drive: @jasmainak @larsoner @rob-luke Does this have the functionality you need? Or did I mess something up for you? Next up: fix the remaining |
I would rather see the CircleCI build fixed, then we can review using the standard CI checking schemes. |
Good point, coming right up! 🏃 🏃 🏃 |
|
one minor point of feedback: I noticed (in your google-drive-shared example of the old and new APIs) that when you deselect "old API" tag, the old-api-tagged elements disappear from the main body of the report (as expected) but their titles also disappear from the left-side TOC (not expected... I think I would want them to be disabled / greyed out maybe, rather than completely hidden?). This opinion is not super-strong, however, so I'm prepared to be talked out of it. |
|
@drammock Totally open for discussion on this one! We'd need to see how the scrollspy behaves if we do that the way you describe, though. But I would think that it's doable… |
| # should have down-up-down shape | ||
| corr = np.corrcoef(norms, np.hanning(len(imgs)))[0, 1] | ||
| assert 0.78 < corr < 0.80 | ||
| assert 0.778 < corr < 0.80 |
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.
For passing locally on my Mac
|
|
||
| Parameters | ||
| ---------- | ||
| slices_as_figures : bool |
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 documented the new param I added, but didn't feel the urge to add docs for all the other params there were already undocumented before I came along 😅
mne/report/js_and_css/report.sass
Outdated
| position: relative; | ||
| padding-bottom: 5rem; | ||
| } | ||
|
|
||
| #content { | ||
| margin-top: 90px; | ||
| scroll-behavior: smooth; | ||
| position: relative; // for scrollspy | ||
| } | ||
|
|
||
| #toc { | ||
| margin-top: 90px; | ||
| padding-bottom: 5rem; |
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.
sass does not use semicolons
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.
Thank you, addressed in 3b1a73e
mne/report/report.py
Outdated
| from matplotlib import __version__ as MPL_VERSION | ||
| from pkg_resources import parse_version | ||
| if parse_version(MPL_VERSION) >= parse_version('3.2'): |
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.
elsewhere we mostly use from distutils.version import LooseVersion to do comparisons like this. Is this approach better / more modern?
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.
distutils is being deprecated. +1 for adding a mne.fixes._version_greater(a, b, comp='>=') or something that uses pkg_resources if available and LooseVersion if not (comp could be '>=' or '>')
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.
Great idea @larsoner, will give it a shot. The deprecation was actually the reason why I picked this approach, yes.
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.
|
@hoechenberger let me know when I should look |
f239514 to
23b9ad2
Compare
|
The only thing left on my todo list (top post) is "Update tutorial". @larsoner I've tried to rework the git history a little by soft-resetting the branch to cb1916f (the last commit before I moved If you have any advice / would like to give this a shot, please feel free to play with and force-push to this branch. |
|
Closing in favor of your next upcoming PR |
Motivation
The goal of this PR is to make
Reportmore versatile and to update the UI and functionality to better meet the expectations of new users in 2021.Reportused to have only few public methods; the primary way to use it was viaparse_folder(). This, however, gave users little control over the generated output. In the MNE-BIDS-Pipeline, we would render most objects manually and then add them viaadd_figs_to_section()– a somewhat dull and cumbersome endeavour.I therefore decided it would be nice to have numerous public methods that have an inherent understanding of various MNE-Python objects and could render them in a sensible way automatically, without requiring users to cook up their own plotting code.
What's new
Methods
add_epochsadd_evokedsadd_rawadd_stcadd_forwardadd_transadd_inverseadd_covarianceadd_eventsadd_ssp_projsadd_code(arbitrary code blocks with syntax highlighting)add_sys_info(output ofmne sys_info)add_bem(replacesadd_bem_to_section)add_figure(replacesadd_figs_to_section)add_image(replacesadd_images_to_section)add_slider(replacesadd_slider_to_section)add_html(replacesadd_htmls_to_section)"Data model"
The notion of "sections" is gone. Instead, all methods accept a parameter,
tags, allowing users to assign an arbitrary number of tags to each added element.UI
Dependencies, custom JavaScript & CSS
constandletkeywords, and the spread operator)MWE
Issues & todo
parse_folder()runadd_figs_to_section(250ebda)add_images_to_section(ad496a7)add_slider_to_section(5ff87cc)add_htmls_to_section(7ffea91)add_bem_to_section(987706b)Currently, each condition in an evoked file gets its own TOC entry. Inmain, there is some kind of nesting. Do we want / need this?data_pathin many places where we don't actually need it anymore (a8fa634)replaceparameter exists & works (6e534d7)Report.remove()(deb88ea)Better input sanitizationReplace unmaintained Tempita templating engine with JinjaLow prio / do later
The code, all in all, while functional, is still kind of messy. Still I'd appreciate code design feedback if you dare :) Otherwise I'm super happy about any feedback and thoughts on the redesigned UI and UX.
cc @dengemann @SophieHerbst @drammock @agramfort @sappelhoff @jasmainak