goo.handler

class goo.handler.AdhesionLocationHandler[source]

Bases: Handler

Handler for updating cell-associated adhesion locations every frame.

run(scene, depsgraph)[source]

Run the handler.

This is the function that gets passed to Blender, to be called upon specified events (e.g. post-frame change).

Parameters:
  • scene – The Blender scene.

  • depsgraph – The dependency graph.

class goo.handler.ColorizeHandler(colorizer: Colorizer = Colorizer.PRESSURE)[source]

Bases: Handler

Handler for coloring cells based off of a specified property.

Cells are colored on a blue-red spectrum, based on the relative value of the specified property to all other cells. For example, the cell with the highest pressure is colored red, while the cell with an average pressure is colored purple.

Variables:

colorizer (Colorizer) – the property by which cells are colored.

Parameters:

colorizer (Colorizer)

run(scene, depsgraph)[source]

Run the handler.

This is the function that gets passed to Blender, to be called upon specified events (e.g. post-frame change).

Parameters:
  • scene – The Blender scene.

  • depsgraph – The dependency graph.

class goo.handler.Colorizer(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

PRESSURE = 1
RANDOM = 3
VOLUME = 2
class goo.handler.DataExporter(path='', options: ~goo.handler.DataFlag = <DataFlag.TIMES|DIVISIONS|MOTION_PATH|FORCE_PATH|VOLUMES|PRESSURES|CONTACT_AREAS|GRID|CELL_CONCENTRATIONS: 511>)[source]

Bases: Handler

Handler for the reporting and saving of data generated during the simulation.

Variables:
  • path (str) – Path to save .json file of calculated metrics. If empty, statistics are printed instead.

  • options – (DataFlag): Flags of which metrics to calculated and save/print. Flags can be combined by binary OR operation, i.e. DataFlag.TIMES | DataFlag.DIVISIONS.

Parameters:

options (DataFlag)

run(scene, depsgraph)[source]

Run the handler.

This is the function that gets passed to Blender, to be called upon specified events (e.g. post-frame change).

Parameters:
  • scene – The Blender scene.

  • depsgraph – The dependency graph.

setup(get_cells: Callable[[], list[Cell]], get_diffsystems: Callable[[], list[DiffusionSystem]], dt)[source]

Set up the handler.

Parameters:
  • get_cells (Callable[[], list[Cell]]) – A function that, when called, retrieves the list of cells that may divide.

  • dt – The time step for the simulation.

  • get_diffsystems (Callable[[], list[DiffusionSystem]])

class goo.handler.DataFlag(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Flag

Enum of data flags used by the DataExporter() handler.

Variables:
  • TIMES – time elapsed since beginning of simulation.

  • DIVISIONS – list of cells that have divided and their daughter cells.

  • MOTION_PATH – list of the current position of each cell.

  • FORCE_PATH – list of the current positions of the associated motion force of each cell.

  • VOLUMES – list of the current volumes of each cell.

  • PRESSURES – list of the current pressures of each cell.

  • CONTACT_AREAS – list of contact areas between each pair of cells.

  • CONCENTRATIONS – concentrations of each molecule in the grid system.

ALL = 511
CELL_CONCENTRATIONS = 256
CONTACT_AREAS = 64
DIVISIONS = 2
FORCE_PATH = 8
GRID = 128
MOTION_PATH = 4
PRESSURES = 32
TIMES = 1
VOLUMES = 16
class goo.handler.DiffusionHandler(diffusionSystem: DiffusionSystem)[source]

Bases: Handler

Handler for simulating diffusion of a substance in the grid in the scene.

Parameters:

diffusionSystem (DiffusionSystem) – The reaction-diffusion system to simulate.

build_kd_tree()[source]

Build the KD-Tree from the grid coordinates if not already built.

diffuse(mol_idx: int)[source]

Update the concentration of molecules based on diffusion.

Parameters:

mol_idx (int)

read_molecular_signal(cell: Cell, cell_distances: ndarray, indices: ndarray, radius: float) None[source]

Read the concentration of molecules in the cell.

Parameters:
  • cell (Cell)

  • cell_distances (ndarray)

  • indices (ndarray)

  • radius (float)

Return type:

None

run(scene, depsgraph) None[source]

Run the handler.

This is the function that gets passed to Blender, to be called upon specified events (e.g. post-frame change).

Parameters:
  • scene – The Blender scene.

  • depsgraph – The dependency graph.

Return type:

None

simulate_diffusion()[source]

Run the diffusion simulation over the total time.

update_molecular_signal(cell: Cell, cell_distances: ndarray, indices: ndarray, radius: float) None[source]

Update the concentration of molecules in the cell.

Parameters:
  • cell (Cell)

  • cell_distances (ndarray)

  • indices (ndarray)

  • radius (float)

Return type:

None

class goo.handler.ForceDist(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

CONSTANT = 1
GAUSSIAN = 3
UNIFORM = 2
class goo.handler.Growth(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

EXPONENTIAL = 2
LINEAR = 1
LOGISTIC = 3
class goo.handler.GrowthPIDHandler(growth_type: Growth = Growth.LINEAR, growth_rate: float = 1, initial_pressure=0.01, target_volume=30, Kp=0.05, Ki=1e-05, Kd=0.5)[source]

Bases: Handler

Handler for simulating cell growth based off of internal pressure.

Growth is determined by a PID controller, in which changes to a cell’s internal pressure governs how much it grows in the next frame.

Variables:
  • growth_type (Growth) – Type of growth exhibited by cells.

  • growth_rate (float) – Rate of growth of cells.

  • initial_pressure (float) – Initial pressure of cells.

  • target_volume (float) – Target volume of cells.

  • Kp (float) – P variable of the PID controller.

  • Ki (float) – I variable of the PID controller.

  • Kd (float) – D variable of the PID controller.

Parameters:
  • growth_type (Growth)

  • growth_rate (float)

initialize_PID(cell: Cell)[source]

Initialize PID controller for a cell.

Parameters:

cell (Cell) – Cell to initialize PID controller.

run(scene, depsgraph)[source]

Run the handler.

This is the function that gets passed to Blender, to be called upon specified events (e.g. post-frame change).

Parameters:
  • scene – The Blender scene.

  • depsgraph – The dependency graph.

setup(get_cells: Callable[[], list[Cell]], get_diffsystems: Callable[[], list[DiffusionSystem]], dt)[source]

Set up the handler.

Parameters:
  • get_cells (Callable[[], list[Cell]]) – A function that, when called, retrieves the list of cells that may divide.

  • dt – The time step for the simulation.

  • get_diffsystems (Callable[[], list[DiffusionSystem]])

class goo.handler.Handler[source]

Bases: object

run(scene: Scene, depsgraph: Depsgraph)[source]

Run the handler.

This is the function that gets passed to Blender, to be called upon specified events (e.g. post-frame change).

Parameters:
  • scene (Scene) – The Blender scene.

  • depsgraph (Depsgraph) – The dependency graph.

setup(get_cells: Callable[[], list[Cell]], get_diffsystems: Callable[[], list[DiffusionSystem]], dt: float)[source]

Set up the handler.

Parameters:
  • get_cells (Callable[[], list[Cell]]) – A function that, when called, retrieves the list of cells that may divide.

  • dt (float) – The time step for the simulation.

  • get_diffsystems (Callable[[], list[DiffusionSystem]])

class goo.handler.RandomMotionHandler(distribution: ForceDist = ForceDist.UNIFORM, max_strength: int = 0)[source]

Bases: Handler

Handler for simulating random cell motion.

At every frame, the direction of motion is randomized, and the strength of the motion force is randomly selected from a specified distribution.

Variables:
  • distribution (ForceDist) – Distribution of random strength of motion force.

  • max_strength (int) – Maximum strength motion force.

Parameters:
  • distribution (ForceDist)

  • max_strength (int)

run(scene, depsgraph)[source]

Run the handler.

This is the function that gets passed to Blender, to be called upon specified events (e.g. post-frame change).

Parameters:
  • scene – The Blender scene.

  • depsgraph – The dependency graph.

class goo.handler.RemeshHandler(freq=1, voxel_size=None, smooth_factor=0.1, sphere_factor=0)[source]

Bases: Handler

Handler for remeshing cells at given frequencies.

Variables:
  • freq (int) – Number of frames between remeshes.

  • smooth_factor (float) – Factor to pass to bmesh.ops.smooth_vert. Disabled if set to 0.

  • voxel_size (float) – Factor to pass to voxel_remesh(). Disabled if set to 0.

  • sphere_factor (float) – Factor to pass to Cast to sphere modifier. Disabled if set to 0.

run(scene, depsgraph)[source]

Run the handler.

This is the function that gets passed to Blender, to be called upon specified events (e.g. post-frame change).

Parameters:
  • scene – The Blender scene.

  • depsgraph – The dependency graph.

class goo.handler.SliceExporter(output_dir: str = '', z_range: tuple[float, float] = (5, -5), z_step: float = 0.2, microscope_dt: int = 10)[source]

Bases: Handler

Handler to save Z slices of the simulation at each frame.

Parameters:
  • output_dir (str)

  • z_range (tuple[float, float])

  • z_step (float)

  • microscope_dt (int)

run(scene: Scene, depsgraph: Depsgraph)[source]

Run the handler.

This is the function that gets passed to Blender, to be called upon specified events (e.g. post-frame change).

Parameters:
  • scene (Scene) – The Blender scene.

  • depsgraph (Depsgraph) – The dependency graph.

goo.handler.create_and_center_camera(location=(0, 0, 10), target=(0, 0, 0))[source]

Create a new camera object, set its parameters, center it to the specified location, and orient it towards the target.

Parameters:
  • location – The location to place the camera (default is (0, 0, 10)).

  • target – The point the camera should face (default is the origin in (0, 0, 0)).