• No results found

PARAMETRIC MODEL-BASED METHODS

Spectral Analysis: Modern Techniques

PARAMETRIC MODEL-BASED METHODS

The techniques for determining the power spectra described in Chapter 3 are all based on the Fourier transform and are referred to as classical methods. These methods are the most robust of the spectral estimators. They require little in the way of assumptions regarding the origin or nature of the data, although some knowledge of the data could be useful for window selection and averaging strat-egies. In these classical approaches, the waveform outside the data window is implicitly assumed to be zero. Since this is rarely true, such an assumption can lead to distortion in the estimate (Marple, 1987). In addition, there are distor-tions due to the various data windows (including the rectangular window) as described in Chapter 3.

Modern approaches to spectral analysis are designed to overcome some of the distortions produced by the classical approach and are particularly effec-tive if the data segments are short. Modern techniques fall into two broad classes: parametric, model-based* or eigen decomposition, and nonparametric.

These techniques attempt to overcome the limitations of traditional methods by taking advantage of something that is known, or can be assumed, about the source signal. For example, if something is known about the process that

gener-*In some semantic contexts, all spectral analysis approaches can be considered model-based. For example, classic Fourier transform spectral analysis could be viewed as using a model consisting of harmonically related sinusoids. Here the term parametric is used to avoid possible confusion.

125

TLFeBOOK

FIGURE5.1 Schematic representation of model-based methods of spectral esti-mation.

ated the waveform of interest, then model-based, or parametric, methods can make assumptions about the waveform outside the data window. This eliminates the need for windowing and can improve spectral resolution and fidelity, partic-ularly when the waveform contains a large amount of noise. Any improvement in resolution and fidelity will depend strongly on the appropriateness of the model selected (Marple, 1987). Accordingly, modern approaches, particularly parametric spectral methods, require somewhat more judgement in their applica-tion than classical methods. Moreover, these methods provide only magnitude information in the form of the power spectrum.

Parametric methods make use of a linear process, commonly referred to as a model* to estimate the power spectrum. The basic strategy of this approach is shown in Figure 5.1. The linear process or model is assumed to be driven by white noise. (Recall that white noise contains equal energy at all frequencies;

its power spectrum is a constant over all frequencies.) The output of this model is compared with the input waveform and the model parameters adjusted for the best match between model output and the waveform of interest. When the best match is obtained, the model’s frequency characteristics provide the best esti-mate of the waveform’s spectrum, given the constraints of the model. This is because the input to the model is spectrally flat so that the spectrum at the output is a direct reflection of the model’s magnitude transfer function which, in turn, reflects the input spectrum. This method may seem roundabout, but it permits well-defined constraints, such as model type and order, to be placed on the type of spectrum that can be found.

*To clarify the terminology, a linear process is referred to as a model in parametric spectral analysis, just as it is termed a filter when it is used to shape a signal’s spectral characteristics. Despite the different terms, linear models, filters, or processes are all described by the basic equations given at the beginning of Chapter 4.

TLFeBOOK

Modern Spectral Analysis 127

A number of different model types are used in this approach, differentiated by the nature of their transfer functions. Three models types are the most popu-lar: autoregressive (AR), moving average (MA), and autoregressive moving average (ARMA). Selection of the most appropriate model selection requires some knowledge of the probable shape of the spectrum. The AR model is partic-ularly useful for estimating spectra that have sharp peaks but no deep valleys.

The AR model has a transfer function with only a constant in the numerator and a polynomial in the denominator; hence, this model is sometimes referred to as an all-pole model. This gives rise to a time domain equation similar to Eq.

(6) in Chapter 4, but with only a single numerator coefficient, b(0), which is assumed to be 1:

y(n)= −

p

k=1

a(k) y(n− k) + u(n) (1)

where u(n) is the input or noise function and p is the model order. Note that in Eq. (1), the output is obtained by convolving the model weight function, a(k), with past versions of the output (i.e., y(n-k)). This is similar to an IIR filter with a constant numerator.

The moving average model is useful for evaluating spectra with the val-leys, but no sharp peaks. The transfer function for this model has only a numera-tor polynomial and is sometimes referred to as an all-zero model. The equation for an MA model is the same as for an FIR filter, and is also given by Eq. (6) in Chapter 4 with the single denominator coefficient a(0) set to 1:

y(n)= −

q

k=1

b(k) u(n− k) (2)

where again x(n) is the input function and q is the model order*.

If the spectrum is likely to contain bold sharp peaks and the valleys, then a model that combines both the AR and MA characteristics can be used. As might be expected, the transfer function of an ARMA model contains both nu-merator and denominator polynomials, so it is sometimes referred to as a pole–

