How to handle lots of data in batch mode?

Questions about BrainVisa usage and installation

Moderators: denghien, riviere

jinju
Posts: 20
Joined: Tue Nov 25, 2008 4:44 am

How to handle lots of data in batch mode?

Post by jinju »

Hi~

I'll run the BV to get some results from using the morphometry / automatic recognition process with a lot of patient data on IBM server.
I'd like to know how to use in batch mode.
Please, give me some advice to handle it.

Happy New Year :D

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

Re: How to handle lots of data in batch mode?

Post by Yann Cointepas »

Hi Jin-ju,

Usually when we need to apply a process to several patients, we use the iteration BrainVISA feature that is available for most of the processes and pipelines (see http://brainvisa.info/doc/brainvisa-3.1 ... tml#N10A53 for more details).

However there is a batch mode in BrainVISA that relies on Python language. When you start BrainVISA you can use -c <python_code> or -e <python_script> to run some code at startup. You can add -b option to run BrainVISA without graphical interface. In order to run a BrainVISA process in Python you must get an execution context and know the identifier of the process (this identifier is displayed in processes documentation, it is the process file name without the .py extension). Then you can call the runProcess method of the execution context and give values to processes parameters like in any Python function. For file parameters, you can give the full path name but you can also provide attributes values in a dictionary an let BrainVISA find the filename for you.

In the following example, Vip Bias Correction is called on three images by giving file names. In this case, no database is used, therefore all output file names must be provided (in this example there is only mri_corrected).

Code: Select all

from neuroProcesses import *
context = defaultContext()
for i in 'x', 'y', 'z':
  context.runProcess( 'VipBiasCorrection',
    mri = i + '.nii',
    mri_corrected=i + '_corrected.nii',
    field_rigidity=15 )
The next example calls the same process but using database to iterate on several subjects (mri_corrected is found automatically). In this particular case, it would have been easier to use iteration feature (no batch to write).

Code: Select all

from neuroProcesses import *
context = defaultContext()
for subject in 'Albert', 'Renato', 'Siegfried', 'John':
  context.runProcess( 'VipBiasCorrection',
    mri = { 'protocol': 'test', subject=subject },
    field_rigidity=15 )
You can also write your batch as a custom process. This is, to my opinion, the most convenient way. Just create a process *.py file on <home directory>/.brainvisa/processes and it will appear next time you run BrainVISA in "My processes" toolbox. Once opened, you can keep modifying and running the process without restarting BrainVISA because process can be automatically updated when modification is detected. To have more information about a process structure see http://brainvisa.info/doc/brainvisa-3.1 ... /ch03.html.

Good batching,

Yann
User avatar
Jean-Francois Mangin
Posts: 337
Joined: Mon Mar 01, 2004 10:24 am
Location: Neurospin, CEA, France
Contact:

Re: How to handle lots of data in batch mode?

Post by Jean-Francois Mangin »

The process computing morphometric measurements is a bit special, you can select has many subject as you want to
get only one file per sulcus.
Otherwise, for the sulcus recognition, you use the iteration process selecting as many subject as you want.
For the distribution of a lot of processing to a cluster, you can do slight modifications to some processing (P. Kochunov did that) or
wait for a future brainVISA release...
jinju
Posts: 20
Joined: Tue Nov 25, 2008 4:44 am

Re: How to handle lots of data in batch mode?

Post by jinju »

Hi, Yann
Thanks a lot for your answer.
I'm trying to...
But I'm sorry to keep troubling you.
I don't know how to use "siRelax" command.
Could you show me an example??


Jin-ju
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: How to handle lots of data in batch mode?

Post by riviere »

Hi Jin-Ju,
siRelax is interfaced in BrainVisa: go to morphometry -> automatic recognition.
If you really need to use it at lower level, just run it a first time from BrainVisa, then look at the log to see how it is called...
Denis
jinju
Posts: 20
Joined: Tue Nov 25, 2008 4:44 am

Re: How to handle lots of data in batch mode?

Post by jinju »

By the way, I wonder when the bv_******.cfg creates?

(I know it is parameters file for inputs for the command. )

Does it create before automatic recognition process?


And, I have another query about RIC Peter Ks Magic Sulcal Length.

I confirmed the commands from the log.
============================================================================================================================
'siGraph2Label' '-g' '/home/jinju/zz/Ljj_auto.arg' '-a' 'label' '-tv' '/home/jinju/zz/nobias_jj.ima' '-o' '/home/jinju/zz/LBottom_jj_default_session_auto.ima' '-l' 'S.C._left' '-b' 'aims_bottom'


'siGraph2Label' '-g' '/home/jinju/zz/Ljj_auto.arg' '-a' 'label' '-tv' '/home/jinju/zz/nobias_jj.ima' '-o' '/home/jinju/zz/LHullJunction_jj_default_session_auto.ima' '-l' 'S.C._left' '-b' 'aims_junction' '-s' 'hull_junction'


'AimsClosing' '-i' '/home/jinju/zz/LSulci_jj_default_session_auto.ima' '-o' '/home/jinju/zz/ric/tmp.ima' '-r' '10.0'
=> I can't follow the process where LSulci_jj_default_session_auto.ima has been created??
I guess some stages are omited. ( I'm not sure!)

'AimsMesh' '-i' '/home/jinju/zz/ric/tmp.ima' '-o' '/home/jinju/zz/ric/S_C__left' '-l' '32766' '--smooth' '--smoothIt' '20'


'AimsZCat' '-o' '/home/jinju/zz/ric/S_C__left.mesh' '-i' '/home/jinju/zz/ric/S_C__left_32767_1.mesh' '/home/jinju/zz/ric/S_C__left_32767_0.mesh'


Thanks in advance.

Jin-ju
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: How to handle lots of data in batch mode?

Post by riviere »

By the way, I wonder when the bv_******.cfg creates?
It is directly created by the BrainVisa process (in the python code of recognition.py)
Normally it is dumped in the log, sou you just need to copy/paste it in your own .cfg file if you want to run siRelax manually.

For the RIC question, I let Peter answer (but I don't actually know if he reads this forum regularly). You'd maybe better have opened another topic because those were two distinct questions (and there is already a drift from the initial subject)...

Denis
jinju
Posts: 20
Joined: Tue Nov 25, 2008 4:44 am

Re: How to handle lots of data in batch mode?

Post by jinju »

Hi, BV users
Did anyone write a python script of the T1 pipeline 2007 process for running it on server??
It's my purpose to deal with lots of data on IBM server.
My problem is that I don't know how to write a python script.
Please, help me...
(I want to receive it.)
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: How to handle lots of data in batch mode?

Post by riviere »

Hi,
You don't need to write another python script for the T1 pipeline: Brainvisa processes *are* python scripts. You can run them in batch mode on a server if you like:

Code: Select all

brainvisa -b -c 'defaultContext().runProcess( "t1pipeline07", <parameters> )'
But understand that we cannot take time to write scripts for you...
Denis
jinju
Posts: 20
Joined: Tue Nov 25, 2008 4:44 am

Re: How to handle lots of data in batch mode?

Post by jinju »

Thank you for your answer.
By the way, I wrote the script with commandline from logfile.
(I'm poor at programming so I did it.)
It doesn't work at the siMorpho commandline.
Who can modify my script?? or Who give me some advice??
(I'd like to receive the script for running T1 process.)
It ended in failure at siMorpho process.

Error message is following this:
siMorpho /home/jinju/bv_test/bv_3.cfg
/usr/local/softwares/brainvisa/bin/commands-links/siMorpho : bad param in file /home/jinju/bv_test/bv_3.cfg, param graphFiles
siMorpho /home/jinju/bv_test/bv_4.cfg
/usr/local/softwares/brainvisa/bin/commands-links/siMorpho : bad param in file /home/jinju/bv_test/bv_4.cfg, param graphFiles

Code: Select all

#!/usr/bin/python
import os
from sys import * 
helpmsg='''
dir1=argv[1]
dir2=argv[2]
name_t1=argv[3]
pt_name=argv[4]

e.g) python bv_brainvisa.py /home/jinju/ /home/jinju/targetdir/ t1_icbm.mnc pt_name

'''

if argv[1]=='help':
	print helpmsg
	exit()

dir1=argv[1]
dir2=argv[2]
name_t1=argv[3]
pt_name=argv[4]

os.system('mkdir '+dir2)

fp = open(dir2+pt_name+'.APC','w')
strin='AC: 90 90 108\nPC: 90 118 108\nIH: 90 110 48\nThe previous coordinates, used by the system, are defined in voxels\nThey stem from the following coordinates in millimeters:\nACmm: 90 90 108\nPCmm: 90 118 108\nIHmm: 90 110 48'
fp.write(strin)
fp.close()

Aims1 = 'AimsFileConvert -i '+dir1+name_t1+' -o '+dir2+'normalized_yes_'+pt_name+'.ima -t S16 -r --omin 0 --omax 4095'

Vip1 = 'VipT1BiasCorrection -i '+dir2+'normalized_yes_'+pt_name+'.ima -o '+dir2+'nobias_'+pt_name+' -Fwrite no -field '+dir2+'biasfield_'+pt_name+' -Wwrite yes -wridge '+dir2+'whiteridge_'+pt_name+' -Kregul 20.0 -sampling 16.0 -Grid 2 -ZregulTuning 0.5 -vp 75 -e 3 -eWrite no -ename '+dir2+'edges_'+pt_name+' -vWrite no -vname '+dir2+'variance_'+pt_name+' -mWrite no -mname '+dir2+'mean_curvature_'+pt_name+' -hWrite yes -hname '+dir2+'hfiltered_'+pt_name+' -Last 0'

Vip2 = 'VipHistoAnalysis -i '+dir2+'nobias_'+pt_name+' -o '+dir2+'nobias_'+pt_name+' -S y -m a'

Vip3 = 'VipGetBrain -m Standard -i '+dir2+'nobias_'+pt_name+' -analyse r -hname '+dir2+'nobias_'+pt_name+' -bname '+dir2+'brain_'+pt_name+' -berosion 2.1 -First 1 -Last 3 -Points '+dir2+pt_name+'.APC -niter 0'

Vip4 = 'VipSplitBrain -input '+dir2+'nobias_'+pt_name+' -brain '+dir2+'brain_'+pt_name+' -analyse r -hname '+dir2+'nobias_'+pt_name+' -output '+dir2+'voronoi_'+pt_name+' -erosion 2.0 -ccsize 500 -walgo r -Points '+dir2+pt_name+' -template /usr/local/softwares/brainvisa/share/shfj-3.1/hemitemplate/closedvoronoi -TemplateUse y'

Aims2 = 'AimsThreshold -i '+dir2+'voronoi_'+pt_name+'.ima -o '+dir2+'bv_1125248.ima -m be -t 1 -u 2 -b'

Vip5 = 'VipTalairachTransform -i '+dir2+pt_name+'.APC -o '+dir2+'RawT1-'+pt_name+'_3T_TO_Talairach-ACPC.trm -m '+dir2+'bv_1125248.ima'


Vip6 = 'VipGreyWhiteClassif -i '+dir2+'nobias_'+pt_name+' -h '+dir2+'nobias_'+pt_name+' -m '+dir2+'voronoi_'+pt_name+' -o '+dir2+'Lgrey_white_'+pt_name+' -l 2 -w t'

Vip7 = 'VipGreyWhiteClassif -i '+dir2+'nobias_'+pt_name+' -h '+dir2+'nobias_'+pt_name+' -m '+dir2+'voronoi_'+pt_name+' -o '+dir2+'Rgrey_white_'+pt_name+' -l 1 -w t'

Vip8 = 'VipSplineResamp -i '+dir2+'nobias_'+pt_name+' -ord 3 -dx 182 -dy 218 -dz 182 -sx 1 -sy 1 -sz 1 -did -o '+dir2+'bv_1125265'

Vip9 = 'VipSplineResamp -i '+dir2+'voronoi_'+pt_name+' -ord 0 -dx 182 -dy 218 -dz 182 -sx 1 -sy 1 -sz 1 -did -o '+dir2+'bv_1125266'


Vip10 = 'VipMask -i '+dir2+'bv_1125265 -m '+dir2+'bv_1125266 -o '+dir2+'bv_1125271 -w t -l 2'

Vip11 = 'VipHomotopicSnake -i '+dir2+'bv_1125271 -h '+dir2+'nobias_'+pt_name+' -o '+dir2+'bv_1125274 -w t -p 100'

Vip12 = 'VipSingleThreshold -i '+dir2+'bv_1125274 -o '+dir2+'bv_1125277 -t 0 -c b -m ne -w t'

Aims3 = 'AimsMeshWhite -i '+dir2+'bv_1125277 -o '+dir2+pt_name+'_Lwhite.mesh'

Aims4 = 'AimsMeshSmoothing -i '+dir2+pt_name+'_Lwhite.mesh -n 10 -I -r 0.2'


Vip13 = 'VipMask -i '+dir2+'bv_1125265 -m '+dir2+'bv_1125266 -o '+dir2+'bv_1125287 -w t -l 1'

Vip14 = 'VipHomotopicSnake -i '+dir2+'bv_1125287 -h '+dir2+'nobias_'+pt_name+' -o '+dir2+'bv_1125290 -w t -p 100'

Vip15 = 'VipSingleThreshold -i '+dir2+'bv_1125290 -o '+dir2+'bv_1125293 -t 0 -c b -m ne -w t'

Aims5 = 'AimsMeshWhite -i '+dir2+'bv_1125293.ima -o '+dir2+''+pt_name+'_Rwhite.mesh'

Aims6 = 'AimsMeshSmoothing -i '+dir2+''+pt_name+'_Rwhite.mesh -n 10 -I -r 0.2'


Vip16 = 'VipMask -i '+dir2+'nobias_'+pt_name+' -m '+dir2+'voronoi_'+pt_name+' -o '+dir2+'bv_11252107 -w t -l 2'

Vip17 = 'VipHomotopicSnake -i '+dir2+'bv_11252107 -h '+dir2+'nobias_'+pt_name+' -o '+dir2+'Lcortex_'+pt_name+' -w t'

Vip18 = 'VipSingleThreshold -i '+dir2+'Lcortex_'+pt_name+' -o '+dir2+'bv_11252112 -t 0 -c b -m eq -w t'

Vip19 = 'VipOpenFold -i '+dir2+'bv_11252107 -s '+dir2+'bv_11252112 -o '+dir2+'bv_11252115 -a i -w t -n 5'

Aims7 = 'AimsMeshBrain -i '+dir2+'bv_11252115.ima -o '+dir2+pt_name+'_Lhemi.mesh'


Vip20 = 'VipMask -i '+dir2+'nobias_'+pt_name+' -m '+dir2+'voronoi_'+pt_name+' -o '+dir2+'bv_11252120 -w t -l 1'

Vip21 = 'VipHomotopicSnake -i '+dir2+'bv_11252120 -h '+dir2+'nobias_'+pt_name+' -o '+dir2+'Rcortex_'+pt_name+' -w t'

Vip22 = 'VipSingleThreshold -i '+dir2+'Rcortex_'+pt_name+' -o '+dir2+'bv_11252125 -t 0 -c b -m eq -w t'

Vip23 = 'VipOpenFold -i '+dir2+'bv_11252120 -s '+dir2+'bv_11252125 -o '+dir2+'bv_11252128 -a i -w t'

Aims8 = 'AimsMeshBrain -i '+dir2+'bv_11252128.ima -o '+dir2+pt_name+'_Rhemi.mesh'


Vip24 = 'VipGetHead -i '+dir2+'nobias_'+pt_name+' -hn '+dir2+'nobias_'+pt_name+' -o '+dir2+'bv_11252136.ima -w t -r t' 

Aims9 = 'AimsMeshBrain -i '+dir2+'bv_11252136.ima -o '+dir2+pt_name+'_head.mesh'


Vip25 = 'VipMask -i '+dir2+'nobias_'+pt_name+' -m '+dir2+'voronoi_'+pt_name+' -o '+dir2+'bv_11252146.ima -w t -l 2'

Vip26 = 'VipMask -i '+dir2+'nobias_'+pt_name+' -m '+dir2+'voronoi_'+pt_name+' -o '+dir2+'bv_11252149.ima -w t -l 1'


Vip27 = 'VipHomotopicSnake -i '+dir2+'bv_11252146.ima -h '+dir2+'nobias_'+pt_name+' -o '+dir2+'Lcortex_'+pt_name+' -w t'

Vip28 = 'VipSkeleton -i '+dir2+'Lcortex_'+pt_name+' -so '+dir2+'Lskeleton_'+pt_name+' -vo '+dir2+'Lroots_'+pt_name+' -g '+dir2+'bv_11252146.ima -w t'

Vip29 = 'VipFoldArg -i '+dir2+'Lskeleton_'+pt_name+' -v '+dir2+'Lroots_'+pt_name+' -o '+dir2+'L'+pt_name+''

Vip30 = 'VipFoldArgAtt -i '+dir2+'Lskeleton_'+pt_name+' -lh '+dir2+'bv_11252146.ima -rh '+dir2+'bv_11252149.ima -a '+dir2+'L'+pt_name+' -P '+dir2+pt_name+' -t y'

Vip31 = 'VipFoldArg -a '+dir2+'L'+pt_name+' -o '+dir2+'L_local'+pt_name+' -w g'

Aims10 = 'AimsGraphConvert -i '+dir2+'L_local'+pt_name+'.arg -o '+dir2+'L'+pt_name+'.arg -b L'+pt_name+'.data -g'

Aims11 = 'AimsGraphComplete -i '+dir2+'L'+pt_name+'.arg --dversion 3.0 --mversion 3.0'


Vip32 = 'VipHomotopicSnake -i '+dir2+'bv_11252149.ima -h '+dir2+'nobias_'+pt_name+' -o '+dir2+'Rcortex_'+pt_name+' -w t'

Vip33 = 'VipSkeleton -i '+dir2+'Rcortex_'+pt_name+' -so '+dir2+'Rskeleton_'+pt_name+' -vo '+dir2+'Rroots_'+pt_name+' -g '+dir2+'bv_11252149.ima -w t'

Vip34 = 'VipFoldArg -i '+dir2+'Rskeleton_'+pt_name+' -v '+dir2+'Rroots_'+pt_name+' -o '+dir2+'R'+pt_name+''

Vip35 = 'VipFoldArgAtt -i '+dir2+'Rskeleton_'+pt_name+' -lh '+dir2+'bv_11252146.ima -rh '+dir2+'bv_11252149.ima -a '+dir2+'R'+pt_name+' -P '+dir2+pt_name+' -t y'

Vip36 = 'VipFoldArg -a '+dir2+'R'+pt_name+' -o '+dir2+'R_local'+pt_name+' -w g'

Aims12 = 'AimsGraphConvert -i '+dir2+'R_local'+pt_name+'.arg -o '+dir2+'R'+pt_name+'.arg -b R'+pt_name+'.data -g'

Aims13 = 'AimsGraphComplete -i '+dir2+'R'+pt_name+'.arg --dversion 3.0 --mversion 3.0'


siRelaxL = 'siRelax '+dir2+'bv_1.cfg'

siRelaxR = 'siRelax '+dir2+'bv_2.cfg'

siMorphoL = 'siMorpho '+dir2+'bv_3.cfg'

siMorphoR = 'siMorpho '+dir2+'bv_4.cfg'

'''
RIC1 = 'siGraph2Label -g '+dir2+'L'+pt_name+'_default_session_auto.arg -a label -tv '+dir2+'nobias_'+pt_name+' -o '+dir2+'LBottom_'+pt_name+'_default_session_auto.ima -l S.C._left -b aims_bottom'


RIC2 = 'siGraph2Label -g '+dir2+'L'+pt_name+'_default_session_auto.arg -a label -tv '+dir2+'nobias_'+pt_name+' -o '+dir2+'LHullJunction_'+pt_name+'_default_session_auto.ima -l S.C._left -b aims_junction -s hull_junction'


RIC3 = 'AimsClosing -i '+dir2+'LSulci_'+pt_name+'_default_session_auto.ima -o '+dir2+'tmp.ima -r 10.0'


RIC4 = 'AimsMesh -i '+dir2+'tmp.ima -o '+dir2+'S_C__left -l 32766 --smooth --smoothIt 20'

RIC5 = 'AimsZCat -o '+dir2+'S_C__left.mesh -i '+dir2+'s_C__left_32767_0.mesh'
'''


fp = open(dir2+'bv_1.cfg','w')
strin='*BEGIN TREE 1.0 siRelax'+'\n'+\
'modelFile /usr/local/softwares/brainvisa/share/shfj-3.1/models/3.0/Lfolds_noroots_171201/Lfolds_model_noroots_2001.arg'+'\n'+\
'graphFile '+str(dir2)+'L'+pt_name+'.arg'+'\n'+\
'output '+str(dir2)+'L'+pt_name+'_default_session_auto.arg'+'\n'+\
'plotfile '+str(dir2)+'L'+pt_name+'_default_session_auto.nrj'+'\n'+\
'rate 0.98'+'\n'+\
'stopRate 0.05'+'\n'+\
'niterBelowStopProp 1'+'\n'+\
'extensionMode CONNECT_VOID CONNECT'+'\n'+\
'*END'
fp.write(strin)
fp.close()

fp = open(dir2+'bv_2.cfg','w')
strin='*BEGIN TREE 1.0 siRelax'+'\n'+\
'modelFile /usr/local/softwares/brainvisa/share/shfj-3.1/models/3.0/Rfolds_noroots_020200/Rfolds_model_noroots_2000.arg'+'\n'+\
'graphFile '+str(dir2)+'R'+pt_name+'.arg'+'\n'+\
'output '+str(dir2)+'R'+pt_name+'_default_session_auto.arg'+'\n'+\
'plotfile '+str(dir2)+'R'+pt_name+'_default_session_auto.nrj'+'\n'+\
'rate 0.98'+'\n'+\
'stopRate 0.05'+'\n'+\
'niterBelowStopProp 1'+'\n'+\
'extensionMode CONNECT_VOID CONNECT'+'\n'+\
'*END'
fp.write(strin)
fp.close()

fp = open(dir2+'bv_3.cfg','w')
strin='*BEGIN TREE 1.0 siMorpho'+'\n'+\
'modelFile /usr/local/softwares/brainvisa/share/shfj-3.1/models/3.0/Lfolds_noroots_171201/Lfolds_model_noroots_2001.arg'+'\n'+\
'graphFile '+str(dir2)+'L'+pt_name+'_default_session_auto.arg'+'\n'+\
'filter_attributes label'+'\n'+\
'selection /home/jinju/bv_16863125.sel'+'\n'+\
'output_prefix '+'L'+pt_name+'_\n'+\
'labelsMapFile  /usr/local/softwares/brainvisa/share/shfj-3.1/nomenclature/hierarchy/sulcal_root_colors.hie'+'\n'+\
'name_descriptors 1'+'\n'+\
'descriptor_aliases '+'fold_descriptor2 '+'fold_descriptor3 '+'\n'+\
'print_labels 1'+'\n'+\
'subjects '+pt_name+'\n'+\
'*END'
fp.write(strin)
fp.close()

fp = open(dir2+'bv_4.cfg','w')
strin='*BEGIN TREE 1.0 siMorpho'+'\n'+\
'modelFile /usr/local/softwares/brainvisa/share/shfj-3.1/models/3.0/Rfolds_noroots_020200/Rfolds_model_noroots_2000.arg'+'\n'+\
'graphFile '+str(dir2)+'R'+pt_name+'_default_session_auto.arg'+'\n'+\
'filter_attributes label'+'\n'+\
'selection /home/jinju/bv_1779377.sel'+'\n'+\
'output_prefix '+pt_name+'_\n'+\
'labelsMapFile /usr/local/softwares/brainvisa/share/shfj-3.1/nomenclature/hierarchy/sulcal_root_colors.hie'+'\n'+\
'name_descriptors 1'+'\n'+\
'descriptor_aliases '+'fold_descriptor2 '+'fold_descriptor3 '+'\n'+\
'print_labels 1'+'\n'+\
'subjects '+pt_name+'\n'+\
'*END'
fp.write(strin)
fp.close()



print Aims1
os.system(Aims1)

print Vip1
os.system(Vip1)

print Vip2
os.system(Vip2)

print Vip3
os.system(Vip3)

print Vip4
os.system(Vip4)

print Aims2
os.system(Aims2)

print Vip5
os.system(Vip5)

print Vip6
os.system(Vip6)

print Vip7
os.system(Vip7)

print Vip8
os.system(Vip8)

print Vip9
os.system(Vip9)

print Vip10
os.system(Vip10)

print Vip11
os.system(Vip11)

print Vip12
os.system(Vip12)

print Aims3
os.system(Aims3)

print Aims4
os.system(Aims4)

print Vip13
os.system(Vip13)

print Vip14
os.system(Vip14)

print Vip15
os.system(Vip15)

print Aims5
os.system(Aims5)

print Aims6
os.system(Aims6)

print Vip16
os.system(Vip16)

print Vip17
os.system(Vip17)

print Vip18
os.system(Vip18)

print Vip19
os.system(Vip19)

print Aims7
os.system(Aims7)

print Vip20
os.system(Vip20)

print Vip21
os.system(Vip21)

print Vip22
os.system(Vip22)

print Vip23
os.system(Vip23)

print Aims8
os.system(Aims8)

print Vip24
os.system(Vip24)

print Aims9
os.system(Aims9)

print Vip25
os.system(Vip25)

print Vip26
os.system(Vip26)

print Vip27
os.system(Vip27)

print Vip28
os.system(Vip28)

print Vip29
os.system(Vip29)

print Vip30
os.system(Vip30)

print Vip31
os.system(Vip31)

print Aims10
os.system(Aims10)

print Aims11
os.system(Aims11)

print Vip32
os.system(Vip32)

print Vip33
os.system(Vip33)

print Vip34
os.system(Vip34)

print Vip35
os.system(Vip35)

print Vip36
os.system(Vip36)

print Aims12
os.system(Aims12)

print Aims13
os.system(Aims13)

print siRelaxL
os.system(siRelaxL)

print siRelaxR
os.system(siRelaxR)

print siMorphoL
os.system(siMorphoL)

print siMorphoR
os.system(siMorphoR)

'''
print RIC1 
os.system(RIC1)

print RIC2
os.system(RIC2)

print RIC3 
os.system(RIC3)

print RIC4 
os.system(RIC4)

print RIC5 
os.system(RIC5) 
'''

jinju
Posts: 20
Joined: Tue Nov 25, 2008 4:44 am

Re: How to handle lots of data in batch mode?

Post by jinju »

Hi, again
If I run the t1pipeline07 process on the server like this,

Code: Select all

brainvisa -b -c 'defaultContext().runProcess( "t1pipeline07", <parameters> )'
What should I put in parameters?
Could you tell me more in detail?
How do I manage input and output files or argument?
Nobody do like this??
Who could help me? :oops:

Jin-ju
Dominique Geffroy
Site Admin
Posts: 161
Joined: Thu Mar 01, 2007 4:22 pm
Location: IFR 49 - Neurospin, Gif-sur-Yvette, France
Contact:

Re: How to handle lots of data in batch mode?

Post by Dominique Geffroy »

Hi,

To know what are the parameters, you can run Brainvisa in normal mode (with the graphical interface) and open the process "T1 MRI/Segmentation Pipeline/T1 Pipeline 2007". The name of the parameters in the graphical interface are the same as the parameters that you can pass to the method runProcess.

However, the pipeline is composed of several process and there are a huge number of parameters. You cannot fill in all the parameters by hand. So, you have to use a brainvisa database and then you can fill in only the first parameter "mri" and all the others will be automatically filled in by Brainvisa. Except the AC/PC points which Brainvisa cannot guess, you have to fill these parameters yourself or run the process "Prepare Subject for anatomical pipeline" before runnning the pipeline, so the points will be saved in a .APC file that will be used by brainvisa during the pipeline execution.

First you need to configure your brainvisa database in brainvisa/preferences/databases menu, and import your data in the database using the process "T1 MRI/import/Import T1 MRI". You can find more details about how to do that in Brainvisa manual : http://brainvisa.info/doc/brainvisa-3.1 ... index.html

Then, to run the pipeline in batch mode, here are the step :
# find the input in the database
from neuroHierarchy import databases
from neuroProcesses import *
inputMri=databases.getDiskItemFromFileName(<fullpath of your data>)
defaultContext().runProcess("t1pipeline", mri=inputMri)

You'd better putting your script in a file and use brainvisa -b -e <script file> to run the script in batch mode.

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

Re: How to handle lots of data in batch mode?

Post by riviere »

# find the input in the database
from neuroHierarchy import databases
from neuroProcesses import *
inputMri=databases.getDiskItemFromFileName(<fullpath of your data>)
defaultContext().runProcess("t1pipeline", mri=inputMri)
Right, but you don't even need to use getDiskItemFromFileName, it will be done inside runProcess if needed. You can use for instance:

Code: Select all

defaultContext().runProcess("t1pipeline", mri="/home/pinpin/database/subjects/subject01/t1mri/default_acquisition/subject01.nii")
and specify other parameters if needed (or if you wish) using filenames.
Denis
jinju
Posts: 20
Joined: Tue Nov 25, 2008 4:44 am

Re: How to handle lots of data in batch mode?

Post by jinju »

Hi,
Thank you sooooooo much!
By the way, could you modify that?
defaultContext().runProcess("ImportT1MRI", input="/home/jinju/t1_icbm.mnc", output = How to write protocol, subject??)
defaultContext().runProcess("preparesubject", T1mri="/home/jinju/DB/test/ddd/ddd/t1mri/default_acquisition/ddd.ima", Commissure_coordinates="/home/jinju/DB/test/ddd/ddd/t1mri/default_acquisition/ddd.ddd", Normalised="MNI from Mritotal")

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

Re: How to handle lots of data in batch mode?

Post by Yann Cointepas »

Code: Select all

defaultContext().runProcess("ImportT1MRI", input="/home/jinju/t1_icbm.mnc", output = { 'protocol': 'a protocol', 'subject': 'a subject', 'acquisition': 'default_acquisition' } )
Or you may prefer the following syntax:

Code: Select all

defaultContext().runProcess("ImportT1MRI", input="/home/jinju/t1_icbm.mnc", output =dict( protocol='a protocol', subject='a subject', acquisition='default_acquisition' ) )
In this case acquisition attribute is not mandatory. You can just use the attributes values you would enter in the database graphical selection tool.
Post Reply