morphogen.models.affine¶
Affine anisotropy of morphological models.
A model given an anisotropy generates the image by the linear map x = A y of a
realization of its isotropic version: A = g^T diag(s) g stretches by s along
principal axes, the rows of the Bunge rotation g of the angles euler (degrees, the
convention of morphogen.orientations.euler_to_matrix()). The stretches are normalized
to a unit product, so that A preserves volumes: volume fractions, numbers of objects
per unit volume, object volumes, integral ranges, Euler densities and other topological
numbers keep their values and meaning, and only shapes change. A sphere of radius r
becomes an ellipsoid of semi-axes s_i r (and of the same volume), a hard-core packing
of spheres a hard-core packing of aligned ellipsoids, a Voronoi or Laguerre tessellation
the tessellation computed in the stretched space and mapped back (cells elongated along
the axes of the largest stretches), an excursion of a Gaussian field the excursion of a
field of covariance rho(|A^-1 h|). The mean intercept length along a unit direction
d becomes MIL_iso / |A^-1 d|: its fabric tensor (morphogen.analysis.
fabric_tensor()) has the principal axes of A and principal MILs in the ratios of s.
Configuration, the same for every model:
anisotropy: {stretch: [1, 1, 2], euler: [0, 0, 0]} # elongated twice as much along z
anisotropy: [1, 1, 2] # the same: 3 stretches, or 6
# numbers with the Euler angles
anisotropy: 2 # an elongation 2 along z
Periodicity. The image of a periodic box by A is periodic in the same box only when
A is diagonal in the axes of the box: principal axes along the box axes (Euler angles
multiples of 90 degrees, or turning about the axis of two equal stretches). The isotropic
model is then generated in the box of edges L_i / t_i (t = diag A), periodic like
the domain, and its voxel images on the grid of the same shape are those of the
anisotropic structure (an exact map of grids). Other principal axes need a non-periodic
domain (an error otherwise): the isotropic model is generated in the bounding box of the
preimage of the domain (numbers of cells or objects then refer to that box). Two-phase
structures are voxelized exactly, by point queries at the preimages of the voxel centres;
labels, several phases and level sets by sampling at those preimages a grid of that box of
spacing the voxel size over the largest stretch (nearest voxel; trilinear for level sets
and partial volume fractions: interfaces within half a voxel). Models that apply the
metric themselves (the Gaussian field) accept any rotation in periodic boxes.
- morphogen.models.affine.ALIGNED = 1e-12¶
Relative size of the off-diagonal entries of
Abelow which its principal axes are taken along the box axes.
- class morphogen.models.affine.Anisotropy(stretch: tuple[float, float, float] = (1.0, 1.0, 1.0), euler: tuple[float, float, float] = (0.0, 0.0, 0.0), elongation: float | None = None)[source]¶
Bases:
objectStretches
stretchalong the principal axes turned by the Bunge angleseuler(degrees);elongation: the number it was given as (an elongation along z).- property principal: ndarray¶
The stretches normalized to a unit product (a map preserving volumes).
- property axes: ndarray¶
The principal axes (columns) in the axes of the sample.
- property matrix: ndarray¶
the image of a point
yof the isotropic structure.- Type:
A = g^T diag(s) g
- property is_identity: bool¶
- morphogen.models.affine.anisotropy_from_config(value, name: str = 'anisotropy') Anisotropy | None[source]¶
An
Anisotropyfrom a configuration value: None (isotropic), a mapping withstretchandeuler, a list of 3 stretches or of 6 numbers (stretches, then angles), or a number (an elongation along z).
- morphogen.models.affine.ANISOTROPY = 'Affine anisotropy: stretches along principal axes turned by Bunge angles, {stretch: [sx, sy, sz], euler: [phi1, Phi, phi2]} (degrees), or 3 or 6 numbers, or an elongation along z; normalized to preserve volumes; periodic boxes: principal axes along the box axes (none: isotropic)'¶
The documentation of the
anisotropyfield of the models that accept it (declaredparam(None, doc=ANISOTROPY, kind="anisotropy", kw_only=True); None: isotropic).
- morphogen.models.affine.invariant_theory(values: dict[str, float]) dict[str, float][source]¶
The characteristics of
Model.theory()that a volume-preserving map keeps.
- morphogen.models.affine.reference_domain(anisotropy: Anisotropy, domain: Domain, name: str = 'model') Domain[source]¶
The domain where the isotropic model is generated (see the module).
- morphogen.models.affine.anisotropic(cls)[source]¶
Class decorator of a model with an
anisotropyfield: its realizations are those of its isotropic version, generated in the preimage of the domain and mapped (AffineStructure), and its theoretical characteristics those the map keeps. Without anisotropy the model is unchanged.
- class morphogen.models.affine.AffineStructure(domain: Domain, inner: Microstructure, anisotropy: Anisotropy, **kwargs)[source]¶
Bases:
MicrostructureThe image by
x = A y(Anisotropy) of a realizationinnerof the isotropic model, generated in the preimage ofdomain.- FORWARDED = ('orientations', 'cell_phases')¶
Attributes of the inner realization that do not depend on positions (data of its cells and grains), forwarded.
- property has_labels: bool¶
Whether
labels(...)gives an image of cell indices (cells, grains).
- voxelize(shape=None, *, voxel_size=None, grid: Grid | None = None, supersampling: int = 1) VoxelImage[source]¶
Phase image (uint8), or partial volume fractions of phase 1 (float32) when
supersampling > 1(supersampling**3sub-samples per voxel).
- labels(shape=None, *, voxel_size=None, grid: Grid | None = None) VoxelImage[source]¶
- level_set(shape=None, *, voxel_size=None, grid: Grid | None = None) VoxelImage[source]¶
The level set of the inner realization at the preimages (its zero set is the boundary; its values are distances in the isotropic space).
- implicit_phases() list[int][source]¶
The phases of the realization, each described by an implicit function (
phase_level_set()), in increasing order: phase 1 and what surrounds it (the structures of more phases, or of others, say theirs).
- phase_level_set(phase: int, shape=None, *, voxel_size=None, grid: Grid | None = None) VoxelImage[source]¶
The implicit function of a phase of the inner realization at the preimages.
- property lipschitz: float¶
That of the inner realization, times the largest stretch of the inverse map.
- level_set_at(points, reach: float = inf) ndarray[source]¶
The level set of the inner realization at the preimages of the points (its zero set is the boundary; distances of the isotropic space, within the stretch ratios of those of the mapped one).
- phase_level_sets_at(points, reach: float = inf) dict[int, ndarray][source]¶
The functions of the phases of the inner realization at the preimages of the points (
phase_level_set()at any point).