mufasa.nodes.detection.threshold#

Classes#

Threshold

Detect connected regions in a Map or BayesianMap.

Module Contents#

class mufasa.nodes.detection.threshold.Threshold(threshold: float, alarm_timeout_s: float = 0.0, dilation_px: int = 0, simplify_m: float = 0.0)#

Bases: mufasa.node.Node

Detect connected regions in a Map or BayesianMap.

Output type and accepted input type are resolved at wiring time from the predecessor’s output type:

  • BayesianMap predecessor → accepts BayesianMap, emits Observation (threshold compared against map.probabilities; confidence = mean probability across the region). Threshold must be in (0, 1).

  • Plain Map predecessor → accepts Map, emits Location (threshold compared against raw map.data; mean value stored in properties["mean_value"]).

Parameters:
  • threshold (float) – Detection threshold. For BayesianMap input must be in (0, 1).

  • alarm_timeout_s (float) – Minimum seconds between alarm bursts. 0 = alarm on every call (no accumulation, default).

  • dilation_px (int) – Morphological dilation radius in pixels applied before connected- component labelling. 0 = no dilation.

  • simplify_m (float) – Shapely simplification tolerance in CRS units (metres for UTM). 0 = no simplification.

threshold#
alarm_timeout_s = 0.0#
dilation_px = 0#
simplify_m = 0.0#
property output_type: type | None#

Type this node emits. Derived from _output_type.

Return type:

type | None

property input_types: frozenset#

Types this node accepts as input. Derived from _input_types.

Return type:

frozenset

__call__(*inputs: mufasa.node.Node) → mufasa.node.Node#
Parameters:

inputs (mufasa.node.Node)

Return type:

mufasa.node.Node

reset() → None#

Clear all runtime state, returning the node to its post-init condition.

Called by the framework between pipeline runs so the same node instance can process a fresh dataset without being reconstructed. Override in nodes that hold mutable state (buffers, accumulators, fitted models). The default is a no-op — stateless nodes need not override this.

Return type:

None

process() → list#

Process incoming data and forward results to successors.

Override with the signature appropriate for this node’s role:

Observation-consuming nodes receive one observation per call:

def process(self, obs: Observation) -> None:
    result = ...                    # compute result
    for succ in self._successors:
        succ.process(result)        # push to downstream nodes

Map-consuming nodes are called with no arguments and read their input from the predecessor via its .map attribute:

def process(self) -> None:
    m = self._predecessors[0].map   # read upstream map
    ...                             # update self.map in place
    self._trigger_successors()      # notify downstream nodes

Sink nodes collect data without emitting anything further:

def process(self, obs: Observation) -> None:
    self._collected.append(obs)
Return type:

list

get_config() → dict#

Return all constructor arguments as a plain JSON-serializable dict.

Used by Graph.to_config() to serialise the pipeline. Every key must be a string; every value must be JSON-serializable.

Return type:

dict