<?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: Timing error in the generated RF data</title>
		<link>http://www.k-wave.org/forum/topic/timing-error-in-the-generated-rf-data</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 08:18:31 +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/timing-error-in-the-generated-rf-data" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "Timing error in the generated RF data"</title>
			<link>http://www.k-wave.org/forum/topic/timing-error-in-the-generated-rf-data#post-7558</link>
			<pubDate>Sat, 06 Jun 2020 14:36:47 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">7558@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Wonseok,&#60;/p&#62;
&#60;p&#62;Could you try setting &#60;code&#62;medium.alpha_mode = &#38;#39;no_dispersion&#38;#39;&#60;/code&#62;?&#60;/p&#62;
&#60;p&#62;When you have power law acoustic absorption, causality dictates that you must also have dispersion (a dependence of the sound speed on frequency). As your power law is very close to 1, I suspect that this is giving you a noticeably different sound speed in the medium. &#60;/p&#62;
&#60;p&#62;Have a look at the &#60;a href=&#34;http://www.k-wave.org/documentation/example_na_modelling_absorption.php&#34;&#62;Modelling Power Law Absorption Example&#60;/a&#62; in MATLAB. You can see for the same background sound speed, the actual wave speed can vary quite a lot (in accordance with the theory) depending on the absorption parameters.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Wonseok Choi on "Timing error in the generated RF data"</title>
			<link>http://www.k-wave.org/forum/topic/timing-error-in-the-generated-rf-data#post-7522</link>
			<pubDate>Fri, 22 May 2020 03:29:36 +0000</pubDate>
			<dc:creator>Wonseok Choi</dc:creator>
			<guid isPermaLink="false">7522@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Thank you for you reply.&#60;br /&#62;
I have posted the working code.&#60;/p&#62;
&#60;p&#62;I tried removing the sensor.frequency_response line, but it didn't work either. &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;clearvars;

%% =========================================================================
% SIMULATION
% =========================================================================
% Environment setting

PML_size = 40;          % size of the PML in grid points --&#38;gt; PML = perfectly matched layer. assumed to simulate open boundaries
Nz = 1600;               % number of grid points in the x (row) direction
Nx = 1600;               % number of grid points in the y (column) direction

dz = 1e-4;            % grid point spacing in the z direction [m]
dx = 1e-4;            % grid point spacing in the x direction [m]

Xsize =  Nx * dx; Zsize = Nz*dz;

% define a binary line sensor
sensor.mask = zeros(Nz, Nx);
posXgrid = 613:3:994;
posZgrid = 56;
for idxEle = 1:length(posXgrid)
    sensor.mask(posZgrid, posXgrid(idxEle)) = 1;
end

% Temporal arguments
SoundSpeed = 1510;
SampleFreq = 50e6;
dt = 1/SampleFreq;
Nt = ceil(1.1 * sqrt(Xsize^2+Zsize^2)/SoundSpeed/dt)/2;

% Transducer arguments
transducer.pitch = 0.298e-3;   % [m]
transducer.numElement = 128;   % [m]
transducer.centerFreq = 5e6; % [1/sec]
transducer.BW = 60; % [%]
sensor.frequency_response = [transducer.centerFreq, transducer.BW];

% create the computational grid
kgrid = kWaveGrid(Nz, dz, Nx, dx);
kgrid.setTime(Nt, dt);

% Medium Parameters
medium.alpha_coeff = 0.75;  % [dB/(MHz^y cm)]
medium.alpha_power = 1.01;
medium.sound_speed = SoundSpeed;           % [m/s]

% create initial pressure distribution using makeDisc
NumSource_x = 3;
NumSource_z = 3;
Disc.magnitude = 1; % [Pa]
Disc.radius = 2;    % scaled by grid point spacing.

