Page 1 of 1

Hemispheres merge

Posted: Tue Jun 27, 2006 12:36 pm
by richards
Hi,

I have done a segmentation of a MRI picture of brain, so i got two different GIS pictures (one for left, one for right hemisphere).

But i want with to merge those two pictures to make only one with both hemispheres of the brain.

Does someone know if there is an Aims or Vip command able to do that ?

Posted: Tue Jun 27, 2006 12:50 pm
by Jean-Francois Mangin
Try VipMerge or AimsMerge wiith the right options.
To Merge two grey level volume images, this sjould work:
"VipMerge -i image1 -m image2 -c s -o result".
Do "VipMerge -h" to know more

Posted: Tue Jun 27, 2006 1:12 pm
by richards
ok thank you !!

but i have another question

do you know if there is a way to remove the "white matter" on each hemisphere ?

with "remove" i mean to make the "white matter" in the black color

Posted: Tue Jun 27, 2006 2:34 pm
by Jean-Francois Mangin
You can find some grey/white classification images in the pipeline.
A low tech one: L or Rgrey_white_ammon.ima,
A high tech one dedicated to the spherical grey/white interface.
R or Lcortex_ammon.ima.
A priori, the first one is more reliable, but this depends
on the quality of your data.

IF you want only grey matter, you can do a threshold:
"VipSingleThreshold -i image -t value_of_grey -mode eq -color b -o result"

To find more useful commandlines go there:
http://brainvisa.info/doc/html/shfjcomm ... mands.html

Posted: Tue Jun 27, 2006 4:51 pm
by richards
yes it perfectly worls with VipSingleThreshold !!

thank you !!

Posted: Tue Jun 27, 2006 5:31 pm
by Yann Cointepas
I would recomand to use the more up-to-date AimsThreshold command:

Code: Select all

AimsThreshold -i image -t value_of_grey -m eq -b -o result

error in execution

Posted: Tue May 22, 2007 2:27 pm
by salemhannoun
hi,
i'm trying to write a code on python to add it like the pipeline of segmentation.
i used the same functions that u said before. but i'm not a good programer, so whenever i excecute they say that it is not working.
this is the code i used:

from neuroProcesses import *
import shfjGlobals, shelltools

name = 'Extract Grey and white matter'
userLevel=0

signature=Signature(
'left_grey_white', ReadDiskItem( 'Left Grey White Mask', 'GIS Image' ),
'right_grey_white', ReadDiskItem( 'Right Grey White Mask', 'GIS Image' ),
'grey', WriteDiskItem( 'Grey White Mask', 'GIS Image' ),
'white', WriteDiskItem( 'Grey White Mask', 'GIS Image' ),
)


# def initialization( self ):



def execution( self, context ):
temp = context.temporary ( 'GIS Image' )
context.system( 'VipMerge', '-i', self.left_grey_white, '-m',
self.right_grey_white, '-c', 's', '-o',
temp )
context.system( 'AimsThreshold', '-i', temp, '-t',
50, '-m', 'eq', '-b', 'o', self.grey() )
context.system( 'AimsThreshold', '-i', temp, '-t',
100, '-m', 'eq', '-b', 'o',
self.white() )


can u tell me what is wrong and what should i do?
with this code, i'm trying to merge 2 images that i got from the pipeline 2004 left anf right grey and white matter, then extract only the white matter and in another image only the grey matter

thank you a lot for ur help

Posted: Wed May 23, 2007 2:13 am
by riviere
Hi,
Well, we normally do not have time to debug everybody's programs... especially if the exact error message is not provided: "it is not working" is just not enough for us to understand where and why your program fails (and here python indentation is not preserved so we cannot see if it is OK or not).
But just at first glance, it seems that you are using processes parameters as functions (or methods): self.grey(), but they are not functions actually: they are variables: self.grey would work better here.
Denis

Posted: Wed May 23, 2007 3:36 pm
by Yann Cointepas
Whenever you use a DiskItem object in a system call (for instance temp, self.left_grey_white, self.grey, etc. in your process), I would recommand to use fullPath method for Aims commands and fullName method for Vip commands. The difference is that fullName does not include the file extension (Vip commands do not want the extension). Here is a quickly copy/pasted/modified sample of your process:

