Skip to main content
. 2023 May 22;20(10):5913. doi: 10.3390/ijerph20105913
Algorithm 1 Multiscale entropy (MSE) computation
  • For each EEG channel, define a TS as X=[X(1),X(2),,X()] where is the number of EEG samples.

  • Fix m, the length of compared sub vectors

  • Choose τmin, Δτ, τmax, the minimum, maximum and increment values, resp., of the subsample vector τ.

  • for τ = τmin to τmax step Δτ do

  •  Subsample X for τmin,τ(2),,τmax

  •  Fix q sub TS from each EEG channel as X1=X(1),X(2),,Xq),…, Xq=[X(q),,X()].

  • for i=1 to q do

  •    Determine a variable threshold r(Xi) for each sub TS, Xi according to r(Xi))=0.2σ(Xi)

  •    Construct a sequence of m-long vectors as z={u(1), u(2), …, u(m+1)} as u(i)=[X(i)X(i+1)X(i+1m)]

  •    From the sequence z, calculate the number of u(j),j=N/τ such that its distance d(u(i),u(j)))=maxi|u(i)u(j)|<r(Xi)

  •    For ij, calculate the number of distances (denoted as #) within threshold r(X(i)) as Cim(r)=#d(u(i),u(j)))<rm+1

  •    Calculate the logarithmic average Φm(r)=1m+1i=1m+1ln(Cim(r))

  •    For each sub TS vector, compute Si=Φm(r)Φm+1(r) = 1m+1i=1m+1lnCim(r)Cim+1(r)

  •    Determine the average of all Si and name it MSEi

  • end for

  • end for

  • Plot τ vs. MSE