EMC2 Stitcher
Stiching/gap closing with EMC2 algorithm (See tps propagation from propagation module)
- class byotrack.implementation.refiner.stitching.emc2.EMC2Stitcher(method: str | DirectedPropagate = 'tps', eta: float = 5.0, **kwargs)
Bases:
DistStitcherImplements Elastic Motion Correction and Concatenation (EMC2)
Stitch tracks using motion corrected positions following the paper: T. Lagache, A. Hanson, J. Perez-Ortega, et al., “Tracking calcium dynamics from individual neurons in behaving animals”, PLoS computational biology, vol. 17, pp. e1009432, 10 2021.
- method
Method to use for position propagation. Either “constant”, “tps” or “flow” (see constant_directed_propagate, tps_directed_propagate or optical_flow_directed_propagate) or a user defined Callable following the DirectedPropagate protocol. Default: “tps”
- Type:
- kwargs
Additional parameters given to method. For instance for “tps”, you can set alpha (float) which is the regularization parameter of the interpolation (see tps_propation module and torch_tps librarie). We advise to use alpha > 5.0 (alpha = 10 by default). For “flow” propagation, you should provide optflow (byotrack.OpticalFlow) to correctly estimate optical flows.
- Type:
Dict[str, Any]
- max_dist
Cannot stich track i and track j if the last position of i and first position of j are farther than max_dist (ignored if max_dist <= 0) Default: 100.0
- Type:
- max_gap
Cannot stich track i and track j if i ended more than max_gap frame before j started (ignored if max_gap <= 0) Default: 250
- Type:
- compute_dist(video: Sequence[ndarray] | ndarray, tracks: Collection[Track]) ndarray
Compute EMC2 distance between tracks
Compute the mininum distance between each track propagation (only in the temporal gap between them).
- Parameters:
video (Sequence[np.ndarray] | np.ndarray) – Video of the tracked particles
tracks (Collection[Track]) – Input tracks
- Returns:
- Distance between each track. (Contains np.inf)
Shape: (N, N), dtype: float32
- Return type:
np.ndarray