spd_learn.modules.TimeFrequencyCovariances#
- class spd_learn.modules.TimeFrequencyCovariances(segments: Sequence[tuple[int, int, int]], *, center: bool = False, shrinkage: float = 0.0, ridge: float = 1e-05)[source]#
Bases:
ModuleEstimate covariance matrices from ordered filter-bank windows.
See [Ju and Guan, 2024].
- Parameters:
segments (sequence of tuple) – Ordered (band, start, stop) windows in samples; stop is exclusive.
center (bool, default=False) – Subtract each channel mean within its window.
shrinkage (float, default=0.0) – Mixture weight of the trace-scaled identity, in [0, 1].
ridge (float, default=1e-05) – Positive absolute loading in squared signal units.
Notes
Without centering this computes a second moment, using divisor window length. Leading trials and channel order are preserved; filtering is external.
- forward(input: Tensor) Tensor[source]#
Estimate one covariance matrix per window.
- Parameters:
input (torch.Tensor) – Filtered trials of shape (batch, bands, channels, samples).
- Returns:
Covariances of shape (batch, nodes, channels, channels).
- Return type: