organoid_tracker.core.experiment module
- class organoid_tracker.core.experiment.Experiment
Bases:
object
A complete experiment, with many stacks of images collected over time. This class ultimately collects all details of the experiment.
An experiment contains
Position
objects. They represent a cell detection at a particular time point. The object itself just stores an x, y, z and time point. The objects can be found inexperiment.positions
. For example, to get a list of all positions at time point 7, uselist(experiment.positions.of_time_point(TimePoint(7))
.Cell detections from different time points can be marked as belonging to the same biological cell. These links over time are stored in
experiment.links
. Using for exampleexperiment.links.find_futures(position)
, you’ll know what position in the next time point represents locates same cell. This will usually be one position, but in the case of a division, it will be two positions. In the case of a cell death, it will be 0 positions.Cells can also have neighbors, and those are defined in
experiment.connections
. Metadata of cell positions, like the cell type or fluorescent intensity, is stored inexperiment.position_data
.- property beacons: BeaconCollection
Gets all beacon positions. Beacons are used to measure the movement of cells towards or around some static position.
- close()
Closes any system resources of this experiment, like file handles for images on disk.
- property color: Color
Returns the color of this experiment. This color is used in various plots where multiple experiments are summarized.
- property connections: Connections
Gets the connections, which are used to group positions at the same time point.
- copy_selected(*, images: bool = False, positions: bool = False, position_data: bool = False, links: bool = False, link_data: bool = False, global_data: bool = False, connections: bool = False, name: bool = False) Experiment
Copies the selected attributes over to a new experiment. Note that position_data and links can only be copied if the positions are copied.
- property division_lookahead_time_points
Where there no divisions found because a cell really didn’t divide, or did the experiment simply end before the cell divided? If the experiment continues for at least this many time points, then we can safely assume that
the cell did not divide.
- first_time_point() Optional[TimePoint]
Gets the first time point of the experiment where there is data (images, splines and/or positions).
- first_time_point_number() Optional[int]
Gets the first time point of the experiment where there is data (images, splines and/or positions).
- get_next_time_point(time_point: TimePoint) TimePoint
Gets the time point directly after the given time point. Throws ValueError if the given time point is the last time point of the experiment.
- get_previous_time_point(time_point: TimePoint) TimePoint
Gets the time point directly before the given time point. Throws ValueError if the given time point is the first time point of the experiment.
- get_time_point(time_point_number: int) TimePoint
Gets the time point with the given number. Throws ValueError if no such time point exists. This method is essentially an alternative for TimePoint(time_point_number), but with added bound checks.
- property global_data: GlobalData
- last_time_point() Optional[TimePoint]
Gets the last time point of the experiment where there is data (images, splines and/or positions).
- last_time_point_number() Optional[int]
Gets the last time point (inclusive) of the experiment where there is data (images, splines and/or positions).
- merge(other: Experiment)
Merges the position, linking, connections and global data of the other experiment into this one. Images and their resolution/timings are not merged, so do that yourself in an appropriate way.
- move_in_time(time_point_delta: int)
Moves all data with the given time offset.
The only thing that is not moved are the images themselves. So images.get_image_stack(TimePoint(2)) will still report the same image array as before. However, the timings and offsets of the images are moved.
- move_position(position_old: Position, position_new: Position, update_splines: bool = True)
Moves the position of a position, preserving any links. (So it’s different from remove-and-readd.) The shape of a position is not preserved, though. Throws ValueError when the position is moved to another time point. If the new position has not time point specified, it is set to the time point o the existing position.
When update_splines is set to False, the zero point of all splines (if any) will not be updated. This makes moving the positions a lot faster. However, you should call splines.update_for_changed_positions yourself after moving all positions.
- property position_data: PositionData
Gets the metadata associated with cell positions, like cell type, intensity, etc.
- property positions: PositionCollection
Gets all cell positions of all time points.
- remove_position(position: Position, *, update_splines: bool = True)
Removes a position and its links and other data from the experiment.
When update_splines is set to False, the zero point of all splines (if any) will not be updated. This makes moving the positions a lot faster. However, you should call splines.update_for_changed_positions yourself after moving all positions.
- remove_positions(positions: Iterable[Position], *, update_splines: bool = True)
Removes multiple positions and their links and other data from the experiment. If you have multiple positions to delete, it is more efficient to call this method than to call remove_position many times.
When update_splines is set to False, the zero point of all splines (if any) will not be updated. This makes moving the positions a lot faster. However, you should call splines.update_for_changed_positions yourself after moving all positions.
- splines: SplineCollection
- time_points() Iterable[TimePoint]
Returns an iterable over all time points, so that you can do for time_point in experiment.time_points():.
- property warning_limits: WarningLimits
Gets the limits used by the error checker. For example: what movement is so fast that it should raise an error?