{'fraction_non_alphanumeric': 0.026687189201989106, 'fraction_numerical': 0.009448259531139001, 'mean_word_length': 4.55744176865377, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Estimation of the optimal parameters for K-edge subtraction imaging with PixiRad-2/PixieIII photon counting detector on a conventional laboratory X-ray micro-tomograph

Photon Counting Detectors (PCDs) open new opportunities in X-ray imaging. Pixie III is a PCD using simultaneously two energy thresholds. This enables to acquire images from two distinct energy bins in a single exposure. This is particularly suited to perform K-Edge Subtraction (KES) imaging with laboratory sources. In that context, one has however to deal with an energy bin optimization: narrow energy bins leads to high KES signal, at the expense of higher noise, while wider energy bins leads to poor KES signal but better statistics. This work presents a model that aims at finding the optimal thresholds and source voltage in order to retrieve the best Contrast to Noise Ratio (CNR) for a given sample. The model also optimizes the configurations for conventional absorption modality and compares both modalities. We noticed that the input flux and the energy difference between the thresholds influence the noise on image. We included this in the model using phenomenological laws. The model is then compared to empirical optimization by experimental screening of the parameters on model materials composed of barium, iodine and water. Finally, a study of the predicted CNRs has function of the sample composition is presented as an example of usage of the model.


Introduction
X-ray tomography is now daily used in research domains such as material science, medical and biological science, and more and more in industries (see e.g. [1]). The conventional and most employed technique is based on absorption contrast, discriminating material by their difference of absorption at a given energy (monochromatic beam) or by their difference of integrated absorption over an energy range (polychromatic beam). However, it may happen that this contrast is not large enough to differentiate the materials. A possibility for enhancing contrast in that case is to exploit phase contrast techniques [2][3][4]. However these techniques are not easy to handle on laboratory tomographs. Another possibility is to increase contrast from variation in absorption coefficient measured at two different energies (or over two distinct energy ranges). This is particularly efficient when the K-edge of one of the materials, that corresponds to a strong variation of absorption coefficient, lies between the two spectral measurements points. Thus, this approach is named K-edge Subtraction (KES) imaging [5]. The classical example of such an application is the use of contrast agent as iodine or barium for biological and medical applications. Historically, this technique was developed under somehow monochromatic condition with laboratory source, using secondary source fluorescence peaks [6,7] or additional monochromator [8]. This permits measurements to be performed right before and right after the K-edge. However, these approaches were restricted to specific chemical elements and limited to low flux. Practically, this technique was mainly used at synchrotron [9,10] as the beam offer high monochromaticity and high flux at the expense of the accessibility of the technique. Recent development of new technologies such as Compact Light Source allows overcoming this difficulty and was used to perform KES imaging for medical application [11]. This kind of sources definitely offers promising perspectives but their access and use are still more complicated than laboratory sources. Another strategy to develop KES imaging relies on the recent development of photon counting detectors, offering detectors with energy-discriminating capabilities [12]. One of them is the PixieIII photon counting detector [13]. It has the capacity to count incoming photons over two distinct energy ranges simultaneously, allowing to acquire two images in a single exposure time when illuminated with a polychromatic beam. This technology allows the benefits of the polychromatic aspects of laboratory X-ray sources to be taken advantage of. However, in that case, as the absorption coefficient measurements corresponds to mean over energy ranges, and not at specific energies, one has to deal with an optimization problem. This problem is depicted in figure 1. Consider two absorbance spectra of two distinct materials, one with K-edge at energy and another one without K-edge represented by the green and purple solid curves respectively. The PCD detector thresholds and and the source voltage U defines the energy range Ω 1 and Ω 2 over which the two spectral images are formed (represented by the blue and red shaded areas, respectively). In order to get the strongest KES signal, one may be tempted to use narrow energy ranges on each side of the K-edge energy as sketched by figure 1.a). However, since laboratory sources offer limited photon flux, this would result in low statistic images. Conversely, in order to get lower noise, one may choose large energy bins as in figure 1.c). In this case, the KES signal is low as the averaging over large energy bin smooths the K-edge. So the optimal tuning of the energy ranges over which to perform the K-edge imaging is a trade-off between high KES signal and good statistic in the images ( fig. 1 To address this problem, He et al. [14,15] presented a theoretical approach to predict the optimal width of the energy range. Their model is based on optimization of contrast to noise ratio of the projection images, the noise being Poisson noise from the beam, and the contrast signal being obtained from Beer-Lambert law through the sample. Their results assumed an equal width of the two energy bins. Later, Meng et al. [16] used the same approach, the optimization being based on the Contrast to Noise Ratio (CNR) of the reconstructed images, and showed that bin width are similar when optimizing CNR on projections or reconstructed images. While this approach answers the optimization problem for the general case, detector-specific features like detector noise or spectral resolution are not taken into account. For PixieIII, Brun et al. [17] presented results of empirical optimization of one of the two thresholds on a test phantom made of iodine, water and barium. The objective of this work is to present an optimization model that includes both theoretical modelling of general behaviour of detector and empirical detector-specific characteristics (noise, spectral resolution, counter depth) in order to refine predictions when using PixieIII detector. Also, the model aims for as few constraints as possible while simultaneously optimizing source voltage and current, both energy thresholds, and predicts if it is better to use KES imaging or conventional absorption imaging for the considered sample. This paper is structured as follows. The first section presents the main equations of the model. Then, the second section is dedicated to the materials and methods for the various empirical studies that are shown: characterization of the energy resolution in terms of absorbance spectra, noise parametrization, model resolution and validation and application example. The third section presents the results of these studies which are discussed in the fourth section.

Generality
The objective of the model is to help the operator to choose configuration parameters based on the sample he wants to image and the objectives of the acquisition. Given the materials and to be contrasted in the sample, with respective densities and , the model predicts the source voltage , current , the two detector energy thresholds ( and ) and the modality to use (absorption or KES imaging) in order to achieve the highest Contrast-to-Noise Ratio (CNR) on the obtained radiographs. Actually, current and exposure time have equivalent influence on the variable of interest, namely it acts on the number of incoming photons during exposure. Here the reasoning is done talking with current only for simplicity, thinking exposure time as fixed. But the current variable could then be thought as the product of current times exposure time or exposure while keeping current fixed without modifying the conclusions. The objective of the model is represented by the function in the equation 2.1.
In the context of computed tomography, [16] showed that optimizing CNR for radiographs is close to optimizing on reconstructed images. Thus, we focused in predicting CNR on radiographs, and to perform optimization of 5 parameters, as shown by relation 2.1, including the two energy thresholds are optimized. The metric to evaluate CNR for a given modality MOD is defined as the difference of mean signal between material and divided by a standard deviation representing noise computed on the image with that modality: Where represent the image obtained with the modality MOD (absorption or KES) for material m, · stand for mean of pixel values over a representative region of Interest (ROI) and is the mean of the standard deviations measured for material X and Y. The absorption image and KES image are combinations of raw images. In that section we derive the expression of absorption contrast and noise standard deviation as well as KES contrast and standard deviation from the mean and the standard deviation of count levels of acquired images.
For both modality, raw data consists of an image Ω 0 taken without the sample, and a sample image containing a set Ω of pixels filled with material and a set Ω of pixels filled with material . Ω in these notations refers to the energy range Ω 1 or Ω 2 over which these images are formed. The input flux on the detector at a given energy will be denoted 0 ( ). Assuming random noise as unique source of dispersion, the image without sample is flat with a mean counts given by for the image with the sample, the mean count is for pixels of a sample image filled with material ∈ { , }. Here ( ) refer to the absorbance of material and is given by : Where ( ( )) is the imaginary part of the refractive index ( ) at energy for material with density and thickness . ℎ is the Planck constant and is the speed of light. The refractive index ( ) is taken from xraylib database [18], which gives data with 1 keV spectral resolution.
Since in practice the flat image is an image acquired with high statistics in order to correct for systematic dispersion of the gray levels, dispersion of values on flat image will be assumed negligible in comparison with the one of sample image, which standard deviation will be noted Ω , evaluated in Ω .

Absorption modality
Let us start by establishing the expression of the contrast and noise for absorption modality. The absorption image is obtained by dividing the sample image with the flat image. The absorption, gathering counts obtained with both registers of Pixie III detector, counting over Ω 1 and Ω 2 respectively, will be expressed by Note that as Pixie III is a photon counting detector, with energy discriminating thresholds so that images without X-Rays should be (and are in practice in our tests) perfectly dark, so there is no need to correct from any dark levels as it may usually be done with charge integrating detectors. The mean may be obtained by Taylor expansion [19] of a bivariate function for the ratio function, to give : as Var( Similarly, assuming (low noise in flats compared to sample images), allows expressing the associated variance as: Then, the CNR for absorption modality is computed as: is the mean of standard deviation of absorption image computed between pixels filled with materials and respectively.

KES modality
KES image may be defined as Following similar assumption than the ones used to obtain equations 2.7 and 2.8, one obtains: where i=1 or 2. Then, using Taylor expansion at first order of the log function [19], one may estimate: and Var log and Var( ) = Var log Thus, the CNR for KES modality may be expressed as: . Equation 2.9 and 2.17 give expression of CNR computed from input spectrum 0 ( ), gray level Ω for both material and noise Ω on raw data. These quantities, specific to the hardware used, can be seen as hardware configuration parameters of the model, and the method we used to obtain them will be described in section 3.

Materials and Methods
In this section, we first present the hardware used in our case and the test sample. Then, we describe methods to model or obtain empirical parametrization for 0 ( ), Ω and Ω . Last we present: the optimization scheme, the method for validating the model, and finally the description of an application example.

The hardware: source and detector
For all acquisitions, we used a microfocus reflection source (HAMAMATSU L12161-07, Hamamatsu, Japan) with tungsten anode and operated with an acceleration voltage of 50 kV.
The detector consisted in a PixiRad2-PixieIII, a photon counting detector with energy discriminating capabilities. The detector is made of 2 PixieIII module tiled side-by-side and made from a 750 µm thick CdTe crystal bonded to a processing ASIC. This offers a grid of 1024x402 squared pixels of 62 µm. The detector offers two thresholds -that will be named low threshold, at energy and high threshold at energy -associated with two 15 bit counters, this enabled to acquire 2 images, on two distinct energy bins simultaneously. The so called low-energy counter counts photons with energy in range Ω 1 = [ , ] while the high energy counters count photons with energy in range Ω 2 = [ , ∞). The detector has the specificity to offer 3 levels of correction of charge sharing at the hardware level. Throughout this article, the detector was operated in NPISUM mode, which corresponds to the finest level of correction of charge sharing, and corrects both the number of counts, and the energy of the interaction events ( [13,20,21]).

Test sample
To develop the absorption model and to evaluate its performance, we used a phantom sample made with three capillary glass of 1 mm of inner diameter and 1.5 mm of outer diameter, filled with a solution of 0.3 g/cm 3 of KI, barium sulfate a solution of 0.46 g/cm 3 of BaSO 4 and distilled water for reference (figure 2).

Source model
In the expressions 2.3 and 2.4, one needs to evaluate 0 ( ) over the considered energy ranges. There are basically two possibilities for that: using simulated spectrum or an empiric one. We used SpekPy( [22,23] to simulate the input spectrum that illuminates the sample. This model simulates tungsten anode reflection sources, at desired voltage and current and any source-detector distances. Alternatively, we can also obtain an input spectrum by doing a threshold scan with Pixie-III (i.e., acquiring flat images with increasing threshold value and then differentiating successive images to obtain a spectrum).

Absorption model
In order to evaluate the mean counts in the sample image Ω , one needs computing the absorbance spectra ( ) for any energy . As described in the section 2, this is basically done using xraylib. However, due to finite resolution of the detector, the measured K-edges are smoother than the tabulated values. In order to take into account that effect, we measured absorbance spectra with the phantom sample (figure 2). Images with and without the phantom were acquired with the detector using the low register only with varying from 15 to 50 keV by steps of 1 keV. The mean number of count per pixel for images without the sample ranges from 20 000 for =15keV to 500 for = 40 keV. Then, successive images were differentiated to obtain the number of counts per energy bins of 1 keV width. For each energy bins, the image with the sample was divided by the image without the sample, and the opposite of the logarithm of the result was computed to obtain spectral image series of the absorbance. For each of the three tube, a mean spectrum was computed as the mean value over an ROI consisting of a column of pixel in the centre of the tube so that the thickness of solution correspond to the tubes' diameter. Finally, the spectrum obtained from the water tube was subtracted from those obtained from the iodine and barium tubes in order to remove contributions from the glass tube and water. This results in the absorbance spectra ( ) and 4 ( ) of iodine and barium sulfate respectively.

Noise model
The last part of the model is the prediction of the standard deviation Ω that one can expect on the acquired images.
As mentioned in the introduction, previous papers ([ [14][15][16]) focused on modelling Poisson noise from the source, we will now focus on the noise arising from the acquisition procedure as a function of threshold values. To that purpose, we acquired a set of images without sample, taking all possible combinations of thresholds, between 25 keV and 46 keV by step of 1 keV and using the low energy register, i.e. counting photon in range [ , ]. For each combination of threshold, 50 images of 1s of exposure time were taken.
Then we processed the data as follows: for each combination of thresholds, a flat field corrected image was obtained by dividing the first image of the series of 50 images by the median of these 50 images, and the resulting image is then multiplied by the mean value of the median image. This correction permits to compensate the dispersion of the gray values arising from the inhomogeneity of the beam and pixel to pixel systematic variations. Therefore, the dispersion of gray levels is mainly due to noise, so that the image fit the assumptions of the model described in section 2.
Pixel with a zero value in the median image were labelled as defective. Then, for each combination of thresholds, mean count level and standard deviation were computed on a ROI of 1850 pixels (370x5) of the flat-field corrected image, discarding defective pixels. Then, from this dataset, the relations between , and the two thresholds and were studied and parametrized. Results of this analysis will be found in section 4.2.

Optimization
Given the output of the source, the absorption and the noise models, it is possible to evaluate the CNRs for both modalities from configuration parameters using the expressions 2.9 and 2.17. Now, it remains to specify the procedure to find the optimum and the associated constrains.
The procedure is detailed in algorithm 1. As a first implementation, the principle is exhaustive, i.e. it consists in evaluating CNRs for both modalities at all points of discrete search ranges Ω (for voltage), Ω (for ) and Ω (for ). Optionally, during the computation of CNRs, the current is set so that a prescribed count level is obtained on the detector when the sample is out of the beam for each set of voltage and thresholds.
Then, raw images mean counts Ω and Ω 0 , and noise and raw images Ω are estimated. From these variables, CNR for both absorption and KES modality are computed. Once these computations for all combinations of source voltage and detector thresholds are performed, the best configuration is extracted by searching for the maximum CNR obtained. ) for highest CNR.

Validation of the global model
In order to evaluate the model, we compared predictions in terms of voltage and thresholds to empirical optimization performed on a test sample by evaluating K-edge CNR for all combination of thresholds in given ranges. The dataset was obtained using the phantom sample described in section 3.2. This sample allows testing the model on three contrast pairs : I/BaSO 4 , water/BaSO 4 and water/KI. For that acquisition, the source was operated with 50 kV acceleration voltage, a target current of 14µA, exposing for 1s at an SDD = 281.12 mm, and SOD = 25.08 mm, thresholds varying from 25 to 45 keV by step of 1keV. For each couple of low and high thresholds within that range and for each energy bin, 50 beam images were acquired and 2 images of the sample were taken. The images were averaged in order to get one beam image and one sample image per couple of thresholds from which KES images were computed. Then, CNR was computed from mean count level and standard deviation measured over ROIs focusing on each material. The ROIs were made of 3600 pixels (360x10) centred on their corresponding tubes. While the 10 pixels width implies a heterogeneous thickness of tube crossed by the X-rays, it is necessary to get sufficient statistics. In parallel, the simulation of that problem was performed using the model presented in the previous section. The results of this validation are presented in section 4.3 first in terms of the intermediate variable Ω and Ω and then in terms of CNR and optimal configuration.

Application example
In order to illustrate the application of the model, we show the optimization results with BaSO 4 and KI, fixing the density of BaSO 4 and varying the density of KI.
The materials whose contrast has to be optimized are 1 mm of BaSO 4 at 0.46g/cm 3 , and 1 mm of KI at density in range [0.1g/cm 3  The spectra measured with the detector are the light blue solid curves in figure 3. The tabulated spectra obtained using xraylib are displayed in orange dashed line. As one can see, the position of the K-edge measured by the detector is correct, as well as the global evolution of the absorbance. However, one need to account for the spectral resolution of the detector which is necessarily finite and lead to a smoothing of the edges, which is then not measured as a strict vertical edge. This is done by applying a Gaussian smoothing with a 1.8 keV kernel. This value was chosen in order to reproduce the experimental slope of the edge. The result is represented by the red dashed line in figure 3. As one can see, the resulting spectra are really close to the measured one. In the model, smoothed value of ( ) (eq. 2.5) are used to compute Ω terms.  Figure 4 shows the variation of the relation between mean count level and standard deviation when varying mean energy = 0.5 * ( + ) and energy gap width = − . As one may see, the relation between noise and input flux is dependent on the values of the thresholds. In order to investigate that dependence, we modelled the measured noise as being the beam intrinsic noise (proportional to the square root of the input flux) affected by a prefactor Γ that may depend on the thresholds values and possibly the mean count:

Noise model
Representing the intrinsic noise by = √ (thus letting the proportionality factor in the prefactor) permits to compute the prefactor with: This quantity is represented in figure 5, as a function of , for eight values of , and colour corresponding to . One can see a first dependence of with and/or : increases with while decreases. For the following, we made the assumption that this dependence can be described by only as the experiment is performed without filter on the source so that it is expected that the mean count decreases with the bin mean energy. This point will be discussed in section 5. Additionally, a clear dependence can be observed on : points of different size appear to align along different curves. An interpretation of this effect in the context of a photon counting dector will be discussed in section 5.  In order to parametrize that dependence, the left panel of figure 6a) present the evolution of the prefactor against mean count for different fixed (dots). From the evolution, to describe the relation between prefactor Γ, and we propose a function of the form: where and are fitting parameters (amplitude and characteristic Intensity) that depends on the gap with . This shape has been fitted on the data point using least square optimization (solid curves on panel a)) and the evolution of the fitting parameters , and against are displayed on panels b) and c) of the figure. Evolution for is monotonically decreasing. is approximately increasing up to a given value then does not evolve. In fact, from left panel, one see that for largest gap width, the prefactor depends on I only for really low count rate. Thus, we suggest parametrizing those evolutions with a decreasing exponential shape for and a piecewise constant function for . Least square fitting of these shapes gives:

