goofi v3.0.0

FractalDimension

Fractal dimension: how much the trace fills the plane.

Explore this node in the cookbook →

1 is a smooth line, 2 a trace that fills it.

FractalDimension py
data
dimension
Type name
signal:FractalDimension
Plane
signal
Tags
analysis
Language
python
Tier
in-process
Bundle
complexity
Source
node-bundles/complexity/fractal_dimension.py
Availability
available

Slots

SlotDirectionType
datainputARRAY
dimensionoutputARRAY

Parameters

fractal

NameTypeDefaultRangeDoc
methodstringpetrosianpetrosian | katz | higuchiPetrosian counts turns, Katz measures path length, Higuchi reads several scales.
kmaxint102 … 100Higuchi only: the coarsest scale read.

Source

The current source of this node, as it stands in the goofi repository at node-bundles/complexity/fractal_dimension.py.

node-bundles/complexity/fractal_dimension.py
"""FractalDimension — how much a signal's trace fills the plane, from antropy.

A smooth curve scores near 1 and a trace that fills its box approaches 2. Three estimators
under one `method`: Petrosian counts turns, Katz measures path length, Higuchi reads the length
at several scales and is the slowest. The last axis is time and is consumed; every axis before
it survives.
"""

import antropy
import numpy as np
import goofi


class FractalDimension(goofi.Node):
    """Fractal dimension: how much the trace fills the plane.

    1 is a smooth line, 2 a trace that fills it.
    """

    TAGS = ["analysis"]
    INPUTS = {"data": goofi.InputSlot(goofi.DataType.ARRAY, required=True)}
    OUTPUTS = {"dimension": goofi.DataType.ARRAY}
    PARAMS = {
        "fractal": {
            "method": goofi.StringParam(
                "petrosian",
                ["petrosian", "katz", "higuchi"],
                doc="Petrosian counts turns, Katz measures path length, Higuchi reads several scales.",
            ),
            "kmax": goofi.IntParam(10, 2, 100, doc="Higuchi only: the coarsest scale read."),
        }
    }

    def process(self, data):
        p = self.params.fractal
        x = np.asarray(data.data, dtype=np.float64)
        if p.method == "higuchi":
            out = np.apply_along_axis(antropy.higuchi_fd, -1, x, kmax=p.kmax)
        else:
            measure = antropy.katz_fd if p.method == "katz" else antropy.petrosian_fd
            out = measure(x, axis=-1)
        return np.asarray(out, dtype=np.float32), data.drop_axis(-1)

← All nodes