Dear All,
I have some questions regarding the code "example_us_bmode_linear_transducer." I am trying to create a homogeneous B-mode image without any artifacts. I have tested different values for the tone burst frequency—3.47 MHz, 7.8 MHz, and 15.62 MHz—along with varying values for the medium's alpha coefficient and alpha power, while keeping the sound speed and density uniform. I am using a plane wave setup with the focus set to infinity.
However, I encountered some unexpected results:
1. At a frequency of 3.47 MHz, the resulting B-mode image was not as expected.
2. At 7.8 MHz, I observed a bright line in the middle of the final B-mode image.
3. The same issue occurred at 15.62 MHz.
I would appreciate your assistance in determining whether my code is correct, as this simulation software is crucial for my project. I would also like to share my code for your review if you have some time to look at it and provide your valuable suggestions.
Thank you for your attention.
The code:
RUN_SIMULATION = true;
% =========================================================================
% DEFINE THE K-WAVE GRID
% =========================================================================
% set the size of the perfectly matched layer (PML)
pml_x_size = 20; % [grid points]
pml_y_size = 10; % [grid points]
pml_z_size = 1; % [grid points]
% set total number of grid points not including the PML
Nx = 256*2 - 2 * pml_x_size; % [grid points]
Ny = 128*2 - 2 * pml_y_size; % [grid points]
Nz = 2; % [grid points] %128 - 2 * pml_z_size;
x= 40e-3;
dx = x / Nx;
dy = dx;
dz = dx; % [m]
% create the k-space grid
kgrid = kWaveGrid(Nx, dx, Ny, dy, Nz, dz);
% =========================================================================
% DEFINE THE MEDIUM PARAMETERS
% =========================================================================
% define the properties of the propagation medium
c0 = 1540; % [m/s]
rho0 = 1000; % [kg/m^3]
% medium.alpha_mode = 'no_dispersion';
medium.alpha_coeff = 0.5; % [dB/(MHz^y cm)]
medium.alpha_power = 1.0;
% create the time array
t_end = (Nx * dx) * 2.2 / c0; % [s]
kgrid.makeTime(c0, [], t_end);
% =========================================================================
% DEFINE THE INPUT SIGNAL
% =========================================================================
% define properties of the input signal
source_strength = 1e6; % [Pa]
tone_burst_freq = 15.62e6; % [Hz] 7.8 MHz, 3.47 MHz
tone_burst_cycles = 4;
% create the input signal using toneBurst
input_signal = toneBurst(1/kgrid.dt, tone_burst_freq, tone_burst_cycles);
% scale the source magnitude by the source_strength divided by the
% impedance (the source is assigned to the particle velocity)
input_signal = (source_strength ./ (c0 * rho0)) .* input_signal;
% =========================================================================
% DEFINE THE ULTRASOUND TRANSDUCER
% =========================================================================
% physical properties of the transducer
transducer.number_elements = 32; % total number of transducer elements
transducer.element_width = 2; % width of each element [grid points]
transducer.element_length = 1; %24; % length of each element [grid points]
transducer.element_spacing = 0; % spacing (kerf width) between the elements [grid points]
transducer.radius = inf; % radius of curvature of the transducer [m]
% calculate the width of the transducer in grid points
transducer_width = transducer.number_elements * transducer.element_width ...
+ (transducer.number_elements - 1) * transducer.element_spacing;
% use this to position the transducer in the middle of the computational grid
transducer.position = round([1, Ny/2 - transducer_width/2, Nz/2 - transducer.element_length/2]);
% properties used to derive the beamforming delays
transducer.sound_speed = c0; % sound speed [m/s]
% transducer.focus_distance = Inf; %40e-3; % focus distance [m]
% transducer.elevation_focus_distance = Inf; %19e-3; % focus distance in the elevation plane [m]
transducer.steering_angle = 0; % steering angle [degrees]
% apodization
transducer.transmit_apodization = 'Hanning';
transducer.receive_apodization = 'Rectangular';
% define the transducer elements that are currently active
number_active_elements = 32;
transducer.active_elements = ones(transducer.number_elements, 1);
% append input signal used to drive the transducer
transducer.input_signal = input_signal;
% create the transducer using the defined settings
transducer = kWaveTransducer(kgrid, transducer);
% print out transducer properties
transducer.properties;
% =========================================================================
% DEFINE THE MEDIUM PROPERTIES
% =========================================================================
% define a large image size to move across
number_scan_lines = 96;
Nx_tot = Nx;
Ny_tot = Ny + number_scan_lines * transducer.element_width;
Nz_tot = Nz;
% define a random distribution of scatterers for the medium
background_map_mean = 1;
background_map_std = 0.008;
background_map = background_map_mean + background_map_std * randn([Nx_tot, Ny_tot, Nz_tot]);
sound_speed_map = c0 * ones(Nx_tot, Ny_tot, Nz_tot) .* background_map;
density_map = rho0 * ones(Nx_tot, Ny_tot, Nz_tot) .* background_map;
% RUN THE SIMULATION
% =========================================================================
% preallocate the storage
scan_lines = zeros(number_scan_lines, kgrid.Nt);
% set the input settings
input_args = {...
'PMLInside', false, 'PMLSize', [pml_x_size, pml_y_size, pml_z_size], ...
'DataCast', DATA_CAST, 'DataRecast', true, 'PlotSim', false};
% run the simulation if set to true, otherwise, load previous results from
% disk
h = waitbar(0,'Please wait...');
if RUN_SIMULATION
% set medium position
medium_position = 1;
% loop through the scan lines
for scan_line_index = 1:number_scan_lines
scan_line_index
waitbar(scan_line_index/number_scan_lines,h)
% update the command line status
disp('');
disp(['Computing scan line ' num2str(scan_line_index) ' of ' num2str(number_scan_lines)]);
% load the current section of the medium
medium.sound_speed = sound_speed_map(:, medium_position:medium_position + Ny - 1, :);
medium.density = density_map(:, medium_position:medium_position + Ny - 1, :);
% run the simulation
sensor_data = kspaceFirstOrder3D(kgrid, medium, transducer, transducer, input_args{:});
% extract the scan line from the sensor data
scan_lines(scan_line_index, :) = transducer.scan_line(sensor_data);
% update medium position
medium_position = medium_position + transducer.element_width;
end
% save the scan lines to disk
save HomogeneousTriaNew_scan_lines.mat;
else
% load the scan lines from disk
load ('HomogeneousReferenceNew_scan_lines.mat');
end
scan_lines_saved = scan_lines;
scan_lines = scan_lines_saved;