braintools.input.Smoothed

braintools.input.Smoothed#

class braintools.input.Smoothed(input_obj, tau)#

Exponentially smoothed version of an input.

Applies exponential smoothing (low-pass filtering) to an input, useful for removing sharp transitions or high-frequency noise.

Parameters:
  • input_obj (Input) – The input to smooth.

  • tau (float | Quantity) – Smoothing time constant. Larger values give more smoothing.

Notes

Implements exponential smoothing: y[t] = alpha * x[t] + (1 - alpha) * y[t-1] where alpha = dt / tau.

The cutoff frequency is approximately 1 / (2 * pi * tau).

Examples

>>> # Sharp steps
>>> steps = Step([0, 1, 0.5, 1, 0],
...                   [0, 50, 100, 150, 200],
...                   250 * u.ms)
>>>
>>> # Light smoothing (fast response)
>>> light = Smoothed(steps, 5 * u.ms)
>>>
>>> # Heavy smoothing (slow response)
>>> heavy = Smoothed(steps, 25 * u.ms)
>>>
>>> # Usually created via smooth() method
>>> smooth = steps.smooth(10 * u.ms)
__init__(input_obj, tau)[source]#

Initialize smoothed input.

Parameters:
  • input_obj (Input) – The input to smooth.

  • tau (float | Quantity) – Smoothing time constant.

Methods

__init__(input_obj, tau)

Initialize smoothed input.

apply(func)

Apply a custom function to the input.

clip([min_val, max_val])

Clip the input values to a range.

generate()

Generate the smoothed input.

repeat(n_times)

Repeat the input pattern n times.

scale(factor)

Scale the input by a factor.

shift(time_shift)

Shift the input in time.

smooth(tau)

Apply exponential smoothing to the input.

Attributes

dt

Get the time step from global environment.

n_steps

Get the number of time steps.

shape

Get the shape of the input array.