<?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: Increasing the number of active elements and grid points Ny</title>
		<link>http://www.k-wave.org/forum/topic/increasing-number-of-active-elements-and-grid-points-ny</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 03:12:26 +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/increasing-number-of-active-elements-and-grid-points-ny" rel="self" type="application/rss+xml" />

		<item>
			<title>marjanbn on "Increasing the number of active elements and grid points Ny"</title>
			<link>http://www.k-wave.org/forum/topic/increasing-number-of-active-elements-and-grid-points-ny#post-8226</link>
			<pubDate>Fri, 25 Jun 2021 17:21:57 +0000</pubDate>
			<dc:creator>marjanbn</dc:creator>
			<guid isPermaLink="false">8226@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;I’m trying to simulate a B-mode image using a phantom with an inclusion. When I use 32 active transducer elements with Ny = 364, the simulation works well. Please find below the resultant B-mode image:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://photos.app.goo.gl/8LYRwA2CR41abxcK8&#34; rel=&#34;nofollow&#34;&#62;https://photos.app.goo.gl/8LYRwA2CR41abxcK8&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;However, when I change the number of active elements to 64 or 128 and also increase Ny to 652 (for 64 active elements), I get only a dark patch. I cannot find the reason, it seems the wave is not traveled properly. I’m only changing Ny and the number of active elements and not the Nx or travel time. Please find below the resultant B-mode image:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://photos.app.goo.gl/8LYRwA2CR41abxcK8&#34; rel=&#34;nofollow&#34;&#62;https://photos.app.goo.gl/8LYRwA2CR41abxcK8&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I appreciate it if you can help me with this problem and clarify why this happens.&#60;/p&#62;
