2.3. ECT

class ect.ect.ECT(directions=None, num_dirs=None, num_thresh=None, bound_radius=None, thresholds=None, dtype=<class 'numpy.int32'>)[source]

A class to calculate the Euler Characteristic Transform (ECT) from an input ect.embed_complex.EmbeddedComplex, using a set of directions to project the complex onto and thresholds to filter the projections.

The result is a matrix where entry M[i,j] is \(\chi(K_{a_i})\) for the direction \(\omega_j\) where \(a_i\) is the ith entry in self.thresholds, and \(\omega_j\) is the jth entry in self.directions.

Example

>>> from ect import ECT, EmbeddedComplex
>>> from ect import EmbeddedGraph
>>> complex = EmbeddedComplex()
>>> complex.add_node(0, [0, 0])
>>> complex.add_node(1, [1, 0])
>>> complex.add_edge(0, 1)
>>> ect = ECT(num_dirs=10, num_thresh=10) # chooses 10 uniform directions and 10 thresholds
>>> result = ect.calculate(complex)
>>> result.plot()
__init__(directions=None, num_dirs=None, num_thresh=None, bound_radius=None, thresholds=None, dtype=<class 'numpy.int32'>)[source]

Initialize ECT calculator with either a Directions object or sampling parameters

Parameters:
  • directions – Optional pre-configured Directions object

  • num_dirs – Number of directions to sample (ignored if directions provided)

  • num_thresh – Number of threshold values (required if directions not provided)

  • bound_radius – Optional radius for bounding circle

  • thresholds – Optional array of thresholds

  • dtype – Data type for output array

calculate(graph, theta=None, override_bound_radius=None)[source]
class ect.sect.SECT(directions=None, num_dirs=None, num_thresh=None, bound_radius=None, thresholds=None, dtype=<class 'numpy.float32'>)[source]

A class to calculate the Smooth Euler Characteristic Transform (SECT). Inherits from ECT and applies smoothing to the final result.

__init__(directions=None, num_dirs=None, num_thresh=None, bound_radius=None, thresholds=None, dtype=<class 'numpy.float32'>)[source]

Initialize SECT calculator with smoothing parameter

Parameters:
  • directions – Optional pre-configured Directions object

  • num_dirs – Number of directions to sample (ignored if directions provided)

  • num_thresh – Number of threshold values (required if directions not provided)

  • bound_radius – Optional radius for bounding circle

  • thresholds – Optional array of thresholds

  • dtype – Data type for output array

calculate(graph, theta=None, override_bound_radius=None)[source]

Calculate Smooth Euler Characteristic Transform (SECT)

Parameters:
  • graph – The input graph to calculate the SECT for

  • theta – The angle in [0,2π] for the direction to calculate the SECT

  • override_bound_radius – Optional override for bounding radius

Returns:

The smoothed transform result containing the matrix,

directions, and thresholds

Return type:

ECTResult

class ect.dect.DECT(directions=None, num_dirs=None, num_thresh=None, bound_radius=None, thresholds=None, dtype=<class 'numpy.float32'>, scale=10.0)[source]

A class to calculate the Differentiable Euler Characteristic Transform (DECT)

__init__(directions=None, num_dirs=None, num_thresh=None, bound_radius=None, thresholds=None, dtype=<class 'numpy.float32'>, scale=10.0)[source]

Initialize a Differentiable Euler Characteristic Transform (DECT) calculator.

Parameters:
  • directions (Optional[Directions]) – Directions for the transform. If None, directions are generated automatically.

  • num_dirs (Optional[int]) – Number of directions to use. If None, determined from directions or defaults.

  • num_thresh (Optional[int]) – Number of thresholds to use. If None, determined from data or defaults.

  • bound_radius (Optional[float]) – Bounding radius for threshold generation. If None, computed from input.

  • thresholds (Optional[np.ndarray]) – Array of threshold values. If None, thresholds are generated automatically.

  • dtype – Data type for computation (default: np.float32).

  • scale (float) – Slope parameter for the sigmoid function controlling smoothness (default: 10.0).

Notes

  • The scale parameter controls the sharpness of the sigmoid transition in the DECT calculation.

  • All other parameters are passed to the parent ECT.

calculate(graph, scale=None, theta=None, override_bound_radius=None)[source]

Calculate the Differentiable Euler Characteristic Transform (DECT) for a given embedded complex.

Parameters:
  • graph (EmbeddedGraph or EmbeddedCW) – The embedded complex to analyze.

  • scale (Optional[float]) – Slope parameter for the sigmoid function. If None, uses the instance’s scale.

  • theta (Optional[float]) – Specific direction angle to use. If None, uses all directions.

  • override_bound_radius (Optional[float]) – Override for bounding radius in threshold generation.

Returns:

Result object containing the DECT matrix, directions, and thresholds.

Return type:

ECTResult

Notes

  • Uses _compute_directional_transform() for the core DECT calculation.

  • The DECT matrix is computed for all directions and thresholds specified.