<?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: use addnoise function does not work in simulation process</title>
		<link>http://www.k-wave.org/forum/topic/use-addnoise-function-does-not-work-in-simulation-process</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 01:49:33 +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/use-addnoise-function-does-not-work-in-simulation-process" rel="self" type="application/rss+xml" />

		<item>
			<title>zhangguangjie on "use addnoise function does not work in simulation process"</title>
			<link>http://www.k-wave.org/forum/topic/use-addnoise-function-does-not-work-in-simulation-process#post-6640</link>
			<pubDate>Thu, 08 Nov 2018 05:56:54 +0000</pubDate>
			<dc:creator>zhangguangjie</dc:creator>
			<guid isPermaLink="false">6640@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello Brad:&#60;br /&#62;
 Thank you very much!&#60;br /&#62;
 Now,I meet a new problem. setting signal_to_noise_ratio = 1, which means SNR=1.12. However,the reconstruction result CNR is lager, which means the noise does not exert a important effect to the reconstruction  imaging. why ? I am confused.&#60;br /&#62;
 Thanks in advance.&#60;br /&#62;
 Look forward to your reply.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "use addnoise function does not work in simulation process"</title>
			<link>http://www.k-wave.org/forum/topic/use-addnoise-function-does-not-work-in-simulation-process#post-6634</link>
			<pubDate>Tue, 06 Nov 2018 21:46:17 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">6634@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;It looks like you store the sensor data with noise as &#60;code&#62;sensor_data1&#60;/code&#62;, but assign the noise-free data to &#60;code&#62;sensor.time_reversal_boundary_data&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>zhangguangjie on "use addnoise function does not work in simulation process"</title>
			<link>http://www.k-wave.org/forum/topic/use-addnoise-function-does-not-work-in-simulation-process#post-6633</link>
			<pubDate>Tue, 06 Nov 2018 10:44:13 +0000</pubDate>
			<dc:creator>zhangguangjie</dc:creator>
			<guid isPermaLink="false">6633@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello everyone:&#60;br /&#62;
   I add addnoise function in 3D Time Reversal Reconstruction For A Planar Sensor Example. However, I find it is not impact the reconstruction result whether or not add noise. My code is as follows. I eager to get help from you.&#60;br /&#62;
