organoid_tracker.core.position_data module

class organoid_tracker.core.position_data.PositionData

Bases: object

add_data_from_time_point_dict(time_point: TimePoint, positions: List[Position], metadata_dict: Dict[str, List[Optional[Union[float, int, str, bool, List[float], List[int], List[str], List[bool]]]]])

Adds a time point with positions and metadata. The metadata dictionary must contain lists of the same length as the positions list. The position and metadata lists must be in the same order, and the position list must not contain any duplicates.

This method is kind of low-level, and is mostly used for loading data from files. It’s faster than just calling set_position_data for every position. However, note that for speed reasons, this method does not check the positions list for duplicates.

You can easily create the metadata dictionary

add_positions_data(data_name: str, data_set: Dict[Position, Union[float, int, str, bool, List[float], List[int], List[str], List[bool]]])

Bulk-addition of position data. Should be faster that adding everything individually.

copy() PositionData

Creates a copy of this position metadata collection. Changes made to the copy will not affect this instance and vice versa.

create_time_point_dict(time_point: TimePoint, positions: List[Position]) Dict[str, List[Optional[Union[float, int, str, bool, List[float], List[int], List[str], List[bool]]]]]

Creates a dictionary of metadata lists for a given time point. The metadata lists are empty. This is useful for creating a new time point with the same positions as an existing time point, but with no metadata.

delete_data_with_name(data_name: str)

Deletes the data with the given key, for all positions in the experiment.

find_all_data_names() Set[str]

Finds all data_names

find_all_data_of_position(position: Position) Iterable[Tuple[str, Union[float, int, str, bool, List[float], List[int], List[str], List[bool]]]]

Finds all stored data of a given position.

find_all_positions_with_data(data_name: str) Iterable[Tuple[Position, Union[float, int, str, bool, List[float], List[int], List[str], List[bool]]]]

Gets a dictionary of all positions with the given data marker. Do not modify the returned dictionary.

first_time_point() Optional[TimePoint]

Gets the first time point that contains positions, or None if there are no positions stored.

first_time_point_number() Optional[int]

Gets the first time point that contains positions, or None if there are no positions stored.

get_data_names_and_types() Dict[str, Type]

Gets all data names that are currently in use, along with their type. The type will be str, float, bool, list, or object. (The type int is never returned, for ints float is returned instead. This is done so that users don’t have to worry about storing their numbers with the correct type.)

get_position_data(position: Position, data_name: str) Optional[Union[float, int, str, bool, List[float], List[int], List[str], List[bool]]]

Gets the attribute of the position with the given name. Returns None if not found.

has_position_data() bool

Gets whether there is any position data stored here.

has_position_data_with_name(data_name: str) bool

Returns whether there is position data stored for the given type.

last_time_point() Optional[TimePoint]

Gets the last time point (inclusive) that contains positions, or None if there are no positions stored.

last_time_point_number() Optional[int]

Gets the last time point (inclusive) that contains positions, or None if there are no positions stored.

merge_data(position_data: PositionData)

Merges all position data

move_in_time(time_point_delta: int)

Moves all data with the given time point delta.

remove_position(position: Position)

Removes a position from a time point. Does nothing if the position is not in this collection.

replace_position(old_position: Position, new_position: Position)

Moves a position, keeping its shape. Does nothing if the position is not in this collection. Raises a value error if the time points the provided positions are None or if they do not match.

set_position_data(position: Position, data_name: str, value: Optional[Union[float, int, str, bool, List[float], List[int], List[str], List[bool]]])

Adds or overwrites the given attribute for the given position. Set value to None to delete the attribute.

If the data_name is ‘id’ or starts with “__”, a ValueError is raised. This requirement was necessary for the old save system, so as long as OrganoidTracker still supports writing to the old format, this restriction remains in place.