direction
direction.peaks
BootDirectionGetter
ClosestPeakDirectionGetter
DeterministicMaximumDirectionGetter
InTemporaryDirectory
PeaksAndMetrics
PeaksAndMetricsDirectionGetter
ProbabilisticDirectionGetter
Sphere
repeat
xrange
InTemporaryDirectory
PeaksAndMetrics
PeaksAndMetricsDirectionGetter
Sphere
repeat
xrange
direction
BootDirectionGetter 
Methods 

ClosestPeakDirectionGetter 
A direction getter that returns the closest odf peak to previous tracking direction.  
DeterministicMaximumDirectionGetter 
Return direction of a sphere with the highest probability mass function (pmf).  
InTemporaryDirectory ([suffix, prefix, dir]) 
Create, return, and change directory to a temporary directory  
PeaksAndMetrics 


PeaksAndMetricsDirectionGetter 
Deterministic Direction Getter based on peak directions.  
ProbabilisticDirectionGetter 
Randomly samples direction of a sphere based on probability mass function (pmf).  
Sphere ([x, y, z, theta, phi, xyz, faces, edges]) 
Points on the unit sphere.  
repeat (object [,times]) 
for the specified number of times.  
xrange 
alias of builtins.range 

Pool 
Returns a process pool object  
cpu_count 
Returns the number of CPUs in the system  
gfa (samples) 
The general fractional anisotropy of a function evaluated on the unit sphere  
local_maxima 
Local maxima of a function evaluated on a discrete set of points.  
ndindex (shape) 
An Ndimensional iterator object to index arrays.  
peak_directions (odf, sphere[, …]) 
Get the directions of odf peaks.  
peak_directions_nl (sphere_eval[, …]) 
Non Linear Direction Finder.  
peaks_from_model (model, data, sphere, …[, …]) 
Fit the model to data and computes peaks and metrics  
remove_similar_vertices 
Remove vertices that are less than theta degrees from any other  
reshape_peaks_for_visualization (peaks) 
Reshape peaks for visualization.  
search_descending 
i in descending array a so a[i] < a[0] * relative_threshold  
sh_to_sf_matrix (sphere, sh_order[, …]) 
Matrix that transforms Spherical harmonics (SH) to spherical function (SF).  
warn 
Issue a warning, or maybe ignore it or raise an exception. 
direction.peaks
InTemporaryDirectory ([suffix, prefix, dir]) 
Create, return, and change directory to a temporary directory  
PeaksAndMetrics 


PeaksAndMetricsDirectionGetter 
Deterministic Direction Getter based on peak directions.  
Sphere ([x, y, z, theta, phi, xyz, faces, edges]) 
Points on the unit sphere.  
repeat (object [,times]) 
for the specified number of times.  
xrange 
alias of builtins.range 

Pool 
Returns a process pool object  
cpu_count 
Returns the number of CPUs in the system  
gfa (samples) 
The general fractional anisotropy of a function evaluated on the unit sphere  
local_maxima 
Local maxima of a function evaluated on a discrete set of points.  
ndindex (shape) 
An Ndimensional iterator object to index arrays.  
peak_directions (odf, sphere[, …]) 
Get the directions of odf peaks.  
peak_directions_nl (sphere_eval[, …]) 
Non Linear Direction Finder.  
peaks_from_model (model, data, sphere, …[, …]) 
Fit the model to data and computes peaks and metrics  
remove_similar_vertices 
Remove vertices that are less than theta degrees from any other  
reshape_peaks_for_visualization (peaks) 
Reshape peaks for visualization.  
search_descending 
i in descending array a so a[i] < a[0] * relative_threshold  
sh_to_sf_matrix (sphere, sh_order[, …]) 
Matrix that transforms Spherical harmonics (SH) to spherical function (SF).  
warn 
Issue a warning, or maybe ignore it or raise an exception. 
BootDirectionGetter
dipy.direction.
BootDirectionGetter
Bases: dipy.direction.closest_peak_direction_getter.BaseDirectionGetter
Methods
from_data 
Create a BootDirectionGetter using HARDI data and an ODF type model 
initial_direction 
Returns best directions at seed location to start tracking. 
get_direction 
from_data
()Create a BootDirectionGetter using HARDI data and an ODF type model
Parameters: 


