Skip to content

Commit

Permalink
Merge pull request #45 from shots47s/master
Browse files Browse the repository at this point in the history
Creating symbolic links for the template directories is safer than checking if directories exist while running multiple instances in same directory.
  • Loading branch information
Shawn Brown authored Feb 19, 2019
2 parents 30ee17e + f6c62e0 commit 753bd76
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from warnings import warn
import pandas as pd
import re
import errno

def run(command, env={}, ignore_errors=False):
merged_env = os.environ
Expand Down Expand Up @@ -177,15 +178,16 @@ def run(command, env={}, ignore_errors=False):

# running participant level
if args.analysis_level == "participant":
if not os.path.exists(os.path.join(output_dir, "fsaverage")):
run("cp -rf " + os.path.join(os.environ["SUBJECTS_DIR"], "fsaverage") + " " + os.path.join(output_dir, "fsaverage"),
ignore_errors=True)
if not os.path.exists(os.path.join(output_dir, "lh.EC_average")):
run("cp -rf " + os.path.join(os.environ["SUBJECTS_DIR"], "lh.EC_average") + " " + os.path.join(output_dir, "lh.EC_average"),
ignore_errors=True)
if not os.path.exists(os.path.join(output_dir, "rh.EC_average")):
run("cp -rf " + os.path.join(os.environ["SUBJECTS_DIR"], "rh.EC_average") + " " + os.path.join(output_dir, "rh.EC_average"),
ignore_errors=True)
fst_links_to_make = ["fsaverage", "lh.EC_average","rh.EC_average"]
for fst in fst_links_to_make:
try:
os.symlink(os.path.join(os.environ["SUBJECTS_DIR"], fst),os.path.join(output_dir, fst))
except OSError as e:
if e.errno == errno.EEXIST:
print("Symbolic link to {0} already exists".format(fst))
else:
print("ERROR: Symbolic link to {0} unable to be created because: {1}".format(fst,str(e)))
raise e

for subject_label in subjects_to_analyze:
if glob(os.path.join(args.bids_dir, "sub-%s" % subject_label, "ses-*")):
Expand Down

0 comments on commit 753bd76

Please sign in to comment.