<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Steve,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thank you so much for informing me. I could not figure out why my stats were so good.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Best wishes,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Matthew<br>
</div>
<div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Gate-users <gate-users-bounces@lists.opengatecollaboration.org> on behalf of COURT, Steven (UNIVERSITY COLLEGE LONDON HOSPITALS NHS FOUNDATION
TRUST) <steven.court@nhs.net><br>
<b>Sent:</b> February 19, 2020 9:12 AM<br>
<b>To:</b> gate-users@lists.opengatecollaboration.org <gate-users@lists.opengatecollaboration.org><br>
<b>Subject:</b> Re: [Gate-users] Problems/inconsistencies calculating dose uncertainty</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">Hi Matthew,<br>
<br>
You've maybe solved this by now but I had a similar problem this week. To reproduce the uncertainty calculated by Gate, in the initial equation you provided:<br>
<br>
double std_dose = sqrt( (1.0/(N-1))*(sq_dose/N - pow(dose/N, 2)) )/(dose/N);<br>
if( dose == 0.0 || N == 1 || sq_dose == 0 )<br>
std_dose = 1.0;<br>
<br>
the N is not the number of hits, but is actually the total number of primaries simulated (which can be read from the NumberOfEvents in your stat.txt file).<br>
<br>
Steve<br>
<br>
________________________________________<br>
From: Gate-users <gate-users-bounces@lists.opengatecollaboration.org> on behalf of gate-users-request@lists.opengatecollaboration.org <gate-users-request@lists.opengatecollaboration.org><br>
Sent: 07 February 2020 11:00<br>
To: gate-users@lists.opengatecollaboration.org<br>
Subject: Gate-users Digest, Vol 165, Issue 9<br>
<br>
Send Gate-users mailing list submissions to<br>
gate-users@lists.opengatecollaboration.org<br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://lists.opengatecollaboration.org/mailman/listinfo/gate-users">
http://lists.opengatecollaboration.org/mailman/listinfo/gate-users</a><br>
or, via email, send a message with subject or body 'help' to<br>
gate-users-request@lists.opengatecollaboration.org<br>
<br>
You can reach the person managing the list at<br>
gate-users-owner@lists.opengatecollaboration.org<br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Gate-users digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Re: Problems/inconsistencies calculating dose uncertainty<br>
(Matthew Strugari)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Thu, 6 Feb 2020 20:57:22 +0000<br>
From: Matthew Strugari <matthew.strugari@dal.ca><br>
To: "gate-users@lists.opengatecollaboration.org"<br>
<gate-users@lists.opengatecollaboration.org><br>
Subject: Re: [Gate-users] Problems/inconsistencies calculating dose<br>
uncertainty<br>
Message-ID:<br>
<YTXPR0101MB13734E510B6A64FDB5EDBBB3FA1D0@YTXPR0101MB1373.CANPRD01.PROD.OUTLOOK.COM><br>
<br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Hi again,<br>
<br>
I'm following up with some further calculations/derivations of the relative statistical uncertainty. According to the docs, GATE outputs the relative statistical uncertainty. Using the usual statistical formulae, this would be the standard deviation divided
by the dose. Given that the standard deviation is the square root of the sample variance, the final formula should be<br>
sampleVariance = (1/(N-1)) * (sq_dose - pow(dose,2)/N)<br>
standardDeviation = np.sqrt(sampleVariance)<br>
std_dose = standardDeviation/dose<br>
# or inline:<br>
std_dose = np.sqrt( (1/(N-1))*(sq_dose - pow(dose,2)/N) )/dose<br>
<br>
When comparing my calculated uncertainty to the reference uncertainty, I am now 58% different at the origin (opposed to >8000%) but the average percent difference is 77% (opposed to 1% using the GATE formula). I am overall quite confused how the uncertainty
is calculated by GATE, especially considering that the docs (<a href="https://opengate.readthedocs.io/en/latest/voxelized_source_and_phantom.html#dose-collection">https://opengate.readthedocs.io/en/latest/voxelized_source_and_phantom.html#dose-collection</a>)
outline the dose calculations using the sample variance with a formula that represents the population variance.<br>
<br>
If anyone would be so kind to instruct me how GATE calculates the uncertainty, and/or how I can reproduce the uncertainty using the Dose, Dose-Squared, and NbOfHits files, it would be greatly appreciated!<br>
<br>
Positively,<br>
Matthew<br>
<br>
<br>
<br>
________________________________<br>
From: Gate-users <gate-users-bounces@lists.opengatecollaboration.org> on behalf of Matthew Strugari <matthew.strugari@dal.ca><br>
Sent: February 6, 2020 2:59 PM<br>
To: gate-users@lists.opengatecollaboration.org <gate-users@lists.opengatecollaboration.org><br>
Subject: [Gate-users] Problems/inconsistencies calculating dose uncertainty<br>
<br>
Hi all,<br>
<br>
I am in need of assistance when calculating the dose uncertainty using output from the dose actor. I would like to merge multiple dose point kernel outputs from the dose actor to speed up my overall simulation time. Using the output from a single simulation
to verify the calculation of the uncertainty, my results are ~1% different from the reference GATE output on average with a >8000% difference at the origin. I am using the formula found in GateDoseActor.cc:<br>
double std_dose = sqrt( (1.0/(N-1))*(sq_dose/N - pow(dose/N, 2)) )/(dose/N);<br>
if( dose == 0.0 || N == 1 || sq_dose == 0 )<br>
std_dose = 1.0;<br>
<br>
Here, the corresponding image data (attached in doseActorOutput.zip) are assigned as dose = Dose.mhd, sq_dose = Dose-Squared.mhd, and N = NbOfHits.mhd and then element-wise operations are performed. My approach is slightly different as I mask the matrices to
avoid nan/inf results:<br>
N = np.ma.masked_equal(N, 0)<br>
N = np.ma.masked_equal(N, 1)<br>
dose = np.ma.masked_equal(dose, 0.0)<br>
sq_dose = np.ma.masked_equal(sq_dose,0)<br>
<br>
# calculate uncertainty using formula from GateDoseActor.cc<br>
std_dose = np.sqrt( (1.0/(N-1))*(sq_dose/N - pow(dose/N, 2)) )/(dose/N)<br>
std_dose = np.ma.filled(std_dose, 1.0).astype(np.float32)<br>
<br>
Some/very few of the calculated std_dose values are greater than one (1.0000001 so I am not sure if this is indicative of an error or if I should just normalize std_dose before filling the masked values with 1. Also, the Dose-Uncertainty.mhd images appear identical
in ImageJ but the actual values appear to be scaled differently (see attached doseKernel.zip).<br>
<br>
Please correct me in my calculation or provide any information on the correct way to calculate the uncertainty using the Dose, Dose-Squared, and NbOfHits files.<br>
<br>
Positively,<br>
Matthew<br>
<br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.opengatecollaboration.org/pipermail/gate-users/attachments/20200206/a243e97a/attachment-0001.html">http://lists.opengatecollaboration.org/pipermail/gate-users/attachments/20200206/a243e97a/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
_______________________________________________<br>
Gate-users mailing list<br>
Gate-users@lists.opengatecollaboration.org<br>
<a href="http://lists.opengatecollaboration.org/mailman/listinfo/gate-users">http://lists.opengatecollaboration.org/mailman/listinfo/gate-users</a><br>
<br>
------------------------------<br>
<br>
End of Gate-users Digest, Vol 165, Issue 9<br>
******************************************<br>
<br>
<br>
********************************************************************************************************************<br>
<br>
This message may contain confidential information. If you are not the intended recipient please inform the<br>
sender that you have received the message in error before deleting it.<br>
Please do not disclose, copy or distribute information in this e-mail or take any action in relation to its contents. To do so is strictly prohibited and may be unlawful. Thank you for your co-operation.<br>
<br>
NHSmail is the secure email and directory service available for all NHS staff in England and Scotland. NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and other accredited email services.<br>
<br>
For more information and to find out how you can switch, <a href="https://portal.nhs.net/help/joiningnhsmail">
https://portal.nhs.net/help/joiningnhsmail</a><br>
<br>
_______________________________________________<br>
Gate-users mailing list<br>
Gate-users@lists.opengatecollaboration.org<br>
<a href="http://lists.opengatecollaboration.org/mailman/listinfo/gate-users">http://lists.opengatecollaboration.org/mailman/listinfo/gate-users</a></div>
</span></font></div>
</div>
</body>
</html>