ClosestPeakDirectionGetter
dipy.direction.
ClosestPeakDirectionGetter
Bases: dipy.direction.closest_peak_direction_getter.PmfGenDirectionGetter
A direction getter that returns the closest odf peak to previous tracking direction.
Methods
from_pmf 
Constructor for making a DirectionGetter from an array of Pmfs 
from_shcoeff 
Probabilistic direction getter from a distribution of directions on the sphere 
initial_direction 
Returns best directions at seed location to start tracking. 
get_direction 
DeterministicMaximumDirectionGetter
dipy.direction.
DeterministicMaximumDirectionGetter
Bases: dipy.direction.probabilistic_direction_getter.ProbabilisticDirectionGetter
Return direction of a sphere with the highest probability mass function (pmf).
Methods
from_pmf 
Constructor for making a DirectionGetter from an array of Pmfs 
from_shcoeff 
Probabilistic direction getter from a distribution of directions on the sphere 
initial_direction 
Returns best directions at seed location to start tracking. 
get_direction 
InTemporaryDirectory
dipy.direction.
InTemporaryDirectory
(suffix='', prefix='tmp', dir=None)Bases: nibabel.tmpdirs.TemporaryDirectory
Create, return, and change directory to a temporary directory
Examples
>>> import os
>>> my_cwd = os.getcwd()
>>> with InTemporaryDirectory() as tmpdir:
... _ = open('test.txt', 'wt').write('some text')
... assert os.path.isfile('test.txt')
... assert os.path.isfile(os.path.join(tmpdir, 'test.txt'))
>>> os.path.exists(tmpdir)
False
>>> os.getcwd() == my_cwd
True
Methods
cleanup 
PeaksAndMetrics
PeaksAndMetricsDirectionGetter
dipy.direction.
PeaksAndMetricsDirectionGetter
Bases: dipy.tracking.local.direction_getter.DirectionGetter
Deterministic Direction Getter based on peak directions.
This class contains the cython portion of the code for PeaksAndMetrics and is not meant to be used on its own.
Attributes: 


Methods
initial_direction 
The best starting directions for fiber tracking from point 
get_direction 
ProbabilisticDirectionGetter
dipy.direction.
ProbabilisticDirectionGetter
Bases: dipy.direction.closest_peak_direction_getter.PmfGenDirectionGetter
Randomly samples direction of a sphere based on probability mass function (pmf).
The main constructors for this class are current from_pmf and from_shcoeff.
The pmf gives the probability that each direction on the sphere should be
chosen as the next direction. To get the true pmf from the “raw pmf”
directions more than max_angle
degrees from the incoming direction are
set to 0 and the result is normalized.
Methods
from_pmf 
Constructor for making a DirectionGetter from an array of Pmfs 
from_shcoeff 
Probabilistic direction getter from a distribution of directions on the sphere 
initial_direction 
Returns best directions at seed location to start tracking. 
get_direction 
__init__
()Direction getter from a pmf generator.
Parameters: 


See also
Sphere
dipy.direction.
Sphere
(x=None, y=None, z=None, theta=None, phi=None, xyz=None, faces=None, edges=None)Bases: object
Points on the unit sphere.
The sphere can be constructed using one of three conventions:
Sphere(x, y, z)
Sphere(xyz=xyz)
Sphere(theta=theta, phi=phi)
Parameters: 


Attributes: 

Methods
find_closest (xyz) 
Find the index of the vertex in the Sphere closest to the input vector 
subdivide ([n]) 
Subdivides each face of the sphere into four new faces. 
edges  
faces  
vertices 
__init__
(x=None, y=None, z=None, theta=None, phi=None, xyz=None, faces=None, edges=None)Initialize self. See help(type(self)) for accurate signature.
find_closest
(xyz)Find the index of the vertex in the Sphere closest to the input vector
Parameters: 


subdivide
(n=1)Subdivides each face of the sphere into four new faces.
New vertices are created at a, b, and c. Then each face [x, y, z] is divided into faces [x, a, c], [y, a, b], [z, b, c], and [a, b, c].
y
/ / a/____
/\ / / \ / /____\/____ x c z
Parameters: 


Returns: 

