Skip to content
Snippets Groups Projects
Commit 3a8bcfaf authored by Fidel Alfaro Almagro's avatar Fidel Alfaro Almagro :speech_balloon:
Browse files

Fixing a bug in the FreeSurfer call

parent 11709dc5
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -28,11 +28,11 @@ def recon_all(subjects_dir, directive, subjid, infile, FLAIR=None, **kwargs):
os.environ["SUBJECTS_DIR"] = subjects_dir
cmd = ['recon-all', "-"+directive + " -s " + subjid ]
cmd += [ " -i " + subjects_dir + "/" + infile ]
cmd = ['recon-all', "-" + directive + " -s " + subjid]
cmd += [" -i " + subjects_dir + "/" + infile]
if FLAIR:
cmd += [ " -FLAIR " + subjects_dir + "/" + FLAIR + " -FLAIRpial" ]
cmd += [" -FLAIR " + subjects_dir + "/" + FLAIR + " -FLAIRpial -debug"]
return cmd
......
......@@ -11,9 +11,11 @@
#
import os
import shutil
import logging
import subprocess
from pipe_tree import In, Out, Ref
from bip import ext_wrappers
#from bip import ext_wrappers
from bip.utils import redirect_logging
log = logging.getLogger(__name__)
......@@ -22,15 +24,31 @@ def run(ctx,
T1_unbiased: In,
T2_FLAIR_unbiased: In(optional=True),
logs_dir: Ref,
FreeSurfer_dir: Ref,
rh_entorhinal_exvivo_label: Out):
with redirect_logging('FS_proc', outdir=logs_dir):
opt_T2_FLAIR = None
if os.path.exists(FreeSurfer_dir):
shutil.rmtree(FreeSurfer_dir)
subjects_dir=os.getcwd()
os.environ["SUBJECTS_DIR"] = subjects_dir + "/" + ctx.subject
cmd = 'recon-all -all -s FreeSurfer -i ' + subjects_dir + "/" + T1_unbiased
if os.path.exists(T2_FLAIR_unbiased):
opt_T2_FLAIR = T2_FLAIR_unbiased
cmd += " -FLAIR " + subjects_dir + "/" + T2_FLAIR_unbiased + " -FLAIRpial"
try:
returned_val = subprocess.call(cmd, shell=True)
print(returned_val)
except Exception as e:
print('Command: ' + cmd)
print('Exception type: \t' + str(type(e)))
print('Exception args: \t' + str(e.args))
print('Exception message: \t' + str(e))
ext_wrappers.recon_all(subjects_dir=os.getcwd(), directive="all",
subjid="FreeSurfer", infile=T1_unbiased,
FLAIR=opt_T2_FLAIR)
print("PATATA")
#ext_wrappers.recon_all(subjects_dir=os.getcwd(),
# directive="all", subjid="FreeSurfer",
# infile=T1_unbiased, FLAIR=opt_T2_FLAIR)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment