Extracting Vertical Data Line from Plot
1 次查看(过去 30 天)
显示 更早的评论
I am having a bit of a issue extracting data to show how the fluence varies through the medium vertically. I have a horizontal line, but want to get a vertical line. Could anyone help. I have attatched the script and figures for more information. Could anyone suggest how to get a vertical line extracted?
Code:
% A code to show an Isotropic Light Source traveling through a Medium of
% Oxygenised Blood. The source code has been taken from
% https://inverselight.github.io/ValoMC/simpletest.html and has been
% adapted for the project - Referenced in report.
% This example demonstrates how to setup a simple photon transport
% simulation, run it and visualise the result.
%% Create a triangular mesh
% Function createRectangularMesh is used to setup a simple triangular mesh. The
% mesh is visualised in the figure below. Each element (a triangle) and
% boundary element (a line) in the mesh has a unique index that can be
% used to set their properties. The indices of the boundary elements are
% shown in the figure.
xsize = 10; % width of the region [mm]
ysize = 10; % height of the region [mm]
dh = 0.1; % discretisation size [mm]
vmcmesh = createRectangularMesh(xsize, ysize, dh);
%% Set up Optical Parameters for Oxygenised Blood
% The Optical Parameters have been taken from literature values and have
% been cited within the report.
% Wavelength of light at 900nm
vmcmedium.absorption_coefficient = 0.56; % absorption coefficient [1/mm]
vmcmedium.scattering_coefficient = 68.86; % scattering coefficient [1/mm]
vmcmedium.scattering_anisotropy = 0.9824; % anisotropy parameter g of
% the Heneye-Greenstein scattering
% phase function [unitless]
vmcmedium.refractive_index = 1.615; % refractive index [unitless]
%% Create a Direct light sources from Boundary 4:7
% Photons are launched in the same direction.
vmcboundary.lightsource(20:80) = {'direct'};
%% Run the Monte Carlo simulation
% Use the parameters that were generated to run the simulation in the mesh.
solution = ValoMC(vmcmesh, vmcmedium, vmcboundary);
%% Plot the solution using MATLAB
figure(1);
hold on;
patch('Faces',vmcmesh.H,'Vertices',vmcmesh.r,'FaceVertexCData', solution.element_fluence, 'FaceColor', 'flat', 'EdgeColor', 'none');
xlabel('[mm]');
ylabel('[mm]');
c = colorbar;
title('Fluence [W/mm^2]');
hold off
%% Extracting Fluence to plot curve (Horizontal Line)
figure(2);
linetest = solution.element_fluence;
A = linetest;
B = A(50:100:end,:);
plot(B);
xlim([1 100]);
title('Variation in Fluence (W/mm^2) versus distance travelled (mm)')
xlabel('Distance travelled by Photons (mm)')
ylabel('Fluence (W/mm^2)')
%% Extracting Fluence to plot curve (Veritcal Line)
figure(3);
linetest = solution.element_fluence;
A = linetest;
B = A(50:100:end,:);
plot(B);
xlim([1 100]);
title('Variation in Fluence (W/mm^2) versus distance travelled (mm)')
xlabel('Distance travelled by Photons (mm)')
ylabel('Fluence (W/mm^2)')
Figure to show Light Source Travelling through Medium:

Figure to show Horizontal data line at (-5,0) to (5,0) to show how fluence intensity changes with depth penetration:

5 个评论
Prudhvi Peddagoni
2021-1-22
Hi,
Can you provide the dimensions of solution.element_fluence variable? I tried to run this script but there seems to be some dependency issues ( after downloading the GitHub repo). For getting horizontal line data, the code was
B = A(50:100:end,:);
I do not understand why you selected multiple rows if you only want to select a single horizontal line. But you should be able to switch the dimensions to
B = A(:,50:100:end);
to get the vertical line. But I need more info about the solution.element_fluence variable to confirm this. Maybe if you can share the mat file for this variable, that would be great.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!