# core

Core objects

## Module: core.geometry

Utility functions for algebra etc

 _TUPLE2AXES dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2). sphere2cart(r, theta, phi) Spherical to Cartesian coordinates cart2sphere(x, y, z) Return angles for Cartesian 3D coordinates x, y, and z See doc for sphere2cart for angle conventions and derivation of the formulae. sph2latlon(theta, phi) Convert spherical coordinates to latitude and longitude. normalized_vector(vec[, axis]) Return vector divided by its Euclidean (L2) norm vector_norm(vec[, axis, keepdims]) Return vector Euclidean (L2) norm rodrigues_axis_rotation(r, theta) Rodrigues formula Least squares positive semi-definite tensor estimation sphere_distance(pts1, pts2[, radius, ...]) Distance across sphere surface between pts1 and pts2 cart_distance(pts1, pts2) Cartesian distance between pts1 and pts2 vector_cosine(vecs1, vecs2) Cosine of angle between two (sets of) vectors lambert_equal_area_projection_polar(theta, phi) Lambert Equal Area Projection from polar sphere to plane Return positions in (y1,y2) plane corresponding to the points with polar coordinates (theta, phi) on the unit sphere, under the Lambert Equal Area Projection mapping (see Mardia and Jupp (2000), Directional Statistics, p. Lambert Equal Area Projection from cartesian vector to plane Return positions in $$(y_1,y_2)$$ plane corresponding to the directions of the vectors with cartesian coordinates xyz under the Lambert Equal Area Projection mapping (see Mardia and Jupp (2000), Directional Statistics, p. euler_matrix(ai, aj, ak[, axes]) Return homogeneous rotation matrix from Euler angles and axis sequence. compose_matrix([scale, shear, angles, ...]) Return 4x4 transformation matrix from sequence of transformations. decompose_matrix(matrix) Return sequence of transformations from transformation matrix. circumradius(a, b, c) a, b and c are 3-dimensional vectors which are the vertices of a triangle. vec2vec_rotmat(u, v) rotation matrix from 2 unit vectors Compose multiple 4x4 affine transformations in one 4x4 matrix perpendicular_directions(v[, num, half]) Computes n evenly spaced perpendicular directions relative to a given vector v dist_to_corner(affine) Calculate the maximal distance from the center to a corner of a voxel, given an affine Test whether all points on a unit sphere lie in the same hemisphere.

## Module: core.gradients

 GradientTable(gradients[, big_delta, ...]) Diffusion gradient information logger Instances of the Logger class represent a single logging channel. unique_bvals(bvals[, bmag, rbvals]) This function gives the unique rounded b-values of the data dipy.core.gradients.unique_bvals is deprecated, Please use dipy.core.gradients.unique_bvals_magnitude instead * deprecated from version: 1.2 * Raises as of version: 1.4 Parameters ---------- bvals : ndarray Array containing the b-values bmag : int The order of magnitude that the bvalues have to differ to be considered an unique b-value. gradient_table_from_bvals_bvecs(bvals, bvecs) Creates a GradientTable from a bvals array and a bvecs array gradient_table_from_qvals_bvecs(qvals, ...) A general function for creating diffusion MR gradients. A general function for creating diffusion MR gradients. gradient_table(bvals[, bvecs, big_delta, ...]) A general function for creating diffusion MR gradients. reorient_bvecs(gtab, affines[, atol]) Reorient the directions in a GradientTable. generate_bvecs(N[, iters]) Generates N bvectors. round_bvals(bvals[, bmag]) "This function rounds the b-values Parameters ---------- bvals : ndarray Array containing the b-values bmag : int The order of magnitude to round the b-values. unique_bvals_tolerance(bvals[, tol]) Gives the unique b-values of the data, within a tolerance gap get_bval_indices(bvals, bval[, tol]) Get indices where the b-value is bval unique_bvals_magnitude(bvals[, bmag, rbvals]) This function gives the unique rounded b-values of the data Parameters ---------- bvals : ndarray Array containing the b-values bmag : int The order of magnitude that the bvalues have to differ to be considered an unique b-value. check_multi_b(gtab, n_bvals[, non_zero, bmag]) Check if you have enough different b-values in your gradient table Parameters ---------- gtab : GradientTable class instance. btens_to_params(btens[, ztol]) Compute trace, anisotropy and asymmetry parameters from b-tensors. params_to_btens(bval, bdelta, b_eta) Compute b-tensor from trace, anisotropy and asymmetry parameters. ornt_mapping(ornt1, ornt2) Calculate the mapping needing to get from orn1 to orn2. reorient_vectors(bvecs, current_ornt, new_ornt) Change the orientation of gradients or other vectors. reorient_on_axis(bvecs, current_ornt, new_ornt) orientation_from_string(string_ornt) Return an array representation of an ornt string. Return a string representation of a 3d ornt.

## Module: core.graph

A simple graph class

 A simple graph class

## Module: core.histeq

 histeq(arr[, num_bins]) Performs an histogram equalization on arr.

## Module: core.ndindex

 ndindex(shape) An N-dimensional iterator object to index arrays.

## Module: core.onetime

Descriptor support for NIPY.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

• Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.

• Redistributions in binary form must reproduce the above

copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

• Neither the name of the NIPY Developers nor the names of any

contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Utilities to support special Python descriptors [1,2], in particular the use of a useful pattern for properties we call ‘one time properties’. These are object attributes which are declared as properties, but become regular attributes once they’ve been read the first time. They can thus be evaluated later in the object’s life cycle, but once evaluated they become normal, static attributes with no function call overhead on access or any other constraints.

A special ResetMixin class is provided to add a .reset() method to users who may want to have their objects capable of resetting these computed properties to their ‘untriggered’ state.

 A Mixin class to add a .reset() method to users of OneTimeProperty. A descriptor to make special properties that become normal attributes. auto_attr(func) Decorator to create OneTimeProperty attributes.