hsltools.dfa

Module Contents

Functions

calc_rms(x, scale)

windowed Root Mean Square (RMS) with linear detrending.

dfa(x, scale_lim=[5, 9], scale_dens=0.25, show=False)

Detrended Fluctuation Analysis - measures power law scaling coefficient

hsltools.dfa.calc_rms(x, scale)

windowed Root Mean Square (RMS) with linear detrending.

xnumpy.array

one dimensional data vector

scaleint

length of the window in which RMS will be calculaed

rmsnumpy.array

RMS data in each window with length len(x)//scale

hsltools.dfa.dfa(x, scale_lim=[5, 9], scale_dens=0.25, show=False)

Detrended Fluctuation Analysis - measures power law scaling coefficient of the given signal x. More details about the algorithm you can find e.g. here: Hardstone, R. et al. Detrended fluctuation analysis: A scale-free view on neuronal oscillations, (2012). Args: —–

xnumpy.array

one dimensional data vector

scale_lim = [5,9]list of length 2

boundaries of the scale, where scale means windows among which RMS is calculated. Numbers from list are exponents of 2 to the power of X, eg. [5,9] is in fact [2**5, 2**9]. You can think of it that if your signal is sampled with F_s = 128 Hz, then the lowest considered scale would be 2**5/128 = 32/128 = 0.25, so 250 ms.

scale_dens = 0.25float

density of scale divisions, eg. for 0.25 we get 2**[5, 5.25, 5.5, … ]

show = False

if True it shows matplotlib log-log plot.

scalesnumpy.array

vector of scales (x axis)

fluctnumpy.array

fluctuation function values (y axis)

alphafloat

estimation of DFA exponent

hsltools.dfa.n = 1000