This Python script extracts essential metadata from DIAD tomography scan .nxs (NeXus) files and outputs the information into a structured, human-readable .txt file. The output is organized into clearly defined sections for easier interpretation.
- Dynamic file selection through command-line or GUI file dialog.
- Human-readable date and time formatting.
- Duration displayed in
hh mm ssformat. - Organized metadata output with clear section headers:
- General Information
- Instrument Parameters
- Scanning Parameters
- Reconstruction Info
- Python 3.7 or higher
- Required Python packages:
h5pytkinterargparsedatetimere
Install dependencies with:
pip install h5pyRun the script from the command line by specifying the file path:
python metadata_extractor.py --file_path "C:\path\to\file.nxs"Simply run the script without arguments to open a file dialog:
python metadata_extractor.pyThe script generates a .txt file in the same directory as the input .nxs file. The output will be structured as follows:
=== General Information ===
Beamline: k11
Experiment no.: mg12345-1
Scan no.: k11-45357
Start Time: Wednesday, July 31, 2024 at 11:52:39 PM
=== Instrument Parameters ===
X-ray beam type: Monochromatic
Nominal Energy (keV): 25
Propagation dist. (mm): 150.0
=== Scanning Parameters ===
PCO Exposure Time (s): 0.05
Duration: 02h 15m 42s
No. of flats: 10
No. of darks: 10
No. of projection: 500
Start angle: 0.0
Stop angle: 180.0
Angular step: 0.1
=== Reconstruction Info ===
savu PL: /path/to/savu/config.json
- Ensure
.nxsfiles are accessible and not in use by another application. - Compatible with Windows and cross-platform systems.
This project is licensed under the MIT License.