Validation of the global model
As the model consists in different sub-models, let us first compare some intermediate variables to evaluate these different sub-models. Panels a), b) and c) of figure 8 compare Ω 1 , the mean gray level on the ROI focusing on KI tube measured on the low energy register; d), e) and f) Ω 1 , the standard deviation measured on that same ROI and low energy register. We can see that for both variables, simulated values are close to the experimentally measured ones (igure 8c) and f) ). The shapes of the maps of these variables are respected, and quantitatively, the value are globally well respected, particularly where and the number of counts are highest. For getting close to 1, the error increases and the ratio of simulated values over experimental one is globally about 5-6.
Then, we compare KES CNR maps with respect to the two threshold values (see figure 9). Optimal configurations were then defined as the maximum of these CNR maps. The empirical optimum is represented by the red dot and the simulated one by the red cross. Additionally, we represent the value of the corresponding K-edges by black dotted-dashed (for I) and dashed (for Ba) lines.
Let's begin the comparison with the top row, i.e. for the BaSO 4 /KI contrast pair (panels a) and b) ). The general shape of the modelled map is close to the shape of the experimental one. From top right to bottom left: CNR is low for any configuration with both threshold above both K-edges, a principal maximum is reached for low thresholds between both K-edges, and high threshold above Ba K-edge. A secondary maximum is found at the bottom left part of the map where both thresholds are below both K-edges and a narrow "valley" of minima separate both maximum.
Quantitatively, values for the predicted and measured optima for the three contrast pairs are given in table 1. For the BaSO 4 /KI pair, the model predicts an optimum at (33 keV, 40 keV) with a CNR of 0.4 while the empirical optimum is (34 keV, 40 keV) with a CNR of 3.1. The secondary maximum for model and experiment is respectively about 0.3 and 0.4. The maps of BaSO 4 /water or KI/water CNR exhibit simpler shapes as the K-edge split the map in 3 area: Both maxima are reached with low thresholds clearly below the K-edge and high threshold at the K-edge value and CNR get low values and even vanishes if both thresholds are above (upper right part) or below (bottom left part) the K-edge. Quantitatively, for BaSO 4 /water contrast, the model predicts an  optimum at (27 keV, 38 keV) with a CNR of 0.6 where it is (34 keV, 39 keV) with a CNR of 3.0 for the experiment. For KI/water contrast, the model predicts an optimum at (25 keV, 33 keV) with a CNR of 0.5 where it is (29 keV, 34 keV) with a CNR of 0.9 for the experiment. The quantitative differences between model and experiment described in that section will be commented in section 5.
For a qualitative assessment of these results, figure 10 shows images obtained a) with conventional approach, using the images from the high energy register with = 26 keV (1 phantom images and 50 flat images for flat field correction) b) KES image obtained by procedure described above at the predicted optimum for BaSO 4 /KI contrast, i.e. =33 keV, =40 keV, c) KES image at empirical optimum for BaSO 4 /KI contrast, d) KES image at the predicted optimum for BaSO 4 /water contrast, =38 keV and e) KES image at the empirical optimum for BaSO 4 /water contrast. Two observations can be made: i) KES imaging permits to considerably increase the contrast between KI and BaSO 4 , even removing water and glass capillary tubes from the image, and ii) KES images obtained at predicted and empirical optima are visually very close. Figure 11 shows the evolution of the absorption and KES CNR computed from equations 2.9 and 2.17 respectively for varying density of KI with fixed density of BaSO 4 . As one may see, the modality to obtain the highest CNR is not necessarily KES: it depends on the concentration of the materials. KES is recommended for density of iodine in range [0.24 g/cm 3 , 0.37 g/cm 3 ] and absorption is recommended elsewhere. The curve for absorption can be split in two parts: a first decreasing and a second increasing with iodine density. The plots a) to d) of figure 12 display the optimal choice of thresholds for both modality (represented by vertical dashed lines: blue for absorption and red for KES) in relation with the absorbance spectra of the two material (solid curves: orange for barium, green for iodine) as well as the optimal voltage (black solid vertical line) which was found to be 50kV for all configurations. Each of these plots corresponds to different densities of iodine represented by vertical dashed line on figure 11.

