<?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: Simulating medium with two acoustic properties</title>
		<link>http://www.k-wave.org/forum/topic/simulating-medium-with-two-acoustic-properties</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 03:09:21 +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/simulating-medium-with-two-acoustic-properties" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "Simulating medium with two acoustic properties"</title>
			<link>http://www.k-wave.org/forum/topic/simulating-medium-with-two-acoustic-properties#post-6041</link>
			<pubDate>Tue, 04 Jul 2017 09:01:31 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">6041@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Mohalmadi,&#60;/p&#62;
&#60;p&#62;See my comment above.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Mohalmadi on "Simulating medium with two acoustic properties"</title>
			<link>http://www.k-wave.org/forum/topic/simulating-medium-with-two-acoustic-properties#post-6039</link>
			<pubDate>Mon, 03 Jul 2017 16:56:39 +0000</pubDate>
			<dc:creator>Mohalmadi</dc:creator>
			<guid isPermaLink="false">6039@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Bradley .. Thank you for your response.&#60;/p&#62;
&#60;p&#62;What I did is creating a medium which has the following properties: c0, rho0, medium.alpha_coeff. Then I wanted to create another medium within it which has the following properties: scattering_c0, scattering_rho0, and scattering_alpha_coeff. By doing that I was able to change the properties of the cavity independently from the medium. Even changing the value of the smaller medium's (scatterer) attenuation doesn't seem to affect the final result.&#60;/p&#62;
&#60;p&#62;So basically when a sound signal travels from a medium with high attenuation (Brain) and passes through a medium with a lower attenuation (water) we should see a hyperechoic signal coming from the base of the water medium. From the simulation, I wasn't able to see that. &#60;/p&#62;
&#60;p&#62;So my question is, how can I change the value of the attenuation?&#60;/p&#62;
&#60;p&#62;Thank you
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Simulating medium with two acoustic properties"</title>
			<link>http://www.k-wave.org/forum/topic/simulating-medium-with-two-acoustic-properties#post-6022</link>
			<pubDate>Thu, 29 Jun 2017 15:03:53 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">6022@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Moe,&#60;/p&#62;
&#60;p&#62;The field name for the attenuation is called &#60;code&#62;medium.alpha_coeff&#60;/code&#62; not &#60;code&#62;medium.attenuation&#60;/code&#62;, so it looks like you're not assigning the heterogeneous absorption value. You might also want to try a stronger attenuation contrast.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Mohalmadi on "Simulating medium with two acoustic properties"</title>
			<link>http://www.k-wave.org/forum/topic/simulating-medium-with-two-acoustic-properties#post-6017</link>
			<pubDate>Wed, 28 Jun 2017 04:04:52 +0000</pubDate>
			<dc:creator>Mohalmadi</dc:creator>
			<guid isPermaLink="false">6017@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello &#60;/p&#62;