&#60;p&#62;Please see below the codes for both images. In the second code, as I mentioned before, only Ny and the number of active elements have been changed.&#60;/p&#62;
&#60;p&#62;Best,&#60;br /&#62;
Marjan&#60;/p&#62;
&#60;p&#62;--------------------------------------------------------------------------------------------------------------------------&#60;/p&#62;
&#60;p&#62;Code related to the first image:&#60;/p&#62;
&#60;p&#62;% Simulating B-mode Ultrasound Images&#60;/p&#62;
&#60;p&#62;clearvars;&#60;br /&#62;
clc;&#60;/p&#62;
&#60;p&#62;% simulation settings&#60;br /&#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;br /&#62;
pml_x_size = 20;                % [grid points]&#60;br /&#62;
pml_y_size = 10;                % [grid points]&#60;br /&#62;
pml_z_size = 1;                % [grid points]&#60;/p&#62;
&#60;p&#62;c_background = 1530;   %[m/s]&#60;br /&#62;
c_target = 1600;       %[m/s]&#60;br /&#62;
c0 = [c_background c_target];&#60;/p&#62;
&#60;p&#62;f_max = 10e6; %5e6;     % Maximum frequency&#60;br /&#62;
c0_min = min([c_background c_target]);     % Mininmum apeed of sound&#60;br /&#62;
c0_max = max([c_background c_target]);     % Maximum apeed of sound&#60;br /&#62;
c0_mean = mean([c_background c_target]);&#60;/p&#62;
&#60;p&#62;% % set desired grid size in the x- and y- direction not including the PML&#60;br /&#62;
x = 30e-3;       % [m]&#60;br /&#62;
% y = 40e-3;       % [m]   &#60;/p&#62;
&#60;p&#62;points_per_wavelength = 5; %4;&#60;br /&#62;
dx = c0_min/(points_per_wavelength*f_max);&#60;br /&#62;
dy = dx;                   % [m]&#60;br /&#62;
dz = dx;   % [m]&#60;br /&#62;
Nx = round(x/dx)&#60;br /&#62;
% Ny = round(y/dy)&#60;br /&#62;
Nx = 1024 - 2 * pml_x_size;   % Check for Prime Factors!&#60;br /&#62;
% Ny = 672 - 2 * pml_y_size;  % 1350 - 2 * pml_y_size;   % Check for Prime Factors!&#60;/p&#62;
&#60;p&#62;% set total number of grid points not including the PML&#60;br /&#62;
% Nx = 512 - 2 * pml_x_size;    % [grid points]&#60;br /&#62;
Ny = 384 - 2 * pml_y_size;      % [grid points]&#60;br /&#62;
Nz = 2;&#60;/p&#62;
&#60;p&#62;% create the k-space grid&#60;br /&#62;
kgrid = kWaveGrid(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;/p&#62;
&#60;p&#62;rho0= 1000;                % [kg/m^3]&#60;/p&#62;
&#60;p&#62;medium.alpha_coeff = 0.5; %0.73; %0.75;    % [dB/(MHz^y cm)]&#60;br /&#62;
medium.alpha_power = 1.05;&#60;br /&#62;
% medium.BonA = 9.21; %6;&#60;br /&#62;
% medium.alpha_mode = 'no_dispersion'; &#60;/p&#62;
&#60;p&#62;% create the time array&#60;br /&#62;
t_end = (Nx * dx) * 2.2 / c0_min;   % [s]&#60;br /&#62;
% t_end = (Nx * dx) * 4.2 / c0_min;   % [s]&#60;br /&#62;
kgrid.makeTime(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 = f_max; %7.5e6; %1.5e6;        % [Hz]&#60;br /&#62;
tone_burst_cycles = 4;&#60;/p&#62;
&#60;p&#62;fs = 1/kgrid.dt; %sampling frequency [Hz]&#60;/p&#62;
&#60;p&#62;% figure()&#60;br /&#62;
% create the input signal using toneBurst&#60;br /&#62;
input_signal = toneBurst(fs, tone_burst_freq, tone_burst_cycles);&#60;br /&#62;
% input_signal = toneBurst(1/kgrid.dt, tone_burst_freq, tone_burst_cycles,'Plot',true);&#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 ./ (c_background * 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 (considering L14-5/38 Linear&#60;br /&#62;
% transducer)&#60;br /&#62;
transducer.number_elements = 32;  	% total number of transducer elements&#60;br /&#62;
transducer.element_width = 10;        % width of each element [grid points] Pitch = 0.3 mm&#60;br /&#62;
transducer.element_length = 1; % length of each element [grid points] Elevation height = 4 mm&#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_mean;                       % sound speed [m/s]&#60;br /&#62;
transducer.focus_distance = 10e-3;                      % focus distance [m]&#60;br /&#62;
transducer.elevation_focus_distance = 16e-3; %19e-3;    % focus distance in the elevation plane [m]&#60;br /&#62;
transducer.steering_angle = 0;                  % 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 = kWaveTransducer(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;/p&#62;
&#60;p&#62;y_FOV = 40e-3;&#60;br /&#62;
% number_scan_lines = 96;&#60;br /&#62;
number_scan_lines = round((dy+y_FOV)/(transducer.element_width*dy));&#60;br /&#62;
Nx_tot = Nx;&#60;br /&#62;
Ny_tot = Ny + number_scan_lines * transducer.element_width;&#60;br /&#62;
Nz_tot = Nz;&#60;/p&#62;
&#60;p&#62;% define a random distribution of scatterers for the medium and the&#60;br /&#62;
% properties&#60;br /&#62;
background_map_mean = 1;&#60;br /&#62;
% background_map_std_background = 0.0026;&#60;br /&#62;
background_map_std_background = 0.008; %0.04;&#60;br /&#62;
background_map = background_map_mean + background_map_std_background * randn([Nx_tot, Ny_tot, Nz_tot]);&#60;/p&#62;
&#60;p&#62;sound_speed_map = c_background * ones(Nx_tot, Ny_tot, Nz_tot) .* background_map;&#60;br /&#62;
density_map = rho0 * ones(Nx_tot, Ny_tot, Nz_tot) .* background_map;&#60;/p&#62;
&#60;p&#62;% background_map_std_target = 0.0036;&#60;br /&#62;
background_map_std_target = 0.001; %0;&#60;br /&#62;
background_map_target = background_map_mean + background_map_std_target * randn([Nx_tot, Ny_tot, Nz_tot]);&#60;br /&#62;
sound_speed_target = c_target * ones(Nx_tot, Ny_tot, Nz_tot) .* background_map_target;&#60;br /&#62;
density_target = rho0 * ones(Nx_tot, Ny_tot, Nz_tot) .* background_map_target;&#60;/p&#62;
&#60;p&#62;radius_x = 5e-3;&#60;br /&#62;
radius_y = 5e-3;&#60;br /&#62;
radius_z = 0.25e-3;&#60;br /&#62;
r_x = round(radius_x/dx);&#60;br /&#62;
r_y = round(radius_y/dy);&#60;br /&#62;
r_z = round(radius_z/dz);&#60;/p&#62;
&#60;p&#62;x_pos = 15e-3;      % [m]&#60;br /&#62;
y_pos = 20e-3;   % [m]&#60;br /&#62;
c_x = round(x_pos/dx) ;&#60;br /&#62;
c_y = round(y_pos/dy)+ Ny/2 + 1;&#60;br /&#62;
c_z = Nz_tot/2;&#60;/p&#62;
&#60;p&#62;target_region = makeEllipsoid([Nx_tot, Ny_tot, Nz_tot], [c_x, c_y, c_z], [r_x, r_y, r_z]);&#60;br /&#62;
sound_speed_map(target_region == 1) = sound_speed_target(target_region == 1);&#60;br /&#62;
density_map(target_region == 1) = density_target(target_region == 1);&#60;/p&#62;
&#60;p&#62;y_FOV_mm = (Ny_tot-Ny-1)*dy*1000&#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_pr= 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;br /&#62;
    'Smooth', [true,true,true]};&#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;    % set medium position&#60;br /&#62;
    medium_position = 1;&#60;/p&#62;
&#60;p&#62; %%% predeformation medium &#60;/p&#62;
&#60;p&#62;    % loop through the scan lines&#60;br /&#62;
    for scan_line_index = 1: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(scan_line_index) ' of ' num2str(number_scan_lines)  ' (Predeformation)']);&#60;/p&#62;
