k-Wave User Forum » Topic: Zero matrix computed in scanConversion
http://www.k-wave.org/forum/topic/zero-matrix-computed-in-scanconversion
Support for the k-Wave MATLAB toolboxen-USSat, 27 Nov 2021 09:15:12 +0000http://bbpress.org/?v=1.0.2<![CDATA[Search]]>q
http://www.k-wave.org/forum/search.php
mario7lorenzo on "Zero matrix computed in scanConversion"
http://www.k-wave.org/forum/topic/zero-matrix-computed-in-scanconversion#post-8309
Tue, 21 Sep 2021 02:28:58 +0000mario7lorenzo8309@http://www.k-wave.org/forum/<p>Hi guys,</p>
<p>I am new to this k-Wave library. My aim is to create a sector scan image using <code>scanConversion</code> method. I have the signal data for several plane wave angles with time. I have arranged the data into a matrix of sized <code>nAngles vs Time</code> as required in the documentation. I have also specified what are the scan angles used in the data, the time difference between samples, and the image size. However, somehow the result is all zero matrix. I could not think of what potential issues that happens here. Looking forward for your insights!</p>
<p>Thanks!</p>
<p>Btw, here is the code:<br />
<pre><code>function result = process()
load('data.mat');
% Compute the time delay
% Reference point: The left most element as the first element
dx = 10; % in mm
theta = [-10 -5 0 5 10]; % in degrees
na = 5; % no of steering angles
c = 6300; % speed of sound in m/s
thetaradian = theta * pi/180;
Fs = Receive(1).decimSampleRate * 1e6;
ts = 1/Fs;
tStart = 0;
N = Receive(1).endSample;
t = tStart + (0:N-1)*ts;
example = RcvData{1}(Receive(1).startSample:Receive(1).endSample, 1, 1);
sz = size(example);
scanLines = zeros([na sz(1)]);
for j = 1:5
accumulated = RcvData{1}(Receive(j).startSample:Receive(j).endSample, 1, 1);
accumulated = double(accumulated);
sz = size(accumulated);
dt = dx * 1e-3 * sin(thetaradian(j))/c; % time delay per elem, in s
for i = 2:3
curr = RcvData{1}(Receive(j).startSample:Receive(j).endSample, i, 1);
zipped = [t' double(curr)];
td = (i-1) * dt;
zipped(:,1) = zipped(:,1) - td;
zipped = zipped(zipped(:,1) >= t(1) & zipped(:,1) <= t(end),:);
filtered = zipped(:,2);
szFiltered = size(filtered);
if (td < 0)
padded = [zeros([sz(1) - szFiltered(1) 1]); filtered];
else
padded = [filtered; zeros([sz(1) - szFiltered(1) 1])];
end
accumulated = accumulated + padded;
end
% post processing
% 1. High pass filtering
accumulated = highpass(accumulated, 10000, Fs);
% 2. Rectification
accumulated = abs(accumulated);
% 3. Enveloping
[accumulated, dummy] = envelope(accumulated,300,'peak');
scanLines(j,:) = accumulated';
end
% k-Wave scanConversion part
image_size = [480 480];
b_mode = scanConversion(scanLines, theta, image_size, c, t(2)-t(1));
result = b_mode;
end</code></pre>