kWave
A MATLAB toolbox for the timedomain
simulation of acoustic wave fields
 Getting Started
 Examples
 Initial Value Problems
 Example: Homogenous Propagation Medium
 Example: Using A Binary Sensor Mask
 Example: Defining A Sensor Mask By Opposing Corners
 Example: Loading External Image Maps
 Example: Heterogeneous Propagation Medium
 Example: Saving Movie Files
 Example: Recording The Particle Velocity
 Example: Defining A Gaussian Sensor Frequency Response
 Example: Comparison Of Modelling Functions
 Example: Setting An Initial Pressure Gradient
 Example: Simulations In One Dimension
 Example: Simulations In Three Dimensions
 Example: Photoacoustic Waveforms in 1D, 2D and 3D
 Time Varying Source Problems
 Example: Monopole Point Source In A Homogeneous Propagation Medium
 Example: Dipole Point Source In A Homogeneous Propagation Medium
 Example: Simulating Transducer Field Patterns
 Example: Steering A Linear Array
 Example: Snell's Law And Critical Angle Reflection
 Example: The Doppler Effect
 Example: Diffraction Through A Slit
 Example: Simulations In ThreeDimensions
 Sensor Directivity
 Example: Focussed Detector in 2D
 Example: Focussed Detector in 3D
 Example: Modelling Sensor Directivity in 2D
 Example: Modelling Sensor Directivity in 3D
 Example: Sensor Element Directivity in 2D
 Example: Focussed 2D Array with Directional Elements
 Photoacoustic Image Reconstruction
 Example: 2D FFT Reconstruction For A Line Sensor
 Example: 3D FFT Reconstruction For A Planar Sensor
 Example: 2D Time Reversal For A Line Sensor
 Example: 2D Time Reversal For A Circular Sensor
 Example: 3D Time Reversal For A Planar Sensor
 Example: 3D Time Reversal For A Spherical Sensor
 Example: Image Reconstruction With Directional Sensors
 Example: Image Reconstruction With Bandlimited Sensors
 Example: Iterative Image Improvement Using Time Reversal
 Example: Attenuation Compensation Using Time Reversal
 Example: Attenuation Compensation Using Time Variant Filtering
 Example: Automatic Sound Speed Selection
 Diagnostic Ultrasound Simulation
 Example: Defining An Ultrasound Transducer
 Example: Simulating Ultrasound Beam Patterns
 Example: Using An Ultrasound Transducer As A Sensor
 Example: Simulating Bmode Ultrasound Images
 Example: Simulating Bmode Images Using A Phased Array
 Numerical Analysis
 Example: Controlling The Absorbing Boundary Layer
 Example: Source Smoothing
 Example: Filtering A Delta Function Input Signal
 Example: Modelling Power Law Absorption
 Example: Modelling Nonlinear Wave Propagation
 Example: Optimising kWave Performance
 Using The C++ Code
 Elastic Wave Propagation
 Example: Explosive Source In A Layered Medium
 Example: Plane Wave Absorption
 Example: Shear Waves And Critical Angle Reflection
 Example: Simulations In Three Dimensions
 Functions  By Category
 Functions  Alphabetical List
 Release Notes
 License
