I have simulated an image using Monte Carlo simulation and saved it as a 2D array and when I load it as an external image to have it reconstructed I get an error in the acoustical forward simulation using kspaceFirstOrder2D which refers it to the line p = c.^2 .* (rhox + rhoy) in the kspaceFirstOrder2D code. what am I doing wrong?
k-Wave
A MATLAB toolbox for the time-domain
simulation of acoustic wave fields
loading an external image for reconstruction
(5 posts) (2 voices)-
Posted 5 years ago #
-
Hi elahehamini,
It's hard to say without seeing more details. Is your image the same size as the grid (Nx, Ny)? Are you using it to define the source or the medium properties?
Brad.
Posted 5 years ago # -
yes, my image is the same size as the grid and I use it to define the source. the Image is 128*128 pixels. This is the code:
p0_magnitude = 1;
load d1.mat
F =d1;
p0_image =p0_magnitude* F;
% assign the grid size and create the computational grid
PML_size = 20; % size of the PML in grid points
Nx = 168 - 2 * PML_size; % number of grid points in the x direction
Ny = 168 - 2 * PML_size; % number of grid points in the y direction
x = 2.56e-3; % total grid size [m]
y = 2.56e-3; % total grid size [m]
dx = x / Nx; % grid point spacing in the x direction [m]
dy = y / Ny; % grid point spacing in the y direction [m]
kgrid = kWaveGrid(Nx, dx, Ny, dy);
% assign to the source structure
source.p0 = p0_image;
% define the properties of the propagation medium
medium.sound_speed = 1500; % [m/s]
% define a centered Cartesian circular sensor
sensor_radius = 1.26e-3; % [m]
sensor_angle = pi; % [rad]
sensor_pos = [0, 0]; % [m]
num_sensor_points = 70;
cart_sensor_mask = makeCartCircle(sensor_radius, num_sensor_points, sensor_pos, sensor_angle);
% assign to sensor structure
sensor.mask = cart_sensor_mask;
% create the time array
kgrid.makeTime(medium.sound_speed);
% set the input options
input_args = {'Smooth', true, 'PMLInside', false, 'PlotPML', false, 'PlotSim', true, 'DataCast', 'single'};
% run the simulation
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});
Posted 5 years ago # -
If I set
p0_image = rand(128, 128);
the simulation runs without errors. Are the values in F real numbers in single/double precision?
Posted 5 years ago # -
I found out the problem and it was the name of my m-file which was c and the code tried to execute it as a function and that's why I got an error on line
p = c.^2 .* (rhox + rhoy)
. Thank you so much for your timePosted 5 years ago #
Reply
You must log in to post.