locan.analysis.drift.DriftComponent#
- class locan.analysis.drift.DriftComponent(type=None, **kwargs)[source]#
Bases:
object
Class carrying model functions to describe drift over time (in unit of frames). DriftComponent provides a transformation to apply a drift correction.
Standard models for constant, linear or polynomial drift correction are taken from
lmfit.models
. For fitting splines we use the scipy functionscipy.interpolate.splrep()
.- Parameters:
type (Literal["none", "zero", "one", "constant", "linear", "polynomial", "spline"] | lmfit.models.Model | None) – Model class or indicator for setting up the corresponding model class.
- Variables:
type – String indicator for model.
model (lmfit.models.Model | None) – The model definition (return value of
scipy.interpolate.splrep()
)model_result (lmfit.model.ModelResult, collection of model results.) – The results collected from fitting the model to specified data.
Methods
__init__
([type])eval
(x)Compute a transformation for time x from the drift model.
fit
(x, y[, verbose])Fit model to the given data and create self.model_results.
- eval(x)[source]#
Compute a transformation for time x from the drift model.
- Parameters:
x (
Union
[_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – frame values- Return type:
npt.NDArray[np.float64].
- fit(x, y, verbose=False, **kwargs)[source]#
Fit model to the given data and create self.model_results.
- Parameters:
x (
Union
[_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – x datay (
Union
[_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – y valuesverbose (
bool
) – show plotkwargs (
Any
) – Other parameters passed tolmfit.model.fit()
or toscipy.interpolate.splrep()
Use the parameter s to set the amount of smoothing.
- Return type:
Self