pept.tracking.RemoveStatic#
- class pept.tracking.RemoveStatic(time_window, max_distance, quantile=0.9)[source]#
Bases:
Reducer
Remove parts of a PointData where the tracer remains static.
Reducer signature:
PointData -> OutOfViewFilter.fit -> PointData list[PointData] -> OutOfViewFilter.fit -> PointData numpy.ndarray -> OutOfViewFilter.fit -> PointData
If there is a time_window in which the tracer does not move more than max_distance, it is removed.
The distances moved are computed relative to the average position within each time window; to make the reducer more robust to noise, the given distance quantile is compared to max_distance.
New in pept-0.5.2
Examples
Given some trajectories from e.g. a long experiment where the particle may have got stuck at some points, we can remove the static windows with:
import pept import pept.tracking as pt trajectories = ... # Remove positions that spent more than 2 seconds without moving more # than 20 mm trajectories_nonstatic = RemoveStatic( time_window = 2000, max_distance = 20, ).fit(trajectories)
This reducer, like the rest in pept.tracking, can be chained into a pipeline, for example:
import pept import pept.tracking as pt pipeline = pept.Pipeline([ # Remove positions with high errors pt.Condition("error < 20"), # Remove tracers that got stuck pt.RemoveStatic(time_window = 2000, max_distance = 20), # Trajectory separation pt.Segregate(window = 20, cut_distance = 15), # Group each trajectory into its own sample, then stack them pt.GroupBy("label"), pt.Stack(), ])
Methods
__init__
(time_window, max_distance[, quantile])copy
([deep])Create a deep copy of an instance of this class, including all inner attributes.
fit
(samples)load
(filepath)Load a saved / pickled PEPTObject object from filepath.
save
(filepath)Save a PEPTObject instance as a binary pickle object.
- 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
- filepath
filename
orfile
handle
If filepath is a path (rather than file handle), it is relative to where python is called.
- filepath
- 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
- filepath
filename
orfile
handle
If filepath is a path (rather than file handle), it is relative to where python is called.
- filepath
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")