In physics–especially medical physics–the gamma index is a criterion for comparing data from two particle detectors. More abstractly, the gamma index takes two 2D arrays (let’s say array1 and array2) and compares each element of array1 with spatially-nearby elements of array2.
There are hundreds of academic papers that use the gamma index in their analysis sections. These papers don’t seem to mention what tools/libraries they use to calculate the gamma index. It’s possible the authors implement their own gamma index calculations (it’s not that hard). However, I’m guessing that there are libraries/extensions/tools for calculating a gamma index.
Can anyone suggest a gamma index library to use in R or Python? (Other languages would be ok if there’s nothing off-the-shelf for Python or R.)
I found basic MATLAB implementation of the 2D gamma index in Appendix A of this thesis.
I copy/pasted the following code from the thesis, and I made a couple of simplifications for readability. I talked to the author and confirmed that my version of the code (below) is correct. Recently, I have been using this code in the analysis portion of a medical physics study that I’ll be publishing soon.
The inputs
A1andA2are 2D arrays (which, in practice, are dose maps or fluence maps). We letA1serve as the reference data, andA2is the data that is being evaluated. If we use a typical 2%, 2mm acceptance criterion, then we set distance to agreement asDTA=2mm, and we set the dose thresholddosed=0.02, which is 2%.In this simple implementation, we assume that the array indices are spaced in 1mm increments. If your data doesn’t use 1mm increments, then scale your
dosedvalue accordingly (e.g. if yourA1andA2are in 0.5mm increments, then useDTA=4to get a 2mm criterion).The output,
G, is a 2D array of gamma values.To see an explanation of the gamma index in math notation, I recommend looking at this blog post.