pept.processing.LaceyColors#

class pept.processing.LaceyColors(p1, p2, ax1=None, ax2=None, basis1=None, basis2=None, xlim=None, ylim=None, max_distance=10, resolution=(8, 8))[source]#

Bases: Reducer

Compute Lacey-like mixing image, with streamlines passing through plane 1 being split into Red and Blue tracers, then evaluated into RGB pixels at a later point in plane 2.

Intuitively, red and blue pixels will contain unmixed streamlines, while purple pixels will indicate mixing.

Reducer signature:

       PointData -> LaceyColors.fit -> (height, width, 3) pept.Voxels
 list[PointData] -> LaceyColors.fit -> (height, width, 3) pept.Voxels
list[np.ndarray] -> LaceyColors.fit -> (height, width, 3) pept.Voxels

Each sample in the input `PointData` is treated as a separate streamline / tracer pass. You can group passes using `Segregate + GroupBy(“label”)`.

The first plane where tracers are split into Red and Blue streamlines is defined by a point p1 and direction axis ax1. The point `p1` should be the middle of the pipe.

The second plane where mixing is evaluated is similarly defined by p2 and ax2. The point `p2` should be the middle of the volume / pipe.

If the direction vectors ax1 and ax2 are undefined (None), the tracers are assumed to follow a straight line between p1 and p2.

The max_distance parameter defines the maximum distance allowed between a point and a plane to be considered part of it. The resolution defines the number of pixels in the height and width of the resulting image.

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 LaceyColors reducer can be used to create an image of the mixing between the pipe entrance and exit:

>>> from pept.processing import LaceyColors
>>> entrance = [-100, 0, 0]     # Pipe data was aligned with X and centred
>>> exit = [100, 0, 0]
>>> lacey_image = LaceyColors(entrance, exit).fit(streamlines)
>>> print(lacey_image.voxels)    # RGB channels of image
(8, 8, 3)

Now the image can be visualised e.g. with Plotly:

>>> from pept.plots import PlotlyGrapher2D
>>> PlotlyGrapher2D().add_image(lacey_image).show()
__init__(p1, p2, ax1=None, ax2=None, basis1=None, basis2=None, xlim=None, ylim=None, max_distance=10, resolution=(8, 8))[source]#

Methods

__init__(p1, p2[, ax1, ax2, basis1, basis2, ...])

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.

fit(trajectories, executor='joblib', max_workers=None, verbose=True)[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")