cellects.image_analysis.oscillations_functions
cellects.image_analysis.oscillations_functions
Analyze oscillating clusters in 2D video data through flux tracking.
This module implements a class to track cluster dynamics by analyzing pixel flux changes over time. The core functionality updates cluster identifiers, tracks periods of activity, and archives final data for completed clusters based on morphological analysis and contour boundaries.
Classes ClusterFluxStudy : Updates flux information and tracks oscillating clusters in 2D space
Functions update_flux : Processes flux changes to update cluster tracking and archive completed clusters
Notes Uses cv2.connectedComponentsWithStats and custom distance calculations for boundary analysis Maintains cumulative pixel data for active clusters during time-lapse processing
detect_oscillations_dynamics(converted_video, binary, arena_label, starting_time, expected_oscillation_period, time_interval, minimal_oscillating_cluster_size, min_ram_free=1.0, lose_accuracy_to_save_memory=False, save_coord_thickening_slimming=True)
Detects oscillatory dynamics in a labeled arena from processed video data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
converted_video
|
NDArray
|
Processed intensity values of the input video as 3D/4D array (t,y,x[,c]) |
required |
binary
|
NDArray[uint8]
|
Binary segmentation mask with 1 for active region and 0 otherwise |
required |
arena_label
|
int
|
Label identifier for the specific arena being analyzed in binary mask |
required |
starting_time
|
int
|
Timepoint index to start oscillation analysis from (earlier frames are ignored) |
required |
expected_oscillation_period
|
int
|
Expected average period of oscillations in seconds |
required |
time_interval
|
int
|
Sampling interval between consecutive video frames in seconds |
required |
minimal_oscillating_cluster_size
|
int
|
Minimum number of pixels required for a cluster to be considered an oscillation feature |
required |
min_ram_free
|
(float, optional(default=1.0))
|
Minimum free RAM in GB that must remain available during processing |
1.0
|
lose_accuracy_to_save_memory
|
(bool, optional(default=False))
|
If True, uses low-precision calculations to reduce memory usage at the cost of accuracy |
False
|
save_coord_thickening_slimming
|
(bool, optional(default=True))
|
If True, saves detected cluster coordinates as .h5 files |
True
|
Returns:
| Type | Description |
|---|---|
NDArray[int8]
|
3D array where each pixel is labeled with 1=influx region, 2=efflux region, or 0=no oscillation |
Notes
- Processes video data by calculating intensity gradients to detect directional oscillations
- Memory-intensive operations use float16 when available RAM would otherwise be exceeded
- Saves coordinate arrays if requested, which may consume significant disk space for large datasets
Source code in src/cellects/image_analysis/oscillations_functions.py
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 | |