BME404 Lab 04 July 2023
BME404 Lab 04 July 2023
Introduction
An ultrasound research interface (URI) is a software tool loaded onto a diagnostic clinical ultrasound
device which provides functionality beyond typical clinical modes of operation. A normal clinical
ultrasound user only has access to the ultrasound data in its final processed form, typically a B-Mode
image, in DICOM format. For reasons of device usability they also have limited access to the processing
parameters that can be modified. A URI allows a researcher to achieve different results by either
acquiring the image at various intervals through the processing chain, or changing the processing
parameters.
A typical digital ultrasound processing chain for B-Mode imaging may look as follows:
• Multiple analog signals are acquired from the ultrasound transducer (the transmitter/receiver
applied to the patient)
• Analog signals may pass through one or more analog notch filters and a variable-gain amplifier
(VCA)
• Multiple analog-to-digital converters convert the analog radio frequency (RF) signal to a digital
RF signal sampled at a predetermined rate (typical ranges are from 20MHz to 160MHz) and at a
predetermined number of bits (typical ranges are from 10 bits to 16 bits)
• Beamforming is applied to individual RF signals by applying time delays and summations as a
function of time and transformed into a single RF signal
• The RF signal is run through one or more digital FIR or IIR filters to extract the most interesting
parts of the signal given the clinical operation
• The filtered RF signal runs through an envelope detector and is log compressed into a grayscale
format
• Multiple signals processed in this way are lined up together and interpolated and rasterized into
a readable image.
Data Access
A URI may provide data access at many different stages of the processing chain, these include:
Ultrasound RF Data
Ultrasound transducers convert electrical signals into pressure waves which are transmitted
into the tissue (transmit pulse). Differences in tissue density and speed of sound cause
reflection and scattering of the transmit pulses, such that a portion of the sound waves reflect
back towards the transducer. When these waves reach the transducer, they are converted into
a receive electrical signal. The receive signal is composed of multiple reflections which combine
together to form an interference pattern known as speckle. This receive signal is commonly
referred to as RF data.
Part A: RF to B-mode
Ultrasound raw data is not well suited for the interpretation by users. Necessary is a conversion from RF
to B-mode data.
Goal: To write a MATLAB code that will convert raw RF data obtained from a URI to a B-mode image.
B-Mode is a two-dimensional ultrasound image display composed of bright dots representing the
ultrasound echoes. The brightness of each dot is determined by the amplitude of the returned echo
signal. This allows for visualization and quantification of anatomical structures, as well as for the
visualization of diagnostic and therapeutic procedures for small animal studies.
RF to B-mode Conversion
Envelope Detection
The envelope detection filters out the high frequency information of the RF signal by calculating an
envelope of the signal. The envelope is basically a non-negative curve that connects the peaks of the
original signal. Therefore, the envelope describes the developing of the amplitude. The values of the
envelope signal can then be mapped to a grayscale color map. Hilbert Transform is the most common
technique for the envelope detection of a signal.
Hilbert Transform
In mathematics and in signal processing, the Hilbert transform is a specific linear operator that takes a
function, u(t) of a real variable and produces another function of a real variable H(u)(t). This linear
operator is given by convolution with the function 1/πt:
Analytic Signal
An analytic signal is composed of the original waveform g(t) and its Hilbert transform ˜g(t) in the
following manner:
To obtain the envelope of the original signal g(t) it is necessary to take the absolute value of the analytic
signal as
t = (1:131072)*(1e-4);
gt = sin(t).*sin(10*t);
envelope = abs(hilbert(gt));
figure; plot(t,gt,'b-',t,imag(hilbert(gt)),'k--',t,envelope,'r:')
Since we do not have access to a URI, we are going to use FIELD to generate synthetic RF data and
calculate the B-mode image from the RF data.
Let us now write the code for generating the B-mode image
Next, we will construct the B-mode image line by line. The first stage is to extract the envelope
using the Hilbert Transform
min_sample=0;
for i=1:no_lines
% Load the result
cmd=['load rf_ln',num2str(i),'.mat'];
disp(cmd)
eval(cmd)
% Find the envelope
rf_env=abs(hilbert([zeros(round(tstart*fs-min_sample),1);
rf_data]));
env(1:max(size(rf_env)),i)=rf_env;
end
[n,m]=size(env);
ID=20;
D=10;
fn=fs/D;
clf
image(((1:(ID*no_lines-1))*d_x/ID-
no_lines*d_x/2)*1000,((1:n)/fn+min_sample/fs)*1540/2*1000,env)
xlabel('Lateral distance [mm]')
ylabel('Axial distance [mm]')
colormap(gray(127))
axis('image')
axis([-20 20 35 90])
A method for correcting the dynamic range of the image is through log compression. While we
could simply normalize the image to correct the range using the code snippet below, see the
problems that may arise:
Because of the extreme disparity between the values of the pixels, ony a few pixels will have
value close to 1. The rest of the pixels will be close to 0 and hence, we again end up with a dark
image.
Hence, log compression is performed so that the values come to reasonable ranges and also
there is not a wide variation in the pixel values.
log_env=env(1:D:max(size(env)),:)/max(max(env));
log_env=20*log10(log_env);
log_env=127/60*(log_env+60);
Finally, we are going to interpolate to increase the number of pixels in the data to get our
required B-mode image.
ID=20;
[n,m]=size(log_env);
new_env=zeros(n,m*ID);
for i=1:n
new_env(i,:)=abs(interp(log_env(i,:),ID));
end
[n,m]=size(log_env);
fn=fs/D;
clf
image(((1:(ID*no_lines-1))*d_x/ID-
no_lines*d_x/2)*1000,((1:n)/fn+min_sample/fs)*1540/2*1000,env
)
xlabel('Lateral distance [mm]')
ylabel('Axial distance [mm]')
colormap(gray(127))
A hand-written report (A4, both sides) needs to be handed in during the next lab class. The lab report
must be submitted individually. Any codes/images should be given in printed form, the corresponding
codes should be submitted to Teams in a single .m file renaming it as ‘‘18180xx_BME404_Lab_04.m’.
The lab report should contain answers to the following problems.
1. Apply a spatial smoothing filter to smooth the B-mode image. Show the results on MATLAB.
2. Explain speckle noise in ultrasound B-mode images. Apply a 3x3 median filter on the image.
Calculate using MATLAB the SNR of the pre-filtered and filtered image.
3. A file named “ES000100 N_2CH_3.avi” is provided in a zipped folder. Convert it to the DICOM
format. Reduce the noise in the image series by applying a speckle-reducing anisotropic
diffusion filter to each frame and save the smoothed data in another DICOM file. Generate
corresponding montage from processed data and save the output as a .mp4/.avi file.
The lab report will be graded out of 10 and the GUI will be graded out of 10. Please cite all sources you
may use to write your report in the References section. Copying/plagiarism will earn you 0 (zero) marks.
2 (two) marks will be deducted for each day of late submission.