&#60;p&#62;        % load the current section of the medium&#60;br /&#62;
        medium.sound_speed = sound_speed_map(:, medium_position:medium_position + Ny - 1, :);&#60;br /&#62;
        medium.density = density_map(:, medium_position:medium_position + Ny - 1, :);&#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;        % extract the scan line from the sensor data&#60;br /&#62;
        scan_lines_pre(scan_line_index, :) = transducer.scan_line(sensor_data);&#60;br /&#62;
       save Bmode_scan_lines_CIRSphantom_1Inclusion_10MHz_10mm_focus_2.mat scan_lines_pre&#60;/p&#62;
&#60;p&#62;        % update medium position&#60;br /&#62;
        medium_position = medium_position + transducer.element_width;&#60;/p&#62;
&#60;p&#62;    end&#60;/p&#62;
&#60;p&#62;    % save the scan lines to disk&#60;/p&#62;
&#60;p&#62;       save Bmode_scan_lines_CIRSphantom_1Inclusion_10MHz_10mm_focus_2.mat scan_lines_pre&#60;/p&#62;
&#60;p&#62;else&#60;/p&#62;
&#60;p&#62;    % load the scan lines from disk&#60;br /&#62;
    load Bmode_scan_lines_CIRSphantom_1Inclusion_10MHz_10mm_focus.mat;&#60;/p&#62;
