Hyperspectral package for spectroscopists
Project description
SpectraMap (SpMap)
A Robust Hyperspectral Analysis Package for Spectroscopists in Python
Hyperspectral imaging has critical applications across medicine, agriculture, pharmaceuticals, materials science, and food quality control. SpectraMap provides an advanced, fast, and highly structured framework specifically designed for analyzing Raman and other spectroscopic hyperspectral data.
Recently optimized with a robust architecture, SpectraMap validates data types to ensure reliable and error-free execution of advanced processing techniques like clustering, unmixing, and deep dimensionality reduction.
🛠️ Key Features
SpectraMap is built around the highly versatile hyper_object class. It includes comprehensive tools covering the entire hyperspectral workflow:
1. Robust Data Type Architecture
SpectraMap strictly validates processing operations based on your data type to prevent computational errors:
hyper_image: Full 2D/3D spatial spectral maps (supports spatial mapping, unmixing, and image segmentation).multi_spectra: Collections of independent spectra without spatial relations (supports PCA, PLS-LDA, scatter plotting).single_spectrum: Individual spectral signatures (supports baseline correction, smoothing, peak analysis).
2. Preprocessing & Correction
Advanced baseline corrections, smoothing algorithms, spike removal, and normalizations.
Figure 1: Mean and standard deviation visualization of a tissue Raman signature.
3. Machine Learning & Processing
Includes powerful unsupervised and supervised tools:
- Clustering: K-Means, Hierarchical (HCA), and Density-Based (DBSCAN/HDBSCAN).
- Dimensionality Reduction: Principal Component Analysis (PCA) and Partial Least Squares Discriminant Analysis (PLS-LDA).
- Unmixing: Vertex Component Analysis (VCA) for extracting pure endmembers.
Figure 2: Segmentation of microplastics on complex matrices via clustering algorithms.
4. Advanced Visualization
High-quality rendering of false-color maps, spectral stacks, and scatter profiling.
Figure 3: 2D PCA scores distinguishing different biomolecular components.
🚀 Installation
SpectraMap is available on PyPI and requires Python 3.
pip install spectramap
For comprehensive documentation and all 7 extended hyperspectral examples, please see the Official Manual.
📖 Quick Start Guide
Example 1: Hyperspectral Image (HDBSCAN Clustering)
from spectramap import spmap as sp
# Initialize as a hyperspectral image (default)
micro = sp.hyper_object('Microplastics', data_type='hyper_image')
micro.read_csv_xz('examples/microplastics_tissue/microplastics_tissue')
# Preprocessing to remove background and highlight sharp peaks
micro.keep(400, 1850)
micro.snip(30) # fast SNIP baseline correction
micro.gaussian(2)
micro.vector()
# Apply Hierarchical Density-Based Clustering (HDBSCAN)
micro.hdbscan(5, 5)
# Render the segmentation map and corresponding spectral stacks
colors = micro.show_map(['gray', 'k', 'r'], None, 1)
micro.show_stack(0.1, 0.5, colors)
Example 2: Multi-Spectra (PCA & PLS-LDA)
from spectramap import spmap as sp
# Initialize as independent multiple spectra
plastics = sp.hyper_object("Plastics", data_type="multi_spectra")
plastics.read_csv_xz('examples/plastics_PLS_PCA/plastics')
# Standard preprocessing
plastics.rubber(10)
plastics.vector()
# Principal Component Analysis
scores_pca, loadings_pca = plastics.pca(3)
scores_pca.show_scatter(main_label=15, size=15, colors="auto")
🗺️ Roadmap & Upcoming Developments
- Interactive Graphical User Interface (GUI)
- Integration of Supervised Deep Learning models
- Specialized spectral Large Language Model (LLM) agents
- Robust
data_typeattribute validation framework - MKDocs comprehensive manual and example gallery
📄 License & References
SpectraMap is distributed under the MIT License.
Key Algorithm References:
- Pedregosa et al., "Scikit-learn: Machine Learning in Python," JMLR, 2011.
- Nascimento & Dias, "Vertex component analysis," IEEE TGRS, 2005.
- Zhang et al., "Baseline correction using adaptive iteratively reweighted penalized least squares," Analyst, 2010.
- McInnes et al., "hdbscan: Hierarchical density based clustering," JOSS, 2017.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spectramap-0.6.4.tar.gz.
File metadata
- Download URL: spectramap-0.6.4.tar.gz
- Upload date:
- Size: 31.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3df461d8809220d0d25e88b8a1eeba8a9d0ac97673b0b74392ad918cf755d0a4
|
|
| MD5 |
f7ac05bcbedf8e8d024895e68e314adb
|
|
| BLAKE2b-256 |
c252b2417dfe9010c742efe0bafd34d1be35259f65305341b9c6c7b73a8bb907
|
File details
Details for the file spectramap-0.6.4-py3-none-any.whl.
File metadata
- Download URL: spectramap-0.6.4-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0c0e7cbfc984ee718509528dc7f62918ab8727138e67c82e2e99c8a19c966bf
|
|
| MD5 |
f8c1f6347a2d347785118c39156e02dd
|
|
| BLAKE2b-256 |
a5605c4288a6e241d81cfa3d3ad6e65aab19fd075a0967be25a6e1c3188a31d3
|