marcomusy / vedo

A python module for scientific analysis of 3D data based on VTK and Numpy
https://vedo.embl.es
MIT License
2.04k stars 265 forks source link

Color aberations #430

Closed MathieuBo closed 3 years ago

MathieuBo commented 3 years ago

Hey,

I am using BrainRender for visualisation of neuro-related data. I have been using a function to slice some parts of the 3D objects however I get some aberations. After discussing with Fede Claudi, he mentionned that the problem could be probably using vedo.

I am attached here an example. Any idea how to solve that?

Thanks a lot !!

Sans titre

marcomusy commented 3 years ago

uhm it looks like you are rendering 2 almost coincident surfaces, is that a possibility?

MathieuBo commented 3 years ago

Yes I think that could be it. Essentially I am generating the full "brain" object and then extracting a slice of it.

marcomusy commented 3 years ago

a possible way to find out is to set a transparency and line width to all meshes with eg.: mymesh.alpha(0.5).lw(1)

MathieuBo commented 3 years ago

Ok thanks. I will try that!

FedeClaudi commented 3 years ago

Hey @MathieuBo when we spoke i hadn't realized you were cutting the root mesh as well. That would indeed create two surfaces going through the same points which would result in artifacts. Have you tried slicing the root mesh separately without closing it?

Something like this

from brainrender import Scene, settings
import numpy as np

settings.SHOW_AXES = False
settings.vsettings.immediateRendering  = False

scene = Scene(atlas_name='allen_mouse_25um')

regions = scene.add_brain_region('TH', 'CA1',  'Isocortex',)

p1 = scene.root.mesh.centerOfMass( ) - np.array([+1000, 0, 0])
p2 = scene.root.mesh.centerOfMass() 

for p, norm in zip((p1, p2), (1, -1)):
    plane = scene.atlas.get_plane(pos=p, norm=(norm, 0, 0))
    scene.slice(plane, actors=regions, close_actors=True)
    scene.slice(plane, actors=scene.root, close_actors=False)

scene.render(camera='frontal')

creates

image

which doesn't have artifacts.

Unfortunately tihs way you loose the fact that the inside of the brain is grey, which is quite nice. I've tried setting close_actors=True when cutting the 'back' point, but that closes the front of the brain outline too. I've tried a couple of things, but I haven't found a way to make it so that only in the back cut the root mesh is closed. It either closes both the back and the front or neither

MathieuBo commented 3 years ago

Thanks @FedeClaudi. I think that solution is good enough for my purpose!