Mapping Neurons¶
Fragment Generation¶
-
class
brainlit.map_neurons.
DiffeomorphismAction
¶ Interface for differentiable mappings e.g. transformations that register a brain image to an atlas.
-
D
(self, position: np.array, deriv: np.array, order: int = 1)¶ Evaluate the mapping on a set of derivatives at specified positions.
- Parameters:
position (np.array) -- Coordinates in the original space.
deriv (np.array) -- Derivatives at the respective positions
order (int, optional) -- Derivative order. Defaults to 1.
- Returns:
Transformed derivatives.
- Return type:
np.array
-
evaluate
(self, position: np.array)¶ Evaluate the mapping at specified positions.
- Parameters:
position (np.array) -- Coordinates in original space.
- Returns:
Transformed coordinates.
- Return type:
np.array
-
-
class
brainlit.map_neurons.
CloudReg_Transform
(vpath: str, Apath: str, direction: str = 'atlas')¶ Object that can read mat files from CloudReg, and compute transformations on points and Jacobians. Implements DiffeomorphismAction which is an interface to transform points and tangent vectors.
-
D
(self, position: np.array, deriv: np.array, order: int = 1)¶ Compute transformed derivatives of mapping at given positions. Only for the non-affine component.
- Parameters:
position (np.array) -- nx3 positions at which to compute derivatives.
deriv (np.array) -- nx3 derivatives at the respective positions.
order (int, optional) -- Order of derivative (must be 1). Defaults to 1.
- Raises:
ValueError -- Only derivative order 1 is allowed here.
- Returns:
Transformed derivatives
- Return type:
np.array
-
Jacobian
(self, pos: np.array)¶ Compute Jacobian of transformation at a given point.
- Parameters:
pos (np.array) -- Coordinate in space.
- Returns:
Jacobian at that coordinate
- Return type:
np.array
-
apply_affine
(self, position: np.array)¶ Apply affine transformation in the transformation of positions in target space to atlas space.
- Parameters:
position (np.array) -- nx3 array with positions in target space.
- Returns:
positions after affine transformation was applied.
- Return type:
np.array
-
evaluate
(self, position: np.array)¶ Apply non-affine component of mapping to positions, in direction of self.direction (default from target to atlas).
- Parameters:
position (np.array) -- Positions at which to compute mappings.
- Returns:
Mappings of the input.
- Return type:
np.array
-
-
brainlit.map_neurons.
compute_derivs
(us: np.array, tck: tuple = None, positions: np.array = None, deriv_method: str = 'difference')¶ Estimate derivatives of a sequence of points. Derivatives can be estimated in three ways: - For curves parameterized by scipy's spline API, spline estimation uses scipy's derivative computation - For a sequence of points, we use the finite-difference method from:
Sundqvist, H., & Veronis, G. (1970). A simple finite‐difference grid with non‐constant intervals. Tellus, 22(1), 26-31.
one-sided derivatives are derived from the piecewise linear interpolation.
- Parameters:
us (np.array) -- Parameter values (in form returned by scipy.interpolate.splprep).
tck (tuple) -- Knots, bspline coefficients, and degree of spline (in form returned by scipy.interpolate.splprep).
positions (np.array) -- nx3 array of positions (for use by difference method).
deriv_method (str, optional) -- Method to use (from list above), spline for scipy.interpolate.splev, difference for the finite difference method, two-sided for one-sided derivatives from linear interpolation. Defaults to "difference".
- Raises:
ValueError -- If the wrong combination of arguments/deriv_method is used.
ValueError -- If derivative method is unrecognized.
- Returns:
Derivative estimates at specified positions, or tuple of np.array for two-sided option.
- Return type:
np.array