<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>k-Wave User Forum &#187; Topic: B-mode Ultrasound Imaging Test</title>
		<link>http://www.k-wave.org/forum/topic/b-mode-ultrasound-imaging-test</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Tue, 12 May 2026 23:39:46 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.k-wave.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.k-wave.org/forum/rss/topic/b-mode-ultrasound-imaging-test" rel="self" type="application/rss+xml" />

		<item>
			<title>Yuxin on "B-mode Ultrasound Imaging Test"</title>
			<link>http://www.k-wave.org/forum/topic/b-mode-ultrasound-imaging-test#post-8519</link>
			<pubDate>Tue, 26 Apr 2022 19:12:18 +0000</pubDate>
			<dc:creator>Yuxin</dc:creator>
			<guid isPermaLink="false">8519@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I think it's because of:&#60;/p&#62;
&#60;p&#62;1. the focus depth&#60;br /&#62;
'transducer.focus_distance = x*0.5; % focus distance [m]'&#60;/p&#62;
&#60;p&#62;2. the attenuation and the time gain compensation&#60;br /&#62;
 'medium.alpha_power=1.05;'&#60;br /&#62;
 'tgc_alpha = 0.1; % [dB/(MHz cm)]'
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "B-mode Ultrasound Imaging Test"</title>
			<link>http://www.k-wave.org/forum/topic/b-mode-ultrasound-imaging-test#post-6916</link>
			<pubDate>Tue, 25 Jun 2019 08:51:37 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">6916@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I haven't run your code, but a couple of things to check:&#60;/p&#62;
&#60;p&#62;Do the raw a-lines look as would expect before applying any further image processing?&#60;/p&#62;
&#60;p&#62;For the dark band at the bottom, have you tried increasing the simulation time?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>guns2roses on "B-mode Ultrasound Imaging Test"</title>
			<link>http://www.k-wave.org/forum/topic/b-mode-ultrasound-imaging-test#post-6847</link>
			<pubDate>Fri, 10 May 2019 13:25:53 +0000</pubDate>
			<dc:creator>guns2roses</dc:creator>
			<guid isPermaLink="false">6847@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Bradley,&#60;/p&#62;
&#60;p&#62;I recently ran a test simulation for B-mode ultrasound imaging. The medium is just a cube with randomly distributed scatters. However, the resulting images look a bit weird. I can see a very bright strap zone above 40 mm depth in both fundamental and harmonic images (especially in the harmonic image, this strap zone is very distinctive). Besides, the signal seems lost at the bottom (20 - 80 mm horizontal; around 90 mm depth) of the two images. So I wonder if there is something wrong with my code. Could you please help me with it? Thanks very much. &#60;/p&#62;
&#60;p&#62;The images and the Matlab code are pasted below. &#60;/p&#62;
&#60;p&#62;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://imageshack.com/i/pl0JRRZ1j&#34; rel=&#34;nofollow&#34;&#62;https://imageshack.com/i/pl0JRRZ1j&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&#60;/p&#62;
&#60;p&#62;clearvars;&#60;/p&#62;
&#60;p&#62;% simulation settings&#60;/p&#62;
&#60;p&#62;DATA_CAST       = 'gpuArray-single';     % set to 'single' or 'gpuArray-single' to speed up computations&#60;br /&#62;
RUN_SIMULATION  = true;         % set to false to reload previous results instead of running simulation&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% DEFINE THE K-WAVE GRID&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% set the size of the perfectly matched layer (PML)&#60;/p&#62;
&#60;p&#62;pml_x_size=20;            % [grid points]&#60;br /&#62;
pml_y_size=10;            % [grid points]&#60;br /&#62;
pml_z_size=10;            % [grid points]&#60;/p&#62;
&#60;p&#62;% set total number of grid points not including the PML&#60;/p&#62;
&#60;p&#62;Nx = 1000 - 2*pml_x_size;   % [grid points]&#60;br /&#62;
Ny = 1000 - 2*pml_y_size;   % [grid points]&#60;br /&#62;
Nz = 100 - 2*pml_z_size;   % [grid points]&#60;/p&#62;
&#60;p&#62;% set desired grid size in the x-direction not including the PML&#60;br /&#62;
x = Nx*0.1e-3;                  % [m]&#60;/p&#62;
&#60;p&#62;% calculate the spacing between the grid points&#60;br /&#62;
dx = x/Nx;                  % [m]&#60;br /&#62;
dy = dx;                    % [m]&#60;br /&#62;
dz = dx;                    % [m]&#60;/p&#62;
&#60;p&#62;% create the k-space grid&#60;br /&#62;
kgrid = makeGrid(Nx, dx, Ny, dy, Nz, dz);&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% DEFINE THE MEDIUM PARAMETERS&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% define the properties of the propagation medium&#60;br /&#62;
c0 = 1480;                  % [m/s]&#60;br /&#62;
rho0 = 1000;                % [kg/m^3]&#60;br /&#62;
medium.alpha_power=1.05;&#60;/p&#62;
&#60;p&#62;% create the time array&#60;br /&#62;
t_end = (Nx*dx)*2.2/c0;     % [s]&#60;br /&#62;
kgrid.t_array = makeTime(kgrid, c0, [], t_end);&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% DEFINE THE INPUT SIGNAL&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% define properties of the input signal&#60;br /&#62;
source_strength = 1e6;    	% [Pa]&#60;br /&#62;
tone_burst_freq = 2e6; 	% [Hz]&#60;br /&#62;
tone_burst_cycles = 4;&#60;/p&#62;
&#60;p&#62;% create the input signal using toneBurst&#60;br /&#62;
input_signal = toneBurst(1/kgrid.dt, tone_burst_freq, tone_burst_cycles);&#60;/p&#62;
&#60;p&#62;% scale the source magnitude by the source_strength divided by the&#60;br /&#62;
% impedance (the source is assigned to the particle velocity)&#60;br /&#62;
input_signal = (source_strength./(c0*rho0)).*input_signal;&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% DEFINE THE ULTRASOUND TRANSDUCER&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% physical properties of the transducer&#60;br /&#62;
transducer.number_elements = 128;  	% total number of transducer elements&#60;br /&#62;
transducer.element_width = 2;       % width of each element [grid points]&#60;br /&#62;
transducer.element_length = 78;  	% length of each element [grid points]&#60;br /&#62;
transducer.element_spacing = 0;  	% spacing (kerf  width) between the elements [grid points]&#60;br /&#62;
transducer.radius = inf;            % radius of curvature of the transducer [m]&#60;/p&#62;
&#60;p&#62;% calculate the width of the transducer in grid points&#60;br /&#62;
transducer_width = transducer.number_elements*transducer.element_width ...&#60;br /&#62;
    + (transducer.number_elements - 1)*transducer.element_spacing;&#60;/p&#62;
