Adding flatmap rendering functionallity#269
Conversation
Integrate better with Jupyter notebook (nipy#268)
Adding flat patches support
larsoner
left a comment
There was a problem hiding this comment.
Looks promising. Missing tests of this new functionality, can you add them?
Circle fails:
https://circleci.com/gh/nipy/PySurfer/253
I can add the patch files to the archive used here in a separate PR. Is some specific FreeSurfer version required?
| configure_input_data(mapper, mesh.data) | ||
| actor = tvtk.Actor() | ||
| actor.mapper = mapper | ||
| fig.scene.add_actor(actor) |
There was a problem hiding this comment.
I would not modify every example, just one or two. Maybe adding the plot_flatmap.py is already enough.
| cam = fig.scene.camera | ||
| cam.zoom(1.85) | ||
|
|
||
| mlab.savefig('test.png',figure=fig,magnification=5) # save a high-res figure No newline at end of file |
There was a problem hiding this comment.
No need for this savefig command in the example
|
|
||
| brain.show_view("medial") | ||
| if not hasattr(brain,'patch_mode'): | ||
| brain.show_view("medial") |
|
|
||
| brain.show_view("dorsal") | ||
| if not brain.patch_mode: | ||
| brain.show_view("dorsal") |
There was a problem hiding this comment.
Instead of forcing people to write conditionals, in brain.show_view I would check to see if in patch_mode and if so, discard the azimuth/elevation/roll arguments (only pay attention to distance), and say that this is the behavior in the show_view docstring. If people really want to configure the view they can use mlab to do it.
| if 'patch' in surf.lower().split('.'): | ||
| view=None | ||
| else: | ||
| view = 'frontal' |
There was a problem hiding this comment.
None of these conditionals are needed with the show_view modification suggested above.
|
|
||
| # reverse the lookup table: | ||
| original_vertices_in_patch_indexing=np.zeros((n_orig_vertices,)); original_vertices_in_patch_indexing[:]=np.nan | ||
| original_vertices_in_patch_indexing[patch_vertices_in_original_surf_indexing]=np.arange(len(patch_vertices_in_original_surf_indexing)) |
There was a problem hiding this comment.
There are many PEP8 violations in this and other files, can you fix them?
| for v in args: | ||
| cut_v.append(np.asarray(v)[vertices_in_patch]) | ||
| return (vertices,)+tuple(cut_v) | ||
| def read_patch_file(fname): |
There was a problem hiding this comment.
Is this in nibabel? If not, can you make a PR there, too?
| surface where hemispheres typically overlap (Default: True) | ||
| surface where hemispheres typically overlap. For flat patches, | ||
| this aligns the two patches along their posterior | ||
| edges. (Default: True) |
There was a problem hiding this comment.
You should also update the surface argument above to say that it's supported, and add a:
.. versionchanged:: 0.10
Support for flat maps.
|
Now that #270 is in, if you rebase CircleCI might render properly. |
Addressing issue 214, I added flat-map rendering functionality. This was done by creating a Patch, a child object of Surface, that deals with storing the relevant meta-data (which patch vertices correspond to which surface vertices). I worked over all of the examples and modified the relevant functions so they work with flatmaps as seamlessly as possible.