% 3D Time Reversal Reconstruction For A Planar Sensor Example&#60;br /&#62;
%&#60;br /&#62;
% This example demonstrates the use of k-Wave for the reconstruction of a&#60;br /&#62;
% three-dimensional photoacoustic wave-field recorded  over a planar array&#60;br /&#62;
% of sensor elements.  The sensor data is simulated and then time-reversed&#60;br /&#62;
% using kspaceFirstOrder3D. It builds on the 3D FFT Reconstruction For A&#60;br /&#62;
% Planar Sensor and 2D Time Reversal Reconstruction For A Line Sensor&#60;br /&#62;
% examples.&#60;br /&#62;
%&#60;br /&#62;
% author: Bradley Treeby&#60;br /&#62;
% date: 10th July 2009&#60;br /&#62;
% last update: 20th June 2017&#60;br /&#62;
%&#60;br /&#62;
% This function is part of the k-Wave Toolbox (&#60;a href=&#34;http://www.k-wave.org&#34; rel=&#34;nofollow&#34;&#62;http://www.k-wave.org&#60;/a&#62;)&#60;br /&#62;
% Copyright (C) 2009-2017 Bradley Treeby&#60;/p&#62;
&#60;p&#62;% This file is part of k-Wave. k-Wave is free software: you can&#60;br /&#62;
% redistribute it and/or modify it under the terms of the GNU Lesser&#60;br /&#62;
% General Public License as published by the Free Software Foundation,&#60;br /&#62;
% either version 3 of the License, or (at your option) any later version.&#60;br /&#62;
%&#60;br /&#62;
% k-Wave is distributed in the hope that it will be useful, but WITHOUT ANY&#60;br /&#62;
% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS&#60;br /&#62;
% FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for&#60;br /&#62;
% more details.&#60;br /&#62;
%&#60;br /&#62;
% You should have received a copy of the GNU Lesser General Public License&#60;br /&#62;
% along with k-Wave. If not, see &#38;lt;http://www.gnu.org/licenses/&#38;gt;. &#60;/p&#62;
&#60;p&#62;clearvars;&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% SIMULATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% change scale to 2 to reproduce the higher resolution figures used in the&#60;br /&#62;
% help file&#60;br /&#62;
scale = 1;&#60;/p&#62;
&#60;p&#62;% create the computational grid&#60;br /&#62;
PML_size = 10;                  % size of the PML in grid points&#60;br /&#62;
Nx = 32 * scale - 2 * PML_size; % number of grid points in the x direction&#60;br /&#62;
Ny = 64 * scale - 2 * PML_size; % number of grid points in the y direction&#60;br /&#62;
Nz = 64 * scale - 2 * PML_size; % number of grid points in the z direction&#60;br /&#62;
dx = 0.2e-3 / scale;            % grid point spacing in the x direction [m]&#60;br /&#62;
dy = 0.2e-3 / scale;            % grid point spacing in the y direction [m]&#60;br /&#62;
dz = 0.2e-3 / scale;            % grid point spacing in the z direction [m]&#60;br /&#62;
kgrid = kWaveGrid(Nx, dx, Ny, dy, Nz, dz);&#60;/p&#62;
&#60;p&#62;% define the properties of the propagation medium&#60;br /&#62;
medium.sound_speed = 1500;      % [m/s]&#60;/p&#62;
&#60;p&#62;% create initial pressure distribution using makeBall&#60;br /&#62;
ball_magnitude = 10;            % [Pa]&#60;br /&#62;
ball_radius = 3 * scale;        % [grid points]&#60;br /&#62;
p0 = ball_magnitude * makeBall(Nx, Ny, Nz, Nx/2, Ny/2, Nz/2, ball_radius);&#60;/p&#62;
&#60;p&#62;% smooth the initial pressure distribution and restore the magnitude&#60;br /&#62;
p0 = smooth(kgrid, p0, true);&#60;/p&#62;
&#60;p&#62;% assign to the source structure&#60;br /&#62;
source.p0 = p0;&#60;/p&#62;
&#60;p&#62;% define a binary planar sensor&#60;br /&#62;
sensor.mask = zeros(kgrid.Nx, kgrid.Ny, kgrid.Nz);&#60;br /&#62;
sensor.mask(1, :, :) = 1;&#60;/p&#62;
&#60;p&#62;% create the time array&#60;br /&#62;
kgrid.makeTime(medium.sound_speed);&#60;/p&#62;
&#60;p&#62;% set the input arguements&#60;br /&#62;
input_args = {'PMLSize', PML_size, 'PMLInside', false, ...&#60;br /&#62;
    'PlotPML', false, 'Smooth', false, 'DataCast', 'single'};&#60;/p&#62;
&#60;p&#62;% run the simulation&#60;br /&#62;
sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor, input_args{:});&#60;/p&#62;
&#60;p&#62;% reset the initial pressure&#60;br /&#62;
source.p0 = 0;&#60;/p&#62;
&#60;p&#62;signal_to_noise_ratio = 6;	% [dB]&#60;br /&#62;
[sensor_data1, snr]= addNoise(sensor_data, signal_to_noise_ratio,'peak');&#60;br /&#62;
% assign the time reversal data&#60;br /&#62;
sensor.time_reversal_boundary_data = sensor_data;&#60;/p&#62;
&#60;p&#62;% run the time-reversal reconstruction&#60;br /&#62;
p0_recon = kspaceFirstOrder3D(kgrid, medium, source, sensor, input_args{:});&#60;/p&#62;
&#60;p&#62;% add first order compensation for only recording over a half plane&#60;br /&#62;
p0_recon = 2 * p0_recon;&#60;/p&#62;
&#60;p&#62;% apply a positivity condition&#60;br /&#62;
p0_recon(p0_recon &#38;lt; 0) = 0;&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% VISUALISATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% plot the initial pressure&#60;br /&#62;
figure;&#60;br /&#62;
plot_scale = [-10, 10];&#60;br /&#62;
subplot(2, 2, 1);&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, squeeze(p0(:, :, Nz/2)), plot_scale);&#60;br /&#62;
title('x-y plane');&#60;br /&#62;
axis image;&#60;/p&#62;
&#60;p&#62;subplot(2, 2, 2);&#60;br /&#62;
imagesc(kgrid.z_vec * 1e3, kgrid.x_vec * 1e3, squeeze(p0(:, Ny/2, :)), plot_scale);&#60;br /&#62;
title('x-z plane');&#60;br /&#62;
axis image;&#60;br /&#62;
xlabel('(All axes in mm)');&#60;/p&#62;
&#60;p&#62;subplot(2, 2, 3);&#60;br /&#62;
imagesc(kgrid.z_vec * 1e3, kgrid.y_vec * 1e3, squeeze(p0(Nx/2, :, :)), plot_scale);&#60;br /&#62;
title('y-z plane');&#60;br /&#62;
axis image;&#60;br /&#62;
colormap(getColorMap);&#60;/p&#62;
&#60;p&#62;% plot the reconstructed initial pressure&#60;br /&#62;
figure;&#60;br /&#62;
subplot(2, 2, 1);&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, squeeze(p0_recon(:, :, Nz/2)), plot_scale);&#60;br /&#62;
title('x-y plane');&#60;br /&#62;
axis image;&#60;/p&#62;
&#60;p&#62;subplot(2, 2, 2);&#60;br /&#62;
imagesc(kgrid.z_vec * 1e3, kgrid.x_vec * 1e3, squeeze(p0_recon(:, Ny/2, :)), plot_scale);&#60;br /&#62;
title('x-z plane');&#60;br /&#62;
axis image;&#60;br /&#62;
xlabel('(All axes in mm)');&#60;/p&#62;
&#60;p&#62;subplot(2, 2, 3);&#60;br /&#62;
imagesc(kgrid.z_vec * 1e3, kgrid.y_vec * 1e3, squeeze(p0_recon(Nx/2, :, :)), plot_scale);&#60;br /&#62;
title('y-z plane');&#60;br /&#62;
axis image;&#60;br /&#62;
colormap(getColorMap);&#60;/p&#62;
&#60;p&#62;Thanks in advance!
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
