Efficacy of Wavelet Transform Techniques for Denoising Polarized Target NMR Signals James Maxwell May 2, 24 Abstract Under the guidance of Dr. Donal Day, mathematical techniques known as Wavelet Transforms were investigated for possible use in denoising NMR signals used to measure target polarization. Three methods, each using the Daubechies 4 wavelet transform, were evaluated for this denoising application; two using Labview s wavelet transform tool, and the other from Matlab s wavelet toolbox. Matlab s denoising utility proved to be much more flexible for denoising, as it combined the advantages of the Labview scripts written by the experimenter. The wavelet transform s capability for denoising is strikingly powerful, and application for polarized targets is recommended.
Introduction. Wavelet Transforms The Wavelet Transform, like the Fourier Transform, is a mathematical technique which represents a time vs. amplitude signal in a frequency vs. amplitude space. For convenience, we will refer to time and amplitude signal components, when these methods can transform any set of ordered amplitude data. A Fourier Transform returns the frequency spectrum of a given signal, showing what frequencies exist and how strong these frequency components are. The weakness of the Fourier Transform is the lack of information regarding where in time those frequencies occur. For non-stationary signals, where knowledge of what spectral components occur in what time interval, the Fourier Transform is deficient. When the time localization of frequency components is needed, a Wavelet Transform is more useful. The mechanism of the Wavelet Transform is analogous to a series of high and low pass electronic filters operating on a signal. First, the signal is passed though both a low and high pass filter. The signal obtained from the low pass filter is then passed through another low and high pass filter. If, for example, a signal has frequencies up to Hz, the first step would result in two signals: one representing frequencies between 5 and Hz, the other representing frequencies between and 5 Hz. After the second step, three signals would exist representing to 25 Hz, 25 to 5 Hz, and 5 to 2
Hz. Since each signal representing a given frequency range is still time vs. amplitude, we know in which time intervals each frequency band exists. In the Discrete Wavelet Transform, where ordered amplitude data are the input, the actual mathematical mechanism is a series of vector multiplications. We shall express the discrete signal as f = (f, f 2,..., f N ), where N is a positive even integer, and where the values of signal f are the N real numbers f i which represent the amplitude of the signal at each point in time. Wavelets are the mathematical low and high pass filters which operate on f to produce wavelet coefficients, the resultant transformed signal. [2] The most simple wavelets are the Haar wavelets. In this case, the low pass filter, hereafter the trend a = (a, a 2,...,a N/2 ), is a running average, and the high pass, the fluctuation d = (d, d 2,,..., d N/2 ), a running difference: a m = f 2m + f 2m, d m = f 2m f 2m () 2 2 for m =, 2, 3,..., N/2. The Wavelet Coefficients for the first level Haar Wavelet are simply a and d concatenated: f (a d ) Since a and d are both half the length of f, the transform of f is the same length, N. The multi-level Haar Transform is obtained by computing a second trend, a 2, and second fluctuation d 2 from a by the same means, so that f H2 (a 2 d 2 d ). (2) Where a 2 and d 2 are half the length of d, which is length N/2, so the 3
transformed signal is still length N. This process can be continued, forming higher level transforms as long as the a i can be divided by 2. Powers of two, 2 n, can have an n-level wavelet transform where a n and d n consist of one value. It is convenient to express the trend and fluctuation operators as vectors. The high pass fluctuation coefficients for the Haar wavelets can be expressed as d m = f Wm for m =, 2,..., N/2, where ( 2 W =, ),,,...., 2 ( W 2 =,,, ),,,...., 2 2 W N/2 =. (,,...,,, ) 2 2 are known as the first level Haar wavelets. The low pass trend coefficients can likewise be expressed as a m = f V m, where ( ) V = 2,,,,...., 2 ) V 2 (, =,,,,,...., 2 2 V N/2 = (,,...,,. ), 2 2 are known as the first level Haar scaling signals. This vector multiplication representation extends easily to other Wavelet families. The Daubechies Wavelet transform uses more values from the signal to make averages and differences, and provides drastically improved capabilities from this small change. A particularly useful, and widely used transform of 4
the Daubechies family is the Daub4. Like the Haar wavelets, the trend and fluctuation coefficients are produced by a dot product: a m = f V m and d m = f W m : V = (α, α 2, α 3, α 4,,,...., ) V 2 = (,, α, α 2, α 3, α 4,,,...., ). V N/2 = (,,...,α, α 2, α 3, α 4,, ) V N/2 = (α, α 2,,,...,, α 3, α 4 ) where and α = + 3 4, α 2 2 = 3+ 3 4, α 2 3 = 3 3 4, α 2 4 = 3 4 2 W = (β, β 2, β 3, β 4,,,...., ) W 2 = (,, β, β 2, β 3, β 4,,,...., ). W N/2 = (,,...,β, β 2, β 3, β 4,, ) W N/2 = (β, β 2,,,...,, β 3, β 4 ) where β = 3 4, β 2 2 = 3 3 4, β 2 3 = 3+ 3 4, β 2 4 = 3 4. 2 By performing an inverse Wavelet Transform on the wavelet coefficients of a signal, like when performing an inverse Fourier Transform, the original signal is 5
exactly reproduced. A few key applications of Wavelets involve careful removal of certain coefficients before restoring the original signal. For most signals, most of the meaningful information is carried in only a few frequency ranges. By ignoring all coefficients approximately equal to zero, the all the information in a long signal can be represented by a fraction of the number of wavelet coefficients. This compression, while technically lossy, can produce arbitrarily accurate decompressed signals, depending on where the removal threshold is set. Wavelet Transforms can also be used to remove noise from a signal. If the meaningful signal has wavelet coefficients above a certain threshold, and the noise s coefficients are below this threshold, simply setting all transform coefficients below this threshold to zero gives a good approximation of the meaningful signal. It is this denoising ability of Wavelet Transforms that we will explore in more detail. [].2 Polarized Targets A prospective application for wavelet denoising techniques is cleaning NMR signals that measure the polarization of given substances. Unpaired nuclear spins under the influence of an external magnetic field tend to align themselves with this field, or polarize. Higher polarizations than those attainable through brute force magnetization are available with Dynamic Nuclear Polarization. In Dynamic Nuclear Polarization, or DNP, the material to be polarized is doped, chemically or via irradiation, with paramagnetic impurities. This doped material, modeled here 6
as a nucleon and electron, has a Hamiltonian with three terms; two Zeeman terms from the nucleon s and electron s magnetic moments, and one from the spin interaction between them. In this example, there are four pure states,,,, in order of increasing energy where up is aligned and down is anti-aligned (here represent the up and down spins of the nucleon, and the same for the electron). By bringing a doped sample to equilibrium in a magnetic field and cooled to a low temperature, it will be naturally (brute force) polarized, and will be the most populated state. Bombarding this sample with photons with the energy of the energy gap between states and, transitions from this 2nd to this 3rd state will occur. Since the nucleon has drastically longer relaxation time than the electron, most of these will decay to. Thus the spin of the electron is used to induce the anti-aligned nucleons into aligned states. This photon bombardment inducement is the key mechanism of DNP. Since measuring the polarization of the material is equivalent to measuring net nuclear magnetization, we can use Nuclear Magnetic Resonance, NMR. techniques to measure polarization. The NMR measures the absorptive component of the magnetic susceptibility, and integrating this component over all frequencies is directly proportional to the polarization of the material. Polarization shows up on the NMR s frequency sweeps as bumps, and by subtracting a baseline, data taken without polarized material introduced, the sum under this bump can be found. [3] Like any real world application, these NMR sweep signals are subject to 7
noise. By averaging over many sweeps, some of the noise is reduced, but a more rigorous denoising method would be advantageous..3 Wavelet Denoising Three approaches to denoising were investigated, all of which were based on the Daubechies-4 wavelet transform. Using Labview s wavelet transform tool, two Labview scripts were written (see diagrams in Appendix.). The first of these Labview programs, hereafter known as the Selective Omission method, loads data, performs a wavelet transform, and allows a range of wavelet coefficients to be set to zero before performing an inverse transform to restore the signal. Labview s built-in wavelet transform tool requires the set of data to be a power of two, 2 n, in length and performs the transform to the maximum n levels. Knowing this, one can choose to omit a range of wavelet coefficients corresponding to unwanted frequencies; for example, for a signal of 24 values, setting values 52 to 24 to zero removes the highest frequency band, setting values 256 to 24 to zero removes the two highest frequency bands, and setting value to zero removes the lowest frequency band from the signal. The selection of values to omit should be done deliberately. Since each range between the powers of 2 represents time values for a frequency band, the wavelet coefficients exist as both a time and frequency axis. If values 768 to 24 are omitted, the highest frequency band will be removed, but only for the second half (in time) of the original signal. Likewise omitting values 52 to 768 will remove the highest frequency band from first half of the original signal. In our 8
case, the entire frequency band will be removed. This method would be most useful if the meaningful signal is in a different part of the frequency spectrum from the noise. The second program written with Labview s wavelet transform tool, hereafter known as Threshold Omission, performs a wavelet transform and sets every wavelet coefficient whose absolute value is below a set value to be zero before performing the inverse transform. Assuming the wavelet coefficients for the meaningful portion of the signal are larger than those coefficients corresponding to noise, this method should be effective in removing the noisy values. This method s chief advantage over the Selective Omission method is it s lack of limitation by a frequency range. If the noise exists in many frequency ranges, including those that contain meaningful data, extracting the noise from the signal by tossing out all values of a frequency range is ineffective. By removing the weak coefficients, we have the ability to remove noise not only from any frequency range, but also from any point in time within that frequency band. The final method explored was the denoising function of Matlab s Wavelet Toolbox. Matlab s built-in denoising utility combines the abilities of the two Labview programs written by the experimenter. The utility performs a wavelet transform to a level specified by the user, so signals of length not equal to a power of two can be used. Each frequency band is displayed, (a n,d n,d n,..., d ) and a different threshold value can be chosen for each (again, see pictures in Appendix A). 9
The ability to set a threshold for each frequency band makes the denoising utility much more flexible. Like the Selective Omission method, frequency bands where only noise exists can be penalized more heavily, and like Threshold Omission, noise that exists within a frequency range that also contains meaningful data can be safely removed. 2 Investigation 2. Test Signals In order to become familiar with the capabilities of each of the three methods, practice signals were created. A wave packet like signal, and a variable frequency signal, both shown in Figure, were created. "wavelet/test\ Signals/packet.txt" "wavelet/test\ Signals/varfreq.txt".8.8.6.6.4.4.2.2 -.2 -.2 -.4 -.4 -.6 -.6 -.8 -.8-2 4 6 8 2-2 4 6 8 2 Figure : Test Signals To add noise to these signals, static was recorded from the NMR using a digital oscilloscope. This noise was then multiplied by different scaling factors and added to the ideal signals. Five noisy signals were created for both original test functions, with the first having weak noise compared to the meaningful
signal, and the fifth being entirely overwhelmed by noise. See appendix A.2 for example signals. The Labview scripts had problems providing a clean signal. As expected, the selection method was effective at eliminating noise at a higher frequency than the meaningful signal, but the noise added included frequency components in ranges with meaningful data. While this method certainly denoises impressively, it doesn t provide enough advantage to be chosen over our other methods. The threshold method proved promising, but also had important flaws. For softer noise, the threshold method denoised effectively, but even the first level noisy signals had noise peaks that were too strong for this method. As seen in the appendices, the threshold method let through peaks of noise, especially when the noise was strong in comparison to the signal. The Matlab method was much more effective. Since it s thresholds are set at each frequency range, it avoided the selection method s problem of removing noise in frequency ranges with meaningful data. Frequency ranges predominantly consisting of noise could be removed entirely, which the threshold method could not accomplish. Even when the noise overwhelmed the real signal, this method produced impressive results (see figure 8). The most noticeable differences between the signal before noise was added and Matlab s denoised signal was a very low frequency wave in the data, a result of using only one sweep to generate the noise added. With averaging, this abberation should disappear.
2.2 Polarized Target Signals To observe the denoising methods effects on actual polarized target NMR data, four signals were captured. These deuteron NMR signals are averages of only 2 sweeps, so the denoising effects of the averaging are minimal. These four signals were passed through all three denoising methods, as seen in appendix A.3. As seen with the test signals, Matlab s denoising utility proved most effective at removing noise. Signal 23, a relatively high noise signal is shown in figure 2..6 "wavelet/modsignal_23.txt".5 "matmodsignal_23b.txt".5.4.4.3.3.2.2 e-4. -. -.2 -.3 2 3 4 5 6 -. 2 3 4 5 6.6 "selmodsignal_23.txt".6 "thrmodsignal_23.txt".5.5.4.4.3.3.2.2.. -. -. -.2 -.2 2 3 4 5 6 -.3 2 3 4 5 6 Figure 2: NMR Signal 23 and Denoised Signals, (Original, top left; Matlab, top right; Selection, bottom left; Threshold, bottom right) The selection method seen here again removes all the noise from frequen- 2
cies outside the meaningful range, but lower frequency noise creeps in. The threshold method removes a good deal of weak noise, but much of the strong noise seen here makes it through. Matlab s denoising utility provided consistently better denoised NMR signals. By allowing the user to set a threshold at each frequency level, it becomes much more flexible in removing unwanted portions of a signal. Although lacking in comparison to Matlab, the threshold method can be effectively used when the noise is weak compared to the signal. The selection method is equally effective when the unwanted noise only occurs in a given frequency range. Wavelet transforms are incredibly powerful when used properly. Manipulating the wavelet coefficients of a signal before inverting the transform has proven effective for removing noise from signals, and polarized target NMR signals in particular. Matlab s denoising method is recommended for any application where denoising is required. 3
A Appendices A. Test Signal Denoising "wavelet/test\ Signals/packet.txt".8.6.4.2 -.2 -.4 -.6 -.8-2 4 6 8 2 Figure 3: Original Packet Test Signal.5 "wavelet/test\ Signals/packet.txt".4 "matpacketb.txt".2 -.2 -.5 -.4 -.6 - -.8 - -.5 -.2 -.4-2 2 4 6 8 2 -.6 2 4 6 8 2 5 "wavelet/test\ Signals/selpacket.txt" 5 "wavelet/test\ Signals/thrpacket.txt" -5-5 - - -5-5 -2 2 4 6 8 2-2 2 4 6 8 2 Figure 4: First Noisy Packet Signals and Denoised Signals, (Noisy, top left; Matlab, top right; Selection, bottom left; Threshold, bottom right) 4
- "wavelet/test\ Signals/packet.txt".8.6.4.2 -.2 -.4 -.6 -.8 2 4 6 8 2 Figure 5: Original Packet Test Signal "wavelet/test\ Signals/packet2.txt" "matpacket2b.txt" -.2 -.5 -.4 -.6 - -.8 - -.2 -.5 -.4 -.6-2 -.8-2 -2.5 2 4 6 8 2-2.2 2 4 6 8 2 "wavelet/test\ Signals/selpacket2.txt" "wavelet/test\ Signals/thrpacket2.txt" -5-5 - - -5-5 -2-2 -25 2 4 6 8 2-25 2 4 6 8 2 Figure 6: Second Noisy Packet Signals and Denoised Signals, (Noisy, top left; Matlab, top right; Selection, bottom left; Threshold, bottom right) A.2 NMR Data Signals References [] J. S. Walker, A Primer on Wavelets and their Scientific Applications. (CRC Press LLC, Florida, 999) 5
- "wavelet/test\ Signals/packet.txt".8.6.4.2 -.2 -.4 -.6 -.8 2 4 6 8 2 Figure 7: Original Packet Test Signal -.5 "wavelet/test\ Signals/packet3.txt" -.8 "matpacket3b.txt" -2-2 -2.2-2.4-2.5-2.6-2.8-3 -3-3.2-3.5-3.4-3.6-4 2 4 6 8 2-3.8 2 4 6 8 2-5 "wavelet/test\ Signals/selpacket3.txt" -5 "wavelet/test\ Signals/thrpacket3.txt" -2-2 -25-25 -3-3 -35-35 -4 2 4 6 8 2-4 2 4 6 8 2 Figure 8: Third Noisy Packet Signals and Denoised Signals, (Noisy, top left; Matlab, top right; Selection, bottom left; Threshold, bottom right) [2] R. Polikar. The Engineer s Ultimate Guide to Wavelet Analysis, The Wavelet Tutorial. (http://users.rowan.edu/ polikar/wavelets/wttutorial. 6
- "wavelet/test\ Signals/varfreq.txt".8.6.4.2 -.2 -.4 -.6 -.8 2 4 6 8 2 Figure 9: Original Variable Frequency Test Signal "wavelet/test\ Signals/varfreq.txt".5 "matvarfreqb.txt".5 -.5 -.5 - - -.5 -.5-2 2 4 6 8 2-2 2 4 6 8 2 "wavelet/test\ Signals/selvarfreq.txt" "wavelet/test\ Signals/thrvarfreq.txt" 5 5-5 -5 - - -5-5 -2 2 4 6 8 2-2 2 4 6 8 2 Figure : First Noisy Packet Signals and Denoised Signals, (Noisy, top left; Matlab, top right; Selection, bottom left; Threshold, bottom right) [3] P. McKee. The Spin Structure Function of the Proton From SLAC Experiment E55. (University of Virginia, 2) 7
- "wavelet/test\ Signals/varfreq.txt".8.6.4.2 -.2 -.4 -.6 -.8 2 4 6 8 2 Figure : Original Variable Frequency Test Signal.5 "wavelet/test\ Signals/varfreq2.txt" "matvarfreq2b.txt" -.5 -.5 - - -.5 -.5-2 -2-2.5 2 4 6 8 2-2.5 2 4 6 8 2 5 "wavelet/test\ Signals/selvarfreq2.txt" 5 "wavelet/test\ Signals/thrvarfreq2.txt" -5-5 - - -5-5 -2-2 -25 2 4 6 8 2-25 2 4 6 8 2 Figure 2: Second Noisy Packet Signals and Denoised Signals, (Noisy, top left; Matlab, top right; Selection, bottom left; Threshold, bottom right) 8
- "wavelet/test\ Signals/varfreq.txt".8.6.4.2 -.2 -.4 -.6 -.8 2 4 6 8 2 Figure 3: Original Variable Frequency Test Signal - "wavelet/test\ Signals/varfreq3.txt" -.5 "matvarfreq3b.txt" -.5-2 -2-2.5-2.5-3 -3-3.5-3.5-4 -4.5 2 4 6 8 2-4 2 4 6 8 2 - "wavelet/test\ Signals/selvarfreq3.txt" - "wavelet/test\ Signals/thrvarfreq3.txt" -5-5 -2-2 -25-25 -3-3 -35-35 -4-4 -45 2 4 6 8 2-45 2 4 6 8 2 Figure 4: Second Noisy Packet Signals and Denoised Signals, (Noisy, top left; Matlab, top right; Selection, bottom left; Threshold, bottom right) 9
-.3.6 "wavelet/modsignal_23.txt".5 "matmodsignal_23b.txt".5.4.4.3.3.2.2 e-4. -. -.2 2 3 4 5 6 -. 2 3 4 5 6.6 "selmodsignal_23.txt".6 "thrmodsignal_23.txt".5.5.4.4.3.3.2.2.. -. -. -.2 -.2 2 3 4 5 6 -.3 2 3 4 5 6 Figure 5: NMR Signal 23 and Denoised Signals, (Original, top left; Matlab, top right; Selection, bottom left; Threshold, bottom right) 2
-.4. "wavelet/modsignal_43.txt".8 "matmodsignal_43b.txt".8.7.6.6.5.4.4.2.3.2. -.2 2 3 4 5 6 -. 2 3 4 5 6.9 "selmodsignal_43.txt" "thrmodsignal_43.txt".8.7.8.6.6.5.4.4.3.2.2. -.2 -. -.2 2 3 4 5 6 -.4 2 3 4 5 6 Figure 6: NMR Signal 43 and Denoised Signals, (Original, top left; Matlab, top right; Selection, bottom left; Threshold, bottom right) 2
-.4.4 "wavelet/modsignal_63.txt".4 "matmodsignal_63b.txt".2.2...8.8.6.6.4.4.2.2 -.2 2 3 4 5 6 -.2 2 3 4 5 6.4 "selmodsignal_63.txt".4 "thrmodsignal_63.txt".2.2.8.8.6.6.4.4.2.2 -.2 -.4 -.2 2 3 4 5 6 -.6 2 3 4 5 6 Figure 7: NMR Signal 63 and Denoised Signals, (Original, top left; Matlab, top right; Selection, bottom left; Threshold, bottom right) 22
-.5.2 "wavelet/modsignal_83.txt".8 "matmodsignal_83b.txt".6.5.4.2...8.5.6.4.2 2 3 4 5 6 -.2 2 3 4 5 6 2 "selmodsignal_83.txt".8 "thrmodsignal_83.txt".6.5.4.2.8.5.6.4.2 -.5 2 3 4 5 6 -.2 2 3 4 5 6 Figure 8: NMR Signal 83 and Denoised Signals, (Original, top left; Matlab, top right; Selection, bottom left; Threshold, bottom right) 23