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

BF: Need to read these parameters from file, before getting the data. #615

Merged
merged 3 commits into from
Dec 11, 2020
Merged
Changes from 2 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
17 changes: 15 additions & 2 deletions AFQ/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ def _dki_md(self, row):
def _dki_awf(self, row, sphere='repulsion100', gtol=1e-2):
dki_awf_file = self._get_fname(row, '_model-DKI_AWF.nii.gz')
if not op.exists(dki_awf_file):
dki_params = self._dki(row).get_fdata()
dki_params = nib.load(self._dki(row)).get_fdata()
awf = axonal_water_fraction(dki_params, sphere=sphere, gtol=gtol)
nib.save(nib.Nifti1Image(awf, row['dwi_affine']),
dki_awf_file)
Expand All @@ -907,12 +907,25 @@ def _dki_awf(self, row, sphere='repulsion100', gtol=1e-2):
afd.write_json(meta_fname, meta)
return dki_awf_file

def _dki_mk(self, row):
dki_mk_file = self._get_fname(row, '_model-DKI_MK.nii.gz')
if not op.exists(dki_mk_file):
tf = self._dki_fit(row)
mk = tf.mk()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that mk is indeed a standard method of the object, and not an attribute (in contrast to fa and md)

nib.save(nib.Nifti1Image(mk, row['dwi_affine']),
dki_mk_file)
meta_fname = self._get_fname(row, '_model-DKI_MK.json')
meta = dict()
afd.write_json(meta_fname, meta)
return dki_mk_file

# Keep track of functions that compute scalars:
_scalar_dict = {"dti_fa": _dti_fa,
"dti_md": _dti_md,
"dki_fa": _dki_fa,
"dki_md": _dki_md,
"dki_awf": _dki_awf}
"dki_awf": _dki_awf,
"dki_mk": _dki_mk}

def _get_best_scalar(self):
for scalar in self.scalars:
Expand Down