Discussion
In section 3.5, we assumed that the dependence with and/or can be described by only. To check that it would be interesting to reproduce the experiment with varying the source current so that varies while E does not. However, as seen in section 3.7, errors on arise mainly from variations of E , so this assumption appears consistent with the accuracy of the model. Also, noise   level not only depends on the mean count but also on . We suppose that this effect might be due to finite spectral resolution of the detector: Ideally, when a photon interact with the detector, it should be counted if and only if its energy lies in the energy bin defined by threshold values, i.e. the evolution of the probability for a photon to be counted presents a jump from 0 to 1 at the thresholds values. However, in practice, that probability evolves smoothly over a finite energy range centred on the thresholds values. As a result, some photons with an energy lying in that transition range may be badly counted. This results in an additional noise which increases with decreasing the gap width, as the proportion of badly classified photons increases (since the mean difference between photons energies and threshold value decreases).
Additionally, it has to be precised that the version of the PixiRad2-PixieIII we own exhibits a salt and pepper noise when used in NPISUM mode (see figure 10) not mentioned in previous papers. This artefact is not a normal behaviour of the detector, but should be linked to errors showing up randomly in the 15bit counters of the detector. A first consequence of this, is that the current noise level is particularly high and globally the CNR values described above somewhat underestimate the performances the technology has to offer. In the future, this extra noise is brought to disappear with the resolution of this issue, thus the noise model will need to be updated. However, the current dependencies described by that model (on the mean count level and for the low energy register) are explained on the basis of other phenomenons intrinsic to the detector technology. Thus, we may expect that the current shape of the noise model is not affected by this artefact. Without that noise artefact, one may need to re-adjust the parameters of the parametrization by reproducing the exposed experiment, seeing it as a calibration procedure of the current model.
As described in section 3.7, figure 9 a) and b) shows 2 maxima for the BaSO 4 /KI pair. Keeping in memory that KES signal measures the variation in absorption between the two energy bins, the principal maximum corresponds to the Ba K-edge as this implies strong variations of absorption for BaSO 4 while moderate ones for KI. The secondary maximum can be understood by seeing the KES CNR as the difference of absorption CNR between the two energy bin. This maximum corresponds to a configuration where the high energy bin includes both K-edges so that the absorption CNR between both material on that energy bin is low. It remains that the KES CNR in that configuration is made only from the absorption CNR on the lower energy bin which focus on the monotonically decreasing part of the spectrum. The minimum between these maxima corresponds to a configuration where the lower energy bin is centred on the lower K-edge and the higher energy bin on the highest K-edges. In that configuration, the contrast vanishes : for each bin absorption is stronger for one material on the first part of the bin, and stronger for the second material in the second part of the bin so that absorption CNR is low on both energy bin. Then, the application example illustrates how the proposed model allows to take into consideration different strategies and put them into balance. In that particular case, the best modality predicted by the model depends on the density of KI.
To explain these variations, let us focus on the absorption first: blue solid curve on figure 11, and blue dashed line on figure 12. For low KI density, BaSO 4 has the highest contrast, and the difference is at its highest above Ba K-edge, the strategy for point a) and b) is then to focus on that part of the spectrum (E 40 ) and choosing the high threshold so both detector count as much as they can (i.e. is set so that CL is reached on both detectors). As the iodine density increases, the spectral contrast above the Ba K-edge reduces and gets inverted (iodine more absorbent than barium) between the two K-edges. This explains why the absorption CNR decreases with iodine density up to 0.3 / 3 . At this point, the best strategy for absorption modality becomes to focus on the part of the energy domain where KI is the most absorbent. Then, the thresholds are set so that the low energy bin focus on the part where iodine is the most absorbent. From here, since the CNR is built from the fact that KI is the most absorbent, the absorption CNR keeps increasing with KI density. Now let us focus on the KES modality illustrated by red solid curve on top panel, and red dashed line on a)-d) panels. The strategy for KES is to focus the low energy bin on the part between both K-edges, and the high energy bin above the Ba K-edge. One may notice that the curve for KES CNR is much flatter than for the absorption one. This may be an interesting fact to ensure an acceptable CNR for example a sample containing areas with variable density of KI or unknown composition.
The presented model allows reproducing qualitatively well the variations of CNR with energy thresholds of the detector . Particularly, the shapes of the maps on figure 9 are correct, and the predicted optimum is quantitatively correct for the case where KES imaging is the most relevant. However, noticeable errors remain. Both flux and noise standard deviation on detector after going through the materials show increased error for small energy bins (i.e. for and close). As the mean intensity is used by the noise model to estimate the noise standard deviation, it is expected that the error seen in Ω propagates in Ω and at the end in the computed CNR. The errors seen on Ω originates from the input flux model Ω 0 ( ) and sample absorbance model ( ). Additionally, the CNR computed in the section 3.7 appeared underestimated up to a factor 10 for KI/BaSO 4 contrast. This quantitative errors may have several explanations: • The exposed results demonstrate the performances when used without prior empirical knowledge of the other elements from the imaging chain, i.e. this demonstrates the minimal performance of the model. The results may be improved if one has i) empirical source spectra Ω 0 ( ) ii) empirical absorbance spectrum of the samples ( ). Both these spectra may be measured using Pixie-III by performing a threshold scan.
• As it has been shown in section 3.5, the noise depends on both mean counts and thresholds, i.e. it shows a spectral sensibility. However, although the developed noise model fits well to the data for images without the sample, the terms Ω are computed taking into account the effect of the sample on the mean counts only, but not on the spectrum shape. Thus, it may happen that the parametrization does not give accurate estimations for those terms, particularly when is small. This would be a point to be studied in finer details.
• The ratio Ω Ω ranges from 1 to 5 in the validation example, and is about 1.2 for the coordinates of the optimum. Additionally, the specific salt and pepper noise described at the beginning of that section is made of values far from the mean. For both reasons, the presented Taylor expansions may not hold. For example, experimentally, in eq. 2.14, the first order term (second term in the right-hand side) represents 0.17 times the zero order term, which is not completely negligible yet.
From figure 9, particularly for BaSO 4 contrast, one can see that the model predicts a wider low energy bin than the one found experimentally (lower ). Taking into account the efficiency of the detector may improve that aspect. Indeed, at the moment, the estimation of the mean counts does not take into account detector specificities : such as efficiency and linearity. It is anticipated that the efficiency decreases significantly for energy above the Cd and Te K-edges (26.7 keV and 31.8 keV respectively) since part of the incoming photons leads to fluorescence. The bin width results from a trade-off between KES signal and statistics. Thus, in practice, energies just below the sample K-edges are under-weighted in the measurement of the absorbance on the low energy bin in comparison to the lowest energies of that bin. The absorbance measured on that bin is then larger than expected (as spectral absorbance is monotonically decreasing below the K-edge) and thus the KES signal is reduced. As a consequence, this pushes to take narrower low energy bin in order to compensate that loss of KES signal. The optimum is then moved towards higher value. This effect should increase with the K-edge energy of the sample as the efficiency decreases, this is actually the case when comparing KI/water optima to BaSO 4 /water optima: the error on is higher for BaSO 4 /water than for KI/water. Additionally, this effect is not observable for the KI/BaSO 4 as in that case the trade-off is to not mix KES signal from both K-edges as they would annihilate each other. In that case, both model and experiment results in taking just above the lower K-edge.
Finally, the optimization procedure described by algorithm 1 is quite simple. One may consider developing it into a refined procedure by adding some constrains on the product exposure time times source current intensity. Indeed, when asking a count level CL in the image, the algorithm adapt that product to reach that level. In practice both parameters are limited. The source is physically limited by the design of the source and the exposure time is in practice limited to get a reasonable acquisition time or by the need in time resolution for in-situ experiment for example. Additionally, one may include additional modalities in the comparison. For example, it would be straightforward to consider the absorption image obtained uniquely on the low energy bin. This would consider an absorption modality where some low and high energies are ignored. This may be interesting for a case like the one depicted in figure 12.b where the contrast is mainly due to the absorption difference in the low energy bin. Since the high energy image is contrasted in the opposite manner, summing the counts from both energy bins finally reduces the global contrast.

