noahbenson / neuropythy

A neuroscience library for Python, intended to complement the existing nibabel library.
GNU Affero General Public License v3.0
115 stars 21 forks source link

Add support for mesh transparency #11

Closed libertyh closed 5 years ago

libertyh commented 5 years ago

Please add support for transparency of triangle mesh surfaces. Example:

color = np.ones((sub.rh.pial_surface.vertex_count,4)) color[:,3] = 0.5 ipv.figure() ipf = ny.cortex_plot(sub.rh.pial_surface, color=color, alpha=0.5, underlay=None)

ipf.meshes[0].material.transparent = True ipf.meshes[0].color = color

This would be helpful for people who want to plot other meshes within a brain mesh, or electrodes (for ECoG)

noahbenson commented 5 years ago

Okay, this has been fixed in neuropythy 0.10.1; if you upgrade, you should be able to pass the optional argument mesh_alpha to ny.cortex_plot() -- e.g., ny.cortex_plot(sub.rh.pial_surface, color=color, mesh_alpha=0.5). The mesh_alpha parameter can be (1) a number 0-1, (2) None (same as 1), (3) a vector of values, one per vertex, or (4) the name of a property (like 'V1_label'); if you pass multiple meshes to the cortex_plot function, you can pass a list of mesh_alpha values, one per mesh.

Let me know if you find any bugs--I tested it just enough to make sure it wasn't completely broken, but there may be bugs.