&#60;p&#62;end&#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;% Precompression&#60;br /&#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(kgrid.Nt * 2, 'Tukey', 'Param', 0.05).';&#60;br /&#62;
scan_line_win = [zeros(1, length(input_signal) * 2), scan_line_win(1:end/2 - length(input_signal) * 2)];&#60;/p&#62;
&#60;p&#62;% apply the window to each of the scan lines&#60;br /&#62;
scan_lines_pre = bsxfun(@times, scan_line_win, scan_lines_pre);&#60;/p&#62;
&#60;p&#62;% store a copy of the middle scan line to illustrate the effects of each&#60;br /&#62;
% processing step&#60;/p&#62;
&#60;p&#62;if mod(number_scan_lines,2)==0&#60;br /&#62;
scan_line_example_pre(1, :) = scan_lines_pre(end/2, :);&#60;br /&#62;
else&#60;br /&#62;
scan_line_example_pre(1, :) = scan_lines_pre((end+1)/2, :);&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% -----------------------------&#60;br /&#62;
% Time Gain Compensation&#60;br /&#62;
% -----------------------------&#60;/p&#62;
&#60;p&#62;% create radius variable assuming that t0 corresponds to the middle of the&#60;br /&#62;
% input signal&#60;br /&#62;
t0 = length(input_signal) * kgrid.dt / 2;&#60;br /&#62;
r = c0_max * ( (1:length(kgrid.t_array)) * kgrid.dt - t0 ) / 2;    % [m]&#60;/p&#62;
&#60;p&#62;% define absorption value and convert to correct units&#60;br /&#62;
tgc_alpha_db_cm = medium.alpha_coeff * (tone_burst_freq * 1e-6)^medium.alpha_power;&#60;br /&#62;
tgc_alpha_np_m = tgc_alpha_db_cm / 8.686 * 100;&#60;/p&#62;
&#60;p&#62;% create time gain compensation function based on attenuation value and&#60;br /&#62;
% round trip distance&#60;br /&#62;
tgc = exp(tgc_alpha_np_m * 2 * r);&#60;/p&#62;
&#60;p&#62;% apply the time gain compensation to each of the scan lines&#60;br /&#62;
scan_lines_pre = bsxfun(@times, tgc, scan_lines_pre);&#60;/p&#62;
&#60;p&#62;% store a copy of the middle scan line to illustrate the effects of each&#60;br /&#62;
% processing step&#60;br /&#62;
if mod(number_scan_lines,2)==0&#60;br /&#62;
scan_line_example_pre(2, :) = scan_lines_pre(end/2, :);&#60;br /&#62;
else&#60;br /&#62;
scan_line_example_pre(2, :) = scan_lines_pre((end+1)/2, :);&#60;br /&#62;
end&#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_pre = gaussianFilter(scan_lines_pre, 1/kgrid.dt, tone_burst_freq, 100, true);&#60;br /&#62;
scan_lines_fund_pre = gaussianFilter(scan_lines_pre, 1/kgrid.dt, tone_burst_freq, 100);&#60;br /&#62;
% set(gca, 'XLim', [0, 20]);  %set(gca, 'XLim', [0, 6]);&#60;br /&#62;
% title('Predeformation');&#60;br /&#62;
% scan_lines_harm_pre = gaussianFilter(scan_lines_pre, 1/kgrid.dt, 2 * tone_burst_freq, 30, true);&#60;br /&#62;
scan_lines_harm_pre = gaussianFilter(scan_lines_pre, 1/kgrid.dt, 2 * tone_burst_freq, 30);&#60;br /&#62;
% set(gca, 'XLim', [0, 20]);  %set(gca, 'XLim', [0, 6]);&#60;br /&#62;
% title('Predeformation');&#60;/p&#62;
&#60;p&#62;% store a copy of the middle scan line to illustrate the effects of each&#60;br /&#62;
% processing step&#60;br /&#62;
if mod(number_scan_lines,2)==0&#60;br /&#62;
scan_line_example_pre(3, :) = scan_lines_fund_pre(end/2, :);&#60;br /&#62;
else&#60;br /&#62;
scan_line_example_pre(3, :) = scan_lines_fund_pre((end+1)/2, :);&#60;br /&#62;
end&#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_pre = envelopeDetection(scan_lines_fund_pre);&#60;br /&#62;
scan_lines_harm_pre = envelopeDetection(scan_lines_harm_pre);&#60;/p&#62;
&#60;p&#62;% store a copy of the middle scan line to illustrate the effects of each&#60;br /&#62;
% processing step&#60;br /&#62;
if mod(number_scan_lines,2)==0&#60;br /&#62;
scan_line_example_pre(4, :) = scan_lines_fund_pre(end/2, :);&#60;br /&#62;
else&#60;br /&#62;
scan_line_example_pre(4, :) = scan_lines_fund_pre((end+1)/2, :);&#60;br /&#62;
end&#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 = 30;&#60;br /&#62;
scan_lines_fund_pre = logCompression(scan_lines_fund_pre, compression_ratio, true);&#60;br /&#62;
scan_lines_harm_pre = logCompression(scan_lines_harm_pre, compression_ratio, true);&#60;/p&#62;
&#60;p&#62;% store a copy of the middle scan line to illustrate the effects of each&#60;br /&#62;
% processing step&#60;br /&#62;
if mod(number_scan_lines,2)==0&#60;br /&#62;
scan_line_example_pre(5, :) = scan_lines_fund_pre(end/2, :);&#60;br /&#62;
else&#60;br /&#62;
scan_line_example_pre(5, :) = scan_lines_fund_pre((end+1)/2, :);&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% -----------------------------&#60;br /&#62;
% Scan Conversion&#60;br /&#62;
% -----------------------------&#60;/p&#62;
&#60;p&#62;% upsample the image using linear interpolation&#60;br /&#62;
scale_factor = 30;&#60;br /&#62;
scan_lines_fund_pre = interp2(1:kgrid.Nt, (1:number_scan_lines).', scan_lines_fund_pre, 1:kgrid.Nt, (1:1/scale_factor:number_scan_lines).');&#60;br /&#62;
scan_lines_harm_pre = interp2(1:kgrid.Nt, (1:number_scan_lines).', scan_lines_harm_pre, 1:kgrid.Nt, (1:1/scale_factor:number_scan_lines).');&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% VISUALISATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;figure;&#60;br /&#62;
imagesc((0:number_scan_lines * transducer.element_width - 1) * dy * 1e3,...&#60;br /&#62;
    (0:Nx_tot-1) * dx * 1e3, sound_speed_map(:, 1 + Ny/2:end - Ny/2, Nz/2)...&#60;br /&#62;
    .* density_map(:, 1 + Ny/2:end - Ny/2, Nz/2));&#60;br /&#62;