repeat
dipy.direction.
repeat
(object[, times]) → create an iterator which returns the objectBases: object
for the specified number of times. If not specified, returns the object endlessly.
dipy.direction.
gfa
(samples)The general fractional anisotropy of a function evaluated on the unit sphere
Parameters: 


Returns: 

Notes
The GFA is defined as [1]
\sqrt{\frac{n \sum_i{(\Psi_i  <\Psi>)^2}}{(n1) \sum{\Psi_i ^ 2}}}
Where \(\Psi\) is an orientation distribution function sampled discretely on the unit sphere and angle brackets denote average over the samples on the sphere.
[1]  Quality assessment of High Angular Resolution Diffusion Imaging data using bootstrap on Qball reconstruction. J. Cohen Adad, M. Descoteaux, L.L. Wald. JMRI 33: 11941208. 
dipy.direction.
local_maxima
()Local maxima of a function evaluated on a discrete set of points.
If a function is evaluated on some set of points where each pair of neighboring points is an edge in edges, find the local maxima.
Parameters: 


Returns: 

See also
dipy.direction.
ndindex
(shape)An Ndimensional iterator object to index arrays.
Given the shape of an array, an ndindex instance iterates over the Ndimensional index of the array. At each iteration a tuple of indices is returned; the last dimension is iterated over first.
Parameters: 


Examples
>>> from dipy.core.ndindex import ndindex
>>> shape = (3, 2, 1)
>>> for index in ndindex(shape):
... print(index)
(0, 0, 0)
(0, 1, 0)
(1, 0, 0)
(1, 1, 0)
(2, 0, 0)
(2, 1, 0)
dipy.direction.
peak_directions
(odf, sphere, relative_peak_threshold=0.5, min_separation_angle=25, minmax_norm=True)Get the directions of odf peaks.
Peaks are defined as points on the odf that are greater than at least one neighbor and greater than or equal to all neighbors. Peaks are sorted in descending order by their values then filtered based on their relative size and spacing on the sphere. An odf may have 0 peaks, for example if the odf is perfectly isotropic.
Parameters: 


Returns: 

Notes
If the odf has any negative values, they will be clipped to zeros.
dipy.direction.
peak_directions_nl
(sphere_eval, relative_peak_threshold=0.25, min_separation_angle=25, sphere=<dipy.core.sphere.HemiSphere object>, xtol=1e07)Non Linear Direction Finder.
Parameters: 


Returns: 

dipy.direction.
peaks_from_model
(model, data, sphere, relative_peak_threshold, min_separation_angle, mask=None, return_odf=False, return_sh=True, gfa_thr=0, normalize_peaks=False, sh_order=8, sh_basis_type=None, npeaks=5, B=None, invB=None, parallel=False, nbr_processes=None)Fit the model to data and computes peaks and metrics
Parameters: 


Returns: 

References
[1]  (1, 2) Descoteaux, M., Angelino, E., Fitzgibbons, S. and Deriche, R. Regularized, Fast, and Robust Analytical Qball Imaging. Magn. Reson. Med. 2007;58:497510. 
[2]  (1, 2) Tournier J.D., Calamante F. and Connelly A. Robust determination of the fibre orientation distribution in diffusion MRI: Nonnegativity constrained superresolved spherical deconvolution. NeuroImage. 2007;35(4):14591472. 
dipy.direction.
remove_similar_vertices
()Remove vertices that are less than theta degrees from any other
Returns vertices that are at least theta degrees from any other vertex. Vertex v and v are considered the same so if v and v are both in vertices only one is kept. Also if v and w are both in vertices, w must be separated by theta degrees from both v and v to be unique.
Parameters: 


Returns: 

dipy.direction.
search_descending
()i in descending array a so a[i] < a[0] * relative_threshold
Call T = a[0] * relative_threshold
. Return value i will be the
smallest index in the descending array a such that a[i] < T
.
Equivalently, i will be the largest index such that all(a[:i] >= T)
.
If all values in a are >= T, return the length of array a.
Parameters: 


Returns: 

