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

Correcting syntax in IDP scripts

parent 9a5a217f
No related branches found
No related tags found
No related merge requests found
Showing
with 65 additions and 70 deletions
......@@ -7,10 +7,10 @@
# Author: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
#
# pylint: disable=C0103,E0602,C0114,C0115,C0116,R0913,R0914,R0915
# pylint: disable=W0613
#
import os
import json
import logging
from fsl import wrappers
from pipe_tree import In, Out, Ref
......@@ -20,10 +20,10 @@ log = logging.getLogger(__name__)
def run(ctx,
T2star_to_T1: In,
T1_first_all_fast_firstseg: In(optional=True),
T1_first_all_fast_firstseg: In(optional=True),
logs_dir: Ref,
IDP_SWI_T2star: Out):
with redirect_logging('IDP_SWI_T2star', outdir=logs_dir):
result = ("NaN " * 14).strip()
......@@ -39,4 +39,4 @@ def run(ctx,
result = " ".join(result)
with open(IDP_SWI_T2star, 'wt', encoding="utf-8") as f:
f.write(f'{result}\n')
\ No newline at end of file
f.write(f'{result}\n')
......@@ -7,10 +7,10 @@
# Author: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
#
# pylint: disable=C0103,E0602,C0114,C0115,C0116,R0913,R0914,R0915
# pylint: disable=W0613
#
import os
import json
import logging
from fsl import wrappers
from pipe_tree import In, Out, Ref
......@@ -22,7 +22,7 @@ def run(ctx,
T1_first_all_fast_firstseg: In(optional=True),
logs_dir: Ref,
IDP_T1_FIRST_vols: Out):
with redirect_logging('IDP_T1_FIRST_vols', outdir=logs_dir):
result = ("NaN " * 15).strip()
......
......@@ -9,8 +9,6 @@
# pylint: disable=C0103,E0602,C0114,C0115,C0116,R0913,R0914,R0915
#
import os
import json
import logging
from fsl import wrappers
from pipe_tree import In, Out, Ref
......@@ -25,14 +23,14 @@ def run(ctx,
tmp_dir: Ref,
logs_dir: Ref,
IDP_T1_GM_parcellation: Out):
with redirect_logging('IDP_T1_GM_parcellation', outdir=logs_dir),\
tempdir(tmp_dir):
result = ("NaN " * 139).strip()
GMatlas_to_T1 = tmp_dir + '/GMatlas_to_T1.nii.gz'
GMatlas = ctx.get_data("IDPs/GMatlas/GMatlas.nii.gz")
wrappers.applywarp(src=GMatlas, ref=T1, w=T1_to_MNI_warp_coef_inv,
out=GMatlas_to_T1, interp='nn')
......
......@@ -7,11 +7,12 @@
# Author: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
#
# pylint: disable=C0103,E0602,C0114,C0115,C0116,R0913,R0914,R0915
# pylint: disable=W0613
#
import os
import json
import logging
from shutil import copyfile
from pipe_tree import In, Out, Ref
from bip.utils.log_utils import redirect_logging
......@@ -22,7 +23,7 @@ def run(ctx,
T1_sienax_txt: Ref,
logs_dir: Ref,
IDP_T1_SIENAX: Out):
with redirect_logging('IDP_T1_SIENAX', outdir=logs_dir):
result = ("NaN " * 11).strip()
......
......@@ -9,7 +9,6 @@
# pylint: disable=C0103,E0602,C0114,C0115,C0116,R0913,R0914,R0915
#
import os
import logging
from fsl import wrappers
from pipe_tree import In, Out, Ref
......@@ -25,25 +24,25 @@ def run(ctx,
tmp_dir: Ref,
logs_dir: Ref,
IDP_T1_align_to_std: Out):
with redirect_logging('IDP_T1_align_to_std', outdir=logs_dir),\
tempdir(tmp_dir):
tmp_jac = tmp_dir + '/tmpjac.nii.gz'
tmp_mat = tmp_dir + '/tmp_mat.mat'
tmp_mat = tmp_dir + '/tmp_mat.mat'
MC=ctx.FSLDIR + '/etc/flirtsch/measurecost1.sch'
MNI152_T1_1mm_brain = ctx.get_standard("MNI152_T1_1mm_brain.nii.gz")
MNI152_T1_1mm_brain_mask = ctx.get_standard("MNI152_T1_1mm_brain_mask.nii.gz")
costs1 = wrappers.flirt(src=T1_brain, ref=MNI152_T1_1mm_brain,
refweight=MNI152_T1_1mm_brain_mask,
init=T1_to_MNI_linear_mat,
costs1 = wrappers.flirt(src=T1_brain, ref=MNI152_T1_1mm_brain,
refweight=MNI152_T1_1mm_brain_mask,
init=T1_to_MNI_linear_mat,
schedule=MC, omat=tmp_mat).stdout[0].strip()
val1 = costs1.split()[0]
costs2 = wrappers.flirt(src=T1_brain_to_MNI, ref=MNI152_T1_1mm_brain,
refweight=MNI152_T1_1mm_brain_mask,
costs2 = wrappers.flirt(src=T1_brain_to_MNI, ref=MNI152_T1_1mm_brain,
refweight=MNI152_T1_1mm_brain_mask,
schedule=MC, omat=tmp_mat).stdout[0].strip()
val2 = costs2.split()[0]
......
......@@ -7,10 +7,9 @@
# Author: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
#
# pylint: disable=C0103,E0602,C0114,C0115,C0116,R0913,R0914,R0915
# pylint: disable=W0613
#
import os
import json
import logging
from fsl import wrappers
from pipe_tree import In, Out, Ref
......@@ -24,7 +23,7 @@ def run(ctx,
tmp_dir: Ref,
logs_dir: Ref,
IDP_T1_noise_ratio: Out):
with redirect_logging('IDP_T1_noise_ratio', outdir=logs_dir),\
tempdir(tmp_dir):
......
......@@ -7,10 +7,9 @@
# Author: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
#
# pylint: disable=C0103,E0602,C0114,C0115,C0116,R0913,R0914,R0915
# pylint: disable=W0613
#
import os
import json
import logging
from shutil import copyfile
from pipe_tree import In, Out, Ref
......@@ -22,6 +21,6 @@ def run(ctx,
T2_FLAIR_bianca_volume: In,
logs_dir: Ref,
IDP_T2_FLAIR_WMH: Out):
with redirect_logging('IDP_T2_FLAIR_WMH', outdir=logs_dir):
copyfile(src=T2_FLAIR_bianca_volume, dst=IDP_T2_FLAIR_WMH)
......@@ -32,18 +32,18 @@ def run(ctx,
with redirect_logging('IDP_all_align_to_T1', outdir=logs_dir),\
tempdir(tmp_dir):
tmp_mat = tmp_dir + '/tmp_mat.mat'
tmp_mat = tmp_dir + '/tmp_mat.mat'
result=""
MC=ctx.FSLDIR + '/etc/flirtsch/measurecost1.sch'
for file_name in [T2_FLAIR_brain, fieldmap_iout_to_T1, SWI_to_T1,
for file_name in [T2_FLAIR_brain, fieldmap_iout_to_T1, SWI_to_T1,
rfMRI_example_func2highres,tfMRI_example_func2highres]:
if os.path.exists(file_name):
costs1 = wrappers.flirt(src=file_name, ref=T1_brain,
refweight=T1_brain_mask, schedule=MC,
costs1 = wrappers.flirt(src=file_name, ref=T1_brain,
refweight=T1_brain_mask, schedule=MC,
omat=tmp_mat).stdout[0].strip()
result += " " + str(costs1.split()[0])
else:
......
#!/usr/bin/env python
#
# IDP_diff_TBSS.py - Generating IDP file with TBSS metrics
# IDP_diff_TBSS.py - Generating IDP file with TBSS metrics
#
# Author: Fidel Alfaro Almagro <fidel.alfaroalmagro@ndcn.ox.ac.uk>
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
# Author: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
#
# pylint: disable=C0103,E0602,C0114,C0115,C0116,R0913,R0914,R0915
# pylint: disable=W0613
#
import os
import json
import logging
from pipe_tree import In, Out, Ref
from bip.utils.log_utils import redirect_logging
......@@ -22,7 +22,7 @@ def run(ctx,
logs_dir: Ref,
JHUrois_prefix: Ref,
IDP_diff_TBSS: Out):
with redirect_logging('IDP_diff_TBSS', outdir=logs_dir):
nan_result = ("NaN " * 48).strip()
......@@ -34,7 +34,7 @@ def run(ctx,
file_name = JHUrois_prefix + mod + ".txt"
print(file_name)
if os.path.exists(file_name):
with open(file_name, "r") as f:
with open(file_name, "r", encoding="utf-8") as f:
mini_result = f.read()
mini_result = mini_result.replace("\n", " ")
mini_result = mini_result.replace(" ", " ")
......
......@@ -7,13 +7,14 @@
# Author: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
#
# pylint: disable=C0103,E0602,C0114,C0115,C0116,R0913,R0914,R0915
# pylint: disable=W0613
#
import os
import logging
import nibabel as nib
from fsl import wrappers
from pipe_tree import In, Out, Ref, Var
from pipe_tree import In, Out, Ref
from bip.utils.log_utils import redirect_logging, tempdir
log = logging.getLogger(__name__)
......
#!/usr/bin/env python
#
# IDP_diff_eddy_outliers.py - Generating IDP file with eddy outliers metrics
# IDP_diff_eddy_outliers.py - Generating IDP file with eddy outliers metrics
#
# Author: Fidel Alfaro Almagro <fidel.alfaroalmagro@ndcn.ox.ac.uk>
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
# Author: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
#
# pylint: disable=C0103,E0602,C0114,C0115,C0116,R0913,R0914,R0915
# pylint: disable=W0613
#
import os
import json
import logging
from pipe_tree import In, Out, Ref
from bip.utils.log_utils import redirect_logging
......@@ -21,7 +21,7 @@ def run(ctx,
eddy_outlier_report: In(optional=True),
logs_dir: Ref,
IDP_diff_eddy_outliers: Out):
with redirect_logging('IDP_diff_eddy_outliers', outdir=logs_dir):
num_outliers = 0
......
......@@ -7,10 +7,10 @@
# Author: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
#
# pylint: disable=C0103,E0602,C0114,C0115,C0116,R0913,R0914,R0915
# pylint: disable=W0613
#
import os
import json
import logging
from fsl import wrappers
from pipe_tree import In, Out, Ref
......@@ -25,7 +25,7 @@ def run(ctx,
logs_dir: Ref,
tmp_dir: Ref,
IDP_func_TSNR: Out):
with redirect_logging('IDP_func_TSNR', outdir=logs_dir),\
tempdir(tmp_dir):
......
......@@ -7,6 +7,7 @@
# Author: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
#
# pylint: disable=C0103,E0602,C0114,C0115,C0116,R0913,R0914,R0915
# pylint: disable=W0613
#
import os
......@@ -22,9 +23,8 @@ def run(ctx,
tfMRI_mc_rel_mean: In(optional=True),
logs_dir: Ref,
IDP_func_head_motion: Out):
with redirect_logging('IDP_func_head_motion', outdir=logs_dir):
result=""
if os.path.exists(rfMRI_mc_rel_mean):
with open(rfMRI_mc_rel_mean, "r", encoding="utf-8") as f:
......
......@@ -10,7 +10,6 @@
#
import os
import json
import shutil
import logging
from fsl import wrappers
......@@ -41,10 +40,10 @@ def run(ctx,
tfMRI_featquery_5_report: Out,
tfMRI_featquery_5a_report: Out,
IDP_func_task_activation: Out):
with redirect_logging('IDP_func_task_activation', outdir=logs_dir):
if not os.path.exists(highres2standard_warp):
os.symlink(src=os.getcwd() + "/" + T1_to_MNI_warp,
os.symlink(src=os.getcwd() + "/" + T1_to_MNI_warp,
dst=highres2standard_warp)
if not os.path.exists(highres2standard_warp_inv):
......@@ -77,27 +76,27 @@ def run(ctx,
N_tfMRI_featquery_5a_dir = tfMRI_featquery_5a_dir.replace(tfMRI_feat,"")
wrappers.featquery(N_featdirs="1", featdir1=tfMRI_feat, N_stats="2",
stats1=[N_tfMRI_cope1, N_tfMRI_zstat1],
outputRootName=N_tfMRI_featquery_1_dir,
wrappers.featquery(N_featdirs="1", featdir1=tfMRI_feat, N_stats="2",
stats1=[N_tfMRI_cope1, N_tfMRI_zstat1],
outputRootName=N_tfMRI_featquery_1_dir,
mask=group_mask_1)
wrappers.featquery(N_featdirs="1", featdir1=tfMRI_feat, N_stats="2",
stats1=[N_tfMRI_cope2, N_tfMRI_zstat2],
outputRootName=N_tfMRI_featquery_2_dir,
wrappers.featquery(N_featdirs="1", featdir1=tfMRI_feat, N_stats="2",
stats1=[N_tfMRI_cope2, N_tfMRI_zstat2],
outputRootName=N_tfMRI_featquery_2_dir,
mask=group_mask_2)
wrappers.featquery(N_featdirs="1", featdir1=tfMRI_feat, N_stats="2",
stats1=[N_tfMRI_cope5, N_tfMRI_zstat5],
outputRootName=N_tfMRI_featquery_5_dir,
wrappers.featquery(N_featdirs="1", featdir1=tfMRI_feat, N_stats="2",
stats1=[N_tfMRI_cope5, N_tfMRI_zstat5],
outputRootName=N_tfMRI_featquery_5_dir,
mask=group_mask_5)
wrappers.featquery(N_featdirs="1", featdir1=tfMRI_feat, N_stats="2",
stats1=[N_tfMRI_cope5, N_tfMRI_zstat5],
outputRootName=N_tfMRI_featquery_5a_dir,
wrappers.featquery(N_featdirs="1", featdir1=tfMRI_feat, N_stats="2",
stats1=[N_tfMRI_cope5, N_tfMRI_zstat5],
outputRootName=N_tfMRI_featquery_5a_dir,
mask=group_mask_5a)
result=""
result=""
for file_name in [tfMRI_featquery_1_report, tfMRI_featquery_2_report,
tfMRI_featquery_5_report, tfMRI_featquery_5a_report]:
tfMRI_featquery_5_report, tfMRI_featquery_5a_report]:
with open(file_name, "r", encoding="utf-8") as f:
report = f.readlines()
......
......@@ -7,10 +7,10 @@
# Author: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
#
# pylint: disable=C0103,E0602,C0114,C0115,C0116,R0913,R0914,R0915
# pylint: disable=W0613
#
import os
import json
import logging
from pipe_tree import In, Out, Ref
from bip.utils.log_utils import redirect_logging
......@@ -18,7 +18,6 @@ from bip.utils.log_utils import redirect_logging
log = logging.getLogger(__name__)
def run(ctx,
T1_orig: In,
T1_QC_COG: In,
T1_dcm_txt: In,
dMRI_dcm_txt: Ref,
......@@ -31,14 +30,13 @@ def run(ctx,
with redirect_logging('IDP_subject_COG_table', outdir=logs_dir):
result = ""
with open(T1_QC_COG, "r", encoding="utf-8") as f:
COG = f.read().strip()
table = "NaN"
table_text = "(0019, 1012) [TablePositionOrigin]"
for file_name in [T1_dcm_txt, T2_dcm_txt, rfMRI_dcm_txt, SWI_dcm_txt,
for file_name in [T1_dcm_txt, T2_dcm_txt, rfMRI_dcm_txt, SWI_dcm_txt,
dMRI_dcm_txt, tfMRI_dcm_txt]:
if os.path.exists(file_name):
......
......@@ -7,6 +7,7 @@
# Author: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
#
# pylint: disable=C0103,E0602,C0114,C0115,C0116,R0913,R0914,R0915
# pylint: disable=W0613
#
import logging
......
......@@ -18,7 +18,6 @@ from bip.utils.log_utils import redirect_logging
log = logging.getLogger(__name__)
def run(ctx,
T1_orig: In,
T1_dcm_txt: In,
dMRI_dcm_txt: Ref,
rfMRI_dcm_txt: Ref,
......@@ -27,13 +26,13 @@ def run(ctx,
tfMRI_dcm_txt: Ref,
logs_dir: Ref,
IDP_subject_centre: Out):
with redirect_logging('IDP_subject_centre', outdir=logs_dir):
line = ""
address_text = "(0008, 0081) Institution Address"
for file_name in [T1_dcm_txt, T2_dcm_txt, rfMRI_dcm_txt, SWI_dcm_txt,
for file_name in [T1_dcm_txt, T2_dcm_txt, rfMRI_dcm_txt, SWI_dcm_txt,
dMRI_dcm_txt, tfMRI_dcm_txt]:
if os.path.exists(file_name):
......
......@@ -18,7 +18,6 @@ from bip.pipelines.IDPs_gen import IDP_all_align_to_T1
from bip.pipelines.IDPs_gen import IDP_T1_FIRST_vols
from bip.pipelines.IDPs_gen import IDP_T1_SIENAX
from bip.pipelines.IDPs_gen import IDP_T1_GM_parcellation
from bip.pipelines.IDPs_gen import IDP_T1_SIENAX
from bip.pipelines.IDPs_gen import IDP_T1_align_to_std
from bip.pipelines.IDPs_gen import IDP_T1_noise_ratio
from bip.pipelines.IDPs_gen import IDP_T2_FLAIR_WMH
......@@ -37,7 +36,7 @@ def add_to_pipeline(ctx, pipe, tree, targets):
logs_dir=tree.get('logs_dir')
subj = ctx.subject
subj = ctx.subject
with redirect_logging('pipe_IDPs_gen', outdir=logs_dir):
pipe(IDP_subject_ID.run,
......
......@@ -70,5 +70,7 @@ def run(ctx,
result = result.replace(" ", " ").strip()
with open(IDP_diff_autoPtx, 'wt', encoding="utf-8") as f:
print(result)
with open(IDPs, 'wt', encoding="utf-8") as f:
f.write(f'{result}\n')
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