Command AimsZcat

Questions about BrainVisa usage and installation

Moderators: denghien, riviere

Post Reply
quere
Posts: 54
Joined: Mon Mar 28, 2005 10:50 pm

Command AimsZcat

Post by quere »

Hello,
I write a script which permit to concat two files .mesh and display the result it in Anatomist Window but it 's wrong and I don't know why. Someone could help me :cry:

that it's my script:

from neuroProcesses import *
import shfjGlobals
import Anatomist

name = 'Dipole'
userLevel = 0

def validation():
Anatomist.validation()

signature = Signature(
'cyl_mesh',
ReadDiskItem( "Mesh", shfjGlobals.anatomistMeshFormats ),
'sph_mesh', ReadDiskItem( "Mesh", shfjGlobals.anatomistMeshFormats ),
'dip_mesh', WriteDiskItem( "Mesh",shfjGlobals.anatomistMeshFormats ),
)

def initialization( self ):
pass

def execution(delf,context):
a = Anatomist.anatomist()
context.system( 'AimsZcat', '-i', self.cyl_mesh, self.sph, '-o', self.dip_mesh)
cyl_mesh = a.loadObject( self.cyl_mesh )
sph_mesh = a.loadObject( self.sph_mesh )
dip_mesh = a.loadObject( self.dip_mesh )
win = a.createWindow( '3D' )
win.addObject( dip_mesh)


please help me :o
Manik
Posts: 99
Joined: Fri Mar 05, 2004 1:00 pm
Location: INSERM U836, Grenoble

Post by Manik »

Could you please give the error message or describe your problem ?

I see two problems here : there is no indentation (but I assume there is in your actual process), and you wrote "def execution(delf,context): " instead of "def execution(self,context): ".

If you want to see the objects after the end of the "execution" function, you should also add "return [cyl_mesh,sph_mesh,dip_mesh,win]" at the end of it, so BrainVisa will not destroy these items.
Manik Bhattacharjee
INSERM U836
quere
Posts: 54
Joined: Mon Mar 28, 2005 10:50 pm

Post by quere »

thank you I changed delf instead of self and I forgot sph_mesh in my script too so now my new script is that:

from neuroProcesses import *
import shfjGlobals
import Anatomist

name = 'Dipole'
userLevel = 0

def validation():
Anatomist.validation()

signature = Signature(
'cyl_mesh',
ReadDiskItem( "Mesh", shfjGlobals.anatomistMeshFormats ),
'sph_mesh', ReadDiskItem( "Mesh", shfjGlobals.anatomistMeshFormats ),
'dip_mesh', WriteDiskItem( "Mesh", shfjGlobals.anatomistMeshFormats ),
# 'head_mesh', ReadDiskItem( "Mesh", shfjGlobals.anatomistMeshFormats ),
# 'dip_head_mesh', WriteDiskItem( "Mesh", shfjGlobals.anatomistMeshFormats )
)

def initialization( self ):
pass

def execution(self,context):
a = Anatomist.anatomist()
context.system( 'AimsZcat', '-i', self.cyl_mesh, self.sph_mesh, '-o', self.dip_mesh)
#context.system( 'AimsZcat', '-i', self.dip_mesh, self.head_mesh, '-o', self.dip_head_mesh )
cyl_mesh = a.loadObject( self.cyl_mesh )
sph_mesh = a.loadObject( self.sph_mesh )
dip_mesh = a.loadObject( self.dip_mesh )
#head_mesh = a.loadObject( self.head_mesh )
#dip_head_mesh = a.loadObject( self.dip_head_mesh )
context.write( 'dipole: ', dip_mesh )
#context.write( 'head_dipole:', dip_head_mesh )
win = a.createWindow( '3D' )
win.addObject( dip_mesh )
return [cyl_mesh, sph_mesh, dip_mesh, win ]


and my error message is

Exception: argument dip_mesh is mandatory

neuroProcessesGUI.py (559) in _startCurrentProcess: apply( self._startProcess, ( self.process, distributed), d)
neuroProcesses.py (820) in _startProcess:
apply( self._setArguments, (_process,)+args, kwargs )
neuroProcesses.py (815) in _setArguments:
_process.checkArguments()
neuroProcesses.py (255) in checkArguments:
raise Exception( _t_('argument <em>%s</em> is mandatory') % p )


Could you help to solve this problem.
:lol:
Manik
Posts: 99
Joined: Fri Mar 05, 2004 1:00 pm
Location: INSERM U836, Grenoble

Post by Manik »

