How to activate coloring by normals using pyanatomist ?

Questions about Anatomist manipulation

Moderators: riviere, denghien

pron.a
Posts: 22
Joined: Mon Feb 22, 2016 10:09 am

How to activate coloring by normals using pyanatomist ?

Postby pron.a » Thu Mar 01, 2018 5:16 pm

Hello Anatomist experts,

I am trying to visualize streamlines color coded by their local orientation. To do so, I calculate tangent of these streamlines and incorporate this information
into the normal field of the resulting 2D mesh.
In graphical interface of anatomist, I then click on activate shaders and select color model: normals. However I do not manage to do this operation using pyanatomist. When I do the operation into GUI and then check informations stored into the mesh AObject using getInfos method there is a shader_color_normals field into the material field. Unfortunately I do not manage to modify it using setMaterial method .
Do you have any hint ?

Alex

User avatar
riviere
Site Admin
Posts: 1358
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: How to activate coloring by normals using pyanatomist ?

Postby riviere » Fri Mar 02, 2018 1:42 am

Hi,
Well, after checking it seems that we haven't done any python bindings for these set of functionalities... That's definitely something we could do...
Denis

pron.a
Posts: 22
Joined: Mon Feb 22, 2016 10:09 am

Re: How to activate coloring by normals using pyanatomist ?

Postby pron.a » Sat Mar 03, 2018 5:20 pm

Thank you very much for the answer Denis :)
Have a good day
Alex

User avatar
riviere
Site Admin
Posts: 1358
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: How to activate coloring by normals using pyanatomist ?

Postby riviere » Mon Mar 05, 2018 10:49 am

Hi,
Well, actually there is a trick to setup normals colors, it's not very convenient but it should work until we do something better:

Code: Select all

# load/init anatomist
import anatomist.api as ana
a = ana.Anatomist()
# load a mesh
mesh = a.loadObject('soma_mesh.mesh')
# get low-level Material object (not the same as mesh.material)
mat = mesh.GetMaterial()
# set options on it
mat.set({'use_shader': True, 'shader_color_normals': True})
# this line might not be neededd
mesh.SetMaterial(mat)
# force setting material/shading options (this is not done by SetMaterial - for now)
mesh.setHeaderOptions()
# notify changes
mesh.setChanged()
mesh.notifyObservers()

Denis

User avatar
riviere
Site Admin
Posts: 1358
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: How to activate coloring by normals using pyanatomist ?

Postby riviere » Mon Mar 05, 2018 12:32 pm

OK in the next update (or if you are building anatomist from sources), it should be included in setMaterial():

Code: Select all

mesh.setMaterial(use_shader=1, shader_color_normals=1)

Denis

pron.a
Posts: 22
Joined: Mon Feb 22, 2016 10:09 am

Re: How to activate coloring by normals using pyanatomist ?

Postby pron.a » Thu Mar 08, 2018 12:17 pm

Hello Denis,

Sorry for the delay. Thank you very much for your super answers :) I will try the first solution for now and will rebuild from source later :P
Have a good day
Alex


Return to “Anatomist”

Who is online

Users browsing this forum: No registered users and 2 guests