&#60;p&#62;I'm trying to mimic some of the artifact associated with the intraoperative ultrasound system. basically, I created a medium that has homogeneous acoustic properties. and within the medium, I created a cavity that has different acoustic properties.&#60;br /&#62;
I started by changing the code of one of the examples (b-mode linear transducer), however, I couldn't change the attenuation coefficient of the cavity (Ball). So what I did is changing the matrix of the medium. I was able to change the attenuation value, but unfortunately, the B-mode image doesn't change when I change the value. It seems that it only depends on c0 (sound speed) and rho0 (density) but not attenuation. Can anyone explain to me how to do that?&#60;/p&#62;
&#60;p&#62;Thank you for your help&#60;br /&#62;
Moe&#60;/p&#62;
&#60;p&#62;My code is here if you want to check it:&#60;/p&#62;
&#60;p&#62;close all&#60;br /&#62;
clear all&#60;br /&#62;
clc&#60;/p&#62;
&#60;p&#62;% simulation settings&#60;br /&#62;
DATA_CAST       = '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 = 5;            % Depth [grid points]&#60;br /&#62;
pml_y_size = 3;            % Width [grid points]&#60;br /&#62;
pml_z_size = 3;            % Length[grid points] &#60;/p&#62;
&#60;p&#62;% set total number of grid points not including the PML&#60;br /&#62;
Nx = 64 - 2*pml_x_size;   % [grid points]&#60;br /&#62;
Ny = 32 - 2*pml_y_size;   % [grid points]&#60;br /&#62;
Nz = 32 - 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 = 20e-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;% Calculations for plotting depth&#60;br /&#62;
N_whole_x = Nx + (2*pml_x_size);&#60;br /&#62;
Whole_x_cartesian = N_whole_x * dx;&#60;br /&#62;
Start_medium_depth = (Whole_x_cartesian-x)/2;&#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 = 1560;                  % Speed of sound in medium [m/s]&#60;br /&#62;
rho0 = 1046;                % Denisty of medium [kg/m^3]&#60;br /&#62;
medium.alpha_coeff = 0.60; 	% Attenuation coefficent of medium [dB/(MHz^y cm)]&#60;br /&#62;
medium.alpha_power = 1.35;  % Power law absorption exponent&#60;br /&#62;
medium.BonA = 6;            % Parameter of nonlinearity&#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;     % Total simulation time default number is 2.2 however,&#60;br /&#62;
                            % when need more time to capture signal you&#60;br /&#62;
                            % nedd to increase it [s] &#60;/p&#62;
