-
Notifications
You must be signed in to change notification settings - Fork 98
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
Mapping values to foci. #259
base: master
Are you sure you want to change the base?
Conversation
- added Brain.add_text3d for labeling foci in 3d
surfer/viz.py
Outdated
data : numpy array | ||
1D array the same size as the number of foci. Spheres will be | ||
colorcoded acording to data values, whereas spheres' sizes will be | ||
coded using the absolute values of data. |
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.
API seems quite complicated. Can you achieve what you want using only one new parameter? and without adding a new method?
also you miss tests and some new example for documentation.
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 agree with @agramfort. Can allow_data
as an external parameter not be replaced with an internal check for data is not None
?
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 also am not sure that I like forcing the color and size of the spheres by default. There are lots of cases when you might want colors to reflect a scalar but a uniform size. Or (probably less commonly) vice versa. Also I don't see any way to control the size range, colormap, etc. through this API, which would be important.
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.
Thanks for pointing out the issues, i'll try to fix them. This is my first attempt at a pull request, so bear with me, especially with the tests.
surfer/viz.py
Outdated
@@ -1588,8 +1588,8 @@ def add_foci(self, coords, coords_as_verts=False, map_surface=None, | |||
whether the coords parameter should be interpreted as vertex ids | |||
map_surface : Freesurfer surf or None | |||
surface to map coordinates through, or None to use raw coords | |||
scale_factor : float | |||
Controls the size of the foci spheres (relative to 1cm). | |||
scale_factor : int |
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.
Why the change to int here? Scale factors can be floats, as seen in the example: http://pysurfer.github.io/auto_examples/plot_foci.html Do your changes break that, or is this just an errant attempt to fix the documentation?
@@ -1737,6 +1748,45 @@ def add_text(self, x, y, text, name, color=None, opacity=1.0, | |||
if justification is not None: | |||
text.property.justification = justification | |||
|
|||
def add_text3d(self, x, y, z, text, name, color=None, opacity=1.0, | |||
row=-1, col=-1, font_size=None, justification=None): |
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.
Do we use this row
, col
parameterization anywhere else in pysurfer? Ideally if you're going to add a new method it should match the existing API as closely as possible.
surfer/viz.py
Outdated
if font_size is not None: | ||
text.property.font_size = font_size | ||
text.actor.text_scale_mode = 'viewport' | ||
if justification is not None: |
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 parameter doesn't appear in the docstring. Also despite it being the property name in mayavi, "justification" is a weird term and "alignment" would be more correct.
Codecov Report
@@ Coverage Diff @@
## master #259 +/- ##
==========================================
- Coverage 74.9% 66.64% -8.26%
==========================================
Files 7 7
Lines 2506 2536 +30
Branches 501 505 +4
==========================================
- Hits 1877 1690 -187
- Misses 454 664 +210
- Partials 175 182 +7 |
Hi, Regarding text functions: i only copied add_text function from above and changed it to uses the text3d function in mayavi. All 4 arguments (row, col, justification and font_size) were already there. Couldn't figure out failed tests myself, please help me fix those. |
* FIX: Render tweaks * FIX: Use correct data_dict * FIX: test backend * FIX: Better check * FIX: Old VTK
* FIX: width/height in offscreen mode * MAINT: Sisyphus * BUG: Modernize labels * FIX: Circle * FIX: Stretch * FIX: More * MAINT: Push the rock * FIX: Skip for 3
* Integrate better with Jupyuter notebook Mayavi can render things inside a jupyter notebook as either PNG or X3D. This functionality can be enabled with `mlab.init_notebook()`. This PR adds an `_ipython_display_` hook to the `Brain` class that renders the brain accordgin to the Mayavi notebook integration settings. * Add note on Jupyter notebook integration to docs * Fix links in doc
* MAINT: Update fsaverage * FIX: Bump to 3.5 * ENH: Run more on CircleCI * MAINT: CI * MAINT: CI * MAINT: CI * MAINT: Circle * FIX: Pattern * FIX: Circle * FIX: Try again * FIX: Better * FIX: One more
* ENH: Add option to smooth to nearest * DOC: Update docstring * FIX: Flake * FIX: Undordered vertices are the worst * FIX: Orders are hard * DOC: Changes
* Feat: add kwargs in Brain.add_* and pass it to mayavi modules, so that we could directly manipulate mayavi display settings, like point resolution and overlay opacity. * Fix: Fix code styles which failed in the flake test. * Modify test_viz to pass the kwargs to the mayavi module. * fix flake test. * Specifying `kwargs` as `mlab_kws` and make the documentation more clear. * Revert "Specifying `kwargs` as `mlab_kws` and make the documentation more clear." This reverts commit c7a5912. * Link mayavi documents. * Give detailed explanations about the kwargs passed to the functions. * Revert "Link mayavi documents." This reverts commit 2c86a04. * Change the position of line breaking. * Fix the typo and unavailable links. * Fix render errors. * Revert "Fix render errors." This reverts commit ac0b7b8. * Fix render error. * Improve code rendering. * Revert "Fix render error." This reverts commit bbf7631. * Fix line breaking error. * Revert "Fix line breaking error." This reverts commit 6efccac. * Fix line breaking error. * Revert "Fix line breaking error." This reverts commit a7abf61. * Force line breaking to fix the rendering error on long code. * Revert "Force line breaking to fix the rendering error on long code." This reverts commit 6a9cdf1. * Force line breaking to fix the rendering error on long code. * Revert "Force line breaking to fix the rendering error on long code." This reverts commit c7f6a9f. * Force line breaking to fix the rendering error on long code. * Revert "Force line breaking to fix the rendering error on long code." This reverts commit de31e5f. * Fix render error Force line breaking to avoid render error. * Render undocumented function as plain code. * Fix sectioning. * FIX: Formatting
BUG: Properly clean up on del
Hi, was this feature ever implemented in the library? Thanks |
@danielegrattarola This has not been merged. There are unresolved questions about how best to integrate into the existing PySurfer API, and the tests are not passing. But looking at the code should give you a pretty good idea of how to add text onto a PySurfer visualization. It will take you writing more code than if it were just a method on the |
@mwaskom Thanks, I've managed to hack a solution together using |
MRG, FIX: Safer exit
* FIX: Fix bug with scale_data_colormap * FIX: Fix for deprecation * FIX: One more
[skip ci]
MRG, FIX: Remove force render
* FIX: Verbose * FIX: MNE vers
* ENH: Move up to 3.8 * FIX: Newer * FIX: Newer
* ENH: Add FXAA option * FIX: Mayavi for VTK9
* MAINT: Simpler vector params * FIX: Undo auto scaling * FIX: Dup * FIX: URL * FIX: Better * FIX: More tolerant of type
… master � Conflicts: � surfer/viz.py
I made the following changes to plot SEEG electrodes and task-related activations: