<?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; User Favorites: DLam</title>
		<link><a href='http://www.k-wave.org/forum/profile/dlam'>dlam</a></link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Tue, 12 May 2026 22:59:45 +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/profile/" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "Strange increase in starting magnitude when validating attenuation"</title>
			<link>http://www.k-wave.org/forum/topic/strange-increase-in-starting-magnitude-when-validating-attenuation#post-5805</link>
			<pubDate>Wed, 04 Jan 2017 14:39:02 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">5805@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi DLam,&#60;/p&#62;
&#60;p&#62;Yes, that's correct regarding &#60;code&#62;source.p&#60;/code&#62;. If you spectrally decompose your signal, do you get the attenuation you expect? &#60;/p&#62;
&#60;p&#62;It's possible that using the peak magnitude is not a good measure of attenuation when the medium is dispersive, as the wave will change shape. One way to test this would be to set &#60;code&#62;medium.alpha_mode = no_absorption&#60;/code&#62; and just examine the effects of dispersion.&#60;/p&#62;
&#60;p&#62;For an inhomogeneous medium, you should scale the source based on the local value of the sound speed.&#60;/p&#62;
&#60;p&#62;Brad
&#60;/p&#62;</description>
		</item>
		<item>
			<title>DLam on "Strange increase in starting magnitude when validating attenuation"</title>
			<link>http://www.k-wave.org/forum/topic/strange-increase-in-starting-magnitude-when-validating-attenuation#post-5790</link>
			<pubDate>Thu, 15 Dec 2016 16:16:55 +0000</pubDate>
			<dc:creator>DLam</dc:creator>
			<guid isPermaLink="false">5790@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Brad,&#60;/p&#62;
&#60;p&#62;Thanks!&#60;/p&#62;
&#60;p&#62;Sorry for the late reply.  Just to clarify, do you mean multiplying source.p by the scaling_factor?  I have tried this (0.1 mm grid resolution, f = 1MHz) , and it fixes the simulated source magnitude at the source; but as the wave propagates, the simulated peak magnitude again becomes larger than the theoretical power law.&#60;/p&#62;
&#60;p&#62;I have removed the BonA parameter, so I am testing this on linear propagation equation.&#60;/p&#62;
&#60;p&#62;Is this unavoidable?&#60;/p&#62;
&#60;p&#62;Furthermore, for an inhomogenous medium the medium.sound_speed will vary, thus varying the sound_speed_dispersion with spatial position.  Is it possible for the code to account for this as well?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Strange increase in starting magnitude when validating attenuation"</title>
			<link>http://www.k-wave.org/forum/topic/strange-increase-in-starting-magnitude-when-validating-attenuation#post-5766</link>
			<pubDate>Fri, 25 Nov 2016 13:43:42 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">5766@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi DLam,&#60;/p&#62;
&#60;p&#62;Thanks for the interesting post. After some digging, the reason is due to the dependence of the source scaling factors on sound speed (see Eqs. 2.18 and 2.19 in the k-Wave manual). In an absorbing medium, the sound speed depends on frequency (this is required for causality), and so the source scaling should use the dispersive sound speed. However, k-Wave currently uses the value of &#60;code&#62;medium.sound_speed&#60;/code&#62; as shown in the manual. This means the amplitude of the source depends on the absorption values, as you have observed.&#60;/p&#62;
&#60;p&#62;If you only have a single frequency and the source points all have the same background value, you can correct for this by introducing an additional scaling factor, and multiplying your source by this:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;sound_speed_dispersive = powerLawKramersKronig(2*pi*source_freq, 0, medium.sound_speed, db2neper(medium.alpha_coeff, medium.alpha_power), medium.alpha_power);
scaling_factor = medium.sound_speed ./ sound_speed_dispersive;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;where it's assumed that &#60;code&#62;medium.sound_speed&#60;/code&#62; is a scalar. Alternatively, if sound speed dispersion is not important, you can switch this off by setting:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;medium.alpha_mode = &#38;#39;no_dispersion&#38;#39;&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;Note, a few points about your simulation. The comparison that you're doing is only valid in 1D, i.e., for a plane wave. You can fix this either by moving your simulation to 1D, or by making your source the whole width of the domain with the PML inside, and turning off the PML in the lateral direction by setting:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#38;#39;PMLAlpha&#38;#39;, [2, 0]&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>DLam on "Strange increase in starting magnitude when validating attenuation"</title>
			<link>http://www.k-wave.org/forum/topic/strange-increase-in-starting-magnitude-when-validating-attenuation#post-5744</link>
			<pubDate>Wed, 16 Nov 2016 13:09:18 +0000</pubDate>
			<dc:creator>DLam</dc:creator>
			<guid isPermaLink="false">5744@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Sorry, I think I have solved my own problem after perusing the 2010 paper on modelling absorption.  It is because my alpha_power is too close to 1.&#60;/p&#62;
