espm: The Electron Spectro-Microscopy Python Library

Documentation Status

The espm package is designed for simulation and physics-guided NMF decomposition of hyperspectral data. Even though the package is mainly centered around electron spectro-microscopy applications, custom models can be implemented for other type of data. Currently espm supports the simulation and analysis of simultaneous scanning transmission electron microscopy and energy dispersive X-ray spectroscopy (STEM / EDXS). In future implementation, we will try to extend the package to support electron energy loss spectroscopy (EELS).

The main components of the package are: - The simulation of STEM-EDXS datasets using espm.datasets which combines espm.weights for the simulation of spatial distributions and èspm.models for the simulation of spectra. - The hyperspectral unmixing of STEM-EDXS spectrum images using espm.estimators. This module contains algorithms to perform non-negative matrix factorization with diverse regularisation (e.g. Laplacian or L1) and contraints (e.g. simplex). - The espm.models module can also be used to perform a physics-guided decomposition of STEM-EDXS datasets.


You can install this package from PyPi using:

$ pip install espm

If you want to develop, please use the option:

$ git clone
$ cd espm
$ pip install cython
$ pip install -e ."[dev]"

If you get issues regarding pandoc when using make doc, you can install it using:

$ sudo apt-get install pandoc


$ conda install pandoc

Getting started

Try the api.ipynb notebook in the notebooks folder.


The documentation is available at

You can get started with the following notebooks:


If you use this library, please cite the following paper:

title={espm: A Python library for the simulation of STEM-EDXS datasets},
author={Teurtrie, Adrien and Perraudin, Nathana{\"e}l and Holvoet, Thomas and Chen, Hui and Alexander, Duncan TL and Obozinski, Guillaume and H{\'e}bert, C{\'e}cile},

Documentation map