axis image;&#60;br /&#62;
colormap(gray);&#60;br /&#62;
title('Impedance Image');&#60;br /&#62;
xlabel('Horizontal Position [mm]');&#60;br /&#62;
ylabel('Depth [mm]');&#60;/p&#62;
&#60;p&#62;% plot the processing steps&#60;br /&#62;
figure;&#60;br /&#62;
stackedPlot(kgrid.t_array * 1e6, {'1. Beamformed Signal', '2. Time Gain Compensation', '3. Frequency Filtering', '4. Envelope Detection', '5. Log Compression'}, scan_line_example_pre);&#60;br /&#62;
xlabel('Time [\mus]');&#60;br /&#62;
title('Predeformation');&#60;br /&#62;
set(gca, 'XLim', [5, t_end * 1e6]);&#60;/p&#62;
&#60;p&#62;% plot the processed b-mode ultrasound image&#60;br /&#62;
figure;&#60;br /&#62;
horz_axis = (0:length(scan_lines_fund_pre(:, 1)) - 1) * transducer.element_width * dy / scale_factor * 1e3;&#60;br /&#62;
imagesc(horz_axis, r * 1e3, scan_lines_fund_pre.');&#60;br /&#62;
axis image;&#60;br /&#62;
colormap(gray);&#60;br /&#62;
set(gca, 'YLim', [2, 30]);&#60;br /&#62;
title('B-mode Image (Predeformation)');&#60;br /&#62;
xlabel('Horizontal Position [mm]');&#60;br /&#62;
ylabel('Depth [mm]');&#60;/p&#62;
&#60;p&#62;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------&#60;/p&#62;
&#60;p&#62;Code related to the second image:&#60;/p&#62;
&#60;p&#62;% Simulating B-mode Ultrasound Images&#60;/p&#62;
&#60;p&#62;clearvars;&#60;br /&#62;
clc;&#60;/p&#62;
&#60;p&#62;% simulation settings&#60;br /&#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;br /&#62;
pml_x_size = 20;                % [grid points]&#60;br /&#62;
pml_y_size = 10;                % [grid points]&#60;br /&#62;
pml_z_size = 1;                % [grid points]&#60;/p&#62;
&#60;p&#62;c_background = 1530;   %[m/s]&#60;br /&#62;
c_target = 1600;       %[m/s]&#60;br /&#62;
c0 = [c_background c_target];&#60;/p&#62;
&#60;p&#62;f_max = 10e6; %5e6;     % Maximum frequency&#60;br /&#62;
c0_min = min([c_background c_target]);     % Mininmum apeed of sound&#60;br /&#62;
c0_max = max([c_background c_target]);     % Maximum apeed of sound&#60;br /&#62;
c0_mean = mean([c_background c_target]);&#60;/p&#62;
&#60;p&#62;% % set desired grid size in the x- and y- direction not including the PML&#60;br /&#62;
x = 30e-3;       % [m]&#60;br /&#62;
% y = 40e-3;       % [m]   &#60;/p&#62;
&#60;p&#62;points_per_wavelength = 5; %4;&#60;br /&#62;
dx = c0_min/(points_per_wavelength*f_max);&#60;br /&#62;
dy = dx;                   % [m]&#60;br /&#62;
dz = dx;   % [m]&#60;br /&#62;
Nx = round(x/dx)&#60;br /&#62;
% Ny = round(y/dy)&#60;br /&#62;
Nx = 1024 - 2 * pml_x_size;   % Check for Prime Factors!&#60;br /&#62;
Ny = 672 - 2 * pml_y_size;  % 1350 - 2 * pml_y_size;   % Check for Prime Factors!&#60;/p&#62;
&#60;p&#62;% set total number of grid points not including the PML&#60;br /&#62;
% Nx = 512 - 2 * pml_x_size;    % [grid points]&#60;br /&#62;
% Ny = 384 - 2 * pml_y_size;      % [grid points]&#60;br /&#62;
Nz = 2;&#60;/p&#62;
&#60;p&#62;% create the k-space grid&#60;br /&#62;
kgrid = kWaveGrid(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;/p&#62;
&#60;p&#62;rho0= 1000;                % [kg/m^3]&#60;/p&#62;
&#60;p&#62;medium.alpha_coeff = 0.5; %0.73; %0.75;    % [dB/(MHz^y cm)]&#60;br /&#62;
medium.alpha_power = 1.05;&#60;br /&#62;
% medium.BonA = 9.21; %6;&#60;br /&#62;
% medium.alpha_mode = 'no_dispersion'; &#60;/p&#62;
&#60;p&#62;% create the time array&#60;br /&#62;
t_end = (Nx * dx) * 2.2 / c0_min;   % [s]&#60;br /&#62;
% t_end = (Nx * dx) * 4.2 / c0_min;   % [s]&#60;br /&#62;
kgrid.makeTime(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 = f_max; %7.5e6; %1.5e6;        % [Hz]&#60;br /&#62;
tone_burst_cycles = 4;&#60;/p&#62;
&#60;p&#62;fs = 1/kgrid.dt; %sampling frequency [Hz]&#60;/p&#62;
&#60;p&#62;% figure()&#60;br /&#62;
% create the input signal using toneBurst&#60;br /&#62;
input_signal = toneBurst(fs, tone_burst_freq, tone_burst_cycles);&#60;br /&#62;
% input_signal = toneBurst(1/kgrid.dt, tone_burst_freq, tone_burst_cycles,'Plot',true);&#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 ./ (c_background * 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 (considering L14-5/38 Linear&#60;br /&#62;
% transducer)&#60;br /&#62;
transducer.number_elements = 64;  	% total number of transducer elements&#60;br /&#62;
transducer.element_width = 10;        % width of each element [grid points] Pitch = 0.3 mm&#60;br /&#62;
transducer.element_length = 1; % length of each element [grid points] Elevation height = 4 mm&#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_mean;                       % sound speed [m/s]&#60;br /&#62;
transducer.focus_distance = 10e-3;                      % focus distance [m]&#60;br /&#62;
transducer.elevation_focus_distance = 16e-3; %19e-3;    % focus distance in the elevation plane [m]&#60;br /&#62;
transducer.steering_angle = 0;                  % 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 = kWaveTransducer(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;/p&#62;
&#60;p&#62;y_FOV = 40e-3;&#60;br /&#62;
% number_scan_lines = 96;&#60;br /&#62;
number_scan_lines = round((dy+y_FOV)/(transducer.element_width*dy));&#60;br /&#62;
Nx_tot = Nx;&#60;br /&#62;
Ny_tot = Ny + number_scan_lines * transducer.element_width;&#60;br /&#62;
Nz_tot = Nz;&#60;/p&#62;
&#60;p&#62;% define a random distribution of scatterers for the medium and the&#60;br /&#62;
% properties&#60;br /&#62;
background_map_mean = 1;&#60;br /&#62;
% background_map_std_background = 0.0026;&#60;br /&#62;
background_map_std_background = 0.008; %0.04;&#60;br /&#62;
background_map = background_map_mean + background_map_std_background * randn([Nx_tot, Ny_tot, Nz_tot]);&#60;/p&#62;
&#60;p&#62;sound_speed_map = c_background * ones(Nx_tot, Ny_tot, Nz_tot) .* background_map;&#60;br /&#62;
density_map = rho0 * ones(Nx_tot, Ny_tot, Nz_tot) .* background_map;&#60;/p&#62;
&#60;p&#62;% background_map_std_target = 0.0036;&#60;br /&#62;
background_map_std_target = 0.001; %0;&#60;br /&#62;
background_map_target = background_map_mean + background_map_std_target * randn([Nx_tot, Ny_tot, Nz_tot]);&#60;br /&#62;
sound_speed_target = c_target * ones(Nx_tot, Ny_tot, Nz_tot) .* background_map_target;&#60;br /&#62;
density_target = rho0 * ones(Nx_tot, Ny_tot, Nz_tot) .* background_map_target;&#60;/p&#62;
&#60;p&#62;radius_x = 5e-3;&#60;br /&#62;
radius_y = 5e-3;&#60;br /&#62;
radius_z = 0.25e-3;&#60;br /&#62;
r_x = round(radius_x/dx);&#60;br /&#62;
r_y = round(radius_y/dy);&#60;br /&#62;
r_z = round(radius_z/dz);&#60;/p&#62;
&#60;p&#62;x_pos = 15e-3;      % [m]&#60;br /&#62;
y_pos = 20e-3;   % [m]&#60;br /&#62;
c_x = round(x_pos/dx) ;&#60;br /&#62;
c_y = round(y_pos/dy)+ Ny/2 + 1;&#60;br /&#62;
c_z = Nz_tot/2;&#60;/p&#62;
&#60;p&#62;target_region = makeEllipsoid([Nx_tot, Ny_tot, Nz_tot], [c_x, c_y, c_z], [r_x, r_y, r_z]);&#60;br /&#62;
sound_speed_map(target_region == 1) = sound_speed_target(target_region == 1);&#60;br /&#62;
density_map(target_region == 1) = density_target(target_region == 1);&#60;/p&#62;
&#60;p&#62;y_FOV_mm = (Ny_tot-Ny-1)*dy*1000&#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_pr= 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;br /&#62;
    'Smooth', [true,true,true]};&#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;    % set medium position&#60;br /&#62;
    medium_position = 1;&#60;/p&#62;
&#60;p&#62;    % loop through the scan lines&#60;br /&#62;
    for scan_line_index = 1: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(scan_line_index) ' of ' num2str(number_scan_lines)  ' (Predeformation)']);&#60;/p&#62;