Examples
>>> a = np.arange(10, 0, 1, dtype=float)
>>> a
array([ 10., 9., 8., 7., 6., 5., 4., 3., 2., 1.])
>>> search_descending(a, 0.5)
6
>>> a < 10 * 0.5
array([False, False, False, False, False, False, True, True, True, True], dtype=bool)
>>> search_descending(a, 1)
1
>>> search_descending(a, 2)
0
>>> search_descending(a, 0)
10
dipy.direction.
sh_to_sf_matrix
(sphere, sh_order, basis_type=None, return_inv=True, smooth=0)Matrix that transforms Spherical harmonics (SH) to spherical function (SF).
Parameters: 


Returns: 

References
[1]  (1, 2) Descoteaux, M., Angelino, E., Fitzgibbons, S. and Deriche, R. Regularized, Fast, and Robust Analytical Qball Imaging. Magn. Reson. Med. 2007;58:497510. 
[2]  (1, 2) Tournier J.D., Calamante F. and Connelly A. Robust determination of the fibre orientation distribution in diffusion MRI: Nonnegativity constrained superresolved spherical deconvolution. NeuroImage. 2007;35(4):14591472. 
InTemporaryDirectory
dipy.direction.peaks.
InTemporaryDirectory
(suffix='', prefix='tmp', dir=None)Bases: nibabel.tmpdirs.TemporaryDirectory
Create, return, and change directory to a temporary directory
Examples
>>> import os
>>> my_cwd = os.getcwd()
>>> with InTemporaryDirectory() as tmpdir:
... _ = open('test.txt', 'wt').write('some text')
... assert os.path.isfile('test.txt')
... assert os.path.isfile(os.path.join(tmpdir, 'test.txt'))
>>> os.path.exists(tmpdir)
False
>>> os.getcwd() == my_cwd
True
Methods
cleanup 
PeaksAndMetrics
PeaksAndMetricsDirectionGetter
dipy.direction.peaks.
PeaksAndMetricsDirectionGetter
Bases: dipy.tracking.local.direction_getter.DirectionGetter
Deterministic Direction Getter based on peak directions.
This class contains the cython portion of the code for PeaksAndMetrics and is not meant to be used on its own.
Attributes: 


Methods
initial_direction 
The best starting directions for fiber tracking from point 
get_direction 
Sphere
dipy.direction.peaks.
Sphere
(x=None, y=None, z=None, theta=None, phi=None, xyz=None, faces=None, edges=None)Bases: object
Points on the unit sphere.
The sphere can be constructed using one of three conventions:
Sphere(x, y, z)
Sphere(xyz=xyz)
Sphere(theta=theta, phi=phi)
Parameters: 


Attributes: 

Methods
find_closest (xyz) 
Find the index of the vertex in the Sphere closest to the input vector 
subdivide ([n]) 
Subdivides each face of the sphere into four new faces. 
edges  
faces  
vertices 
__init__
(x=None, y=None, z=None, theta=None, phi=None, xyz=None, faces=None, edges=None)Initialize self. See help(type(self)) for accurate signature.
find_closest
(xyz)Find the index of the vertex in the Sphere closest to the input vector
Parameters: 


subdivide
(n=1)Subdivides each face of the sphere into four new faces.
New vertices are created at a, b, and c. Then each face [x, y, z] is divided into faces [x, a, c], [y, a, b], [z, b, c], and [a, b, c].
y
/ / a/____
/\ / / \ / /____\/____ x c z
Parameters: 


Returns: 

repeat
dipy.direction.peaks.
repeat
(object[, times]) → create an iterator which returns the objectBases: object
for the specified number of times. If not specified, returns the object endlessly.
dipy.direction.peaks.
gfa
(samples)The general fractional anisotropy of a function evaluated on the unit sphere
Parameters: 


Returns: 

Notes
The GFA is defined as [1]
\sqrt{\frac{n \sum_i{(\Psi_i  <\Psi>)^2}}{(n1) \sum{\Psi_i ^ 2}}}
Where \(\Psi\) is an orientation distribution function sampled discretely on the unit sphere and angle brackets denote average over the samples on the sphere.
[1]  Quality assessment of High Angular Resolution Diffusion Imaging data using bootstrap on Qball reconstruction. J. Cohen Adad, M. Descoteaux, L.L. Wald. JMRI 33: 11941208. 
dipy.direction.peaks.
local_maxima
()Local maxima of a function evaluated on a discrete set of points.
If a function is evaluated on some set of points where each pair of neighboring points is an edge in edges, find the local maxima.
Parameters: 


