cellects.video.network_tracking
cellects.video.network_tracking
Video network detection and skeleton analysis for biological networks (such as Physarum polycephalum's) images.
This module uses network functions on images to track networks on a video.
Classes:
| Name | Description |
|---|---|
NetworkTracking: detect the network on every image of a video and use their temporality to improve accuracy |
|
NetworkTracking
Source code in src/cellects/video/network_tracking.py
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 280 281 282 283 284 285 286 287 288 289 290 291 | |
frame_by_frame_tracking()
Summary
Iterate network detection over video frames and return the network segmentation of the final frame.
Returns:
| Name | Type | Description |
|---|---|---|
complete_network |
ndarray of uint8
|
The segmentation network produced for the last processed frame. |
Source code in src/cellects/video/network_tracking.py
init_tracking()
Summary
Initialize tracking attributes, set up visualizations, and configure the network detection pipeline for the current motion data.
Notes
- Resets motion‑related buffers such as
coord_networkandpseudopod_coord. - Determines the origin based on
self.motion.vars['origin_state']. - Allocates arrays (e.g.,
pseudopod_vid,potential_network,network_dynamics) matching the shape ofself.motion.binary. - Creates a greyscale image from either
self.motion.visuorself.motion.converted_videofor further processing. - Instantiates :class:
NetworkDetectionwith the greyscale frame, the binary mask of the last frame, the origin (if any), and the morphological closing flag. - Sets
self.lighter_backgroundby comparing the mean intensity of foreground and background pixels.
Source code in src/cellects/video/network_tracking.py
post_process(t)
Post‑process a single time‑frame of the network and return a visualisation image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
int
|
Index of the time‑frame to be processed. Must be a non‑negative integer within the range of the video sequence. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
imtoshow |
ndarray of uint8
|
Visualises the processed network overlayed on the original frame. |
Notes
-
If
self.motion.vars['sliding_window_segmentation']isTrue, a five‑frame sliding window centred ontis summed to obtain a provisional network. Edge cases (t < 2ort > self.dims[0] - 3) use a truncated window. The provisional network is binarised so that any pixel with a value greater than1becomes1and isolated single‑pixel detections are removed. -
When
self.originis provided, its contour is merged with the provisional network. The original shape is discarded and only its contour contributes to the final network. -
keep_one_connected_componentguarantees that the resulting binary mask contains a single 8‑connected component, removing stray islands. -
If
self.detect_pseudopodsisTrue, pseudopods from the current frame (self.pseudopod_vid[t]) are temporarily added back to the network before growth‑control checks. The maximal allowed decrease in pixel count is computed from the previous frame (self.network_dynamics[t‑1]) scaled by1 + self.motion.vars['maximal_growth_factor']. Should the network fall below this threshold, missing pieces that belong to large connected components are reinstated. -
After growth control, large growing regions that are not part of the main network are identified as pseudopods. These are stored in
self.pseudopod_vid[t]while ensuring that removal of pseudopods does not fragment the remaining network. -
The visualisation image is created by eroding the final binary network with a 3×3 cross‑shaped structuring element (
cross_33) and highlighting the resulting boundary pixels in a distinct colour. -
This method mutates
self.network_dynamicsand, when enabled,self.pseudopod_vidas side‑effects.
Source code in src/cellects/video/network_tracking.py
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 | |
post_processing()
Apply post‑processing to all time steps from starting_time up to the
last index of the time dimension.
Returns:
| Type | Description |
|---|---|
None
|
The method updates internal state; it does not return a value. |
Notes
For each t the private method post_process is invoked to perform
dynamic improvement of the segmentation.
Source code in src/cellects/video/network_tracking.py
save_network()
Save the coordinates of the network and, optionally, pseudopods to HDF5 files.
Returns:
| Type | Description |
|---|---|
tuple of (numpy.ndarray, numpy.ndarray or None)
|
|
Notes
- If
self.detect_pseudopodsisTrue, cells identified as pseudopods are marked with the value2inself.network_dynamics. - Coordinate arrays are written to HDF5 files when
self.motion.vars['save_coord_network']isTrue. The filenames embed the arena identifier and the dimensionst,y, andx. - The function relies on
smallest_memory_arrayto cast the result ofnp.nonzeroto the minimal unsigned‑integer representation.
Source code in src/cellects/video/network_tracking.py
segment_frame(t)
Segment a single frame into a network mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
int
|
Index of the frame to process. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
complete_network |
ndarray of uint8
|
Binary network mask for frame |
Notes
The method updates internal buffers:
self.potential_network stores the detected network,
self.pseudopod_vid is filled when detect_pseudopods is True,
and NetDet_fast.greyscale_image receives the greyscale frame.