espm: The Electron Spectro-Microscopy Python Library

Documentation Status

This library contains algorithms to perform non-negative matrix factorization with diverse regularisation (e.g. Laplacian or L1) and contraints (e.g. simplex).

It is specialized for Electron Microscopy applications. It contains code to create artificial Energy dispersive X-ray spectroscopy (EDXS) data and to perform hyperspectral unmixing on EDXS spectrum images.


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]"

Getting started

Generate the synthetic dataset. Run the script:

$ python experiments/


The documentation is available at

You can get started with the following notebooks:


Here is a list of things that we need to do before the version 0.2.0, which will be the first official release of the library. The code is already available on github at the following address: A draft of the documentation is available at:

  • Update the line 40 of doc/introduction/index.rst (@Adrien)

  • Make some doc for the dataset module (just the minimum) (@Adrien)
    • Nati: I started doint it. I suggest to put all the function that create samples in dataset.samples.

  • Toy dataset: create model class, change outputs, adapts function (@Nati) Done!

  • Separate the spectral and spacial parts (@Adrien)
    • Move generate_EDXS_phases to models

    • Create a modules for weights (Nati: I started doing it)

  • Complete the general doc in doc/introduction/index.rst (@Adrien)

  • Clarify the code for the estimator: remove the L2 loss (@Nati) Done!

  • Add the general problem that we solve in the doc (@Nati) Done!

  • Update the ML notebook with more explanations (@Nati) Done!

  • Check that the doc is somehow understanable and sufficiently complete (@Sebastian)

  • Add the reference to the dataset paper (@Nati)

  • add the reference to the algorithm paper (@Nati)

@Adrien: Check the code in espm.weights. If you copy this code, you can generate figures for the doc. It seems that you need to have the title Examples for the system to work. Example does not work!

Documentation map