zero model. The ARMA model equation is the same as Chapter 4’s Eq. (6) which describes a general linear process:

y(n)= −

p

k=1

a(k) y(n− k) +

q

k=1

b(k) u(n− k) (3)

In addition to selecting the type of model to be used, it is also necessary to select the model order, p and/or q. Some knowledge of the process generating

*Note p and q are commonly used symbols for the order of AR and MA models, respectively.

TLFeBOOK

the data would be helpful in this task. A few schemes have been developed to assist in selecting model order and are described briefly below. The general approach is based around the concept that model order should be sufficient to allow the model spectrum to fit the signal spectrum, but not so large that it begins fitting the noise as well. In many practical situations, model order is derived on a trial-and-error basis. The implications of model order are discussed below.

While many techniques exist for evaluating the parameters of an AR model, algorithms for MA and ARMA are less plentiful. In general, these algo-rithms involve significant computation and are not guaranteed to converge, or may converge to the wrong solution. Most ARMA methods estimate the AR and MA parameters separately, rather than jointly, as required for optimal solu-tion. The MA approach cannot model narrowband spectra well: it is not a high-resolution spectral estimator. This shortcoming limits its usefulness in power spectral estimation of biosignals. Since only the AR model is implemented in the MATLAB Signal Processing Toolbox, the rest of this description of model-based power spectral analysis will be restricted to autoregressive spectral esti-mation. For a more comprehensive implementation of these and other models, the MATLAB Signal Identification Toolbox includes both MA and ARMA models along with a number of other algorithms for AR model estimation, in addition to other more advanced model-based approaches.

AR spectral estimation techniques can be divided into two categories: al-gorithms that process block data and alal-gorithms that process data sequentially.

The former are appropriate when the entire waveform is available in memory, while the latter are effective when incoming data must be evaluated rapidly for real-time considerations. Here we will consider only block-processing algo-rithms as they find the largest application in biomedical engineering and are the only algorithms implemented in the MATLAB Signal Processing Toolbox.

As with the concept of power spectral density introduced in the last chap-ter, the AR spectral approach is usually defined with regard to estimation based on the autocorrelation sequence. Nevertheless, better results are obtained, partic-ularly for short data segments, by algorithms that operate directly on the wave-form without estimating the autocorrelation sequence.

There are a number of different approaches for estimating the AR model coefficients and related power spectrum directly from the waveform. The four approaches that have received the most attention are: the Yule-Walker, the Burg, the covariance, and the modified covariance methods. All of these approaches to spectral estimation are implemented in the MATLAB Signal Processing Toolbox.

The most appropriate method will depend somewhat on the expected (or desired) shape of the spectrum, since the different methods theoretically enhance

TLFeBOOK

Modern Spectral Analysis 129

different spectral characteristics. For example, the Yule-Walker method is thought to produce spectra with the least resolution among the four, but provides the most smoothing, while the modified covariance method should produce the sharpest peaks, useful for identifying sinusoidal components in the data (Marple, 1987). The Burg and covariance methods are known to produce similar spectra.

In reality, the MATLAB implementations of the four methods all produce simi-lar spectra, as show below.

Figure 5.2 illustrates some of the advantages and disadvantages of using AR as a spectral analysis tool. A test waveform is constructed consisting of a low frequency broader-band signal, four sinusoids at 100, 240, 280, and 400 Hz, and white noise. A classically derived spectrum (Welch) is shown without the added noise in Figure 5.2A and with noise in Figure 5.2B. The remaining plots show the spectra obtained with an AR model of differing model orders.

Figures 5.2C–E show the importance of model order on the resultant spectrum.

Using the Yule-Walker method and a relatively low-order model (p= 17) pro-duces a smooth spectrum, particularly in the low frequency range, but the spec-trum combines the two closely spaced sinusoids (240 and 280 Hz) and does not show the 100 Hz component (Figure 5.2C). The two higher order models (p= 25 and 35) identify all of the sinusoidal components with the highest order model showing sharper peaks and a better defined peak at 100 Hz (Figure 5.2D and E). However, the highest order model (p= 35) also produces a less accurate estimate of the low frequency spectral feature, showing a number of low fre-quency peaks that are not present in the data. Such artifacts are termed spurious peaks and occur most often when high model orders are used. In Figure 5.2F, the spectrum produced by the covariance method is shown to be nearly identical to the one produced by the Yule-Walker method with the same model order.

