A modular desktop application for processing Ancorelog hyperspectral core scan data. It provides a Tkinter GUI with seven processing pipelines covering HSI extraction, reflectance correction, coregistration, masking, XRF processing, RGB extraction, and depth overlap correction.
- Prerequisites
- Installation
- Configuration
- Running the Application
- Project Structure
- Processing Pipelines
- Expected Folder Structure
- Troubleshooting
Before you begin, make sure the following are installed on your system:
- Python 3.9 or higher — Download Python
- Git — Download Git
- pip (comes bundled with Python)
To check your Python version:
python --versionFollow these steps exactly after cloning the repository.
git clone https://github.com/suvDMT/anc-data-processing.git
cd anc-data-processingA virtual environment keeps all dependencies isolated from your system Python.
python -m venv venvActivate it:
# On Windows
venv\Scripts\activate
# On Linux / macOS
source venv/bin/activateYou should see (venv) appear at the start of your terminal prompt.
PyTorch must be installed separately because the correct version depends on whether your machine has an NVIDIA GPU (CUDA) or not.
Option A — CPU only (no GPU):
pip install torch --index-url https://download.pytorch.org/whl/cpuOption B — GPU with CUDA 11.8:
pip install torch --index-url https://download.pytorch.org/whl/cu118Option C — GPU with CUDA 12.1:
pip install torch --index-url https://download.pytorch.org/whl/cu121Not sure which version to pick? Use the selector at https://pytorch.org/get-started/locally/
pip install -r requirements.txtThis installs all required packages at the exact versions the software was developed and tested with. PyTorch (installed in Step 3) will be skipped automatically since it is already satisfied.
Before running the application, open config.py and update the three path
constants to match your local machine:
# config.py
# Path to the Azure Tkinter theme file
THEME_PATH_FALLBACK = r"\path\to\azure.tcl"
# Path to the affine transform parameters file for SWIR/VNIR coregistration
TRANSFORM_PARAMETERS_FILE = r"\path\to\transform_parameters.txt"
# Path to the pre-trained PyTorch model file for HSI masking
MASK_MODEL_PATH = r"\path\to\your_model.pth"| Constant | What it points to | When it is used |
|---|---|---|
THEME_PATH_FALLBACK |
azure.tcl from the Azure TTK theme folder |
Every launch (GUI styling) |
TRANSFORM_PARAMETERS_FILE |
A .txt file with a 3x3 affine matrix (one row per line) |
Step 3 — Coregister |
MASK_MODEL_PATH |
A .pth PyTorch model checkpoint |
Step 4 — Mask HSI |
The
azure.tcltheme file is included in the repository under:tkinter_themes/Azure-ttk-theme-main/azure.tclPointTHEME_PATH_FALLBACKto that file.
With the virtual environment active and config.py configured, run:
python main.pyThe GUI window will open. Use the Browse buttons to set your input paths, then click the processing buttons in order.
anc-data-processing/
│
├── main.py # Entry point — run this file to launch the app
├── config.py # Global path constants — edit before first run
├── utils.py # Shared helpers (buffered I/O, stdout redirector)
│
├── extraction.py # CODE 1 — Extract & rename files from .ancprj archives
├── reflectance.py # CODE 2 — HSI reflectance correction using white panels
├── coregistration.py # CODE 3 — SWIR/VNIR coregistration via affine transform
├── masking.py # CODE 4 — HSI masking with pre-trained PyTorch model
├── xrf_processing.py # CODE 5 — XRF XML parsing, calibration & Excel export
├── rgb_extraction.py # CODE 6 — RGB core piece extraction & enhancement
├── depth_overlap.py # CODE 7 — Depth overlap detection & correction
│
├── gui.py # Tkinter window layout, widgets & button wiring
│
├── tkinter_themes/
│ └── Azure-ttk-theme-main/
│ └── azure.tcl # GUI dark/light theme
│
├── requirements.txt # Pinned Python dependencies
└── README.md
The GUI provides seven processing buttons. They are designed to be run in order for a complete workflow, though each can also be run independently.
| # | Button | Module | What it does |
|---|---|---|---|
| 1 | Extract Files from ANCPRJ | extraction.py |
Unzips .ancprj archives, pads HSI data to 384 samples, writes ENVI HDR metadata files |
| 2 | Correct HSI Files | reflectance.py |
Loads white reference panel data, calibrates and applies reflectance correction to both SWIR and VNIR cubes |
| 3 | Coregister VNIR/SWIR Data | coregistration.py |
Aligns SWIR and VNIR cubes using a pre-defined affine transform matrix and stitches them into a single composite |
| 4 | Mask HSI Files | masking.py |
Runs a segmentation model in a subprocess to generate binary masks and zero out background pixels in HSI data |
| 5 | Compile XRF Data | xrf_processing.py |
Parses XRF XML result files, applies element calibration formulas and exports a formatted Excel report |
| 6 | Extract RGB Core Pieces | rgb_extraction.py |
Crops individual core piece images from full-box RGB scans, applies enhancement and matches them to HSI filenames |
| 7 | Make Depth Overlap Correction | depth_overlap.py |
Detects depth overlaps between consecutive core boxes and corrects stop positions in XML and HDR files |
The Folder Path of ancprj input should point to a project root folder. Sub-folders are created automatically by each processing step:
<your_project_folder>/
│
├── *.ancprj <- Input: raw archive files (used by Step 1)
│
├── SWIR_HSI_Files/ <- Created by Step 1
├── VNIR_HSI_Files/ <- Created by Step 1
├── Extracted_WR/ <- Created by Step 1 (white reference files)
│
├── Corrected_SWIR/ <- Created by Step 2
├── Corrected_VNIR/ <- Created by Step 2
│
├── Coregistered_HSI/ <- Created by Step 3
│
└── Masked_HSI/ <- Created by Step 4
├── false_RGB/
└── false_RGB_Masks/
The GUI does not open / theme error
Update
THEME_PATH_FALLBACKinconfig.pyto point to the correctazure.tclfile inside thetkinter_themesfolder of this repository.
"Model file not found" error on masking
Update
MASK_MODEL_PATHinconfig.pyto the full path of your.pthfile.
"Failed to load transform parameters" error on coregistration
Update
TRANSFORM_PARAMETERS_FILEinconfig.py. The file must contain a 3x3 affine matrix — three rows, three space-separated float values per row.
PyTorch installs CPU version even though having a GPU
Make sure you installed PyTorch using the correct CUDA URL in Step 3 before running
pip install -r requirements.txt.
Import errors when running
Make sure your virtual environment is activated (
(venv)in terminal prompt) and that you ranpip install -r requirements.txtsuccessfully.