MIDAS is an open-source suite for reconstructing three-dimensional microstructures from High-Energy Diffraction Microscopy (HEDM) data. Developed at the Advanced Photon Source at Argonne National Laboratory, it supports the complete data-reduction pipeline β from raw detector frames to grain maps, strain tensors, spatially resolved orientation fields, and tomographic reconstructions.
Version: 11.0 Contact: Hemant Sharma (hsharma@anl.gov)
| Technique | What It Produces | Detector Distance |
|---|---|---|
| Far-Field HEDM (FF-HEDM) | Grain centroids, average orientations, full elastic strain tensors | β 1 m |
| Near-Field HEDM (NF-HEDM) | Spatially resolved 3D orientation maps, grain morphology, grain boundary networks | β 5β10 mm |
| Point-Focus HEDM (PF-HEDM) | High-resolution grain orientations from focused beam | β 1 m |
| Radial Integration (Caking) | 1D intensity vs. 2ΞΈ profiles for Rietveld refinement (GSAS-II) | β |
| Grain Matching & Stitching | Track grains across load states; combine multi-layer scans | β |
| Tomography (CT) | Absorption-contrast cross-sections via gridrec algorithm | β |
- GPU acceleration β CUDA-accelerated indexing (
IndexerGPU), strain fitting (FitPosOrStrainsGPU), NF orientation fitting (FitOrientationGPU), scanning HEDM (IndexerScanningGPU,FitOrStrainsScanningGPU), radial integration (IntegratorFitPeaksGPUStream), and tomographic reconstruction (tomo_gpu). See GPU_Acceleration - Consolidated binary I/O β PF/scanning HEDM replaces ~30K+ per-voxel files with 3 consolidated binary files per scan via
IndexerConsolidatedIO.h - CalibrantIntegratorOMP β new primary calibration executable (replaces archived
CalibrantPanelShiftsOMP) - Switchable peak fitting β unified pseudo-Voigt (pV) and Thompson-Cox-Hastings (TCH) modes across calibration, integration, and auto-calibration
- Physical corrections β parallax, solid-angle, and polarization corrections in DetectorMapper (matching pyFAI convention)
- Q-spacing integration β radial bins equally spaced in Q (Γ
β»ΒΉ) via
QBinSize/QMin/QMaxparameters - CBF file format β new
ReadCBFFrame()reader for CBF detector data - Streaming median β histogram-based streaming median for NF image processing (~500 MB vs 11.5 GB)
- Stripe artifact removal β Vo et al. (2018) algorithms for tomography ring/stripe correction
- Shared integration library β extracted
IntegrationCore,MapperCore,CalibrationCore,CalibPeakFitmodules - Centralized MIDAS_ParamParser β unified parameter file parsing across all executables
- Gradient-aware pixel splitting β sub-pixel radial resampling for improved integration accuracy
- FF viewer caking overlay workflow β added load/save/edit support for
cake_parameters*.csv, per-detector caking metadata, and composite-sector overlay drawing. - Plot/Clear + keyboard toggle β caking overlay can now be toggled directly from the GUI and with the
Cshortcut. - Multi-detector caking controls β HYDRA mode now includes per-GE cake rows and a dedicated cake parameter editor panel.
- Path precedence hardening β explicit user selections (first file, dark file, HDF5 data/dark dataset paths) are preserved and no longer overwritten by later parameter-file loads.
- Dark subtraction fallback β when no separate dark file is configured, dark data can be read from the current HDF5 data file path.
- Overlay readability improvements β lab-frame axes were restyled for clearer on-image visibility.
- Consolidated HDF5 output β all FF-HEDM results (grains, spots, strains, peak provenance) in a single
.h5file - Pipeline restart β
--resumeand--restart-fromflags on all workflows (FF, PF, NF, dual-dataset, multi-resolution) allow resuming from any completed stage using the HDF5 checkpoint - Version & provenance tracking β every C binary and Python workflow embeds
MIDAS v11.0 (<git-hash>)into output files, HDF5 attributes, and Zarr metadata for full reproducibility - Pseudo-Voigt peak fitting β two-stage decomposed fitting (Lorentzian + Gaussian) with mu-weighted effective widths
- Grain matching & stitching β Python-native optimal (Hungarian) matching across load states with affine deformation support
- Reprocess mode β regenerate
MergeMap.csvand consolidated HDF5 on old datasets (-reprocess 1) - Dynamic detector sizes β auto-detected from data, no hardcoded dimensions
- Zarr-ZIP data format β compressed, portable, self-contained analysis archives
- Forward simulation engine β compressed output with OpenMP parallelism
- Multi-resolution NF-HEDM β iterative reconstruction at increasing grid resolution
- Interactive GUI β browser-based visualization of NF calibration, microstructure, and FF results
- Multi-stage auto-calibration β geometry-first calibration strategy with panel auto-detection from masks
MIDAS/
βββ FF_HEDM/ # Far-field HEDM (calibration, indexing, fitting, integration)
β βββ src/ # C source code (peak search, fitting, merging, indexing, grains)
β βββ workflows/ # Python workflow drivers (ff_MIDAS.py)
β βββ bin/ # Compiled binaries (auto-generated by build)
β βββ Example/ # Example dataset for testing
βββ NF_HEDM/ # Near-field HEDM reconstruction
β βββ src/ # C source code (forward model, grid reconstruction)
β βββ workflows/ # Python workflow drivers (nf_MIDAS.py)
β βββ bin/ # Compiled binaries (auto-generated by build)
β βββ v7/ # Workflow templates
β βββ seedOrientations/ # Orientation seed files (downloaded by build)
β βββ Example/ # Example dataset for testing
βββ DT/ # Diffraction tomography (peak-fit integrator)
βββ TOMO/ # Tomographic reconstruction (gridrec CT engine)
βββ utils/ # Python utilities
β βββ AutoCalibrateZarr.py # FF-HEDM auto-calibration
β βββ match_grains.py # Grain matching and layer stitching
β βββ calcMiso.py # Crystallographic misorientation calculations
β βββ gsas_ii_refine.py # GSAS-II integration
β βββ ...
βββ gui/ # Interactive visualization GUI
βββ manuals/ # Comprehensive documentation (see below)
βββ cmake/ # CMake build configuration and dependency management
βββ build.sh # Build script (Linux / macOS)
βββ build_wsl_windows.sh # Build script (Windows via WSL)
βββ environment.yml # Conda environment specification
βββ CMakeLists.txt # Top-level CMake configuration
βββ LICENSE # UChicago Argonne open-source license
Full manuals are in the manuals/ directory. Start with the manuals README for an overview of all HEDM techniques, coordinate systems, and a getting-started checklist.
| Manual | Topic |
|---|---|
| GPU_Acceleration | GPU-accelerated computation (CUDA) |
| FF_Calibration | FF-HEDM geometry calibration |
| FF_Analysis | FF-HEDM grain indexing and fitting |
| FF_Match_Stack_Reconstructions | Grain matching across load states and layer stitching |
| FF_Radial_Integration | Radial integration / caking |
| FF_Interactive_Plotting | Interactive FF-HEDM visualization |
| FF_Visualization | FF-HEDM result visualization |
| FF_Dual_Datasets | Dual-dataset FF-HEDM analysis |
| PF_Analysis | Point-Focus HEDM analysis |
| NF_Calibration | NF-HEDM detector calibration |
| NF_Analysis | NF-HEDM reconstruction workflow |
| NF_MultiResolution_Analysis | Multi-resolution NF-HEDM |
| NF_GUI | NF-HEDM interactive GUI |
| Forward_Simulation | Forward simulation for validation |
| GSAS-II_Integration | Importing MIDAS output into GSAS-II |
| Tomography_Reconstruction | Absorption-contrast CT reconstruction |
| FF_Benchmark | FF-HEDM benchmark testing |
| NF_Benchmark | NF-HEDM benchmark testing |
The Python pipeline β calibration, integration, indexing, refinement, grain processing β installs from PyPI and does not need the source build below:
pip install "midas-suite[all]"midas-index and midas-fit-grain bundle C/OpenMP executables
(midas_indexer, midas_fitgrain) and are published as sdist, so pip
compiles them during install. CMake and ninja come along automatically; you
need a C compiler and OpenMP (macOS: brew install libomp gcc; Linux:
gcc; Windows: Visual Studio Build Tools). If either is missing the install
still succeeds and silently leaves you on the much slower Python-only path β
so check:
import midas_index.backend_c as b; print(b.available()) # True = c-omp indexer present
import midas_fit_grain.backend_c as f; print(f.available()) # True = c-omp refiner presentSee packages/midas_suite/README.md for the
full breakdown of what pip does and does not give you.
| Platform | Requirements |
|---|---|
| macOS | Homebrew, LLVM, libomp, GCC, CMake, jemalloc |
| Linux | GCC β₯ 9, CMake β₯ 3.16 |
| Windows | WSL with Ubuntu |
MIDAS automatically downloads and builds these C/C++ dependencies during compilation: NLOPT, LIBTIFF, FFTW, HDF5, BLOSC, BLOSC-2, ZLIB, LIBZIP.
git clone https://github.com/marinerhemant/MIDAS.git
cd MIDAS-
Install Homebrew (if not already installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Without sudo access, install to your home directory:
mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/main | tar xz --strip-components 1 -C homebrew eval "$(homebrew/bin/brew shellenv)" brew update --force --quiet chmod -R go-w "$(brew --prefix)/share/zsh"
Add Homebrew to your PATH:
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> ~/.zshrc source ~/.zshrc
-
Install dependencies:
brew install llvm libomp gcc cmake jemalloc
-
Configure environment variables:
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc echo 'export LDFLAGS="-L/opt/homebrew/opt/llvm/lib $LDFLAGS"' >> ~/.zshrc echo 'export CPPFLAGS="-I/opt/homebrew/opt/llvm/include $CPPFLAGS"' >> ~/.zshrc echo 'export LDFLAGS="-L/opt/homebrew/opt/libomp/lib $LDFLAGS"' >> ~/.zshrc echo 'export CPPFLAGS="-I/opt/homebrew/opt/libomp/include $CPPFLAGS"' >> ~/.zshrc echo 'CC=/opt/homebrew/opt/gcc/bin/gcc-15' >> ~/.zshrc echo 'export CC' >> ~/.zshrc echo 'CXX=/opt/homebrew/opt/gcc/bin/g++-15' >> ~/.zshrc echo 'export CXX' >> ~/.zshrc source ~/.zshrc
-
Build:
./build.sh
./build.shsudo ./build_wsl_windows.sh# Disable CUDA support
./build.sh --cuda OFF
# Specify a custom nvcc compiler path
./build.sh --nvcc /usr/local/cuda-12/bin/nvcc
# Or pass it directly to cmake
cd build && cmake .. -DCMAKE_CUDA_COMPILER=/path/to/cuda/bin/nvcc && cmake --build . -j
# Specify target CUDA architectures (default is "86;90")
cd build && cmake .. -DCMAKE_CUDA_ARCHITECTURES="75;80" && cmake --build . -j
# Build and run benchmarks
./build.sh --test all
# Build a single target
cd build
cmake --build . --target IntegratorFitPeaksGPUStreamEach time you pull the latest changes, rebuild the C binaries:
cd MIDAS/build
cmake --build .conda env create -f environment.yml
conda activate midas_envOr install the required packages manually:
pip install numpy scipy h5py parsl- Calibrate the detector geometry β FF_Calibration
- Run FF-HEDM grain indexing and fitting β FF_Analysis
- Visualize results interactively β FF_Interactive_Plotting
- Match/stitch grains across load states or layers β FF_Match_Stack_Reconstructions
- Reconstruct NF-HEDM orientation maps β NF_Analysis
- Validate with forward simulation β Forward_Simulation
See the manuals README for the full step-by-step checklist.
conda activate midas_env
cd FF_HEDM/Example
python ../workflows/ff_MIDAS.py -paramFN ps_ff.txtpython FF_HEDM/workflows/ff_MIDAS.py -paramFN ps_ff.txt -useGPU 1# Auto-detect last completed stage and resume:
python FF_HEDM/workflows/ff_MIDAS.py -paramFN ps_ff.txt -resume /path/to/consolidated.h5
# Or restart from a specific stage:
python FF_HEDM/workflows/ff_MIDAS.py -paramFN ps_ff.txt -restartFrom refinementpython FF_HEDM/workflows/ff_MIDAS.py -reprocess 1 -resultFolder /path/to/results/python utils/match_grains.py match \
--state1 unloaded/Grains.csv \
--state2 loaded/Grains.csv \
--space-group 225 --mode combined --weights 2.0 50.0MIDAS includes automated benchmark tests that validate every pipeline using synthetic data and built-in reference comparisons. Each test also runs pre-flight checks (binary existence, staleness, package availability) and prints an environment fingerprint to make failures easy to diagnose.
# Build and run all benchmarks
./build.sh --test all
# Or run benchmarks individually:
./build.sh --test ff # FF-HEDM only
./build.sh --test nf # NF-HEDM onlyconda activate midas_env
# FF-HEDM: Forward simulation β indexing β grain recovery (6-stage HDF5 comparison)
python tests/test_ff_hedm.py -nCPUs 4
# NF-HEDM: Forward simulation β reconstruction β orientation comparison (>80% < 0.25Β°)
python tests/test_nf_hedm.py -nCPUs 8
# Calibration + Integration: CeO2 ring fitting + peak strain residual
python tests/test_calibration_integration.py -nCPUs 4
# Phase ID: CeO2 detected, Au absent, lattice constant within 500 ppm
python tests/test_phase_id.py -nCPUs 4
# Tomography: Shepp-Logan phantom β FBP reconstruction β Pearson correlation > 0.85
python tests/test_tomo.py -nCPUs 4All tests support built-in diagnostic flags for troubleshooting:
# Generate a JSON diagnostic report with full environment and comparison details
python tests/test_ff_hedm.py -nCPUs 4 --diagnose
# Save the generated output file alongside the reference for manual comparison
python tests/test_ff_hedm.py -nCPUs 4 --save-on-failSend the generated diagnostic report to hsharma@anl.gov for assistance.
See tests/README.md for detailed documentation on what each test computes, how results are compared, and exact pass/fail criteria.
If you use MIDAS in your research, please cite:
In review, citations coming soon.
FF-HEDM methodology:
H. Sharma, R. M. Huizenga & S. E. Offerman, "A fast methodology to determine the characteristics of thousands of grains using three-dimensional X-ray diffraction. I. Overlapping diffraction peaks and parameters of the experimental setup," J. Appl. Cryst. 45, 693β704 (2012). DOI: 10.1107/S0021889812025563
H. Sharma, R. M. Huizenga & S. E. Offerman, "A fast methodology to determine the characteristics of thousands of grains using three-dimensional X-ray diffraction. II. Volume, centre-of-mass position, crystallographic orientation and strain state of grains," J. Appl. Cryst. 45, 705β718 (2012). DOI: 10.1107/S0021889812025599
MIDAS is released under the UChicago Argonne open-source license.
Copyright Β© 2012, UChicago Argonne, LLC. All rights reserved.
This product includes software produced by UChicago Argonne, LLC under Contract No. DE-AC02-06CH11357 with the Department of Energy.
