pept.tracking.CutpointsToF#

class pept.tracking.CutpointsToF(max_distance=None, cutoffs=None, append_indices=False, cutpoints_only=False)[source]#

Bases: LineDataFilter

Compute cutpoints from all pairs of lines whose Time Of Flight-predicted locations are closer than max_distance.

Filter signature:

LineData -> CutpointsToF.fit_sample -> PointData

If the TimeOfFlight filter was used and a temporal resolution was specified (as a FWHM), then max_distance is automatically inferred as the minimum between 2 * “spatial_resolution” and the dimension-wise standard deviation of the input points.

The cutoffs parameter may be set as [xmin, xmax, ymin, ymax, zmin, zmax] for a minimum bounding box outside of which cutpoints are discarded. Otherwise it is automatically set to the minimum bounding box containing all input LoRs.

If append_indices = True, two extra columns are appended to the result as “line_index1” and “line_index2” containing the indices of the LoRs that produced each cutpoint; an extra attribute “_lines” is also set to the input LineData.

If cutpoints_only = False (default), the Time Of Flight-predicted positron annihilation locations are also appended to the returned points.

New in pept-0.4.2

See also

pept.LineData

Encapsulate LoRs for ease of iteration and plotting.

pept.tracking.HDBSCAN

Efficient, HDBSCAN-based clustering of (cut)points.

pept.read_csv

Fast CSV file reading into numpy arrays.

Examples

Make sure to use the TimeOfFlight filter to compute to ToF annihilation locations; if you specify a temporal resolution, the max_distance parameter is automatically computed:

>>> import pept
>>> from pept.tracking import *
>>> line_data = pept.LineData(example_tof_data)
>>> line_data_tof = TimeOfFlight(100e-9).fit_sample(line_data)
>>> cutpoints_tof = CutpointsToF().fit_sample(line_data_tof)

Alternatively, set max_distance yourself:

>>> line_data = pept.LineData(example_tof_data)
>>> line_data_tof = TimeOfFlight().fit_sample(line_data)
>>> cutpoints_tof = CutpointsToF(5.0).fit_sample(line_data_tof)
__init__(max_distance=None, cutoffs=None, append_indices=False, cutpoints_only=False)[source]#

Methods

__init__([max_distance, cutoffs, ...])

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.

Attributes

append_indices

cutoffs

max_distance

property max_distance#
property cutoffs#
property append_indices#
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.

fit_sample(sample_lines: LineData)[source]#
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")