@@ -420,11 +420,11 @@ def mkdir_p(path):
420420 else :
421421 raise
422422
423- def getdefaultconfig ():
423+ def getdefaultconfig (exitonfail = False ):
424424 config = { 'custom_atlas' : None ,
425425 'cw256' : False ,
426426 'field_strength' : '1.5T' ,
427- 'fs_home' : checkenv (),
427+ 'fs_home' : checkenv (exitonfail ),
428428 'longitudinal' : False ,
429429 'long_base' : None ,
430430 'openmp' : None ,
@@ -463,31 +463,35 @@ def getdefaultconfig():
463463 return config
464464
465465
466- def checkenv ():
467- import sys
466+ def checkenv (exitonfail = False ):
468467 """Check for the necessary FS environment variables"""
468+ import sys
469469 fs_home = os .environ .get ('FREESURFER_HOME' )
470470 path = os .environ .get ('PATH' )
471471 print ("FREESURFER_HOME: {0}" .format (fs_home ))
472472 if fs_home == None :
473- print ( "ERROR: please set FREESURFER_HOME before running the workflow")
473+ msg = " please set FREESURFER_HOME before running the workflow"
474474 elif not os .path .isdir (fs_home ):
475- print ("ERROR: FREESURFER_HOME must be set to a valid directory before " +
476- "running this workflow" )
475+ msg = "FREESURFER_HOME must be set to a valid directory before running this workflow"
477476 elif os .path .join (fs_home , 'bin' ) not in path .replace ('//' ,'/' ):
478477 print (path )
479- print ( "ERROR: Could not find necessary executable in path")
478+ msg = " Could not find necessary executable in path"
480479 setupscript = os .path .join (fs_home , 'SetUpFreeSurfer.sh' )
481480 if os .path .isfile (setupscript ):
482481 print ("Please source the setup script before running the workflow:" +
483- "\n source {0}" .format (setupscript ))
482+ "\n source {0}" .format (setupscript ))
484483 else :
485484 print ("Please ensure that FREESURFER_HOME is set to a valid fs " +
486485 "directory and source the necessary SetUpFreeSurfer.sh script before running " +
487486 "this workflow" )
488487 else :
489488 return fs_home
490- sys .exit (2 )
489+
490+ if exitonfail :
491+ print ("ERROR: " + msg )
492+ sys .exit (2 )
493+ else :
494+ print ("Warning: " + msg )
491495
492496def center_volume (in_file ):
493497 import SimpleITK as sitk
0 commit comments