&#60;p&#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;% The maximum frequency that can be represented on the spatial grid is the&#60;br /&#62;
% Nyquist limit of c_min/(2*dx) where dx is the grid spacing.&#60;br /&#62;
% When using higher frequencies in the simulation, decrease the grid spacing.&#60;/p&#62;
&#60;p&#62;source_strength = 1e6;   % Intensity of source [Pa]&#60;br /&#62;
tone_burst_freq = 0.4e6; % Signal frequesncy [Hz]&#60;br /&#62;
tone_burst_cycles = 4;   % Number of cycles [#]&#60;/p&#62;
&#60;p&#62;% create the input signal using toneBurst % &#38;lt;becomes our ultrasound pulse&#38;gt;&#60;br /&#62;
input_signal = toneBurst(1/kgrid.dt, tone_burst_freq, tone_burst_cycles,'Envelope','Rectangular');&#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 = 8;  	% Total number of transducer elements&#60;br /&#62;
transducer.element_width = 2;       % Width of each element [grid points]&#60;br /&#62;
transducer.element_length = 6;  	% 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;                % Speed of sound [m/s]&#60;br /&#62;
transducer.focus_distance = Inf;            % Focus distance [m]&#60;br /&#62;
transducer.elevation_focus_distance = Inf;  % 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 = 'Rectangular'; % Apodization used on transmit&#60;br /&#62;
transducer.receive_apodization = 'Rectangular';  % Apodization used on receive&#60;/p&#62;
&#60;p&#62;% define the transducer elements that are currently active&#60;br /&#62;
number_active_elements = transducer.number_elements;&#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;
number_scan_lines = 30;&#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&#60;br /&#62;
background_map_mean = 1;&#60;br /&#62;
background_map_std = 0.00;&#60;br /&#62;
background_map = background_map_mean + background_map_std*randn([Nx_tot, Ny_tot, Nz_tot]);&#60;/p&#62;
&#60;p&#62;% define a random distribution of scatterers for the highly scattering region&#60;/p&#62;
&#60;p&#62;scattering_map_bin = zeros(Nx_tot, Ny_tot, Nz_tot);&#60;/p&#62;
&#60;p&#62;% The position of the highly scattering object on the x-axis&#60;br /&#62;
x_min = round(Nx_tot/4);    % Starting point&#60;br /&#62;
x_center = round(Nx_tot/2); % Middle point&#60;br /&#62;
x_max = round(Nx_tot/2);% End point&#60;/p&#62;
&#60;p&#62;% The position of the highly scattering object on the y-axis&#60;br /&#62;
y_min = round(Ny_tot/4);    % Starting point&#60;br /&#62;
y_center = round(Ny_tot/2); % Middle point&#60;br /&#62;
y_max = round(Ny_tot/2);% End point&#60;/p&#62;
&#60;p&#62;% The position of the highly scattering object on the z-axis&#60;br /&#62;
z_min = round(Nz_tot/8);    % Starting point&#60;br /&#62;
z_center = round(Nz_tot/4); % Middle point&#60;br /&#62;
z_max = round(Nz_tot/4);% End point&#60;/p&#62;
&#60;p&#62;for k = z_max:Nz_tot&#60;/p&#62;
&#60;p&#62; for i = x_center:x_max&#60;br /&#62;
    for j = y_center:y_max&#60;br /&#62;
            scattering_map_bin(i,j,k) = 1;&#60;br /&#62;
    end&#60;br /&#62;
 end &#60;/p&#62;
&#60;p&#62; for i = x_min:x_center&#60;br /&#62;
    for j = y_min:y_center&#60;br /&#62;
            scattering_map_bin(i,j,k) = 1;&#60;br /&#62;
    end&#60;br /&#62;
 end &#60;/p&#62;
&#60;p&#62; for i = x_center:x_max&#60;br /&#62;
    for j = y_min:y_center&#60;br /&#62;
            scattering_map_bin(i,j,k) = 1;&#60;br /&#62;
    end&#60;br /&#62;
 end &#60;/p&#62;
&#60;p&#62; for i = x_min:x_center&#60;br /&#62;
    for j = y_center:y_max&#60;br /&#62;
            scattering_map_bin(i,j,k) = 1;&#60;br /&#62;
    end&#60;br /&#62;
 end &#60;/p&#62;
&#60;p&#62;end&#60;/p&#62;
&#60;p&#62;transducer_bin = zeros(Nx_tot, Ny_tot, Nz_tot);&#60;br /&#62;
  for i = transducer.position(1);&#60;br /&#62;
    for j = transducer.position(2):transducer.position(2)+transducer_width&#60;br /&#62;
        for k = transducer.position(3):transducer.position(3)+ transducer.element_length&#60;br /&#62;
        transducer_bin(i,j,k) = 1;&#60;br /&#62;
        end&#60;br /&#62;
    end&#60;br /&#62;
  end&#60;/p&#62;
&#60;p&#62;% Define the properties of the highly scatterer object (Water)&#60;br /&#62;
scattering_c0 = 1450 *scattering_map_bin;            % Speed of sound in medium [m/s]&#60;br /&#62;
scattering_rho0 = 993 *scattering_map_bin;    % Denisty of medium [kg/m^3]&#60;br /&#62;
scattering_alpha_coeff = 1 *scattering_map_bin;  % Attenuation coefficent of medium [dB/(MHz^y cm)]&#60;/p&#62;
&#60;p&#62;% Define properties&#60;br /&#62;
sound_speed_map = c0 *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;br /&#62;
attenuation_map= medium.alpha_coeff *ones(Nx_tot, Ny_tot, Nz_tot).*background_map;&#60;/p&#62;
&#60;p&#62;% Assign region&#60;br /&#62;
sound_speed_map(scattering_map_bin == 1) = scattering_c0(scattering_map_bin == 1);&#60;br /&#62;
density_map(scattering_map_bin == 1) = scattering_rho0(scattering_map_bin == 1);&#60;br /&#62;
attenuation_map(scattering_map_bin == 1) = scattering_alpha_coeff(scattering_map_bin == 1);&#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;% 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;    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)]);&#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;br /&#62;
        medium.attenuation = attenuation_map(:, medium_position:medium_position + Ny - 1, :);&#60;/p&#62;
&#60;p&#62;        % run the simulation&#60;br /&#62;
        sensor_data = kspaceFirstOrder3D(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(scan_line_index, :) = transducer.scan_line(sensor_data);&#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 example_us_bmode_scan_lines scan_lines;&#60;br /&#62;
else&#60;br /&#62;
    % load the scan lines from disk&#60;br /&#62;
    load example_us_bmode_scan_lines&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++&#60;br /&#62;
% PROCESS THE RESULTS&#60;br /&#62;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++&#60;/p&#62;
&#60;p&#62;% 1) Remove Input Signal&#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(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 = bsxfun(@times, scan_line_win, scan_lines);&#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;
scan_line_example(1, :) = scan_lines(end/2, :);&#60;/p&#62;
&#60;p&#62;% 2) Time Gain Compensation&#60;/p&#62;
&#60;p&#62;% create radius variable assuming that t0 corresponds to the middle of the input signal&#60;br /&#62;
t0 = length(input_signal)*kgrid.dt/2;&#60;br /&#62;
r = c0*( (1:length(kgrid.t_array))*kgrid.dt/2 - t0);    % [m]&#60;/p&#62;
&#60;p&#62;%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++&#60;br /&#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.4;       % [dB/(MHz cm)]&#60;br /&#62;
tgc = exp(2*tgc_alpha*tone_burst_freq/1e6*r*100);&#60;br /&#62;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++&#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;% store a copy of the middle scan line to illustrate the effects of each&#60;br /&#62;
% processing step&#60;br /&#62;
scan_line_example(2, :) = scan_lines(end/2, :);&#60;/p&#62;
&#60;p&#62;% 3) Frequency Filtering&#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;% store a copy of the middle scan line to illustrate the effects of each&#60;br /&#62;
% processing step&#60;br /&#62;
scan_line_example(3, :) = scan_lines_fund(end/2, :);&#60;/p&#62;
&#60;p&#62;% 4) Envelope Detection&#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;% store a copy of the middle scan line to illustrate the effects of each&#60;br /&#62;
% processing step&#60;br /&#62;
scan_line_example(4, :) = scan_lines_fund(end/2, :);&#60;/p&#62;
&#60;p&#62;% 5) Log Compression&#60;/p&#62;
&#60;p&#62;% normalised log compression&#60;br /&#62;
compression_ratio = 3;&#60;br /&#62;
scan_lines_fund = logCompression(scan_lines_fund, compression_ratio, true);&#60;br /&#62;
scan_lines_harm = logCompression(scan_lines_harm, 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;
scan_line_example(5, :) = scan_lines_fund(end/2, :);&#60;/p&#62;
&#60;p&#62;% 6) Scan Conversion&#60;/p&#62;
&#60;p&#62;% upsample the image using linear interpolation&#60;br /&#62;
scale_factor = 2;&#60;br /&#62;
scan_lines_fund = interp2(1:kgrid.Nt, (1:number_scan_lines).', scan_lines_fund, 1:kgrid.Nt, (1:1/scale_factor:number_scan_lines).');&#60;br /&#62;
scan_lines_harm = interp2(1:kgrid.Nt, (1:number_scan_lines).', scan_lines_harm, 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;% 1) Plotting the transducer:&#60;br /&#62;
transducer.plot&#60;br /&#62;
title('Schematic Of The Transducer');&#60;br /&#62;
xlabel('x-dimension (voxel)');&#60;br /&#62;
ylabel('y-dimension (voxel)');&#60;br /&#62;
zlabel('z-dimension (voxel)');&#60;/p&#62;
&#60;p&#62;% Plotting the input signal&#60;br /&#62;
figure;&#60;br /&#62;
plot (input_signal)&#60;br /&#62;
title('Input Signal (MHz)');&#60;br /&#62;
xlabel('Time');&#60;br /&#62;
ylabel('Amplitude');&#60;/p&#62;
&#60;p&#62;% Plottung the highly scattering object&#60;br /&#62;
voxelPlot(single(scattering_map_bin))&#60;br /&#62;
title('Schematic Of The Highly Scattering Object');&#60;br /&#62;
xlabel('x-dimension (voxel)');&#60;br /&#62;
ylabel('y-dimension (voxel)');&#60;br /&#62;
zlabel('z-dimension (voxel)');&#60;/p&#62;
&#60;p&#62;% Plotting transducer and scattering object&#60;br /&#62;
voxelPlot(single(scattering_map_bin &#124; transducer_bin));&#60;br /&#62;
title('Schematic Of The Highly Scattering Object And The Transducer');&#60;br /&#62;
xlabel('x-dimension (voxel)');&#60;br /&#62;
ylabel('y-dimension (voxel)');&#60;br /&#62;
zlabel('z-dimension (voxel)');&#60;br /&#62;
colormap(gray);&#60;/p&#62;
&#60;p&#62;% Extracting a single scan line from the sensor data using the current beamforming settings&#60;br /&#62;
scan_line = transducer.scan_line(sensor_data);&#60;br /&#62;
figure;&#60;br /&#62;
plot (scan_line)&#60;br /&#62;
title('Received Signal');&#60;br /&#62;
xlabel('Time');&#60;br /&#62;
ylabel('Amplitude');&#60;/p&#62;
&#60;p&#62;% Plotting the sound speed map&#60;br /&#62;
figure;&#60;br /&#62;
imagesc((0:number_scan_lines*transducer.element_width-1)*dy*1e3, (0:Nx_tot-1)*dx*1e3, sound_speed_map(:, 1 + Ny/2:end - Ny/2, Nz/2));&#60;br /&#62;
axis image;&#60;br /&#62;
colormap(gray);&#60;br /&#62;
set(gca, 'YLim', [0, 8]);&#60;br /&#62;
title('The Sound Speed Map');&#60;br /&#62;
xlabel('Horizontal Position [mm]');&#60;br /&#62;
ylabel('Depth [mm]');&#60;br /&#62;
colorbar;&#60;/p&#62;
&#60;p&#62;% Plotting the density map&#60;br /&#62;
figure;&#60;br /&#62;
imagesc((0:number_scan_lines*transducer.element_width-1)*dy*1e3, (0:Nx_tot-1)*dx*1e3, density_map(:, 1 + Ny/2:end - Ny/2, Nz/2));&#60;br /&#62;
axis image;&#60;br /&#62;
colormap(gray);&#60;br /&#62;
set(gca, 'YLim', [0, 8]);&#60;br /&#62;
title('The Density Map');&#60;br /&#62;
xlabel('Horizontal Position [mm]');&#60;br /&#62;
ylabel('Depth [mm]');&#60;br /&#62;
colorbar;&#60;/p&#62;
&#60;p&#62;% Plotting the attenuation map&#60;br /&#62;
figure;&#60;br /&#62;
imagesc((0:number_scan_lines*transducer.element_width-1)*dy*1e3, (0:Nx_tot-1)*dx*1e3, attenuation_map(:, 1 + Ny/2:end - Ny/2, Nz/2));&#60;br /&#62;
axis image;&#60;br /&#62;
colormap(gray);&#60;br /&#62;
set(gca, 'YLim', [0, 8]);&#60;br /&#62;
title('The Attenuation Map');&#60;br /&#62;
xlabel('Horizontal Position [mm]');&#60;br /&#62;
ylabel('Depth [mm]');&#60;br /&#62;
colorbar;&#60;/p&#62;
&#60;p&#62;% Plotting the processed b-mode ultrasound image&#60;br /&#62;
figure;&#60;br /&#62;
horz_axis = (0:length(scan_lines_fund(:, 1))-1)*transducer.element_width*dy/scale_factor*1e3;&#60;br /&#62;
imagesc(horz_axis, r*1e3, scan_lines_fund.');&#60;br /&#62;
axis image;&#60;br /&#62;
colormap(gray);&#60;br /&#62;
set(gca, 'YLim', [0, 8]);&#60;br /&#62;
title('The B-mode Image');&#60;br /&#62;
xlabel('Horizontal Position [mm]');&#60;br /&#62;
ylabel('Depth [mm]');&#60;br /&#62;
colorbar;&#60;/p&#62;
&#60;p&#62;% plot the processed harmonic ultrasound image&#60;br /&#62;
figure;&#60;br /&#62;
imagesc(horz_axis, r*1e3, scan_lines_harm.');&#60;br /&#62;
axis image;&#60;br /&#62;
colormap(gray);&#60;br /&#62;
set(gca, 'YLim', [0, 8]);&#60;br /&#62;
title('The Harmonic Image');&#60;br /&#62;
xlabel('Horizontal Position [mm]');&#60;br /&#62;
ylabel('Depth [mm]');&#60;br /&#62;
colorbar;
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
