Skip to content

Commit

Permalink
Merge pull request #1127 from 36000/expose_fa_thresh_csd
Browse files Browse the repository at this point in the history
[ENH] expose FA thresh param for autoresponse ssst for csd
  • Loading branch information
36000 authored Apr 16, 2024
2 parents 39ecef2 + 4022552 commit f79b3a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 6 additions & 4 deletions AFQ/models/csd.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CsdNanResponseError(Exception):
pass


def _model(gtab, data, response=None, sh_order=None):
def _model(gtab, data, response=None, sh_order=None, csd_fa_thr=0.7):
"""
Helper function that defines a CSD model.
"""
Expand All @@ -50,7 +50,7 @@ def _model(gtab, data, response=None, sh_order=None):
response, _ = csd.auto_response_ssst(response_gtab,
data,
roi_radii=10,
fa_thr=0.7)
fa_thr=csd_fa_thr)
# Catch conditions where an auto-response could not be calculated:
if np.all(np.isnan(response[0])):
raise CsdNanResponseError
Expand All @@ -59,11 +59,13 @@ def _model(gtab, data, response=None, sh_order=None):
return csdmodel


def _fit(gtab, data, mask, response=None, sh_order=None, lambda_=1, tau=0.1):
def _fit(gtab, data, mask, response=None, sh_order=None,
lambda_=1, tau=0.1, csd_fa_thr=0.7):
"""
Helper function that does the core of fitting a model to data.
"""
return _model(gtab, data, response, sh_order).fit(data, mask=mask)
return _model(gtab, data, response, sh_order, csd_fa_thr).fit(
data, mask=mask)


def fit_csd(data_files, bval_files, bvec_files, mask=None, response=None,
Expand Down
12 changes: 9 additions & 3 deletions AFQ/tasks/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ def msdki_msk(msdki_tf):
@as_img
def csd_params(dwi, brain_mask, gtab, data,
csd_response=None, csd_sh_order=None,
csd_lambda_=1, csd_tau=0.1):
csd_lambda_=1, csd_tau=0.1,
csd_fa_thr=0.7):
"""
full path to a nifti file containing
parameters for the CSD fit
Expand Down Expand Up @@ -309,6 +310,9 @@ def csd_params(dwi, brain_mask, gtab, data,
set to tau*100 percent of the mean fODF amplitude (here, 10 percent
by default)
(see [1]_). Default: 0.1
csd_fa_thr : float, optional.
The threshold on the FA used to calculate the single shell auto
response. Can be useful to reduce for baby subjects. Default: 0.7
References
----------
Expand All @@ -324,7 +328,8 @@ def csd_params(dwi, brain_mask, gtab, data,
gtab, data,
mask=mask,
response=csd_response, sh_order=csd_sh_order,
lambda_=csd_lambda_, tau=csd_tau)
lambda_=csd_lambda_, tau=csd_tau,
csd_fa_thr=csd_fa_thr)
except CsdNanResponseError as e:
raise CsdNanResponseError(
'Could not compute CSD response function for file: '
Expand All @@ -334,7 +339,8 @@ def csd_params(dwi, brain_mask, gtab, data,
SphericalHarmonicDegree=csd_sh_order,
ResponseFunctionTensor=csd_response,
lambda_=csd_lambda_,
tau=csd_tau)
tau=csd_tau,
csd_fa_thr=csd_fa_thr)
meta["SphericalHarmonicBasis"] = "DESCOTEAUX"
meta["ModelURL"] = f"{DIPY_GH}reconst/csdeconv.py"
return csdf.shm_coeff, meta
Expand Down

0 comments on commit f79b3a7

Please sign in to comment.