edxia’s documentation¶

Warning
The documentation is under construction !
Tip
A step-by-step tutorial is available in a separate documentation: edxia through the Glueviz interface. This is the recommended document for non-technical users !
About¶
edxia¶
edxia is an image analysis framework for EDS/BSE hyperspectral maps. It is available as an API to develop your own tool adapte to your problems or as a plugin to Glueviz to be available to any researcher.
The code is developed by Fabien Georget in the Laboratory of Construction Materials, at EPFL, Lausanne, Switzerland. This work is a collaboration with William Wilson (EPFL, University of Sherbrooke) and Karen Scrivener (EPFL).
Quickstart¶
A step-by-step tutorial is available in a separate documentation: edxia through the Glueviz interface.
Citing¶
If you use this work, please cite the following:
- Fabien Georget, William Wilson and Karen Scrivener, edxia. Zenodo. http://doi.org/10.5281/zenodo.3246902
- Fabien Georget, William Wilson and Karen Scrivener, Comprehensive microstructure characterization from quantified SEM-EDS maps in cementitious materials (in preparation)
Install¶
Requirements¶
edxia
requires
- Python 3 (tested with python versions 3.6 and 3.7).
- scipy/numpy/matplotlib
- pandas
- Glue (version >0.15)
- py_expression_eval..
Note
The Anaconda distribution might be used to install these dependances.
Installation¶
Installation with conda¶
With a valid anaconda distribution installation (anaconda or miniconda), the edxia
package can be installed with the requirements using the conda command
conda install -c specmicp edxia
To update a previous installation, the following command can be executed:
conda update -c specmicp edxia
Installation with pip¶
The edxia
package is uploaded to Pypi, the Python Package Index. Therefore it is possible to install the latest version with its requirements very easily in any valid python installation:
pip install edxia
By default, this command attempt a system-wide installation. The package can be installed for the user only:
pip install edxia --user
To update a previous installation, the following command can be executed:
pip install edxia --upgrade
Input files¶
edxia
requires raw maps in text format from the microscope/EDS software.
The text format is required to easily accept data from various acquisition software.
The text format must be one of the various csv-type formats.
The exact delimiter, and normalization to apply are described by edxia.io.raw_io.TextMapFormat
.
Several predefined format are available in this module (edxia.io.raw_io
).
All maps from a a set must be in the same folder. Using the default classes, the user only select the BSE map, and the program find the other maps available based on the filenames. For example, the following is a valid set of names for the maps:
- cement/durability/slag_28d_BSE.txt
- cement/durability/slag_28d_Ca.txt
- cement/durability/slag_28d_Al.txt
- cement/durability/slag_28d_Si.txt
The corresponding pattern would be
- cement/durability/slag_28d_component}.txt
The choice of this pattern was made to avoid selecting every single patterns. However, it means that the name of the files need to be consistent so they can be recognized.
This is the default in :mod:edxia: but the user can defines it’s own loading functions by specializing edxia.io.loader.base_loader.AbstractLoader
.
Main concepts¶
The main concept between edxia is the extraction of representative points from the map. The representative points are extracted following these steps:
- Loading the individual maps
- Creation of a composite map
- Segmentation of the composite maps, and extraction of representative points
- Analysis of the representative points
Individual maps¶
The individual maps are loaded from the text-formatted quantified maps as provided by the microscope software. The details are described in: Input files. The maps are then filtered according the parameters provided by the user.

Individual component BSE/EDS maps
The composite map¶
The individual maps are assigned a color as shown in the figure of BSE/EDS components. These maps are then assigned to the channels (Red, Blue and Green) of a RGB image (see for example the Scikit-Image documentation). Since only 3 color channels are available, 3 main components must be chosen. The following choice is quite common:
- Red: Si
- Green: Al
- Blue: Ca
An additional component (such as the BSE) can be used as an offset on all channels, or as a transparent overlay. A composite image is obtained, the colors represent the mixture of phases.