As stated in the error message, you have probably forgotten to fill the "dip_mesh" line when running your process in Brainvisa :
you should enter the path to the file that will be written, using the "folder" icon at the right of the "dip_mesh" line.
Manik Bhattacharjee
INSERM U836
quere
Posts: 54
Joined: Mon Mar 28, 2005 10:50 pm

Post by quere »

Thank you for your reply.
But I doesn't want to return the path like this, I would like that Brainvisa writes it directly. So how I can do!!! :)

Aurelie
User avatar
alexis
Posts: 43
Joined: Mon Jan 31, 2005 4:21 pm
Location: Paris
Contact:

Post by alexis »

Hi,

If you don't want to give the path like this, how do you want the process to know where to write the file? (is it because you want the file to be created in the same directory as the other files?)

There are several possibilities :

- you will always create the file at the same place with the same name, so you can give a default value to the paramter, but if you don't move the file, it will be overwritten everytime you trigger the process,
- you want the process to guess the path according to the other parameters:
*using the brainvisa hierarchy (located in brainvisa/shfjHierarchy.py), but I don't think it will work because there's no type difference between your arguments,
* extracting the path from the files, working on strings (it's very easy in python to seperate the file name and the path with function like 'split'),

- and last, if you still have problems and if I have some time, I can have a look in the processes to see if this hasn't ever been done,

Bye
Alexis Barbot
CNRS UPR640 LENA
quere
Posts: 54
Joined: Mon Mar 28, 2005 10:50 pm

Post by quere »

Hi,
thanks for your replay.
In my script I decide to give a default value the parameter, so I writed in the initialization :

def initialization( self ):
self.dip_mesh('C:\Documents and Settings\Lili\Mes documents\stage canada\dipoles\dip_mesh.mesh')


But I have two error messages:

in hierarchy file C:/Documents and Settings/Lili/Mes documents/stage canada/brainvisa/Brainvisa Data/hierarchy.py IOError: [Errno 2] No such file or directory: 'C:/Documents and Settings/Lili/Mes documents/stage canada/brainvisa/Brainvisa Data/hierarchy.py'

neuroHierarchy.py (1377) in readHierarchies: execfile( p[ 1 ], globals(), hContent )




in hierarchy file C:/Documents and Settings/Lili/Mes documents/stage canada/brainvisa/Brainvisa Data/hierarchy.py IOError: [Errno 2] No such file or directory: 'C:/Documents and Settings/Lili/Mes documents/stage canada/brainvisa/Brainvisa Data/hierarchy.py'

neuroHierarchy.py (1377) in readHierarchies: execfile( p[ 1 ], globals(), hContent )


But I don't anderstand why. So if you have any time could you help me to solve my problem
:x
User avatar
alexis
Posts: 43
Joined: Mon Jan 31, 2005 4:21 pm
Location: Paris
Contact:

Post by alexis »

I don't think this the right way to write a default value, you should do it like that :

Code: Select all

def initialization( self ): 
       self.dip_mesh='C:\Documents and Settings\Lili\Mes documents\stage canada\dipoles\dip_mesh.mesh' 
Alexis Barbot
CNRS UPR640 LENA
quere
Posts: 54
Joined: Mon Mar 28, 2005 10:50 pm

Post by quere »

Oh thank you very much Alexis , it's exactely what I need, and now it's run very good. :lol:
But however I still have a display problem, in fact when I excecute my fonction I can't see the result in the Anatomist window, and I am obliged to charge the files mesh with the hand...
So if you know why!!!
User avatar
alexis
Posts: 43
Joined: Mon Jan 31, 2005 4:21 pm
Location: Paris
Contact:

Post by alexis »

Hum... I tryed to run your function and it worked well, (there was just a little problem for the context call: my binary seems to be 'AimsZCat' instead of 'AimsZcat', but you didn't have errors about this, no?)
If I find anything I tell you.

Bye !
Alexis Barbot
CNRS UPR640 LENA
quere
Posts: 54
Joined: Mon Mar 28, 2005 10:50 pm

Post by quere »

Hi

I also tested my function on another computer and it goes. I believe that the probléme comes from my Anatomist. In fact I have the same problem for the others fonctions. I have nothing display in Anatomist. I am obliged to charge all the files with the hand... And I don't know why :?

Aurélie
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,

For the anatomist problem:
Are you sure you have not mixed two incompatible brainvisa/anatomist versions ? (maybe you changed the anatomistExecutable setting ?)
Or it might be a communication problem between BV and anatomist (it has sometimes been reported on computers with "strange" network settings).
Does anatomist work with other data using "standard" viewers from brainvisa ?

Anyway you could check the log, in the "communications with anatomist" section, you may have some information there.

Denis
Post Reply