organoid_tracker.core.position module

class organoid_tracker.core.position.Position(x: float, y: float, z: float, *, time_point: Optional[TimePoint] = None, time_point_number: Optional[int] = None)

Bases: object

A detected position. Only the 3D + time position is stored here, see the PositionShape class for the shape. The position is immutable.

check_time_point(time_point: TimePoint)

Raises a ValueError if this position has no time point set, or if it has a time point that is not equal to the given time point.

distance_squared(other: Position, resolution: ImageResolution) float

Gets the squared distance in micrometers. Working with squared distances instead of normal ones gives a much better performance, as the expensive sqrt(..) function can be avoided.

distance_um(other: Position, resolution: ImageResolution) float

Gets the distance to the other position in micrometers.

static from_vector_um(vector: Vector3, resolution: ImageResolution, *, time_point: Optional[TimePoint] = None, time_point_number: Optional[int] = None) Position

Returns a position from the given vector, which is assumed to be in micrometers. If you want, you can specify a time point.

interpolate(to_pos: Position) List[Position]

Gets a time-interpolated list of positions. If you have positions A and B, with one time point in between, then a list will be returned of three elements: [A, I, B], with I an interpolated position. If there are two time points in between, then a list of four elements will be returned, and so on.

If there are no time points in between the two positions, then the two positions are simply returned. If both positions are in the same time point, then this method will raise ValueError. The returned list will always start with the earliest position first.

is_zero() bool

Returns True if the X, Y and Z are exactly zero. Time is ignored.

time_point() TimePoint

Gets the time point of this position. Note: getting the time point number is slightly more efficient, as this method requires allocating a new TimePoint instance.

time_point_number() Optional[int]
to_dict_key() str
to_vector_um(resolution: ImageResolution) Vector3
with_offset(dx: float, dy: float, dz: float) Position

Returns a copy of this position with the x, y and z moved.

Note that you can also just add two positions together, a + b == a.with_offset(b.x, b.y, b.z)

with_time_point(time_point: Optional[TimePoint]) Position

Returns a copy of this position with the time point set to the given position.

with_time_point_number(time_point_number: int) Position

Returns a copy of this position with the time point set to the given position.

x: float
y: float
z: float