Field _II 仿真 学习笔记

  参考Field II的使用说明,进行了四个例子的练习。仿真程序和结果如下:

奋斗PURPOSE1:Calculate the received response from all elements of a linear array and plot the responses and the summed response 【计算来自所有线性阵元的接收响应,并绘制该响应以及叠加响应。】

>> path(path,'D:\MATLAB\R2016a\Field_II_PC7');field_init 

%set initial parameters

>> f0=3e6;%Transducer center frequency

>> fs=100e6;%sampling frequency
>> c=1540;%speed of sound
>> lambda=c/f0;%wave length
>> height=5/1000;%height of element
>> width=1/1000;%width of element
>> kerf=width/4;%distance between transducer elements
>> N_elements=32;%number of elements

>> focus=[0 0 40]/1000;%initial electronic focus

%define the transducer

>> Th=xdc_linear_array(N_elements, width, height ,kerf ,2, 3, focus);%set the impulse response and excitation of the emit aperture
>> impulse_response=sin(2*pi*f0*(0:1/fs:2/f0));
>> impulse_response=impulse_response.*hanning(max(size(impulse_response)))';
>> xdc_impulse(Th,impulse_response);
>> excitation=sin(2*pi*f0*(0:1/fs:2/f0));

>> xdc_excitation(Th,excitation);

%Do the calculation

>> [v,t]=calc_scat_multi(Th,Th,[0 0 20]/1000,1);

%plot the individual response

