77from shutil import rmtree
88import subprocess
99
10- def run (command , env = {}):
10+ def run (command , env = {}, ignore_errors = False ):
1111 merged_env = os .environ
1212 merged_env .update (env )
1313 # DEBUG env triggers freesurfer to produce gigabytes of files
@@ -19,7 +19,7 @@ def run(command, env={}):
1919 print (line )
2020 if line == '' and process .poll () != None :
2121 break
22- if process .returncode != 0 :
22+ if process .returncode != 0 and not ignore_errors :
2323 raise Exception ("Non zero return code: %d" % process .returncode )
2424
2525__version__ = open ('/version' ).read ()
@@ -70,11 +70,14 @@ def run(command, env={}):
7070# running participant level
7171if args .analysis_level == "participant" :
7272 if not os .path .exists (os .path .join (args .output_dir , "fsaverage" )):
73- run ("cp -rf " + os .path .join (os .environ ["SUBJECTS_DIR" ], "fsaverage" ) + " " + os .path .join (args .output_dir , "fsaverage" ))
73+ run ("cp -rf " + os .path .join (os .environ ["SUBJECTS_DIR" ], "fsaverage" ) + " " + os .path .join (args .output_dir , "fsaverage" ),
74+ ignore_errors = True )
7475 if not os .path .exists (os .path .join (args .output_dir , "lh.EC_average" )):
75- run ("cp -rf " + os .path .join (os .environ ["SUBJECTS_DIR" ], "lh.EC_average" ) + " " + os .path .join (args .output_dir , "lh.EC_average" ))
76+ run ("cp -rf " + os .path .join (os .environ ["SUBJECTS_DIR" ], "lh.EC_average" ) + " " + os .path .join (args .output_dir , "lh.EC_average" ),
77+ ignore_errors = True )
7678 if not os .path .exists (os .path .join (args .output_dir , "rh.EC_average" )):
77- run ("cp -rf " + os .path .join (os .environ ["SUBJECTS_DIR" ], "rh.EC_average" ) + " " + os .path .join (args .output_dir , "rh.EC_average" ))
79+ run ("cp -rf " + os .path .join (os .environ ["SUBJECTS_DIR" ], "rh.EC_average" ) + " " + os .path .join (args .output_dir , "rh.EC_average" ),
80+ ignore_errors = True )
7881 # find all T1s and skullstrip them
7982 for subject_label in subjects_to_analyze :
8083
0 commit comments