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

[ENH] Add mrds scripts part 3 #1046

Merged
merged 14 commits into from
Nov 13, 2024
8 changes: 4 additions & 4 deletions scilpy/tractanalysis/mrds_along_streamlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def mrds_metrics_along_streamlines(sft, mrds_pdds,
metrics, max_theta,
length_weighting):
"""
Compute mean map for a given lobe-specific metric along streamlines.
Compute mean map for a given fixel-specific metric along streamlines.

Parameters
----------
Expand All @@ -34,7 +34,7 @@ def mrds_metrics_along_streamlines(sft, mrds_pdds,

all_metric = mrds_sum[0]
for curr_metric in mrds_sum[1:]:
all_metric += curr_metric
all_metric += np.abs(curr_metric)

non_zeros = np.nonzero(all_metric)
weights_nz = weights[non_zeros]
Expand All @@ -56,7 +56,7 @@ def mrds_metric_sums_along_streamlines(sft, mrds_pdds, metrics,
mrds_pdds : ndarray (X, Y, Z, 3*N_TENSORS)
MRDS principal diffusion directions (PDDs) of the tensors
metrics : list of ndarray (X, Y, Z, N_TENSORS)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think metrics should be metric

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I aggree it's "a" list but reading it I feel like metrics make sense here.

The fixel-specific metric of interest.
Fixel-specific metrics.
max_theta : float
Maximum angle in degrees between the fiber direction and the
MRDS principal diffusion direction.
Expand All @@ -66,7 +66,7 @@ def mrds_metric_sums_along_streamlines(sft, mrds_pdds, metrics,
Returns
-------
metric_sum_map : np.array
fixel-specific metric sum map.
fixel-specific metrics sum map.
weight_map : np.array
Segment lengths.
"""
Expand Down
24 changes: 13 additions & 11 deletions scripts/scil_bundle_mean_fixel_mrds_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
diffusivity (fixel-MD), radial diffusivity (fixel-RD) and
axial diffusivity (fixel-AD).

Fixel-specific metrics are metrics extracted from Bingham distributions fitted
to fODF. Their are as many values per voxel as there are lobes extracted. The
Fixel-specific metrics are metrics extracted from
Multi-Resolution Discrete-Search (MRDS) solutions.
There are as many values per voxel as there are fixels extracted. The
values chosen for a given voxel is the one belonging to the lobe better aligned
with the current streamline segment.

Output metrics will be name: [prefix]_mrds_f[metric_name].nii.gz
Input files come from scil_mrds_metrics.py command.

Output metrics will be name: [prefix]_mrds_[metric_name].nii.gz
arnaudbore marked this conversation as resolved.
Show resolved Hide resolved

arnaudbore marked this conversation as resolved.
Show resolved Hide resolved
Please use a bundle file rather than a whole tractogram.
"""
Expand Down Expand Up @@ -63,7 +66,7 @@ def _build_arg_parser():
'segment lengths. [%(default)s]')

p.add_argument('--max_theta', default=60, type=float,
help='Maximum angle (in degrees) condition on lobe '
help='Maximum angle (in degrees) condition on fixel '
'alignment. [%(default)s]')

add_reference_arg(p)
Expand All @@ -80,15 +83,15 @@ def main():
if args.fa is not None:
in_metrics.append(args.fa)
out_metrics.append('{}_mrds_fFA.nii.gz'.format(args.prefix))
if args.md is not None:
in_metrics.append(args.md)
out_metrics.append('{}_mrds_fMD.nii.gz'.format(args.prefix))
if args.rd is not None:
in_metrics.append(args.rd)
out_metrics.append('{}_mrds_fRD.nii.gz'.format(args.prefix))
if args.ad is not None:
in_metrics.append(args.ad)
out_metrics.append('{}_mrds_fAD.nii.gz'.format(args.prefix))
if args.rd is not None:
in_metrics.append(args.rd)
out_metrics.append('{}_mrds_fRD.nii.gz'.format(args.prefix))
if args.md is not None:
in_metrics.append(args.md)
out_metrics.append('{}_mrds_fMD.nii.gz'.format(args.prefix))

if in_metrics == []:
parser.error('At least one metric is required.')
Expand All @@ -114,7 +117,6 @@ def main():
args.length_weighting)

for metric_id, curr_metric in enumerate(fixel_metrics):

nib.Nifti1Image(curr_metric.astype(np.float32),
affine=affine,
header=header,
Expand Down