&#60;p&#62;        % load the current section of the medium&#60;br /&#62;
        medium.sound_speed = sound_speed_map(:, medium_position:medium_position + Ny - 1, :);&#60;br /&#62;
        medium.density = density_map(:, medium_position:medium_position + Ny - 1, :);&#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;        % extract the scan line from the sensor data&#60;br /&#62;
        scan_lines_pre(scan_line_index, :) = transducer.scan_line(sensor_data);&#60;br /&#62;
	 save Bmode_scan_lines_CIRSphantom_1Inclusion_10MHz_10mm_focus_3.mat scan_lines_pre&#60;/p&#62;
&#60;p&#62;        % update medium position&#60;br /&#62;
        medium_position = medium_position + transducer.element_width;&#60;/p&#62;
&#60;p&#62;    end&#60;/p&#62;
&#60;p&#62;    % save the scan lines to disk&#60;br /&#62;
	save Bmode_scan_lines_CIRSphantom_1Inclusion_10MHz_10mm_focus_3.mat scan_lines_pre&#60;/p&#62;
&#60;p&#62;else&#60;/p&#62;
&#60;p&#62;    % load the scan lines from disk&#60;br /&#62;
    load Bmode_scan_lines_CIRSphantom_1Inclusion_10MHz_10mm_focus.mat;&#60;/p&#62;
