pept.tracking.GaussianDensity#
- class pept.tracking.GaussianDensity(sigma=None)[source]#
Bases:
Filter
Append weights according to the Gaussian distribution that best fits the samples of points.
Filter signature:
PointData -> GaussianDensity.fit_sample -> PointData numpy.ndarray -> GaussianDensity.fit_sample -> PointData list[PointData] -> GaussianDensity.fit_sample -> list[PointData]
This is treated as an optimisation problem: find the 3D location that maximises the sum of Probability Distributions (PDF) centered at each point.
Given N points p_1, p_2, ..., p_N: N maximise sum( exp( -0.5 * |x - p_i|^2 / sigma^2 ) ) x i
Each point is then assigned a weight corresponding to its PDF - i.e. the exponential part - saved in the weight column.
Sigma controls the standard deviation of the Gaussian distribution centred at each point; this corresponds to the relative uncertainty in each point’s location. For
TimeOfFlight
data, leave sigma = None and it will be computed from the “spatial_resolution” attribute.You can use
Centroids
afterwards to compute the weighted centroid, i.e. where the tracer is. For multiple particle tracking (or just more robustness to noise) you can use HDBSCAN + SplitLabels beforehand.New in pept-0.4.2
Methods
__init__
([sigma])copy
([deep])Create a deep copy of an instance of this class, including all inner attributes.
fit
(samples[, executor, max_workers, verbose])Apply self.fit_sample (implemented by subclasses) according to the execution policy.
fit_sample
(points)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.
- fit(samples, 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
- 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")