Hi Dr. Fang,
Thank you for continuing to develop MCX! I have been using it personally for years and have enjoyed diving deeper into the complexity.
I am currently interested to use the pattern3d emission source with an absorbed energy deposition map as the input. However, when testing, I was unable to match the output weights with initial weights in a simulation
with no attenuation. I provided a script to replicate what I'm seeing:
- Run an initial energy simulation with no scattering to get a basic energy deposition map
- Use the deposition map for a "pattern3d" emission (input)
- Emit the light perfectly collimated and with no attenuation back to the detector (output)
From this setup, I expected the input = output, since there is no attenuation. I first checked whether sum(detp.w0) was equal to sum(eng.data(:)), which was my input. However, I did not see that. I noticed the following:
1. Calculating total photon weight from Reflectance does match well with the Launch weight.
2. However, sum(detp.w0) did not match the Launch weight and was also not consistent over radii despite the total input energy being unchanged.
I remain puzzled, and I was hoping you could shed some light on how detp.w0 is saved when using a pattern3d source. Any hints would be greatly appreciated.
Thank you.
Kind regards,
Jesse
clear;
%% Basic options
rad=.2:.2:1;
%set of increasing disk radii
voxsize=.05;
%voxel edge length (mm)
cubelen=4;
%total simulation size (mm)
%% Building cfg for energy deposition
cfg.nphoton=1e6;
cfg.unitinmm=voxsize;
% Volume parameters
sx=cubelen./voxsize;
sy=cubelen./voxsize;
sz=cubelen./voxsize;
cfg.vol=uint8(ones(sx,sy,sz));
cfg.vol(:,:,1)=0;
cfg.isreflect=0;
cfg.isspecular=0;
cfg.seed=1;
for
a=1:length(rad)
% source parameters
cfg.srctype='disk';
cfg.srcparam1(1)=rad(a)./voxsize;
cfg.srcparam1(2)=0;
cfg.srcpos=[sx/2 sy/2 1];
cfg.srcdir=[0 0 1];
% detector
cfg.detpos=[sx/2 sy/2 1 sqrt(sx^2+sy^2)/2];
%det size = top surface
cfg.tstart=0;
cfg.tend=1e-8;
cfg.tstep=1e-8;
cfg.outputtype='energy';
cfg.savedetflag='dpwxv';
% run sim
cfg.prop=[0 0 1 1; .1 0 1 1];
eng=mcxlab(cfg);
% energy map to be used as input
%% Building cfg for emission
cfg.outputtype='fluence';
cfg.issaveref=1;
cfg.issaveexit=1;
cfg.isspecular=0;
% update source
launch_w0(a)=sum(eng.data(:));
%expected initial weight
cfg.srctype='pattern3d';
cfg.srcpattern=eng.data./max(eng.data(:));
%pattern3d input float [0 1]
cfg.srcpos=[1 1 1 launch_w0(a)];
%specify initial weight
cfg.srcdir=[0 0 -1];
%photons launch back to detector
cfg.srcparam1=[sx sy sz];
% run sim
cfg.prop=[0 0 1 1; 0 0 1 1];
%no attenuation
[flu,detp]=mcxlab(cfg);
% results
detected_weight(a)=sum(eng.data(:)).*sum(flu.dref(:).*cfg.unitinmm.^2);
w0(a)=sum(detp.w0);
end
%% Plotting
figure(1); clf;
subplot(3,1,1);
plot(rad,launch_w0);
ylabel('Weight');
title('Launched Photon Weight');
subplot(3,1,2);
plot(rad,detected_weight);
ylabel('Weight');
title('Detected Photon Weight');
subplot(3,1,3);
plot(rad,w0);
ylabel('Weight');
title('Sum of detp.w0');
You received this message because you are subscribed to the Google Groups "mcx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
.