diff --git a/README b/README deleted file mode 100644 index cff636962d6a01cca7287f26920bcc4b558d51cd..0000000000000000000000000000000000000000 --- a/README +++ /dev/null @@ -1,12 +0,0 @@ -------------------------------------------- -BRAIN IMAGING PIPELINE -Fidel Alfaro Almagro, WIN-FMRIB -June, 2022 -------------------------------------------- -Automated tool - -Installation ------------- -If you want to install everythong that is needed from scratch, run: -```cd /path-to-lib/install_dir/ -python setup.py install``` diff --git a/__init__.py b/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/bb_pipeline/.gitignore b/bb_pipeline/.gitignore deleted file mode 100644 index e43b0f988953ae3a84b00331d0ccf5f7d51cb3cf..0000000000000000000000000000000000000000 --- a/bb_pipeline/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.DS_Store diff --git a/bb_pipeline/__init__.py b/bb_pipeline/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/bb_pipeline/bb_pipeline.py b/bb_pipeline/bb_pipeline.py deleted file mode 100755 index 8607956853374037a4bc2a664c2b3507218fd35e..0000000000000000000000000000000000000000 --- a/bb_pipeline/bb_pipeline.py +++ /dev/null @@ -1,181 +0,0 @@ -#!/usr/bin/env python - -import os -import sys -import nibabel as nib -from fsl import data -from fsl import utils -from fsl import scripts -from fsl import wrappers -from shutil import copyfile -from file_tree import FileTree -from pipe_tree import Pipeline, In, Out, Ref, Var, update_closure -#from bb_struct.bb_struct import bb_struct -from my_wrappers.standard_space_roi import standard_space_roi -from gradunwarp.core.gradient_unwarp_apply import gradient_unwarp_apply - -pipe = Pipeline() - -BB_BIN_DIR = os.environ['BB_BIN_DIR'] -FSLDIR = os.environ['FSLDIR'] -coeff = BB_BIN_DIR + '/data/bb_GDC_coeff.grad' -MNI = FSLDIR + '/data/standard/MNI152_T1_1mm' - -with open(BB_BIN_DIR + '/data/subj.txt', 'r') as f: - subjects = [x.replace('\n','') for x in f.readlines()] - -tree = FileTree.read(BB_BIN_DIR + '/data/FileTree').update(subject=subjects) - -log_conf = {'cmd': sys.stdout} -#Alternative (needs to be moved inside bb_struct, as logs_dir is not accessible here): -#script_name = os.path.splitext(os.path.basename(__file__))[0] -#log_conf = {'cmd': logs_dir + "/" + script_name + "_cmd.txt"} - -@pipe(submit=dict(logdir=Ref("logs_dir"), jobtime=200)) -def bb_struct( T1_orig: In, - T1_brain: Out, - logs_dir: Out, - T1: Out, - T1_orig_ud: Out, - T1_orig_ud_warp: Out, - T1_brain_mask: Out, - T1_orig_defaced: Out, - T1_defacing_mask: Out, - T1_unbiased: Out, - T1_unbiased_brain: Out, - T1_brain_to_MNI: Out, - T1_QC_face_mask_inside_brain_mask: Out, - transform_outputs: Out("T1*_to_*"), - fast_outputs: Out("T1_fast_*"), - first_outputs: Out("T1_first_*"), - T1_GDC: Ref, - temp_outputs: Ref("T1_tmp_*")): - - with update_closure(temp_outputs, transform_outputs, fast_outputs, - first_outputs): - - if [ coeff != '' ] : - #Calculate and apply the Gradient Distortion Unwarp - gradient_unwarp_apply(WD=T1_GDC, infile=T1_orig, outfile=T1_orig_ud, - owarp=T1_orig_ud_warp,gradcoeff=coeff, - vendor='siemens', nojac=True) - else: - pipe(copyfile, kwargs={'src': In('A'), 'dst': Out('B')}) - - #Calculate where does the brain start in the z dimension and extract the roi - head_top=int(round(float(wrappers.robustfov(T1_orig_ud).stdout[0].split()[7]))) - wrappers.fslmaths(T1_orig_ud).roi(0,-1,0,-1,head_top,170,0,1,).run(T1_tmp_1, - log=log_conf) - - #Run a (Recursive) brain extraction on the roi - wrappers.bet(T1_tmp_1, T1_tmp_1_brain, robust=True, log=log_conf) - - #Reduce the FOV of T1_orig_ud by calculating a registration - #from T1_tmp_brain to ssref and apply it to T1_orig_ud - # TODO: Once this wrapper is ready, merge it with FSL wrappers - standard_space_roi(T1_tmp_1_brain, T1, maskNONE=True, ssref = MNI + '_brain', - altinput=T1_orig_ud, d=True, log=log_conf) - - #Generate the actual affine from the orig_ud volume to the cut version - #we haveand combine it to have an affine matrix from orig_ud to MNI - wrappers.flirt(src=T1, ref=T1_orig_ud, omat=T1_to_T1_orig_ud_mat, - schedule = FSLDIR + '/etc/flirtsch/xyztrans.sch', log=log_conf) - wrappers.invxfm(inmat=T1_to_T1_orig_ud_mat, omat=T1_orig_ud_to_T1_mat, - log=log_conf) - wrappers.concatxfm(atob=T1_to_T1_orig_ud_mat, btoc=T1_orig_ud_to_std_mat, - atoc=T1_to_MNI_linear_mat, log=log_conf) - - #Non-linear registration to MNI using the previously calculated alignment - wrappers.fnirt(src = T1, ref = MNI, aff = T1_to_MNI_linear_mat, - config = BB_BIN_DIR + '/data/bb_fnirt.cnf', - refmask = BB_BIN_DIR + '/data/MNI152_T1_1mm_brain_mask_dil_GD7.nii.gz', - logout = logs_dir + '/bb_T1_to_MNI_fnirt.log', - cout = T1_to_MNI_warp_coef, fout = T1_to_MNI_warp, - jout = T1_to_MNI_warp_jac, iout = T1_tmp_3, - interp = 'spline',log=log_conf) - - #Combine all transforms (Gradient Distortion Unwarp and T1 to MNI) into one - if coeff != '' : - wrappers.convertwarp(ref=MNI, warp1=T1_orig_ud_warp, - midmat=T1_orig_ud_to_T1_mat, warp2=T1_to_MNI_warp, - out=T1_orig_to_MNI_warp,log=log_conf) - else: - wrappers.convertwarp(ref=MNI, premat=T1_orig_ud_to_T1_mat, - warp1=T1_orig_ud_warp, out=T1_orig_to_MNI_warp, - log=log_conf) - - # Apply the previously generated transformation - wrappers.applywarp(src=T1_orig, ref=MNI, w=T1_orig_to_MNI_warp, - out=T1_brain_to_MNI, rel=True, interp='spline', - log=log_conf) - - #Create brain mask - wrappers.invwarp(ref=T1, warp=T1_to_MNI_warp_coef, - out=T1_to_MNI_warp_coef_inv, - log=log_conf) - wrappers.applywarp(src=MNI + '_brain_mask', ref=T1 , - w=T1_to_MNI_warp_coef_inv, out=T1_brain_mask, - rel=True, interp='trilinear', log=log_conf) - wrappers.fslmaths(T1).mul(T1_brain_mask).run(T1_brain,log=log_conf) - wrappers.fslmaths(T1_brain_to_MNI).mul(MNI + '_brain_mask').run(T1_brain_to_MNI, - log=log_conf) - - #TODO: Replace this part with proper call to fsl_deface - #Defacing T1_orig - wrappers.concatxfm(atob=T1_orig_ud_to_T1_mat, btoc=T1_to_MNI_linear_mat, - atoc=T1_tmp_mat, log=log_conf) - wrappers.concatxfm(atob=T1_tmp_mat, - btoc=BB_BIN_DIR + '/data/MNI_to_MNI_BigFoV_facemask.mat', - atoc=T1_tmp_mat, log=log_conf) - wrappers.invxfm(inmat=T1_tmp_mat, omat=T1_tmp_mat, log=log_conf) - wrappers.applyxfm(src=BB_BIN_DIR + '/data/MNI152_T1_1mm_BigFoV_facemask', - ref=T1_orig, mat=T1_tmp_mat, out=T1_defacing_mask, - log=log_conf) - wrappers.fslmaths(T1_defacing_mask).binv().mul(T1_orig).run(T1_orig_defaced, - log=log_conf) - - #Defacing T1 - wrappers.concatxfm(atob=T1_to_MNI_linear_mat, - btoc = BB_BIN_DIR + '/data/MNI_to_MNI_BigFoV_facemask.mat', - atoc = T1_tmp_mat, log=log_conf) - wrappers.invxfm(inmat=T1_tmp_mat, omat=T1_tmp_mat, log=log_conf) - wrappers.applyxfm(src=BB_BIN_DIR + '/data/MNI152_T1_1mm_BigFoV_facemask', - ref=T1, mat=T1_tmp_mat, out=T1_defacing_mask, - log=log_conf) - wrappers.fslmaths(T1_defacing_mask).binv().mul(T1).run(T1, log=log_conf) - - #Generation of QC value: Number of voxels in which - #the defacing mask goes into the brain mask - wrappers.fslmaths(T1_brain_mask).thr(0.5).bin().run(T1_tmp_4, - log=log_conf) - wrappers.fslmaths(T1_defacing_mask).thr(0.5).bin().add(T1_tmp_4).run(T1_tmp_4, - log=log_conf) - vals = wrappers.fslstats(T1_tmp_4).V.run(log=log_conf)[0] - with open(T1_QC_face_mask_inside_brain_mask, 'w') as f: - f.write(str(vals)) - - #Run fast - wrappers.fast(T1_brain, out = T1_fast_dir + '/T1_brain', b=True, - log=log_conf) - - #Binarize PVE masks - wrappers.fslmaths(T1_fast_pve_0).thr(0.5).bin().run(T1_fast_CSF_mask, - log=log_conf) - wrappers.fslmaths(T1_fast_pve_1).thr(0.5).bin().run(T1_fast_WM_mask, - log=log_conf) - wrappers.fslmaths(T1_fast_pve_2).thr(0.5).bin().run(T1_fast_GM_mask, - log=log_conf) - - #Apply bias field correction to T1 - wrappers.fslmaths(T1).div(T1_fast_brain_bias).run(T1_unbiased, - log=log_conf) - wrappers.fslmaths(T1_brain).div(T1_fast_brain_bias).run(T1_unbiased_brain, - log=log_conf) - - #Creates a link inside T1_first to T1_unbiased_brain.nii.gz - os.symlink(src="../T1_unbiased_brain.nii.gz", dst=T1_first_unbiased_brain) - - #pipe(copyfile, kwargs={'src': In('A'), 'dst': Out('B')}) - -if __name__ == "__main__": - pipe.cli(tree) diff --git a/bb_struct/.gitignore b/bb_struct/.gitignore deleted file mode 100644 index e43b0f988953ae3a84b00331d0ccf5f7d51cb3cf..0000000000000000000000000000000000000000 --- a/bb_struct/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.DS_Store diff --git a/bb_struct/__init__.py b/bb_struct/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/bb_struct/bb_struct.py b/bb_struct/bb_struct.py deleted file mode 100755 index 7fd3162a5d2e910ed4da7b50631da21c14167fc5..0000000000000000000000000000000000000000 --- a/bb_struct/bb_struct.py +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env python - -@pipe(submit=dict(logdir=Ref("logs_dir"), jobtime=200)) -def bb_struct( T1_orig: In, - T1_brain: Out, - logs_dir: Out, - T1: Out, - T1_orig_ud: Out, - T1_orig_ud_warp: Out, - T1_brain_mask: Out, - T1_orig_defaced: Out, - T1_defacing_mask: Out, - T1_unbiased: Out, - T1_unbiased_brain: Out, - T1_brain_to_MNI: Out, - T1_QC_face_mask_inside_brain_mask: Out, - transform_outputs: Out("T1*_to_*"), - fast_outputs: Out("T1_fast_*"), - first_outputs: Out("T1_first_*"), - T1_GDC: Ref, - temp_outputs: Ref("T1_tmp_*")): - - with update_closure(temp_outputs, transform_outputs, fast_outputs, - first_outputs): - - if [ coeff != '' ] : - #Calculate and apply the Gradient Distortion Unwarp - gradient_unwarp_apply(WD=T1_GDC, infile=T1_orig, outfile=T1_orig_ud, - owarp=T1_orig_ud_warp,gradcoeff=coeff, - vendor='siemens', nojac=True) - else: - pipe(copyfile, kwargs={'src': In('A'), 'dst': Out('B')}) - - #Calculate where does the brain start in the z dimension and extract the roi - head_top=int(round(float(wrappers.robustfov(T1_orig_ud).stdout[0].split()[7]))) - wrappers.fslmaths(T1_orig_ud).roi(0,-1,0,-1,head_top,170,0,1,).run(T1_tmp_1, - log=log_conf) - - #Run a (Recursive) brain extraction on the roi - wrappers.bet(T1_tmp_1, T1_tmp_1_brain, robust=True, log=log_conf) - - #Reduce the FOV of T1_orig_ud by calculating a registration - #from T1_tmp_brain to ssref and apply it to T1_orig_ud - # TODO: Once this wrapper is ready, merge it with FSL wrappers - standard_space_roi(T1_tmp_1_brain, T1, maskNONE=True, ssref = MNI + '_brain', - altinput=T1_orig_ud, d=True, log=log_conf) - - #Generate the actual affine from the orig_ud volume to the cut version - #we haveand combine it to have an affine matrix from orig_ud to MNI - wrappers.flirt(src=T1, ref=T1_orig_ud, omat=T1_to_T1_orig_ud_mat, - schedule = FSLDIR + '/etc/flirtsch/xyztrans.sch', log=log_conf) - wrappers.invxfm(inmat=T1_to_T1_orig_ud_mat, omat=T1_orig_ud_to_T1_mat, - log=log_conf) - wrappers.concatxfm(atob=T1_to_T1_orig_ud_mat, btoc=T1_orig_ud_to_std_mat, - atoc=T1_to_MNI_linear_mat, log=log_conf) - - #Non-linear registration to MNI using the previously calculated alignment - wrappers.fnirt(src = T1, ref = MNI, aff = T1_to_MNI_linear_mat, - config = BB_BIN_DIR + '/data/bb_fnirt.cnf', - refmask = BB_BIN_DIR + '/data/MNI152_T1_1mm_brain_mask_dil_GD7.nii.gz', - logout = logs_dir + '/bb_T1_to_MNI_fnirt.log', - cout = T1_to_MNI_warp_coef, fout = T1_to_MNI_warp, - jout = T1_to_MNI_warp_jac, iout = T1_tmp_3, - interp = 'spline',log=log_conf) - - #Combine all transforms (Gradient Distortion Unwarp and T1 to MNI) into one - if coeff != '' : - wrappers.convertwarp(ref=MNI, warp1=T1_orig_ud_warp, - midmat=T1_orig_ud_to_T1_mat, warp2=T1_to_MNI_warp, - out=T1_orig_to_MNI_warp,log=log_conf) - else: - wrappers.convertwarp(ref=MNI, premat=T1_orig_ud_to_T1_mat, - warp1=T1_orig_ud_warp, out=T1_orig_to_MNI_warp, - log=log_conf) - - # Apply the previously generated transformation - wrappers.applywarp(src=T1_orig, ref=MNI, w=T1_orig_to_MNI_warp, - out=T1_brain_to_MNI, rel=True, interp='spline', - log=log_conf) - - #Create brain mask - wrappers.invwarp(ref=T1, warp=T1_to_MNI_warp_coef, - out=T1_to_MNI_warp_coef_inv, - log=log_conf) - wrappers.applywarp(src=MNI + '_brain_mask', ref=T1 , - w=T1_to_MNI_warp_coef_inv, out=T1_brain_mask, - rel=True, interp='trilinear', log=log_conf) - wrappers.fslmaths(T1).mul(T1_brain_mask).run(T1_brain,log=log_conf) - wrappers.fslmaths(T1_brain_to_MNI).mul(MNI + '_brain_mask').run(T1_brain_to_MNI, - log=log_conf) - - #TODO: Replace this part with proper call to fsl_deface - #Defacing T1_orig - wrappers.concatxfm(atob=T1_orig_ud_to_T1_mat, btoc=T1_to_MNI_linear_mat, - atoc=T1_tmp_mat, log=log_conf) - wrappers.concatxfm(atob=T1_tmp_mat, - btoc=BB_BIN_DIR + '/data/MNI_to_MNI_BigFoV_facemask.mat', - atoc=T1_tmp_mat, log=log_conf) - wrappers.invxfm(inmat=T1_tmp_mat, omat=T1_tmp_mat, log=log_conf) - wrappers.applyxfm(src=BB_BIN_DIR + '/data/MNI152_T1_1mm_BigFoV_facemask', - ref=T1_orig, mat=T1_tmp_mat, out=T1_defacing_mask, - log=log_conf) - wrappers.fslmaths(T1_defacing_mask).binv().mul(T1_orig).run(T1_orig_defaced, - log=log_conf) - - #Defacing T1 - wrappers.concatxfm(atob=T1_to_MNI_linear_mat, - btoc = BB_BIN_DIR + '/data/MNI_to_MNI_BigFoV_facemask.mat', - atoc = T1_tmp_mat, log=log_conf) - wrappers.invxfm(inmat=T1_tmp_mat, omat=T1_tmp_mat, log=log_conf) - wrappers.applyxfm(src=BB_BIN_DIR + '/data/MNI152_T1_1mm_BigFoV_facemask', - ref=T1, mat=T1_tmp_mat, out=T1_defacing_mask, - log=log_conf) - wrappers.fslmaths(T1_defacing_mask).binv().mul(T1).run(T1, log=log_conf) - - #Generation of QC value: Number of voxels in which - #the defacing mask goes into the brain mask - wrappers.fslmaths(T1_brain_mask).thr(0.5).bin().run(T1_tmp_4, - log=log_conf) - wrappers.fslmaths(T1_defacing_mask).thr(0.5).bin().add(T1_tmp_4).run(T1_tmp_4, - log=log_conf) - vals = wrappers.fslstats(T1_tmp_4).V.run(log=log_conf)[0] - with open(T1_QC_face_mask_inside_brain_mask, 'w') as f: - f.write(str(vals)) - - #Run fast - wrappers.fast(T1_brain, out = T1_fast_dir + '/T1_brain', b=True, - log=log_conf) - - #Binarize PVE masks - wrappers.fslmaths(T1_fast_pve_0).thr(0.5).bin().run(T1_fast_CSF_mask, - log=log_conf) - wrappers.fslmaths(T1_fast_pve_1).thr(0.5).bin().run(T1_fast_WM_mask, - log=log_conf) - wrappers.fslmaths(T1_fast_pve_2).thr(0.5).bin().run(T1_fast_GM_mask, - log=log_conf) - - #Apply bias field correction to T1 - wrappers.fslmaths(T1).div(T1_fast_brain_bias).run(T1_unbiased, - log=log_conf) - wrappers.fslmaths(T1_brain).div(T1_fast_brain_bias).run(T1_unbiased_brain, - log=log_conf) - - #Creates a link inside T1_first to T1_unbiased_brain.nii.gz - os.symlink(src="../T1_unbiased_brain.nii.gz", dst=T1_first_unbiased_brain) - - #pipe(copyfile, kwargs={'src': In('A'), 'dst': Out('B')}) diff --git a/bb_tools/.gitignore b/bb_tools/.gitignore deleted file mode 100644 index e43b0f988953ae3a84b00331d0ccf5f7d51cb3cf..0000000000000000000000000000000000000000 --- a/bb_tools/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.DS_Store diff --git a/bb_tools/__init__.py b/bb_tools/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/bb_tools/correct_file_org.sh b/bb_tools/correct_file_org.sh deleted file mode 100644 index c3817fefef1f2c2034223af9e33c2691ed4f46ee..0000000000000000000000000000000000000000 --- a/bb_tools/correct_file_org.sh +++ /dev/null @@ -1,105 +0,0 @@ -for elem in `cat subj.txt ` ; do - cd $elem/DICOM ; - mv T2.dcm T2_FLAIR.dcm ; - mv T2.txt T2_FLAIR.txt ; - mv T2_strings.txt T2_FLAIR_strings.txt ; - cd ../.. ; -done - -for elem in `cat subj.txt ` ; do - cd $elem/raw ; - if [ -f SWI_TOTAL_MAG_notNorm.nii.gz ] ; then - mv SWI_TOTAL_MAG_notNorm.nii.gz SWI_TOTAL_MAG_notNorm_TE1.nii.gz - fi - if [ -f SWI_TOTAL_MAG_notNorm.json ] ; then - mv SWI_TOTAL_MAG_notNorm.json SWI_TOTAL_MAG_notNorm_TE1.json - fi - cd ../.. ; -done - -for elem in `cat subj.txt ` ; do - cd $elem/ - mv fMRI rfMRI; - mkdir tfMRI; - if [ -f rfMRI/tfMRI.nii.gz ] ; then - mv rfMRI/tfMRI.nii.gz tfMRI/ - fi - if [ -f rfMRI/tfMRI.json ] ; then - mv rfMRI/tfMRI.json tfMRI/ - fi - if [ -f rfMRI/tfMRI_SBREF.nii.gz ] ; then - mv rfMRI/tfMRI_SBREF.nii.gz tfMRI/ - fi - if [ -f rfMRI/tfMRI_SBREF.json ] ; then - mv rfMRI/tfMRI_SBREF.json tfMRI/ - fi - cd ../ -done - -for elem in `cat subj.txt ` ; do - cd $elem/SWI ; - if [ -f SWI_TOTAL_MAG.nii.gz ] ; then - mv SWI_TOTAL_MAG.nii.gz SWI_TOTAL_MAG_TE1.nii.gz - fi - if [ -f SWI_TOTAL_MAG.json ] ; then - mv SWI_TOTAL_MAG.json SWI_TOTAL_MAG_TE1.json - fi - if [ -f SWI_TOTAL_PHA.nii.gz ] ; then - mv SWI_TOTAL_PHA.nii.gz SWI_TOTAL_PHA_TE1.nii.gz - fi - if [ -f SWI_TOTAL_PHA.json ] ; then - mv SWI_TOTAL_PHA.json SWI_TOTAL_PHA_TE1.json - fi - cd ../.. ; -done - -for elem in `cat subj.txt` ; do - cd $elem/T1 ; - if [ -f T1.nii.gz ] ; then - mv T1.nii.gz T1_orig.nii.gz - fi - if [ -f T1.json ] ; then - mv T1.json T1_orig.json - fi - cd ../..; -done - -for elem in `cat subj.txt` ; do - cd $elem/T2_FLAIR ; - if [ -f T2_FLAIR.nii.gz ] ; then - mv T2_FLAIR.nii.gz T2_FLAIR_orig.nii.gz - fi - if [ -f T2_FLAIR.json ] ; then - mv T2_FLAIR.json T2_FLAIR_orig.json - fi - cd ../..; -done - -for elem in `cat subj.txt ` ; do - cd $elem/SWI ; - if [ -f SWI_TOTAL_MAG_TE1.nii.gz ] ; then - mv SWI_TOTAL_MAG_TE1.nii.gz SWI_TOTAL_MAG_TE1_orig.nii.gz - fi - if [ -f SWI_TOTAL_MAG_TE1.json ] ; then - mv SWI_TOTAL_MAG_TE1.json SWI_TOTAL_MAG_TE1_orig.json - fi - if [ -f SWI_TOTAL_MAG_TE2.nii.gz ] ; then - mv SWI_TOTAL_MAG_TE2.nii.gz SWI_TOTAL_MAG_TE2_orig.nii.gz - fi - if [ -f SWI_TOTAL_MAG_TE2.json ] ; then - mv SWI_TOTAL_MAG_TE2.json SWI_TOTAL_MAG_TE2_orig.json - fi - if [ -f SWI_TOTAL_PHA_TE1.nii.gz ] ; then - mv SWI_TOTAL_PHA_TE1.nii.gz SWI_TOTAL_PHA_TE1_orig.nii.gz - fi - if [ -f SWI_TOTAL_PHA_TE1.json ] ; then - mv SWI_TOTAL_PHA_TE1.json SWI_TOTAL_PHA_TE1_orig.json - fi - if [ -f SWI_TOTAL_PHA_TE2.nii.gz ] ; then - mv SWI_TOTAL_PHA_TE2.nii.gz SWI_TOTAL_PHA_TE2_orig.nii.gz - fi - if [ -f SWI_TOTAL_PHA_TE2.json ] ; then - mv SWI_TOTAL_PHA_TE2.json SWI_TOTAL_PHA_TE2_orig.json - fi - cd ../.. ; -done diff --git a/data/.gitignore b/data/.gitignore deleted file mode 100644 index 13494ec472379c0fb984df51fe7b5e2a97607214..0000000000000000000000000000000000000000 --- a/data/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -bb_GDC_*.grad -subj.txt diff --git a/data/FileTree.tree b/data/FileTree.tree deleted file mode 100644 index 32891e9c7b448891477f196159eea845365f9dc4..0000000000000000000000000000000000000000 --- a/data/FileTree.tree +++ /dev/null @@ -1,109 +0,0 @@ -subject = dummy -tissue_idx = 0,1,2 - -{subject} - logs (logs_dir) - T1 (T1_dir) - T1_orig.nii.gz (T1_orig) - T1_GDC (T1_GDC) - T1.nii.gz (T1) - T1_orig_ud.nii.gz (T1_orig_ud) - T1_orig_ud_warp.nii.gz (T1_orig_ud_warp) - T1_brain.nii.gz (T1_brain) - T1_brain_mask.nii.gz (T1_brain_mask) - T1_orig_defaced.nii.gz (T1_orig_defaced) - T1_defacing_mask.nii.gz (T1_defacing_mask) - T1_unbiased.nii.gz (T1_unbiased) - T1_unbiased_brain.nii.gz (T1_unbiased_brain) - T1_unbiased_mask.nii.gz (T1_unbiased_mask) - T1_brain_to_MNI.nii.gz (T1_brain_to_MNI) - T1_QC_face_mask_inside_brain_mask.txt (T1_QC_face_mask_inside_brain_mask) - T1_tmp_1.nii.gz (T1_tmp_1) - T1_tmp_2.nii.gz (T1_tmp_2) - T1_tmp_3.nii.gz (T1_tmp_3) - T1_tmp_4.nii.gz (T1_tmp_4) - T1_tmp.mat (T1_tmp_mat) - T1_tmp_1_brain.nii.gz (T1_tmp_1_brain) - T1_tmp_to_std.mat (T1_tmp_to_std_mat) - T1_tmp_to_std.mat (T1_orig_ud_to_std_mat) - transforms (T1_transforms_dir) - T1_to_T1_orig_ud.mat (T1_to_T1_orig_ud_mat) - T1_orig_ud_to_T1.mat (T1_orig_ud_to_T1_mat) - T1_to_MNI_linear.mat (T1_to_MNI_linear_mat) - T1_to_MNI_warp_coef.nii.gz (T1_to_MNI_warp_coef) - T1_to_MNI_warp.nii.gz (T1_to_MNI_warp) - T1_to_MNI_warp_jac.nii.gz (T1_to_MNI_warp_jac) - T1_orig_to_MNI_warp.nii.gz (T1_orig_to_MNI_warp) - T1_to_MNI_warp_coef_inv.nii.gz (T1_to_MNI_warp_coef_inv) - T1_fast (T1_fast_dir) - T1_brain_pveseg.nii.gz (T1_fast_pveseg) - T1_brain_pve_0.nii.gz (T1_fast_pve_0) - T1_brain_pve_1.nii.gz (T1_fast_pve_1) - T1_brain_pve_2.nii.gz (T1_fast_pve_2) - T1_brain_CSF_mask.nii.gz (T1_fast_CSF_mask) - T1_brain_WM_mask.nii.gz (T1_fast_WM_mask) - T1_brain_GM_mask.nii.gz (T1_fast_GM_mask) - T1_brain_bias.nii.gz (T1_fast_brain_bias) - T1_first (T1_first_dir) - T1_unbiased_brain.nii.gz (T1_first_unbiased_brain) - T2_FLAIR (T2_FLAIR_dir) - T2_FLAIR_orig.nii.gz (T2_FLAIR_orig) - dMRI (dMRI_dir) - raw (dMRI_raw_dir) - AP.nii.gz (AP) - PA.nii.gz (PA) - rfMRI (rfMRI_dir) - rfMRI.nii.gz (rfMRI) - rfMRI_SBREF.nii.gz (rfMRI_SBREF) - tfMRI (tfMRI_dir) - tfMRI.nii.gz (tfMRI) - tfMRI_SBREF.nii.gz (tfMRI_SBREF) - SWI (SWI_dir) - SWI_TOTAL_MAG_TE1_orig.nii.gz (SWI_MAG_TE1_orig) - SWI_TOTAL_MAG_TE2_orig.nii.gz (SWI_MAG_TE2_orig) - SWI_TOTAL_PHA_TE1_orig.nii.gz (SWI_PHA_TE1_orig) - SWI_TOTAL_PHA_TE2_orig.nii.gz (SWI_PHA_TE2_orig) - MAG_TE1 - SWI_3MM_UPDATED_V1.1_COILH9_ECHO1_{COIL}.nii.gz (SWI_MAG_TE1_COILS) - MAG_TE2 - SWI_3MM_UPDATED_V1.1_COILH9_ECHO2_{COIL}.nii.gz (SWI_MAG_TE2_COILS) - PHA_TE1 - SWI_3MM_UPDATED_V1.1_COILH10_ECHO1_{COIL}_PH.nii.gz (SWI_PHA_TE1_COILS) - PHA_TE2 - SWI_3MM_UPDATED_V1.1_COILH10_ECHO2_{COIL}_PH.nii.gz (SWI_PHA_TE2_COILS) - ASL (ASL_dir) - raw (ASL_raw_dir) - ASL_M0.nii.gz (ASL_M0) - ASL_M0_NORM.nii.gz (ASL_M0_NORM) - ASL_PLD_0400_control.nii.gz (ASL_PLD_0400_control) - ASL_PLD_0400_label.nii.gz (ASL_PLD_0400_label) - ASL_PLD_0800_control.nii.gz (ASL_PLD_0800_control) - ASL_PLD_0800_label.nii.gz (ASL_PLD_0800_label) - ASL_PLD_1200_control.nii.gz (ASL_PLD_1200_control) - ASL_PLD_1200_label.nii.gz (ASL_PLD_1200_label) - ASL_PLD_1600_control.nii.gz (ASL_PLD_1600_control) - ASL_PLD_1600_label.nii.gz (ASL_PLD_1600_label) - ASL_PLD_2000_control.nii.gz (ASL_PLD_2000_control) - ASL_PLD_2000_label.nii.gz (ASL_PLD_2000_label) - DICOM (DICOM_dir) - T1.txt (T1_DICOM_HEADER) - T2_FLAIR.txt (T2_FLAIR_DICOM_HEADER) - dMRI.txt (dMRI_DICOM_HEADER) - rfMRI.txt (rfMRI_DICOM_HEADER) - tfMRI.txt (tfMRI_DICOM_HEADER) - SWI.txt (SWI_DICOM_HEADER) - ASL.txt (ASL_DICOM_HEADER) - T1_strings.txt (T1_DICOM_STRINGS) - T2_FLAIR_strings.txt (T2_FLAIR_DICOM_STRINGS) - dMRI_strings.txt (dMRI_DICOM_STRINGS) - rfMRI_strings.txt (rfMRI_DICOM_STRINGS) - tfMRI_strings.txt (tfMRI_DICOM_STRINGS) - SWI_strings.txt (SWI_DICOM_STRINGS) - ASL_strings.txt (ASL_DICOM_STRINGS) - raw (raw_dir) - T1_notNorm.nii.gz (T1_NOTNORM) - T2_FLAIR_notNorm.nii.gz (T2_FLAIR_NOTNORM) - AP_SBREF.nii.gz (AP_SBREF) - PA_SBREF.nii.gz (PA_SBREF) - SWI_TOTAL_MAG_notNorm_TE1.nii.gz (SWI_MAG_TE1_NOTNORM) - SWI_TOTAL_MAG_notNorm_TE2.nii.gz (SWI_MAG_TE2_NOTNORM) diff --git a/data/MNI152_T1_1mm_BigFoV_facemask.nii.gz b/data/MNI152_T1_1mm_BigFoV_facemask.nii.gz deleted file mode 100644 index bb9db35e6608ac03902587e2023ba29c391f3855..0000000000000000000000000000000000000000 Binary files a/data/MNI152_T1_1mm_BigFoV_facemask.nii.gz and /dev/null differ diff --git a/data/MNI152_T1_1mm_brain_mask_dil_GD7.nii.gz b/data/MNI152_T1_1mm_brain_mask_dil_GD7.nii.gz deleted file mode 100644 index 9d11bde2aa02bc90230b12a87d99850d33a61b67..0000000000000000000000000000000000000000 Binary files a/data/MNI152_T1_1mm_brain_mask_dil_GD7.nii.gz and /dev/null differ diff --git a/data/MNI_to_MNI_BigFoV_facemask.mat b/data/MNI_to_MNI_BigFoV_facemask.mat deleted file mode 100644 index 063ab124ad4e2bc38530327103b6ac1bc92b266f..0000000000000000000000000000000000000000 --- a/data/MNI_to_MNI_BigFoV_facemask.mat +++ /dev/null @@ -1,4 +0,0 @@ -1 0 0 50 -0 1 0 50 -0 0 1 100 -0 0 0 1 diff --git a/data/bb_fnirt.cnf b/data/bb_fnirt.cnf deleted file mode 100644 index 940d9a199be7a40381def1720edf225230386c6e..0000000000000000000000000000000000000000 --- a/data/bb_fnirt.cnf +++ /dev/null @@ -1,46 +0,0 @@ -# name of reference image -# --ref=/usr/local/fsl/data/standard/MNI152_T1_2mm.nii.gz ---ref=MNI152_T1_2mm -# name of file with mask in reference space -# --refmask=/usr/local/fsl/data/standard/MNI152_T1_2mm_brain_mask_dil.nii.gz ---refmask=MNI152_T1_2mm_brain_mask_dil -# If =1, use implicit masking based on value in --ref image. Default =1 ---imprefm=1 -# If =1, use implicit masking based on value in --in image, Default =1 ---impinm=1 -# Value to mask out in --ref image. Default =0.0 ---imprefval=0 -# Value to mask out in --in image. Default =0.0 ---impinval=0 -# sub-sampling scheme, default 4,2,1,1 ---subsamp=4,4,2,2,1,1 -# Max # of non-linear iterations, default 5,5,5,5 ---miter=5,5,5,5,5,10 -# FWHM (in mm) of gaussian smoothing kernel for input volume, default 6,4,2,2 ---infwhm=8,6,5,4.5,3,2 -# FWHM (in mm) of gaussian smoothing kernel for ref volume, default 4,2,0,0 ---reffwhm=8,6,5,4,2,0 -# Weigth of membrane energy regularisation, default depending on --ssqlambda and --regmod switches. See user documetation. ---lambda=300,150,100,50,40,30 -# Estimate intensity-mapping if set, deafult 1 (true) ---estint=1,1,1,1,1,0 -# Apply the mask if set, default 1 (true) ---applyrefmask=1,1,1,1,1,1 -# Apply the mask if set, default 1 (true) ---applyinmask=1 -# (approximate) resolution (in mm) of warp basis in x-, y- and z-direction, default 10,10,10 ---warpres=10,10,10 -# If set (=1), lambda is weighted by current ssq, default 1 ---ssqlambda=1 -# Model for regularisation of warp-field [membrane_energy bending_energy], default bending_energy ---regmod=bending_energy -# Model for intensity-mapping [none global_linear global_non_linear local_linear global_non_linear_with_bias local_non_linear] ---intmod=global_non_linear_with_bias -# Order of poynomial for mapping intensities, default 5 ---intorder=5 -# Resolution (in mm) of bias-field modelling local intensities, default 50,50,50 ---biasres=50,50,50 -# Weight of regularisation for bias-field, default 10000 ---biaslambda=10000 -# If =1, ref image is used to calculate derivatives. Default =0 ---refderiv=0 diff --git a/data/orig_FileTree.txt b/data/orig_FileTree.txt deleted file mode 100644 index a1dcb6ec6232fcc02b4549797c23e00c3e0002fd..0000000000000000000000000000000000000000 --- a/data/orig_FileTree.txt +++ /dev/null @@ -1,98 +0,0 @@ -{subject} - T1 - T1.nii.gz (T1) - T1.json - T2_FLAIR - T2_FLAIR.nii.gz (T2) - T2_FLAIR.json - dMRI - raw - AP.nii.gz (AP) - AP.bval - AP.bvec - AP.json - PA.nii.gz (PA) - PA.bval - PA.bvec - PA.json - rfMRI - rfMRI.nii.gz (rfMRI) - rfMRI.json - rfMRI_SBREF.nii.gz (rfMRI_SBREF) - rfMRI_SBREF.json - tfMRI - tfMRI.nii.gz (tfMRI) - tfMRI.json - tfMRI_SBREF.nii.gz (tfMRI_SBREF) - tfMRI_SBREF.json - SWI - SWI_TOTAL_MAG_TE1.nii.gz (SWI_MAG_TE1) - SWI_TOTAL_MAG_TE1.json - SWI_TOTAL_MAG_TE2.nii.gz (SWI_MAG_TE2) - SWI_TOTAL_MAG_TE2.json - SWI_TOTAL_PHA_TE1.nii.gz (SWI_PHA_TE1) - SWI_TOTAL_PHA_TE1.json - SWI_TOTAL_PHA_TE2.nii.gz (SWI_PHA_TE2) - SWI_TOTAL_PHA_TE2.json - MAG_TE1 - SWI_3MM_UPDATED_V1.1_COILH9_ECHO1_{COIL_MAG_TE1}.nii.gz (SWI_MAG_TE1_COILS) - MAG_TE2 - SWI_3MM_UPDATED_V1.1_COILH9_ECHO2_{COIL_MAG_TE2}.nii.gz (SWI_MAG_TE2_COILS) - PHA_TE1 - SWI_3MM_UPDATED_V1.1_COILH10_ECHO1_{COIL_PHA_TE1}_PH.nii.gz (SWI_PHA_TE1_COILS) - PHA_TE2 - SWI_3MM_UPDATED_V1.1_COILH10_ECHO2_{COIL_PHA_TE2}_PH.nii.gz (SWI_PHA_TE2_COILS) - ASL - raw - ASL_M0.nii.gz (ASL_M0) - ASL_M0.json - ASL_M0_NORM.nii.gz (ASL_M0_NORM) - ASL_M0_NORM.json - ASL_PLD_0400_control.nii.gz (ASL_PLD_0400_control) - ASL_PLD_0400_control.json - ASL_PLD_0400_label.nii.gz (ASL_PLD_0400_label) - ASL_PLD_0400_label.json - ASL_PLD_0800_control.nii.gz (ASL_PLD_0800_control) - ASL_PLD_0800_control.json - ASL_PLD_0800_label.nii.gz (ASL_PLD_0800_label) - ASL_PLD_0800_label.json - ASL_PLD_1200_control.nii.gz (ASL_PLD_1200_control) - ASL_PLD_1200_control.json - ASL_PLD_1200_label.nii.gz (ASL_PLD_1200_label) - ASL_PLD_1200_label.json - ASL_PLD_1600_control.nii.gz (ASL_PLD_1600_control) - ASL_PLD_1600_control.json - ASL_PLD_1600_label.nii.gz (ASL_PLD_1600_label) - ASL_PLD_1600_label.json - ASL_PLD_2000_control.nii.gz (ASL_PLD_2000_control) - ASL_PLD_2000_control.json - ASL_PLD_2000_label.nii.gz (ASL_PLD_2000_label) - ASL_PLD_2000_label.json - DICOM - T1.txt (T1_DICOM_HEADER) - T2_FLAIR.txt (T2_FLAIR_DICOM_HEADER) - dMRI.txt (dMRI_DICOM_HEADER) - rfMRI.txt (rfMRI_DICOM_HEADER) - tfMRI.txt (tfMRI_DICOM_HEADER) - SWI.txt (SWI_DICOM_HEADER) - ASL.txt (ASL_DICOM_HEADER) - T1_strings.txt (T1_DICOM_STRINGS) - T2_strings.txt (T2_DICOM_STRINGS) - dMRI_strings.txt (dMRI_DICOM_STRINGS) - rfMRI_strings.txt (rfMRI_DICOM_STRINGS) - tfMRI_strings.txt (tfMRI_DICOM_STRINGS) - SWI_strings.txt (SWI_DICOM_STRINGS) - ASL_strings.txt (ASL_DICOM_STRINGS) - raw - T1_notNorm.nii.gz (T1_NOTNORM) - T1_notNorm.json - T2_FLAIR_notNorm.nii.gz (T2_FLAIR_NOTNORM) - T2_FLAIR_notNorm.json - AP_SBREF.nii.gz (AP_SBREF) - AP_SBREF.json - PA_SBREF.nii.gz (PA_SBREF) - PA_SBREF.json - SWI_TOTAL_MAG_notNorm_TE1.nii.gz (SWI_MAG_TE1_NOTNORM) - SWI_TOTAL_MAG_notNorm_TE1.json - SWI_TOTAL_MAG_notNorm_TE2.nii.gz (SWI_MAG_TE2_NOTNORM) - SWI_TOTAL_MAG_notNorm_TE2.json diff --git a/init.sh b/init.sh deleted file mode 100755 index 265fd031639454d66e51ec0905cc7c6d87a383c2..0000000000000000000000000000000000000000 --- a/init.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -export FSLDIR="$HOME/fsl" # Change according to the user's FSL installation -export BB_BIN_DIR="$HOME/BIP/" # Change according to the present folder -export PATH="$BB_BIN_DIR:$BB_BIN_DIR/data:$BB_BIN_DIR/bb_pipeline:$PATH" -export PYTHONPATH="$BB_BIN_DIR:$PYTHONPATH" diff --git a/install_dir/.gitignore b/install_dir/.gitignore deleted file mode 100644 index 9d7cbf04f28780547e37e9e1e0d6f74e5046f82a..0000000000000000000000000000000000000000 --- a/install_dir/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.DS_Store -list_*.txt diff --git a/install_dir/gradunwarp_FMRIB.tar.gz b/install_dir/gradunwarp_FMRIB.tar.gz deleted file mode 100644 index a0882a3647c74b892d73111de16a0349e4aeba0c..0000000000000000000000000000000000000000 Binary files a/install_dir/gradunwarp_FMRIB.tar.gz and /dev/null differ diff --git a/install_dir/manual_install.txt b/install_dir/manual_install.txt deleted file mode 100644 index 2dfb0308aa5d7fd8efd90ef96c4f26f52a05dde1..0000000000000000000000000000000000000000 --- a/install_dir/manual_install.txt +++ /dev/null @@ -1,27 +0,0 @@ - -# Installing FSL (with its own miniconda) -curl https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/releases/fslinstaller.py > fslinstaller.py -python ./fslinstaller.py --no_env --dest $HOME/fsl/ -export FSLDIR="$HOME/fsl" -export PATH="$FSLDIR/bin/:$PATH" -pushd $FSLDIR -git clone https://git.fmrib.ox.ac.uk/fsl/fslpy -cd fslpy -$FSLDIR/bin/pip install -e . -popd -rm -f ./fslinstaller.py - -# Creating a new python environment -$FSLDIR/bin/conda create -n ukb python=3.10 -source $FSLDIR/bin/activate ukb -pip install file-tree file-tree-fsl -pip install git+https://git.fmrib.ox.ac.uk/ndcn0236/pipe-tree.git -pip install -r $BB_BIN_DIR/install_dir/requirements.txt -pip list &> $BB_BIN_DIR/install_dir/list_`date +%Y_%m_%d`.txt - -# Install gradunwarp -tar -zxvf gradunwarp_FMRIB.tar.gz -cd gradunwarp_FMRIB -python setup.py install -cd .. -rm -rf gradunwarp_FMRIB diff --git a/install_dir/requirements.txt b/install_dir/requirements.txt deleted file mode 100644 index 82aaba22bf9a4320ff1a3e462d6366dbf7756c27..0000000000000000000000000000000000000000 --- a/install_dir/requirements.txt +++ /dev/null @@ -1,28 +0,0 @@ -oxasl -oxasl-deblur -pickle-mixin -Babel -Jinja2 -MarkupSafe -Pillow -PyWavelets -Sphinx -Theano -bottom -deprecation -jupyter-core -niicat -nose -pygam -retrying -simplegeneric -graphviz -pickleshare -ipython -seaborn -jsonschema -python-utils -zipp -urllib3 -scikit-image -scikit-learn diff --git a/install_dir/setup.py b/install_dir/setup.py deleted file mode 100644 index 9ff1a1247e6c5cd241653bf17f1290be023ed3c5..0000000000000000000000000000000000000000 --- a/install_dir/setup.py +++ /dev/null @@ -1,12 +0,0 @@ -from setuptools import setup,find_packages -with open('requirements.txt', 'rt') as f: - install_requires = [l.strip() for l in f.readlines()] - -setup(name='BIP', - version='1.0.0', - description='Brain Imaging Pipeline', - author='Fidel Alfaro Almagro', - install_requires=install_requires, - scripts=['BIP/general/BIP'], - packages=find_packages(), - include_package_data=True) diff --git a/my_wrappers/.gitignore b/my_wrappers/.gitignore deleted file mode 100644 index e43b0f988953ae3a84b00331d0ccf5f7d51cb3cf..0000000000000000000000000000000000000000 --- a/my_wrappers/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.DS_Store diff --git a/my_wrappers/__init__.py b/my_wrappers/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/my_wrappers/standard_space_roi.py b/my_wrappers/standard_space_roi.py deleted file mode 100644 index 76622b88598bc46928c2b160858c21e2e8e7c351..0000000000000000000000000000000000000000 --- a/my_wrappers/standard_space_roi.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python -# -# standard_space_roi.py - Wrapper for the standard_space_roi command. -# -# Author: Fidel Alfaro Almagro -# -"""This module provides the :func:`standard_space_roi` function, a wrapper for -the FSL `standard_space_roi`_ command. -""" - -import fsl.utils.assertions as asrt -from fsl.wrappers import wrapperutils as wutils - -@wutils.fileOrImage('input', 'maskMASK', 'roiMASK', 'ssref', 'altinput',outprefix='output') -@wutils.fslwrapper -def standard_space_roi(input, output, **kwargs): - """Wrapper for the ``standard_space_roi`` command. - - :arg maskFOV: Mask output using transformed standard space FOV (default) - :arg maskMASK: Mask output using transformed standard space mask - :arg maskNONE: Do not mask output - - :arg roiFOV: Cut down input FOV using bounding box of the transformed standard space FOV (default) - :arg roiMASK: Cut down input FOV using nonbackground bounding box of the transformed standard space mask - :arg roiNONE: Co not cut down input FOV - - :arg ssref Standard space reference image to use (default $FSLDIR/data/standard/MNI152_T1) - :arg altinput Alternative input image to apply the ROI to (instead of the one used to register to the reference) - :arg d Debug (don't delete intermediate files) - :arg b Betpremask, equivalent to: -maskMASK $FSLDIR/data/standard/MNI152_T1_2mm_brain_mask_dil -roiNONE - - Refer to the ``standard_space_roi`` command-line help for details on all arguments. - """ - asrt.assertIsNifti(input) - - valmap = { - 'maskFOV' : wutils.SHOW_IF_TRUE, - 'maskNONE' : wutils.SHOW_IF_TRUE, - 'roiFOV' : wutils.SHOW_IF_TRUE, - 'roiNONE' : wutils.SHOW_IF_TRUE, - 'd' : wutils.SHOW_IF_TRUE, - 'b' : wutils.SHOW_IF_TRUE, - } - - cmd = ['standard_space_roi', input, output] - - cmd += wutils.applyArgStyle('-', valmap=valmap, **kwargs) - - return cmd