numTarget = 9;
if numTarget == 9
    % 9 target
    disc = 0;
    for idx_x = 1:NumSource_x
        for idx_z = 1:NumSource_z
            Disc.z_pos = 384*(idx_z-2)/(NumSource_z+1)+Nz/2;    % [grid points]
            Disc.x_pos = 384*(idx_x-2)/(NumSource_x+1)+Nx/2;  	% [grid points]
            temp = Disc.magnitude * makeDisc(Nz, Nx, Disc.z_pos, Disc.x_pos, Disc.radius);
            disc = disc + temp;
        end
    end
elseif numTarget == 3
    % 3 target diagonal
    disc = 0;
    for idx_x = 1:NumSource_x
            Disc.z_pos = 384*(idx_x-2)/(NumSource_z+1)+Nz/2;    % [grid points]
            Disc.x_pos = 384*(idx_x-2)/(NumSource_x+1)+Nx/2;  	% [grid points]
            temp = Disc.magnitude * makeDisc(Nz, Nx, Disc.z_pos, Disc.x_pos, Disc.radius);
            disc = disc + temp;
    end
end
figure; imagesc(disc + sensor.mask); axis image;

% smooth the initial pressure distribution and restore the magnitude
source.p0 = smooth(kgrid, disc, true);

% set the input arguements: force the PML to be outside the computational
% grid; switch off p0 smoothing within kspaceFirstOrder2D
input_args = {&#38;#39;PMLInside&#38;#39;, false, &#38;#39;PMLSize&#38;#39;, PML_size, &#38;#39;PlotPML&#38;#39;, false, &#38;#39;Smooth&#38;#39;, false,  &#38;#39;DataCast&#38;#39;, &#38;#39;gpuArray-single&#38;#39;};

%% RF generation
% run the simulation
sensor_data_raw = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});

%% Time reversal
source2 = source;
source2.p0=0;
sensor2 = sensor;
sensor2.time_reversal_boundary_data = sensor_data_raw;
kgrid2 = kgrid;
medium2 = medium;
medium2.alpha_coeff = 0;

p0_tr = kspaceFirstOrder2D(kgrid2, medium2, source2, sensor2, input_args{:});
figure; imagesc(p0_tr);&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Timing error in the generated RF data"</title>
			<link>http://www.k-wave.org/forum/topic/timing-error-in-the-generated-rf-data#post-7512</link>
			<pubDate>Thu, 21 May 2020 11:09:31 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">7512@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Wonseok,&#60;/p&#62;
&#60;p&#62;Can you post a working code? I'll take a look. Does it work if you remove the &#60;code&#62;sensor.frequency_response = ...&#60;/code&#62; line?&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Wonseok Choi on "Timing error in the generated RF data"</title>
			<link>http://www.k-wave.org/forum/topic/timing-error-in-the-generated-rf-data#post-7506</link>
			<pubDate>Tue, 19 May 2020 06:56:58 +0000</pubDate>
			<dc:creator>Wonseok Choi</dc:creator>
			<guid isPermaLink="false">7506@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Dear developers,&#60;br /&#62;
Thank you so much for providing this wonderful simulator!&#60;/p&#62;
&#60;p&#62;We are trying to generate RF data for photoacoustic computed tomography that uses multiple linear arrays circularly positioned around the target.&#60;br /&#62;
We tried the code below and performed time reversal for image reconstruction.&#60;br /&#62;
However, we got a wrong reconstruction that looks like the time reversing was done a little bit more.&#60;br /&#62;
(i.e. circular targets appearing as donut shapes)&#60;br /&#62;
We then tried to reconstruct the image using self-developed delay-and-sum algorithm, and we still got a similar result with time reversal.&#60;/p&#62;
&#60;p&#62;We found an unexpected error in the RF data: the wavefronts appearing at earlier timings than expected.&#60;br /&#62;
Using point source targets, we calculated the expected timing of the wavefront, and we found that the wavefronts in the RF data appeared at about 88% of the calculated delay.&#60;br /&#62;
When we manually multiplied 0.88 at the calculated delays for delay-and-sum, the image was well reconstructed.&#60;br /&#62;
We think time reversal operation was working all right, but the forward process was somehow not right. &#60;/p&#62;
&#60;p&#62;We have provided the code as the following lines.&#60;br /&#62;
Sorry that we couldn't include the element positions here for you to test the code.&#60;br /&#62;
If you need to execute the code, you can simply put a single 128-element linear array on the top of the grid.&#60;br /&#62;
(We also tried that but it also gave the same error.) &#60;/p&#62;
&#60;p&#62;Thank you in advance for kindly taking your time on this issue.&#60;br /&#62;
Wonseok Choi.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;% Environment setting
PML_size = 40;          % size of the PML in grid points --&#38;gt; PML = perfectly matched layer. assumed to simulate open boundaries
Nz = 1600;               % number of grid points in the x (row) direction
Nx = 1600;               % number of grid points in the y (column) direction