Conclusions and perspectives
We designed a model that estimates CNR of both absorption and KES modalities for Pixie III photon counting detector. The model optimizes the setup parameters : voltage U, the product exposure time times intensity, thresholds and and acquisition modality (conventional absorption or KES). The model can be divided into sub-models that can be used and improved independently. Particularly, we have presented: • A noise model, that evaluate the standard deviation of count levels on a representative ROI of homogeneous material. Besides accounting for intrinsic Poisson noise which evolves as the square root of the mean intensity, the noise model includes an empirical parametrization of Pixie III that reveals and takes into account a specific behaviour of the detector for small gap with . The resulting parametrization reproduces quantitatively the data.
• A noise propagation model that evaluates CNRs for absorption and KES modalities on the projection image at the end of the processing chain.
Computationally speaking, the model reduces to simple operations on spectral integrals which lead to instantaneous computations. The optimization consists in an exhaustive exploration of the space of acquisition parameters given a desired count level on the images. The output typically consists of maps of CNR in the space of acquisition parameters. Confrontation with experimental exploration of the parameters shows that the model reproduces well the shapes of the maps. The prediction in terms of thresholds compares within few keV with experimental. Globally, the model tends to predict lower threshold values than the ones suggested by experiment. Quantitatively, the error tends to increase with small energy bins. Additionally, it has to be kept in mind that the detector currently in our possession suffer from a random noise artefact. That should not impact the predicted optimal parameters, but may require recalibration of the noise model for quantitative predictions. Finally, it has been illustrated how the model enables to compare different strategies to enhance the contrast and how it allows understanding the underlying trade-offs the operator has to make.
Additional improvements may be considered to improve this model. This includes: • to push forward the noise model by taking into account the effect of sample on the spectrum of the X-ray beam.
• to account for linearity and efficiency of the detector. Particularly, this would improve the predictions for sample with K-edge above CdTe K-edges.
• to design more advanced resolution algorithms, this includes : additions of derivate modalities in the comparison, constrains on the space of set up parameters, computational improvement of the optimization scheme.