Skip to main content

AutoEMXSp - Automated Electron Microscopy X-Ray Spectroscopy for Compositional Characterization of Materials

Project description

AutoEMXSp

PyPI version Python Version License: Custom Non-Commercial

Automated Electron Microscopy X-Ray Spectroscopy for Compositional Characterization of Materials

AutoEMXSp is a fully automated framework for SEM-EDS workflows โ€” from spectral acquisition and quantification to data filtering and compositional analysis โ€” all in one click.

๐Ÿ“– This work is described in:
A. Giunto et al., Harnessing Automated SEM-EDS and Machine Learning to Unlock High-Throughput Compositional Characterization of Powder Materials, 2025.
DOI: https://doi.org/10.21203/rs.3.rs-7837297/v1

โœจ Key Features

  • Automated acquisition & quantification of X-ray spectra using the peak-to-background method. Single spectrum quantification also available
  • Automated rule-based filtering of compositions to discard poorly quantified spectra from the analysis
  • Automated machine learningโ€“based compositional analysis to identify the compositions of individual phases in the sample
  • Automated experimental standard collection scripts included
  • Extensible architecture โ€” adaptable to other techniques such as
    • Wavelength Dispersive Spectroscopy (WDS)
    • Scanning Transmission Electron Microscopy (STEM) with EDS
  • Extensible hardware support โ€” includes driver for ThermoFisher Phenom Desktop SEM series, and can be extended to any electron microscope with a Python API

๐Ÿ“Š Performance

  • Benchmarked on 74 single-phase samples with compositions spanning 38 elements (from nitrogen to bismuth), it achieved <5โ€“10% relative deviation from expected values
  • Machine learning compositional analysis detects individual phase composition in multi-phase samples, including minor phases
  • Intermixed phases can also be resolved

๐Ÿงช Supported Use Cases

  • Powder, bulk, and rough samples
  • Scanning Electron Microscopy (SEM) with Energy-Dispersive Spectroscopy (EDS)

โš™๏ธ Requirements

  • Cross-platform: runs on Linux, macOS, and Windows
  • Quick installation
  • Requires calibration for use with different electron microscopes

๐Ÿ“‘ Table of Contents


๐ŸŽฅ Demo


๐Ÿš€ Installation

You can install AutoEMXSp in just one command.

Using pip

pip install autoemxsp

Or directly from GitHub:

pip install git+https://github.com/CederGroupHub/AutoEMXSp

Using conda

conda install -c conda-forge autoemxsp

๐Ÿ–ฅ Quick Start

AutoEMXSp supports three main automated workflows:

  1. Experimental Standard Collection โ€” acquire and fit X-ray spectra from known-composition samples to generate reference peak-to-background ratios.
  2. Sample Acquisition & Analysis โ€” acquire spectra from unknown samples, quantify them, and perform compositional phase analysis.
  3. Particle Size Statistical Analysis - control EM to search for particles and collect statistics on their size distribution.

1๏ธโƒฃ Acquire Experimental Standards

See Run_Experimental_Standard_Collection.py script

from autoemxsp.runners import batch_acquire_experimental_stds

# Define standards(s) to analyse (additional options available):
# - 'ID': unique standard identifier
# - 'formula': standard composition
# - 'pos': stage position (x, y) in mm
# - 'sample_type': bulk or powder
# - 'is_manual_meas': Manually select spots if standard is not bulk, nor powder

std_list = [
    {
        'id': 'Al_std',
        'formula': 'Al',
        'pos': (0, 0),
        'sample_type': 'bulk',
        'is_manual_meas': False
    },
]

# Run experimental standard acquisition at the microscope computer
batch_acquire_experimental_stds(stds=std_list)

2๏ธโƒฃ Acquire & Analyse Samples

See Run_Acquisition_Quant_Analysis.py script

from autoemxsp.runners import batch_acquire_and_analyze

# Define sample(s) to analyse (additional options available):
# - 'id': unique sample identifier
# - 'els': list of possible elements in the sample
# - 'pos': stage position (x, y) in mm
# - 'cnd' (optional): list of candidate phases/formulas

