playnano.analysis.base module

The base class that every analysis module subclasses.

class playnano.analysis.base.AnalysisModule[source]

Bases: ABC

Base class for analysis modules.

An analysis module measures something in a stack (for example, detecting features or tracking particles) and returns its results as a dict. AnalysisPipeline runs modules in order. Built-in modules are in playnano.analysis.modules; plugins are registered under the playnano.analysis entry point group.

A subclass must define:

  • name: the name used to add the module to a pipeline.

  • run(): the analysis.

and can set these class attributes:

  • version (str): recorded in the provenance of each step.

  • requires (list of str): names of modules, at least one of which must run earlier in the pipeline; the pipeline raises RuntimeError otherwise.

abstract property name: str

Name used to add the module to a pipeline, for example "feature_detection".

Must be unique among the installed modules.

abstractmethod run(stack: AFMImageStack, previous_results: dict[str, Any] | None = None, **params) → dict[str, Any][source]

Run the analysis on a stack.

Parameters:
  • stack (AFMImageStack) – The stack to analyse.

  • previous_results (dict, optional) – Outputs of the modules run earlier in the pipeline: each module name mapped to the dict its latest run returned. Default is None.

  • **params – Parameters of this module, as given to add().

Returns:

Outputs, keyed by str. The values can be anything, for example:

{"features_per_frame": [...], "summary": {"total_features": 23}}

Later modules receive this dict through previous_results.

Return type:

dict