Lab 09 : Ultrasound simulation


Field II simulator

In this part we will examine the basic properties of US imaging systems using the Field II simulator. The Field II simulator is an environment for the numeric simulation of ultrasound signals. The simulator is capable of numerically simulating emitted and received acoustic fields for a broad range of acoustic transducers. With the simulator it is for example possible to acquire data and reconstruct images similarly to a conventional ultrasound imaging device. However we will only cover simple properties of the acoustic signals and fields generated by an array of transducers.


Field II is distributed as a bundle of Matlab functions for various operating system (Win, Unix, …). To use the simulator , do the following:

  1. Download the appropriate version of the Field II simulator for your operating system ( Field II for Windows, Field II for Linux, Field II for Mac OS ) or from project webpage Field II download.
  2. Extract the archive into an appropriate project folder. To unwrap the .tar.gz file on linux (especialy on the school computers) open the terminal, navigate the project folder using cd, create a new folder using mkdir (mkdir Field_II) and extract the files using tar (tar -xvzf Field_II_ver_3_30_linux.tar.gz -C ./Field_II); on windows the tar.gz is not supported by the operating system, but third party software like WinZip or 7-zip should work, but you might need to first unzip and then untar the file; and on mac you could use the commandline approach using the tar utility similarly to linux or use a third party app (some forums suggest TunesBro FossZIP or The Unarchiver).
  3. there are some issues on Mac computers with the M1 processor, see Field II download page for a workaround.
  4. Start Matlab and add the Field II simulator to the search path using addpath('path_to_fieldii')
  5. Start the simulator field_init;, simulate signals and fields and then end the simulator field_end;

Description of some functions from the Field II simulator

This file contains the description of several functions. Complete description of the simulator Field II is in the user's guide.

1. US field simulation

The first task consists of a few steps:

  1. Setting up the acoustic environment
  2. Modelling the impulse response of the transducers
  3. Visualizing the acoustic field

Alternatively, instead of writing your simulation from scratch, you can use this prepared m-file.

1.1 Acoustic environment

We set up the acoustic system with the following parameters:

  • Speed of propagation in the environment 1540 m/s
  • Sampling frequency 100 MHz
  • Transducer – transmitter (function xdc_linear_array)
    • Number of elements 128
    • Space between elements 0.02 mm
    • Width of the elements 0.2 mm
    • Height of the elements 5 mm
    • Coordinates of the fixed focus [0 0 30] mm
    • Subdividion of elements in x 1
    • Subdivision of elements in y 4

1.2 Impulse response

The function xdc_impulse modifies the impulse response of the transducer. We will use the impulse response in shape of Gaussian-modulated sinusoidal pulse. Use the gauspuls function for the generation of the impulse response.

tc = gauspuls('cutoff',fc,bw,bwr,tpe)

In this mode the function returns the cutoff time tc at which the trailing pulse envelope falls below tpe dB with respect to the peak envelope amplitude. After estimating an appropriate values for the cutoff time we obtain the impulse response in the form of Gaussian-modulated sinusoidal pulse with a following call to the gauspuls function.

yi = gauspuls(t,fc,bw,bwr)

For our simulation, we will use the following parameters of the impulse response:

  • Central frequency (fc) 7.5 MHz
  • Fractional bandwidth (bw) 50% with the reference level (bwr) at -6 dB
  • The length of the impulse response will be such that the cutoff time will when the amplitude drops by 40 dB (tpe)
  • The impulse response has generated in time interval from - cutoff time to + cutoff time with correct time steps (sampling frequency)

Let the excitation of the transducer be the Dirac impulse.

1.3 Acoustic field

When excited by the excitation signal the piezoelectric elements start to oscillate and the transducer emits an acoustic pulse into the environment. The Field II simulator simulates the pressure field for the given transducer and excitation signal. In the simulation we can measure the time dependent changes in pressure at a certain point in the environment.

The emitter which we set up in the acoustic system part emits an ultrasound ray alongside the z-axis. The ray is focused to the distance 30 mm.

Simulate the time dependent changes on a line of points evenly distributed from -1 mm to 1 mm with the step 0.02 mm that runs parallel to the x-axis and goes through the fixed focus (x = -1:0.02:1, y = 0, z = 30 mm). Use function calculate_hp to calculate the pressure field (see the help page for the format of the coordinates).

