Maximizing the Accuracy of Continuous Quantification Measures Using Discrete PackTest Products with Deep Learning and Pseudocolor Imaging

Using the standard colors provided in the instructions, PackTest products can approximate and quickly estimate the chemical characteristics of liquid samples. The combination of PackTest products and deep learning was examined for its accuracy and precision in quantifying chemical oxygen demand, ammonium ion, and phosphate ion using a pseudocolor imaging method. Each PackTest product underwent reactions with standard solutions. The generated color was scanner-read. From the color image, ten grayscale images representing the intensity values of red, green, blue, cyan, magenta, yellow, key black, and L∗, and the values of a∗ and b∗ were generated. Using the grayscale images representing the red, green, and blue intensity values, 73 other grayscale images were generated. The grayscale intensity values were used to prepare datasets for the ten and 83 (=10 + 73) images. For both datasets, chemical oxygen demand quantification was successful, resulting in values of normalized mean absolute error of less than 0.4% and coefficients of determination that were greater than 0.9996. However, the quantification of ammonium and phosphate ions commonly provided false positive results for the standard solution that contained no ammonium ion/phosphate ion. For ammonium ion, multiple regression markedly improved the accuracy using the pseudocolor method. Phosphate ion quantification was also improved by avoiding the use of an estimated value for the reference solution that contained no phosphate ion. Real details of the measurements and the perspectives were discussed.


