'SelectByNomenclature' script

Questions about BrainVisa usage and installation

Moderators: denghien, riviere

Post Reply
f4bry
Posts: 29
Joined: Wed Mar 25, 2009 1:46 pm

'SelectByNomenclature' script

Post by f4bry »

Dear All,
I am trying to reproduce the following example with brainvisa-4.6.1 on a mac osx 10.14. The graph is loaded in Anatomist but the 'PREFRONTAL_right' doesn't show up.

Code: Select all

import anatomist.direct.api as anatomist
from soma import aims
import os

a = anatomist.Anatomist()
sh = aims.carto.Paths.shfjShared()
nom = a.loadObject(os.path.join(sh, 'nomenclature', 'hierarchy',
                                'sulcal_root_colors.hie'))
graph = a.loadObject('subj_Rbase.arg')
w = a.createWindow('3D')
w.addObjects(graph, add_graph_nodes=True)

a.execute('SelectByNomenclature', names='PREFRONTAL_right', nomenclature=nom)
I got the following message on terminal:

Code: Select all

>>> a.execute('SelectByNomenclature', names='PREFRONTAL_right', nomenclature=nom)
SelectByNomenclatureCommand
nomenclature : sulcal_root_colors.hie
select : 1 names
group : 0
modifiers : 1
<anatomist.cpp.RegularCommand object at 0x3a094d0>
but nothing happen on the window. Any clue how I can fix it?
Thank you!
f4b
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: 'SelectByNomenclature' script

Post by riviere »

Hi,
I think I know: sulci graphs may contain 2 labels sets: one for automatic labeling (from the sulcal recognition processes) and one for manual labeling. By default, if not specified, tools in anatomist are using the auto labeling. Here I think you have manual labels. Auto labels are stored in the "label" attribute of graph nodes, while manual ones are stored in the "name" attribute. You can set which one is used in the graph global attributes:

Code: Select all

graph.attributed()['label_property'] = 'name'
# then use the selection
a.execute('SelectByNomenclature', names='PREFRONTAL_right', nomenclature=nom)
Denis
f4bry
Posts: 29
Joined: Wed Mar 25, 2009 1:46 pm

Re: 'SelectByNomenclature' script

Post by f4bry »

Hi Denis,
Unfortunately this doesn't solve the issue. Since I am not getting error messages I don't know how to debug it.
Is there a method to check which objects are loaded in the Anatomist window?

Thank you!
f4b
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: 'SelectByNomenclature' script

Post by riviere »

You can get the list of objects present in the window:

Code: Select all

w.getObjects()
But let's get things clear: do you want to highlight sulci which are already visible, or display sulci which are not seen on screen ? As you have used "add_graph_nodes=True" in w.addObjects(), then all sulci should be visible anyway. If you don't see anything at all, then there is a problem.
a. either the graph has not been loaded completely.
b. or there is a display problem.

a. a graph is not only a .arg file, it also includes a .data directory coming with it. If you have moved or renamed the .arg, and did not bring the .data directory along, then you can still load the graph vertices / edges structure, but the graphical objects (voxels lists, meshes...) will not be here, and nothing will display
b1. do other objects (volumes, meshes) display properly in anatomist on your system ? Or sulci graphs loaded via the user interface or via brainvisa ?
b2. if yes, how does your script run ? I mean, you you load (or type, or copy/paste) it in an Ipython terminal ? Or run a python script which starts anatomist, load things and display things ?
* in ipython, ipython has to be run using the option --gui=qt so that it properly runs an event loop and display is updated regularly
* in a sctipt, after loading things, opening windows and putting objects in them, at the end of your script, an event loop has to be started: QtGui.qApp.exec() has to be called, otherwise events (like draw events) will not be called and rendering will not happen.
Is all this OK ?
To be sure, you can try loading a mesh (a .gii file) in your script and displaying it in anatomist in the same situation so that we are sure all the display infrastructure is OK.

Denis
Post Reply