Returns: 

See also
dipy.direction.peaks.
ndindex
(shape)An Ndimensional iterator object to index arrays.
Given the shape of an array, an ndindex instance iterates over the Ndimensional index of the array. At each iteration a tuple of indices is returned; the last dimension is iterated over first.
Parameters: 


Examples
>>> from dipy.core.ndindex import ndindex
>>> shape = (3, 2, 1)
>>> for index in ndindex(shape):
... print(index)
(0, 0, 0)
(0, 1, 0)
(1, 0, 0)
(1, 1, 0)
(2, 0, 0)
(2, 1, 0)
dipy.direction.peaks.
peak_directions
(odf, sphere, relative_peak_threshold=0.5, min_separation_angle=25, minmax_norm=True)Get the directions of odf peaks.
Peaks are defined as points on the odf that are greater than at least one neighbor and greater than or equal to all neighbors. Peaks are sorted in descending order by their values then filtered based on their relative size and spacing on the sphere. An odf may have 0 peaks, for example if the odf is perfectly isotropic.
Parameters: 


Returns: 

Notes
If the odf has any negative values, they will be clipped to zeros.
dipy.direction.peaks.
peak_directions_nl
(sphere_eval, relative_peak_threshold=0.25, min_separation_angle=25, sphere=<dipy.core.sphere.HemiSphere object>, xtol=1e07)Non Linear Direction Finder.
Parameters: 


Returns: 

dipy.direction.peaks.
peaks_from_model
(model, data, sphere, relative_peak_threshold, min_separation_angle, mask=None, return_odf=False, return_sh=True, gfa_thr=0, normalize_peaks=False, sh_order=8, sh_basis_type=None, npeaks=5, B=None, invB=None, parallel=False, nbr_processes=None)Fit the model to data and computes peaks and metrics
Parameters: 


Returns: 

References
[1]  (1, 2) Descoteaux, M., Angelino, E., Fitzgibbons, S. and Deriche, R. Regularized, Fast, and Robust Analytical Qball Imaging. Magn. Reson. Med. 2007;58:497510. 
[2]  (1, 2) Tournier J.D., Calamante F. and Connelly A. Robust determination of the fibre orientation distribution in diffusion MRI: Nonnegativity constrained superresolved spherical deconvolution. NeuroImage. 2007;35(4):14591472. 
dipy.direction.peaks.
remove_similar_vertices
()Remove vertices that are less than theta degrees from any other
Returns vertices that are at least theta degrees from any other vertex. Vertex v and v are considered the same so if v and v are both in vertices only one is kept. Also if v and w are both in vertices, w must be separated by theta degrees from both v and v to be unique.
Parameters: 


Returns: 

dipy.direction.peaks.
search_descending
()i in descending array a so a[i] < a[0] * relative_threshold
Call T = a[0] * relative_threshold
. Return value i will be the
smallest index in the descending array a such that a[i] < T
.
Equivalently, i will be the largest index such that all(a[:i] >= T)
.
If all values in a are >= T, return the length of array a.
Parameters: 


Returns: 

Examples
>>> a = np.arange(10, 0, 1, dtype=float)
>>> a
array([ 10., 9., 8., 7., 6., 5., 4., 3., 2., 1.])
>>> search_descending(a, 0.5)
6
>>> a < 10 * 0.5
array([False, False, False, False, False, False, True, True, True, True], dtype=bool)
>>> search_descending(a, 1)
1
>>> search_descending(a, 2)
0
>>> search_descending(a, 0)
10
dipy.direction.peaks.
sh_to_sf_matrix
(sphere, sh_order, basis_type=None, return_inv=True, smooth=0)Matrix that transforms Spherical harmonics (SH) to spherical function (SF).
Parameters: 


Returns: 

References
[1]  (1, 2) Descoteaux, M., Angelino, E., Fitzgibbons, S. and Deriche, R. Regularized, Fast, and Robust Analytical Qball Imaging. Magn. Reson. Med. 2007;58:497510. 
[2]  (1, 2) Tournier J.D., Calamante F. and Connelly A. Robust determination of the fibre orientation distribution in diffusion MRI: Nonnegativity constrained superresolved spherical deconvolution. NeuroImage. 2007;35(4):14591472. 