samples = [
    {
        'id': 'Anorthite_mineral',
        'els': ['Ca', 'Al', 'Si', 'O'],
        'pos': (-37.5, -37.5),
        'cnd': ['CaAl2Si2O8']
    },
]

# Run acquisition and analysis at the microscope computer
batch_acquire_and_analyze(samples)

3๏ธโƒฃ Particle Size Statistical Analysis

See Collect_Particle_Statistics.py script

from autoemxsp.runners import collect_particle_statistics

# Define sample(s) to analyse (additional options available):
# - 'id': unique sample identifier
# - 'pos': stage position (x, y) in mm

samples = [
    {
        'id': 'Anorthite_mineral',
        'pos': (-37.5, -37.5),
    },
]

# Run acquisition and analysis at the microscope computer
collect_particle_statistics(samples)

๐Ÿ“ฆ Requirements

  • Python 3.11 or newer
  • All dependencies are installed automatically via pip or conda.
  • Tested versions of dependencies are specified in pyproject.toml.

    The package may work with more recent versions, but these have not been tested.


Electron Microscope Support

  • โœ… Developed and tested for Thermo Fisher Phenom Desktop SEMs.
  • โœ… Compatible with any Phenom microscope equipped with PPI (Phenom Programming Interface).
  • โš ๏ธ For other microscope models, the driver must be adapted to the appropriate API commands.

๐Ÿ†• Coming Soon

Hereโ€™s whatโ€™s planned for future releases of AutoEMXSp:

  • โšก GPU acceleration for faster spectral fitting
  • ๐Ÿ Upgrade to Python 3.12 for improved performance, modern syntax features, and better compatibility with the latest scientific libraries
  • ๐Ÿš€ Integration of a forked lmfit version accepting Model.fit(data, fit_kws={'full_output': False}) to avoid covariance computations and speed up fitting
  • ๐Ÿ“ New scripts for spectral parameter calibration to extend the XSp_calibs library to your own instrument.
  • ๐Ÿค– Integration of ML models for particle segmentation and improved size distribution analysis

๐Ÿ“‚ Project Structure

The repository is organized as follows:

AutoEMXSp/
โ”œโ”€โ”€ autoemxsp/                 # Main package source code
โ”‚   โ”œโ”€โ”€ core/                   # Core objects and source code
โ”‚   โ”œโ”€โ”€ runners/                # Runner functions calling on core objects
โ”‚   โ”œโ”€โ”€ lib/                    # Libraries of X-ray data
โ”‚   โ”œโ”€โ”€ tools/                  # Miscellaneous helper functions
โ”‚   โ”‚   โ””โ”€โ”€ custom_fnctns.py        # Customizable clustering plot function
โ”‚   โ”œโ”€โ”€ EM_driver/              # Electron Microscope driver (โš ๏ธ adapt to your own instrument)
โ”‚   โ”œโ”€โ”€ XSp_calibs/             # X-ray spectral calibrations (โš ๏ธ adapt to your own instrument)
โ”‚   โ”œโ”€โ”€ scripts/                # Helper scripts (see Scripts below)
โ”‚   โ””โ”€โ”€ Results/                # Example acquired data (used for unit tests)
โ”‚
โ”œโ”€โ”€ tests/                     # Unit tests for fitting, quantification, compositional analysis and image processing
โ”‚                               # (Acquisition tests require proper EM drivers & calibration)
โ”œโ”€โ”€ paper_data/                # Raw paper data uploaded on Git LFS (Dowload instructions in Paper Data section below)
โ”‚
โ”œโ”€โ”€ LICENSE.txt
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ pyproject.toml

๐Ÿ“ Scripts

This repository includes a collection of scripts that streamline the use of AutoEMXSp.
Each script is tailored for a specific task in spectral acquisition, calibration, quantification, or analysis.

๐Ÿ”ฌ Acquisition, Quantification & Analysis

  • Run_Acquisition_Quant_Analysis.py โ€” Acquire X-ray spectra and optionally perform quantification and composition analysis.
  • Run_Quantification_Analysis.py โ€” Quantify acquired spectra (single or multiple samples) and perform machine-learning analysis.
  • Run_Analysis.py โ€” Launch customized machine-learning analysis on previously quantified data.