kWave Toolbox 
attenComp
Attenuation compensation using timevariant filtering
Syntax
signal = attenComp(signal, dt, c, alpha_0, y) signal = attenComp(signal, dt, c, alpha_0, y, ...) [signal, tfd, cutoff_freq] = attenComp(signal, dt, c, alpha_0, y) [signal, tfd, cutoff_freq] = attenComp(signal, dt, c, alpha_0, y, ...)
Description
attenComp
corrects for frequency dependent acoustic attenuation in photoacoustic signals using timevariant filtering [1]. The timevariant filter is constructed to correct for acoustic attenuation and dispersion following a frequency power law of the form alpha_0*f^y
under the assumption the distribution of attenuation parameters is homogeneous. The filter is applied directly to the recorded timedomain signals using a form of nonstationary convolution. The approach is computationally efficient and can be used with any detector geometry or reconstruction algorithm.
To prevent highfrequency noise from being amplified, the compensation is regularised using a Tukey window with a timevariant cutoff frequency. The cutoff frequency can be specified manually using the optional input 'FilterCutoff'
. This is set as a twoelement vector corresponding to the cutoff frequency in Hz for the first and last time points, respectively. For a fixed cutoff, these should be specified as the same value, e.g., [3e6, 3e6]
. Alternatively, if 'FilterCutoff'
is set to 'auto'
(the default), the cutoff frequency is chosen based on the local timefrequency distribution of the recorded signals using the following steps:
 Compute the average timefrequency distribution of the input signals (the method can be defined using the optional input
'Distribution'
)  Threshold the timefrequency distribution to remove noise (the threshold value can be defined using the optional input
'NoiseThreshold'
)  Calculate the integral of the thresholded timefrequency distribution at each time point using
cumsum
 Find the cutoff frequency at each time point where the integral reaches a given percentage of the maximum value (this percentage can be defined using the optional input
'EnergyThreshold'
)  Increase the filter cutoff frequency by a fixed multiplier so the cutoff corresponds to the edge of the passband for the Tukey window (the multiplier can be defined using the optional input
'FrequencyMultiplier'
)  Smooth the variation of the cutoff frequency over time (the smoothing function can be defined using the optional input
'FitType'
)  Threshold any values of the cutoff frequency below zero or above the Nyquist limit
If the input contains a matrix of signals, the cutoff frequency is based on the average time frequency distribution. To calculate the cutoff frequency for each signal individually, this function should be called in a loop. This can be parallelised, for example, using parfor
from the parallel computing toolbox. For further details about this function and attenuation compensation using time variant filtering, see the reference below.
[1] B. E. Treeby (2013) "Acoustic attenuation compensation in photoacoustic tomography using timevariant filtering," J. Biomed. Opt., vol. 18, no. 3, p.036008.
Inputs

matrix of time series to compensate indexed as 

time step [s] 

sound speed [m/s] 

power law absorption prefactor [dB/(MHz^y cm)] 

power law absorption exponent [0 < y < 3, y ~= 1] 
Optional Inputs
Optional 'string', value pairs that may be used to modify the default computational settings.
Input  Valid Settings  Default  Description 


(Boolean scalar) 

Boolean controlling whether command line updates and compute time are printed to the command line. 



Timefrequency distribution used to automatically compute the filter cutoff frequency if 

(numeric scalar) 

Threshold value given as a percentage of the total amplitude spectrum used to choose the filter cutoff frequency at each time point. 

(numeric two element vector) or 

Option to manually define the cutoff frequencies for a linear variation in the filter cutoff instead of using an automatic search. 



Fitting type used to smooth the filter cutoff frequency after an automatic search, where 

(numeric scalar) 

By default, the compensation is regularised using a Tukey window with a timevariant cutoff frequency. The default Tukey window has a taper ratio of 0.5, so the filter cutoff frequency found by the automatic search is increased by a frequency multiplier so that the filter cutoff frequency corresponds to the edge of the passband of the Tukey window. 

(numeric scalar) 

Number of spline segments used in the smoothing spline if 

(numeric scalar) 

Threshold value given as a percentage of the signal maximum used to threshold the TFD before the automatic search for the filter cutoff. 

(Boolean scalar) 

Boolean controlling whether a plot of the time frequency distribution and filter cutoff frequency are displayed. 

(numeric two element vector) or 

Option to manually set the plot range in the frequency axis when 

(numeric scalar) 

Taper ratio used to construct the Tukey Windows. 

(numeric scalar) 

Time index of T0 in the input signals. For photoacoustic imaging, T0 corresponds to the arrival of the excitation laser pulse at the sample. 
Outputs

time series after attenuation compensation 

average time frequency distribution of the input signals 

filter cutoff frequency for each time index 
Examples
applyFilter  attenuationWater 
© 20092014 Bradley Treeby and Ben Cox.