推薦 | 關於Detrended fluctuation analysis的指南!
本文相關資源摘自指南作者主頁,點擊閱讀原文跳轉至原始發布方。
Detrended fluctuation analysisInvestigations of neural signals are often described in terms of an average that discards the observed variability. An average measure, however, might be a poor description of a neural signal, if the signal does not have a typical scale. These systems are referred to as scale-free (for a good review see Hardstone et al. 2012).
More and more research aims at characterizing scale-free signals. It has attracked attention particularly in the fields that study rhythmic (oscillations) and non-rhythmic neural activity. Previous investigations have revealed changes in non-rhythmic neural activity as a function of age (Voytek et al. 2015) and task (He et al. 2010), and log-range correlations in neural signals (Linkenkaer-Hansen et al. 2001).
http://journal.frontiersin.org/article/10.3389/fphys.2012.00450/fullhttp://www.jneurosci.org/content/35/38/13257http://www.cell.com/neuron/fulltext/S0896-6273(10)00291-6http://www.jneurosci.org/content/21/4/1370http://journal.frontiersin.org/article/10.3389/fphys.2012.00450/fullhttp://www.jneurosci.org/content/21/4/1370http://bjornherrmann.com/MultiScaleEntropy.htmlOne of the challenges researchers face is how to assess noise/variability or scale-free properties in neural signals. In the following, we describe the detrended fluctuation analysis, which quantifies the long-term autocorrelation or long-range correlation of non-stationary signals (Hardstone et al. 2012, Linkenkaer-Hansen et al. 2001). Please see also the tutorial on multi-scale entropy which is closely related to the detrended fluctuation analysis and also quantifies variablity in time series.
Simulated time series with different 1/f structureFor the simulations discussed below, four sample time series with a duration of 60 s were generated. The four time series differ in their (1/f) noise structure: blue noise (1/f^-1), white noise (1/f^0), pink noise (1/f^1), brown noise (1/f^2). The time courses and corresponding spectra are shown on the right. Low-frequency power increases and high-frequency power decreases as the 1/f exponent increases.
Time series may also be derived from the neural power fluctuations over time calculated using time-frequency transformations of the signal (e.g., by means of wavelet analysis).
Detrended fluctuation analysis:The methodThe detrended fluctuation analysis method is well descibed in empirical and review papers (Hardstone et al.). The method can be applied to any given time series (although the time series should not be too short) and involves the following steps. The mean is calculated across all time points of the time series and then subtracted from the signal at each time point.
http://bjornherrmann.com/MultiScaleEntropy.htmlThis centers the signal around zero (the top panel of the figure on the left shows the mean-centered 'white noise' time series). The cumulative sum is calculated for the mean-centered time series (displayed in the middle panel of the figure). Sliding windows of different size are subsequently shifted across the cumulative sum signal with a 50% overlap. Window sizes are usually logarithmically spaced. Here, 20 windows were used and their size ranged from 0.1 s to 50 s (the time course of the cumulative sum for two example windows are displayed in the bottom panel). For each window shift, the signal is detrended using linear regression (i.e., slope and intercept are removed; bottom panel) which mean-centers the signal within a window.
The root-mean-square (RMS) is then calculated for the detended signal (sometimes the standard deviation is used instead). The root-mean square is closely related to the sum over the area between the signal and zero (shaded area in the bottom panel of the figure on the left). The root-mean-square is averaged across all shifts of a particular window size. This results in a mean root-mean-square value for each window size, which, when displayed on logarithmic axes, shows a linear trend (shown in the figure on the right; the color dots relate to the time windows displayed in the figure on the left). Finally, a linear function is fit to the log-transformed root-mean square values as a function of the log-transformed window size. The estimated slope (here called alpha coefficient) of the fitted linear function reflects the degree long-range correlation in the orginal time series (the bar graph in the figure on the right shows the slope/alpha). We show below how slope/alpha depends on the type of 1/f structure in time series
Detrended fluctuation analysis: Results for different noise typesWe used the detrended fluctuation analysis to calculate the alpha coefficient for the four different noise types described above. The alpha coefficient (i.e., the slope of the linear function fit to the RMS values; see figure on the left) increases parametrically with the 1/f exponent that was used to generate the time series. White noise (1/f^0) has an alpha coefficient of about 0.5. and pink noise (1/f^1) has an alpha coefficient of about 1. The alpha coefficients indicate that the different time series differ in their scaling properties. They quantify the long-term autocorrelation or long-range correlation of non-stationary signals (Hardstone et al. 2001, Linkenkaer-Hansen et al. 2012). Intuitively, long-range (auto-) correlations are larger with more energy in the low-frequency parts of a signal.
http://journal.frontiersin.org/article/10.3389/fphys.2012.00450/fullhttp://www.jneurosci.org/content/21/4/1370A matlab script that calculates the detrended fluctuation analysis can be downloaded here.
function [F alpha pred] = detrended_fluctuation_analysis(X,nsamps,overlap)
% [F alpha pred] = detrended_fluctuation_analysis(X,nsamps,overlap) % % Inputs:% X - vector of power over time% nsamps - vector of sample numbers defining the time segments used for the% analysis; segment lengthes should be logarithmic% overlap - expressed as proportion, e.g., 0 - no overlap, 0.5 - 50% overlap%% Outputs:% F - dfa fluctuation parameter% alpha - slope of linear fit to log10(dfa) as a function log10(nsamps);% alpha ~0.5 --> uncorrelated signal (white noise)% alpha >0.5 --> temporal correlations over the range of tau% pred - predicted dfa values from linear fit%% Steps:% (1) mean subtraction, (2) cummulative sum, (3) detrend segments, (4) rms% of detrended sgement, (5) fitting a linear function to dfa%% References:% Linkenkaer-Hansen K et al. (2001) Long-Range Temporal Correlations and % Scaling Behavior in Human Brain Oscillations. J Neurosci 21:1370–1377.% Smit DJA et al. (2013) Long-Range Temporal Correlations in Resting-State Alpha% Oscillations Predict Human Timing-Error Dynamics. J Neurosci 33:11212–11220.%% Description:% The script calculates long-range temporal correlations of oscillatory% activity. It relates to the slope of the 1/f scale-free properties of% power spectra. It is an autocorrelation analysis for non-stationary data.% ----%% Copyright (C) 2015, B. Herrmann% This program is free software: you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation, either version 3 of the License, or% (at your option) any later version.%% This program is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% GNU General Public License for more details.%% You should have received a copy of the GNU General Public License% along with this program. If not, see <http://www.gnu.org/licenses/>.%% % B. Herrmann, Email: herrmann.b@gmail.com, 2015-10-23
% subtract mean from amplitude envelopeX = X(:);X = X - mean(X);nsamps = nsamps(:);
% calculate cummulative sumCX = cumsum(X);
% get shifting vectorshift = round(nsamps*(1-overlap));
F = zeros([length(nsamps) 1]);for ii = 1 : length(nsamps) nn = 1:nsamps(ii); counter = 0; while nn(end) < length(CX) % detrend segment tmpX = detrend(CX(nn)); % calculate RMS F(ii) = F(ii) + sqrt(sum(tmpX.^2)/length(tmpX)); nn = nn + shift(ii); counter = counter + 1; end F(ii) = F(ii)/counter;end
coef = polyfit(log10(nsamps),log10(F),1); % linear fitpred = polyval(coef,log10(nsamps)); % predicted dfa valuesalpha = coef(1); % slopePlease only use under under GNU license. No warranty can be provided. Self-check for errors.
https://www.auditoryaging.com/tutorial-dfa