&#60;p&#62;Is there a way around this?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>DLam on "Strange increase in starting magnitude when validating attenuation"</title>
			<link>http://www.k-wave.org/forum/topic/strange-increase-in-starting-magnitude-when-validating-attenuation#post-5742</link>
			<pubDate>Tue, 15 Nov 2016 19:40:49 +0000</pubDate>
			<dc:creator>DLam</dc:creator>
			<guid isPermaLink="false">5742@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;I am wondering if anyone can give me some help on an odd issue I've been having?&#60;br /&#62;
I was modelling the ultrasound wave propagating through a homogeneous, linear, attenuating medium in 2D.  When I plotted the results, I spotted that the peak of the maximum pressure of the source wave is higher than the source magnitude that I have set by about 10-40%, from attenuation_coeff of 8 to 16 respectively.  I am sure that there is no aliasing going on (dx = dy = 0.25e-3, frequency = 0.25 MHz).&#60;/p&#62;
&#60;p&#62;This is using a continuously-powered sinusoidal line source that I am sure is placed outside of the Perfectly-Matched-Layer.  I also moved the line source to the centre of my simulation block, to check that the effect is not caused by minor reflections off the discrete matching layer elements, but this effect is still there.&#60;/p&#62;
&#60;p&#62;I am wondering if this is an artefact related to the implementation of the fractional Laplacian, or whether I have forgotten something else? &#60;/p&#62;
&#60;p&#62;Any help is appreciated.&#60;/p&#62;
&#60;p&#62;This is my code:&#60;/p&#62;
&#60;p&#62;% k-wave simulation&#60;br /&#62;
% B. E. Treeby and B. T. Cox, &#34;k-Wave: MATLAB toolbox for the simulation and reconstruction of photoacoustic wave-fields,&#34; J. Biomed. Opt., vol. 15, no. 2, p. 021314, 2010.&#60;br /&#62;
% B. E. Treeby, J. Jaros, A. P. Rendell, and B. T. Cox, &#34;Modeling nonlinear ultrasound propagation in heterogeneous media with power law absorption using a k-space pseudospectral method,&#34; J. Acoust. Soc. Am., vol. 131, no. 6, pp. 4324-4336, 2012.&#60;br /&#62;
% addpath('C:\Users\DLam\Desktop\k-Wave') % in case of non-admin access&#60;br /&#62;
clear all; close all;&#60;br /&#62;
filename = 'test_homogenous_medium.mat'; % filename to save to.  If don't want to save, use [].&#60;/p&#62;
&#60;p&#62;mode = 'flat' %'flat'&#60;br /&#62;
sensor.record = {'p_final', 'p_max', 'p_rms', 'I_avg'}; % this is what to record. If out of memory, delete 'p', 'I', 'I_avg'&#60;br /&#62;
% create the computational grid&#60;br /&#62;
Nx = 256;           % number of grid points in the x (down-row) direction&#60;br /&#62;
Ny = 256;           % number of grid points in the y (towards right column) direction&#60;br /&#62;
dx = 0.25*1e-3;        % grid point spacing in the x direction  [m]&#60;br /&#62;
dy = 0.25*1e-3;        % grid point spacing in the y direction  [m]&#60;br /&#62;
t_end = 60e-6; % end time of sim&#60;br /&#62;
offset = 22; % [grid points] distance between transducer source and top edge of simulation block&#60;br /&#62;
%boundary_gp = Nx/2; % [grid points] for flat Tx only.  This is the row of the interface.&#60;/p&#62;
&#60;p&#62;si = [Nx, Ny];&#60;br /&#62;
kgrid = makeGrid(Nx, dx, Ny, dy);&#60;br /&#62;
% CARE: makeGrid implements a 20 grid-point (10 in 3D) thick &#34;border&#34; around the&#60;br /&#62;
% simulation block that helps with absorbing the incoming wave&#60;/p&#62;
&#60;p&#62;% Source settings: create pressure distribution&#60;br /&#62;
source_magnitude = 1e06; % [Pa]&#60;br /&#62;
source_freq = 0.25e06; % [Hz]&#60;/p&#62;
&#60;p&#62;    %Flat Tx&#60;br /&#62;
    if strcmp(mode,'flat') == 1&#60;br /&#62;
        starting_gp = 22;&#60;br /&#62;
        source.p_mask = zeros(si);&#60;br /&#62;
        source.p_mask(starting_gp,22:end-22) = 1;&#60;br /&#62;
        source.p_mask = logical(source.p_mask);&#60;br /&#62;
    end&#60;/p&#62;
