Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laue diffraction and Grain Correlation Analysis

This project contains two Python scripts for analyzing and visualizing spatial correlation in grain-labeled microstructure images, and for visualizing feature distributions using a trained encoder model.


📁 Files

1. correlation_map.py

This script computes spatial correlation maps for different datasets (e.g., Laue, EBSD, PIML, XMAS) by measuring the probability of matching labels at shifted positions. It generates both 2D heatmaps and 1D cross-section plots.

✨ Features:

  • Computes spatial correlation using label agreement and np.roll.
  • Compares four datasets: uncorrected ML, physics-informed ML (PIML), EBSD, and XMAS.
  • Generates 2D correlation maps and X/Y slice plots.

📥 Data Inputs (expected in ../../data/):

  • data_laue_wodp.npy: uncorrected ML prediction.
  • data_laue_wdp.npy: physics-informed ML (PIML) prediction.
  • data_EBSD.npy: EBSD-labeled reference image.
  • correlation_map_XMAS.npy: precomputed XMAS correlation map.

2. piml.py

This script loads a pre-trained autoencoder and performs feature extraction on filtered grain image patches. It uses PCA to project learned features into RGB space for visualization.

✨ Features:

  • Loads a pre-trained convolutional encoder (encoder.json + encoder.h5).
  • Applies physics-informed filtering to highlight grain structures.
  • Extracts features from image patches and visualizes them via PCA coloring.

📥 Data Input (not included in repository):

  • all_au3_img.npy: Not included in the repository due to file size constraints.
    Please contact the author to obtain this data separately or place your own image stack at ../../data/all_au3_img.npy.

  • Encoder model directory: ./models/ae_conv_4_256_best/
    Must contain:

    • encoder.json
    • encoder.h5

🔧 Requirements

  • Python 3.7+
  • NumPy
  • SciPy
  • Matplotlib
  • Seaborn
  • scikit-learn
  • TensorFlow / Keras

Install dependencies via:

pip install numpy scipy matplotlib seaborn scikit-learn tensorflow keras

---

## 📊 Output

- **`correlation_map.py`**:
  - Displays 2D spatial correlation maps using `imshow`.
  - Plots 1D correlation profiles along X and Y directions.

- **`piml.py`**:
  - Visualizes PCA-reduced features as RGB images to reveal spatial similarity between grain patterns.

---

## 📦 Data Disclaimer

Some datasets used in this project are too large to be included in the repository.

- **`all_au3_img.npy`** (used in `piml.py`) is **not included** due to file size limitations.  
  You may request access by contacting **khchanbw@connect.ust.hk**, or provide your own image stack placed at:  
  `../../data/all_au3_img.npy`.

---

## ✍️ Author

Created by **khchanbw** — September 2024

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages