playnano.analysis.modules.tracked_particle_boundary_size module

Particle boundary size analysis module for the playNano analysis pipeline.

This module computes a per-particle boundary size metric over time by consuming the output of particle_region_extraction.

For each tracked particle and frame, the maximum dimension of the (tight) bounding box is recorded. Optionally, a threshold may be applied to classify each time point into a discrete state (e.g. compact vs extended).

The module is designed to integrate with the playNano AnalysisPipeline and records results in a provenance-aware, serializable format suitable for downstream analysis and plotting.

class playnano.analysis.modules.tracked_particle_boundary_size.BoundarySizeModule[source]

Bases: AnalysisModule

Measure particle boundary size over time from pre-extracted particle regions.

This module consumes output from ParticleRegionExtractionModule (registered as "particle_region_extraction" in the pipeline). It expects that module to have been run with include_bbox=True.

The boundary size metric is derived from the tight bounding box:

max_dim = max(bbox_height, bbox_width)

Optionally, a threshold can be applied to derive a discrete state variable (e.g. compact vs extended).

Parameters accepted in run()

extraction_modulestr, default "particle_region_extraction"

Name of the upstream extraction module in the pipeline.

thresholdfloat or None

If provided, each frame is classified as state = int(max_dim > threshold).

measurestr, default "bbox_max_dim"

Metric name (currently only "bbox_max_dim" is supported).

Notes

  • If a region entry is None (missing detection) or its bounding box is None, max_dim is recorded as np.nan.

  • If the upstream extraction module was run without include_bbox=True, a RuntimeError is raised.

property name: str

Module name for registration in the analysis pipeline.

requires = ['particle_region_extraction']
run(stack: Any, previous_results: Dict[str, Any] | None = None, *, extraction_module: str = 'particle_region_extraction', threshold: float | None = None, measure: str = 'bbox_max_dim') → Dict[str, Any][source]

Execute the boundary size analysis.

Parameters:
  • stack (AFMImageStack) – Input image stack (not used directly; present for pipeline API compatibility).

  • previous_results (dict, optional) – Results from earlier pipeline modules. Must contain output from extraction_module with include_bbox=True.

  • extraction_module (str, default "particle_region_extraction") – Key identifying the region extraction module output in previous_results.

  • threshold (float or None, optional) – Threshold applied to max_dim to compute a binary state variable. If None, no state classification is performed.

  • measure (str, default "bbox_max_dim") – Name of the boundary size metric. Currently only "bbox_max_dim" is supported.

Returns:

Keys:

measurestr

Name of the boundary size metric used.

thresholdfloat or None

Threshold used for state classification, or None.

per_tracklist of dict

Per-track time series. Each dict has:

  • "track_id" : int

  • "frames" : list of int

  • "timestamps" : list of float

  • "max_dim" : list of float (np.nan where absent)

  • "state" : list of int/float (only if threshold given)

flat_tablelist of dict

Row-per-frame representation suitable for pandas.DataFrame.

plot_hintsdict

Suggested plotting helper function names.

summarydict

Bookkeeping counters.

Return type:

dict

version = '0.1.0'