0% found this document useful (0 votes)
30 views8 pages

BME404 Lab 04 July 2023

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views8 pages

BME404 Lab 04 July 2023

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

BME 404: Medical Imaging Sessional

Lab 04: Ultrasound RF Signal Processing

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.

Typical B-mode Recieve Processing Chain

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:

• Pre-beamformed digital RF data from individual channels


• Beamformed RF data

©2023, Department of Biomedical Engineering, BUET Page 1


• Envelope detected data
• Interpolated image data

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.

What is 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:

©2023, Department of Biomedical Engineering, BUET Page 2


The Hilbert transform has a particularly simple representation in the frequency domain: it imparts a
phase shift of 90o to every Fourier component of a function. For example, the Hilbert transform of
cos(wt), where w>0, is cos (wt-π/2)

Analytic Signal

An analytic signal is composed of the original waveform g(t) and its Hilbert transform ˜g(t) in the
following manner:

Hilbert Transform as an Envelope Extractor

Let us use a dummy example, if

the analytic signal can be written explicitly as

To obtain the envelope of the original signal g(t) it is necessary to take the absolute value of the analytic
signal as

The result may now be impletended quite easily in MATLAB:


close all
clear all
clc

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:')

©2023, Department of Biomedical Engineering, BUET Page 3


Lab Protocol:

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.

1. Run the script called field.m to initialize the FIELD II software.


2. Run the script called cyst_pht.m to generate the positions of scatterers in the cyst.
3. Run the script called sim_img.m to generate the synthetic RF data

Let us now write the code for generating the B-mode image

First we have to declare the system parameters:

f0=3.5e6; % Transducer center frequency [Hz]


fs=100e6; % Sampling frequency [Hz]
c=1540; % Speed of sound [m/s]
no_lines=50; % Number of lines in image
image_width=40/1000; % Size of image sector
d_x=image_width/no_lines; % Increment for 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

©2023, Department of Biomedical Engineering, BUET Page 4


We may now observe the image. However, the image will not be visible because of the problem
with the dynamic range of the image. As the values in the envelope matrix are extremely low
(explain why), they are simply considered as black pixels. You can run the following code
snippet to verify.

[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:

©2023, Department of Biomedical Engineering, BUET Page 5


D=10;
norm_env=env(1:D:max(size(env)),:)/max(max(env));
[n,m]=size(norm_env);
ID=20;
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,nor
m_env)
xlabel('Lateral distance [mm]')
ylabel('Axial distance [mm]')
colormap(gray(127))
axis('image')
axis([-20 20 35 90])

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))

©2023, Department of Biomedical Engineering, BUET Page 6


Report

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.

©2023, Department of Biomedical Engineering, BUET Page 7


4. Perform gain adjustment (balance the brightness and contrast), contrast enhancement
(histogram equalization, contrast stretching, adaptive contrast enhancement) and edge
enhancement (Laplacian or gradient filters) to better visualize the tissue characteristics and
distinguish between the structures.
5. As an engineer when you are designing such a tool for a radiologist, it is convenient if you can
develop a graphical user interface (GUI) which contains all the functionalities shown in this
experiment. Using MATLAB, develop a GUI called 18180xx_BME404_USGUI, which does just
that. Submit the code of the GUI file in Teams and include a snapshot of the GUI in your report.
Following is a sample of one such GUI, you DO NOT NEED to follow the exact interface.

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.

©2023, Department of Biomedical Engineering, BUET Page 8

You might also like