SCTrack.base module

class SCTrack.base.Cell(*args, **kwargs)[source]

Bases: object

Define the cell class, which is the core class of SC-Track. The smallest unit of all operations is the Cell instance, and the Cell is implemented as a conditional singleton mode: that is, different objects are generated according to the parameters passed in. If the parameters passed in are the same , only one object is instantiated. When defining the Cell object, Cell class can be guaranteed that there is only one Cell instance for the same cell in one frame, and differentCell instances are generated in different frames. If you want to instantiate a Cell object, at least its position information needs to be passed in, that is, all the xy coordinate points that constitute the outline of the cell.

property area

Area of a cell

Type:

return

property available_range: Rectangle

Define the matchable range of the two frames before and after, the default is twice the horizontal and vertical coordinates of the cell :return: Rectangle instance

property bbox

bounding box coordinates

property branch_id
property cell_id

Cell id, parent cell and daughter cell have different value

property center

cell physical center

Type:

return

change_mitosis_flag(flag: bool)[source]
When the cell enters mitosis for the first time, self.mitosis_start_flag is set to True, and when the cell

completes division, it is reset to false.

property contours

Convert the list of xy coordinate points into contour points list :return: if successful, return contours, else return None

property d_long

Long side diameter of cell bounding box

Type:

return

property d_short

Short side diameter of cell bounding box

Type:

return

draw(background=None, isShow=False, color=(255, 0, 0))[source]
property feature
property is_accurate_matched
property is_be_matched

I f participated in the match, return match status, otherwise, False

move(speed: Vector, time: int = 1)[source]
Parameters:
  • speed – move speed, Vector object instance

  • time – move time,frame

Returns:

New Cell instance after moving

property move_speed: Vector

moving speed of the cell, the Vector object type

Type:

return

property parent
static polygon_area(x, y)[source]

Calculate cell area

Parameters:
  • x – A list of x-coordinates of all points of the cell counters

  • y – A list of y-coordinates of all points of the cell counters

Returns:

Area of cell

static polygon_centroid(vertex_coordinates)[source]

Calculate the physical center of gravity of the cell counters. :param vertex_coordinates: list of cell outline coordinate points, the format is [[x1, x2,…xn], [y1, y2,..yn]] :return: physical center of gravity

property r_long

Cell bounding box long side radius

Type:

return

property r_short

Cell bounding box short side radius

Type:

return

property region
set_branch_id(branch_id)[source]
set_cell_id(cell_id)[source]
set_feature(feature)[source]

set Feature object for cell

set_match_status(status: bool | str)[source]
set_parent_id(_Cell__parent_id)[source]
set_region(region)[source]
set_status(status: TreeStatus | CellStatus)[source]
set_track_id(_Cell__track_id, status: 1)[source]

Set the track_id for the cell

property status
property track_id
update_region(**kwargs)[source]

update annotation region information ,add the tracking results.

update_speed(speed: Vector)[source]
Parameters:

speed – new speed of the cell, Vector instance.

Returns:

None

property vector: Vector

Returns the cell center point vector, starting from the upper left corner of the image as the origin. :return: Vector instance

class SCTrack.base.CellStatus(*args, **kwargs)[source]

Bases: TreeStatus

Record the status of cells and exclude them from other matching candidates if they have participated in precise matching. If the cell has undergone Mitosis in a short time, it will not participate in Mitosis matching.

class SCTrack.base.MatchStatus(value)[source]

Bases: Enum

Matching status enumeration object, including matched, unmatched, and missing matches, is the status value of TrackingTree.

LossMatch = 2
Matched = 0
Unmatched = 1
SCTrack.base.NoneTypeFilter(func)[source]
class SCTrack.base.Rectangle(x_min, x_max, y_min, y_max)[source]

Bases: object

Rectangular class , used to record the bounding box and available range of cells

property area

Return the Rectangle area,

draw(background=None, isShow=False, color=(255, 0, 0))[source]

draw the rectangle

isInclude(other)[source]

Determine whether two rectangles contain

isIntersect(other)[source]

Determine whether two rectangles intersect

class SCTrack.base.SingleInstance(*args, **kwargs)[source]

Bases: object

Singleton pattern base class. If the parameters are the same, only one instance object will be instantiated

init_flag = False
class SCTrack.base.TreeStatus(*args, **kwargs)[source]

Bases: object

Record the state of the tracked cells, including cell cell_type status, division status, and matching status Phase: whether Mitosis has entered, and which frame has entered Mitosis Division: whether there is Mitosis Matching situation: Is there any loss of matching in this cell

add_M_count()[source]
add_exist_time()[source]
check_division_window()[source]

Check if the cell is in the division window stage

enter_mitosis(frame)[source]
exit_mitosis(frame)[source]
property exit_mitosis_time
get_status(status_type: str)[source]
Parameters:

status_type – __status_types member

Returns:

member status

is_in_division_window()[source]
property is_mitosis_enter
property predict_M_len
reset_M_count()[source]
reset_division_window()[source]

reset the division_windows_len

set_matched_status(value)[source]
property status
sub_division_window()[source]

When the cell is in the division window stage, continuously decreases the division_windows_len

class SCTrack.base.Vector(x=None, y=None, shape=(2, ), dtype=<class 'float'>, buffer=None, offset=0, strides=None, order=None)[source]

Bases: ndarray

2D plane vector class

EuclideanDistance(other)[source]

Return the Euclidean distance between two vectors

property cos

Return the cosine value of vector

cosDistance(other)[source]

Cosine distance, numerically equal to 1 minus cosine similarity, range of values [0,2]

cosSimilar(other)[source]

Compare the cosine similarity of two vectors, with a range of values [-1, 1]

property module

Return the modulus of vector

SCTrack.base.warningFilter(func)[source]