๐Ÿ› ๏ธ Miscellaneous

  • Collect_Particle_Statistics.py - Analyse sample collecting particle size statistics and distribution.
  • Fit_Quant_Single_Spectrum.py โ€” Fit and optionally quantify a single spectrum. Prints fitting parameters and plots fitted spectrum for detailed inspection of model performance.
  • Run_Experimental_Standard_Collection.py โ€” Acquire and fit experimental standards.
  • Run_SDD_Calibration.py โ€” Perform calibration of the SDD detector.

โš—๏ธ Characterize Extent of Intermixing in Known Powder Mixtures

(see Chem. Mater. 2015, 27, 20, 7084โ€“7094 for example)

  • Run_Acquisition_PrecursorMix.py โ€” Acquire spectra for powder precursor mixtures.
  • Run_Quantification_PrecursorMix.py โ€” Quantify spectra for one or multiple powder mixtures and run machine-learning analysis.
  • Customized analysis can be performed using the Run_Analysis.py script

๐Ÿ‘‰ All scripts can be executed directly from the command line or imported into a Python environment, making them accessible from anywhere on your system.


๐Ÿค Contributing

Contributions are welcome!

Open to collaborations to extend this package to different tools or to different types of samples, for example thin films. Please contact me at agiunto@lbl.gov


๐Ÿ“„ License

This project is licensed under an academic, nonprofit, internal, research & development, NON-COMMERCIAL USE ONLY, LICENSE โ€” see the LICENSE file for details.


๐Ÿ“– Citation

If you use AutoEMXSp in your research, please cite the following publication:

A. Giunto et al.
Harnessing Automated SEM-EDS and Machine Learning to Unlock High-Throughput Compositional Characterization of Powder Materials, 2025.
DOI: https://doi.org/10.21203/rs.3.rs-7837297/v1

BibTeX

@article{Giunto2025AutoEMXSp,
  author    = {A. Giunto and others},
  title     = {Harnessing Automated SEM-EDS and Machine Learning to Unlock High-Throughput Compositional Characterization of Powder Materials},
  journal   = {Submitted},
  year      = {2025},
  doi       = {10.21203/rs.3.rs-7837297/v1},
  url       = {https://doi.org/10.21203/rs.3.rs-7837297/v1}
}

๐Ÿ“‚ Paper Data

The raw data used in the associated publication is stored in the paper_data/ directory.
These files are tracked with Git LFS (Large File Storage).

๐Ÿ”ฝ Download with Git LFS

If you cloned the repository without Git LFS, you may only see placeholder text files instead of the actual datasets.
To download the full data, on the terminal go to the repo directory and:

# 1. Install Git LFS (only needed once per machine)
git lfs install

# 2. Fetch the data files
git lfs pull

Alternatively, download manually from the github repo Download button.

After downloading, move the raw paper data into the Results/ folder to analyze it with AutoEMXSp, or add the folder's path to 'results_dir' within the provided analysis and quantification scripts.


๐Ÿ“ฌ Contact

For questions or issues, please open an issue on GitHub.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autoemxsp-0.1.1.tar.gz (42.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autoemxsp-0.1.1-py3-none-any.whl (43.3 MB view details)

Uploaded Python 3

File details

Details for the file autoemxsp-0.1.1.tar.gz.

File metadata

  • Download URL: autoemxsp-0.1.1.tar.gz
  • Upload date:
  • Size: 42.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.0

File hashes

Hashes for autoemxsp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 93bb67487d0fc37f4cc77de924223e7710e766a14c623a889262cb2af8ca5e16
MD5 bf94f0f33f6e872b0e85cb7549225153
BLAKE2b-256 2bfdf09f7521e920a26622cad34e2c08c6169b1b923cfb9fff825eb245669466

See more details on using hashes here.

File details

Details for the file autoemxsp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: autoemxsp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 43.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.0

File hashes

Hashes for autoemxsp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b435e96e00fdf627c4adec637708c839696f53d004113ef71893803ba27df061
MD5 ce15ed2b905e7cff03b6c1b97a0ab60d
BLAKE2b-256 fbb261bd9fd926a21a0fda753873de10ab997721ff0409b6fda483e9885f25f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page