Skip to content

Commit

Permalink
Merge pull request #44 from shots47s/master
Browse files Browse the repository at this point in the history
Added the -qcache option and fixed some formatting issues
  • Loading branch information
chrisgorgo authored Feb 18, 2019
2 parents 1d071d6 + ea22f83 commit 30ee17e
Showing 1 changed file with 49 additions and 39 deletions.
88 changes: 49 additions & 39 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def run(command, env={}, ignore_errors=False):
'(in parallel) using the same output_dir. '
'"group1" creates study specific group template. '
'"group2" exports group stats tables for cortical parcellation, subcortical segmentation '
'a table with euler numbers.',
'a table with euler numbers.',
choices=['participant', 'group1', 'group2'])
parser.add_argument('--participant_label', help='The label of the participant that should be analyzed. The label '
'corresponds to sub-<participant_label> from the BIDS spec '
Expand Down Expand Up @@ -94,7 +94,7 @@ def run(command, env={}, ignore_errors=False):
"curvind"],
default=["thickness"],
nargs="+")

parser.add_argument('--qcache', help="Enable qcache", action='store_true')
parser.add_argument('-v', '--version', action='version',
version='BIDS-App example version {}'.format(__version__))
parser.add_argument('--bids_validator_config', help='JSON file specifying configuration of '
Expand Down Expand Up @@ -170,7 +170,8 @@ def run(command, env={}, ignore_errors=False):
output_dir = os.path.abspath(args.output_dir)

if os.path.exists(args.license_file):
env = {'FS_LICENSE': args.license_file}
absPathLic = os.path.abspath(args.license_file)
env = {'FS_LICENSE': absPathLic}
else:
raise Exception("Provided license file does not exist")

Expand Down Expand Up @@ -208,10 +209,13 @@ def run(command, env={}, ignore_errors=False):
"anat",
"%s_T1w.nii*" % acq_tpl))
input_args = ""

if three_T == 'true':
input_args += " -3T"

if args.qcache:
input_args += ' -qcache'

for T1 in T1s:
if (round(max(nibabel.load(T1).header.get_zooms()), 1) < 1.0 and args.hires_mode == "auto") or args.hires_mode == "enable":
input_args += " -hires"
Expand All @@ -237,16 +241,16 @@ def run(command, env={}, ignore_errors=False):
fsid = "sub-%s_ses-%s" % (subject_label, session_label)
stages = " ".join(["-" + stage for stage in args.stages])


cmd = "recon-all -subjid %s -sd %s %s %s -openmp %d" % (fsid,
output_dir,
input_args,
stages,
args.n_cpus)
output_dir,
input_args,
stages,
args.n_cpus)
resume_cmd = "recon-all -subjid %s -sd %s %s -openmp %d" % (fsid,
output_dir,
stages,
args.n_cpus)
output_dir,
stages,
args.n_cpus)

if os.path.isfile(os.path.join(output_dir, fsid, "scripts/IsRunning.lh+rh")):
rmtree(os.path.join(output_dir, fsid))
Expand All @@ -270,10 +274,10 @@ def run(command, env={}, ignore_errors=False):
stages = " ".join(["-" + stage for stage in args.stages])

cmd = "recon-all -base %s -sd %s %s %s -openmp %d" % (fsid,
output_dir,
input_args,
stages,
args.n_cpus)
output_dir,
input_args,
stages,
args.n_cpus)

if os.path.isfile(os.path.join(output_dir, fsid, "scripts/IsRunning.lh+rh")):
rmtree(os.path.join(output_dir, fsid))
Expand All @@ -295,12 +299,12 @@ def run(command, env={}, ignore_errors=False):
# longitudinally process all timepoints
fsid = "sub-%s" % subject_label
stages = " ".join(["-" + stage for stage in args.stages])

cmd = "recon-all -long %s %s -sd %s %s -openmp %d" % (tp,
fsid,
output_dir,
stages,
args.n_cpus)
fsid,
output_dir,
stages,
args.n_cpus)

if os.path.isfile(os.path.join(output_dir, tp + ".long." + fsid, "scripts/IsRunning.lh+rh")):
rmtree(os.path.join(output_dir, tp + ".long." + fsid))
Expand All @@ -323,7 +327,10 @@ def run(command, env={}, ignore_errors=False):
input_args = ""

if three_T == 'true':
input_args += " -3T"
input_args += " -3T"

if args.qcache:
input_args += " -qcache"

for T1 in T1s:
if (round(max(nibabel.load(T1).header.get_zooms()), 1) < 1.0 and args.hires_mode == "auto") or args.hires_mode == "enable":
Expand Down Expand Up @@ -355,14 +362,14 @@ def run(command, env={}, ignore_errors=False):
stages = " ".join(["-" + stage for stage in args.stages])

cmd = "recon-all -subjid %s -sd %s %s %s -openmp %d" % (fsid,
output_dir,
input_args,
stages,
args.n_cpus)
output_dir,
input_args,
stages,
args.n_cpus)
resume_cmd = "recon-all -subjid %s -sd %s %s -openmp %d" % (fsid,
output_dir,
stages,
args.n_cpus)
output_dir,
stages,
args.n_cpus)

if os.path.isfile(os.path.join(output_dir, fsid, "scripts/IsRunning.lh+rh")):
rmtree(os.path.join(output_dir, fsid))
Expand Down Expand Up @@ -392,9 +399,12 @@ def run(command, env={}, ignore_errors=False):
continue

input_args = ""

if three_T == 'true':
input_args += " -3T"
input_args += " -3T"

if args.qcache:
input_args += " -qcache"

for T1 in T1s:
if (round(max(nibabel.load(T1).header.get_zooms()), 1) < 1.0 and args.hires_mode == "auto") or args.hires_mode == "enable":
Expand All @@ -417,16 +427,16 @@ def run(command, env={}, ignore_errors=False):

fsid = "sub-%s" % subject_label
stages = " ".join(["-" + stage for stage in args.stages])

cmd = "recon-all -subjid %s -sd %s %s %s -openmp %d" % (fsid,
output_dir,
input_args,
stages,
args.n_cpus)
output_dir,
input_args,
stages,
args.n_cpus)
resume_cmd = "recon-all -subjid %s -sd %s %s -openmp %d" % (fsid,
output_dir,
stages,
args.n_cpus)
output_dir,
stages,
args.n_cpus)

if os.path.isfile(os.path.join(output_dir, fsid, "scripts/IsRunning.lh+rh")):
rmtree(os.path.join(output_dir, fsid))
Expand Down

0 comments on commit 30ee17e

Please sign in to comment.