Closed JulienLefevreMars closed 3 years ago
Hi Julien,
The Brain
class is a GUI that merges visbrain objects and also contains buttons for interaction. I would first strongly suggest to use the SceneObj
as it is way more flexible and stable. In addition, the scenes can be returned by other functions, I'm not so sure for the GUI.
BrainObj and VectorObj which displays something but not expected
Hi Etienne and thank you for the super fast answer !
SceneObj
. I had just a problem with the color of the arrows (black as the background :-) ).I added my new visualization funcion if it can help.
`def visbrain_plot_vector_field(vector_field): visb_sc = SceneObj(bgcolor='black', size=(1000, 1000))
# Mesh
mesh = vector_field.mesh
b_obj = BrainObj('Mesh', vertices=np.array(mesh.vertices),
faces=np.array(mesh.faces),
translucent=False)
visb_sc.add_to_subplot(b_obj,row=0,col=0)
# Vector field
dtype = [('vertices', float, 3), ('normals', float, 3)] # Arrows dtype
arrows = np.zeros(mesh.vertices.shape[0], dtype=dtype) # Empty arrows array
arrows['vertices'] = mesh.vertices # Set the vertices
arrows['normals'] = 0.01*vector_field.coordinates_3d # Set the normals
v_obj = VectorObj('VectorField', arrows,color='white')
visb_sc.add_to_subplot(v_obj)
return visb_sc
`
So I am able now to display a scene with mesh and vectors, following the approach with SceneObj. I had just a problem with the color of the arrows (black as the background :-) ).
I suggest two small tests :
SceneObj(bgcolor='white')
and check that indeed you've black arrowsdata = np.random.rand(mesh.vertices.shape[0])
v_obj = VectorObj('VectorField', arrows, color='white', data=data)
I have no interactions
This is more problematic to me. First thing first, Visbrain is (unfortunately) not compatible with ipython or Jupyter, therefore you've to launch python scripts... The most basic example that cames to my mind to check this interaction issue is :
from visbrain.objects import BrainObj
BrainObj('B1').preview()
Does it works?
You could also try to run your python script, from a terminal, outside of your IDE (spyder, pycharm etc.).
And probably outside of Frioul :\
Thanks again !
1. Can you try to set a white background to the [SceneObj](http://visbrain.org/generated/visbrain.objects.SceneObj.html#visbrain.objects.SceneObj) with `SceneObj(bgcolor='white')` and check that indeed you've black arrows
It works perfectly well. So one the previous issue, linked to same color for background and arrows is fixed
I have no interactions
This is more problematic to me. First thing first, Visbrain is (unfortunately) not compatible with ipython or Jupyter, therefore you've to launch python scripts... The most basic example that cames to my mind to check this interaction issue is :
from visbrain.objects import BrainObj BrainObj('B1').preview()
Does it works?
It works fine in a python shell, I can interact with the figure but with pycharm, on my laptop (not frioul), the figure is static and there are no interactions. So probaly it is linked to pycharm configuration.
Well, in any case, I thank you a lot for all those precious hints. I am now able to visualize nice vector fields !
Cool Julien ! If I remember correctly, Guillaume is using Pycharm, maybe you could ask whether there's a config to change to have interactive figures...
See u ;)
Good point. I will ask him. See u (in another issue to follow :-) )
Hello !
I am working on vector fields defined on meshes - I develop my own class for that - and I want to display it with visbrain :-)
I have tried the following code adapting one of the example you provided
`def visbrain_plot_vector_field(vector_field):
but I have the following error
File "/home/julienlefevre/Documents/Softs/anaconda3/lib/python3.7/site-packages/visbrain/gui/brain/interface/gui/brain_gui.py", line 1881, in setupUi QtCore.QMetaObject.connectSlotsByName(MainWindow) SystemError: <built-in function connectSlotsByName> returned a result with an error set
visbrain is working with my configuration (through the slam module) and I have also tried another way to add vector fields by using ScenObj + add_suplot applied to BrainObj and VectorObj which displays something but not expected. Last, but not least, when using visbrain through slam I obtain figures that I cannot rotate. I don't know if all those things are related...
The version of visbrain is 0.4.5 (I have done an update with pip but it did not change the version, whereas it is said 0.4.6 on the website) Thanks in advance for the help !
Julien
PS: sorry for the code insertion, I did not manage to do it properly