The influence of model order is explored further in Figure 5.3. Four spectra are obtained from a waveform consisting of 3 sinusoids at 100, 200, and 300 Hz, buried in a fair amount of noise (SNR= -8 db). Using the traditional Welch method, the three sinusoidal peaks are well-identified, but other lesser peaks are seen due to the noise (Figure 5.3A). A low-order AR model, Figure 5.3B, smooths the noise very effectively, but identifies only the two outermost peaks at 100 and 300 Hz. Using a higher order model results in a spectrum where the three peaks are clearly identified, although the frequency resolution is moderate as the peaks are not very sharp. A still higher order model im-proves the frequency resolution (the peaks are sharper), but now a number of spurious peaks can be seen. In summary, the AR along with other model-based methods can be useful spectral estimators if the nature of the signal is known, but considerable care must be taken in selecting model order and model type.

Several problems at the end of this chapter further explore the influence of model order.

TLFeBOOK

spectrum. (A) Spectrum obtained using classical methods (Welch) of a waveform consisting of four sinusoids (100, 240, 280, and 400 Hz) and a low frequency region generated from lowpass filtered noise. (B) Spectrum obtained using the Welch method applied to the same waveform after white noise has been added (SNR= -8 db). (C, D and E) Spectra obtained using AR models (Yule-Walker) having three different model orders. The lower order model (p= 17) cannot distin-guish the two closely spaced sinusoids (240 and 280 Hz). The highest order model (p= 35) better identifies the 100 Hz signal and shows sharper peaks, but shows spurious peaks in the low frequency range. (F) AR spectral analysis using the covariance method produces results nearly identical to the Yule-Walker method.

TLFeBOOK

Modern Spectral Analysis 131

FIGURE 5.3 Spectra obtained from a waveform consisting of equal amplitude sinusoids at 100, 200, and 300 Hz with white noise (N= 1024; SNR = -12 db).

(A) The traditional Welch method shows the 3 sinusoids, but also lesser peaks due solely to the noise. (B) The AR method with low model order (p= 7) shows the two outside peaks with a hint of the center peak. (C) A higher order AR model (p= 13) shows the three peaks clearly. (D) An even higher order model (p = 21) shows the three peaks with better frequency resolution, but also shows a number of spurious peaks.

MATLAB Implementation

The four AR-based spectral analysis approaches described above are available in the MATLAB Signal Processing Toolbox. The AR routines are implemented though statements very similar in format to that used for the Welsh power spec-tral analysis described in Chapter 3. For example, to implement the Yule-Walker AR method the MATLAB statement would be:

TLFeBOOK

[PS, freq] = pyulear(x,p,nfft,Fs);

Only the first two input arguments,xandp, are required as the other two have default values. The input argument, x, is a vector containing the input waveform, andpis the order of the AR model to be used. The input argument nfftspecifies the length of the data segment to be analyzed, and ifnfftis less than the length ofx, averages will be taken as in pwelch. The default value for nfft is 256*. As in pwelch, Fs is the sampling frequency and if specified is used to appropriately fill the frequency vector,freq, in the output. This output variable can be used in plotting to obtain a correctly scaled frequency axis (see Example 5.1). In the AR spectral approach, Fsis also needed to scale the hori-zontal axis of the output spectrum correctly. If Fs is not specified, the output vectorfreq varies in the range of 0 toπ.

As in routinepwelch, only the first output argument, PS, is required, and it contains the resultant power spectrum. Similarly, the length of PS is either (nfft/2)ⴙ 1if nfftis even, or (nfftⴙ1)/2ifnfft is odd since additional points would be redundant. An exception is made ifxis complex, in which case the length of PS is equal to nfft. Other optional arguments are available and are described in the MATLAB help file.

The other AR methods are implemented using similar MATLAB state-ments, differing only in the function name.

[Pxx, freq] = pburg(x,p,nfft,Fs);

[Pxx, freq] = pcov(x,p,nfft,Fs);

[Pxx, freq] = pmcov(x,p,nfft,Fs);

The routine pburg, uses the Burg method, pcov the covariance method andpmcovthe modified covariance method. As we will see below, this general format is followed in other MATLAB spectral methods.

Example 5.1 Generate a signal combining lowpass filtered noise, four sinusoids, two of which are closely spaced, and white noise (SNR= -3 db). This example is used to generate the plots in Figure 5.2.

% Example 5.1 and Figure 5.2

% Program to evaluate different modern spectral methods

% Generate a spectra of lowpass filtered noise, sinusoids, and

% noise that applies classical and AR sprectral analysis methods

%

*Note the use of the term nfft is somewhat misleading since it implies an FFT is taken, and this is not the case in AR spectral analysis. We use it here to be consistent with MATLAB’s terminology.

TLFeBOOK

Modern Spectral Analysis 133

N = 1024; % Size of arrays

fs = 1000; % Sampling frequency

