morphogen.image

Voxel images: a 3D array on a regular grid with its geometry and metadata.

class morphogen.image.VoxelImage(data: ndarray, spacing: tuple[float, float, float]=(1.0, 1.0, 1.0), origin: tuple[float, float, float]=(0.0, 0.0, 0.0), periodic: bool = False, name: str = 'phase', metadata: dict = <factory>)[source]

Bases: object

3D image of a microstructure.

data

Array of shape (nx, ny, nz) indexed [i, j, k] along (x, y, z). Typical contents: phase indices (uint8), cell labels (int32), partial volume fractions or level-set values (float32).

Type:

numpy.ndarray

spacing

Voxel edge lengths.

Type:

tuple[float, float, float]

origin

Lower corner of voxel (0, 0, 0) (not its centre).

Type:

tuple[float, float, float]

periodic

Whether the image is periodic (measurements then wrap around the faces).

Type:

bool

name

Name of the array in exported files (e.g. "phase", "material").

Type:

str

metadata

JSON-able information (model, seed, version…).

Type:

dict

property shape: tuple[int, int, int]
property size: ndarray

Physical extent of the image.

property voxel_volume: float
property volume: float
property n_voxels: int
domain(unit: str = '') → Domain[source]
grid() → Grid[source]
with_data(data, *, name: str | None = None) → VoxelImage[source]

New image on the same grid.

layer(axis: int = 2, index: int | None = None) → VoxelImage[source]

One layer of voxels normal to axis (the middle one by default), as an image one voxel thick of the same voxels: a planar section of a volume, for a study in its plane (a plane strain for the mechanics) on far fewer voxels. Periodic as the image (the fields then do not vary across the layer).

crop(start, stop) → VoxelImage[source]

Sub-image data[start[0]:stop[0], ...] (never periodic).