Skip to content

Mitochondria

Mitochondria Generation

The MitochondriaGenerator class simulates 3D point clouds of mitochondria based on a persistent random walk model within a discrete voxel grid. This model generates complex, branching mitochondrial networks that realistically occupy a 3D volume.

Core Algorithm: Persistent Random Walk

The generation of each mitochondrion is modeled as a path, or "centerline," grown step-by-step through a 3D space. The key principles are:

  1. Persistent Random Walk: The mitochondrion extends in a series of steps. At each step, the direction of growth is slightly perturbed from the previous step's direction. The degree of straightness or tortuosity is controlled by the persistence_length parameter. A higher persistence length results in straighter, more rigid segments.

  2. Dynamic Radius: The mitochondrion is modeled as a tube with a varying ellipsoidal cross-section. The two radii of the ellipsoid (radius1, radius2) change at each step of the walk. This change is autocorrelated, ensuring that the radius varies smoothly along the length of the mitochondrion, avoiding abrupt jumps.

  3. Branching: The model can create complex networks by allowing mitochondria to branch. At each step of the walk, there is a certain probability (branch_prob_per_step) of a new branch forming. A new branch sprouts from the current position and grows independently, following its own persistent random walk.

Generation Process

The overall generation follows a multi-step process, from creating an abstract centerline to sampling a final point cloud.

1. Single Network Generation (_generate_single_mito_network)

This is the core function for generating a single, potentially branched, mitochondrial network.

  • Initialization: A random starting position is chosen within the simulation volume. An initial direction is also randomly selected. To avoid unnatural clustering, the generator can optionally search for a sparse region to begin growth.
  • Growth Loop: The generator maintains a list of active branches. It extends one branch at a time, step-by-step.
  • At each step, it updates the direction based on the persistence length and adds a new point to the centerline.
  • The radii are updated based on the autocorrelation parameters.
  • It checks if a new branch should be created. If so, a new branch is initialized with a portion of the remaining length and added to the list of active branches. The current branch terminates at the fork.
  • Output: The function returns the set of all points and associated radii that constitute the complete centerline network for one mitochondrion.

2. Voxelization (_create_ellipsoid_mask)

The abstract centerline is converted into a solid 3D object in a voxel grid.

  • For each point along the centerline, the generator places a 3D ellipsoid mask into the grid.
  • The dimensions of the ellipsoid are determined by the radius1 and radius2 values at that point.
  • The union of all these ellipsoids forms the complete 3D volume of the mitochondrion.

3. Multi-Mitochondria Simulation and Collision Handling

When generating multiple mitochondria, the simulation handles overlaps to ensure physical realism.

  • Mitochondria are generated sequentially.
  • When a new mitochondrion is generated, its voxelized volume is compared against the volume occupied by all previously generated mitochondria (volume_grid).
  • Carving: Any part of the new mitochondrion that overlaps with an existing one is "carved out."
  • Overlap Control: If the carved volume exceeds a defined threshold (max_overlap_ratio), the new mitochondrion is discarded, and the generator may attempt to create a new one in its place. This prevents unrealistic, heavily overlapping structures.
  • The final, carved mask of the new mitochondrion is added to the global volume_grid.

4. Point Cloud Sampling

The final step is to generate a point cloud from the voxelized mitochondrial volumes.

  • Surface vs. Volume Sampling: The user can choose to sample points from either the surface of the mitochondria or from both their surface and interior (fill_mitochondria). Different sampling probabilities can be set for the surface and the interior.
  • Jitter: A small random displacement (jitter) is added to each point's coordinates to ensure they are not perfectly aligned with the voxel grid.
  • Noise Models:
  • Localization Noise: To simulate the inherent uncertainty in microscopy imaging, Gaussian noise is added to the (x, y, z) coordinates of each point, based on the specified localization_precision.
  • Background Noise: Randomly distributed points can be added to the entire volume to simulate background signal or non-specific labeling.

The final output is a (N, 4) NumPy array, where N is the total number of points. Each row contains the (x, y, z) coordinates and the id of the mitochondrion to which the point belongs (background points are assigned an ID of 0).