Skip to main content

Hyperspectral package for spectroscopists

Project description

Features

The package includes standard tools such as reading, preprocessing, processing and visualization. The designing was focused on working hyperspectral images from Raman datasets. The package is extended to other spectroscopies as long as the data follows the type data structure. Some features are shown by the next figures.

  • Preprocessing: some tool such as smoothing, removal of spikes, normalization and advanced baseline corrections are included. Figure 1 illustrates a mean and standard deviation of a tissue signature.

Figure 1 Visualization of tissue Raman signature

  • Processing: some tools such as unmixing, pca, pls, vca and hierarchical and kmeans clustering are included. Figure 2 displays application of clustering for locating microplastics on complex matrices.


    Figure 2 Segmentation by clustering: (a) clustered image, (b) unmixing image, (c) image and (d) mean clusters

  • Visualization: the next examples shows the pca scores of several biomolecules.

Figure 3 PCA scores

Further upcoming developments:

  • Graphical User Interface

  • Supervised tools

  • Use of large language models

  • Optimizing speed and organizing main code

  • More examples

Installation

The predetermined work interface is Python 3. The library comes with 8 different hyperspectral examples and analysis. A manual presents the relevant functions and examples Manual.

Install the library and required packages: (admin rights):

pip install spectramap

Quick Start Examples

Below are quick examples demonstrating how to use spectramap for hyperspectral imaging analysis.

Example 1: Microplastics Analysis (DBSCAN Clustering)

This example reads hyperspectral data of microplastics, applies density-based clustering, and displays the mapped clusters.

from spectramap import spmap as sp

# Create hyper_object
micro = sp.hyper_object('MP')

# Read hyperspectral data
path = 'examples/microplastics_tissue/microplastics_tissue'
micro.read_csv_xz(path)

# Apply Hierarchical Density-Based Clustering
micro.dbscan(5, 0.5)

# Display 2D map and spectral cluster stack
colors = micro.show_map(['gray', 'k', 'r'], None, 1)
micro.show_stack(0, 0, colors)

Example 2: Bladder Tissue Segmentation (K-Means Clustering)

This example demonstrates k-means clustering and background removal.

from spectramap import spmap as sp

bladder = sp.hyper_object("bladder")
bladder.read_csv_xz("examples/bladder/bladder")

# Set step size resolution (e.g. 300 µm) and normalize
bladder.set_resolution(0.3)
bladder.vector()

# K-means clustering and label removal
bladder.kmeans(3)
bladder.remove_label([1]) # Removing background label

# Display
colors = bladder.show_map(['black', 'green'], None, 1)
bladder.show_stack(0, 0, colors)

License

MIT

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

References

[1] F. Pedregosa, G. Varoquaux, and A. Gramfort, “Scikit-learn: Machine Learning in Python,” Journal of Machine Learning Research, vol. 12, pp. 2825-- 2830, 2011.

[2] J. M. P. Nascimento and J. M. B. Dias, “Vertex component analysis: A fast algorithm to unmix hyperspectral data,” IEEE Transactions on Geoscience and Remote Sensing, vol. 43, no. 4, pp. 898–910, 2005, doi: 10.1109/TGRS.2005.844293.

[3] Z. M. Zhang, S. Chen, and Y. Z. Liang, “Baseline correction using adaptive iteratively reweighted penalized least squares,” Analyst, vol. 135, no. 5, pp. 1138–1146, 2010, doi: 10.1039/b922045c.

[4] L. McInnes, J. Healy, S. Astels, hdbscan: Hierarchical density based clustering In: Journal of Open Source Software, The Open Journal, volume 2, number 11. 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.2.tar.gz (31.0 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.2-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spectramap-0.6.2.tar.gz
  • Upload date:
  • Size: 31.0 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.2.tar.gz
Algorithm Hash digest
SHA256 308d37ac5e3b52bbfc2e4c742ba5276d724cef787d06601cab50827cacc9b82f
MD5 e596e29f6e48d8437fdfb5aa3351b554
BLAKE2b-256 220a65b7c214c71fd962246c2437effc91f3704cbef8d7cbd416ce9de7285434

See more details on using hashes here.

File details

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

File metadata

  • Download URL: spectramap-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 28.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1bb3aa01b3c1dfcd4de13dda79c686e1160935703689c1650395dfd6790136bb
MD5 dee46ab94c97176bb47f05b8c7627ebc
BLAKE2b-256 fa1eaa053df514f990f06810e4a360d3485f83b6144ac745d755668044452383

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