Skip to content

Commit

Permalink
BF and allow legacy change
Browse files Browse the repository at this point in the history
  • Loading branch information
36000 committed Dec 5, 2024
1 parent 07d7f3e commit 1c664e8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 1 addition & 3 deletions AFQ/tasks/tractography.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,9 @@ def fiber_odf(data_imap, tracking_params):
odf_model = tracking_params["odf_model"]
if isinstance(odf_model, str):
params_file = data_imap[f"{odf_model.lower()}_params"]
elif isinstance(odf_model, nib.Nifti1Image):
params_file = odf_model
else:
raise TypeError((
"odf_model must be a str, nibabel image, or Definition"))
"odf_model must be a string or Definition"))

return params_file

Expand Down
3 changes: 2 additions & 1 deletion AFQ/tasks/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from AFQ.utils.path import drop_extension
import os.path as op
import inspect

__all__ = ["get_fname", "with_name", "get_base_fname"]

Expand All @@ -27,6 +26,8 @@ def get_fname(base_fname, suffix,
fname = base_fname
if tracking_params is not None and 'odf_model' in tracking_params:
odf_model = tracking_params['odf_model']
if not isinstance(odf_model, str):
odf_model = odf_model.get_name()
directions = tracking_params['directions']
fname = fname + (
f'_coordsys-RASMM_trkmethod-{directions+odf_model}'
Expand Down
11 changes: 7 additions & 4 deletions AFQ/tractography/tractography.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def track(params_file, directions="prob", max_angle=30., sphere=None,
seed_mask=None, seed_threshold=0, thresholds_as_percentages=False,
n_seeds=1, random_seeds=False, rng_seed=None, stop_mask=None,
stop_threshold=0, step_size=0.5, minlen=50, maxlen=250,
odf_model="CSD", basis_type="descoteaux07", tracker="local",
trx=False):
odf_model="CSD", basis_type="descoteaux07", legacy=True,
tracker="local", trx=False):
"""
Tractography
Expand Down Expand Up @@ -97,6 +97,9 @@ def track(params_file, directions="prob", max_angle=30., sphere=None,
basis_type : str, optional
The spherical harmonic basis type used to represent the coefficients.
One of {"descoteaux07", "tournier07"}. Deafult: "descoteaux07"
legacy : bool, optional
Whether to use the legacy implementation of the direction getter.
See Dipy documentation for more details. Default: True
tracker : str, optional
Which strategy to use in tracking. This can be the standard local
tracking ("local") or Particle Filtering Tracking ([Girard2014]_).
Expand Down Expand Up @@ -155,10 +158,10 @@ def track(params_file, directions="prob", max_angle=30., sphere=None,
evals = model_params[..., :3]
evecs = model_params[..., 3:12].reshape(params_img.shape[:3] + (3, 3))
odf = tensor_odf(evals, evecs, sphere)
dg = dg.from_pmf(odf, max_angle=max_angle, sphere=sphere)
dg = dg.from_pmf(odf, max_angle=max_angle, sphere=sphere, legacy=legacy)
else:
dg = dg.from_shcoeff(model_params, max_angle=max_angle, sphere=sphere,
basis_type=basis_type, legacy=False)
basis_type=basis_type, legacy=legacy)

if tracker == "local":
if stop_mask is None:
Expand Down

0 comments on commit 1c664e8

Please sign in to comment.