EMC2 Stitcher

Stiching/gap closing with EMC2 algorithm (See tps propagation from propagation module)

class byotrack.implementation.refiner.stitching.emc2.EMC2Stitcher(alpha: float = 10.0, eta: float = 5.0)

Bases: DistStitcher

Implements 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.

alpha

Thin Plate Spline regularization (See tps_propation module and torch_tps librarie) We advise to use alpha > 5.0. It improves outliers resiliences and helps reducing numerical errors. Default: 10.0

Type:

float

eta

Soft threshold in LAP solving (See DistStitcher) Default: 5.0 (Pixels)

Type:

float

max_overlap

Cannot stitch tracks that overlap more than max_overlap Default: 5

Type:

int

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:

float

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:

int

compute_dist(_: Iterable[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 (Iterable[np.ndarray]) – Unused, added for API purposes

  • tracks (Collection[Track]) – Input tracks

Returns:

Distance between each track. (Contains np.inf)

Shape: (N, N), dtype: float32

Return type:

np.ndarray