Skip to content
Open
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ AFQ/version.py
docs/_build
docs/build
docs/source/auto_examples/
docs/source/reference/config.rst
examples/**/*.nii.gz
examples/**/*.trk
examples/**/*.npy
Expand Down
3 changes: 3 additions & 0 deletions AFQ/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ def check_attribute(attr_name):
if attr_name[:-5] in task_modules:
return None

if attr_name in ["tracking_params", "segmentation_params"]:
return "segmentation_imap"

if attr_name in methods_sections:
return f"{methods_sections[attr_name]}_imap"

Expand Down
6 changes: 3 additions & 3 deletions AFQ/definitions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def __init__(self):
def find_path(self, bids_layout, from_path, subject, session, required=True):
pass

def str_for_toml(self):
def str_formal(self):
"""
Uses __init__ in str_for_toml to make string that will instantiate
Uses __init__ in str_formal to make string that will instantiate
itself. Assumes object will have attributes of same name as
__init__ args. This is important for reading/writing definitions
as arguments to config files.
Expand All @@ -56,7 +56,7 @@ def _arglist_to_string(args, get_attr=None):
if get_attr is not None:
arg = getattr(get_attr, arg)
if isinstance(arg, Definition):
arg = arg.str_for_toml()
arg = arg.str_formal()
elif isinstance(arg, str):
arg = f'"{arg}"'
elif isinstance(arg, list):
Expand Down
3 changes: 2 additions & 1 deletion AFQ/recognition/recognize.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ def recognize(
Default: 4
save_intermediates : str, optional
The full path to a folder into which intermediate products
are saved. Default: None, means no saving of intermediates.
are saved. If None, means no saving of intermediates.
Default: None.
cleaning_params : dict, optional
Cleaning params to pass to seg.clean_bundle. This will
override the default parameters of that method. However, this
Expand Down
51 changes: 19 additions & 32 deletions AFQ/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import numpy.testing as npt
import pandas as pd
import pytest
import toml
from dipy.io.streamline import load_tractogram
from dipy.segment.metric import mdf
from pandas.testing import assert_series_equal
Expand Down Expand Up @@ -991,41 +990,29 @@ def test_AFQ_data_waypoint():
"inclusive_labels=[1, 2]))"
)
bm_def_as_str = (
"LabelledImageFile(suffix='seg', "
"filters={'scope': 'freesurfer'}, "
'LabelledImageFile(suffix="seg", '
'filters={"scope": "freesurfer"}, '
"exclusive_labels=[0])"
)
config = dict(
BIDS_PARAMS=dict(
bids_path=bids_path,
dwi_preproc_pipeline="vistasoft",
t1_preproc_pipeline="freesurfer",
),
STRUCTURAL=dict(
brain_mask_definition=bm_def_as_str,
),
DATA=dict(bundle_info=bundle_dict_as_str),
TISSUE=dict(pve=pve_as_str),
SEGMENTATION=dict(
n_points_profile=50,
scalars=[
"dti_fa",
"dti_md",
"dti_ga",
"t1w_over_b0",
f"ImageFile('{t1_path_other}')",
f"TemplateImage('{t1_path}')",
],
),
TRACTOGRAPHY_PARAMS=tracking_params,
SEGMENTATION_PARAMS=segmentation_params,
)

config_file = op.join(tmpdir, "afq_config.toml")
with open(config_file, "w") as ff:
toml.dump(config, ff)
cmd = (
f"pyAFQ -v {op.join(vista_folder, 'sub-01_ses-01_dwi.nii.gz')}"
f" {op.join(freesurfer_folder, 'sub-01_ses-01_T1w.nii.gz')}"
f" {afq_folder}"
f" --brain_mask_definition='{bm_def_as_str}'"
f" --bundle_info='{bundle_dict_as_str}'"
f" --pve='{pve_as_str}'"
f" --n_points_profile=50"
f' --scalars=\'["dti_fa", "dti_md", "dti_ga", "t1w_over_b0", '
f'ImageFile("{t1_path_other}"), TemplateImage("{t1_path}")]\''
f" --odf_model=csd"
f" --n_seeds=2000"
f" --directions=prob"
f" --random_seeds=True"
f" --rng_seed=42"
f" --return_idx=True"
)

cmd = f"pyAFQ -v {config_file}"
completed_process = subprocess.run(cmd, shell=True, capture_output=True)
if completed_process.returncode != 0:
print(completed_process.stdout)
Expand Down
2 changes: 1 addition & 1 deletion AFQ/tests/test_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

def test_str_instantiates_mixin():
thresh_image = ThresholdedScalarImage("dti_fa", lower_bound=0.2)
thresh_image_str = thresh_image.str_for_toml()
thresh_image_str = thresh_image.str_formal()
thresh_image_from_str = eval(thresh_image_str)

npt.assert_(thresh_image.combine == thresh_image_from_str.combine)
Expand Down
11 changes: 6 additions & 5 deletions AFQ/tractography/tractography.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,19 @@ def track(
pft refers to Particle Filtering Tracking ([Girard2014]_).
Default: "prob"
max_angle : float, optional.
The maximum turning angle in each step. Default: 30
The maximum turning angle in each step.
Default: 30
sphere : str or DIPY Sphere
The discretization of the ODF. Can be a DIPY Sphere or
a string name of a DIPY Sphere.
Default: "repulsion724"
seed_mask : array, optional.
Float or binary mask describing the ROI within which we seed for
tracking.
Default to the entire volume (all ones).
tracking. If None, use the entire volume (all ones).
Default: None
seed_threshold : float, optional.
A value of the seed_mask above which tracking is seeded.
Default to 0.
Default: 0
gm_threshold : float, optional.
A value of the pve_gm_data above which we consider a voxel to be GM
for the purposes of ACT stopping criterion. Default: 0.4.
Expand Down Expand Up @@ -114,7 +115,7 @@ def track(
{"DTI", "CSD", "DKI", "GQ", "RUMBA", "MSMT_AODF", "CSD_AODF", "MSMTCSD"}.
If a Definition, we assume it is a definition of a file containing
Spherical Harmonics coefficients.
Defaults to use "CSD_AODF"
Default: "CSD_AODF"
basis_type : str, optional
The spherical harmonic basis type used to represent the coefficients.
One of {"descoteaux07", "tournier07"}. Default: "descoteaux07"
Expand Down
Loading
Loading