&#60;p&#62;% MEDIUM: define the properties of the propagation medium&#60;/p&#62;
&#60;p&#62;medium.alpha_power = 1.1; % for absorption (exponent). Can only be scalar for k-wave. For tissue. Source: F.A. Duck 1990, &#34;Physical Properties of Tissue&#34;.&#60;/p&#62;
&#60;p&#62;% Soft Tissue&#60;br /&#62;
medium.sound_speed = 1540*ones(Nx,Ny); % [m/s] tissue&#60;br /&#62;
medium.density = 1050*ones(Nx,Ny);     % [kg/m^3] % tissue&#60;br /&#62;
medium.alpha_coeff = 8*ones(Nx,Ny);% [dB / (cm.MHz)] fictional number&#60;/p&#62;
&#60;p&#62;% create time array.  This is needed for a continuously-powered transducer.&#60;br /&#62;
[kgrid.t_array] = makeTime(kgrid, medium.sound_speed, 0.3, t_end); % default CFL criterion is 0.3&#60;/p&#62;
&#60;p&#62;source.p = source_magnitude.*sin(2*pi*source_freq*kgrid.t_array);&#60;br /&#62;
%According to k-wave documentation, this applies &#34;a finite impulse response&#60;br /&#62;
%(FIR) filter designed using the Kaiser windowing method&#34; to filter away&#60;br /&#62;
%high harmonics.  BUT this also changes the source magnitude.&#60;br /&#62;
%source.p = filterTimeSeries(kgrid, medium, source.p);&#60;/p&#62;
&#60;p&#62;% SIMULATION&#60;br /&#62;
% define the rectangular sensor region by specifying the location of&#60;br /&#62;
% opposing corners.  Leave this the way it is now to get all information&#60;br /&#62;
% from the sim block.&#60;br /&#62;
rect1_x_start = 1; rect1_y_start = 1; rect1_x_end   = Nx; rect1_y_end   = Ny;&#60;br /&#62;
sensor.mask = [rect1_x_start; rect1_y_start; rect1_x_end;  rect1_y_end];&#60;br /&#62;
% create a display mask to display the transducer&#60;br /&#62;
display_mask = source.p_mask;&#60;/p&#62;
&#60;p&#62;% assign the input options&#60;br /&#62;
input_args = {'DisplayMask', display_mask, 'PMLInside', false, 'PlotPML', false};&#60;/p&#62;
&#60;p&#62;% run the simulation&#60;br /&#62;
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});&#60;/p&#62;
&#60;p&#62;intensity_grid = sqrt((sensor_data.Ix_avg.^2+sensor_data.Iy_avg.^2));&#60;/p&#62;
&#60;p&#62;% test_plot_attenuation&#60;/p&#62;
&#60;p&#62;input = sensor_data.p_final;&#60;br /&#62;
MaxP = max(max(input))&#60;/p&#62;
&#60;p&#62;sensor_data_mean = mean(input(:,round(Ny/3):round(2*Ny/3),end),2); % reduce effect of reflections from PML at side.&#60;/p&#62;
&#60;p&#62;y_raw = sensor_data_mean;&#60;/p&#62;
&#60;p&#62;x = [1:1:Nx].*dx*100; %[cm]&#60;br /&#62;
alpha_dB = (medium.alpha_coeff(Nx/2,Ny/2)).*((source_freq/1e6).^medium.alpha_power); % [dB/(cm. MHz^power)]&#60;br /&#62;
alpha_neper = alpha_dB/(8.685889638); % [Np / (cm.MHz^power)]&#60;/p&#62;
&#60;p&#62;%Theory&#60;br /&#62;
y = source_magnitude*exp(-alpha_neper*(x-(starting_gp*dx*100)));&#60;/p&#62;
&#60;p&#62;h1 = plot(x,y_raw);&#60;/p&#62;
&#60;p&#62;y1 = get(gca,'ylim');&#60;br /&#62;
xl = get(gca,'xlim');&#60;br /&#62;
hold on&#60;br /&#62;
h2 = line([starting_gp*dx*100 starting_gp*dx*100],y1,'Color','r'); % boundary&#60;br /&#62;
h4 = line(xl, [source_magnitude source_magnitude], 'Color','m'); % source magnitude line&#60;br /&#62;
h3 = plot(x,y,'g');&#60;/p&#62;
&#60;p&#62;legend([h1 h2 h3 h4],'Final Pressure as a function of distance', 'Transducer Face Position', 'Theoretical Attenuation','Source Magnitude');&#60;br /&#62;
ylabel('Pressure (Pa)')&#60;br /&#62;
xlabel('Distance (cm)')&#60;br /&#62;
title('Attenuation of pressure with distance using linear k-wave first order')&#60;br /&#62;
hold off
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
