Icy EMHT
Wrapper around Spot Tracking protocol of ICY.
- class byotrack.implementation.linker.icy_emht.icy_emht.Motion(*values)
Bases:
EnumDifferent motion models.
- BROWNIAN
Random gaussian displacement at each time
- DIRECTED
Random gaussian noise around a directed trajectory
- MULTI
Uses both models and switches between them
- class byotrack.implementation.linker.icy_emht.icy_emht.EMHTParameters(detections_fpr: float = 0.1, detections_fnr: float = 0.1, expected_track_length: int = -1, expected_initial_particles: int = -1, expected_new_particles: int = 10, existence_prob: float = 0.5, termination_prob: float = 0.0001, motion: Motion = Motion.BROWNIAN, use_most_likely_model: bool = True, update_motion_1: bool = False, update_motion_2: bool = False, xy_std_1: float = 3.0, z_std_1: float = 3.0, xy_std_2: float = 3.0, z_std_2: float = 3.0, inertia: float = 0.8, gate_factor: float = 4.0, tree_depth: int = 4)
Bases:
objectParameters of EMHT algorithm [4].
- detections_fpr
Estimation of the false positive rate of the detection process Default: 0.1
- Type:
- detections_fnr
Estimation of the false negative rate of the detection process Default: 0.1
- Type:
- expected_track_length
Expected length of tracks. If negative, it defaults to the sequence size Default: -1
- Type:
- expected_initial_particles
Estimation of the number of particles in the first frames. If negative, it defaults to the average number of detections by frame in the sequence Default: -1
- Type:
- motion
Motion of the particles (Brownian vs Directed vs Multi). If MULTI, motion 1 is brownian and motion 2 is directed. Default: Motion.BROWNIAN
- Type:
- use_most_likely_model
Use the most likely model to predict rather than a weighted predictions Default: True
- Type:
- update_motion_{1, 2}
Use an adaptative process covariance, depending on previous prediction errors.
- Type:
- xy_std_{1,2}
Used to define the covariance (Q) of the process. (Looking at Icy code, it is not clear what they truly are, depending on the motion the covariance Q is set a bit weirdly) Default: 3.0
- Type:
- z_std_{1,2}
Same as xy_std but for the 3d axes (if any) Default: 3.0
- Type:
- to_xml(detections_sequence: Sequence[byotrack.Detections]) ET.ElementTree
Convert to xml format used by Icy.
Format example:
<root> <MHTconfiguration> <detectionInput detectionRate="0.9" detectionSource="noSource" numberFalseDetection="20"/> <targetExistence confirmationThreshold="0.5" terminationThreshold="1.0E-4" trackLength="200"/> <motionModel IMMinertia="0.8" isDirectedMotion_1="true" isDirectedMotion_2="true" isMostLikelyModel="true" isSingleMotion="false" updateCovariance_2="false" updateMotion_1="true" yxDisplacement_1="2" yxDisplacement_2="3" zDisplacement_1="2" zDisplacement_2="3"/> <mht gateFactor="4" mhtDepth="4" numberNewObjects="10" numberObjectsFirstFrame="50"/> <output trackGroupName="mht-tracks-1"/> </MHTconfiguration> </root>
- Parameters:
detections_sequence (Sequence[byotrack.Detections]) – Detections (Required to set default values for some parameters)
- Returns:
Xml tree of the configuration
- Return type:
- class byotrack.implementation.linker.icy_emht.icy_emht.IcyEMHTLinker(icy_path: str | os.PathLike | None = None, full_specs: EMHTParameters | None = None, timeout: float | None = None)
Bases:
LinkerRun EMHT [4] from Icy [1].
It is a wrapper around Icy’s tracking code. It supports 2D and 3D data.
About EMHT: It is a probabilistic tracking that uses statistical motion model on particles. It uses multiple kalman filters for each particle allowing a particle to have several mode of motions. It also keeps multiple hypothesis of tracking at each frame so that a final detections linking decision is made after seeing several frames in the past and future of these detections.
Here we rely on the handmade protocol “emht_protocol” that expects detections as a valid rois file for icy and some hyperparameters.
The workflow is:
Detections to rois in Icy format
Run the Icy protocol
[In ICY] Read rois, estimate or load emht parameters, run emht, export tracks to xml
Read Icy tracks and return
Note
This implementation requires Icy to be installed (https://icy.bioimageanalysis.org/download/) You should also install the Spot Tracking Blocks plugin (https://icy.bioimageanalysis.org/tutorial/how-to-install-an-icy-plugin/)
- runner
Icy runner
- Type:
byotrack.icy.IcyRunner
- motion
Prior on the underlying motion model (Brownian vs Directed vs Both) Given to the Icy block that estimates EMHT parameters. (See full_specs and EMHTParameters to have a finegrained control over the algorithm parameters) Default: Motion.BROWNIAN
- Type:
- full_specs
Full specification of the algorithm. If not provided, we use the estimation of EMHT parameters provided by Icy (with motion the only parameter to set).
- Type:
EMHTParameters | None
- run(video, detections_sequence: Sequence[byotrack.Detections]) list[byotrack.Track]
Run the linker on a whole video.
- Parameters:
video (Sequence[np.ndarray] | np.ndarray) – Sequence of T frames (array). Each array is expected to have a shape ([D, ]H, W, C)
detections_sequence (Sequence[byotrack.Detections]) – Detections for each frame Detections is expected for each frame of the video, in the same order. (Note that for a given frame, the Detections can be empty)
- Returns:
Tracks of particles
- Return type:
Collection[byotrack.Track]