mne_rt.combiners.WeightedSumCombiner#

class mne_rt.combiners.WeightedSumCombiner(weights: dict[str, float])[source]#

Bases: FeatureCombiner

Weighted linear combination of feature values.

Computes the weight-normalised linear blend:

mixed = Σ(wᵢ · xᵢ) / Σ(wᵢ)

where the sum runs only over features present in values. Normalising by the sum of active weights means the result is unaffected by how many features are missing in a given window.

Parameters:
weightsdict[str, float]

Mapping of {modality_name: weight}. Weights do not need to sum to 1 — they are normalised internally. Negative weights are allowed (e.g. to subtract one feature from another). Features absent from values at call time are silently skipped.

Notes

Returns 0.0 if none of the specified features are present in values, with a warnings message.

Examples

Alpha-power minus frontal asymmetry:

from mne_rt.combiners import WeightedSumCombiner

combiner = WeightedSumCombiner(
    weights={"sensor_power": 0.6, "laterality": 0.4}
)
mixed = combiner.combine({"sensor_power": 1.5, "laterality": 0.3})
# mixed ≈ 0.6*1.5/1.0 + 0.4*0.3/1.0 = 1.02

Suppressing one feature (negative weight):

combiner = WeightedSumCombiner(
    weights={"sensor_power": 1.0, "entropy": -0.5}
)
__init__(weights: dict[str, float]) None[source]#

Methods

__init__(weights)

combine(values)

Return the normalised weighted sum of available feature values.

combine(values: dict[str, float]) float[source]#

Return the normalised weighted sum of available feature values.