playnano.analysis.modules.count_nonzero module

Analysis module for counting non-zero data points in an array.

class playnano.analysis.modules.count_nonzero.CountNonzeroModule[source]

Bases: AnalysisModule

Count non-zero pixels in each frame of an AFMImageStack.

This simple analysis module computes the number of non-zero pixels per frame and returns the result as a 1D array.

Version

0.1.0

Examples

>>> module = CountNonzeroModule()
>>> result = module.run(stack)
>>> result['counts'].shape
(n_frames,)
property name: str

Name of the analysis module.

Returns:

The string identifier for this module.

Return type:

str

run(stack, previous_results=None, **params) dict[str, Any][source]

Count non-zero pixels per frame in the AFMImageStack.

Parameters:
  • stack (AFMImageStack) – Stack of AFM frames with .data of shape (n_frames, H, W).

  • previous_results (dict[str, Any], optional) – Ignored by this module. Included for API compatibility.

  • **params (dict) – Additional parameters (unused).

Returns:

Dictionary with key:

  • ”counts”: np.ndarray of shape (n_frames,), number of non-zero pixels per frame.

Return type:

dict

version = '0.1.0'