MLA xpoints#
Reader for the raw X-ray (EDS) spectra stored in .xpoints files by the FEI/Thermo
Fisher Mineral Liberation Analyser (MLA) software. An MLA measurement acquires one
spectrum for every point of a grid, or for every grain, of a mosaic of scanning
electron microscope frames; a single measurement can contain more than a million
spectra.
The reader returns one signal with a navigation axis that runs over the spectra, in
acquisition order, and a signal axis with the 2000 channels of the spectra. The signal
type is EDS_SEM, so exspy provides EDS-specific
methods when it is installed. The .xpoints extension is not used by other readers,
therefore hyperspy.api.load() selects this reader automatically:
>>> import hyperspy.api as hs
>>> s = hs.load("3_GXMAP_spx.xpoints", lazy=True)
>>> s # with exspy installed, otherwise a LazySignal1D
<LazyEDSSEMSpectrum, title: 3_GXMAP_spx, dimensions: (1216798|2000)>
Reading scans the headers of all records, because the position of a record depends on
the sizes of all records before it. This reads the whole file, which takes a few seconds
for a file with about 1.2 million spectra (2.5 GB). The counts are always returned as
uint16, so loading such a file completely needs about 5 GB. Use lazy=True to
process these files in chunks of complete spectra, for example to compute a sum spectrum
or the total counts of every spectrum.
Energy axis#
The files do not store a calibration. The signal axis uses the calibration fitted to nine
K lines (Mg Kα to Fe Kβ) of the summed spectrum of one frame of one sample of the dataset
that the format was decoded from: an offset of -10.04 eV and a gain of 10.0163 eV per
channel, in keV. The residuals of the fit are within 3.3 eV. If the detector settings of
your measurement differ, set the offset and scale of the signal axis after
loading. A file with a number of channels other than 2000 gets an uncalibrated channel
axis.
Metadata#
The fields of the record header that are decoded are available for each spectrum as
arrays in original_metadata["spectrum_headers"]:
Field |
Meaning |
|---|---|
|
Pixel column and row of the spectrum in its frame (500 × 500 pixels). |
|
Side, in pixels, of the area that the spectrum stands for: the step size of the grid (10 pixels) or a single spot (1 pixel). In rare cases it is 0. |
|
Most frequent backscattered-electron grey level of the grain that the spectrum belongs to. |
|
Fraction of the pixels of that grain with the grey level |
The .xpoints file does not say which frame a spectrum belongs to. This is stored in
the .jkf file of the X-Ray processing stage with the same name, for example
<name>_spx.jkf for <name>_spx.xpoints. If this file is found next to the
.xpoints file, original_metadata["jkf"] adds, for each spectrum, the arrays
frame, particle and grain (numbers of the frame, the particle and the grain
label at the position of the spectrum) and stage_x_um and stage_y_um (stage
position in µm). The index in the .jkf file can skip spectra whose frames were
dropped during processing: these spectra are matched by their position in the
.xpoints file and have -1 for the numbers and NaN for the positions. A .jkf file
that does not belong to the .xpoints file is ignored with a warning. Use the jkf
argument to select another file or to turn this off.
The stage position follows from the stage position of the centre of the frame and a pixel size of 3 µm, with the image x axis along the stage X axis and the image rows along the negative stage Y axis. The pixel size and the half-pixel origin of the pixel positions are assumed, they are not stored in the file.
File layout#
A .xpoints file has no header and no footer. It is a sequence of records, each of
which consists of an 80-byte little-endian header followed by the counts of one
spectrum: n_channels values as uint8 when the size of the payload (stored at byte
0x4C of the header) equals n_channels, or as little-endian uint16 when it equals
twice n_channels. In the sample of the dataset that was checked record by record, a
spectrum is stored as uint16 exactly when one of its channels exceeds 255, and across
the dataset between 0.01 % and 2 % of the spectra are stored that way. The size of the
payload is the only difference between the two kinds of record.
Source and limitations#
The format is not documented by the vendor. It was decoded from the files of the public
dataset SEM-based automated mineralogy analysis of various granodiorite samples from
the Kindisch quarry (RODARE 4896, published by the
Helmholtz-Zentrum Dresden-Rossendorf under the license
CC BY 4.0), which was measured with
an FEI Quanta 650F and two Bruker XFlash 5030 detectors in the GXMAP mode. In one
sample, all 1.2 million records parse back to back to the last byte and every header equals
the corresponding entry of the .jkf file. For all 20 full-size files of the dataset, the
number of records and of uint16 records follows from the file size and the logged number
of spectra, it agrees with the .jkf index (which omits some frames in one sample), and
the first 16,000 headers of each file equal that index. The files were written by MLA Suite 3.1.4.686 only; other versions of the software, other measurement
modes and other detectors may write a different layout.
API functions#
- rsciio.mla_xpoints.file_reader(filename, lazy=False, chunks='auto', jkf=True)#
Read the raw X-ray spectra of a FEI/Thermo MLA
.xpointsfile.The signal has one navigation axis (the spectrum index, in acquisition order) and one signal axis with the 2000 channels of the spectra. The values are always
uint16, even for the records that MLA stored asuint8.Reading scans the headers of all records, because the position of a record can only be known from the sizes of the records before it. This touches the whole file, which takes a few seconds for a full-size file (about 1.2 million spectra, 2.5 GB). Use
lazy=Truefor those, loading them completely needs about 5 GB.- Parameters:
- filename
str,pathlib.Path Filename of the file to read or corresponding pathlib.Path.
- lazybool, default=False
Whether to load the spectra lazily with
dask. The headers of the records are always read when the file is opened, the counts when the data is computed. No file stays open.- chunks
int,strortupleofint, default=”auto” Number of spectra per chunk when reading lazily.
"auto"letsdask.array.core.normalize_chunks()choose. When a tuple is given its first element is used, because a chunk always holds complete spectra.- jkfbool,
strorpathlib.Path, default=True Whether to add the frame, particle, grain and stage position of each spectrum from the X-Ray stage
.jkffile tooriginal_metadata. IfTrue, the file next to the.xpointsfile with the same name and the extension.jkfis used when it exists, and ignored with a warning if it does not belong to the.xpointsfile. A path selects the file to use and raises an error when it cannot be used.Falsedoes not read a.jkffile.
- filename
- Returns:
listofdictList of dictionaries containing the following fields:
‘data’ – multidimensional
numpy.ndarrayordask.array.Array‘axes’ – list of dictionaries describing the axes containing the fields ‘name’, ‘units’, ‘index_in_array’, and either ‘size’, ‘offset’, and ‘scale’ or a numpy array ‘axis’ containing the full axes vector
‘metadata’ – dictionary containing the parsed metadata
‘original_metadata’ – dictionary containing the full metadata tree from the input file
When the file contains several datasets, each dataset will be loaded as separate dictionary.
Notes
The per-spectrum fields of the record headers are in
original_metadata["spectrum_headers"]as arrays with one value per spectrum:xandy(pixel position in the frame),widthandheight(side in pixels of the area the spectrum stands for),bse_modeandbse_mode_fraction(most frequent backscattered-electron grey level of the spectrum’s grain and the fraction of the grain at that level).With a
.jkffile,original_metadata["jkf"]holds the arraysframe,particleandgrain(-1 where unknown) andstage_x_um,stage_y_um(stage position in um, NaN where unknown).The format was decoded from files written by MLA Suite 3.1.4.686 and the energy axis (offset -10.04 eV, gain 10.0163 eV per channel) was fitted on one frame of one sample; other versions or detector settings may differ.
Examples
>>> from rsciio.mla_xpoints import file_reader >>> s = file_reader("3_GXMAP_spx.xpoints", lazy=True)