Render volumetric heatmaps on top of brain structures
See original GitHub issueHi! This is a duplicate of an issue that I posted yesterday on the official vedo repository (https://github.com/marcomusy/vedo/issues/209). I wasn’t sure anymore whether it fits best as separate brainrender or as a vedo issue (given that not all features of vedo are enabled in brainrender?). I think it is also similar to this issue: https://github.com/BrancoLab/brainrender/issues/105.
What I want is to display some kind of volumetric heatmap, which I constructed as numpy array in the dimensions of the reference brain (allen 25 um), on top of some brain structures.
actor = Volume(
my_numpy_3d_volume,
spacing=[25, 25, 25],
alpha=.5,
alphaUnit=.5
)
actor = actor.legosurface(vmin=np.nanmin(score_map)+0.25, cmap='inferno')
The my_numpy_3d_volume
contains a bunch of scores (but mostly nans). I am able to utilise .legosurface
to display the volume at the correct location, which is great. However, what I really want is some kind of “smooth point cloud” that is mostly transparent where the original volume contains nans. What happens when I use .legosurface
is that I get a volume with pretty jagged edges which distracts from the actual information that I want to shine through (a smooth blob in the center). I can smooth the volume, but that also smoothes the values inside, which is not what I want.
Do you have any tipps on how to do this kind of stuff?
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (2 by maintainers)
Top GitHub Comments
@FedeClaudi correct!
One other trick to see the inside is to transform the volume into a mesh, eg.:
Note that this is feasible if the volume is relatively small.
this is how I do it for gene expression data. I don’t know how it works with
nans
but yeah you can convert them to some numeric value before thresholding if that’s causing you problems.I haven’t played around with it, but you might be able to change the appearance of the mesh you get from lego surface. In vedo when legosurface is created: https://github.com/marcomusy/vedo/blob/c8d5b3fcdeea49a89e74f3b4dd9dc86d7c08b42e/vedo/base.py#L1428
it sets
lw
to0.1
, which I think it’s why you see the voxels edges. You can try to do.lw(0)
to see if that works.