DOI: 10.5061/dryad.b5mkkwhnw
title: Network of artificial olfactory receptors for spatiotemporal monitoring of toxic gas

description: Excessive human exposure to toxic gases can lead to chronic lung and
 cardiovascular diseases. Thus, precise in-situ monitoring of toxic gases
 in the atmosphere is crucial. Here, we present an artificial olfactory
 system for spatiotemporal recognition of NO2 gas flow by integrating a
 network of chemical receptors with near-sensor computing. The artificial
 olfactory receptor features nano islands of metal-based catalysts that
 cover the graphene surface on the heterostructure of an AlGaN/GaN
 two-dimensional electron gas (2DEG) channel. Catalytically dissociated NO2
 molecules bind to graphene, thereby modulating the conductivity of the
 2DEG channel. For the energy/resource-efficient gas flow monitoring, Trust
 region Bayesian optimization algorithm allocates many sensors optimally in
 a complex space. Integrated artificial neural networks on a compact
 microprocessor with a network of sensors provide in-situ gas flow
 predictions. This system enhances protective measures against toxic
 environments through spatiotemporal monitoring of toxic gases. This is
 code for the paper: Trust Region Bayesian Optimized Network of Artificial
 Olfactory Receptors for Spatiotemporal Monitoring of NO2 gas. The code
 includes tflite based file generation, dataset, test, and validation
 processes.
description: # Network of Artificial Olfactory Receptors for Spatiotemporal Monitoring
 of Toxic Gas
 [https://doi.org/10.5061/dryad.b5mkkwhnw](https://doi.org/10.5061/dryad.b5mkkwhnw) ## Description of the Data and File Structure ### Trust Region Bayesian Optimized Network of Artificial Olfactory Receptors for Spatiotemporal Monitoring of NO₂ Gas This repository contains supplementary codes and datasets for the paper: **Trust Region Bayesian Optimized Network of Artificial Olfactory Receptors for Spatiotemporal Monitoring of NO₂ Gas**. The code includes TFLite-based file generation, dataset handling, testing, and validation processes. **Note:** Before starting, ensure you have Jupyter Notebook or Jupyter Lab installed for running the `.ipynb` files. ## Dataset Find the attached dataset files. ### Files and Variables #### File: `Datasets.npy` **Description:** Contains gas simulation datasets for the TuRBO optimization and neural network training. The dimension of dataset is (n × 11, 4455, 3). The dataset represent the contour map of gas concentration throughout the observation space, which is 50 × 23 (m) simulative space. The 'n' number of observations were taken which represent each gas leakage scenarios with different gas leakage points, observed for 11 times within 1000 seconds (0, 100, 200, ... , 1000). The second shape parameter (4455) represents the all points in the contour map. The last dimension 3 represents x, y, and concentration. Specifically, the first 2 of 3 contains x and y coordinate of the observation point, and the last 1 contains the concentration level. * **Shape:** `(n × 11, 4455, 3)` * `n × 11`: Total number of observations multiplied by 11 time steps (from 0 to 1000 seconds at 100-second intervals). * `4455`: Number of points in the contour map. * `3`: Represents `[x, y, concentration]` at each point. **Visualization Example:** To visualize the concentration map for the 15th observation at the 500-second timestamp, use the following code: ```python import numpy as np import matplotlib.pyplot as plt # Load the dataset DATASET = np.load('Datasets.npy') # Parameters observation_number = 15 # 15th observation time_step = 500 # Time in seconds # Time steps in the dataset time_steps = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000] time_index = time_steps.index(time_step) # Get the index of the desired time step # Calculate the dataset index index = (observation_number - 1) * 11 + time_index # Extract x, y coordinates and concentration values x_coords = DATASET[index, :, 0] y_coords = DATASET[index, :, 1] concentration = DATASET[index, :, 2] # Plotting plt.figure(figsize=(10, 8)) scatter = plt.scatter(x_coords, y_coords, c=concentration, cmap='viridis') plt.colorbar(scatter, label='Concentration Level') plt.xlabel('X Coordinate (m)') plt.ylabel('Y Coordinate (m)') plt.title(f'Concentration Map for Observation {observation_number} at {time_step} sec') plt.show() ``` #### File: `Datalabels.npy` **Description:** Contains the labels for each dataset entry. This file is embedded in the code folder found on Zenodo. * **Shape:** `(n × 11, 2)` * The last dimension `[2]` represents the `[x, y]` coordinates of the gas leakage point. ## Code/Software ### Basic Jupyter Notebook Setup and Run Guide #### Prerequisites Ensure you have the following installed on your system: * **Python 3.12** * **pip** (Python package installer) #### Installation 1. **Install Jupyter Notebook via pip** Open your terminal (for macOS/Linux) or Command Prompt/PowerShell (for Windows) and run the following command: ``` pip install notebook ``` 2. **Verify Installation** To ensure Jupyter Notebook was installed correctly, run: ``` jupyter --version ``` This should display the version of Jupyter Notebook installed. #### Running Jupyter Notebook 1. **Start Jupyter Notebook** Navigate to the directory where your notebooks are located or where you wish to create new ones, then run: ``` jupyter notebook ``` This command will start the Jupyter Notebook server and open the interface in your default web browser. 2. **Create a New Notebook** * In the Jupyter Notebook interface, click the **"New"** button at the top right and select **"Python 3"** to create a new notebook. 3. **Using Jupyter Notebook** * **Running Cells**: Write Python code in the cells and run them interactively by pressing Shift + Enter. * **Managing Cells**: Add new cells, delete cells, or change the cell type (Code or Markdown) using the toolbar. 4. **Save and Exit** * **Save**: Click the floppy disk icon in the toolbar to save your notebook. * **Exit**: Close the browser tab and stop the Jupyter server in your terminal by pressing Ctrl + C. #### Additional Resources For more detailed instructions and advanced usage, visit the [Jupyter Project Documentation](https://jupyter.org/documentation). ## Run the Code ### 1. Run `BO_Gas_sensor_T9_EI-TurBO_10.ipynb` This notebook performs Bayesian Optimization to generate an optimized neural network and positions 10 sensors in optimized regions for better gas detection. **Steps:** * Open the notebook in Jupyter. * Run each cell sequentially by pressing `Shift + Enter`. * The notebook includes code for data loading, preprocessing, optimization, and visualization. ### 2. Run `SPresense_TF_GAS.ino` This code sets the Sony SPresense microprocessor into listening mode for gas concentration data. **Instructions:** * **Setup:** Refer to the following resources for detailed settings and environment setup: * [TFLite Micro SPresense Examples on GitHub](https://github.com/sonydevworld/tflite-micro-spresense-examples) * [Running TensorFlow Lite on the Sony Spresense](https://blog.tensorflow.org/2021/10/TF-Lite-Sony-Spresense.html) * **Upload:** Use the Arduino IDE or Sony's development environment to upload the `.ino` file to the SPresense board. ### 3. Run `BO_Gas_sensor_T9_Neural_Network_verify_Board.ipynb` This notebook trains and validates the neural network based on the sensor positions generated by the Bayesian Optimization. **Steps:** * Open the notebook in Jupyter. * Ensure that the optimized sensor positions from the previous steps are correctly loaded. * Run the training and validation cells to evaluate the neural network's performance. ## Access Information **Other publicly accessible locations of the data:** * [https://github.com/bb8ax/TuRBO_Gas/](https://github.com/bb8ax/TuRBO_Gas/) **Data was derived from the following sources:** * None