>> subplot(211)
>> [N,M]=size(v);
>> v=v/max(max(v));
>> for i=1:N_elements
plot((0:N-1)/fs+t,v(:,i)+i),hold on
end
>> hold off
>> title('Individual traces')
>> xlabel('Time [s]')
>> ylabel('Normalized response')
>> subplot(212)
>> plot((0:N-1)/fs+t,sum(v'))
>> title('Summed response')
>> xlabel('Time[s]')
>> ylabel('Normalized response')

>> 
绘制结果:



奋斗PURPOSE2:calculate the received response from all elements of a linear array with 3 transmitting and 16receiving elements and plot the responses and the summed response [计算来自一个带有3个发送和16个接收元的线性阵的所有阵元的接收响应,并绘制该响应和叠加相应。

 f0=3e6;
fs=100e6;
c=1540;
lambda=c/f0;
height=5/1000;
width=1/1000;
kerf=width/5;
N_elements=3;
N_elements2=16;
focus=[0 0 40]/1000;
%define the transducers
Th=xdc_linear_array(N_elements,width,height,kerf,2,3,focus);
Th2=xdc_linear_array(N_elements2,width,height,kerf,2,3,focus);
%Set the impulse response and excitation of the emit aperture
impulse_response =sin(2*pi*f0*(0:1/fs:2/f0));
impulse_response=impulse_response.*hanning(max(size(impulse_response)))';
xdc_impulse(Th,impulse_response);
xdc_impulse(Th2,impulse_response);
excitation=sin(2*pi*f0*(0:1/fs:2/f0));
xdc_excitation(Th,excitation);
%define a small phantom with scatterers
N=200;
x_size = 20/1000;%width of phantom
y_size=10/1000;%transverse width of phantom
z_size=20/1000;%hight of phantom
z_start=5/1000;%start of phantom surface
%creat the general scatters
x=(rand (N,1)-0.5)*x_size;
y=(rand (N,1)-0.5)*y_size;
z=rand (N,1)*z_size + z_start;
positions=[x y z];
%Generate the amplitudes with a Gaussian distribution 
>> amp=randn(N,1);
>> %dO the calculations
>> [v,t]=calc_scat_all(Th,Th2,positions,amp,1);
>> %plot the indicidual response 
>> [N,M]=size(v);
>> scale=max(max(v));
>> v=v/scale;
>> for i=1:M
  plot ((0:N-1)/fs+t,v(:,1)+i,'b'),hold on
end 
>> hold off

>> title ('Individual traces')
>> xlabel('Time[s]')
>> ylabel('Normalized response')
>> axis([t t+N/fs 0 M+1])

得到图:当用三个不同的元发送,得到的16个线性阵列换能器的单个元件的接收电压的痕迹(?)


奋斗PURPOSE3:to show how the procedures can be used for making a phased array scan of a point target【用于说明程序如何可以用于一个点目标的相控阵扫描】

%generate  the transducer aperture for send and receive

f0=3e6;
fs=100e6;
c=1540;
lambda=c/f0;
element_hight=5/1000;
kerf=0.1/1000;
focus=[0 0 70]/1000;
%generate aperture for emission
emit_aperture = xdc_linear_array (128,lambda/2,element_hight,kerf,1,1,focus);
%set the impulse response and excitation of the emit aperture
impulse_response =sin(2*pi*f0*(0:1/fs:2/f0));
impulse_response=impulse_response.*hanning(max(size(impulse_response)))';
>> xdc_impulse (emit_aperture,impulse_response);
>> excitation=sin(2*pi*f0*(0:1/fs:2/f0));
>> xdc_excitation (emit_aperture,excitation);
>> %generate aperture for reception
>> receive_aperture =xdc_linear_array (128,lambda/2,element_hight,kerf,1,1,focus);
>> %set the impulse response for the receive aperture
>> xdc_impulse (receive_aperture ,impulse_response);
>> %Do phased array imaging
>> point_position =[0 0 70 ]/1000;
>> no_lines=50;
>> sector=20*pi/180;
>> d_theta=sector/no_lines;
>> %pre_allocate some storage
>> image_data=zeros (800,no_lines);
>> theta=-sector/2;
>> for i=1:no_lines
%set the focus for this direction
xdc_focus (emit_aperture,0,[70*sin(theta) 0 70*cos(theta)]/1000);
xdc_focus (receive_aperture,0,[70*sin(theta) 0 70*cos(theta)]/1000);
%calculate the received response 
[v,t1]=calc_scat(emit_aperture, receive_aperture,point_position,1);
%store the result 
image_data(1:max(size(v)),i)=v';
times(i)=t1;
%steer in another angle
theta = theta + d_theta;
end
>> %here the display of the data is inserted
>> plot (image_data)


奋斗PURPOSE4:generating an artificial phantom with point scatters and a cyst【产生具有点散射和囊肿的人造体模?】

 f0=3e6;
fs=100e6;
c=1540;
lambda=c/f0;
width=lambda;
element_height=5/1000;
kerf=width/20;
focus=[0 0 50]/1000;
N_elements=192;
N_active=64;
set_sampling(fs);
emit_aperture =xdc_linear_array (N_elements,width,element_height,kerf,1,5,focus);
%set the impulse response and excitation of the emit aperture
impulse_response = sin(2*pi*f0*(0:1/fs:2/f0));
impulse_response =  impulse_response.*hanning(max(size(impulse_response)))';
xdc_impulse (emit_aperture,impulse_response);
excitation=sin(2*pi*f0*(0:1/fs:2/f0));
xdc_excitation(emit_aperture,excitation);
%Generate aperture for reception
receive_aperture =xdc_linear_array (N_elements,width,element_height,kerf,1,5,focus);
%set the impulse response for the receive aperture
xdc_impulse (receive_aperture,impulse_response);
%load the computer phantom
[phantom_positions,phantom_amplitudes]=cyst_phantom(10000);
%Do linear array imaging
no_lines=N_elements-N_active+1;
dx=width;
z_focus=50/1000;
%pre-allocate some storage
image_data=zeros(1,no_lines);
for i=1:no_lines
i
%Find position for imaging
x=(i-1-no_lines/2)*dx;
%set the focus for this direction 
xdc_center_focus(emit_aperture,[x 0 0]);
xdc_focus (emit_aperture,0,[x 0 z_focus]);
xdc_focus (receive_aperture,0,[x 0 z_focus]);
%set the active elements using the apodization
apo=[zeros(1,i-1)  hamming(N_active)' zeros(1,N_elements - N_active - i + 1)];
xdc_apodization (emit_aperture,0,apo);
xdc_apodization(receive_aperture,0,apo);
%calculate the received response 
[v,t1]=calc_scat(emit_aperture,receive_aperture,phantom_positions,phantom_amplitudes);
%store the result 
image_data(1:max(size(v)),i)=v;
times(i)=t1;
Warning:  Remember to set all pulses in apertures for the new sampling frequency
end


i =


     1


 5 seconds used for the calculation                           


i =


     2


 4 seconds used for the calculation                           


i =


     3


 5 seconds used for the calculation                           


i =


     4


 4 seconds used for the calculation                           


i =


     5


 4 seconds used for the calculation                           


i =


     6


 4 seconds used for the calculation                           


i =


     7


 4 seconds used for the calculation                           


i =


     8


 5 seconds used for the calculation                           


i =


     9


 4 seconds used for the calculation                           


i =


    10


 4 seconds used for the calculation                           


i =


    11


 4 seconds used for the calculation                           


i =


    12


 4 seconds used for the calculation                           


i =


    13


 4 seconds used for the calculation                           


i =


    14


 4 seconds used for the calculation                           


i =


    15


 4 seconds used for the calculation                           


i =


    16


 4 seconds used for the calculation                           


i =


    17


 4 seconds used for the calculation                           


i =


    18


 3 seconds used for the calculation                           


i =


    19


 4 seconds used for the calculation                           


i =


    20


 4 seconds used for the calculation                           


i =


    21


 4 seconds used for the calculation                           


i =


    22


 4 seconds used for the calculation                           


i =


    23


 3 seconds used for the calculation                           


i =


    24


 4 seconds used for the calculation                           


i =


    25


 4 seconds used for the calculation                           


i =


    26


 3 seconds used for the calculation                           


i =


    27


 4 seconds used for the calculation                           


i =


    28


 3 seconds used for the calculation                           


i =


    29


 4 seconds used for the calculation                           


i =


    30


 3 seconds used for the calculation                           


i =


    31


 4 seconds used for the calculation                           


i =


    32


 3 seconds used for the calculation                           


i =


    33


 3 seconds used for the calculation                           


i =


    34


 3 seconds used for the calculation                           


i =


    35


 4 seconds used for the calculation                           


i =


    36


 3 seconds used for the calculation                           


i =


    37


 3 seconds used for the calculation                           


i =


    38


 3 seconds used for the calculation                           


i =


    39


 3 seconds used for the calculation                           


i =


    40


 4 seconds used for the calculation                           


i =


    41


 3 seconds used for the calculation                           


i =


    42


 3 seconds used for the calculation                           


i =


    43


 3 seconds used for the calculation                           


i =


    44


 3 seconds used for the calculation                           


i =


    45


 3 seconds used for the calculation                           


i =


    46


 3 seconds used for the calculation                           


i =


    47


 3 seconds used for the calculation                           


i =


    48


 3 seconds used for the calculation                           


i =


    49


 3 seconds used for the calculation                           


i =


    50


 2 seconds used for the calculation                           


i =


    51


 3 seconds used for the calculation                           


i =


    52


 3 seconds used for the calculation                           


i =


    53


 3 seconds used for the calculation                           


i =


    54


 3 seconds used for the calculation                           


i =


    55


 3 seconds used for the calculation                           


i =


    56


 3 seconds used for the calculation                           


i =


    57


 2 seconds used for the calculation                           


i =


    58


 3 seconds used for the calculation                           


i =


    59


 3 seconds used for the calculation                           


i =


    60


 3 seconds used for the calculation                           


i =


    61


 3 seconds used for the calculation                           


i =


    62


 2 seconds used for the calculation                           


i =


    63


 3 seconds used for the calculation                           


i =


    64


 3 seconds used for the calculation                           


i =


    65


 3 seconds used for the calculation                           


i =


    66


 3 seconds used for the calculation                           


i =


    67


 2 seconds used for the calculation                           


i =


    68


 3 seconds used for the calculation                           


i =


    69


 3 seconds used for the calculation                           


i =


    70


 3 seconds used for the calculation                           


i =


    71


 3 seconds used for the calculation                           


i =


    72


 3 seconds used for the calculation                           


i =


    73


 3 seconds used for the calculation                           


i =


    74


 2 seconds used for the calculation                           


i =


    75


 3 seconds used for the calculation                           


i =


    76


 3 seconds used for the calculation                           


i =


    77


 3 seconds used for the calculation                           


i =


    78


 3 seconds used for the calculation                           


i =


    79


 3 seconds used for the calculation                           


i =


    80


 3 seconds used for the calculation                           


i =


    81


 3 seconds used for the calculation                           


i =


    82


 3 seconds used for the calculation                           


i =


    83


 3 seconds used for the calculation                           


i =


    84


 3 seconds used for the calculation                           


i =


    85


 3 seconds used for the calculation                           


i =


    86


 3 seconds used for the calculation                           


i =


    87


 3 seconds used for the calculation                           


i =


    88


 3 seconds used for the calculation                           


i =


    89


 3 seconds used for the calculation                           


i =


    90


 4 seconds used for the calculation                           


i =


    91


 3 seconds used for the calculation                           


i =


    92


 3 seconds used for the calculation                           


i =


    93


 3 seconds used for the calculation                           


i =


    94


 3 seconds used for the calculation                           


i =


    95


 4 seconds used for the calculation                           


i =


    96


 3 seconds used for the calculation                           


i =


    97


 3 seconds used for the calculation                           


i =


    98


 4 seconds used for the calculation                           


i =


    99


 3 seconds used for the calculation                           


i =


   100


 4 seconds used for the calculation                           


i =


   101


 3 seconds used for the calculation                           


i =


   102


 4 seconds used for the calculation                           


i =


   103


 3 seconds used for the calculation                           


i =


   104


 4 seconds used for the calculation                           


i =


   105


 3 seconds used for the calculation                           


i =


   106


 4 seconds used for the calculation                           


i =


   107


 4 seconds used for the calculation                           


i =


   108


 4 seconds used for the calculation                           


i =


   109


 3 seconds used for the calculation                           


i =


   110


 4 seconds used for the calculation                           


i =


   111


 4 seconds used for the calculation                           


i =


   112


 4 seconds used for the calculation                           


i =


   113


 4 seconds used for the calculation                           


i =


   114


 4 seconds used for the calculation                           


i =


   115


 4 seconds used for the calculation                           


i =


   116


 4 seconds used for the calculation                           


i =


   117


 4 seconds used for the calculation                           


i =


   118


 4 seconds used for the calculation                           


i =


   119


 4 seconds used for the calculation                           


i =


   120


 5 seconds used for the calculation                           


i =


   121


 4 seconds used for the calculation                           


i =


   122


 4 seconds used for the calculation                           


i =


   123


 4 seconds used for the calculation                           


i =


   124


 5 seconds used for the calculation                           


i =


   125


 4 seconds used for the calculation                           


i =


   126


 4 seconds used for the calculation                           


i =


   127


 5 seconds used for the calculation                           


i =


   128


 4 seconds used for the calculation                           


i =


   129


 5 seconds used for the calculation                           
>> %free space for aperture
>> xdc_free (emit_aperture)
>> xdc_free (receive_aperture)
>> %Adjust the data in time and display it ai a gray scale image
>> min_sample = min(times)*fs;
>> for i=1:no_lines

 rf_env=abs(hilbert([zeros(round(times(i)*fs - min_sample),1);image_data(:,i)]));

>> env(1:size(rf_env,1),i)=rf_env;

end

 %make logarthmic compression to a 60 db dynamic range
>> %with proper units on the axis
>> env_dB=20*log10(env);
>> env_dB=env_dB-max(max(env_dB));
>> env_gray=127*(env_dB +60)/60;
>> depth=((0:size(env,1)-1)+min_sample)/fs*c/2;
>> x=((1:no_lines)-no_lines/2)*dx;
>> image(x*1000,depth*1000,env_gray)
>> xlabel('Lateral distance [mm]')
>> ylabel('Depth [mm]')
>> axis('image')
>> colormap(gray(128))
>> title('image of cyst phantom(60dB dynamic range)')

得到的结果如下:


猜你喜欢

转载自blog.csdn.net/qq_34018578/article/details/71250511