Skip to main content

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.

Tissue Signature

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.

Clustering Map Clustering Stack

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.

PCA Scores

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')

# Apply Hierarchical Density-Based Clustering
micro.hdbscan(min_samples=5, min_cluster=5)

# Render the segmentation map and corresponding spectral stacks
colors = micro.show_map(['gray', 'k', 'r'], None, 1)
micro.show_stack(0, 0, 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_type attribute validation framework
  • MKDocs comprehensive manual and example gallery

📄 License & References

SpectraMap is distributed under the MIT License.

Key Algorithm References:

  1. Pedregosa et al., "Scikit-learn: Machine Learning in Python," JMLR, 2011.
  2. Nascimento & Dias, "Vertex component analysis," IEEE TGRS, 2005.
  3. Zhang et al., "Baseline correction using adaptive iteratively reweighted penalized least squares," Analyst, 2010.
  4. McInnes et al., "hdbscan: Hierarchical density based clustering," JOSS, 2017.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spectramap-0.6.3.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spectramap-0.6.3-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file spectramap-0.6.3.tar.gz.

File metadata

  • Download URL: spectramap-0.6.3.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for spectramap-0.6.3.tar.gz
Algorithm Hash digest
SHA256 f7aa7fb575ddaa2c9c677fa2f46736c73a09dad59dcdf68e2d64f615e41f08d0
MD5 76d3e45e063300ab4b8755a7b445407c
BLAKE2b-256 3fc8b25a1d01e2e3f07c8596fa3961a7031e7a268d1f36701dc926503c8f4daf

See more details on using hashes here.

File details

Details for the file spectramap-0.6.3-py3-none-any.whl.

File metadata

  • Download URL: spectramap-0.6.3-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for spectramap-0.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 67d6a8beeade415a7c7cc66036ff2f8adcf50d2680c898a1a39d072183999364
MD5 cfbed4d83627e6ef1a655768d09ac562
BLAKE2b-256 0a4bb885f942645424392f21874c92afdadfc09af972fd57d56b03ba3c95faa7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page