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

Completing IDP generation scripts

parent 56ea4d0d
No related branches found
No related tags found
No related merge requests found
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
...@@ -28,7 +28,8 @@ from bip.pipelines.IDPs_gen import IDP_func_TSNR ...@@ -28,7 +28,8 @@ from bip.pipelines.IDPs_gen import IDP_func_TSNR
from bip.pipelines.IDPs_gen import IDP_func_task_activation from bip.pipelines.IDPs_gen import IDP_func_task_activation
from bip.pipelines.IDPs_gen import IDP_diff_eddy_outliers from bip.pipelines.IDPs_gen import IDP_diff_eddy_outliers
from bip.pipelines.IDPs_gen import IDP_diff_TBSS from bip.pipelines.IDPs_gen import IDP_diff_TBSS
from bip.pipelines.IDPs_gen import IDP_diff_autoPtx #from bip.pipelines.IDPs_gen import IDP_diff_autoPtx
from bip.pipelines.IDPs_gen import IDPs_generator
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -109,10 +110,10 @@ def add_to_pipeline(ctx, pipe, tree, targets): ...@@ -109,10 +110,10 @@ def add_to_pipeline(ctx, pipe, tree, targets):
kwargs={'ctx' : ctx}) kwargs={'ctx' : ctx})
targets.append('IDP_diff_TBSS') targets.append('IDP_diff_TBSS')
pipe(IDP_diff_autoPtx.run, #pipe(IDP_diff_autoPtx.run,
submit=dict(jobtime=200, name="BIP_IDP_diff_autoPtx_"+ subj), # submit=dict(jobtime=200, name="BIP_IDP_diff_autoPtx_"+ subj),
kwargs={'ctx' : ctx}) # kwargs={'ctx' : ctx})
targets.append('IDP_diff_autoPtx') #targets.append('IDP_diff_autoPtx')
pipe(IDP_subject_COG_table.run, pipe(IDP_subject_COG_table.run,
submit=dict(jobtime=200, name="BIP_IDP_subject_COG_table_" + subj), submit=dict(jobtime=200, name="BIP_IDP_subject_COG_table_" + subj),
...@@ -124,4 +125,9 @@ def add_to_pipeline(ctx, pipe, tree, targets): ...@@ -124,4 +125,9 @@ def add_to_pipeline(ctx, pipe, tree, targets):
kwargs={'ctx' : ctx}) kwargs={'ctx' : ctx})
targets.append('IDP_subject_centre') targets.append('IDP_subject_centre')
pipe(IDPs_generator.run,
submit=dict(jobtime=200, name="BIP_IDPs_generator_" + subj),
kwargs={'ctx' : ctx})
targets.append('IDPs')
return pipe, targets return pipe, targets
#!/usr/bin/env python
#
# IDP_diff_autoPtx.py - Generating IDP file with autoPtx 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
#
import os
import json
import logging
from pipe_tree import In, Out, Ref
from bip.utils.log_utils import redirect_logging
log = logging.getLogger(__name__)
def run(ctx,
IDP_subject_ID: In(optional=True),
IDP_T1_align_to_std: In(optional=True),
IDP_T1_noise_ratio: In(optional=True),
IDP_all_align_to_T1: In(optional=True),
IDP_func_head_motion: In(optional=True),
IDP_func_TSNR: In(optional=True),
IDP_diff_eddy_outliers: In(optional=True),
IDP_T1_SIENAX: In(optional=True),
IDP_T1_FIRST_vols: In(optional=True),
IDP_T1_GM_parcellation: In(optional=True),
IDP_T2_FLAIR_WMH: In(optional=True),
IDP_SWI_T2star: In(optional=True),
IDP_func_task_activation: In(optional=True),
IDP_diff_TBSS: In(optional=True),
IDP_diff_autoPtx: In(optional=True),
IDP_subject_COG_table: In(optional=True),
IDP_subject_centre: In(optional=True),
logs_dir: Ref,
IDPs: Out):
with redirect_logging('IDPs_generator', outdir=logs_dir):
result=""
IDPs_json_file = ctx.get_data("IDPs/IDPs.json")
with open(IDPs_json_file, "r", encoding="utf-8") as f:
IDPs_dict = json.load(f)
for IDP_file in [IDP_subject_ID, IDP_T1_align_to_std,IDP_T1_noise_ratio,
IDP_all_align_to_T1, IDP_func_head_motion, IDP_func_TSNR,
IDP_diff_eddy_outliers, IDP_T1_SIENAX, IDP_T1_FIRST_vols,
IDP_T1_GM_parcellation, IDP_T2_FLAIR_WMH, IDP_SWI_T2star,
IDP_func_task_activation, IDP_diff_TBSS, IDP_diff_autoPtx,
IDP_subject_COG_table, IDP_subject_centre]:
plain_name = os.path.basename(IDP_file).replace(".txt", "")
num_IDPs = len(IDPs_dict[plain_name])
result_nans = ("NaN " * num_IDPs).strip()
if os.path.exists(IDP_file):
with open(IDP_file, "r", encoding="utf-8") as f:
IDPs = f.read().strip().split()
if len(IDPs) != num_IDPs:
result += " " + result_nans
else:
result += " " + " ".join(IDPs)
else:
result += " " + result_nans
result = result.replace(" ", " ").strip()
with open(IDP_diff_autoPtx, '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