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

Adding new IDP generation scripts

parent e0f0c513
No related branches found
No related tags found
No related merge requests found
File added
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
#!/usr/bin/env python
#
# IDP_T1_GM_parcellation.py - Generating IDP file with GM parcellation 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 fsl import wrappers
from pipe_tree import In, Out, Ref
from bip.utils.log_utils import redirect_logging, tempdir
log = logging.getLogger(__name__)
def run(ctx,
T1: In,
T1_to_MNI_warp_coef_inv: In,
T1_fast_pve_1: In,
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')
wrappers.fslstats(fMRI_SNR).l(0.1).p(50).run()
vals = wrappers.fslstats(T1_brain_pve_1, K=GMatlas_to_T1).m.v.run()
result = " ".join([str(x) for x in vals[:,0] * vals[:,1]])
with open(IDP_T1_GM_parcellation, 'wt', encoding="utf-8") as f:
f.write(f'{result}\n')
......@@ -38,10 +38,7 @@ def run(ctx,
if os.path.exists(file_name):
wrappers.fslmaths(file_name).Tstd().run(fMRI_SNR)
wrappers.fslmaths(file_name).Tmean().div(fMRI_SNR).run(fMRI_SNR)
v=wrappers.fslstats(fMRI_SNR).l(0.1).p(50).run()
print(v)
v = 1/v
print(v)
v = 1 / wrappers.fslstats(fMRI_SNR).l(0.1).p(50).run()
result += f"{v} "
else:
result += "NaN "
......
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