&#60;p&#62;end&#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;% Precompression&#60;br /&#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(kgrid.Nt * 2, 'Tukey', 'Param', 0.05).';&#60;br /&#62;
scan_line_win = [zeros(1, length(input_signal) * 2), scan_line_win(1:end/2 - length(input_signal) * 2)];&#60;/p&#62;
&#60;p&#62;% apply the window to each of the scan lines&#60;br /&#62;
scan_lines_pre = bsxfun(@times, scan_line_win, scan_lines_pre);&#60;/p&#62;
&#60;p&#62;% store a copy of the middle scan line to illustrate the effects of each&#60;br /&#62;
% processing step&#60;/p&#62;
&#60;p&#62;if mod(number_scan_lines,2)==0&#60;br /&#62;
scan_line_example_pre(1, :) = scan_lines_pre(end/2, :);&#60;br /&#62;
else&#60;br /&#62;
scan_line_example_pre(1, :) = scan_lines_pre((end+1)/2, :);&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% -----------------------------&#60;br /&#62;
% Time Gain Compensation&#60;br /&#62;
% -----------------------------&#60;/p&#62;
&#60;p&#62;% create radius variable assuming that t0 corresponds to the middle of the&#60;br /&#62;
% input signal&#60;br /&#62;
t0 = length(input_signal) * kgrid.dt / 2;&#60;br /&#62;
r = c0_max * ( (1:length(kgrid.t_array)) * kgrid.dt - t0 ) / 2;    % [m]&#60;/p&#62;
&#60;p&#62;% define absorption value and convert to correct units&#60;br /&#62;
tgc_alpha_db_cm = medium.alpha_coeff * (tone_burst_freq * 1e-6)^medium.alpha_power;&#60;br /&#62;
tgc_alpha_np_m = tgc_alpha_db_cm / 8.686 * 100;&#60;/p&#62;
&#60;p&#62;% create time gain compensation function based on attenuation value and&#60;br /&#62;
% round trip distance&#60;br /&#62;
tgc = exp(tgc_alpha_np_m * 2 * r);&#60;/p&#62;
&#60;p&#62;% apply the time gain compensation to each of the scan lines&#60;br /&#62;
scan_lines_pre = bsxfun(@times, tgc, scan_lines_pre);&#60;/p&#62;
&#60;p&#62;% store a copy of the middle scan line to illustrate the effects of each&#60;br /&#62;
% processing step&#60;br /&#62;
if mod(number_scan_lines,2)==0&#60;br /&#62;
scan_line_example_pre(2, :) = scan_lines_pre(end/2, :);&#60;br /&#62;
else&#60;br /&#62;
scan_line_example_pre(2, :) = scan_lines_pre((end+1)/2, :);&#60;br /&#62;
end&#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_pre = gaussianFilter(scan_lines_pre, 1/kgrid.dt, tone_burst_freq, 100, true);&#60;br /&#62;
scan_lines_fund_pre = gaussianFilter(scan_lines_pre, 1/kgrid.dt, tone_burst_freq, 100);&#60;br /&#62;
% set(gca, 'XLim', [0, 20]);  %set(gca, 'XLim', [0, 6]);&#60;br /&#62;
% title('Predeformation');&#60;br /&#62;
% scan_lines_harm_pre = gaussianFilter(scan_lines_pre, 1/kgrid.dt, 2 * tone_burst_freq, 30, true);&#60;br /&#62;
scan_lines_harm_pre = gaussianFilter(scan_lines_pre, 1/kgrid.dt, 2 * tone_burst_freq, 30);&#60;br /&#62;
% set(gca, 'XLim', [0, 20]);  %set(gca, 'XLim', [0, 6]);&#60;br /&#62;
% title('Predeformation');&#60;/p&#62;
&#60;p&#62;% store a copy of the middle scan line to illustrate the effects of each&#60;br /&#62;
% processing step&#60;br /&#62;
if mod(number_scan_lines,2)==0&#60;br /&#62;
scan_line_example_pre(3, :) = scan_lines_fund_pre(end/2, :);&#60;br /&#62;
else&#60;br /&#62;
scan_line_example_pre(3, :) = scan_lines_fund_pre((end+1)/2, :);&#60;br /&#62;
end&#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_pre = envelopeDetection(scan_lines_fund_pre);&#60;br /&#62;
scan_lines_harm_pre = envelopeDetection(scan_lines_harm_pre);&#60;/p&#62;
&#60;p&#62;% store a copy of the middle scan line to illustrate the effects of each&#60;br /&#62;
% processing step&#60;br /&#62;
if mod(number_scan_lines,2)==0&#60;br /&#62;
scan_line_example_pre(4, :) = scan_lines_fund_pre(end/2, :);&#60;br /&#62;
else&#60;br /&#62;
scan_line_example_pre(4, :) = scan_lines_fund_pre((end+1)/2, :);&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;scan_lines_ED = scan_lines_fund_pre;&#60;br /&#62;
% scale_factor = 2;&#60;br /&#62;
% scan_lines_ED = interp2(1:kgrid.Nt, (1:number_scan_lines).', scan_lines_ED, 1:kgrid.Nt, (1:1/scale_factor:number_scan_lines).');&#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 = 30;&#60;br /&#62;
scan_lines_fund_pre = logCompression(scan_lines_fund_pre, compression_ratio, true);&#60;br /&#62;
scan_lines_harm_pre = logCompression(scan_lines_harm_pre, compression_ratio, true);&#60;/p&#62;
&#60;p&#62;% store a copy of the middle scan line to illustrate the effects of each&#60;br /&#62;
% processing step&#60;br /&#62;
if mod(number_scan_lines,2)==0&#60;br /&#62;
scan_line_example_pre(5, :) = scan_lines_fund_pre(end/2, :);&#60;br /&#62;
else&#60;br /&#62;
scan_line_example_pre(5, :) = scan_lines_fund_pre((end+1)/2, :);&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% -----------------------------&#60;br /&#62;
% Scan Conversion&#60;br /&#62;
% -----------------------------&#60;/p&#62;
&#60;p&#62;% upsample the image using linear interpolation&#60;br /&#62;
scale_factor = 30;&#60;br /&#62;
scan_lines_fund_pre = interp2(1:kgrid.Nt, (1:number_scan_lines).', scan_lines_fund_pre, 1:kgrid.Nt, (1:1/scale_factor:number_scan_lines).');&#60;br /&#62;
scan_lines_harm_pre = interp2(1:kgrid.Nt, (1:number_scan_lines).', scan_lines_harm_pre, 1:kgrid.Nt, (1:1/scale_factor:number_scan_lines).');&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% VISUALISATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;figure;&#60;br /&#62;
imagesc((0:number_scan_lines * transducer.element_width - 1) * dy * 1e3,...&#60;br /&#62;
    (0:Nx_tot-1) * dx * 1e3, sound_speed_map(:, 1 + Ny/2:end - Ny/2, Nz/2)...&#60;br /&#62;
    .* density_map(:, 1 + Ny/2:end - Ny/2, Nz/2));&#60;br /&#62;