The composite image corresponding to the individual BSE/EDS components.
The colors corresponds to the following phases:
- Blue: Portlandite/Calcite
- Purple CSH/C2S/C3S
- Green: AFm/C3A
- Red: Quartz
- Cyan: C4AF
- Yellow: Metakaolin
The composite image can be used to quickly identify the phases present in the maps. Additional thresholding on the hue can provides a first estimation of the volume fraction of these phases. However, this method is limited because only 3 or 4 independant components can be analysed.
Segmentation¶
The composite image is interesting because it allows to quickly define the region of similar composition in the map.
The pixels in the region of similar composition can be grouped to define “particles” or agglomeration of particles.
The gathering of pixels into larger region is the purpose of a segmentation algorithm.
Many segmentation algorithms exist as seen on this segmentation example from the Scikit-image documentation.
By default in edxia
, the [SLIC] algorithm is used.

The segmented composite image using the [SLIC] algorithm.
Each region defined by the segmentation algorithm is assumed to be relatively uniform. The most uniform point in the region is the point at the center, where the mixing effects are the lowest. Therefore, the geometrical center of each center is used as a representative point of the maps. The composition of these points are assembled into a dataset which can be further analysed.
Ratio plots¶
A simple analysis tools for EDS composition are ratio plots. These ratio plots are scatter plots where the axis are ratios of elemental composition (e.g. Si/Ca, Al/Ca, S/Ca, …). The position of the pure phases can be easily identify on this plots. The points around these points acan be identified as being the respective phase. Mixture lines can be defined between the position of two phases. Points along these lines corresponds to a mix of these two phases. From this analysis, a researcher can detect the existence of a phase, or find the average composition of a variable phase (e.g C-S-H).

