Skip to content

scalartools

LATFilter

Bases: ScalarFilter

Extract LATs (local activation times) from the input scalars using a threshold.

Parameters:

Name Type Description Default
threshold float

Voltage threshold for activation. Defaults to -50.

-50.0
dtime float

Time between samples (ms). Defaults to 1.

1.0

dtime: float = dtime instance-attribute

threshold: float = threshold instance-attribute

__init__(threshold=-50.0, dtime=1.0)

Initialize the LATFilter with a voltage threshold and sample interval.

Parameters:

Name Type Description Default
threshold float

Voltage threshold for activation. Defaults to -50.0.

-50.0
dtime float

Time between samples in milliseconds. Defaults to 1.0.

1.0

apply(scalars)

Compute the local activation times (LATs) for each point.

Parameters:

Name Type Description Default
scalars ndarray

Input scalar array with shape (points, timepoints).

required

Returns:

Type Description
ndarray

np.ndarray: LAT array with shape (n_points, n_lats), NaN where no LAT detected.

MovingAverage

Bases: ScalarFilter

Apply a moving average filter to the input signal(s).

Parameters:

Name Type Description Default
window_length int

Length of the moving average window. Defaults to 5.

5
mode str

Convolution mode. Defaults to "same".

'same'

mode: str = mode instance-attribute

window_length: int = window_length instance-attribute

__init__(window_length=5, mode='same')

Initializes MovingAverage filter with a windowlenght and convolution mode.

Parameters:

Name Type Description Default
window_length int

Length of the moving average window. Defaults to 5.

5
mode str

Convolution mode. Defaults to "same".

'same'

apply(scalars)

Smooth the signal using a moving average.

Parameters:

Name Type Description Default
scalars ndarray

Input scalar array with shape (points, timepoints).

required

Returns:

Type Description
ndarray

np.ndarray: Filtered scalar array with the same shape.

Normalize

Bases: ScalarFilter

Normalize input scalar signal(s) to range [0, 1].

apply(scalars)

Normalize the scalar array to [0, 1].

Parameters:

Name Type Description Default
scalars ndarray

Input scalar array.

required

Returns:

Type Description
ndarray

np.ndarray: Normalized scalar array.

PhaseInterpolator

Bases: ScalarInterpolator

Interpolate and smooth LAT phase values over spatial coordinates.

period: float | None = period instance-attribute

sigma: float = sigma instance-attribute

__init__(period=None, sigma=1.0)

Initialize the PhaseInterpolator object.

Parameters:

Name Type Description Default
period float | None

Period of the phase signal. Defaults to None.

None
sigma float

Standard deviation of the kernel for smoothing. Defaults to 1.0.

1.0

apply(scalars, coords)

Smooth LAT values based on spatial coordinates using a Gaussian kernel.

Parameters:

Name Type Description Default
scalars ndarray

Array of LAT values, possibly containing NaNs.

required
coords ndarray

Array of spatial coordinates with shape (N, 3).

required

Returns:

Type Description
ndarray

np.ndarray: Smoothed and interpolated LAT values.