axis image;&#60;br /&#62;
colormap(gray);&#60;br /&#62;
title('Impedance Image');&#60;br /&#62;
xlabel('Horizontal Position [mm]');&#60;br /&#62;
ylabel('Depth [mm]');&#60;/p&#62;
&#60;p&#62;% plot the processing steps&#60;br /&#62;
figure;&#60;br /&#62;
stackedPlot(kgrid.t_array * 1e6, {'1. Beamformed Signal', '2. Time Gain Compensation', '3. Frequency Filtering', '4. Envelope Detection', '5. Log Compression'}, scan_line_example_pre);&#60;br /&#62;
xlabel('Time [\mus]');&#60;br /&#62;
title('Predeformation');&#60;br /&#62;
set(gca, 'XLim', [5, t_end * 1e6]);&#60;/p&#62;
&#60;p&#62;% plot the processed b-mode ultrasound image&#60;br /&#62;
figure;&#60;br /&#62;
horz_axis = (0:length(scan_lines_fund_pre(:, 1)) - 1) * transducer.element_width * dy / scale_factor * 1e3;&#60;br /&#62;
imagesc(horz_axis, r * 1e3, scan_lines_fund_pre.');&#60;br /&#62;
axis image;&#60;br /&#62;
colormap(gray);&#60;br /&#62;
set(gca, 'YLim', [2, 30]);&#60;br /&#62;
title('B-mode Image (Predeformation)');&#60;br /&#62;
xlabel('Horizontal Position [mm]');&#60;br /&#62;
ylabel('Depth [mm]');
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
