The grid is built once from the atlas bundle and can then be applied to
any number of subject bundles, so users do not have to carry the centroid,
radial vectors and radial edges between function calls.
Parameters:
atlas_bundleStreamlines
Atlas or template bundle used to define the grid.
segment_lengthfloat, optional
Desired along-tract segment length in millimeters.
radial_lengthfloat, optional
Desired radial-bin width in millimeters.
n_segmentsint, optional
Number of along-tract segments.
n_radialint, optional
Number of radial bins. If n_segments is given without
n_radial, a single radial bin is used (1D profile).
thresholdfloat, optional
QuickBundles threshold used to estimate the atlas centroid.
use_robust_centroidbool, optional
If True, use an extended centroid that covers the bundle endpoints.
robust_method{“linear”, “spline”}, optional
Endpoint extension method used by compute_robust_centroid.
See [2] and [3]
for further details about the method.
Parameters:
model_bundleStreamlines
The atlas/template bundle used as the along-tract reference.
Must be in the same space as bundle (common/MNI space).
bundleStreamlines
The subject bundle in common space (e.g., MNI). Used for segment
assignment against the model centroids.
orig_bundleStreamlines
The same subject bundle in native/world (RAS) space. Used for
sampling the metric volume. Must correspond point-for-point to
bundle.
metricndarray
3-D scalar volume (e.g., FA) in the same voxel space as affine.
affinendarray
Voxel-to-world affine of the metric volume (as returned by
nib.load(...).affine). Used to convert orig_bundle from
world to voxel coordinates for metric interpolation.
no_disksint, optional
Number of alongtract segments/disks used for dividing bundle into
segments.
Returns:
bundle_profilendarray, shape (no_disks,)
Inverse-distance-weighted mean metric value for each disk segment.
Disks with no valid data points are set to NaN.
Calculate weights for each streamline/node in a bundle, based on a
Mahalanobis distance from the core the bundle, at that node (mean, per
default).
Parameters:
bundleStreamlines
The streamlines to weight.
n_pointsint, optional
The number of points to resample to. If the `bundle` is an array, this
input is ignored.
return_mahalanobisbool, optional
Whether to return the Mahalanobis distance instead of the weights.
statcallable, optional.
The statistic used to calculate the central tendency of streamlines in
each node. Can be one of {np.mean, np.median} or other functions
that have similar API.`
Returns:
warray of shape (n_streamlines, n_points)
Weights for each node in each streamline, calculated as its relative
inverse of the Mahalanobis distance, relative to the distribution of
coordinates at that node position across streamlines.
The collection of streamlines (possibly already resampled into an array
for each to have the same length) with which we are resampling. See
Note below about orienting the streamlines.
affinearray_like (4, 4)
The mapping from voxel coordinates to streamline points.
The voxel_to_rasmm matrix, typically from a NIFTI file.
n_points: int, optional
The number of points to sample along the bundle. Default: 100.
orient_by: streamline, optional
A streamline to use as a standard to orient all of the streamlines in
the bundle according to.
weights1D array or 2D array or callable, optional
Weight each streamline (1D) or each node (2D) when calculating the
tract-profiles. Must sum to 1 across streamlines (in each node if
relevant). If callable, this is a function that calculates weights.
When using gaussian_weights directly, its node count matches
n_points. Other callables receive the bundle and weights_kwarg.
profile_statcallable, optional
The statistic used to average the profile across streamlines.
If weights is not None, this must take weights as a keyword argument.
The default, np.average, is the same as np.mean but takes weights
as a keyword argument.
weights_kwargkey-word arguments
Additional key-word arguments to pass to the weight-calculating
function. Only to be used if weights is a callable.
Returns:
ndarraya 1D array with the profile of data along the length of
bundle
Notes
Before providing a bundle as input to this function, you will need to make
sure that the streamlines in the bundle are all oriented in the same
orientation relative to the bundle (use orient_by_streamline()).
Create a mapping of dwi volume index to its nearest neighbor.
An approximate q-space is used (the deltas are not included).
Note that neighborhood is not necessarily bijective. One neighbor
is found per dwi volume.
Parameters:
gtab: dipy.core.gradients.GradientTable
Gradient table.
Returns:
neighbors: list of tuple
A list of 2-tuples indicating the nearest q-space neighbor
of each dwi volume.
Calculate the Neighboring DWI Correlation (NDC) from dMRI data.
Using a mask is highly recommended, otherwise the FOV will influence the
correlations. According to Yeh et al.[5], an NDC less than 0.4
indicates a low quality image.
Create a mapping of DWI volume index to its contrast DWI.
For each DWI volume, the contrast DWI is selected using the q-space
criterion described by Yeh. For each candidate q-space vector, its
component perpendicular to the reference q-space vector is calculated
and normalized to the magnitude of the reference vector. The candidate
closest to this normalized perpendicular vector is selected.
Parameters:
gtabdipy.core.gradients.GradientTable
Gradient table.
Returns:
contrastlist of tuple
A list of 2-tuples indicating the contrast DWI for each
DWI volume.
For each DWI volume, the voxel-wise correlation with its nearest
q-space neighbor and with its contrast DWI are calculated. The DWI
contrast metric is the mean neighboring DWI correlation divided by
the mean contrast DWI correlation.
The contrast DWI is selected by finding the candidate closest to a
normalized q-space vector perpendicular to the reference DWI.
Using a mask is highly recommended, otherwise the FOV will influence
the correlations.
Conventional thresholds are:
< 1.1: Poor
1.1-1.3: Fair
> 1.3: Good
Parameters:
dwi_data4D ndarray
DWI data on which to calculate DWI contrast.
gtabdipy.core.gradients.GradientTable
Gradient table.
mask3D ndarray, optional
Mask of voxels to include in the DWI contrast calculation.
Returns:
contrastfloat
DWI contrast, calculated as the mean neighboring DWI
correlation divided by the mean contrast DWI correlation.