Repository navigation
ENH: Add scale parameter to Brain screenshot and save_image (#14385) - #14447
Conversation
ce3916d to
3fcd094
Compare
| Either ``'rgb'`` or ``'rgba'`` for values to return. | ||
| scale : float | None | ||
| The scale factor for the screenshot. Larger values produce higher | ||
| resolution images. Supported when using PyVista. |
There was a problem hiding this comment.
Needs versionadded. I don't think you need the "Supported when using PyVista" (we always do currently)
There was a problem hiding this comment.
done! added .. versionadded:: 1.14 and removed the PyVista mention.
| renderer.reset_camera() | ||
|
|
||
| def save_image(self, filename=None, mode="rgb"): | ||
| def save_image(self, filename=None, mode="rgb", scale=None): |
There was a problem hiding this comment.
| def save_image(self, filename=None, mode="rgb", scale=None): | |
| def save_image(self, filename=None, mode="rgb", *, scale=None): |
There was a problem hiding this comment.
done! made scale keyword-only (with default 1).
|
|
||
| @fill_doc_static("time_viewer_brain_screenshot") | ||
| def screenshot(self, mode="rgb", time_viewer=False): | ||
| def screenshot(self, mode="rgb", time_viewer=False, scale=None): |
There was a problem hiding this comment.
| def screenshot(self, mode="rgb", time_viewer=False, scale=None): | |
| def screenshot(self, mode="rgb", time_viewer=False, *, scale=None): |
There was a problem hiding this comment.
done! made scale keyword-only here too.
| ``time_viewer=True`` and ``separate_canvas=False``. | ||
| scale : float | None | ||
| The scale factor for the screenshot. Larger values produce higher | ||
| resolution images. Supported when using PyVista. |
There was a problem hiding this comment.
done! added .. versionadded:: 1.14 and removed the PyVista mention.
| Path to new image file. | ||
| mode : str | ||
| Either ``'rgb'`` or ``'rgba'`` for values to return. | ||
| scale : float | None |
There was a problem hiding this comment.
I think pyvista might actually only take int... we should probably only support int here and default to 1 (no need for `None)
There was a problem hiding this comment.
good catch! changed scale to an int with default 1, checked it with _ensure_int (and added a unit test that asserts a TypeError for non-int values), and updated the docstrings with .. versionadded:: 1.14. thanks!
3fcd094 to
f2a9b80
Compare
Support exporting high-resolution images from Brain by exposing a scale parameter in Brain.screenshot() and Brain.save_image(), which forwards down to PyVista's plotter.screenshot(scale=scale). Closes mne-tools#14385.
f2a9b80 to
696e1fe
Compare
larsoner
left a comment
There was a problem hiding this comment.
Marking for merge-when-green, thanks in advance @ishaaaan17 !
summary of changes
addresses #14385.
this adds a
scaleparameter toBrain.screenshot()andBrain.save_image(), so users can export high-resolution images for publications.scaleis passed through the renderer backend to PyVista'splotter.screenshot(scale=scale).time_viewer=True, the DPI of the Matplotlib trace is scaled by the same factor, so it matches the size of the 3D canvas.test_image_screenshotthat the dimensions are doubled and that the image has a high correlation (> 0.95) with a bilinear downsampled version.checklist
ruffandcodespelldoc/changes/dev/14385.newfeature.rst