/xpsdeeplearning

Primary LanguagePythonApache License 2.0Apache-2.0

Ruff CodeFactor License: Apache 2.0 DOI

Deep learning for XPS spectra

Dr. Lukas Pielsticker, Dr. Rachel L. Nicholls, Dr. Serena DeBeer, Dr. Mark Greiner

XPS Group @ MPI for Chemical Energy Conversion

InstallationUsagePublicationsContributing

xpsdeeplearning is a toolbox for X-ray Photoelectron Spectroscopy (XPS) data analysis using Convolutional Neural Networks, designed for speeding up your XPS analysis.

The package combines

  1. simulation tools for creating large data sets of synthetic (yet realistic) transition-metal XP spectra base on reference data and
  2. a supervised machine learning framework based on artificial convolutional neural networks that is able to accurately perform automated quantitative analysis of the phases present in such XP spectra.

Installation

It is recommended to use python 3.11 (you will need at least python 3.9) with a dedicated virtual environment for this package. Learn how to manage python versions and virtual environments.

The quickest way to get started is to clone this repository:

git clone https://github.com/surfaceanalytics/xpsdeeplearning.git
cd xpsdeeplearning

...and install it with pip:

pip install .

A note on model visualization

In case you want to save and plot an image of your Tensorflow/Keras model during training/prediction, you can call the save_and_print_model_image method of the Classifier class. This method utilizes the plot_model function of Keras to convert the model to dot format and save the image to a file. However, for the conversion to work, you need to have graphviz installed locally. You can simply download the binary and install.

For conda users, it is also possible to install the binary in a a decicated environment by running

conda install anaconda::graphviz

Usage

Data simulation

The software tools for data simulation are located inside simulation, with exemplary JSON files containing the parameters used during simulation available in the params subfolder. The reference data that is used as input for the simulation is available inside data. Simulation runs can be performed using the run script or the simulate tool from the command line (see below.)

Model training and prediction

The code for convolutional neural network training and quantitative prediction is located inside network. The design of the model architectures as well as the training and testing of the neural networks were performed using TensorFlow and Keras. In order to run the training and prediction pipelines, it is generally advised to use the notebooks, either through your local Jupyter installation or through Google Colab. These notebooks allow visualization of the training/prediction inputs and outputs as well as saving of all results.

In addition, both training and prediction can be run from the command line using JSON files as input (see the README) for more information.

Command line tools

There are several tools available that allow the user to run the simulation, training, and quantification routines from the command line:

  • simulate: Simulate large artificial XPS data sets.
  • train: Simplified pipeline for tensorflow model training.
  • predict: Simplified pipeline for quantitative prediction using trained models.

You can find more information on how to use these tools in the individual READMEs available through the links above.

Data availability

Some simulated data sets and trained models are available through the KEEPER archive of the Max Planck society.

Tests

All tools are shipped with unit tests located in tests.

Publications

Software design, model architectures, and applications

Convolutional neural network framework for the automated analysis of transition metal X-ray photoelectron spectra - L. Pielsticker, R. L. Nicholls, S. DeBeer, and M. Greiner, Anal. Chim. Acta, 2023, 1271, 341433.

Datasets and trained models

DeepXPS: Data Sets and Trained Models - L. Pielsticker, R. L. Nicholls, S. DeBeer, and M. Greiner, KEEPER archive, 2023.

Contributing

Development install

Install the package with its dependencies:

git clone https://github.com/surfaceanalytics/xpsdeeplearning.git \\
    --branch main xpsdeeplearning
cd xpsdeeplearning
python -m pip install --upgrade pip
python -m pip install -e .
python -m pip install -e ".[dev]"

There is also a pre-commit hook available which formats the code and checks the linting before actually commiting. It can be installed with

pre-commit install

from the root of this repository.

Test this software

Especially relevant for developers, there exists a basic test framework written in pytest which can be used as follows:

python -m pytest -sv tests

Questions, suggestions?

To ask further questions, to make suggestions how we can improve xpsdeeplearning, to get advice on how to build on this work, or to get your XPS data ready for neural network analysis, you can:

License

This project is licensed under the MIT License - see the LICENSE file for details.