autoemxsp.runners.batch_quantify_and_analyze module

Batch quantification and analysis of X-ray spectra for a list of samples.

This module provides automated batch quantification and (optionally) clustering/statistical analysis of acquired X-ray spectra for multiple samples. It is robust to missing files or errors in individual samples, making it suitable for unattended batch processing.

Import this module in your own code and call the batch_quantify_and_analyze() function, passing your desired sample IDs and options as arguments. This enables integration into larger workflows or pipelines.

Workflow:
  • Loads sample configurations from Spectra_collection_info.json

  • Loads acquired spectral data from Data.csv

  • Performs quantification (optionally only on unquantified spectra)

  • Optionally performs clustering/statistical analysis and saves results

Notes

  • Only the sample_ID is required if acquisition output is saved in the default directory; otherwise, specify results_path.

  • Designed to continue processing even if some samples are missing or have errors.

Typical usage:
  • Edit the sample_IDs list and parameter options in the script, or

  • Import and call batch_quantify_and_analyze() with your own arguments.

param sample_IDs:

List of sample identifiers.

type sample_IDs:

List[str]

param quantification_method:

Method to use for quantification. Uses quant_cfg.method if unspecified. Currently only supports ‘PB’.

type quantification_method:

str, optional

param results_path:

Base directory where results are stored. Default: autoemxsp/Results

type results_path:

str, optional

param min_bckgrnd_cnts:

Minimum number of background counts underneath reference peaks below which spectra are flagged. If None, leaves it unchanged. Default: None

type min_bckgrnd_cnts:

float, optional

param output_filename_suffix:

Suffix to append to output filenames.

type output_filename_suffix:

str, optional

param use_instrument_background:

Whether to use instrument background if present (Default: False).

type use_instrument_background:

bool, optional

param max_analytical_error:

Maximum allowed analytical error for analysis.

type max_analytical_error:

float, optional

param run_analysis:

Whether to run clustering/statistical analysis after quantification.

type run_analysis:

bool, optional

param quantify_only_unquantified_spectra:

If True, only quantify spectra that lack analytical error.

type quantify_only_unquantified_spectra:

bool, optional

param interrupt_fits_bad_spectra:

If True, interrupt fitting if bad spectra are encountered. Speeds up computations

type interrupt_fits_bad_spectra:

bool, optional

param is_known_precursor_mixture:

Whether sample is a mixture of two known powders. Used to characterize extent of intermixing in powders. See example at:

L. N. Walters et al., Synthetic Accessibility and Sodium Ion Conductivity of the Na 8– x A x P 2 O 9 (NAP) High-Temperature Sodium Superionic Conductor Framework, Chem. Mater. 37, 6807 (2025).

type is_known_precursor_mixture:

bool, optional

returns:
  • quant_results (list()) – List of EMXSp_Composition_Analyzer, the composition analysis object containing the results and methods for further analysis.

  • Created on Tue Jul 29 13 (18:16 2025)

  • @author (Andrea)

autoemxsp.runners.batch_quantify_and_analyze.batch_quantify_and_analyze(sample_IDs: List[str], quantification_method: str = None, results_path: str = None, min_bckgrnd_cnts: float = None, output_filename_suffix: str = '', use_instrument_background: bool = False, max_analytical_error: float = 5, run_analysis: bool = True, num_CPU_cores: int = None, quantify_only_unquantified_spectra: bool = False, interrupt_fits_bad_spectra: bool = False, is_known_precursor_mixture: bool | None = None, standards_dict: dict = None) None[source]

Batch quantification and analysis for a list of samples.

Parameters:
  • sample_IDs (List[str]) – List of sample identifiers.

  • quantification_method (str, optional) – Method to use for quantification. Uses quant_cfg.method if unspecified. Currently only supports ‘PB’.

  • results_path (str, optional) – Base directory where results are stored. Default: autoemxsp/Results

  • min_bckgrnd_cnts (float, optional) – Minimum number of background counts underneath reference peaks below which spectra are flagged. If None, leaves it unchanged. Default: None

  • output_filename_suffix (str, optional) – Suffix to append to output filenames.

  • use_instrument_background (bool, optional) – Whether to use instrument background if present (Default: False).

  • max_analytical_error (float, optional) – Maximum allowed analytical error for analysis.

  • run_analysis (bool, optional) – Whether to run clustering/statistical analysis after quantification.

  • num_CPU_cores (bool | None, optional) – Number of CPU cores to use during fitting and quantification. If None, half of the available cores are used.

  • quantify_only_unquantified_spectra (bool, optional) – If True, only quantify spectra that lack analytical error.

  • interrupt_fits_bad_spectra (bool, optional) – If True, interrupt fitting if bad spectra are encountered. Speeds up computations

  • is_known_precursor_mixture (bool, optional) –

    Whether sample is a mixture of two known powders. Used to characterize extent of intermixing in powders. See example at:

    L. N. Walters et al., Synthetic Accessibility and Sodium Ion Conductivity of the Na 8– x A x P 2 O 9 (NAP) High-Temperature Sodium Superionic Conductor Framework, Chem. Mater. 37, 6807 (2025).

  • standards_dict (dict, optional) – Dictionary of reference PB values from experimental standards. Default : None. If None, dictionary of standards is loaded from the XSp_calibs/Your_Microscope_ID directory. Provide standards_dict only when providing different standards from those normally used for quantification.

Returns:

quant_results – List of EMXSp_Composition_Analyzer, the composition analysis object containing the results and methods for further analysis.

Return type:

list()