autoemx.runners.batch_acquire_experimental_stds module
Automated X-Ray Experimental Standard Acquisition and Analysis
This module configures and runs automated collection and fitting of EDS/WDS spectra from experimental standards (i.e., sampels of known composition) to generate reference values of peak-to-background ratios.
Import this module in your own Python code and call the batch_acquire_experimental_stds() function, passing your desired configuration and sample list as arguments. This enables integration into larger automation workflows or pipelines.
- Workflow includes:
Configuration of microscope, measurement, substrate, and fitting parameters
Sample setup (elements, position, reference formulae)
Calibration and quantification options
Automated or manual navigation and acquisition modes
- Requirements:
Proper instrument calibration files and instrument driver for the selected microscope
- Typical usage:
Edit the ‘std_list’ list to define your standards
Adjust configuration parameters as needed, either directly in the script or by passing them to batch_acquire_experimental_stds
Run the script, or import and call batch_acquire_experimental_stds() to collect experimental standards for one or multiple samples at a time
Created on Fri Aug 20 09:34:34 2025
@author: Andrea
- autoemx.runners.batch_acquire_experimental_stds.batch_acquire_experimental_stds(stds: List[Dict[str, Any]], microscope_ID: str = 'PhenomXL', microscope_type: str = 'SEM', measurement_type: str = 'EDS', measurement_mode: str = 'point', sample_halfwidth: float = 3.0, sample_substrate_type: str = 'Ctape', sample_substrate_shape: str = 'circle', working_distance: float = 5, working_distance_tolerance: float = 1, beam_energy: float = 15.0, spectrum_lims: Tuple[float, float] = (14, 1100), use_instrument_background: bool = False, min_bckgrnd_cnts: float = 5, fit_during_collection=True, update_std_library=True, is_auto_substrate_detection: bool = False, auto_adjust_brightness_contrast: bool = True, contrast: float | None = None, brightness: float | None = None, min_n_spectra: int = 50, max_n_spectra: int = 100, target_Xsp_counts: int = 250000, max_XSp_acquisition_time: float | None = None, els_substrate: List[str] | None = None, powder_meas_cfg_kwargs: Dict[str, Any] | None = None, bulk_meas_cfg_kwargs: Dict[str, Any] | None = None, exp_stds_meas_cfg_kwargs: Dict[str, Any] | None = None, output_filename_suffix: str = '', saved_images_extension: str = 'png', save_raw_images: bool = False, development_mode: bool = False, verbose: bool = True, exp_std_dir: str | None = None, is_manual_meas: bool = False) List[EMXSp_Composition_Analyzer | None][source]
Batch acquisition (and optional quantification) of X-ray spectra for a list of powder samples.
- Parameters:
stds (list of dict) –
List of experimental standard definitions. Each dictionary must contain:
’ID’ (str): Identifier for the standard sample (SampleConfig.ID).
’formula’ (str): Chemical formula of the standard (ExpStandardsConfig.formula).
’pos’ (tuple of float): (x, y) stage coordinates in mm (SampleConfig.center_pos).
’sample_type’ (str): Sample type (‘powder’, ‘bulk’, etc.) (SampleConfig.type).
’is_manual_meas’ (bool): If True, navigation to positions is manual (MeasurementConfig.is_manual_navigation).
microscope_ID (str, optional) – Identifier for the microscope hardware. Must correspond to a calibration folder in ./XSp_calibs/Microscopes/<ID> (MicroscopeConfig.ID). Default is ‘PhenomXL’.
microscope_type (str, optional) – Type of microscope. Allowed: ‘SEM’ (implemented), ‘STEM’ (not implemented). Default is ‘SEM’ (MicroscopeConfig.type).
measurement_type (str, optional) – Measurement type. Allowed: ‘EDS’ (implemented), ‘WDS’ (not implemented). Default is ‘EDS’ (MeasurementConfig.type).
measurement_mode (str, optional) – Acquisition mode (e.g., ‘point’, ‘map’), defining beam/detector calibration settings. Default is ‘point’ (MeasurementConfig.mode).
sample_halfwidth (float, optional) – Half-width of the sample area in mm for mapping/acquisition. Default is 3.0 (SampleConfig.half_width_mm).
sample_substrate_type (str, optional) – Type of sample substrate. Allowed: ‘Ctape’, ‘None’. Default is ‘Ctape’ (SampleSubstrateConfig.type).
sample_substrate_shape (str, optional) – Shape of the substrate. Allowed: ‘circle’, ‘square’. Default is ‘circle’ (SampleSubstrateConfig.shape).
working_distance (float, optional) – Working distance in mm for acquisition. If None, taken from microscope driver. Default is 5.0 (MeasurementConfig.working_distance).
working_distance_tolerance (float, optional) –
- Defines maximum accepted deviation of working distance from its typical value, in mm.
Used to prevent gross mistakes from EM autofocus. Default: 1 mm.
beam_energy (float, optional) – Electron beam energy in keV. Default is 15.0 (MeasurementConfig.beam_energy_keV).
spectrum_lims (tuple of float, optional) – Lower and upper energy limits for spectrum fitting in eV. Default is (14, 1100) (QuantificationOptionsConfig.spectrum_lims).
use_instrument_background (bool, optional) – Whether to use instrument background files during fitting. If False, background is computed during fitting. Default is False (QuantificationOptionsConfig.use_instrument_background).
min_bckgrnd_cnts (float, optional) – Minimum background counts required for a spectrum not to be filtered out. Default is 5 (ClusteringConfig.min_bckgrnd_cnts).
fit_during_collection (bool, optional) – If True, fit spectra during acquisition; otherwise fit later. Default is True.
update_std_library (bool, optional) – If True, update the stored experimental standards library after acquisition. Default is False.
is_auto_substrate_detection (bool, optional) – If True, substrate elements are detected automatically. Implemented only for ‘Ctape’ substrates. Default is False (SampleSubstrateConfig.auto_detection).
auto_adjust_brightness_contrast (bool, optional) – If True, brightness/contrast are set automatically. Default is True (MicroscopeConfig.is_auto_BC).
contrast (float, optional) – Manual contrast setting (required if auto_adjust_brightness_contrast is False). Default is 4.3877 (MicroscopeConfig.contrast).
brightness (float, optional) – Manual brightness setting (required if auto_adjust_brightness_contrast is False). Default is 0.4504 (MicroscopeConfig.brightness).
min_n_spectra (int, optional) – Minimum number of spectra to acquire. Default is 50 (MeasurementConfig.min_n_spectra).
max_n_spectra (int, optional) – Maximum number of spectra to acquire. Default is 100 (MeasurementConfig.max_n_spectra).
target_Xsp_counts (int, optional) – Target counts for spectrum acquisition. Default is 250000 (MeasurementConfig.target_acquisition_counts).
max_XSp_acquisition_time (float, optional) – Maximum acquisition time in seconds. If None, estimated from target counts. Default is None (MeasurementConfig.max_acquisition_time).
els_substrate (list of str, optional) – List of substrate element symbols. Default is [‘C’, ‘O’, ‘Al’] (SampleSubstrateConfig.elements).
powder_meas_cfg_kwargs (dict, optional) – Additional keyword arguments for PowderMeasurementConfig.
bulk_meas_cfg_kwargs (dict, optional) – Additional keyword arguments for BulkMeasurementConfig.
exp_stds_meas_cfg_kwargs (dict, optional) – Additional keyword arguments for ExpStandardsConfig. Used to customize experimental standard acquisition and PB ratio filtering.
output_filename_suffix (str, optional) – String appended to output filenames. Default is ‘’.
saved_images_extension (str, optional) – Extension used for SEM image files saved during acquisition. Default is ‘tif’.
save_raw_images (bool, optional) – Whether to save non-annotated raw SEM images in addition to annotated images. Default is True.
development_mode (bool, optional) – If True, enables development/debug features. Default is False.
verbose (bool, optional) – If True, print verbose output. Default is True.
exp_std_dir (str, optional) – Directory where experimental standard results are saved. Default is None.
is_manual_meas (bool, optional) – If True, all samples are measured in manual navigation mode unless overridden by ‘is_manual_meas’ in the sample dict. Default is False.
- Returns:
results – A list of the composition analysis objects (one per sample) containing the results and methods for further analysis.
- Return type:
list(EMXSp_Composition_Analyzer)