# A QUICK START DEMO - simulations, demodulation, beamforming, compounding

In this quick'n easy tutorial, it is shown how to simulate an ultrasound image from the transmit of plane waves. A few scatterers will be insonified with steered planes waves to obtain a compound image. You will use the following fundamental steps:

1. A transducer will be chosen with GETPARAM,
2. Transmit delays will be designed with TXDELAY
3. A pressure field will be calculated with PFIELD
4. RF signals will be simulated with the function SIMUS.
5. The RF signals will be I/Q demodulated with RF2IQ,
6. then beamformed with DAS.
7. A compound image will eventually be generated.

## Scatterers

Define a few scatterers ...

xs = [1.7 1.3 0.7 0 -0.7 -1.3 -1.7 0 -1 1]*1e-2; % in m
zs = [2.8 3.2 3.5 3.6 3.5 3.2 2.8 2 0.8 0.8]*1e-2; % in m


... with their reflection coefficients

RC = ones(size(xs));


## Select a transducer with GETPARAM

We want a 128-element linear array.

param = getparam('L11-5v');


The structure param contains the tranducer properties.

## Design the transmit delays with TXDELAY

The scatterers will be insonified with 21 plane waves steered at -10 to +10 degrees.

tilt = linspace(-10,10,21)/180*pi; % tilt angles in rad
txdel = cell(21,1); % this cell will contain the transmit delays


Use TXDELAY to calculate the transmit delays for the 21 plane waves.

for k = 1:21
txdel{k} = txdelay(param,tilt(k));
end


## Check a pressure field with PFIELD

Let us visualize the 5th pressure field.

Define a 100 100 8-cm-by-8-cm grid.

[xi,zi] = meshgrid(linspace(-4e-2,4e-2,100),linspace(0,8e-2,100));


Simulate the pressure field.

P = pfield(xi,zi,txdel{5},param);


Display the 5th pressure field.

imagesc(xi(1,:)*1e2,zi(:,1)*1e2,20*log10(P/max(P(:))))
caxis([-30 0]) % dynamic range = [-30,0] dB
c = colorbar;
c.YTickLabel{end} = '0 dB';
colormap([1-hot; hot])
set(gca,'XColor','none','box','off')
axis equal ij
ylabel('[cm]')
title('The 5^{th} plane wave - RMS pressure field')


## Simulate RF signals with SIMUS

We will now simulate 21 series of RF signals. Each series will contain 128 RF signals, as the simulated linear array contains 128 elements.

RF = cell(17,1); % this cell will contain the RF series
param.fs = 4*param.fc; % sampling frequency in Hz

option.WaitBar = false; % remove the progress bar of SIMUS
for k = 1:21
RF{k} = simus(xs,zs,RC,txdel{k},param,option);
end


This is the 64th RF signal of the 1st series:

rf = RF{1}(:,64);
t = (0:numel(rf)-1)/param.fs*1e6; % time (ms)
plot(t,rf)
set(gca,'YColor','none','box','off')
xlabel('time (\mus)')
title('RF signal of the 64^{th} element (1^{st} series, tilt = -20{\circ})')
axis tight


## Demodulate the RF signals with RF2IQ

Before beamforming, the RF signals must be I/Q demodulated.

IQ = cell(21,1);  % this cell will contain the I/Q series

for k = 1:21
IQ{k} = rf2iq(RF{k},param.fs,param.fc);
end


This is the 64th I/Q signal of the 1st series:

iq = IQ{1}(:,64);
plot(t,real(iq),t,imag(iq))
set(gca,'YColor','none','box','off')
xlabel('time (\mus)')
title('I/Q signal of the 64^{th} element (1^{st} series, tilt = -10{\circ})')
axis tight


## Beamform the I/Q signals with DAS

It is recommended to use an adequate receive f-number when beamforming. Define a void f-number; it will be determined automatically by DAS from the element directivity.

param.fnumber = [];


Define a 200 200 4-cm-by-4-cm image grid.

[xi,zi] = meshgrid(linspace(-2e-2,2e-2,200),linspace(0,4e-2,200));


Beamform the I/Q signals using a delay-and-sum with the function DAS.

bIQ = zeros(200,200,21);  % this array will contain the 21 I/Q images

h = waitbar(0,'');
for k = 1:21
waitbar(k/21,h,['DAS: I/Q series #' int2str(k) ' of 21'])
bIQ(:,:,k) = das(IQ{k},xi,zi,txdel{k},param);
end
close(h)


## Compound ultrasound image

An ultrasound image is obtained by log-compressing the amplitude of the beamformed I/Q signals. Have a look at the images obtained when steering at -10 degrees.

I = bmode(bIQ(:,:,1),40); % log-compressed image
imagesc(xi(1,:)*1e2,zi(:,1)*1e2,I)
colormap gray
title('PW-based echo image with a tilt angle of -10{\circ}')

axis equal ij
set(gca,'XColor','none','box','off')
c = colorbar;
c.YTick = [0 255];
c.YTickLabel = {'-40 dB','0 dB'};
ylabel('[cm]')


The individual images are of poor quality. Generate a compound image with the series of 21 diverging waves steered at different angles.

cIQ = sum(bIQ,3); % this is the compound beamformed I/Q
I = bmode(cIQ,40); % log-compressed image
imagesc(xi(1,:)*1e2,zi(:,1)*1e2,I)
colormap gray
title('Compound PW-based echo image')

axis equal ij
set(gca,'XColor','none','box','off')
c = colorbar;
c.YTick = [0 255];
c.YTickLabel = {'-40 dB','0 dB'};
ylabel('[cm]')


Another demonstration to know more about SIMUS: Diverging-wave echocardiography

Damien Garcia, Eng., Ph.D.
Creatis, University of Lyon, France