Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: add DKI kurtosis fit elements as scalars #865

Merged
merged 3 commits into from
Aug 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 52 additions & 3 deletions AFQ/tasks/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,54 @@ def dti_ad(dti_tf):
return dti_tf.ad


@pimms.calc(
"dki_kt0", "dki_kt1", "dki_kt2", "dki_kt3", "dki_kt4",
"dki_kt5", "dki_kt6", "dki_kt7", "dki_kt8", "dki_kt9",
"dki_kt10", "dki_kt11", "dki_kt12", "dki_kt13", "dki_kt14")
def dki_kt(dki_tf, dwi_affine):
"""
Image of first element in the DKI kurtosis model,
Image of second element in the DKI kurtosis model,
Image of third element in the DKI kurtosis model,
Image of fourth element in the DKI kurtosis model,
Image of fifth element in the DKI kurtosis model,
Image of sixth element in the DKI kurtosis model,
Image of seventh element in the DKI kurtosis model,
Image of eighth element in the DKI kurtosis model,
Image of ninth element in the DKI kurtosis model,
Image of tenth element in the DKI kurtosis model,
Image of eleventh element in the DKI kurtosis model,
Image of twelf element in the DKI kurtosis model,
Image of thirteenth element in the DKI kurtosis model,
Image of fourteenth element in the DKI kurtosis model,
Image of fifteenth element in the DKI kurtosis model
"""
dki_kt_dict = {}
for ii in range(15):
dki_kt_dict[f"dki_kt{ii}"] = nib.Nifti1Image(
dki_tf.kt[..., ii],
dwi_affine)
return dki_kt_dict


@pimms.calc("dki_lt0", "dki_lt1", "dki_lt2", "dki_lt3", "dki_lt4", "dki_lt5")
def dki_lt(dki_tf, dwi_affine):
"""
Image of first element in the DTI tensor from DKI,
Image of second element in the DTI tensor from DKI,
Image of third element in the DTI tensor from DKI,
Image of fourth element in the DTI tensor from DKI,
Image of fifth element in the DTI tensor from DKI,
Image of sixth element in the DTI tensor from DKI
"""
dki_lt_dict = {}
for ii in range(6):
dki_lt_dict[f"dki_lt{ii}"] = nib.Nifti1Image(
dki_tf.lower_triangular()[..., ii],
dwi_affine)
return dki_lt_dict


@pimms.calc("dki_fa")
@as_file('_model-DKI_FA.nii.gz')
@as_fit_deriv('DKI')
Expand Down Expand Up @@ -623,9 +671,10 @@ def get_data_plan(kwargs):
data_tasks = with_name([
get_data_gtab, b0, b0_mask, brain_mask,
dti_fit, dki_fit, anisotropic_power_map,
dti_fa, dti_lt, dti_cfa, dti_pdd, dti_md, dki_fa, dki_md, dki_awf,
dki_mk, dti_ga, dti_rd, dti_ad, dki_ga, dki_rd, dki_ad, dki_rk,
dki_ak, dti_params, dki_params, csd_params, get_bundle_dict])
dti_fa, dti_lt, dti_cfa, dti_pdd, dti_md, dki_kt, dki_lt, dki_fa,
dki_md, dki_awf, dki_mk, dti_ga, dti_rd, dti_ad, dki_ga, dki_rd,
dki_ad, dki_rk, dki_ak, dti_params, dki_params, csd_params,
get_bundle_dict])

if "scalars" not in kwargs:
kwargs["scalars"] = ["dti_fa", "dti_md"]
Expand Down