&#60;p&#62;% use this to position the transducer in the middle of the computational grid&#60;br /&#62;
transducer.position = round([1, Ny/2 - transducer_width/2, Nz/2 - transducer.element_length/2]);&#60;/p&#62;
&#60;p&#62;% properties used to derive the beamforming delays&#60;br /&#62;
transducer.sound_speed = c0;                % sound speed [m/s]&#60;br /&#62;
transducer.focus_distance = x*0.5;          % focus distance [m]&#60;br /&#62;
transducer.elevation_focus_distance = x*0.5;% focus distance in the elevation plane [m]&#60;br /&#62;
transducer.steering_angle = 0;              % steering angle [degrees]&#60;br /&#62;
transducer.steering_angle_max = 35;         % maximum steering angle [degrees]&#60;/p&#62;
&#60;p&#62;% apodization&#60;br /&#62;
transducer.transmit_apodization = 'Hanning';&#60;br /&#62;
transducer.receive_apodization = 'Rectangular';&#60;/p&#62;
&#60;p&#62;% define the transducer elements that are currently active&#60;br /&#62;
transducer.active_elements = ones(transducer.number_elements, 1);&#60;/p&#62;
&#60;p&#62;% append input signal used to drive the transducer&#60;br /&#62;
transducer.input_signal = input_signal;&#60;/p&#62;
&#60;p&#62;% create the transducer using the defined settings&#60;br /&#62;
transducer = makeTransducer(kgrid, transducer);&#60;/p&#62;
&#60;p&#62;% print out transducer properties&#60;br /&#62;
transducer.properties;&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% DEFINE THE MEDIUM PROPERTIES&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% define a large image size to move across&#60;br /&#62;
steering_angles = -32:1:32;&#60;br /&#62;
number_scan_lines = length(steering_angles);&#60;/p&#62;
&#60;p&#62;np2db=0.2*log10(exp(1));&#60;br /&#62;
ppts=[1561 1081 3.917*np2db 1.2598 6.756];   % heart muscle&#60;/p&#62;
&#60;p&#62;medium.alpha_coeff=ppts(3);&#60;br /&#62;
medium.BonA=ppts(5);&#60;/p&#62;
&#60;p&#62;reconsf=zeros(Nx, Ny, Nz, 2);&#60;/p&#62;
&#60;p&#62;reconsf(:,:,:,1)=ppts(1);&#60;br /&#62;
reconsf(:,:,:,2)=ppts(2);&#60;/p&#62;
&#60;p&#62;muc=ppts(1);&#60;br /&#62;
sigmac=15.4673;&#60;br /&#62;
scattering_c0=normrnd(muc,sigmac,[Nx, Ny, Nz, 5]);&#60;br /&#62;
scattering_c0(scattering_c0 &#38;gt; 1572) = 1572;&#60;br /&#62;
scattering_c0(scattering_c0 &#38;lt; 1529) = 1529;&#60;/p&#62;
&#60;p&#62;mup=ppts(2);&#60;br /&#62;
sigmap=36.09;&#60;br /&#62;
scattering_rho0=normrnd(mup,sigmap,[Nx, Ny, Nz, 5]);&#60;br /&#62;
scattering_rho0(scattering_rho0 &#38;gt; 1143) = 1143;&#60;br /&#62;
scattering_rho0(scattering_rho0 &#38;lt; 1059) = 1059;&#60;/p&#62;
&#60;p&#62;reconsf(reconsf == ppts(1)) = scattering_c0(reconsf == ppts(1));&#60;br /&#62;
reconsf(reconsf == ppts(2)) = scattering_rho0(reconsf == ppts(2));&#60;/p&#62;
&#60;p&#62;% load the current section of the medium&#60;br /&#62;
medium.sound_speed=reconsf(:, :, :,1);&#60;br /&#62;
medium.density=reconsf(:, :, :,2);&#60;/p&#62;
&#60;p&#62;clearvars scattering_rho0 scattering_c0 reconsf&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% RUN THE SIMULATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% preallocate the storage&#60;br /&#62;
scan_lines = zeros(number_scan_lines, kgrid.Nt);&#60;/p&#62;
&#60;p&#62;% set the input settings&#60;br /&#62;
input_args = {...&#60;br /&#62;
    'PMLInside', false, 'PMLSize', [pml_x_size, pml_y_size, pml_z_size], ...&#60;br /&#62;
    'DataCast', DATA_CAST, 'DataRecast', true, 'PlotSim', false};&#60;/p&#62;
&#60;p&#62;%sensor.record = {'p_max_all'};&#60;br /&#62;
%sensor.mask=[];&#60;/p&#62;
&#60;p&#62;% run the simulation if set to true, otherwise, load previous results from&#60;br /&#62;
% disk&#60;br /&#62;
if RUN_SIMULATION&#60;/p&#62;
&#60;p&#62;    for angle_index = 1:number_scan_lines    %:number_scan_lines&#60;/p&#62;
&#60;p&#62;        % update the command line status&#60;br /&#62;
        disp('');&#60;br /&#62;
        disp(['Computing scan line ' num2str(angle_index) ' of ' num2str(number_scan_lines)]);&#60;/p&#62;
&#60;p&#62;        % update the current steering angle&#60;br /&#62;
        transducer.steering_angle = steering_angles(angle_index);&#60;/p&#62;
&#60;p&#62;        % run the simulation&#60;br /&#62;
        sensor_data = kspaceFirstOrder3DG(kgrid, medium, transducer, transducer, input_args{:});&#60;/p&#62;
&#60;p&#62;        sensor_data = transducer.combine_sensor_data(sensor_data);&#60;/p&#62;
&#60;p&#62;        % extract the scan line from the sensor data&#60;br /&#62;
        scan_lines(angle_index, :) = transducer.scan_line(sensor_data);&#60;/p&#62;
&#60;p&#62;    end&#60;/p&#62;
&#60;p&#62;    % save the scan lines to disk&#60;br /&#62;
    save us_ph_bmode_scan_mc_scatter_only scan_lines;&#60;br /&#62;
else&#60;br /&#62;
    % load the scan lines from disk&#60;br /&#62;
    load us_ph_bmode_scan_mc_scatter_only&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% trim the delay offset from the scan line data&#60;br /&#62;
t0_offset = round(length(input_signal)/2) + (transducer.appended_zeros - transducer.beamforming_delays_offset);&#60;br /&#62;
scan_lines = scan_lines(:, t0_offset:end);&#60;/p&#62;
&#60;p&#62;% get the new length of the scan lines&#60;br /&#62;
Nt = length(scan_lines(1, :));&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% PROCESS THE RESULTS&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% -----------------------------&#60;br /&#62;
% Remove Input Signal&#60;br /&#62;
% -----------------------------&#60;/p&#62;
&#60;p&#62;% create a window to set the first part of each scan line to zero to remove&#60;br /&#62;
% interference from the input signal&#60;br /&#62;
scan_line_win = getWin(Nt*2, 'Tukey', 'Param', 0.05).';&#60;br /&#62;
scan_line_win = [zeros(1, t0_offset*2), scan_line_win(1:end/2 - t0_offset*2)];&#60;/p&#62;
&#60;p&#62;% apply the window to each of the scan lines&#60;br /&#62;
scan_lines = bsxfun(@times, scan_line_win, scan_lines);&#60;/p&#62;
&#60;p&#62;% -----------------------------&#60;br /&#62;
% Time Gain Compensation&#60;br /&#62;
% -----------------------------&#60;/p&#62;
&#60;p&#62;% create radius variable&#60;br /&#62;
r = c0*(1:Nt)*kgrid.dt/2;    % [m]&#60;/p&#62;
&#60;p&#62;% create time gain compensation function based on attenuation value,&#60;br /&#62;
% transmit frequency, and round trip distance&#60;br /&#62;
tgc_alpha = 0.1;       % [dB/(MHz cm)]&#60;br /&#62;
tgc = exp(2*tgc_alpha*tone_burst_freq/1e6*r*100);&#60;/p&#62;
&#60;p&#62;% apply the time gain compensation to each of the scan lines&#60;br /&#62;
scan_lines = bsxfun(@times, tgc, scan_lines);&#60;/p&#62;
&#60;p&#62;% -----------------------------&#60;br /&#62;
% Frequency Filtering&#60;br /&#62;
% -----------------------------&#60;/p&#62;
&#60;p&#62;% filter the scan lines using both the transmit frequency and the second&#60;br /&#62;
% harmonic&#60;br /&#62;
scan_lines_fund = gaussianFilter(scan_lines, 1/kgrid.dt, tone_burst_freq, 100, true);&#60;br /&#62;
scan_lines_harm = gaussianFilter(scan_lines, 1/kgrid.dt, 2*tone_burst_freq, 30, true);&#60;/p&#62;
&#60;p&#62;% -----------------------------&#60;br /&#62;
% Envelope Detection&#60;br /&#62;
% -----------------------------&#60;/p&#62;
&#60;p&#62;% envelope detection&#60;br /&#62;
scan_lines_fund = envelopeDetection(scan_lines_fund);&#60;br /&#62;
scan_lines_harm = envelopeDetection(scan_lines_harm);&#60;/p&#62;
&#60;p&#62;% -----------------------------&#60;br /&#62;
% Log Compression&#60;br /&#62;
% -----------------------------&#60;/p&#62;
&#60;p&#62;% normalised log compression&#60;br /&#62;
compression_ratio = 8;&#60;br /&#62;
scan_lines_fund_cp = logCompression(scan_lines_fund, compression_ratio, true);&#60;br /&#62;
scan_lines_harm_cp = logCompression(scan_lines_harm, compression_ratio, true);&#60;/p&#62;
&#60;p&#62;% -----------------------------&#60;br /&#62;
% Scan Conversion&#60;br /&#62;
% -----------------------------&#60;/p&#62;
&#60;p&#62;% set the desired size of the image&#60;br /&#62;
image_size = [Nx * dx, Ny * dy];&#60;/p&#62;
&#60;p&#62;% convert the data from polar coordinates to Cartesian coordinates for&#60;br /&#62;
% display&#60;br /&#62;
b_mode_fund = scanConversion(scan_lines_fund_cp, steering_angles, image_size, c0, kgrid.dt);&#60;br /&#62;
b_mode_harm = scanConversion(scan_lines_harm_cp, steering_angles, image_size, c0, kgrid.dt);&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% VISUALISATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% create the axis variables&#60;br /&#62;
x_axis = [0, Nx*dx*1e3];    % [mm]&#60;br /&#62;
y_axis = [0, Ny*dy*1e3];    % [mm]&#60;/p&#62;
&#60;p&#62;figure;&#60;/p&#62;
&#60;p&#62;subplot(1, 3, 1);&#60;br /&#62;
imagesc(y_axis, x_axis, medium.sound_speed(:, :, end/2));&#60;br /&#62;
axis image;&#60;br /&#62;
xlabel('Horizontal Position [mm]');&#60;br /&#62;
ylabel('Depth [mm]');&#60;br /&#62;
title('Scattering Phantom');&#60;/p&#62;
&#60;p&#62;subplot(1, 3, 2);&#60;br /&#62;
imagesc(y_axis, x_axis, b_mode_fund);&#60;br /&#62;
axis image;&#60;br /&#62;
xlabel('Horizontal Position [mm]');&#60;br /&#62;
ylabel('Depth [mm]');&#60;br /&#62;
title('B-Mode Image');&#60;/p&#62;
&#60;p&#62;subplot(1, 3, 3);&#60;br /&#62;
imagesc(y_axis, x_axis, b_mode_harm);&#60;br /&#62;
colormap(gray);&#60;br /&#62;
axis image;&#60;br /&#62;
xlabel('Horizontal Position [mm]');&#60;br /&#62;
ylabel('Depth [mm]');&#60;br /&#62;
title('Harmonic Image');&#60;/p&#62;
&#60;p&#62;scaleFig(2, 1);
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
