diff --git a/bip/data/FileTree.tree b/bip/data/FileTree.tree index 57aa223b92cf152f659fa663a7c01fa20cbb0894..eef4f50caf9fbe76977f8829bcba94d084ff4b97 100644 --- a/bip/data/FileTree.tree +++ b/bip/data/FileTree.tree @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3691c74c7e48e228306c84723a8cecc4fca4edf3b89d16849cb2ee9c7f70fb2b -size 19899 +oid sha256:4844a5198e3f2e2dd961155a232d6538aa414b2e8eefdb84b6f57b52bf4607ee +size 19916 diff --git a/bip/ext_wrappers/freesurfer.py b/bip/ext_wrappers/freesurfer.py index ad636b2cd87a0ab63ba8b647bb56dd8b52c4df03..8cfb1a883ad638cb3d70eb7c53106c01ddd63f8f 100644 --- a/bip/ext_wrappers/freesurfer.py +++ b/bip/ext_wrappers/freesurfer.py @@ -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 diff --git a/bip/pipelines/struct_FS/FS_proc.py b/bip/pipelines/struct_FS/FS_proc.py index 9c048d1501167371610ccc87c4117e4276ce8f07..6a654e99d77b95acdf5d3086ecf860631e37b996 100755 --- a/bip/pipelines/struct_FS/FS_proc.py +++ b/bip/pipelines/struct_FS/FS_proc.py @@ -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)