Skip to content

Commit

Permalink
ENH: Modifications to address freesurfer running envirionment.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjmjohnson committed Apr 18, 2012
1 parent 1007fc1 commit cd3d052
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
9 changes: 5 additions & 4 deletions AutoWorkup/WorkupT1T2.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ def printFullPath(outFileFullPath):
## Make deformed Atlas image space
if processingLevel > 2:

many_cpu_sge_options_dictionary={'qsub_args': '-S /bin/bash -q UI -pe smp1 6-12 -l mem_free=5000M -o /dev/null -e /dev/null ', 'overwrite': True}
many_cpu_sge_options_dictionary={'qsub_args': '-S /bin/bash -q all.q -pe smp1 4-12 -l mem_free=5000M -o /dev/null -e /dev/null ', 'overwrite': True}
print("""
Run ANTS Registration at processingLevel={0}
""".format(processingLevel) )
Expand All @@ -769,7 +769,7 @@ def printFullPath(outFileFullPath):
baw200.connect( BAtlas,'template_t1', ComputeAtlasToSubjectTransform,"moving_T2_image")
baw200.connect(BLI,'outputTransformFilename',ComputeAtlasToSubjectTransform,'initialTransform')

#if processingLevel == -123:
if processingLevel == -123:
WarpAtlas = pe.Node(interface=WarpAllAtlas(), name = "19_WarpAtlas")
WarpAtlas.inputs.moving_atlas = atlas_fname_wpath
WarpAtlas.inputs.deformed_atlas = "./template_t2.nii.gz"
Expand All @@ -779,14 +779,15 @@ def printFullPath(outFileFullPath):
baw200.connect( SplitAvgBABC,'avgBABCT1', WarpAtlas, 'reference_image')


#if processingLevel > 3:
if processingLevel == -123:
if processingLevel > 3:
print("""
Run Freesurfer ReconAll at processingLevel={0}
""".format(processingLevel) )
subj_id = os.path.basename(os.path.dirname(os.path.dirname(baw200.base_dir)))
scan_id = os.path.basename(os.path.dirname(baw200.base_dir))
reconall = pe.Node(interface=ReconAll(),name="41_FS510")
freesurfer_sge_options_dictionary={'qsub_args': '-S /bin/bash -q all.q -pe smp1 1 -l mem_free=3100M -o /dev/null -e /dev/null ', 'overwrite': True}
reconall.plugin_args=freesurfer_sge_options_dictionary
reconall.inputs.subject_id = subj_id+'_'+scan_id
reconall.inputs.directive = 'all'
reconall.inputs.subjects_dir = '.'
Expand Down
19 changes: 15 additions & 4 deletions AutoWorkup/baw_exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
import sys

##############################################################################
def get_global_sge_script(pythonPathsList,binPathsList):
def get_global_sge_script(pythonPathsList,binPathsList,customEnvironment={}):
"""This is a wrapper script for running commands on an SGE cluster
so that all the python modules and commands are pathed properly"""

custEnvString=""
for key,value in customEnvironment.items():
custEnvString+=key+"="+value+"\n"

PYTHONPATH=":".join(pythonPathsList)
BASE_BUILDS=":".join(binPathsList)
GLOBAL_SGE_SCRIPT="""#!/bin/bash
Expand All @@ -25,8 +30,11 @@ def get_global_sge_script(pythonPathsList,binPathsList):
export PYTHONPATH={PYTHONPATH}
echo "With PYTHONPATH={PYTHONPATH}"
echo "With PATH={BINPATH}"
echo "With custom environment:"
echo {CUSTENV}
{CUSTENV}
## NOTE: nipype inserts the actaul commands that need running below this section.
""".format(PYTHONPATH=PYTHONPATH,BINPATH=BASE_BUILDS)
""".format(PYTHONPATH=PYTHONPATH,BINPATH=BASE_BUILDS,CUSTENV=custEnvString)
return GLOBAL_SGE_SCRIPT

def main(argv=None):
Expand Down Expand Up @@ -85,6 +93,8 @@ def main(argv=None):
# Define workup common reference data sets
ATLASPATH=expConfig.get(input_arguments.processingEnvironment,'ATLASPATH')
BCDMODELPATH=expConfig.get(input_arguments.processingEnvironment,'BCDMODELPATH')
CUSTOM_ENVIRONMENT=expConfig.get(input_arguments.processingEnvironment,'CUSTOM_ENVIRONMENT')
CUSTOM_ENVIRONMENT=eval(CUSTOM_ENVIRONMENT)

print "Configuring Pipeline"
import WorkupT1T2 ## NOTE: This needs to occur AFTER the PYTHON_AUX_PATHS has been modified
Expand All @@ -98,10 +108,11 @@ def main(argv=None):

## Create the shell wrapper script for ensuring that all jobs running on remote hosts from SGE
# have the same environment as the job submission host.
JOB_SCRIPT=get_global_sge_script(sys.path,PROGRAM_PATHS)
JOB_SCRIPT=get_global_sge_script(sys.path,PROGRAM_PATHS,CUSTOM_ENVIRONMENT)
print JOB_SCRIPT
if input_arguments.wfrun == 'helium_all.q':
baw200.run(plugin='SGE',
plugin_args=dict(template=JOB_SCRIPT,qsub_args="-S /bin/bash -q UI -pe smp1 2-4 -o /dev/null -e /dev/null "))
plugin_args=dict(template=JOB_SCRIPT,qsub_args="-S /bin/bash -q all.q -pe smp1 2-4 -o /dev/null -e /dev/null "))
elif input_arguments.wfrun == 'ipl_OSX':
baw200.run(plugin='SGE',
plugin_args=dict(template=JOB_SCRIPT,qsub_args="-S /bin/bash -q OSX -pe smp1 2-4 -o /dev/null -e /dev/null "))
Expand Down

0 comments on commit cd3d052

Please sign in to comment.