# A Matlab function to compute the attenuation coefficient

The National Institute of Standards and Technology provides values for the attenuation and energy coefficient online (NIST 5632 ). The data represent the best present estimate and are a mixture of experimental data and theoretical calculations.
The energy absorption coefficient measures energy absorption while the attenuation coefficient measures interactions. These are not the same because not all the photon energy is absorbed when a photon interacts. For example in Compton scattering only part of the energy is absorbed and a new photon carries off the rest in a different direction from the original. Energy absorption is useful, as the name implies, for absorbed dose calculations but the attenuation coefficient is the relevant property in x-ray imaging systems.
The NIST 5632 data were incorporated into my function xraymu.m. This function is based on PhotonAttenuation.m by Jaroslaw Tuszynski, which is available on the Mathworks File Exchange (PhotonAttenuation.m). The main improvement is in the interface. See the help for the function for details.
The xraymu.m function uses chemical formulas to specify the material such as
```mus=xraymu(’H2O’,egys)
```
where egys is an array of x-ray energies in keV. The chemical formula is case sensitive and requires chemical symbols. A little reflection shows why. For example, how can we distinguish tin (Sn) from sulfur (S) and nitrogen (N) with a case insensitive formula?
You can also specify the fractions by weight as in
```mus=xraymu(’H0.1119O0.8881’,egys)
```
Finally, you can specify the material as a two column table with one row per element and the atomic number in the first column and the fraction by weight in the second column.
```ztable = [1 0.1119; 8 0.8881];
mus = xraymu(ztable,egys);
```
The code computes the data by log-log interpolating the NIST 5632 data using the Matlab pchip.m function. This function is well suited for handling the discontinuous data shown in Fig. 2 of my previous post.