[Gate-users] Problems/inconsistencies calculating dose uncertainty

COURT, Steven (UNIVERSITY COLLEGE LONDON HOSPITALS NHS FOUNDATION TRUST) steven.court at nhs.net
Wed Feb 19 14:12:03 CET 2020


Hi Matthew,

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:

double std_dose = sqrt( (1.0/(N-1))*(sq_dose/N - pow(dose/N, 2)) )/(dose/N);
      if( dose == 0.0 || N == 1 || sq_dose == 0 )
        std_dose = 1.0;

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).

Steve

________________________________________
From: Gate-users <gate-users-bounces at lists.opengatecollaboration.org> on behalf of gate-users-request at lists.opengatecollaboration.org <gate-users-request at lists.opengatecollaboration.org>
Sent: 07 February 2020 11:00
To: gate-users at lists.opengatecollaboration.org
Subject: Gate-users Digest, Vol 165, Issue 9

Send Gate-users mailing list submissions to
        gate-users at lists.opengatecollaboration.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.opengatecollaboration.org/mailman/listinfo/gate-users
or, via email, send a message with subject or body 'help' to
        gate-users-request at lists.opengatecollaboration.org

You can reach the person managing the list at
        gate-users-owner at lists.opengatecollaboration.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Gate-users digest..."


Today's Topics:

   1. Re: Problems/inconsistencies calculating dose uncertainty
      (Matthew Strugari)


----------------------------------------------------------------------

Message: 1
Date: Thu, 6 Feb 2020 20:57:22 +0000
From: Matthew Strugari <matthew.strugari at dal.ca>
To: "gate-users at lists.opengatecollaboration.org"
        <gate-users at lists.opengatecollaboration.org>
Subject: Re: [Gate-users] Problems/inconsistencies calculating dose
        uncertainty
Message-ID:
        <YTXPR0101MB13734E510B6A64FDB5EDBBB3FA1D0 at YTXPR0101MB1373.CANPRD01.PROD.OUTLOOK.COM>

Content-Type: text/plain; charset="iso-8859-1"

Hi again,

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
        sampleVariance = (1/(N-1)) * (sq_dose - pow(dose,2)/N)
        standardDeviation = np.sqrt(sampleVariance)
        std_dose = standardDeviation/dose
        # or inline:
        std_dose = np.sqrt( (1/(N-1))*(sq_dose - pow(dose,2)/N) )/dose

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 (https://opengate.readthedocs.io/en/latest/voxelized_source_and_phantom.html#dose-collection) outline the dose calculations using the sample variance with a formula that represents the population variance.

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!

Positively,
Matthew



________________________________
From: Gate-users <gate-users-bounces at lists.opengatecollaboration.org> on behalf of Matthew Strugari <matthew.strugari at dal.ca>
Sent: February 6, 2020 2:59 PM
To: gate-users at lists.opengatecollaboration.org <gate-users at lists.opengatecollaboration.org>
Subject: [Gate-users] Problems/inconsistencies calculating dose uncertainty

Hi all,

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:
      double std_dose = sqrt( (1.0/(N-1))*(sq_dose/N - pow(dose/N, 2)) )/(dose/N);
      if( dose == 0.0 || N == 1 || sq_dose == 0 )
        std_dose = 1.0;

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:
        N = np.ma.masked_equal(N, 0)
        N = np.ma.masked_equal(N, 1)
        dose = np.ma.masked_equal(dose, 0.0)
        sq_dose = np.ma.masked_equal(sq_dose,0)

        # calculate uncertainty using formula from GateDoseActor.cc
        std_dose = np.sqrt( (1.0/(N-1))*(sq_dose/N - pow(dose/N, 2)) )/(dose/N)
        std_dose = np.ma.filled(std_dose, 1.0).astype(np.float32)

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).

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.

Positively,
Matthew


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opengatecollaboration.org/pipermail/gate-users/attachments/20200206/a243e97a/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Gate-users mailing list
Gate-users at lists.opengatecollaboration.org
http://lists.opengatecollaboration.org/mailman/listinfo/gate-users

------------------------------

End of Gate-users Digest, Vol 165, Issue 9
******************************************


********************************************************************************************************************

This message may contain confidential information. If you are not the intended recipient please inform the
sender that you have received the message in error before deleting it.
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.

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.

For more information and to find out how you can switch, https://portal.nhs.net/help/joiningnhsmail



More information about the Gate-users mailing list