tractolearn.tractomath package#

Submodules#

tractolearn.tractomath.utils module#

tractolearn.tractomath.utils.compute_angle(u, v, use_smallest=True, nan_to_zero=True)#

Compute the angle between the input vectors. If both u and v have the same shape, angles are computed in a pairwise fashion. Otherwise, P angles are computed for each vector in u if P vectors are provided in v. The former case can be found, for example, when computing the angle between streamlined endpoint dirs and their matched surface vertex normal vectors; the latter case can be found when computing the angle for N streamline segment directions and the local orientation (e.g. fODF) peaks, having P peaks at each streamline segment. Note that although a vector is supposed to have a direction, in the context of tractography, the directionality is not implied by the local orientation. In such cases, the smallest angle between the lines might be desirable. :param u: Container of N 3D vectors. :type u: ndarray (N, 3) :param v: Container of N 3D vectors or P times N 3D vectors. :type v: ndarray (N, 3) or (P, N, 3) :param use_smallest: True to get the smallest value between the computed angle and its

supplementary. This might be especially relevant if vectors are assumed to be undirected, such as local orientation (e.g. fODF) peaks.

Returns:

angles – The angle between the vectors.

Return type:

ndarray (N,) or (P, N)

tractolearn.tractomath.utils.is_normalized(n)#

Checks if a number is a normalized.

Parameters:

n (float) – Number to be checked.

Returns:

True if the input number is normalized; False otherwise.

Return type:

bool

tractolearn.tractomath.utils.unit_vector(vector)#

Returns the unit vector of the vector. NaN values might be returned for null values.

Module contents#