Open Access Article
Xiangyu
Liu
,
Namita
Sharma
,
Aldrik H.
Velders
and
Vittorio
Saggiomo
*
Wageningen University & Research, Department of Agrotechnology and Food Sciences, Laboratory of BioNanoTechnology, Bornse Weilanden 9, 6708WG Wageningen, NL, Netherlands. E-mail: vittorio.saggiomo@wur.nl
First published on 1st October 2025
Computer vision has emerged as a fast and cost-effective method for reaction monitoring and determination of analytes. However, one of the drawbacks of computer vision in analytical chemistry is the reliability of color data, particularly in data acquired from real-time analyses, which may inhibit quantitative interpretation. This highlights the necessity for an effective validation method for data collected using computer vision. Here, we report a simple yet effective variable pathlength cell design that can help data validation in computer vision by exploiting the linear pathlength–absorbance relationship of the Beer–Lambert law. The performance of this novel variable pathlength cell is evaluated using a wide range of analyte concentrations. This variable pathlength cell design is versatile and can be fabricated using various methodologies and materials. This design, combined with computer vision, is compatible with flow chemistry and holds great potential for integration into automatic, inline quantitative analysis of reactions and analytical chemistry.
A color change indicates a physical change, such as a change in dissolution, or a chemical one due to a chemical reaction, complexation, supramolecular interaction, or other processes. Changes in color intensity represent changes in analyte concentrations. By employing cameras to record the color value and light intensity of the analytes, qualitative and quantitative chemical analysis can be further investigated.4,11 CVAC applications in monitoring analyte concentrations also depend on the Beer–Lambert law, A = εcl, where ε is the extinction coefficient, c is the analyte concentration, and l is the pathlength.12,13 Many Complementary Metal-Oxide-Semiconductor (CMOS) – based cameras, such as Digital Single-Lens Reflex (DSLR) cameras, webcams, and smartphones can easily detect color and light intensity changes.14 Those cameras record the color using a light sensor with a Bayer filter placed between the sensor and the lens. The popular RGB (red-green-blue) color system describes color through the three intensity values (for example in a 8 bit system those values range from 0 to 255) of red, green, and blue.11 Such intensity information can then be analyzed through image processing software such as ImageJ.15–19
Compared to traditional spectrophotometers, CVAC is cheap, field-useable, fast and scalable (taking a picture of multiple vials compared to a single UV-Vis spectra), making this technique useful in various analytical disciplines, including food, environmental science, and biology.20–23
Recently, CVAC has been applied as a non-invasive technique for studying solution mixing, determining concentration, and analyzing separation and reaction processes.2,3,24–29 Moreover, cameras can be easily added to robots to navigate laboratories and investigate chemical reactions.30–32
However, the reliability of the colorimetric data collected by CVAC can be affected by multiple parameters, e.g., light source, sensitivity of camera sensors, or lack of selectivity in the wavelength range due to the Bayer filters.11,13,33 Due to these factors, a notable challenge in CVAC applications is ensuring the reliability of colorimetric data. While taking a single picture of a flask, cuvette, or flow cell is easy, determining whether the absorbance falls within the linear response range versus concentration is a challenging task. In this case, with only one absorbance value, it is impossible to judge whether that value is reliable, thus following the Beer–Lambert law or not.
It would be useful to have a colorimetric internal validation to help define and validate a ‘window of linearity’ in which color can be linearly correlated to concentration. For this purpose, we must consider the Beer–Lambert law's physical parameters. Since the extinction coefficient (ε) is an intrinsic physical parameter, and the concentration (c) is difficult to change during inline measurements, the only way to validate the accuracy of data is to change the pathlength (l) and check the linearity between the absorbance (A) and the pathlength (l). These measurements can be done using commercially available cuvettes, usually ranging from 1 cm to 0.1 mm.
However, swapping cuvettes during a chemical reaction is tedious and time-consuming, and changing flow cell cuvettes during reactions in flow is impossible. The absence of prior knowledge about a specific analyte, reactant, or reagent further complicates the challenges of using a cuvette with a suitable pathlength.
We solved this challenge by devising a “variable pathlength” cell that can be used for internal data validation directly while recording the experiment, and its design can be easily adjusted for different detection ranges (Fig. 1). We designed this variable pathlength cell to be used both in static and flow modes. Using a single picture of the variable pathlength cell with the analyte of interest, it is possible to check the linearity of the absorbance over pathlength for each measurement of the linear threshold for analyte measurement using computer vision, allowing qualitative and quantitative interpretation of the data with respect to concentration measurements.
This new cell design not only helps identify the linearity threshold, it also increases the detection range using a fixed light source without modifying the camera settings. Using this triangular design, if the analyte concentration is too high to yield reliable data at a 10 mm pathlength, data from a shorter pathlength, such as 5 mm, can be used for quantification. On the contrary, if the concentration is too low or the camera is less sensitive, data from a longer pathlength can be used. This is achieved using a single picture, without diluting or concentrating the solution, or changing the cuvette during the experiments.
This approach gives continuous pathlength data points, compared to a single data point from a traditional cuvette or flow cell, which can be used as a straightforward internal data reliability verification method.
The absorbance linearly correlates with the pathlength according to the Beer–Lambert law. This means that, in a single picture, it is possible to detect whether the absorbance increases linearly with the length of the cell or not. As a result of this approach, a calibration curve could be established for monitoring the concentration changes inline and in situ.
As the proof-of-concept, we used [Ru(bpy)3]Cl2 for testing the variable pathlength cell. We first present the data acquisition and processing methodologies to illustrate how to use variable pathlength cell. Afterwards, we analysed the grayscale data and established a calibration curve of [Ru(bpy)3]Cl2 to validate the concept of variable pathlength cell. Eventually, we were able to maximize the dynamic range of variable pathlength cell by using split channels (red, green and blue) data.
The lens (FUJINON XC 15–45 mm F3.5-5.6 OIS PZ) was operated at its maximum focal length of 45 mm for minimal lens aberration and perspective distortion. The color determination setup is shown in Fig. 1(c), where the cell was placed on a LED light pad (model L4S, Huion, Shenzhen, China). The variable pathlength cell was covered with a cardboard box, which blocked the light from the surroundings. A mirrorless camera (Fujifilm XT30-i) has been used to take images of colored solutions, and all the images have been stored in 14 bit RAF format (A RAW format belongs to Fujifilm cameras). A 6 mL syringe was used to inject the solutions into the variable pathlength cell. 5 mL of deionized water is first injected into the variable pathlength cell (∼1 mL). A picture was taken as the blank, and the RGBref values e.g., transmitted intensity values R = 1885.6, G = 5524.3, B = 3837.6 (equal to R = 29, G = 86, and B = 60 in 8 bit scale) at 5 mm pathlength were used for calculating the absorbance value of the analyte ([Ru(bpy)3]Cl2). The details are described in the section below Image Processing and Quantitative Analysis. Directly after, the deionized water was removed from the variable pathlength cell. The measuring protocol for analyte was as follows: starting from low concentration, 5 mL of 1 μM of [Ru(bpy)3]Cl2 (colored solution) was manually injected into the variable pathlength cell, and an image was taken to obtain RGB values for further analysis (described in Image Processing and Quantitative Analysis). Subsequently, the rest of the colored solution was flushed out, and 10 mL of deionized water was injected to clean the variable pathlength cell. After flushing the flow cell with air, 5 mL of a higher concentration solution was injected. The measurement continued until the highest concentration (5000 μM) colored solution was reached. Measurements of visible spectroscopy (UV-Vis) were performed in a plastic 10 mm cuvette in a spectrophotometer (Shimadzu UV-1900, US) as a reference for checking the spectrum of the analyte.
After recording all the coordinates of the region of interest for all the images, a Python script was used to crop the images and extract the transmitted intensity value using the Python rawpy package (v0.25.0), as shown in Fig. S4. The transmitted intensity value of each pathlength in each channel can be obtained through ImageJ and further converted into absorbance value based on the Beer–Lambert law, using the formula
, where the Iref represents the reference RGB values obtained from the picture of the variable pathlength cell loaded with deionized water and I refers to RGB values obtained from the picture with analyte (colored) solutions. For example, for [Ru(bpy)3]Cl2 at 150 μM at 5 mm pathlength, we recorded RGB values of 1832.4, 4531.3, 1156.8, respectively. For calculating the absorbance at specific channels, we used the equation:
383 (214), 16
383, 16
383 would be:It is worth mentioning that one single picture was taken for each concentration. The data linearity of one picture was checked through non-intercept linear regression (eqn (2) in SI) using scikit-learn Python package (v1.5.1). If the absorbance versus pathlength is linear, it proves that the data obtained from the variable pathlength cell can be used to determine the analyte concentration. Furthermore, the linear regions within the data were identified by segmented non-intercept linear regression. The detailed procedures are illustrated in Fig. S5.
We initially computed the greyscale value to represent the intensity value by merging red, green and blue channels (eqn (3) in SI) and conducted segmented non-intercept linear regression to construct the calibration curve. Subsequently, we performed an analysis for each channel (RGB) to improve performance of variable pathlength cell.
We recorded pictures of [Ru(bpy)3]Cl2 solutions at different concentrations in the variable pathlength cell and determined the coordinates of the region of interest using ImageJ. A summary of the experimental cropped images (regions of interest) was shown in Fig. 3(a), and their corresponding absorbance values versus pathlength was plotted in Fig. 3(b). A version of this figure including error bars can be found in the SI Fig. S6(a). Herein, instead of a single data point from a traditional fixed pathlength cuvette, we can convert a single data point into multiple data points, and these multiple data points should increase with the increase in pathlength until nonlinearity is observed according to the Beer–Lambert law. Thus, the linear part of the data that follows Beer–Lambert law can be considered correct and validated. By this means, we can perform segmented linear regression to find the linear part of dataset, as shown in Fig. 3(c). And linear regions with coefficient of determination R2 value larger than 0.8 were identified within concentration curves from 25 to 150 μM. The linear regression coefficients (the slopes) derived from linear regression analysis in the linear region of each concentration curve represents the product of extinction coefficient and concentration of [Ru(bpy)3]Cl2. It should be noted that the camera sensor does not record a single wavelength like a spectrophotometer; it records a range of wavelengths based on the Bayer filter. Afterwards, a calibration curve was established by plotting regression coefficients versus concentrations in Fig. 3(d). The correlation between regression coefficients and concentrations was evaluated using the R-squared value (R2), which was found to be 0.99.
Therefore, the computer vision data can be validated by our variable pathlength cell, as the triangular cell geometry generates multiple absorbance data points that allow verification of compliance with the Beer–Lambert law. Afterwards, a channel-wise analysis was performed to explore potential enhancements in the variable pathlength cell dynamic detection range.
As cameras always record red, green, and blue values due to the design of the Bayer filter (Fig. S7), we performed an analysis for each channel, i.e., blue, green, and red. As shown in Fig. 4(a) and the version of this figure with error bar in Fig. S6(c), it was possible to detect the [Ru(bpy)3]Cl2 in the blue and the green channel, while the signal in the red channel was noise (for example a red value of 1907.6 compared to the reference red value of 1885.6 at 5 mm pathlength for 25 μM, giving a negative absorbance close to zero). According to the UV-vis spectrum of [Ru(bpy)3]Cl2 (Fig. S8), the absorption mainly occurs in the blue channel. Afterwards, the segmented linear regression results were summarised in Fig. 4(b). Interestingly, linear regions with R2 larger than 0.8 were identified within the concentration curves from 5 to 100 μM in the blue channel, from 50 to 250 μM in the green channel, respectively. And the R2 values for calibration curves in blue and green channels are 0.99 and 0.94, respectively (Fig. 4(c)). Following this approach, if nonlinearity dominates one channel, the other channels continue to demonstrate rigorously maintained linearity. Thereby, the dynamic detection range of the variable pathlength cell can be expanded.
However, the blank transmitted intensity values in blue, green and red channel are around 3923, 5670 and 1919, respectively (Fig. S6(d)). Those intensity values are far away from the maximum 16
353 intensity value in a 14 bit image. A better camera (sensor), a higher intensity light source, or proper adjustment of camera settings to make the blank value close to 16
353 may help improve the dynamic detection range and accuracy of the concentration determination. It is worth noting that the data acquisition and validation can be simultaneously performed within one picture by using a variable pathlength cell. Once no linear region was found while performing segmented linear regression, the camera settings can be adjusted for better data quality. For example, lower ISO and higher shutter speed for high concentration analyte solution, or high ISO and lower shutter speed for low concentration analyte solution. On the other hand, fine-tuning the R2 threshold in segmented linear regression depends on the intended purpose in CVAC monitoring application. If the focus is on the expansion of dynamic detection range, a lower R2 threshold would be acceptable. On the contrary, if data quality is prioritized, a higher R2 threshold should be applied.
In CVAC applications, it is straightforward to instruct the computer to automatically perform segmented linear regression and identify the linear region of the dataset. This approach would be highly beneficial in a self-driving lab environment, enabling autonomous data-driven decisions for subsequent steps. In the future, instead of the self-standing mirrorless camera, which is being used in this work, a camera connected to a computer like a Raspberry Pi or other IoT devices joined with a variable pathlength flow cell could provide more possibilities in real-time analysis of flow reactions. Imagine that the camera settings could be automatically adjusted in real-time based on the continuous data points collected through the variable pathlength cell. This adaptive approach would ensure optimal signal capturing throughout the experiment, potentially improving data quality. As a result, the system could maintain consistent measurement accuracy and avoid non-linear data, leading to more precise and reliable data over a broader range of concentrations. Especially in CVAC coupled with self-driving laboratories, a variable pathlength cell serves as a powerful tool to help computer based understand of the chemical reactions and analytes, while being an internal validating tool, offering great potential for advancing automated experimental workflows.
Supplementary information is available. See DOI: https://doi.org/10.1039/d5dd00245a.
| This journal is © The Royal Society of Chemistry 2025 |