Modify AnatomistShowFoldGraph.py

Questions about BrainVisa usage and installation

Moderators: denghien, riviere

Post Reply
Olivier_Colliot
Posts: 22
Joined: Wed Mar 17, 2004 5:25 pm
Location: LENA/CNRS, Paris

Modify AnatomistShowFoldGraph.py

Post by Olivier_Colliot »

Hello,

I'd like to modify AnatomistShowFoldGraph.py so that I have a new process which will display only on sulcus at a time.
I don't really see how I should do that. Is there a command that allows to select only some objects in the hierarchy ? (I looked at Anatomist.py but found nothing)

Thanks,
Olivier
PeterK
Posts: 45
Joined: Fri Mar 05, 2004 3:18 pm

Post by PeterK »

Hmm,
I'm not sure if you can edit python code to do it - but if you just to make an active selection you can use "select label" option and to type the name of the label.
That of course will just highlight the selected label - it won't get rid of the rest of the objects.

One way you can display a single object is by removing all the records from the .arg file but the record you want to display. This file is located in the graphe directory and while it is quirky, you can write a perl script to do it for you.
Olivier_Colliot
Posts: 22
Joined: Wed Mar 17, 2004 5:25 pm
Location: LENA/CNRS, Paris

Post by Olivier_Colliot »

Do you mean there is a python function that allows to select labels ?
I looked in Anatomist.py and found a "select" method in the class Anatomist. Is that the one I need to use ?
Is there no function I could use after that to display on the selected labels ?

If this does not work, I'll try to edit the graph as you suggested.
(as you said, it must be possible to do it in perl)
User avatar
Jean-Francois Mangin
Posts: 337
Joined: Mon Mar 01, 2004 10:24 am
Location: Neurospin, CEA, France
Contact:

Post by Jean-Francois Mangin »

Hi Olivier,
I am not sure that I completely understand what you have in mind.
Normally, we do this kind of operation using Anatomist, not brainVISA.
By default the AnatomistShow... turn on all the sulci, because it was clearer
behaviour for most of the user, but afterwards, using the hierarchy of sulci
(our nomenclature), you can turn on or off the sulcuc, or the bunch of sulci you want.
For instance, if you click on brain and unknown, you select everything.
Then zith the right click in a visualization window, you can re;ove
this selection from one or all windows. Finally turn on the sulcus you want.
I suggest not touching the arg file:-)
Olivier_Colliot
Posts: 22
Joined: Wed Mar 17, 2004 5:25 pm
Location: LENA/CNRS, Paris

Post by Olivier_Colliot »

Salut Jeff,

Right now, we actually do this using Anatomist.
However, as we work on a single sulcus for a large number of cases, it is quite annoying to do it manually each time. That's why I was thinking about writing a BV process to display a single sulcus. And I thought modifying AnatomistShowFoldGraph.py was the easiest way.
(an additional reason is that I wrote other processes to display lesions and other stuff and would like to combine them with the sulci display)

Concerning the arg file, I understand what you mean. It would be quite easy to get rid of all unrelevant nodes, but I guess I would have also to remove edges linking them which seems painful.
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

Hi Olivier,

A few hits:
- I didn't do an option (or function) in Anatomist commands to remove (or hide) objects by their names (once they are visible) yet. I'll try not to forget to do it...

but:

- you can avoid displaying all folds in AnatomistShowFoldGraph.py if you remove the lines:

Code: Select all

      if self.nomenclature is not None:
        hie.displayByName( "unknown brain" )
(at the end of execution() function)

- try never directly modify an existing process but copy it with another name if you want to stay in sync with us (future versions etc), for instance rename it to ~/.brainvisa/processes/viewers/automatic/AnatomistShowFoldGraph_OlivierColliot.py

- you can make BrainVisa show only folds with given names by using this displayByName() function of the hierarchy object, for instance:

Code: Select all

      hie.displayByName( "S.C._right S.T.s._right" )
will display only the right central sulcus and the right superior temporal sulcus (you can add a parameter to the process to type names)

- Don't use the Anatomist.select() function for this because you don't have handles to the target folds in BrainVisa. You may use Anatomist.selectByHierarchy() instead (but Hierarchy.displayByName() does it and is more convenient)

- avoid modifying the .arg unless there is really no other solution because then you are actually modifying the data, so you need to copy them first and it's error prone... I don't think you need this here.

Hope it helps
Denis
Olivier_Colliot
Posts: 22
Joined: Wed Mar 17, 2004 5:25 pm
Location: LENA/CNRS, Paris

Post by Olivier_Colliot »

Thanks a lot Denis, it is driving me in the good direction.

However, using "hie.displayByName" seems to work only for manually labelled graphs. I guess it is because the selection is based on the name, not the label.
Is there a way to do the same kind of thing with labels instead of names ? (i.e. is there some "displayByLabel" function)
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

Oh yes you're right: you have to switch Anatomist into "label" selection mode (it is "name" by default).
Do do so, use:

Code: Select all

  a = Anatomist.anatomist()
  a.graphParams( label_attribute='label' )
The selection mode is global (and can't be set differently for different views or different graphs).

Denis
Olivier_Colliot
Posts: 22
Joined: Wed Mar 17, 2004 5:25 pm
Location: LENA/CNRS, Paris

Post by Olivier_Colliot »

It does not seem to work.
What I did is very simple:
remove

Code: Select all

    
if self.nomenclature is not None:
hie.displayByName( "unknown brain" )
and add

Code: Select all

    a.graphParams( label_attribute='label')
    hie.displayByName( "S.C._left " )
But it still only displays for "names" not "labels"

Also, I wonder if adding the "graphParams" command is not redondant because the AnatomistShowFoldGraph process already does it (it checks wether the graph was made automatically or manually).

Thank you very much for spending so much time helping me, I really appreciate !
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

hmmm, you're right, when I try it here the result is a bit random: it sometimes works and sometimes selects nothing. Well done, you've found a bug in Anatomist. I'll investigate...

Denis
Guest

Post by Guest »

If it is really a bug, I'll wait for the next release.
Thanks a lot again for your help !
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

OK it's fixed here. It will be in the next stable version update (which we planed to release last month...)
If you can't wait, you just have to know that it worked when the graph parameters windows was open... stupid isn't it ?

Denis
Post Reply