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.
Metadata
Release files for spectramap 0.6.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| spectramap-0.6.4.tar.gz | 31.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| spectramap-0.6.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.0 kB
Release files / spectramap-0.6.4.tar.gz
| Download URL | spectramap-0.6.4.tar.gz |
|---|---|
| Size | 31.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3df461d8809220d0d25e88b8a1eeba8a9d0ac97673b0b74392ad918cf755d0a4
|
|
BLAKE2b-256 checksum How to use checksums |
c252b2417dfe9010c742efe0bafd34d1be35259f65305341b9c6c7b73a8bb907
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / spectramap-0.6.4-py3-none-any.whl
| Download URL | spectramap-0.6.4-py3-none-any.whl |
|---|---|
| Size | 28.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d0c0e7cbfc984ee718509528dc7f62918ab8727138e67c82e2e99c8a19c966bf
|
|
BLAKE2b-256 checksum How to use checksums |
a5605c4288a6e241d81cfa3d3ad6e65aab19fd075a0967be25a6e1c3188a31d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for spectramap 0.6.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.