dz = 1e-4;            % grid point spacing in the z direction [m]
dx = 1e-4;            % grid point spacing in the x direction [m]

Xsize =  Nx * dx; Zsize = Nz*dz;

% Detector position
load(&#38;#39;ElementPosition.mat&#38;#39;)
% define a binary line sensor
sensor.mask = zeros(Nz, Nx);
posX = pos_ele(:,1);
posXgrid = round((posX-(max(posX)+min(posX))/2)/abs(dx)) + Nx/2;
posZ = pos_ele(:,2);
posZgrid = round((posZ-(max(posZ)+min(posZ))/2)/abs(dz)) + Nz/2;
for idxEle = 1:length(posX)/8
    sensor.mask(posZgrid(idxEle), posXgrid(idxEle)) = 1;
end

% Temporal arguments
SoundSpeed = 1510;
SampleFreq = 50e6;
dt = 1/SampleFreq;
Nt = ceil(1.1 * sqrt(Xsize^2+Zsize^2)/SoundSpeed/dt)/2;

% Transducer arguments
transducer.pitch = 0.298e-3;   % [m]
transducer.numElement = 128;   % [m]
transducer.centerFreq = 5e6; % [Hz]
transducer.BW = 60; % [%]
sensor.frequency_response = [transducer.centerFreq, transducer.BW];

% create the computational grid
kgrid = kWaveGrid(Nz, dz, Nx, dx);
kgrid.setTime(Nt, dt);

% Medium Parameters
    medium.alpha_coeff = 0.75;  % [dB/(MHz^y cm)]
    medium.alpha_power = 1.01;
medium.sound_speed = SoundSpeed;           % [m/s]

% create initial pressure distribution using makeDisc
NumSource_x = 3;
NumSource_z = 3;
Disc.magnitude = 1; % [Pa]
Disc.radius = 2;    % scaled by grid point spacing.

numTarget = 9;
    disc = 0;
    for idx_x = 1:NumSource_x
        for idx_z = 1:NumSource_z
            Disc.z_pos = 384*(idx_z-2)/(NumSource_z+1)+Nz/2;    % [grid points]
            Disc.x_pos = 384*(idx_x-2)/(NumSource_x+1)+Nx/2;  	% [grid points]
            temp = Disc.magnitude * makeDisc(Nz, Nx, Disc.z_pos, Disc.x_pos, Disc.radius);
            disc = disc + temp;
        end
    end

% smooth the initial pressure distribution and restore the magnitude
source.p0 = smooth(kgrid, disc, true);

input_args = {&#38;#39;PMLInside&#38;#39;, false, &#38;#39;PMLSize&#38;#39;, PML_size, &#38;#39;PlotPML&#38;#39;, false, &#38;#39;Smooth&#38;#39;, false};  

sensor_data_raw = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});

% assign the time reversal data
source2 = source;
source2.p0=0;
sensor2 = sensor;
sensor2.time_reversal_boundary_data = sensor_data_raw;
kgrid2 = kgrid;
medium2 = medium;
medium2.alpha_coeff = 0;

p0_tr = kspaceFirstOrder2D(kgrid2, medium2, source2, sensor2, input_args{:});&#60;/code&#62;&#60;/pre&#62;</description>
		</item>

	</channel>
</rss>
