SyMBac.drawing

SyMBac.drawing.OPL_to_FL(cell, density)[source]
Parameters
  • cell (np.ndarray) – A 2D numpy array consisting of a rasterised cell

  • density (float) – Number of fluorescent molecules per volume element to sample in the cell

Returns

A cell with fluorescent reporters sampled in it

Rtypes

np.ndarray

SyMBac.drawing.draw_scene(cell_properties, do_transformation, space_size, offset, label_masks, pinching=True)[source]

Draws a raw scene (no trench) of cells, and returns accompanying masks for training data.

Parameters
  • properties (cell) – A list of cell properties for that frame

  • do_transformation (bool) – True if you want cells to be bent, false and cells remain straight as in the simulation

  • space_size (tuple) – The xy size of the numpy array in which the space is rendered. If too small then cells will not fit. recommend using the SyMBac.drawing.get_space_size() function to find the correct space size for your simulation

  • offset (int) – A necessary parameter which offsets the drawing a number of pixels from the left hand side of the image. 30 is a good number, but if the cells are very thick, then might need increasing.

  • label_masks (bool) – If true returns cell masks which are labelled (good for instance segmentation). If false returns binary masks only. I recommend leaving this as True, because you can always binarise the masks later if you want.

  • pinching (bool) – Whether or not to simulate cell pinching during division

Returns

  • space, space_masks (2D numpy array, 2D numpy array)

  • space (2D numpy array) – Not to be confused with the pyglet object calledspace in some other functions. Simply a 2D numpy array with an image of cells from the input frame properties

  • space_masks (2D numy array) – The masks (labelled or bool) for that scene.

SyMBac.drawing.find_farthest_vertices(vertex_list)[source]

Given a list of vertices, find the pair of vertices which are farthest from each other

Parameters

vertex_list (list(tuple(float, float))) – List of pairs of vertices [(x,y), (x,y), …]

Returns

The two vertices maximally far apart

Return type

array(tuple(float, float))

SyMBac.drawing.gen_cell_props_for_draw(cell_timeseries_lists, ID_props)[source]
Parameters
  • cell_timeseries_lists (list) – A list (single frame) from cell_timeseries, the output from run_simulation. E.g: cell_timeseries[x]

  • ID_props (list) – A list of properties for each cell in that frame, the output of generate_curve_props()

Returns

cell_properties – The final property list used to actually draw a scene of cells. The input to draw_scene

Return type

list

SyMBac.drawing.generate_curve_props(cell_timeseries)[source]

Generates individual cell curvature properties. 3 parameters for each cell, which are passed to a cosine function to modulate the cell’s curvature.

Parameters

cell_timeseries (list(cell_properties)) – The output of SyMBac.simulation.Simulation.run_simulation()

Returns

outupt

Return type

A numpy array of unique curvature properties for each cell in the simulation

SyMBac.drawing.get_centroid(vertices)[source]

Return the centroid of a list of vertices

Parameters

vertices (list(tuple(float, float))) – List of tuple of vertices where each tuple is (x, y)

Returns

Centroid of the vertices.

Return type

tuple(float, float)

SyMBac.drawing.get_distance(vertex1, vertex2)[source]

Get euclidian distance between two sets of vertices.

Parameters
Returns

Absolute distance between two points

Return type

float

SyMBac.drawing.get_midpoint(vertex1, vertex2)[source]

Get the midpoint between two vertices.

Parameters
Returns

Midpoint between vertex 1 and 2

Return type

tuple(float, float)

SyMBac.drawing.get_space_size(cell_timeseries_properties)[source]
Parameters

cell_timeseries_properties – A list of cell properties over time. Generated from SyMBac.simulation.Simulation.draw_simulation_OPL()

Returns

Iterates through the simulation timeseries properties, finds the extreme cell positions and retrieves the required image size to fit all cells into.

Return type

tuple(float, float)

SyMBac.drawing.make_images_same_shape(real_image, synthetic_image, rescale_int=True)[source]

Makes a synthetic image the same shape as the real image

SyMBac.drawing.midpoint_intercept(vertex1, vertex2)[source]

Get the y-intercept of the line connecting two vertices

Parameters
Returns

Y indercept of line between vertex 1 and 2

Return type

float

SyMBac.drawing.place_cell(length, width, angle, position, space)[source]

Creates a cell and places it in the pymunk space

Parameters
  • length (float) – length of the cell

  • width (float) – width of the cell

  • angle (float) – rotation of the cell in radians counterclockwise

  • position (tuple) – x,y coordinates of the cell centroid

  • space (pymunk.space.Space) – Pymunk space to place the cell in

Return type

nothing, updates space

SyMBac.drawing.raster_cell(length, width, separation, pinching=True, FL=False)[source]

Produces a rasterised image of a cell with the intensiity of each pixel corresponding to the optical path length (thickness) of the cell at that point.

Parameters
  • length (int) – Cell length in pixels

  • width (int) – Cell width in pixels

  • separation (int) – An int between (0, width) controlling how much pinching is happening.

  • pinching (bool) – Controls whether pinching is happening

Returns

cell – A numpy array which contains an OPL image of the cell. Can be converted to a mask by just taking cell > 0.

Return type

np.array

SyMBac.drawing.vertices_slope(vertex1, vertex2)[source]

Get the slope between two vertices

Parameters
Returns

Slope between vertex 1 and 2

Return type

float