organoid_tracker.core package

Submodules

Module contents

The core classes of OrganoidTracker. The most important one is Experiment, which holds all data of a single time-lapse movie.

Some example code to construct positions and links:

>>> from organoid_tracker.core.experiment import Experiment
>>> from organoid_tracker.core.images import ImageResolution
>>> from organoid_tracker.core.position import Position
>>> experiment = Experiment()
>>> experiment.images.set_resolution(ImageResolution(0.32, 0.32, 2, 12))
>>> experiment.name.set_name("Some name")
>>>
>>> # Add two positions and link them
>>> experiment.positions.add(Position(0, 0, 0, time_point_number=0))
>>> experiment.positions.add(Position(1, 3, 0, time_point_number=1))
>>> experiment.links.add_link(Position(0, 0, 0, time_point_number=0), Position(1, 3, 0, time_point_number=1))
>>>
>>> print(experiment.positions.of_time_point(TimePoint(1)))  # "{Position(1, 3, 0, time_point_number=1)}"
class organoid_tracker.core.Color(red: int, green: int, blue: int)

Bases: object

Represents an RGB color.

static black()

Returns a fully black color.

property blue: int

Gets the blue component from 0 to 255.

static from_matplotlib(mpl_color: Union[Tuple[float, float, float], Tuple[float, float, float, float], str, float]) Color

Creates a color using the Matplotlib library, so you can for example do Color.from_matplotlib(“red”).

static from_rgb(rgb: int) Color

Restores the color from the hexadecimal value.

static from_rgb_floats(red: float, green: float, blue: float) Color

Creates a color using a RGB float color, for example (1.0, 1.0, 1.0) for white.

property green: int

Gets the green component from 0 to 255.

is_black() bool

Returns True if this color is completely black.

property red: int

Gets the red component from 0 to 255.

to_html_hex()

Returns the color as a hexadecimal value. Same as str(…).

to_rgb() int

Gets the color as a RGB number. See also Color.from_rgb()

to_rgb_floats() Tuple[float, float, float]

Gets the color as a RGB tuple, for use with matplotlib.

to_rgba_floats() Tuple[float, float, float, float]

Gets the color as a RGBA tuple, for use with matplotlib.

static white()

Returns a fully white color.

class organoid_tracker.core.Name(name: Optional[str] = None, *, is_automatic: bool = False)

Bases: object

The name of the experiment. Includes a flag, is_automatic, that specifies whether the name was manually set or generated by the computer (for example from the image file name).

copy() Name

Creates a copy of this name, so that name changes don’t propagate through.

get_name() Optional[str]

Returns the name, or None if not set. Note: use str(self) if you want “Unnamed” instead of None if there is no name.

get_save_name() str

Gets a name that is safe for file saving. It does not contain characters like / or , and no whitespace at the start or end.

has_name() bool

Returns True if there is any name stored.

is_automatic() bool

Returns True if the name was set automatically (for example from an image file name), and False if the user set it manually.

provide_automatic_name(name: Optional[str])
set_name(name: Optional[str], *, is_automatic: bool = False)

Overwrites the name with the new name.

class organoid_tracker.core.TimePoint(time_point_number: int)

Bases: object

A single point in time.

time_point_number() int
exception organoid_tracker.core.UserError(title: str, message: str)

Bases: Exception

Used for errors that are not the fault of the programmer, but of the user.

body: str
title: str
organoid_tracker.core.clamp(minimum: int, value: int, maximum: int)

Clamps the given value to the specified min and max. For example, clamp(2, value, 4) will return value if it’s between 2 and 4, 2 if the value is lower than 2 and 4 if the value is higher than four.

organoid_tracker.core.max_none(numbers: Union[float, None, Iterable[Optional[float]]], *args: Optional[float])

Calculates the minimal number. None values are ignored. Usage:

>>> max_none(2, 3, 5, None, 5)  == 5
>>> max_none([4, None, 2, None, -1]) == 4
>>> max_none([]) is None
>>> max_none(None, None, None) is None
organoid_tracker.core.min_none(numbers: Union[float, None, Iterable[Optional[float]]], *args: Optional[float])

Calculates the minimal number. None values are ignored. Usage:

>>> min_none(2, 3, 5, None, 5) == 2
>>> min_none([4, None, 2, None, -1]) == -1
>>> min_none([]) is None
>>> min_none(None, None, None) is None