context.system( 'VipMerge', '-i', self.left_grey_white.fullName(), '-m',
self.right_grey_white.fullName(), '-c', 's', '-o',
temp.fullName() )
context.system( 'AimsThreshold', '-i', temp.fullPath(), '-t',
50, '-m', 'eq', '-b', 'o', self.grey.fullPath() )
context.system( 'AimsThreshold', '-i', temp.fullPath(), '-t',
100, '-m', 'eq', '-b', 'o',
self.white.fullPath() )

However, fullPath usage is not mandatory(since it is impicitely used when a DiskItem is converted to a string to build the command line. In that case you can directly use the DiskItem without parentheses.

Posted: Thu May 24, 2007 4:42 pm
by salemhannoun
bonjour,
premièrement merci pour votre aide.
j'ai fait ce que vous m'aviez dit, j'ai reécrit le code que vous m'avez donné mais ca n'a pas marché, il m'a donné le message d'erreur suivant:

Traitement Extract Grey and white matter 1 démarré sur 2007/05/24 17:35<bound method File.fullPath of 'C:\\Program Files\\SHFJ_pack-stable-win32-3.0.2\\a.ima'> is not a valid number


dans Extract Grey and white matter 1 RuntimeError: Commande système terminée avec une valeur non nulle : 1

neuroProcesses.py (1641) in _processExecution:
result = process.execution( self )
ExtractGreyWhite.py (59) in execution:
50, '-m', 'eq', '-b', 'o', self.grey.fullPath )
neuroProcessesGUI.py (932) in system:
ret = apply( ExecutionContextGUI.system, (self,) + args, kwargs )
neuroProcesses.py (1721) in system:
raise RuntimeError( _t_( 'System command exited with non null value : %s' ) % str( ret ) )



j'ai essayer les 2 methodes avec et sans les parenthèses pres de fullpath, mais il me dit la même chose.
que dois-je faire?
je vous remercie pour l'aide

Posted: Thu May 24, 2007 4:47 pm
by salemhannoun
excuse me for my mistake, i forgot that i should write in english
hi,
first thank you for all ur help.
i did what u told me to do, i wrote the code that u gave me but it did not work, it gave me the following error message:

Traitement Extract Grey and white matter 1 démarré sur 2007/05/24 17:35<bound method File.fullPath of 'C:\\Program Files\\SHFJ_pack-stable-win32-3.0.2\\a.ima'> is not a valid number


dans Extract Grey and white matter 1 RuntimeError: Commande système terminée avec une valeur non nulle : 1

neuroProcesses.py (1641) in _processExecution:
result = process.execution( self )
ExtractGreyWhite.py (59) in execution:
50, '-m', 'eq', '-b', 'o', self.grey.fullPath )
neuroProcessesGUI.py (932) in system:
ret = apply( ExecutionContextGUI.system, (self,) + args, kwargs )
neuroProcesses.py (1721) in system:
raise RuntimeError( _t_( 'System command exited with non null value : %s' ) % str( ret ) )



i tried the 2 methods with and without the parenteses next to fullpath, but the error messege is the same.
what shoud i do?
thank you for all your help

Posted: Thu May 24, 2007 6:20 pm
by riviere
There is a mistake in the output file parameter of AimsTheshold:

Code: Select all

context.system( 'AimsThreshold', '-i', temp.fullPath(), '-t',
                50, '-m', 'eq', '-b', 'o', self.grey.fullPath() )
the '-' is missing on the 'o' switch, should be:

Code: Select all

context.system( 'AimsThreshold', '-i', temp.fullPath(), '-t', 
                50, '-m', 'eq', '-b', '-o', self.grey.fullPath() )
this can explain that self.grey is not understood as the output filename, but here the output filename is 'o' and self.grey is understood as the following parameter not already specified, namely the '-u' parameter: second threshold, which should be a numeric value, hence the error.

Denis

hi

Posted: Tue May 29, 2007 9:28 am
by salemhannoun
hi
thanks for the help it worked without any errors.

but now i have another problem:
for the grey matter the code worked perfectly, i saw the grey matter alone on a window by itself.
but the whithe matter did not work, i only see a black screen.
the code for the white matter was:

context.system( 'AimsThreshold', '-i', temp.fullPath(), '-t',
100, '-m', 'eq', '-b', '-o', self.grey.fullPath() )

instead of the grey value 50 i changed it and replaced it by 100 the value of white matter that i know.

what should i do to make it work for the white matter?
thanks for your help

Posted: Thu May 31, 2007 12:06 am
by riviere
Hi,
I guess the images values are just not what you think they are. In our pipeline, the grey/white values are 100/200, not 50/100...
Denis