locan.analysis.localization_property.LocalizationProperty#

class locan.analysis.localization_property.LocalizationProperty(meta=None, loc_property='intensity', index=None)[source]#

Bases: _Analysis

Analyze localization property with respect to probability density or variation over a specified index.

Parameters:
  • meta (locan.analysis.metadata_analysis_pb2.AMetadata) – Metadata about the current analysis routine.

  • loc_property (str) – The property to analyze.

  • index (str | None) – The property name that should serve as index (i.e. x-axis in x-y-plot)

Variables:
  • count (int) – A counter for counting instantiations (class attribute).

  • parameter (dict[str, Any]) – A dictionary with all settings for the current computation.

  • meta (locan.analysis.metadata_analysis_pb2.AMetadata) – Metadata about the current analysis routine.

  • results (pandas.DataFrame) – Computed results.

  • distribution_statistics (Distribution_stats | None) – Distribution parameters derived from MLE fitting of results.

Methods

__init__([meta, loc_property, index])

compute(locdata)

Run the computation.

fit_distributions([distribution, ...])

Fit probability density functions to the distributions of loc_property values in the results using MLE (scipy.stats).

hist([ax, bins, log, fit])

Provide histogram as matplotlib.axes.Axes object showing hist(results).

plot([ax, window])

Provide plot as matplotlib.axes.Axes object showing the running average of results over window size.

report(*args, **kwargs)

Show a report about analysis results.

Attributes

count

A counter for counting Analysis class instantiations (class attribute).

compute(locdata)[source]#

Run the computation.

Parameters:

locdata (LocData) – Localization data.

Return type:

Self

fit_distributions(distribution=<scipy.stats._continuous_distns.expon_gen object>, with_constraints=True, **kwargs)[source]#

Fit probability density functions to the distributions of loc_property values in the results using MLE (scipy.stats).

If with_constraints is true we put the following constraints on the fit procedure: If distribution is expon then floc=np.min(self.analysis_class.results[self.loc_property].values).

Parameters:
  • distribution (str | rv_continuous) – Distribution model to fit.

  • with_constraints (bool) – Flag to use predefined constraints on fit parameters.

  • kwargs (Any) – Other parameters are passed to scipy.stat.distribution.fit().

Return type:

None

hist(ax=None, bins='auto', log=True, fit=True, **kwargs)[source]#

Provide histogram as matplotlib.axes.Axes object showing hist(results). Nan entries are ignored.

Parameters:
  • ax (Optional[Axes]) – The axes on which to show the image

  • bins (int | Sequence[int | float] | str) – Bin specifications (passed to matplotlib.hist()).

  • log (bool) – Flag for plotting on a log scale.

  • fit (Optional[bool]) – Flag indicating if distribution fit is shown. The fit will only be computed if distribution_statistics is None.

  • kwargs (Any) – Other parameters passed to matplotlib.pyplot.hist().

Returns:

Axes object with the plot.

Return type:

matplotlib.axes.Axes

plot(ax=None, window=1, **kwargs)[source]#

Provide plot as matplotlib.axes.Axes object showing the running average of results over window size.

Parameters:
  • ax (matplotlib.axes.Axes) – The axes on which to show the image

  • window (int) – Window for running average that is applied before plotting.

  • kwargs (Any) – Other parameters passed to matplotlib.pyplot.plot().

Returns:

Axes object with the plot.

Return type:

matplotlib.axes.Axes