ShowEDS#
ShowEDS is an interactive EDS/EELS spectrum-image explorer for cubes with shape (row, col, energy). It has two linked panels: a real-space base image with an element-map overlay, and a spectrum with a draggable energy band. Drag the energy band to update the map; drag or resize the real-space ROI to update the summed spectrum.
Use Elements to open the periodic table, select candidate elements, and snap the energy band to characteristic X-ray lines. Auto ID ranks nearby line candidates from the current ROI spectrum; treat those as suggestions, not chemistry proof.
This tutorial uses a small synthetic EDS cube so it runs anywhere without private data. ShowEDS is still experimental: the merged baseline supports synthetic/small cubes and the documented data-folder workflow, while direct native EMD sparse-stream loading remains under active real-data testing.
Tip
Run this exact notebook with the Colab badge above, or View or download this notebook on GitHub. For finished results, use HTML and file export to export interactive HTML or share a trusted notebook with widget state.
((96, 96, 320), dtype('uint16'), array([ 0.12, 12. ], dtype=float32))
Synthetic spectrum image#
The cube below is exact uint16 count data with real-space sampling attached to the widget. The widget keeps this small cube in notebook state, so after you save and reopen the notebook the widget can still render without rerunning the cell.
from quantem.widget import ShowEDS
widget = ShowEDS(
cube,
energy,
base_image=base,
sampling=(0.18, 0.18),
units=("nm", "nm"),
title="Synthetic EDS spectrum image",
energy=2.123,
width=0.18,
element_label="Au M",
candidate_elements=["O", "Si", "Ca", "Au"],
selected_elements=["Au", "Ca"],
panel_width_px=420,
spectrum_width_px=650,
spectrum_height_px=250,
log_spectrum=True,
)
widget
Large real EDS data#
For a native multi-GB EMD file, use a data folder instead of embedding the whole cube into the notebook. The data folder stores exact prefix arrays that make band maps and ROI spectra fast in the browser while keeping notebook state small.
from pathlib import Path
from quantem.widget import ShowEDS
path = Path("0031-CaSIO3_134hr_exsitu_SI_1.85_Mx_53.9_nm_EDS_HAADF_Diffraction_Nano.emd")
widget = ShowEDS.from_emd(
path,
sidecar_dir="sidecars/eds_real_0031",
title="Real gold EDS 0031",
energy=8.04,
width=0.24,
element_label="Cu K",
candidate_elements=["O", "Si", "Ca", "Cu", "Au"],
panel_width_px=430,
spectrum_width_px=650,
spectrum_height_px=250,
log_spectrum=True,
)
widget
For exact internal sharing, keep the .ipynb and the sidecars/eds_real_0031 data folder together. For public web demos, use the widget export menu or widget.export_html(..., downsample=4) to create a single count-preserving binned HTML file that is much smaller than the full-resolution data folder.