Task 1.2.1 Visualize the time dependent changes in the simulated pressure field.

HW 1.2.2 [1 pt] Repeat the pressure field simulation, but measure the pressure changes also on lines 25 mm and 35 mm from the transducer. Visualize the maximum values of pressure in dB (20*log10(Pm/max(Pm))) in each point along the three lines. Compare the shape of the normalized pressure maxima, notice especially the side lobes. How do the side lobes affect the US imaging (the lateral resolution)?

HW 1.2.3 [1 pt] Examine the effect of the central frequency on the side lobes. Repeat the steps 1.2.1 and 1.2.2 for two different central frequencies (for example 5 MHz and 10 MHz) and compare the results of the different central frequencies. Discuss the results and their practical implications.

BONUS 1.2.4 [1 pt] Try to eliminate the side lobes by apodization (function xdc_apodization, choose the profil hanning or blackmann), visualize the shape of the normalized pressure similarly to task 1.2.2, discuss the effect of apodization on the lateral resolution.

2. B-mode of water-filled cyst phantom

In this part of the lab we will use the Field II simulator for the ultrasound imaging of a simple phantom of water filled cysts. The task is based on an example provided by the authors of the simulator. However our experiment will be a bit simpler. The archive contains the simplified version.

The project is split into a few scripts.

  • field.m initializes the Field II simulator
  • cyst_pht.m defines the function that generates the cyst phantom
  • mk_pht.m generates the cyst phantom with the defined number of scatterers.
  • sim_img.m performs the simulation (sending ultrasound waves and receiving echoes)
  • make_image.m generates a pretty image from the measured data

The phantom of water filled cysts consists of uniformly distributed particles that randomly scatter ultrasound waves (also called scatterers in the Field II). The scatterers are in a block of size 20 x 10 x 40 mm and there are $10^4$ scatterers (you can try more, but more than $10^5$ may result in a very long computation times for the simulation). The sizes of the water-filled cysts are 6, 4 and 2 mm and are positioned along the middle at 10, 20 and 30 mm from the start. The properties of water are simulated by making the amplitude of scattering zero (or not scattering the ultrasound waves at all).

Task 2.1 Visualize the phantom. Try plot3 function.

After setting up the environment by running the field.m script and creating the phantom by executing the mk_pht.m script, we can run the simulation of the ultrasound measurement by executing the sim_img.m script. The simulation consists of scanning 40 ultrasound beams. The simulation doesn't keep the data in the workspace, but saves them in rf_data folder in the project folder. And after finishing simulating all the lines, you can create the image be by running the make_image.m script.

Task 2.2 Examine the scripts and make sure that you understand how it works.

Task 2.3 Run the simulation and admire the results.

HW 2.4 [1 pt] Update the phantom so that will also include 3 high scattering objects of different sizes (5, 3 and 1 mm). Put them alongside the water-filled cysts (for example by moving the water-filled cysts to $x=-5$ and the high density objects to $x=5$). Simulate the high scattering properties of the objects by making the amplitudes of the scatterers 10 times higher. Visualize the phantom, put the image into the report and also submit the ph_data.mat with the updated phantom alongside the report.

HW 2.5 [2 pt] Repeat the simulation of the B-mode with the updated phantom. You can try to to change the parameters of the simulation, you may want to add more lines, etc. In that case, make sure that you adjust all scripts accordingly, you have to change no_lines and image_width parameters in scripts sim_img.m and make_image.m; in the script make_image.m you also have to change the axes limits. Visualize the result of the simulation with the updated phantom, put the resulting image in the report and comment on the results.

Hint the simulation is not excessively computationally demanding, however the scripts are written in a way that the execution can be run in parallel on multiple computers. If you have a more powerful computer you can try to run the simulation in parallel on your machine. Simply run multiple instances of Matlab that run the same script, however check your resources and how much of them uses one instance of the simulation, before you trying to parallelize.

Matlab can be run from command line without GUI, running a worker on linux computer could look like:

matlab -nosplash -nodesktop -r "run('field.m');run('sim_img.m');exit"

but you might need to add paths, and other things.

courses/zsl/labs2024_09_ussim.txt · Last modified: 2024/04/17 12:46 by anyzjiri