📄 bft_user_guide.html
字号:
6<tt> </tt><tt><i>%</i></tt><br>7<tt> </tt><tt><i>% The function calls XDC_FOCUS, and BFT_FOCUS in order to set the</i></tt><br>8<tt> </tt><tt><i>% the delays. </i></tt><br>9<tt> </tt><tt></tt><br>10<tt> </tt><tt><i>% VERSION 1.0, 29 Feb. 2000, Svetoslav Nikolov</i></tt><br>11<tt> </tt><tt></tt><br>12<tt> </tt><tt>f0 = 4e6; <i>% Central frequency [Hz]</i></tt><br>13<tt> </tt><tt>fs = 100e6; <i>% Sampling frequency [Hz]</i></tt><br>14<tt> </tt><tt>c = 1540; <i>% Speed of sound [m/s]</i></tt><br>15<tt> </tt><tt>no_elements = 64; <i>% Number of elements in the transducer</i></tt><br>16<tt> </tt><tt></tt><br>17<tt> </tt><tt>lambda = c / f0; <i>% Wavelength [m]</i></tt><br>18<tt> </tt><tt>pitch = lambda / 2; <i>% Pitch - center-to-center [m]</i></tt><br>19<tt> </tt><tt>width = .95*pitch; <i>% Width of the element [m]</i></tt><br>20<tt> </tt><tt>kerf = pitch - width; <i>% Inter-element spacing [m]</i></tt><br>21<tt> </tt><tt>height = 10/1000; <i>% Size in the Y direction [m]</i></tt><br>22<tt> </tt><tt> </tt><br>23<tt> </tt><tt> </tt><br>24<tt> </tt><tt><i>% Define the impulse response of the transducer</i></tt><br>25<tt> </tt><tt>impulse_response = sin(2*pi*f0*(0:1/fs:2/f0));</tt><br>26<tt> </tt><tt>impulse_response = impulse_response.*hanning(length(impulse_response))';</tt><br>27<tt> </tt><tt>excitation = impulse_response;</tt><br>28<tt> </tt><tt></tt><br>29<tt> </tt><tt><i>% Define the phantom</i></tt><br>30<tt> </tt><tt></tt><br>31<tt> </tt><tt>pht_pos = [0 0 20;</tt><br>32<tt> </tt><tt> 0 0 30;</tt><br>33<tt> </tt><tt> 0 0 40;</tt><br>34<tt> </tt><tt> 0 0 50;</tt><br>35<tt> </tt><tt> 0 0 60;</tt><br>36<tt> </tt><tt> 0 0 70;</tt><br>37<tt> </tt><tt> 0 0 80;</tt><br>38<tt> </tt><tt> 0 0 90;</tt><br>39<tt> </tt><tt> ] / 1000; <i>% The position of the phantom</i></tt><br>40<tt> </tt><tt>pht_amp = 20*ones(8,1); <i>% The amplitude of the back-scatter</i></tt><br>41<tt> </tt><tt></tt><br>42<tt> </tt><tt></tt><br>43<tt> </tt><tt></tt><br>44<tt> </tt><tt><i>% Define the focus </i></tt><br>45<tt> </tt><tt>focus_r = [20;30;40;50;60;70;80;90] / 1000;</tt><br>46<tt> </tt><tt>T = (focus_r-5/1000)/c *2;</tt><br>47<tt> </tt><tt></tt><br>48<tt> </tt><tt></tt><br>49<tt> </tt><tt><i>% Initialize the program</i></tt><br>50<tt> </tt><tt>field_init(0);</tt><br>51<tt> </tt><tt>bft_init;</tt><br>52<tt> </tt><tt></tt><br>53<tt> </tt><tt></tt><br>54<tt> </tt><tt><i>% Set some paramters</i></tt><br>55<tt> </tt><tt>set_field('c', c);</tt><br>56<tt> </tt><tt>bft_param('c', c);</tt><br>57<tt> </tt><tt></tt><br>58<tt> </tt><tt>set_field('fs', fs);</tt><br>59<tt> </tt><tt>bft_param('fs', fs);</tt><br>60<tt> </tt><tt></tt><br>61<tt> </tt><tt></tt><br>62<tt> </tt><tt></tt><br>63<tt> </tt><tt><i>% Create some apertures.</i></tt><br>64<tt> </tt><tt></tt><br>65<tt> </tt><tt>xmt = xdc_linear_array(no_elements,width,height,kerf,1,1,[0 0 0]);</tt><br>66<tt> </tt><tt>rcv = xdc_linear_array(no_elements,width,height,kerf,1,1,[0 0 0]);</tt><br>67<tt> </tt><tt></tt><br>68<tt> </tt><tt>xdc = bft_linear_array(no_elements, width, kerf);</tt><br>69<tt> </tt><tt></tt><br>70<tt> </tt><tt></tt><br>71<tt> </tt><tt><i>% Set the impulse responses</i></tt><br>72<tt> </tt><tt>xdc_impulse(rcv, impulse_response);</tt><br>73<tt> </tt><tt>xdc_impulse(xmt, impulse_response);</tt><br>74<tt> </tt><tt></tt><br>75<tt> </tt><tt>xdc_excitation(xmt, excitation);</tt><br>76<tt> </tt><tt></tt><br>77<tt> </tt><tt></tt><br>78<tt> </tt><tt></tt><br>79<tt> </tt><tt><i>% Define and create the image</i></tt><br>80<tt> </tt><tt>sector = 30 * pi / 180;</tt><br>81<tt> </tt><tt>no_lines = 32;</tt><br>82<tt> </tt><tt>d_theta = sector / (no_lines-1);</tt><br>83<tt> </tt><tt>theta = -(no_lines-1) / 2 * d_theta;</tt><br>84<tt> </tt><tt></tt><br>85<tt> </tt><tt>Rmax = max(sqrt(pht_pos(:,1).^ 2 + pht_pos(:,2).^ 2 + pht_pos(:,3).^ 2)) + 15/1000;</tt><br>86<tt> </tt><tt></tt><br>87<tt> </tt><tt>no_rf_samples = ceil(2*Rmax/c * fs);</tt><br>88<tt> </tt><tt>rf_line = zeros(no_rf_samples, 1);</tt><br>89<tt> </tt><tt>bf_line = zeros(no_rf_samples, 1);</tt><br>90<tt> </tt><tt></tt><br>91<tt> </tt><tt>env_line = zeros(no_rf_samples, no_lines);</tt><br>92<tt> </tt><tt>env_bf = zeros(no_rf_samples, no_lines);</tt><br>93<tt> </tt><tt></tt><br>94<tt> </tt><tt></tt><br>95<tt> </tt><tt>xmt_r = (max(focus_r) + min(focus_r) )/2;</tt><br>96<tt> </tt><tt></tt><br>97<tt> </tt><tt>for i = 1 : no_lines</tt><br>98<tt> </tt><tt> rf_line(:) = 0; </tt><br>99<tt> </tt><tt> disp(['Line no ' num2str(i)])</tt><br>100<tt> </tt><tt> </tt><br>101<tt> </tt><tt> focus = [sin(theta)*focus_r, zeros(length(focus_r),1), cos(theta)*focus_r];</tt><br>102<tt> </tt><tt> xmt_f = [sin(theta)*xmt_r, zeros(length(xmt_r),1), cos(theta)*xmt_r];</tt><br>103<tt> </tt><tt> xdc_center_focus(xmt,[0 0 0])</tt><br>104<tt> </tt><tt> xdc_center_focus(rcv,[0 0 0])</tt><br>105<tt> </tt><tt> bft_center_focus([0 0 0]);</tt><br>106<tt> </tt><tt> </tt><br>107<tt> </tt><tt> xdc_focus(xmt, 0, xmt_f);</tt><br>108<tt> </tt><tt> xdc_focus(rcv, T, focus);</tt><br>109<tt> </tt><tt> bft_focus(xdc, T, focus);</tt><br>110<tt> </tt><tt> </tt><br>111<tt> </tt><tt> <i>% Beamform with Field II</i></tt><br>112<tt> </tt><tt> [rf_temp, t(i)] = calc_scat(xmt,rcv, pht_pos, pht_amp);</tt><br>113<tt> </tt><tt> </tt><br>114<tt> </tt><tt> <i>% Beamform with BFT</i></tt><br>115<tt> </tt><tt> xdc_focus_times(rcv, 0, zeros(1,no_elements));</tt><br>116<tt> </tt><tt> [rf_data, start_t] = calc_scat_multi(xmt,rcv, pht_pos, pht_amp);</tt><br>117<tt> </tt><tt> rf_data = [zeros(300,no_elements); rf_data; zeros(300,no_elements)];</tt><br>118<tt> </tt><tt></tt><br>119<tt> </tt><tt> start_t = start_t - 300 / fs;</tt><br>120<tt> </tt><tt> bf_temp = bft_beamform(start_t, rf_data);</tt><br>121<tt> </tt><tt> </tt><br>122<tt> </tt><tt> start_sample = t(i)*fs; no_temp_samples = length(rf_temp);</tt><br>123<tt> </tt><tt> </tt><br>124<tt> </tt><tt> rf_line(start_sample:start_sample+no_temp_samples-1) = rf_temp(1:no_temp_samples);</tt><br>125<tt> </tt><tt> env_line(:,i) = abs(hilbert(rf_line(:)));</tt><br>126<tt> </tt><tt></tt><br>127<tt> </tt><tt> start_sample = floor(start_t*fs); no_temp_samples = length(bf_temp);</tt><br>128<tt> </tt><tt> bf_line(start_sample:start_sample+no_temp_samples-1) = bf_temp(1:no_temp_samples);</tt><br>129<tt> </tt><tt> env_bf(:,i) = abs(hilbert(bf_line(:)));</tt><br>130<tt> </tt><tt> theta = theta + d_theta;</tt><br>131<tt> </tt><tt></tt><br>132<tt> </tt><tt>end</tt><br>133<tt> </tt><tt></tt><br>134<tt> </tt><tt><i>% Release the allocated memory</i></tt><br>135<tt> </tt><tt></tt><br>136<tt> </tt><tt>field_end</tt><br>137<tt> </tt><tt>bft_end</tt><br>138<tt> </tt><tt></tt><br>139<tt> </tt><tt>env_line = env_line / max(max(abs(env_line)));</tt><br>140<tt> </tt><tt>env_bf = env_bf / max(max(abs(env_bf)));</tt><br>141<tt> </tt><tt></tt><br>142<tt> </tt><tt>figure;</tt><br>143<tt> </tt><tt>subplot(1,2,1)</tt><br>144<tt> </tt><tt>imagesc([-sector/2 sector/2]*180/pi,[0 Rmax]*1000,20*log10(env_line + 0.001))</tt><br>145<tt> </tt><tt>axis('image')</tt><br>146<tt> </tt><tt>xlabel('Angle [deg]');</tt><br>147<tt> </tt><tt>ylabel('Axial distance [mm]')</tt><br>148<tt> </tt><tt>title('Beamformed by Field II ');</tt><br>149<tt> </tt><tt></tt><br>150<tt> </tt><tt>subplot(1,2,2)</tt><br>151<tt> </tt><tt>imagesc([-sector/2 sector/2]*180/pi,[0 Rmax]*1000,20*log10(env_bf + 0.001));</tt><br>152<tt> </tt><tt>title('Beamformed by BFT');</tt><br>153<tt> </tt><tt>xlabel('Angle [deg]');</tt><br>154<tt> </tt><tt>ylabel('Axial distance [mm]')</tt><br>155<tt> </tt><tt>axis('image')</tt><br>156<tt> </tt><tt></tt><br>157<tt> </tt><tt>colorbar</tt><br>158<tt> </tt><tt>colormap(gray)</tt><br>159<tt> </tt><tt></tt><br>160<tt> </tt><tt>clc</tt><br>161<tt> </tt><tt>disp([' ' 10 10 10 10 ]);</tt><br>162<tt> </tt><tt>disp([9 '*****************************************************']);</tt><br>163<tt> </tt><tt>disp([9 '* *']);</tt><br>164<tt> </tt><tt>disp([9 '* The image beamformed by Field II is in ënv_line" *']);</tt><br>165<tt> </tt><tt>disp([9 '* The image beamformed by BFT is in ënv_bf" *']);</tt><br>166<tt> </tt><tt>disp([9 '* *'])</tt><br>167<tt> </tt><tt>disp([9 '*****************************************************']);</tt><br>168<tt> </tt><tt>disp([' ' 10 10 ]);</tt><br>169<tt> </tt><tt></tt><br>170<tt> </tt><tt></tt><br></font><p><title> Dynamic focusing</title><br><br><br><br><br><p><hr> <H3>Dynamic focusing</H3><hr> <A NAME="dynamic_focusing"></A> <a name="dynamic_focusing"></a><p><font size="-2">1<tt> </tt><tt><i>%PHASED_DYN_IMAGE Create a phased-array B-mode image, using the </i></tt><br>2<tt> </tt><tt><i>% commands for setting a dynamic focusing</i></tt><br>3<tt> </tt><tt></tt><br>4<tt> </tt><tt><i>%VERSION 1.0, 29 Feb 2000, Svetoslav Nikolov</i></tt><br>5<tt> </tt><tt></tt><br>6<tt> </tt><tt>f0 = 4e6; <i>% Central frequency [Hz]</i></tt><br>7<tt> </tt><tt>fs = 100e6; <i>% Sampling frequency [Hz]</i></tt><br>8<tt> </tt><tt>c = 1540; <i>% Speed of sound [m/s]</i></tt><br>9<tt> </tt><tt>B = .35; <i>% Relative bandwith [fraction]</i></tt><br>10<tt> </tt><tt>no_elements = 64; <i>% Number of elements in the transducer </i></tt><br>11<tt> </tt><tt></tt><br>12<tt> </tt><tt>lambda = c / f0; <i>% Wavelength [m]</i></tt><br>13<tt> </tt><tt>pitch = lambda / 2; <i>% Pitch - center-to-center [m]</i></tt><br>14<tt> </tt><tt>width = .95*pitch; <i>% Width of the element [m]</i></tt><br>15<tt> </tt><tt>kerf = pitch - width; <i>% Inter-element spacing [m]</i></tt><br>16<tt> </tt><tt>height = 10/1000; <i>% Size in the Y direction [m]</i></tt><br>17<tt> </tt><tt> </tt><br>18<tt> </tt><tt> </tt><br>19<tt> </tt><tt><i>% Define the impulse response of the transducer</i></tt><br>20<tt> </tt><tt>impulse_response = sin(2*pi*f0*(0:1/fs:2/f0));</tt><br>21<tt> </tt><tt>impulse_response = impulse_response.*hanning(length(impulse_response))';</tt><br>22<tt> </tt><tt>excitation = impulse_response;</tt><br>23<tt> </tt><tt></tt><br>24<tt> </tt><tt><i>% Define the phantom</i></tt><br>25<tt> </tt><tt></tt><br>26<tt> </tt><tt>pht_pos = [0 0 20;</tt><br>27<tt> </tt><tt> 0 0 30;</tt><br>28<tt> </tt><tt> 0 0 40;</tt><br>29<tt> </tt><tt> 0 0 50;</tt><br>30<tt> </tt><tt> 0 0 60;</tt><br>31<tt> </tt><tt> 0 0 70;</tt><br>32<tt> </tt><tt> 0 0 80;] / 1000; <i>% The position of the phantom</i></tt><br>33<tt> </tt><tt>pht_amp = 20*ones(7,1); <i>% The amplitude of the back-scatter</i></tt><br>34<tt> </tt><tt></tt><br>35<tt> </tt><tt><i>% Define the focus </i></tt><br>36<tt> </tt><tt>focus_r = [20;30;40;50;60;70;80;90] / 1000;</tt><br>37<tt> </tt><tt>T = (focus_r-5/1000)/c *2;</tt><br>38<tt> </tt><tt></tt><br>39<tt> </tt><tt><i>% Initialize the program</i></tt><br>40<tt> </tt><tt>field_init(0);</tt><br>41<tt> </tt><tt>bft_init;</tt><br>42<tt> </tt><tt></tt><br>43<tt> </tt><tt><i>% Set some paramters</i></tt><br>44<tt> </tt><tt>set_field('c', c);</tt><br>45<tt> </tt><tt>bft_param('c', c);</tt><br>46<tt> </tt><tt></tt><br>47<tt> </tt><tt>set_field('fs', fs);</tt><br>48<tt> </tt><tt>bft_param('fs', fs);</tt><br>49<tt> </tt><tt></tt><br>50<tt> </tt><tt></tt><br>51<tt> </tt><tt><i>% Create some apertures.</i></tt><br>52<tt> </tt><tt></tt><br>53<tt> </tt><tt>xmt = xdc_linear_array(no_elements,width,height,kerf,1,1,[0 0 0]);</tt><br>54<tt> </tt><tt>rcv = xdc_linear_array(no_elements,width,height,kerf,1,1,[0 0 0]);</tt><br>55<tt> </tt><tt></tt><br>56<tt> </tt><tt>xdc = bft_linear_array(no_elements, width, kerf);</tt><br>57<tt> </tt><tt></tt><br>58<tt> </tt><tt></tt><br>59<tt> </tt><tt><i>% Set the impulse responses</i></tt><br>60<tt> </tt><tt>xdc_impulse(rcv, impulse_response);</tt><br>61<tt> </tt><tt>xdc_impulse(xmt, impulse_response);</tt><br>62<tt> </tt><tt></tt><br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -