pept.tracking.Voxelize#

class pept.tracking.Voxelize(number_of_voxels, xlim=None, ylim=None, zlim=None, set_lims=None)[source]#

Bases: LineDataFilter

Asynchronously voxelize samples of lines from a pept.LineData.

Filter signature:

LineData -> Voxelize.fit_sample -> PointData

This filter is much more memory-efficient than voxelizing all samples of LoRs at once - which often overflows the available memory. Most often this is used alongside voxel-based tracking algorithms, e.g. pept.tracking.FPI:

>>> from pept.tracking import *
>>> pipeline = pept.Pipeline([
>>>     Voxelize((50, 50, 50)),
>>>     FPI(3, 0.4),
>>>     Stack(),
>>> ])
Parameters
number_of_voxels3-tuple

A tuple-like containing exactly three integers specifying the number of voxels to be used in each dimension.

xlim(2,) list[float], optional

The lower and upper boundaries of the voxellised volume in the x-dimension, formatted as [x_min, x_max]. If undefined, it is inferred from the bounding box of each sample of lines.

ylim(2,) list[float], optional

The lower and upper boundaries of the voxellised volume in the y-dimension, formatted as [y_min, y_max]. If undefined, it is inferred from the bounding box of each sample of lines.

zlim(2,) list[float], optional

The lower and upper boundaries of the voxellised volume in the z-dimension, formatted as [z_min, z_max]. If undefined, it is inferred from the bounding box of each sample of lines.

set_lims(N, 7) numpy.ndarray or pept.LineData, optional

If defined, set the system limits upon creating the class to the bounding box of the lines in set_lims.

__init__(number_of_voxels, xlim=None, ylim=None, zlim=None, set_lims=None)[source]#

Methods

__init__(number_of_voxels[, xlim, ylim, ...])

copy([deep])

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

fit(line_data[, executor, max_workers, verbose])

Apply self.fit_sample (implemented by subclasses) according to the execution policy.

fit_sample(sample_lines)

load(filepath)

Load a saved / pickled PEPTObject object from filepath.

save(filepath)

Save a PEPTObject instance as a binary pickle object.

set_lims(lines[, set_xlim, set_ylim, set_zlim])

Attributes

number_of_voxels

xlim

ylim

zlim

set_lims(lines, set_xlim=True, set_ylim=True, set_zlim=True)[source]#
property number_of_voxels#
property xlim#
property ylim#
property zlim#
fit_sample(sample_lines)[source]#
copy(deep=True)#

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

fit(line_data, executor='joblib', max_workers=None, verbose=True)#

Apply self.fit_sample (implemented by subclasses) according to the execution policy. Simply return a list of processed samples. If you need a reduction step (e.g. stack all processed samples), apply it in the subclass.

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")