Database and hierarchy

Questions about BrainVisa usage and installation

Moderators: denghien, riviere

Post Reply
bagory
Posts: 7
Joined: Tue May 23, 2006 1:11 pm
Location: CERMEP, Lyon, France

Database and hierarchy

Post by bagory »

Hi,

I would like to import spectroscopy quantification files to the BrainVisa hierarchy.

In shfjHierarchy.py, I've first add this :

Code: Select all

'd|quantif', SetWeakAttr( 'category', 'spectroscopy' ), SetContent(
            '<subject>_quantif', SetType( 'Spectroscopy Results' ),
            '<subject>_quantif', SetType( 'jMRUI Quantification File' ),
to SetContent() of spectroscopy. ("jMRUI Quantification File" is a FileType previously define in builtin.py)

Then, in my process signature and initialization function :

Code: Select all

name = 'ImportjMRUIQuantification'
userLevel=0

signature=Signature(
    'quantif', ReadDiskItem( 'jMRUI Quantification File', 'Text File' ),
    'rda', ReadDiskItem( 'Raw Data Spectroscopy Siemens', 'RDA File' ),
    'nomMetabolite1', String(),
    'nomMetabolite2', String(),
    'nomMetabolite3', String(),
    'metabolite_map_1', WriteDiskItem( 'Metabolite Map', 'GIS image'),
    'metabolite_map_2', WriteDiskItem( 'Metabolite Map', 'GIS image'),
    'metabolite_map_3', WriteDiskItem( 'Metabolite Map', 'GIS image'),
)

def initialization( self ):
    self.linkParameters( 'nomMetabolite1', 'metabolite_map_1' ),
    self.linkParameters( 'nomMetabolite2', 'metabolite_map_2' ),
    self.linkParameters( 'nomMetabolite3', 'metabolite_map_3' ),
It seams to work well for the importation process itself, but i've got some problems with the database and the hierarchy.
My questions are :
  • 1) How to allow the creation of a new subject and a new protocol in the database file interface when clicking on a WriteDiskItem "magnifing glass" in the process window ?

    2) My variables "nomMetabolite*" and "metabolite_map_*" are not linked. When I filled out "nomMetabolite*" and click and the red button of my WriteDiskItem "metabolite_map_*", no automatic name is proposed. Is something wrong or missing in my code ?

    3) I'm quite confusing with "findValue" and more generally with how the database is working, and there is no documentation for this topic, despite few messages on this forum. Does someone had written stuff on it ? (I've read that Manik had)
Thanks in advance for your help.

Sincerely,

Matthieu
User avatar
Yann Cointepas
Posts: 316
Joined: Tue Jan 20, 2004 2:56 pm
Location: Neurospin, Saint Aubin, France
Contact:

Post by Yann Cointepas »

Hi Matthieu,

1) If you want to create an "editable" attribute, you can use SetFileNameAttribute(). For example, you can have several tractography session and there is the following line in shfjHierarchy.py:

Code: Select all

          'd|*', SetFileNameAttribute( 'tracking_session' ), SetType( 'Tracking session' ), SetContent(
2) Yes, there is something missing in your code. There is no short answer to this question except making an appropriate documentation (see other answer below). Here is a not too long explaination on how things work:

When you link something to a Read/WriteDiskItem, findValue() is responsible of finding an appropriate value. If it fails, nothing is proposed. If the linked value is a string (your case) it is considered as a file name and is only valid if it correspond to one of the supported formats. If the value is another DiskItem, findValue parse the database to find the items having the type of the destination parameter (e.g. 'Metabolite Map' in your links) and it keeps only the items that have the biggest number of attributes in common with the linked value. If only one such item is found, it is returned. If more than one item is found, BrainVISA cannot select which one is the best and return nothing. For the WriteDiskItem, it is a bit more complicated because BrainVISA has to build items that do not exist (they are created by executing the process).

3)

You are right. It is not easy to play with the undocumented hierarchy system, congratulation ! Did you get any help to start ? I thought we in Orsay and people in Pitié-Salpêtrière in Paris (such as Manik) where the only ones to play with the hierarchy. This is why there is no documentation about this system, I would really like to have the time to write one but there are so many important things that have to be done for BrainVISA...

By the way, this system is going to change in the future version (not so much, copy-pasting existing hierarchy files will be enough). Types and hierarchies will be in several files. For example, it will be possible for you to add a spectroscopy.py file containing your modification to the hierarchy without having to edit shfjHierarchy.py. We will have a meeting about this change, you may be interested to come ?
klargenf
Posts: 4
Joined: Tue May 30, 2006 2:19 pm

Post by klargenf »

Well, I should say that the SetFileNameAttribute().function works just well but something wrong has happened when I tried to create new attribute to classify my DTIs according to their orientation count.
I have just added the following code into shfjHierarchy.py:

Code: Select all

'diffusion', SetWeakAttr( 'category', 'diffusion' ),
        SetContent(
            'd|*', SetFileNameAttribute('dirs'), SetType( 'directions' ), SetContent(
          '<subject>_raw_dw_diffusion', SetType( 'Raw DW Diffusion MR' ),
          '<subject>_dw_diffusion', SetType( 'Corrected DW Diffusion MR' ),
...
And the directory type ‘directions’ has been declared in builtin.py. then I tried to input my DTIs. I have clicked on the red magnifing glass and filled in the “dirs” blank with somewhat a name(ex. 12dirs). But after that I found the ‘12dirs’ directories generated not only under the current subject but all the subjects in my database. Certainly that’s not what I wanted.
Would you please give me some tips of solution about that?
User avatar
Yann Cointepas
Posts: 316
Joined: Tue Jan 20, 2004 2:56 pm
Location: Neurospin, Saint Aubin, France
Contact:

Post by Yann Cointepas »

Well I am afraid it is a bug in BrainVISA. I do not see any easy solution I could give you to go around this problem. I will have to fix it myself. The problem is that it cannot say when I will have time to fix it.
Post Reply