Rudolf Žitný, Ústav procesní a zpracovatelské techniky ČVUT FS 2010
Time seriesNoise filtrationFourier transformWaveletsStimulus-response techniques
Experimental methods E181101 EXM9
Median (warm up - introductory exercise noise reduction of a signal y1, y2,….yN)
EXM9
MedianN=9
53179101-44
Sort the numbers according to values
-4113457910
Median is in the middle = 4
Smoothing (noise reduction of a signal y1, y2,….yN)EXM9
Median smoothing
The main idea is to run through the signal replacing each entry with the median of neighboring entries.
The pattern of neighbors is called the "window", which slides, entry by entry, over the entire signal. For 1D signals, the most obvious window is just the first few preceding and following entries, whereas for 2D (or higher-dimensional) signals such as images, more complex window patterns are possible (such as "box" or "cross" patterns). Note that if the window has an odd number of entries, then the median is the middle value after all the entries in the window are sorted numerically.
Median smoothing Nb=50 total number of points N=1024
Smoothing (noise reduction of a signal y1, y2,….yN)EXM9
Regression smoothing Savitzky Golay
Instead of median the signal inside the „window” is approximated by a polynomial – linear regression (degree of polynomial is obviously limited by the width of window).
Median smoothing Nb=50 total number of points N=1024
Regression smoothing Nb=50 total number of points N=1024
Smoothing (noise reduction of a signal y1, y2,….yN)EXM9
Moving average and median filter
Midpoint in the moving „window” is replaced by average value. A moving average may also use unequal weights for each data value in the window to emphasize particular values in the subset.
Write a MATLAB program for moving average and median filter as an excercise
Smoothing (noise reduction of a signal y1, y2,….yN)EXM9
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1
-0.5
0
0.5
1
1.5
2
n=1000;for i=1:nt(i)=i/n;e(i)=exp(-t(i))*sin(20*t(i));endr=rand(n,1);er=e+r';plot(t,er);
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
w=10;for i=1:nwl=max(1,i-w);wr=min(n,i+w);ef(i)=mean(er(wl:wr));endplot(t,ef)
Moving average filter
Smoothing (median)EXM9
for i=2:n-2 wl=max(1,i-w); wr=min(n,i+w); nvalues=wr-wl+1; median=floor(nvalues/2)+1; for j=wl:wr ej=er(j); ngt=0; for k=wl:wr if er(k) >= ej ngt=ngt+1; end end nlt=nvalues-ngt; if (ngt >= median) & (nlt <= median) ef(i)=ej; break end endend
System responsestimulus response technique. EXM9
Balthus
System responsestimulus response technique. EXM9
Some characteristics of identified continuous system (a reactor, furnace, heat exchanger, almost anything) can be obtained by monitoring time response of system y(t) to a stimulus function x(t). Stimulus can be represented by a marker injected to the inlet of system and response its concentration detected at outlet. As marker (indicator) are frequently used salts (concentration is measured by conductivity meter), dyes (detected by colorimeter), bubbles or fine particles (detected by ultrasound or laser), or radionuclides (detected by gamma-radiation detectors).
E
cin
cout
t [s]
0
)()()( dtEctc inout
Dispersion in pipe
System responsestimulus response technique. EXM9
Look at the database using keywords: “residence time distribution”, “transfer function”, “Peclet number”, “axial dispersion”. Some of the following applications can be found on my web pages:
1. Integral characteristics (moments of continuously recorded signals at inlet and outlet of apparatuses). Example: Packed columns evaluation of holdup (mass of flowing film as a function of flowrate). Holdup calculated from first moments t=t2-t1, dispersion (Péclet number) from second central moments.
2. Residence time distribution RTD (flight times of particles flowing through an apparatus). Example: RTD identification of a polydisperse mixture (titanium oxide) in a horizontal rotary drum using radioisotope tracer Na24 mixed with the processed material at inlet (see A* in figure). Identified RTD enables simulation of drying and calcination reactions inside a drum. This kind of analysis is typical for chemical reactors, combustors, waste water treatment, food processing lines.
Applications: experimental characterization of continuous systems
Example: rotary dryer- RTDEXM9
A*
D12D11D5D4 D6D1 D10D2 D8D7 D9D3
172021310
1600
2797031470
3542040150
5480
13890
9420
43910
2220
TV TITIIITIV TII
12000
4391043910
46000360044006200
24440
Example: Residence Time Distribution (rotary dryer/kiln TiO2 Precheza Přerov)
Experimental analysis using radionuclide tracer (Na-half life 15 hours) mixed with the TiO2 feed. Concentration of tracer was recorded by 12 gamma radiation detectors mounted along the rotating cylinder (from outside, gamma radiation penetrates steel wall). This is the way how to track the transported particles and how to identify their residence times.
Na
Radionuclide mixed with processed material
Example: rotary dryer- RTDEXM9
Theory:
MG
gas
Counter-current
particle
Cocurrent
L
D
gas
particle
It was theoretically derived that the residence time of a spherical particle (diameter d) moving in an inclined rotary dryer (diameter of cylinder D, length L, inclination angle , frequency of rotation N) is in the counter current arrangement (when gas flows against transported particles)
and in the parallel (cocurrent) flow
(MG and MS is mass flow rate of gas and solid repectively). It is seen that the residence time decreases with the increasing frequency of rotation, diameter and inclination of cylinder. Influence of particle size depends upon mass flowrate of gas.
Friedman F.,Marshall A.,Chem.Engng.Progr. 45,482, 1949
)()323.0
( 219.0 d
kkL
Md
M
DNtgLt
S
G
)()323.0
( 219.0 d
kkL
Md
M
DNtgLt
S
G
2
1( )k
t L kd
21( )
kt L k
d
Long residence time in the counter-current flow
Short residence time in the co-current flow
Values t are residence times of identical particles (monodisperse mixture)
Example: rotary dryer- RTDEXM9
Theory:MG
gas
Counter-current
particle
Cocurrent
L
D
gas
particle
These functions are distributions of residence times for polydisperse material (Rosin Rammler distribution of particle size)
For polydisperse material Rosin Rammler distribution of particle size must be identified (dm is the mean diameter of particle, n- is characteristic of dispersion)
f dnd
d
d
d
n
mn
m
n( ) exp[ ( ) ] 1
E tn
Lk d
Lk
t Lk
Lk
t Lk dmn
n n
mn( ) ( ) exp[ ( ) ]
2 1
2
2
1
2 1 2
1
2
E tn
Lk d
Lk
Lk t
Lk
Lk t dmn
n n
mn
( ) ( ) exp[ ( ) ]
2 1
2
2
1
2 1 2
1
2
t L kk
d nm
[ ( )]12 1
1
2
t Lk Gb 1
])
2
11(
)28
1(1)
2
11([1
42
2
nK
n
Ke
nKeG
nK
Kb
n
n
mdk
kK
1
2
Residence time distribution of particles in counter-current arrangement
Co-current arrangement
Mean residence time for countercurrent arrangement
Mean residence time for cocurrent arrangement
This is only an approximation at co-current flow (fine particles would have negative residence time
according to this simplified model)
Example: rotary dryer- RTDHP9
Dehydration
D3
A*
dm[mm] n k1[min/m] k2 t[min]2.24 1.274 1.692 0.0037 47.25.70 3.750 1.830 0.0150 48.3
0.500.7511.251.50
t t/ 0
DN D N0 90 0
0 9. ./
G
S
M
M d
0 0.5 1 1.5 2 2.5
2
1.5
1
0
0.5
Experimentally determined impulse response of a dryer section (by recording response of a gamma detector to the instantaneous injection of Na tracer) was used for identification of k1 and k2 parameters of previously derived RTD models.
The values k1 and k2 enable to predict what happens when the rotational speed N is changed (and it was the primary goal of analysis – to answer the question how the frequency of rotation affects lengths of drying and reaction zones in the TiO2 kiln; it is not so easy to change the frequency, it is not sufficient just only to turn a knob, such a change needs money and must be supported by preliminary analysis).
System responsestimulus response technique. EXM9
Integral characteristics of a response E(t) recorded from time zero to infinity Common moments
0
0 )( dEM
0
1 )( dEM
0
22 )( dEM
Mean residence time
0
0
)(
)(
dE
dE
t
Variance of residence times
0
0
2
2
)(
)()(
dE
dEt
Weighted moments (in fact Laplace transformation)
n0
-st nM (s)= e t E(t)dt.
E
t [s]
By measuring the mean residence time it is possible to calculate for example yield of a chemical reactor (yield depends
upon the time available for reaction)
It tells you something about uniformity of residence times
System models stimulus response technique. EXM9
Compartment modelsCompartment is a basic unit (like a brick in LEGO) for
description complicated systems structure. Compartment is an ideally mixed tank, characterfized
by mass, temperature, concentration…
System models stimulus response technique. EXM9
Derive response of a perfectly mixed tank of inner volume V to a short pulse
3[ / ]Q m s
3[ / ]Q m s
( )inc t
( )outc t
Constant flowrate at inlet
Constant flowrate at outletConcentration in tank is the same as at outlet (perfect mikxing, concentration is
uniform inside)
0 t[s]
Initial condition: zero concentration c in the tank at time t=0.
0 t[s]
?
outc c
System models stimulus response technique. EXM9
Mass balance of component having concentration c
( )in
dcV Q c c
dt
outoutin
cc
d Vc
dt Q
3[ / ]Q m s
3[ / ]Q m s
( )inc t
( )outc t
0 t[s]
outc c
Mean residence time
-i
out
out n
d dt
c
c
c
Procedure: First step – describe the system by differential equation for c(t)
System models stimulus response technique. EXM9
Intermediate step: calculate response to a unit step stimulus function
0 01
outc tcd dt
c
1
ln 1
outc t
Response valid up to the time
3[ / ]Q m s
3[ / ]Q m s
( ) 1inc t
( )outc t
0 t[s]
outc c
( ) 1 1 out
t
c ct e e
-i
out
out n
d dt
c
c
c
System models stimulus response technique. EXM9
Intermediate step: response to zero concentration at inlet for t>
outc t
c
d t
c
dc
ln out t
c
c
Response valid for t >
3[ / ]Q m s
3[ / ]Q m s
( ) 1inc t
( )outc t
0 t[s]
outc c
( ) t
out t ec c
-i
out
out n
d dt
c
c
c
System models stimulus response technique. EXM9
Response to puls of width =2s and =1 s
0
0,1
0,2
0,3
0,4
0,5
0,6
0,7
0,8
0,9
1
0 1 2 3 4 5 6
t [s]
co
ut
3[ / ]Q m s
3[ / ]Q m s
( )inc t
( )outc t
0 t[s]
outc c ( ) t
out t ec c
( ) 1out
t
c t e
IMPULSE response E(t) EXM9
x(t)
t [s]
E(t)
1/
Impulse response E(t) is the response of a general system to infinitely short pulse (→0) having unit area (delta function).
Delta function (t) is zero for t≠0 and ( ) 1t dt
x(t)
t [s]
E(t-)
System response to stimulus function. EXM9
Relationship between stimulus and response function Volterra integral equation of the first kind
( ) ( ) ( )y t E t x d
Where E(t) is the so called impulse response.
x
y
t [s]
E
Response y(t) follows from the principle of superposition of responses to narrow pulses (representing stimulus x(t))
Convolution integral
System response to stimulus function. EXM9
x
y
t [s]
E
Typical problems:
Given a stimulus function x(t), the prediction of system response y(t) is calculated from the convolution integral
Given measured stimulus and response functions, the impulse response E(t) is evaluated by identification from the Volterra equation (deconvolution)
E(t)x(t) y(t)
This is difficult problem because identification is sensitive to signal noise
These problems are solved using integral transforms, see
FOURIER transform→
EXM9 FOURIER transform preliminaries
Duchamp
EXM9 FOURIER transform preliminaries
Goniometric functions (sin, cos) are orthogonal in interval (-,).
Orthogonality of Pn(x)=cos nx follows from
])sin()sin(
[2
1
))cos()(cos(2
1coscos
nm
xnm
nm
xnm
dxxnmxnmnxdxmx
for m=n, otherwise 0
In a similar way the orthogonality of sin nx can be derived. From Euler’s formula follows orthogonality of jxijxexP ijx
j sincos)(
Linear combination of Pj(x) is called Fourier’s expansion
0
)()(j
jj xPTxT
Proof!!!
The transformation T(x) to Tj for j=0,1,2,…, is called Fourier transform and its discrete form is DFT T(x1), T(x2),…. T(xN) to T1,T2,…TN . DFT can be realized by FFT (Fast Fourier Transform).
i-imaginary unit
Fourier transformsEXM9
dtetcfc ift2)()(~
dtefctc ift2)(~)(
Continuous Forward Fourier transform from time to frequency domain
Backward transform
Fourier transformsEXM9
1. c(t) is real
dtetcfc ift2)()(~ *)(~)(~ fcfc
Proof *22 )()2sin()2cos()2sin()2cos( iftift eftiftftifte Consequence: it is not necessary to calculate FT for negative frequencies
2. c(t) is real and even,
dtfttcdtftifttcfc )2cos()())2sin()2)(cos(()(~
is also real and even. Proof: integral of odd function is zero.
3. Parseval theorem
dttcdffc 22 )()(~
Basic properties of FT
Fourier transformsEXM9
power spectral density
22)(~)(~)( fcfcfPc
Energy of long waves (low frequency)
Energy of high frequency (noise)
Fourier transformsEXM9
dytxtCxy )()()( )(~)(~)(~ jyfxfCxy
dytxtRxy )()()( )(~)(~)(~ * fyfxfRxy
convolution
correlation
Mean time of x(t)=0.5
Mean time of y(t)=2.1
Mean time of cross correlation Rxy(t)=1.6
represents a time shift between x(t) and y(t)
Fourier transformsEXM9
dttTtTR )()()( 2112
Cross-correlation of stimulated or random signal detected at two locations (technically it can be a heater and thermocouples)
T1 T2
Heater
Fourier transformsEXM9
dttTtTR )()()( 2112
Example calculated by MATLAB
Heater
Random signal shifted by 100 time steps
Discrete Fourier transformEXM9
Sampling of data at constant time step
N-data points (even number)
t: t0=0, t1=, t2=2, 3,......, tN-1= (N-1),
f: f-N/2=
2
1,f-N/2+1=
1)
1
2
1(
N,.. f-1=
N
1, f0=0,
f1=N
1,.. fN/2-1=
1)
1
2
1(
N, fN/2=
2
1
Nyquist frequency
Nyquist frequency is the maximum frequency which can be described by data with the sampling interval
2
Discrete Fourier transformEXM9
t: t0=0, t1=, t2=2, 3,......, tN-1= (N-1),
f: f-N/2=
2
1,f-N/2+1=
1)
1
2
1(
N,.. f-1=
N
1, f0=0,
f1=N
1,.. fN/2-1=
1)
1
2
1(
N, fN/2=
2
1
Discrete FT
1
0
/2)()(~N
k
Niknkn etcfc where
N
nfn and ktk
Discrete FFT has the same properties (convolution, correlation) as the continuous FT.
2( ) ( ) iftc f c t e dt
only the sum is called DFT
Discrete Fourier transformEXM9
Discrete FT
1
0
2
1
0
2
~1
~
N
k
N
kni
nk
N
k
N
kni
kn
ecN
c
ecc
Parseval theorem
1
0
21
0
2 |~|1
||N
kk
N
kk c
Nc
Wiener filteringEXM9
u(t) corrupted c(t)
r(t)-impulse response
noise n(t)
s(t)
)(~)(
~)(~
)(~fr
ffcfu
Discrete Fourier transformEXM9
12 ( 1)
1 1
12 ( 1)
1 1
1 1(cos(2 ( 1) ) sin(2 ( 1) ))
1 1 1 1(cos(2 ( 1) ) sin(2 ( 1) ))
nN Ni kN
k n nn n
nN Ni kN
n k kk k
n nc c e c k i k
N N
n nc c e c k i k
N N N N
MATLAB programming
Forward transformation
cf=fft(c,N)
Inverse transformation
c=ifft(cf,N)
Vector of samples c(1),c(2),….,c(N)
Vector of calculated Fourier coefficients)
Fourier transform PSD exampleEXM9
A common use of Fourier transforms is to find the frequency components of a signal buried in a noisy time domain signal. Consider data sampled at 1000 Hz. Form a signal containing 50 Hz and 120 Hz and corrupt it with some zero-mean random noise:
t = 0:0.001:0.6;
x = sin(2*pi*50*t)+sin(2*pi*120*t);
y = x + 2*randn(size(t));
It is difficult to identify the frequency components by looking at the original signal. Converting to the frequency domain, the discrete Fourier transform of the noisy signal y is found by taking the 512-point fast Fourier transform (FFT):
Y = fft(y,512);
The power spectrum, a measurement of the power at various frequencies, is
Pyy = Y.* conj(Y) / 512;
Graph the first 257 points (the other 255 points are redundant) :
f = 1000*(0:256)/512;0 100 200 300 400 500 600
0
10
20
30
40
50
60
70
80
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7-6
-4
-2
0
2
4
6
Normal distribution (mean=0, variance=1) of random numbers (result is of the same size as t)
Discrete Fourier Transform of 512 points
Power spectral density
the upper half is not important because x is real and not a complex vector
Dominant frequencies
Fourier transform PSD filterEXM9
The simplest way how to filter a noise is to suppress high frequencies, for example all frequencies corresponding to fourier components Y(65),Y(66),…Y(451) (assign zeroes to these entries). Resulting PSD is
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7-6
-4
-2
0
2
4
6
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5-4
-3
-2
-1
0
1
2
3
4
0 100 200 300 400 500 6000
10
20
30
40
50
60
70
80
Filtered signal is reconstructed by inverse FT
y=ifft(Y,512)
Original signal for comparison
Annulated fourier coef.
Fourier transform convolution/correlat.EXM9
0 1 2 3 4 5 60
1
2
3
4
5
6
7
8x 10
-3
0 1 2 3 4 5 60
1
2
3
4
5
6
7
8x 10
-3
for i=1:512c1(i)=t(i)*exp(-2*t(i));c2(i)=t(i)^4*exp(-t(i)*3);endf1=fft(c1,512);f2=fft(c2,512);
for i=1:512c12(i)=f1(i)*f2(i); r12(i)=f1(i)*conj(f2(i));end
cc=ifft(c12,512); rr=ifft(r12,512);
Fourier coef. of convolution and correlation
Inverse Fourier transformation
effect of mirroring
(periodicity of FT)
WaveletsEXM9
Dalí
WaveletsEXM9
dxtxkgxcktkc ))(()(),(~ *
22
2
)1()(z
ezzg
Example of mother wavelet g(z) is Mexican hat
Integral transform with scale k and time shift t
scaletranslation
scale k
Time shift t
EEG and Visual information processingEXM9
http://people.deas.harvard.edu/~gstanley/research_topics_vision.html
Information direction from eyes to brain cortex
EXM9
-Recorded electric activity of primary visual cortex related to the visual stimulus
-Signal is averaged from many realizations to increase signal-to-noise ratio
-We can measure differences in the el. activity of the primary visual cortex related to the stimulus.
-For clinical evaluation of neural diseases is used record from area near the visual cortex
Referential 7thear electrode
nasion
U [V]
t [1 sample = 2ms]
Top of peak - cca 100 – 130 ms after stimulation
Significant VEP peak – manually marked
6 – electrodes system
Signal averaging
from 40 re
alizations
Reversing checker stimulus
inion
EEG and Visual information processing
M. Hulan, J. Kremláček, R. Žitný: New methods for automatic detection of evoked potentials of a human primary visual cortex. HBM 2006
EXM9
VEP-Visually Evoked Potential
CWT-Continuous Wavelet Transformation
EEG and Visual information processing
M. Hulan, J. Kremláček, R. Žitný: New methods for automatic detection of evoked potentials of a human primary visual cortex. HBM 2006
EXM9 Wavelet (papers)A.Z. Averbuch et al. / Appl. Comput. Harmon. Anal. 31 (2011) 98–124 R.C. Guido / Applied Mathematics Letters 24 (2011) 1257–1259
blurred
Tichonov regularization Wiener filter
Wavelet
Deconvolution
EXM9 Wavelet (papers)