cellects.video.graph_tracking
cellects.video.graph_tracking
Graph extraction on a binary video.
This module uses GraphTracking class on binary images to extract and track graph in a video.
Classes:
| Name | Description |
|---|---|
GraphTracking |
|
GraphTracking
Extract dynamic graph data from binary video frames.
The class processes time‑series binary network masks to build evolving vertex and edge tables. It aligns networks with an optional origin contour, extracts skeletons, computes geometric and intensity attributes, and stores the results in CSV files whose names encode the arena label and video dimensions.
Attributes:
| Name | Type | Description |
|---|---|---|
starting_time |
int
|
Frame index at which tracking starts (initially |
coord_network |
NDArray
|
Binary mask of the network for each time point (shape |
converted_video |
NDArray
|
Original video frames used to calculate edge intensity attributes
(shape |
coord_pseudopods |
NDArray or None
|
Optional mask of pseudopod regions; used to label growing areas. |
origin |
NDArray or None
|
Binary mask of the region of interest’s central origin. |
arena_label |
int
|
Identifier that prefixes all output file names. |
dims |
tuple of int
|
Dimensions of the video ( |
pad_origin_centroid |
ndarray or None
|
Centroid of |
pad_origin |
ndarray or None
|
Padded version of |
origin_contours |
list or None
|
Contours extracted from |
vertex_table |
ndarray or None
|
Accumulated vertex data; populated after tracking. |
edge_table |
ndarray or None
|
Accumulated edge data; populated after tracking. |
edge_pix_coord |
ndarray or None
|
Pixel coordinates belonging to each edge; populated after tracking. |
Source code in src/cellects/video/graph_tracking.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
__init__(converted_video, coord_network, arena_label, origin=None, coord_pseudopods=None)
Initialize the arena graph extraction object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
converted_video
|
NDArray
|
Video data that has been pre‑processed and converted to a suitable
numeric format. Its shape is expected to contain at least three
dimensions, where the first three are used to compute |
required |
coord_network
|
NDArray
|
Array describing the connectivity network of the arena; used later for graph construction. |
required |
arena_label
|
int
|
Identifier of the arena instance. Used for logging and tracking. |
required |
origin
|
NDArray[uint8]
|
Binary mask of the arena origin. When provided the centroid of the
origin is computed, padded, and its contours are extracted. If
|
None
|
coord_pseudopods
|
NDArray
|
Optional coordinate data for pseudopod structures. Stored directly without further processing. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
starting_time |
int
|
Timestamp (in whatever units the caller uses) marking the start of
processing; initialized to |
coord_network |
NDArray
|
Reference to the |
converted_video |
NDArray
|
Reference to the |
coord_pseudopods |
NDArray or None
|
Reference to the |
origin |
NDArray[uint8] or None
|
Reference to the |
arena_label |
int
|
Reference to the |
dims |
tuple of int
|
Spatial dimensions of |
pad_origin_centroid |
tuple of int or None
|
Centroid of |
origin_contours |
list or None
|
Contours extracted from |
pad_origin |
NDArray or None
|
Padded version of |
vertex_table |
None
|
Placeholder for the vertex table populated after graph extraction. |
edge_table |
None
|
Placeholder for the edge table populated after graph extraction. |
Source code in src/cellects/video/graph_tracking.py
extract_graph(t)
Compute the graph representation for a given time point t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
int
|
Index of the time frame to process. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
binary_image |
ndarray of uint8
|
Array containing the skeleton (value |
Notes
- The network for time
tis extracted fromself.coord_network. - If
self.originis defined, the origin mask contour is combined with the computed network. - Only the largest connected component is retained via
keep_one_connected_component. - Padding is added before skeletonisation and removed before the result is returned.
- Vertex and edge tables are accumulated in the instance attributes
vertex_table,edge_tableandedge_pix_coord. - When
self.coord_pseudopodsis provided, its coordinates are used as growing areas during vertex identification.
Source code in src/cellects/video/graph_tracking.py
frame_by_frame_tracking()
Perform frame‑by‑frame tracking of the network.
When self.coord_network has no columns the method creates empty
tables for vertices, edges and pixel coordinates. Otherwise it iterates
over the time dimension starting at self.starting_time and extracts
the graph for each frame by calling :meth:extract_graph.
Returns:
| Type | Description |
|---|---|
None
|
The method updates the instance attributes in‑place and does not return a value. |
Source code in src/cellects/video/graph_tracking.py
save_graph()
Save the graph data stored in the instance to CSV files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
self
|
The instance containing the graph attributes. It must provide the following attributes:
|
required |
Returns:
| Type | Description |
|---|---|
``None``
|
The method writes three CSV files and does not return a value. |
Notes
The method converts the internal containers to :class:pandas.DataFrame
objects with fixed column orders and then writes them to CSV files whose
names embed arena_label and the three video dimensions from dims:
vertices_coord{arena_label}_t{t}_y{y}_x{x}.csvedges_to_vertices{arena_label}_t{t}_y{y}_x{x}.csvedges_coord{arena_label}_t{t}_y{y}_x{x}.csv