AFQ.utils.volume

Module Contents

Functions

transform_inverse_roi(roi, mapping, bundle_name='ROI')

After being non-linearly transformed, ROIs tend to have holes in them.

patch_up_roi(roi, bundle_name='ROI', make_convex=True)

After being non-linearly transformed, ROIs tend to have holes in them.

density_map(tractogram, n_sls=None, to_vox=False, normalize=False)

Create a streamline density map.

dice_coeff(arr1, arr2, weighted=True)

Compute Dice's coefficient between two images.

Attributes

logger

AFQ.utils.volume.logger[source]
AFQ.utils.volume.transform_inverse_roi(roi, mapping, bundle_name='ROI')[source]

After being non-linearly transformed, ROIs tend to have holes in them. We perform a couple of computational geometry operations on the ROI to fix that up.

Parameters
roiNifti1Image, str, ndarray

The ROI to transform. Can be a path or image, which will be converted to an ndarray.

mappingDiffeomorphicMap object

A mapping between DWI space and a template.

bundle_namestr, optional

Name of bundle, which may be useful for error messages. Default: None

Returns
ROI after dilation and hole-filling
AFQ.utils.volume.patch_up_roi(roi, bundle_name='ROI', make_convex=True)[source]

After being non-linearly transformed, ROIs tend to have holes in them. We perform a couple of computational geometry operations on the ROI to fix that up.

Parameters
roi3D binary array

The ROI after it has been transformed.

sigmafloat

The sigma for initial Gaussian smoothing.

truncatefloat

The truncation for the Gaussian

bundle_namestr, optional

Name of bundle, which may be useful for error messages. Default: None

Returns
ROI after dilation and hole-filling
AFQ.utils.volume.density_map(tractogram, n_sls=None, to_vox=False, normalize=False)[source]

Create a streamline density map. based on: https://dipy.org/documentation/1.1.1./examples_built/streamline_formats/

Parameters
tractogramStatefulTractogram

Stateful tractogram whose streamlines are used to make the density map.

n_slsint or None, optional

n_sls to randomly select to make the density map. If None, all streamlines are used. Default: None

to_voxbool, optional

Whether to put the stateful tractogram in VOX space before making the density map. Default: False

normalizebool, optional

Whether to normalize maximum values to 1. Default: False

Returns
Nifti1Image containing the density map.
AFQ.utils.volume.dice_coeff(arr1, arr2, weighted=True)[source]

Compute Dice’s coefficient between two images.

Parameters
arr1Nifti1Image, str, ndarray

One ndarray to compare. Can be a path or image, which will be converted to an ndarray.

arr2Nifti1Image, str, ndarray

The other ndarray to compare. Can be a path or image, which will be converted to an ndarray.

weightedbool, optional

Whether or not to weight the DICE coefficient as in [Cousineau2017]. The weighted Dice coefficient is calculated by adding the sum of all values in arr1 where arr2 is nonzero to the sum of all values in arr2 where arr1 is nonzero, then dividing that by the sum of all values in arr1 and arr2. Default: True

Returns
The dice similarity between the images.

Notes

1

Cousineau M, Jodoin PM, Morency FC, et al. A test-retest study on Parkinson’s PPMI dataset yields statistically significant white matter fascicles. Neuroimage Clin. 2017;16:222-233. Published 2017 Jul 25. doi:10.1016/j.nicl.2017.07.020