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

Use only the lowest shell in calculation of the CSD response function. #1089

Merged
merged 3 commits into from
Jan 26, 2024
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
14 changes: 13 additions & 1 deletion AFQ/models/csd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
from dipy.reconst import csdeconv as csd
from dipy.reconst import mcsd
from dipy.reconst import shm
from dipy.core.gradients import gradient_table, unique_bvals_magnitude
import AFQ.utils.models as ut


# Monkey patch fixed spherical harmonics for conda from
# DIPY dev:
from AFQ._fixes import spherical_harmonics
Expand Down Expand Up @@ -37,7 +39,17 @@ def _model(gtab, data, response=None, sh_order=None):

my_model = csd.ConstrainedSphericalDeconvModel
if response is None:
response, _ = csd.auto_response_ssst(gtab, data, roi_radii=10,
unique_bvals = unique_bvals_magnitude(gtab.bvals)
if len(unique_bvals[unique_bvals > 0]) > 1:
low_shell_idx = gtab.bvals <= unique_bvals[unique_bvals > 0][0]
response_gtab = gradient_table(gtab.bvals[low_shell_idx],
gtab.bvecs[low_shell_idx])
data = data[..., low_shell_idx]
else:
response_gtab = gtab
response, _ = csd.auto_response_ssst(response_gtab,
data,
roi_radii=10,
fa_thr=0.7)
# Catch conditions where an auto-response could not be calculated:
if np.all(np.isnan(response[0])):
Expand Down
Loading