Metadata-Version: 2.4
Name: metaxtract
Version: 0.1.3
Summary: Metadata extractor and converter for scientific instrument file formats (AFM, EM, X-ray).
Author-email: Chirayu Patel <Chirayupatel911@gmail.com>
Maintainer-email: Joshua Agar <joshagar@gmail.com>
License: BSD 3-Clause License
        
        Copyright (c) 2024, M3-Learning: Multifunctional Materials and Machine Learning
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Homepage, https://gitlab.com/dataerai/MetaXtract
Project-URL: Documentation, https://dataerai.gitlab.io/MetaXtract/
Project-URL: Source, https://gitlab.com/dataerai/MetaXtract
Project-URL: Changelog, https://gitlab.com/dataerai/MetaXtract/-/blob/main/CHANGELOG.md
Project-URL: Issues, https://gitlab.com/dataerai/MetaXtract/-/issues
Keywords: metadata,afm,xrd,electron-microscopy,hyperspy,scientific-data
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: AUTHORS.rst
Requires-Dist: numpy>=1.23
Requires-Dist: h5py>=3.7
Requires-Dist: igor2>=0.5
Requires-Dist: lxml>=4.9
Requires-Dist: hyperspy>=2.0
Provides-Extra: converters
Requires-Dist: xarray>=0.20.0; extra == "converters"
Requires-Dist: netCDF4>=1.6; extra == "converters"
Provides-Extra: utils
Requires-Dist: requests>=2.25.0; extra == "utils"
Provides-Extra: checksums
Requires-Dist: blake3>=0.3.0; extra == "checksums"
Provides-Extra: viz
Requires-Dist: plotly>=5.0.0; extra == "viz"
Requires-Dist: nbformat>=4.2.0; extra == "viz"
Requires-Dist: matplotlib>=3.5; extra == "viz"
Provides-Extra: all
Requires-Dist: metaxtract[checksums,converters,utils,viz]; extra == "all"
Provides-Extra: testing
Requires-Dist: pytest>=7.4; extra == "testing"
Requires-Dist: pytest-cov>=4.1; extra == "testing"
Requires-Dist: pytest-xdist>=3.5; extra == "testing"
Requires-Dist: pytest-timeout>=2.2; extra == "testing"
Requires-Dist: pytest-mock>=3.12; extra == "testing"
Provides-Extra: docs
Requires-Dist: sphinx>=7.0; extra == "docs"
Requires-Dist: nbsphinx>=0.9; extra == "docs"
Requires-Dist: ipython>=8.0; extra == "docs"
Requires-Dist: pydata-sphinx-theme>=0.15; extra == "docs"
Requires-Dist: myst-parser>=2.0; extra == "docs"
Requires-Dist: sphinx-copybutton>=0.5; extra == "docs"
Requires-Dist: sphinx-design>=0.5; extra == "docs"
Requires-Dist: jupyter>=1.0; extra == "docs"
Provides-Extra: dev
Requires-Dist: metaxtract[docs,testing]; extra == "dev"
Requires-Dist: ruff>=0.4; extra == "dev"
Requires-Dist: pre-commit>=3.6; extra == "dev"
Requires-Dist: build>=1.0; extra == "dev"
Requires-Dist: twine>=4.0; extra == "dev"
Requires-Dist: python-semantic-release>=9.8; extra == "dev"
Dynamic: license-file

# MetaXtract

