pept.processing.LaceyColorsLinear#
- class pept.processing.LaceyColorsLinear(directory, p1, p2, xlim=None, ylim=None, num_divisions=50, max_distance=10, resolution=(8, 8), height=1000, width=1000, prefix='frame')[source]#
Bases:
ReducerApply the LaceyColors mixing algorithm at num_divisions equidistant points between p1 and p2, saving images at each step in directory.
Reducer signature:
PointData -> LaceyColors.fit -> (height, width, 3) np.ndarray list[PointData] -> LaceyColors.fit -> (height, width, 3) np.ndarray list[np.ndarray] -> LaceyColors.fit -> (height, width, 3) np.ndarray
For details about the mixing algorithm itself, check the LaceyColors documentation.
The generated images (saved in directory with height x width pixels) can be stitched into a video using pept.plots.make_video.
New in pept-0.5.1
Examples
Consider a pipe-flow experiment, with tracers moving from side to side in multiple passes / streamlines. First locate the tracers, then split their trajectories into each individual pass:
>>> import pept >>> from pept.tracking import * >>> >>> split_pipe = pept.Pipeline([ >>> Segregate(window = 10, max_distance = 20), # Appends label column >>> GroupBy("label"), # Splits into samples >>> Reorient(), # Align with X axis >>> Center(), # Center points at 0 >>> Stack(), >>> ]) >>> streamlines = split_pipe.fit(trajectories)
Now each sample in streamlines corresponds to a single tracer pass, e.g. streamlines[0] is the first pass, streamlines[1] is the second. The passes were reoriented and centred such that the pipe is aligned with the X axis.
Now the LaceyColorsLinear reducer can be used to create images of the mixing between the pipe entrance and exit:
>>> from pept.processing import LaceyColorsLinear >>> entrance = [-100, 0, 0] # Pipe data was aligned with X and centred >>> exit = [100, 0, 0] >>> LaceyColorsLinear( >>> directory = "lacey", # Creates directory and saves images there >>> p1 = entrance, >>> p2 = exit, >>> ).fit(streamlines)
Now the directory “lacey” was created inside your current working folder, and all Lacey images saved there as “frame0000.png”, “frame0001.png”, etc. You can stitch all images together into a video using pept.plots.make_video:
>>> import pept >>> pept.plots.make_video("lacey/frame*.png", output = "lacey/video.avi")
- __init__(directory, p1, p2, xlim=None, ylim=None, num_divisions=50, max_distance=10, resolution=(8, 8), height=1000, width=1000, prefix='frame')[source]#
Methods
__init__(directory, p1, p2[, xlim, ylim, ...])copy([deep])Create a deep copy of an instance of this class, including all inner attributes.
fit(trajectories[, executor, max_workers, ...])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
filenameorfilehandle If filepath is a path (rather than file handle), it is relative to where python is called.
- filepath
- Returns
pept.PEPTObjectsubclassinstanceThe 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
filenameorfilehandle 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")