# core

Core objects

 test([label, verbose, extra_argv, doctests, …]) Run tests for module using nose.

## Module: core.benchmarks.bench_sphere

Benchmarks for sphere

Run all benchmarks with:

import dipy.core as dipycore
dipycore.bench()


With Pytest, Run this benchmark with:

pytest -svv -c bench.ini /path/to/bench_sphere.py

 Timer Methods func_minimize_adhoc(init_hemisphere, …) func_minimize_scipy(init_pointset, …)

## Module: core.geometry

Utility functions for algebra etc

 cart2sphere(x, y, z) Return angles for Cartesian 3D coordinates x, y, and z cart_distance(pts1, pts2) Cartesian distance between pts1 and pts2 circumradius(a, b, c) a, b and c are 3-dimensional vectors which are the vertices of a triangle. compose_matrix([scale, shear, angles, …]) Return 4x4 transformation matrix from sequence of transformations. Compose multiple 4x4 affine transformations in one 4x4 matrix decompose_matrix(matrix) Return sequence of transformations from transformation matrix. dist_to_corner(affine) Calculate the maximal distance from the center to a corner of a voxel, given an affine euler_matrix(ai, aj, ak[, axes]) Return homogeneous rotation matrix from Euler angles and axis sequence. Test whether all points on a unit sphere lie in the same hemisphere. Lambert Equal Area Projection from cartesian vector to plane lambert_equal_area_projection_polar(theta, phi) Lambert Equal Area Projection from polar sphere to plane Least squares positive semi-definite tensor estimation normalized_vector(vec[, axis]) Return vector divided by its Euclidean (L2) norm perpendicular_directions(v[, num, half]) Computes n evenly spaced perpendicular directions relative to a given vector v rodrigues_axis_rotation(r, theta) Rodrigues formula sph2latlon(theta, phi) Convert spherical coordinates to latitude and longitude. sphere2cart(r, theta, phi) Spherical to Cartesian coordinates sphere_distance(pts1, pts2[, radius, …]) Distance across sphere surface between pts1 and pts2 vec2vec_rotmat(u, v) rotation matrix from 2 unit vectors vector_cosine(vecs1, vecs2) Cosine of angle between two (sets of) vectors vector_norm(vec[, axis, keepdims]) Return vector Euclidean (L2) norm

## Module: core.gradients

 GradientTable(gradients[, big_delta, …]) Diffusion gradient information HemiSphere([x, y, z, theta, phi, xyz, …]) Points on the unit sphere. auto_attr(func) Decorator to create OneTimeProperty attributes. btens_to_params(btens[, ztol]) Compute trace, anisotropy and assymetry parameters from b-tensors check_multi_b(gtab, n_bvals[, non_zero, bmag]) Check if you have enough different b-values in your gradient table deprecate_with_version(message[, since, …]) Return decorator function function for deprecation warning / error. disperse_charges(hemi, iters[, const]) Models electrostatic repulsion on the unit sphere generate_bvecs(N[, iters]) Generates N bvectors. get_bval_indices(bvals, bval[, tol]) Get indices where the b-value is bval gradient_table(bvals[, bvecs, big_delta, …]) A general function for creating diffusion MR gradients. gradient_table_from_bvals_bvecs(bvals, bvecs) Creates a GradientTable from a bvals array and a bvecs array A general function for creating diffusion MR gradients. A general function for creating diffusion MR gradients. inv(a[, overwrite_a, check_finite]) Compute the inverse of a matrix. params_to_btens(bval, bdelta, b_eta) Compute b-tensor from trace, anisotropy and assymetry parameters polar(a[, side]) Compute the polar decomposition. reorient_bvecs(gtab, affines[, atol]) Reorient the directions in a GradientTable. round_bvals(bvals[, bmag]) “This function rounds the b-values unique_bvals(bvals[, bmag, rbvals]) This function gives the unique rounded b-values of the data unique_bvals_magnitude(bvals[, bmag, rbvals]) This function gives the unique rounded b-values of the data unique_bvals_tolerance(bvals[, tol]) Gives the unique b-values of the data, within a tolerance gap vec2vec_rotmat(u, v) rotation matrix from 2 unit vectors vector_norm(vec[, axis, keepdims]) Return vector Euclidean (L2) norm warn(/, message[, category, stacklevel, source]) Issue a warning, or maybe ignore it or raise an exception.

## 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.interpolation

 Interpolator Class to be subclassed by different interpolator types NearestNeighborInterpolator Interpolates data using nearest neighbor interpolation OutsideImage TriLinearInterpolator Interpolates data using trilinear interpolation interp_rbf Interpolate data on the sphere, using radial basis functions. interpolate_scalar_2d Bilinear interpolation of a 2D scalar image interpolate_scalar_3d Trilinear interpolation of a 3D scalar image interpolate_scalar_nn_2d Nearest neighbor interpolation of a 2D scalar image interpolate_scalar_nn_3d Nearest neighbor interpolation of a 3D scalar image interpolate_vector_2d Bilinear interpolation of a 2D vector field interpolate_vector_3d Trilinear interpolation of a 3D vector field map_coordinates_trilinear_iso Trilinear interpolation (isotropic voxel size) nearestneighbor_interpolate trilinear_interp Interpolates vector from 4D data at 3D point given by index trilinear_interpolate4d Tri-linear interpolation along the last dimension of a 4d array

## Module: core.ndindex

 as_strided(x[, shape, strides, subok, writeable]) Create a view into the array with the given shape and strides. 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 descriptor to make special properties that become normal attributes. ResetMixin A Mixin class to add a .reset() method to users of OneTimeProperty. auto_attr(func) Decorator to create OneTimeProperty attributes.