<?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: Question regarding multiple sensor.record within one simulation</title>
		<link>http://www.k-wave.org/forum/topic/question-regarding-multiple-sensorrecord-within-one-simulation</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Tue, 12 May 2026 23:06:40 +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/question-regarding-multiple-sensorrecord-within-one-simulation" rel="self" type="application/rss+xml" />

		<item>
			<title>federico.rossano on "Question regarding multiple sensor.record within one simulation"</title>
			<link>http://www.k-wave.org/forum/topic/question-regarding-multiple-sensorrecord-within-one-simulation#post-8581</link>
			<pubDate>Thu, 14 Jul 2022 08:53:22 +0000</pubDate>
			<dc:creator>federico.rossano</dc:creator>
			<guid isPermaLink="false">8581@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Ben,&#60;/p&#62;
&#60;p&#62;Thank you a lot for your answer. Luckly, in the meantime, I was able to run large simulations without running out of RAM just dividing the sensor.record matrix in different parts and then using 'cat' Matlab function to concatenate all the &#34;result matrices parts&#34;.&#60;br /&#62;
I will attach my code here:&#60;/p&#62;
&#60;p&#62;parts=n; %number of split in the domain along z&#60;br /&#62;
for i=1:parts  %domain splitted in half along z&#60;br /&#62;
x_1=1;&#60;br /&#62;
x_2=Nx;&#60;br /&#62;
y_1=1;&#60;br /&#62;
y_2=Ny;&#60;br /&#62;
z_1=floor((Nz*i)/parts)-(floor(Nz/parts))+1;&#60;br /&#62;
z_2=ceil(Nz/parts)+ceil((Nz*(i-1))/parts);&#60;br /&#62;
if z_2&#38;gt;ceil(Nz*i/parts)&#60;br /&#62;
    z_2=ceil(Nz*i/parts);&#60;br /&#62;
end&#60;br /&#62;
sensor_cuboid=[x_1,y_1,z_1,x_2,y_2,z_2].';&#60;br /&#62;
sensor.mask=sensor_cuboid;&#60;br /&#62;
sensor.record={'p_max'};&#60;br /&#62;
%Starting simulation&#60;br /&#62;
reset(gpuDevice(1)); %reset GPU memory&#60;br /&#62;
input_args={ 'DataCast','single','PMLInside', false};&#60;br /&#62;
sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor, input_args{:},'PlotSim', false);&#60;br /&#62;
data=struct('P_max',sensor_data.p_max,'Nx',Nx,'Ny',Ny,'Nz',Nz,'dx',dx,'dy',dy,'dz',dz,'signal',signal);&#60;br /&#62;
save(['your_folder\data_', num2str(i), '.mat'],'data','-v7.3','-nocompression');&#60;br /&#62;
clear data&#60;br /&#62;
clear sensor.record&#60;br /&#62;
clear sensor.mask&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;Surprisingly the division of the domain led to less computation time.&#60;br /&#62;
The script cannot divide the domain in exact parts and may be an overlap in the results. That will be easy to correct, just deleting the exact same slices running a for cycle.&#60;/p&#62;
&#60;p&#62;Best regards,&#60;br /&#62;
Federico
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bencox on "Question regarding multiple sensor.record within one simulation"</title>
			<link>http://www.k-wave.org/forum/topic/question-regarding-multiple-sensorrecord-within-one-simulation#post-8574</link>
			<pubDate>Wed, 13 Jul 2022 17:56:58 +0000</pubDate>
			<dc:creator>bencox</dc:creator>
			<guid isPermaLink="false">8574@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Federico, &#60;/p&#62;
&#60;p&#62;You can only define one &#60;code&#62;sensor.mask&#60;/code&#62; region using the 'cuboid corners' approach, but you can define &#60;code&#62;sensor.mask&#60;/code&#62; as a binary source mask with any set of points. If you want to record very many time series, then the output will get quite large. It may be worth thinking about whether you need the full time series, or whether you could define another quantity to be recorded, eg. by using &#60;code&#62;sensor.record = {&#38;#39;p_max&#38;#39;}&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;Best wishes&#60;br /&#62;
Ben
&#60;/p&#62;</description>
		</item>
		<item>
			<title>federico.rossano on "Question regarding multiple sensor.record within one simulation"</title>
			<link>http://www.k-wave.org/forum/topic/question-regarding-multiple-sensorrecord-within-one-simulation#post-8557</link>
			<pubDate>Wed, 29 Jun 2022 09:46:31 +0000</pubDate>
			<dc:creator>federico.rossano</dc:creator>
			<guid isPermaLink="false">8557@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
I need to run simulations on very large 3D domains using a frequency of 1 MHz, this translates in high RAM occupation (&#38;gt;128 GB) when the algorithm kSpaceFirstOrder3D tries to create the sensor.record matrix. To overcome this problem, my strategy is to define the sensor.record matrix as small as possible exactly where I need to observe the simulation results. To compute the whole domain solution, I was thinking about create multiple cuboids iteratively and save the solution within them once the computation is completed. My question is all about it, is there a way to run a single kSpaceFirstOrder3D and then store the solution in every matrix one at time?&#60;br /&#62;
Or should I run kSpaceFirstOrder3D iteratively (for cycle) with different sensor.record matrix every time, saving the results and deleting the variables from the workspace? The second option will of course take a longer time because I will need to run the simulations N times to cover all my 3D domain with different sensor.record matrices.&#60;br /&#62;
Thank you in advance, you are doing such a great work with this toolbox!&#60;br /&#62;
Federico
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