Introduction
PackTest products, like test strips, qualitatively indicate chemical characteristics of liquid samples. PackTest products are cost-effective, convenient, quick, easy to use, safe, and have minimal waste and thus are highly feasible to use. ere are some ten PackTest products (http://kyoritsu-lab.co.jp/ english/). Each product contains dry reagents in a handy, flexible, and elastic semitransparent plastic pack. By pressing the pack to purge the air inside and submerging the pack edge in a liquid sample, the plastic pack takes in the sample liquid from a small hole at the edge of the pack. e reagents react with the chemical to be detected. e reaction generates visible coloration of the entire reaction system in the plastic pack [1]. us, the user can visually observe if there is a particular chemical in the liquid sample. e products were originally designed for quick and approximate detection of chemicals, and thus, they are considered to be qualitative or semiquantitative analytical tools. For qualitative or semiquantitative detection, users refer to a series of standard colors that show the approximate concentration of the chemical in question, which generates a color after the chemical reaction. Because of the feasibility, PackTest products may be widely used in various places including secondary schools [2] and field sites with environmental issues [3].
By referring to standard colors, PackTest users find the closest value that is represented by a standard color. For this reason, PackTest was originally a tool with discrete measures for the chemical characteristics. However, recent studies indicated the possibility that the PackTest products can be tools for accurately and quantitatively determining the chemical characteristics of liquid samples [4]. ese tools can be used with continuous measures provided by computation such as regression. e continuous measures can solve the difficulty in determining the closest value when a sample color nears the midpoint between two standard colors [5]. Another reason that continuous measures are preferred is that accurate quantitative determination of chemical characteristics is more advantageous than qualitative detection. An example is the critical effects of blood biochemical characteristics at low levels [6]. Improving the accuracy of PackTest products is expected to enable detection of subtle but significant signals [7]. Previous studies aimed to enhance the accuracy of the feasible tools such as test strips by determining the regression models that describe the chemical characteristics [8]. In addition to the regression techniques, deep learning tools are now commonly available.
Deep learning is especially advantageous for analyzing images. Deep learning was used to explore relationships between health and information that was derived from medical images [9]. Besides its application to image analyses, deep learning was expected to extract the patterns of color changes in the PackTest reaction mixture as responses to changes in the level of the chemical characteristics in question. Deep learning evolved from artificial neural network that was well established and used for quantitative determination of chemical characteristics [10]. Deep learning is relatively more tolerant to some limitations, such as overtraining, which more significantly affect artificial neural networks. Recently, freeware for deep learning was launched. To the best of my knowledge, few studies have involved deep learning for quantification of chemical characteristics.
Based on the above background, this study was conducted to apply deep learning to quantify chemical characteristics of liquid samples. ese characteristics were chemical oxygen demand, ammonium ion concentration, and phosphate ion concentration. Standard solutions with multiple levels of the chemical characteristics were prepared. Coloration was generated by introducing the standard solutions to the PackTest products. e colored pack was optically scanned. e color image was used as the starting material for 83 grayscale images to enhance the information [4]. e grayscale intensity values for selected pixels that indicate the chemical characteristics were read and used for deep learning. Validating the training results revealed that some chemical characteristics were very accurately quantified. However, for some chemical characteristics, the training was found to have problems. ese problems were, however, avoided when complementally techniques were used.

PackTest Products.
PackTest products for determining chemical oxygen demand, ammonium (NH 4 + ) ion, and phosphate (PO 4 3− ) ion (Kyoritsu Chemical-Check Lab, Corp., Tokyo, Japan) were purchased. PackTest is a series of products for determining the chemical characteristics of liquids (http://kyoritsu-lab.co.jp/english/). e product is a handy and flexible plastic pack that has a hole at the edge. e plastic pack contains a set of reagents that react with the chemical (characteristic) to be measured colorimetrically. After purging the air inside the pack using the hole, the pack edge is submerged in the sample liquid and the sample enters the pack through the hole. en, the chemical characteristic is approximately determined by referring to standard colors in the instructions that come with the pack. Chemical oxygen demand is detected by applying the principle of alkaline oxidation with potassium permanganate [11]. NH 4 + and PO 4 3− are detected using an indophenol reaction [12] and a molybdenum blue reaction [13], respectively. ) standard solution was introduced into the pack for phosphate ion detection. e phosphate ion kit contained a small plastic container to accurately take in 1.5 mL of liquid sample into the pack. e reaction took 1 minute at room temperature. e ammonium chloride standard solution was introduced into the pack for the ammonium ion (NH 4 + ) detection at 1.5 mL·pack −1 in a similar manner. e reaction took 5 minutes at room temperature. ree pack replications were used for each NH 4 + or PO 4 3− concentration.

Image Acquisition and
Processing. e coloration was read using an Epson GT-S 650 optical scanner (Seiko Epson Corp., Suwa, Japan) at 300 dots per inch in the professional mode.
e other settings of the scanner were set at the default. e scanner was placed vertically, and the colored pack was attached at approximately the center of the scanner's bed glass using scotch tape to prevent the solution from leaking out. e scanner lid, with a white plastic pad on the inside, was loosely closed. An image of the colored pack was acquired in the dark. e image was saved as a JPG file and then converted to a tag image file format file in the redgreen-blue (RGB) mode with the sRGB color space. 2 Journal of Analytical Methods in Chemistry Details of the image processing methods are described elsewhere [4,14]. With Adobe Photoshop CS2 software (Adobe Systems Inc., California, USA), the tag image file format image generated ten grayscale tag image file format images that indicated the grayscale intensity values for the color components of RGB, cyan-magenta-yellow-key black (CMYK), and the International Commission and Illumination's L * a * b * color models ( Figure 1). CMYK images were generated using the International Color Consortium profile of US Web Coated (SWOP) v2 for digital output such as color printing. Hereafter, these ten grayscale images will be called the original ten grayscale images ( Figure 1). An RGB yellow hybrid grayscale image was prepared by merging the R and G grayscale images at the same weights [15]. Similarly, RGB cyan and RGB magenta hybrid grayscale images were prepared by merging the G and B grayscale images and the R and B grayscale images, respectively.
To prepare a pseudocolor RGB image, the entire area of a B grayscale image in an RGB color image was substituted by the RGB yellow grayscale image. Hereafter, this image is called the RGyB image ( Figure 1). A pseudocolor RG-yB image was prepared by substituting the B grayscale image of the RGB color image with the black-white inverted RGB yellow grayscale image. Similarly, an RmGB pseudocolor image was prepared by placing the RGB magenta grayscale image onto the entire area of a G grayscale image of an RGB image. R-mGB, cRGB, and -cRGB pseudocolor images were also prepared and saved.
Pseudocolor images carrying two or three of the RGB cyan, RGB magenta, and RGB yellow hybrid grayscale images were also prepared ( Figure 1). For example, the G and B grayscale images of an RGB image were substituted with the RGB magenta and yellow hybrid grayscale images, respectively. Hereafter, this image is called the RmGyB pseudocolor image. Similarly, cRGyB and cRmGB pseudocolor images were prepared. By substituting the R, G, and B grayscale images of the RGB color image with the RGB cyan, magenta, and yellow hybrid grayscale images, respectively, a cRmGyB pseudocolor image was also prepared. e ten pseudocolor images were saved as tag image file format files. Each of the pseudocolor images was converted to CMYK and L * a * b * color images. Next, grayscale images that showed the intensity values of C, M, Y, K, and L * and the values of a * and b * were prepared from each pseudocolor image ( Figure 1). Hereafter, the C, M, Y, K, L * , a * , and b * images are referred to as the RGyB C grayscale image and so on. us, 70 grayscale images were added to the original ten grayscale images and the three hybrid grayscale images of RGB yellow, RGB magenta, and RGB cyan. A total of 83 grayscale images were obtained for each chemical characteristic. e grayscale intensity values for pixels representing the colors for the standard solutions were read by running MultiSpec version 3.4 for Windows (Purdue Research Foundation, Indiana, USA).
e intensity values were digital numbers between 0 (complete black) and 255 (complete white). Within a single pack image, ten replication pixels and five other pixels were selected as training and validation pixels, respectively. e pixels were selected in an image area with the least diffuse reflection. e grayscale intensity values for the selected pixels were read for the 83 grayscale images. Grayscale datasets based on the original ten (RGB, CMYK, and L * a * b * ) and all 83 images were prepared and compared in terms of accuracy of quantification of the chemical characteristics.
To train deep learning of relationships between coloration and chemical oxygen demand levels, the grayscale intensity values for the ten replication pixels × five packs × eight chemical oxygen demand levels, 400 pixels were used. Similarly, to estimate NH 4 + and PO 4 3− concentrations, the grayscale intensity values for the ten replication pixels × three packs × six (NH 4 + ) or five (

Deep Learning and Related
Techniques. Using a SONY neural network console 1.20 (SONY Corp., Tokyo, Japan), deep learning was performed. From the basic series of architecture, 10_deep_mlp.sdcproj was selected. e architecture consisted of five layers ( Figure 2). In Figure 2, Affine is a networking structure and Tanh is a process in which hyperbolic tangent-converts a value generated by the upstream processes to provide a converted value between −1 and 1. Sigmoid converts a value generated by the upstream processes to provide a sigmoid-converted value between 0 and 1. e last process of this architecture was Bina-ryCrossEntropy for binarization of the input data. However, in this study, it was substituted by SquaredError to minimize errors in the estimation of values. Eighty-three and the other values on the right side along the architecture diagram ( Figure 2) are the number of values inputted and processed in the layer. When values derived from the ten grayscale images were inputted, the first input number was ten instead of 83. e raw grayscale intensity values were divided by 255 before the values were processed by the architecture, as recommended by the manufacture's manual. For training and validation, ten and five grayscale intensity values were used for each plastic pack, respectively. e default settings were used in the training and validation except that the number of epochs was 3000. By confirming the discrepancy between changes in training and validation errors, overtraining was monitored.
To complement the quantification using the grayscale intensity datasets and deep learning, the author used the statistical software IBM SPSS Statistics V.24.0 (IBM Corp., New York, USA). e multiple regression model that most significantly describes changes in the chemical characteristic was identified using the stepwise method at the default criteria (p � 0.05 for inclusion and 0.10 for removal).
is may generate multiple regression models. However, those that consist of any coefficient with a variance inflation factor of ten or greater were eliminated because the coefficient was unreliable [16].
rough the above processes, the normalized mean absolute error [17] and coefficient of determination (R 2 ) were obtained as indicators of accuracy and precision, Journal of Analytical Methods in Chemistry 3 respectively. e normalized mean absolute error was determined as follows: normalized mean absolute error(%) � 100 × |estimated value − actual value| (number of used pixels/range of value) .
(1) e values of these statistics were compared among the best regression models for the datasets for the ten and 83 images to investigate the effects of pseudocolor imaging on the precision and accuracy of determining the chemical characteristics.
Another error statistic was used to confirm the reproducibility of the scanner-read color intensity values. e statistic called the coefficient of variation was determined as follows: e reproducibility was evaluated by reading the color intensity values for 30 selected Microsoft Office standard colors ( Figure 1) that were printed on white paper. Using the Epson GT-S 650 scanner, the colors were read eight times, and thus, eight RGB color images were obtained. Coefficients of variation for the intensity values of redness, greenness, and blueness were determined for the 30 standard colors.
To observe the performance of the 83 grayscale images that were used in this study, a color gamut [14] and the standard colors in Figure 1 were used. e color gamut and standard colors were provided by Microsoft Office 2016. e tag image file format image of the gamut and standard colors was used to obtain the colors' profiles by reading the grayscale intensity values for the 83 grayscale images. ere were 144 standard colors. In the gamut, 187 pixels were randomly selected. e grayscale intensity values were read for the 331 pixels in the 83 grayscale images. e intensity values for the 331 pixels × 83 images were used for principal component analysis using the IBM SPSS software. Figure 3 shows color development in the plastic packs. When visually observed, the colors were comparable to those in the instructions provided by the manufacturer, but the images obtained by the scanner were less colorful than those in the instructions. e semitransparency of the  plastic material may be at least partially responsible for the relative darkness. Based on the grayscale intensity values derived from the scanner-acquired colors, the chemical oxygen demand was accurately quantified (Figure 4). Training and validation curves overlapped well, and thus, there was no overtraining. e normalized mean absolute errors were 0.384% and 0.347% for the original ten and 83

Results and Discussion
images' datasets, respectively. e normalized mean absolute error was approximately comparable to the corresponding coefficient of variation [4]. From this viewpoint, the normalized mean absolute error was very small compared with those regarded as acceptable values of 10% in areas of analytical chemistry [18] or 5 to 10% in food chemistry [19].  e chemical oxygen demand has been determined using various methods. Some researchers developed sophisticated methods such as a flow chemiluminescence method [11]. Less complicated methods are colorimetry [20] and titration [21], which are more complicated and time-consuming than the current method.
us, the PackTest product for chemical oxygen demand could be an advantageous alternative for quantitative determination of the chemical oxygen demand.
However, based on the coloration, it should have been difficult to use this tool to its fullest because changes in color are complicated. Figure 5 demonstrates this complexity. When the intensity values for the pixels in the original ten grayscale images were investigated, no monotonic increase/decrease in chemical oxygen demand was recognized. ese complex patterns of color change as responses to changes in chemical oxygen demand of samples disabled the simple empirical description of chemical oxygen demand using a single color component of RGB, CMTK, and L * a * b * color models. Another difficulty was suggested. e intensity values for each color component at a single chemical oxygen demand level showed errors ( Figure 5). For example, the grayscale intensity values for the pixels in the B grayscale image ranged from less than 90 to 120. e scanner was investigated for its role in this difficulty. e minimum grayscale intensity values for the selected 30 Microsoft standard colors were 47 (redness), 32 (greenness), and 28 (blueness). e maximum values were 253 (redness), 243 (greenness), and 244 (blueness). e coefficient of variation (N � 8 scanning trials) ranged between 0.2% and 9.1% (redness), 0.3% and 9.0% (greenness), and 0.4% and 15.1% (blueness). e mean coefficient of variation (N � 30 colors) was 3.0% (redness), 3.9% (greenness), and 3.3% (blueness).
erefore, the scanner was demonstrated to have good reproducibility. A more likely source of the errors was an inconsistency in attaching the pack onto the scanner's glass bed. e pack was attached each time as consistently as possible. However, in the interface between the glass bed and the pack's surface, slight differences should have occurred. e differences among the replication color readings were thought to be responsible for the errors indicated by the raw grayscale intensity values in Figure 5. However, the deep learning architecture completely eliminated the errors in the training processes. According to Figures 3 and 4, a chemical oxygen demand value of 4 mg·L −1 or lower is detectable by combining the PackTest product and deep learning. A chemical oxygen demand of 4 mg·L −1 or lower is favorable for a fresh water trout subspecies of Oncorhynchus masou [22], which is an important fish species ecologically and as a foodstuff. e current combination of PackTest and deep learning enabled the accurate detection of low levels of chemical oxygen demand for water samples that were polluted at levels that were marginally critical for O. masou.
Quantification of NH 4 + that relied on deep learning was less successful than that of chemical oxygen demand ( Figure 6) although no signals of overtraining were observed.

Journal of Analytical Methods in Chemistry
For both the ten and 83 images' datasets, the normalized mean absolute error and R 2 were around 3% and 0.99, respectively. Regression coefficients were 0.953 (10 images) and 0.954 (83 images). ese values deviated from 1.0, which was considered to be a perfect match, shown as red oblique lines in Figure 6. e most critical part was that the pack containing no NH 4 + was shown to contain 35 µM NH 4 + . is indicates the possibility of a false positive result if users rely on deep learning and the other techniques that were applied in this study. Here, multiple regression markedly improved the precision, resulting in a smaller normalized mean absolute error of 2.34%. Overall, the regression was very accurate, with a coefficient of 1.001 and a constant of 0.000. e multiple regression model was as follows: where -cRGB a * and the other names of the grayscale images indicated the grayscale intensity values for the selected training pixels in the grayscale images. e variance inflation factor was 2.50 (-cRGB a * ) or less, indicating good reliability for the three coefficients. e grayscale intensity for the -cRGB a * images had a more significant linear correlation with the NH 4 + concentration (R 2 � 0.916) compared with the others for which the R 2 values were smaller than 0.460 (Figure 7). Although the R 2 value of 0.916 for the -cRGB a * grayscale intensity may seem to be large, it was much smaller than the 0.992 result for the multiple regression model ( Figure 6). is indicates that the multiple regression model was achieved using the combination of less linear variables as previously described [4].
In quantification of PO 4 3− , no signals of overtraining were recognized. However, the quantification had a similar problem to that of NH 4 + . e pack containing no PO 4 3− was indicated as containing a small but detectable amount of PO 4 3− (Figure 8). e normalized mean absolute error and R 2 were comparable to those for the NH 4 + determination ( Figure 6). A regression coefficient of 0.922 for deep learning with the original ten images' dataset was worse than that of 0.953 for NH 4 + determination by deep learning with the original ten images' dataset ( Figure 6). Unfortunately, multiple regression did not provide reliable results to improve the poor performance. However, these poor results could be circumvented by limiting the range of PO 4 3− concentration to be determined. e deep learningestimated values for 0 µM PO 4 3− were eliminated (Figure 8). Although the range of PO 4 3− concentration that the method can determine became 13.1 to 105 µM PO 4 3− , the error statistics were significantly improved. e 83 images' dataset improved the accuracy of the NH 4 + and PO 4 3− determination (Figures 6 and 8). Principal component analysis of color profiles based on the 331 pixels in the Microsoft standard colors and gamut is provided in Table 1. e table shows a data structure based on the grayscale intensity values for the 331 pixels in the     [4]. When a user of test strips relies on multiple regression, the different patterns revealed by the principal components were effective in determining the chemical characteristics by combining the best grayscale images that carry the best combination of patterns in the grayscale intensity [4]. In finding differences among color profiles of image pixels representing agricultural plots [24] or tropical forest canopies [25], the 14 grayscale images from the RGyB and RG-yB pseudocolor images together with the RGB yellow hybrid image ( Figure 1) generated minor but significant principal components. In this study, among the 15 grayscale images, nine had the highest loadings on the first principal component ( Table 1). us, the additional 58 grayscale images further diversified the data structure.
e Microsoft standard colors and gamut are thought to include more colors than the images of the agricultural plots and the forest canopies. e greater number of colors is also thought to have revealed the more diversified data structure.
Additionally, most of the grayscale images from the RmGB and R-mGB pseudocolor images had the heaviest loadings on the second or third principal component while none of them had the greatest loadings on the first principal component. is was fortunate because the grayscale images even more significantly added the unique information to the original ten and 15 grayscale images examined in previous studies [24,25]. e second and third principal components were comparable in importance compared with the first principal component, and many grayscale images derived from the RmGB and R-mGB pseudocolor images formed significant regression models in another study [4]. Additionally, the grayscale images derived from the cRGB and -cRGB pseudocolor images had the greatest loadings on the first or third principal component (Table 1). ese unique loading patterns indicate greater dimensionality of changes in pixel color in the Microsoft standard colors and the gamut revealed using the pseudocolor imaging method. RGB cyan, magenta, and yellow hybrid images were likely to broaden the dimensionality because these hybrid images had uniquely different loading patterns on the most significant three principal components ( Table 1).
Because of the high feasibility, PackTest products can be used to quantify the chemical characteristics of various liquid samples using optical scanners and other digital imaging devices such as digital cameras and colorimeters [26] combined with deep learning and pseudocolor imaging. e combination is applicable to solid samples and similar coloration-based tools including test strips. Examples of possible applications are eliminating difficulties in the positive or negative judgment of urinary creatinine [27], improving somewhat inaccurate description of plant biomass growth [28], and confirming the quality of foods [29] and various other materials. e application may be extended to analyses of samples in various places including laboratories, hospitals [30], schools [31], and homes [7], where the color reading-based tools can be easily introduced.

Conclusions
Accurate and highly feasible quantification of chemical characteristics of the liquid sample is possible using PackTest products. e SONY neural network console, as a free-ofcharge deep learning tool, was the first choice for processing the grayscale intensity values derived from color readings of the pack that showed a color as a result of the chemical reaction. Multiple regression revealed the possibility to be a substitute for deep learning when deep learning resulted in unsatisfactory accuracy. Another solution was to limit the range of levels/concentrations of the chemical characteristics to be measured. ese techniques to maximize the quantification accuracy are supported by enhanced information through pseudocolor imaging processes.
Data Availability e grayscale intensity data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest
e author declares that he has no conflicts of interest regarding this study.