Bounded meshes¶
vertax.meshes.bounded_mesh
Bounded mesh are useful to represent finite tissue clusters with curved interfaces.
BoundedMesh ¶
BoundedMesh()
Bases: Mesh
Bounded mesh with arc circles for boundary cells.
For a BoundedMesh, vertices is a 2D array of floats of size (nb_vertices, 2) ;
with the coordinates of the vertices (in ]0, width[ x ]0, height[ ).
edges is a 2D array of integers of size (nb_half_edges, 8), with:
- id of previous half-edge,
- id of next half-edge,
- id of twin half-edge,
- id of source vertex + 2 if current half-edge is an inside edge, else 0,
- id of target vertex + 2 if current half-edge is an inside edge, else 1,
- id of source vertex + 2 if current half-edge is an outside edge, else 0,
- id of target vertex + 2 if current half-edge is an outside edge, else 1,
- id of the face containing the half-edge.
faces is a 2D array of integers of size (nb_faces, 2), with:
- id of a half-edge belonging to the face,
- fate marker of the cell, between 0 and
nb_fates - 1(seefrom_seeds).
angles is a 1D array of floats of size (nb_angles), with the angles sustaining the arcs of the free interfaces ;
between 0 and PI / 2.
Every face is traversed counterclockwise (from_seeds orders it so, and T1 transitions keep it),
and the arc of a free interface bulges to the right of the directed chord of its half-edge, away
from the cell. Cell areas and cluster moments (vertax.geo) rely on this orientation and do not
read it from the sign of a cell's chord polygon, which turns over when the cell's interior
vertices cross the chord of its arc while the cell keeps its side. A mesh built outside VertAX must
therefore list its faces counterclockwise; load_mesh and load_mesh_txt refuse a clockwise mesh.
The floats of vertices and angles use JAX's default float dtype: float32, or float64 when
jax_enable_x64 is enabled before the mesh is built.
Do not call the constructor.
angles
instance-attribute
¶
angles: Array = jnp.array([])
Angle sustaining the arced free interfaces. Between 0 and PI / 2.
from_random_seeds
classmethod
¶
from_random_seeds(nb_seeds: int, width: float, height: float, random_key: int, nb_fates: int = 2) -> Self
Create a bounded Mesh from random seeds, based on a Voronoi diagram with arced free interfaces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nb_seeds
|
int
|
Number of random seeds to use. |
required |
width
|
float
|
width of the box containing the seeds. |
required |
height
|
float
|
height of the box containing the seeds. |
required |
random_key
|
int
|
seed for a random number generator to add new seeds if needed, decide on cell fates... |
required |
nb_fates
|
int, default=2
|
number of possible different fate marker for a cell. |
2
|
Returns:
| Type | Description |
|---|---|
Self
|
The corresponding mesh. |
from_seeds
classmethod
¶
from_seeds(seeds: NDArray, width: float, height: float, random_key: int, nb_fates: int = 2) -> Self
Create a bounded Mesh from a list of given seeds.
The seeds are assumed to have x-coordinate in ]0, width[ and y-coordinate in ]0, height[. Note that the final mesh might not use your seeds if they don't work to create a correct bounded mesh via our method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seeds
|
Array
|
jax float array of seed positions of shape (nbSeeds, 2). |
required |
width
|
float
|
width of the box containing the seeds. |
required |
height
|
float
|
height of the box containing the seeds. |
required |
random_key
|
int
|
seed for a random number generator to add new seeds if needed, decide on cell fates... |
required |
nb_fates
|
int, default=2
|
number of possible different fate marker for a cell. |
2
|
create_empty
classmethod
¶
create_empty() -> Self
Create an empty mesh. Use if you know what you're doing !
copy_mesh
classmethod
¶
copy_mesh(other_mesh: Self) -> Self
Copy all parameters from another mesh in a new mesh.
save_mesh ¶
save_mesh(path: str) -> None
Save mesh to a file.
All BoundedMesh data is saved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the saved file. The extension is .npz. |
required |
load_mesh
classmethod
¶
load_mesh(path: str) -> Self
Load a mesh from a file.
All BoundedMesh data is reloaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the mesh file (.npz). |
required |
Returns:
| Type | Description |
|---|---|
Self
|
The mesh loaded from the .npz file. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the faces of the mesh are clockwise (see |
Warns:
| Type | Description |
|---|---|
UserWarning
|
if some faces have a turned-over chord polygon (a crescent, or a fold). |
save_mesh_txt ¶
save_mesh_txt(directory: str, vertices_filename: str = 'vertTable.txt', angles_filename: str = 'angTable.txt', edges_filename: str = 'heTable.txt', faces_filename: str = 'faceTable.txt', vertices_params_filename: str = 'vertParamsTable.txt', edges_params_filename: str = 'heParamsTable.txt', faces_params_filename: str = 'faceParamsTable.txt', constants_filename: str = 'constants.txt') -> None
Save a mesh in separate text files that can be read by numpy.
Save the vertices, angles, edges and faces tables, the vertex, edge and face parameter tables and the constants (width and height), one text file each.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str
|
Path to the directory where to save the files. |
required |
vertices_filename
|
str
|
Filename for the vertices table. Defaults to "vertTable.txt". |
'vertTable.txt'
|
angles_filename
|
str
|
Filename for the angles table. Defaults to "angTable.txt". |
'angTable.txt'
|
edges_filename
|
str
|
Filename for the half-edges table. Defaults to "heTable.txt". |
'heTable.txt'
|
faces_filename
|
str
|
Filename for the faces table. Defaults to "faceTable.txt". |
'faceTable.txt'
|
vertices_params_filename
|
str
|
Filename for the vertices parameters table. Defaults to "vertParamsTable.txt". |
'vertParamsTable.txt'
|
edges_params_filename
|
str
|
Filename for the half-edges parameters table. Defaults to "heParamsTable.txt". |
'heParamsTable.txt'
|
faces_params_filename
|
str
|
Filename for the faces parameters table. Defaults to "faceParamsTable.txt". |
'faceParamsTable.txt'
|
constants_filename
|
str
|
Filename for width/height. Defaults to "constants.txt". |
'constants.txt'
|
load_mesh_txt
classmethod
¶
load_mesh_txt(directory: str, vertices_filename: str = 'vertTable.txt', angles_filename: str = 'angTable.txt', edges_filename: str = 'heTable.txt', faces_filename: str = 'faceTable.txt', vertices_params_filename: str = 'vertParamsTable.txt', edges_params_filename: str = 'heParamsTable.txt', faces_params_filename: str = 'faceParamsTable.txt', constants_filename: str = 'constants.txt') -> Self
Load a mesh from text files.
Load the vertices, angles, edges and faces tables, the vertex, edge and face parameter tables and the constants (width and height), one text file each.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str
|
Directory where the text files are stored. |
required |
vertices_filename
|
str
|
Filename for the vertices table. Defaults to "vertTable.txt". |
'vertTable.txt'
|
angles_filename
|
str
|
Filename for the angles table. Defaults to "angTable.txt". |
'angTable.txt'
|
edges_filename
|
str
|
Filename for the half-edges table. Defaults to "heTable.txt". |
'heTable.txt'
|
faces_filename
|
str
|
Filename for the faces table. Defaults to "faceTable.txt". |
'faceTable.txt'
|
vertices_params_filename
|
str
|
Filename for the vertices parameters table. Defaults to "vertParamsTable.txt". |
'vertParamsTable.txt'
|
edges_params_filename
|
str
|
Filename for the half-edges parameters table. Defaults to "heParamsTable.txt". |
'heParamsTable.txt'
|
faces_params_filename
|
str
|
Filename for the faces parameters table. Defaults to "faceParamsTable.txt". |
'faceParamsTable.txt'
|
constants_filename
|
str
|
Filename for width/height/MAX_EDGES_IN_ANY_FACE. Defaults to "constants.txt". |
'constants.txt'
|
Returns:
| Type | Description |
|---|---|
Self
|
The loaded mesh. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the faces of the mesh are clockwise (see |
Warns:
| Type | Description |
|---|---|
UserWarning
|
if some faces have a turned-over chord polygon (a crescent, or a fold). |