pept.tracking.Reconnect#

class pept.tracking.Reconnect(tmax, dmax, column='label', num_points=10, **signatures)[source]#

Bases: Reducer

Best-fit trajectory segment reconstruction based on time, distance and arbitrary tracer signatures.

Reducer signature:

      pept.PointData -> Segregate.fit -> pept.PointData
list[pept.PointData] -> Segregate.fit -> pept.PointData
       numpy.ndarray -> Segregate.fit -> pept.PointData

After a trajectory segregation step (e.g. using Segregate), you may be left with multiple smaller trajectory segments. Some trajectories can be reconstructed even when losing the tracers for a bit.

When a tracer is lost for less than tmax time and dmax distance, its trajectory segments are reconnected; if multiple condidates are possible, the best fit is used.

Multiple tracer signatures can be used to improve the reconnection step; supply them as data column names and difference thresholds, e.g. an extra keyword argument v = 1 will join trajectories whose difference in velocity is smaller than 1 m/s.

The last num_points points on a segment are averaged before they are connected with the first num_points on another segment.

New in pept-0.4.2

Examples

Reconnect segments that are closer than 1 second in time and 0.1 m apart:

>>> from pept.tracking import *
>>> trajectories = Reconnect(tmax = 1000, dmax = 100).fit(segments)

You can use the cluster_size (set by the Centroids filter) as a tracer signature; allow segments to be reconnected if the difference in their cluster size is < 100:

>>> trajectories = Reconnect(1000, 100, cluster_size = 100).fit(segments)

And a velocity v difference < 0.1:

>>> Reconnect(1000, 100, cluster_size = 100, v = 0.1).fit(segments)
__init__(tmax, dmax, column='label', num_points=10, **signatures)[source]#

Methods

__init__(tmax, dmax[, column, num_points])

copy([deep])

Create a deep copy of an instance of this class, including all inner attributes.

fit(points)

load(filepath)

Load a saved / pickled PEPTObject object from filepath.

save(filepath)

Save a PEPTObject instance as a binary pickle object.

fit(points)[source]#
copy(deep=True)#

Create a deep copy of an instance of this class, including all inner attributes.

static load(filepath)#

Load a saved / pickled PEPTObject object from filepath.

Most often the full object state was saved using the .save method.

Parameters
filepathfilename or file handle

If filepath is a path (rather than file handle), it is relative to where python is called.

Returns
pept.PEPTObject subclass instance

The loaded object.

Examples

Save a LineData instance, then load it back:

>>> lines = pept.LineData([[1, 2, 3, 4, 5, 6, 7]])
>>> lines.save("lines.pickle")
>>> lines_reloaded = pept.LineData.load("lines.pickle")
save(filepath)#

Save a PEPTObject instance as a binary pickle object.

Saves the full object state, including inner attributes, in a portable binary format. Load back the object using the load method.

Parameters
filepathfilename or file handle

If filepath is a path (rather than file handle), it is relative to where python is called.

Examples

Save a LineData instance, then load it back:

>>> lines = pept.LineData([[1, 2, 3, 4, 5, 6, 7]])
>>> lines.save("lines.pickle")
>>> lines_reloaded = pept.LineData.load("lines.pickle")