The main drawbacks of these ratio plots is that they do not display spatial information. As such, an additional step is required to understand the distribution of phases on the maps. This method was implemented as a plugin to the Glueviz software to answer this problem. This is described in the next section of the documentation: edxia/Glue.
[SLIC] | (1, 2) Radhakrishna Achanta, Appu Shaji, Kevin Smith, Aurelien Lucchi, Pascal Fua, and Sabine Suesstrunk, SLIC Superpixels Compared to State-of-the-art Superpixel Methods, TPAMI, May 2012. |
edxia/Glue¶
Glue¶
Glue is a “Python library to explore relationships within and between related datasets”. The Glue documentation is a good place to start to learn about this software.
edxia plugin¶
In the Glue interface, edxia
is available as a plugin.
The goal of the plugin is to load the dataset and provide some tools to analyse the composition and the distributions of the phases.
The separation of the phases, and the clustering of points is done by the user with the selection tools offered by Glue.
This process is the recommended way for new user to use edxia
.
A step-by-step process is provided in the corresponding documentation ..
API¶
This sections contains the documentation of the API
Core module¶
The core modules contains the core classes used to manipulate Maps.
Experiment¶
This module contains the utilities to describe an experiment.
The main class is edxia.core.experiment.MappingExperiment
.
-
class
edxia.core.experiment.
MappingExperiment
(pattern, label=None, description=None, map_format=None, bse_format=None, map_scale_factor=1, components=None)[source]¶ This class contains the main information describing an experiment, such as the filepaths, the map formats, the list of components… This class is shared between many other classes.
Example:
exp = MappingExperiment(“mymap_{components}.csv”, label=”OPC 28d”)Parameters: - pattern (str) – the pattern of the file paths
- label (str or None) – short, unique label for this set of map
- description (str or None) – optional, longer description
- map_format (edxia.io.raw_io.TextMapFormat) – the file format of the raw EDS maps.
- bse_format (edxia.io.raw_io.TextMapFormat) – the file format of the raw EDS maps.
- components (list[str]) – list of available components for this experiment
-
bse_format
¶ Returns: the format of the raw BSE map Return type: edxia.io.raw_io.TextMapFormat
-
get_path_map
(component)[source]¶ Returns: the filepath to the raw map of ‘component’ Return type: str Raises: RuntimeError – if the component is not valid
-
is_valid
()[source]¶ Check if the experiment describes a valid set of maps.
Returns: True if the experiment is valid, and the exception otherwise Return type: tuple(bool, Exception or None)
-
label
¶ Returns: an identifying label for this experiment Return type: str
-
list_components
¶ Returns: a list of available components Return type: list[str]
-
load_raw_map
(component)[source]¶ Load the map for a component.
This is a low-level function, a loader (
edxia.io.loader
) should be used in normal operationsReturns: a map Return type: a numpy array
-
map_format
¶ Returns: the format of the EDS maps Return type: edxia.io.raw_io.TextMapFormat
-
pattern
¶ Returns: the pattern of filepaths to the maps Return type: str
-
class
edxia.core.experiment.
PartOfExperiment
(parent=None)[source]¶ Base class for a subset of an experiment.
Classes that should have access to the information provided by
edxia.core.experiment.Experiment
should inherit from this class.-
parent
¶ Returns: the experiment from which this effect was created Return type: edxia.core.experiment.Experiment
-
-
class
edxia.core.experiment.
PointsExperiment
(components, label=None, description=None)[source]¶ An experiment describing a EDS point experiment
-
is_valid
()[source]¶ Check if the experiment describes a valid set of maps.
Returns: True if the experiment is valid, and the exception otherwise Return type: tuple(bool, Exception or None)
-
label
¶ Returns: an identifying label for this experiment Return type: str
-
list_components
¶ Returns: a list of available components Return type: list[str]
-
Map¶
-
class
edxia.core.map.
Map
(component, eds_map, parent)[source]¶ A 2D EDS Map
-
component
¶ The map component
-
flat_map
¶ Return the map as a 1D array.
-
map
¶ The map
-
nb_cols
¶ The number of columns
-
nb_rows
¶ The number of rows
-
shape
¶ The shape of the map
-
Composite module¶
Channels¶
Channels information for a composite map.
-
class
edxia.composite.channels.
CompositeChannels
(components, factors)[source]¶ Channels information for a composite map.
-
blue
¶ The component of the blue channel.
-
blue_factor
¶ The scaling factor for the blue channel.
-
gray
¶ The component of the gray channel.
-
gray_factor
¶ The scaling factor for the gray channel.
-
green
¶ The component of the green channel.
-
green_factor
¶ The scaling factor for the green channel.
-
nb_components
¶ The number of components.
-
red
¶ The component of the red channel.
-
red_factor
¶ The scaling factor for the red channel.
-
Composite¶
Segmentation¶
-
class
edxia.composite.segmentation.
FullSlicSegmenter
(compactness, nb_segments)[source]¶ Slic segmenter not restricted to RGB space
-
class
edxia.composite.segmentation.
SegmentedLabels
(labels, composite_parent)[source]¶ The labels issued from segmentation.
-
composite
¶ Return the composite image
-
nb_labels
¶ Return the number of labels.
-
IO module¶
This module provides the input/output tools to read/save maps and datasets.
It is made of 3 main modules:
edxia.io.loader
: Load set of mapsedxia.io.raw_io
: Load and save individual mapsedxia.io.hdf5
: Load and save HDF5 datasets
Loaders¶
The edxia.io.loader
module offers loader classes to be able to easily
load component maps, composite or map stacks.
Three main loaders are defined:
edxia.io.loader.DefaultLoader
: A simple loader, applies the filters every timeedxia.io.loader.PickleLoader
: A loader with a cache, apply the filters only onceedxia.io.loader.StackLoader
: A loader not working from the filesystem, but using aedxia.core.map.MapsStack
as an input data.
The main functions are:
edxia.io.loader.base_loader.AbstractLoader.load_edsmap()
: load a BSE/EDS map,edxia.core.map.Map
.edxia.io.loader.base_loader.AbstractLoader.load_stack()
: load a set of maps,edxia.core.map.MapsStack
edxia.io.loader.base_loader.AbstractLoader.load_composite()
: load a composite map,edxia.composite.CompositeMap
-
class
edxia.io.loader.
DefaultLoader
(exp_manager, filters=None, no_BSE_filter=True)[source]¶ Bases:
edxia.io.loader.base_loader.AbstractLoader
Default loader without loading.
-
class
edxia.io.loader.
PickleLoader
(exp_manager, filters=None, no_BSE_filter=True, remove_previous=True)[source]¶ Bases:
edxia.io.loader.base_loader.AbstractLoader
This loader cache filtered map so long filtering can be done only once.
-
class
edxia.io.loader.
StackLoader
(stack)[source]¶ Bases:
edxia.io.loader.base_loader.AbstractLoader
Loader using a set of maps already read (and optionally filtered) using a different loader.
-
class
edxia.io.loader.base_loader.
AbstractLoader
(exp_manager, filters=None)[source]¶ Abstract base class for a map loader. This class is not intended for use, instead the user should use one of the class in
edxia.io.loader
.-
exp_manager
¶ Return the experience manager
-
filters
¶ Return the list of filters to apply at loading.
-
load_composite
(channels, is_rgb=True)[source]¶ Load a composite map
Parameters: - channels – the different channels to consider
- is_rgb – if true, the map is reduced to an RGB image
-
load_edsmap
(component)[source]¶ Load the map of ‘component’. It can be either a simple component (e.g. ‘BSE’, ‘Ca’), or a combination of components (e.g. “Si+Al/Ca”).
-
Raw IO¶
This module provides raw loading and saving helper functions. It defines how the maps are read before any transformation from the algorithm.
Example: Read txt format from bruker Esprit software:
bse_map_asarray = load_txt_map("map234_BSE.txt", esprit_ascii_map_format)
-
class
edxia.io.raw_io.
TextMapFormat
(delimiter, min_value, max_value, saveformat='%.4f')[source]¶ Bases:
object
A struct-like class to contain formatting information about raw EDS maps.
-
delimiter
¶ Return the column delimiter
-
escaped_delimiter
¶ Return an escaped version of the delimiter
-
max_value
¶ Return the maximum value allowed in the map
-
min_value
¶ Return the minimum value allowed in the map
-
saveformat
¶ Set the save format
-
-
edxia.io.raw_io.
esprit_ascii_map_format
= TextMapFormat(';',0,100)¶ Default EDS map format for the Bruker Esprit software
-
edxia.io.raw_io.
esprit_ascii_bse_format
= TextMapFormat(';',0,-1)¶ Default BSE map format for the Bruker Esprit software
-
edxia.io.raw_io.
aztec_ascii_map_format
= TextMapFormat(',',0,100)¶ Default EDS map format for the Oxford Aztec software
-
edxia.io.raw_io.
aztec_ascii_bse_format
= TextMapFormat(',',0,-1)¶ Default BSE map format for the Oxford Aztec software
-
edxia.io.raw_io.
imagej_ascii_bse_format
= TextMapFormat('\t',0,-1)¶ Format for a text image produced by ImageJ
-
edxia.io.raw_io.
load_txt_map
(filename, txtformat, resize=1)[source]¶ Load a 2D map
Parameters: - filename – filepath to the text map
- txtformat – the format of the text map
- resize – Stretch the map in each axis)
Returns: a 2D numpy array normalized between [0,1]
Raises: whatever numpy.loadtxt can raise
-
edxia.io.raw_io.
save_txt_map
(filename, amap, txtformat)[source]¶ Save a 2D map
Perform a copy first to normalize the data according the format.
Parameters: - filename – filepath to the file
- amap – a 2D map
Format txtformat: the format of the ascii saved map