n1 = 8; % Filter order

w = pi/20; % Filter cutoff frequency

% (25 Hz)

%

% Generate the low frequency broadband process

% Compute the impulse response of a Butterworth lowpass filter noise = randn(N,1); % Generate noise

[b,a] = butter(n1,w); % Filter noise with

Butter-% worth filter out = 5 * filter(b,a,noise);

%

% Generate the sinusoidal data and add to broadband signal [x,f,sig] = sig_noise([100 240 280 400],-8,N);

data = data ⴙ out(1:1024,1)’; % Construct data set with added

% noise

sig = sig ⴙ out(1:1024,1)’; % Construct data set without

% noise

%

% Estimate the Welch spectrum using all points, no window, and no

% overlap

% Apply Welch method to noisy data set [PS,f] = pwelch(x, N,[ ],[ ],fs);

subplot(3,2,2);

plot(f,PS,’k’); ...labels, text, and axis ...

%

% Apply AR to noisy data set at three different weights [PS,f] = pyulear(x,17,N,fs); % Yule-Walker; p = 17 subplot(3,2,3);

plot(f,PS,’k’); ...labels, text, and axis ...

%

[PS,f] = pyulear(x,25,N,fs); % Yule-Walker; p = 25 subplot(3,2,4);

plot(f,PS,’k’); ...labels, text, and axis ...

%

[PS,f] = pyulear(x,35,N,fs); % Yule-Walker; p = 35

TLFeBOOK

subplot(3,2,5);

plot(f,PS,’k’); ...labels, text, and axis ...

%

% Apply Covariance method to data set

[PS,f] = pmcov(x,25,N,fs); % Covariance; p = 25 subplot(3,2,6);

plot(f,PS,’k’); ...labels, text, and axis ...

In this example, the waveform is constructed by combining filtered low-pass noise with sinusoids in white noise. The filtered lowlow-pass noise is con-structed by applying an FIR filter to white noise. A similar approach to generat-ing colored noise was used in Example 2 in Chapter 2. The routinesig_noise was then used to construct a waveform containing four sinusoids at 100, 240, 280, and 400 Hz with added white noise (SNR= -8 db). This waveform was then added to the colored noise after the latter was scaled by 5.0. The resultant waveform was then analyzed using different power spectral methods: the Welch FFT-based method for reference (applied to the signal with and without added noise); the Yule-Walker method with a model orders of 17, 25, and 35; and the modified covariance method with a model order of 25. The sampling frequen-cy was 1000 Hz, the frequenfrequen-cy assumed by the waveform generator routine, sig_noise.

Example 5.2 Explore the influence of noise on the AR spectrum specifi-cally with regard to the ability to detect two closely related sinusoids.

Solution The program defines a vector,noise, that specifies four different levels of SNR (0, -4, -9, and -15 db). A loop is used to run through waveform generation and power spectrum estimation for the four noise levels. The values in noise are used with routine sig_noise to generate white noise of different levels along with two closely spaced sin waves at 240 and 280 Hz. The Yule-Walker AR method is used to determine the power spectrum, which is then plotted. A 15th-order model is used.

% Example 5.2 and Figure 5.4

% Program to evaluate different modern spectral methods

% with regard to detecting a narrowband signal in various

% amounts of noise clear all; close all;

N = 1024; % Size of arrays

fs = 1000; % Sample frequency

order = 15; % Model order

noise = [0 -4 -9 -15]; % Define SNR levels in db for i = 1:4

TLFeBOOK

Modern Spectral Analysis 135

FIGURE5.4 Power spectra obtained using the AR Yule-Walker method with a 15th-order model. The waveform consisted of two sinusoids at 240 and 280 Hz with various levels of noise. At the lowest noise levels, the two sinusoids are clearly distinguished, but appear to merge into one at the higher noise levels.

% Generate two closely space sine waves in white noise x = sig_noise([240 280],noise(i),N);

[PS,f] = pyulear(data,order,N,fs);

subplot(2,2,i); % Select subplot

plot(f,PS,’k’); % Plot power spectrum and label text(200,max(PS),[’SNR: ’,num2str(noise(i)), ‘db’]);

xlabel(’Frequency (Hz)’); ylabel(’PS ’);

end

The output of this Example is presented in Figure 5.4. Note that the sinu-soids are clearly identified at the two lower noise levels, but appear to merge

TLFeBOOK

together for the higher noise levels. At the highest noise level, only a single, broad peak can be observed at a frequency that is approximately the average of the two sine wave frequencies. The number of points used will also strongly influence the resolution of all spectral methods. This behavior is explored in the problems at the end of this chapter.

NON-PARAMETRIC EIGENANALYSIS