ddd_pylib.tracking.

ObjectsTrackingOperator#

class ddd_pylib.tracking.ObjectsTrackingOperator[source]#

Bases: TrackingBase, ImageOperator

This operator performs tracking of nD+t labeled objects. It accepts an image with labeled objects and creates a new identical image with consistent labels across time points, based on the tracking strategy provided.

This operator is just a wrapper, you need to provide a tracking strategy to use it. For now, the only tracking strategy available is the TrackpyStrategy, which uses the trackpy library to perform tracking of points.

Example

from ddd_pylib.tracking import (
    TrackpyStrategy, 
    ObjectsTrackingOperator
)
from tifffile import imread
import numpy as np
import xarray as xr
from pathlib import Path
from ddd_pylib import ImageUtils

folder = Path("data-ddd-pylib")
im_name = "segmented_nuclei.tif"
dims = ["T", "Z", "Y", "X"]

im = xr.DataArray(
    imread(folder / im_name),
    dims = dims,
    name = im_name.split(".")[0],
    attrs = {
        "scale": {"T": 1.0, "Z": 0.3, "Y": 0.065, "X": 0.065},
        "units": {"T": "frame", "Z": "um", "Y": "um", "X": "um"}
    }
)

s = TrackpyStrategy()
s.setMemory(2.5) # using time units (seconds)
s.setSearchingDistance(1.5) # using spatial units (microns)
s.setAdaptiveStep(0.75)

ob_t = ObjectsTrackingOperator()
ob_t.setMainImage(im)
ob_t.setStrategy(s)
ob_t.run()

res = ob_t.getResult()
ImageUtils.writeTiff(
    folder / "results",
    res.astype(np.uint16)
)

Methods

getPrefix()[source]#

Prefix added to the input image name to generate the output image name.

Return type:

str

relabelWithTracks(labels, linked_df)[source]#
Parameters:
Return type:

DataArray