[![PyPI](https://img.shields.io/pypi/v/metaxtract.svg)](https://pypi.org/project/metaxtract/)
[![Python](https://img.shields.io/pypi/pyversions/metaxtract.svg)](https://pypi.org/project/metaxtract/)
[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Pipeline](https://gitlab.com/dataerai/MetaXtract/badges/main/pipeline.svg)](https://gitlab.com/dataerai/MetaXtract/-/pipelines)
[![Coverage](https://gitlab.com/dataerai/MetaXtract/badges/main/coverage.svg)](https://gitlab.com/dataerai/MetaXtract/-/pipelines)
[![Docs](https://img.shields.io/badge/docs-gitlab--pages-blue.svg)](https://dataerai.gitlab.io/MetaXtract/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

## Overview

**MetaXtract** is a Python package designed to extract metadata from various scientific file formats including:

- `.h5` (HDF5)
- `.xrdml` (XRDML XML-based)
- `.dm4` (DigitalMicrograph)
- `.ibw` (Igor Binary Wave)

## Installation

### From PyPI

```bash
# Basic installation (metadata extraction only)
pip install metaxtract

# With converters (xarray + netCDF4)
pip install "metaxtract[converters]"

# With every optional feature (converters, utils, checksums, viz)
pip install "metaxtract[all]"
```

### From source

```bash
git clone https://gitlab.com/dataerai/MetaXtract.git
cd MetaXtract
pip install -e ".[dev]"     # editable install + tests, docs, lint, build tools
```

### Optional Dependencies

- **xarray** (`[converters]`): Required for file conversion to netCDF format
- **requests** (`[utils]`): Required for the `download_file()` utility function
- **blake3** (`[checksums]`): Optional faster checksum algorithm (falls back to sha256 if not available)
- **plotly** (`[viz]`): Required for interactive visualizations (metadata and data visualization)

## Documentation

Full documentation is available at: https://dataerai.gitlab.io/MetaXtract/

## Usage

### Using the High-Level API

```python
from metaxtract import extract_metadata, get_supported_formats

# Get list of supported formats
formats = get_supported_formats()
print(formats)

# Extract metadata from a file
metadata = extract_metadata("path/to/file.h5")
print(metadata)
```

### Data Type Detection

```python
from metaxtract import extract_metadata, detect_data_type

# Extract metadata
metadata = extract_metadata("file.ibw")

# Automatically detect data type
result = detect_data_type(metadata)
if result:
    print(f"Data Type: {result['type']}")
    print(f"Confidence: {result['confidence']:.2%}")
```

### Visualization

```python
from metaxtract import convert_file
from metaxtract.viz import visualize_data, visualize_metadata_tree

# Visualize metadata
metadata = extract_metadata("file.ibw")
fig = visualize_metadata_tree(metadata)
fig.show()

# Visualize data (automatically detects type and routes to appropriate visualization)
dataset = convert_file("file.ibw")
fig = visualize_data(dataset)
fig.show()
```

### Utility Functions

```python
from metaxtract.utils import download_file, benchmark_checksums

# Download a file
file_path = download_file("https://example.com/data.ibw")

# Benchmark checksum algorithms
results = benchmark_checksums("data.ibw", algorithms=['sha256', 'md5', 'blake3'])
```

### Running the extractor

### For h5 File type

```python
from metaxtract.instruments.AFM.bandexcitation.h5 import H5
import json
from pprint import pprint

process_file = H5("path/to/file")
metadata = process_file.extract()

print(metadata)
pprint(metadata)  # Pretty Print likewise
print(json.dumps(metadata, indent=4))  # Print metadata in JSON format
```
### For xrdml file type

```python
from metaxtract.instruments.Xray.panalytical.xrdml import XRDML
import json
from pprint import pprint

process_file = XRDML("path/to/file")
metadata = process_file.extract()

print(metadata)
pprint(metadata)  # Pretty Print likewise
print(json.dumps(metadata, indent=4))  # Print metadata in JSON format

```
### For dm4 file type

```python
from metaxtract.instruments.EM.dm.dm4 import DM4
import json
from pprint import pprint

process_file = DM4("path/to/file")
metadata = process_file.extract()

print(metadata)
pprint(metadata)  # Pretty Print likewise
print(json.dumps(metadata, indent=4))  # Print metadata in JSON format
```
### For ibw file type

```python
from metaxtract.instruments.AFM.oxfordAFM.ibw import IBW
import json
from pprint import pprint

process_file = IBW("path/to/file")
metadata = process_file.extract()

print(metadata)
pprint(metadata)  # Pretty Print likewise
print(json.dumps(metadata, indent=4))  # Print metadata in JSON format
```

## Links

- **Source Code**: https://gitlab.com/dataerai/MetaXtract
- **Documentation**: https://dataerai.gitlab.io/MetaXtract/
- **Package Registry**: https://gitlab.com/dataerai/MetaXtract/-/packages
- **Issues**: https://gitlab.com/dataerai/MetaXtract/-/issues

## Contributing

Contributions are welcome! Please see [CONTRIBUTING.rst](CONTRIBUTING.rst) for guidelines.

## License

This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.
