Skip to main content

See Beyond the Visible: The Magic of Hyperspectral Imaging

Project description

Documentation Status codecov

HSI Wizard

See Beyond the Visible: The Magic of Hyperspectral Imaging

HSI Wizard is a Python package designed to create a streamlined environment for hyperspectral imaging (HSI) analysis, from basic spectral analysis to advanced AI methods.

Features

  • DataCube Class for managing and processing HSI data.
  • Spectral plotting and visualization.
  • Clustering and spectral analytics.
  • Tools for merging and processing spectral data.
  • Data loaders for various file formats (e.g., NRRD, Pickle, TDMS, and XLSX).
  • Decorators for method tracking, input validation, and execution time logging.

Requirements


Installation

Via pip

You can install the package via pip:

pip install hsi-wizard

Compile from Source

Alternatively, you can compile HSI Wizard from source:

python -m pip install -U pip setuptools wheel            # Install/update build tools
git clone https://github.com/BlueSpacePotato/hsi-wizard   # Clone the repository
cd hsi-wizard                                             # Navigate into the directory
python -m venv .env                                       # Create a virtual environment
source .env/bin/activate                                  # Activate the environment
pip install -e .                                          # Install in editable mode
pip install wheel                                         # Install wheel
pip install --no-build-isolation --editable .             # Compile and install hsi-wizard

Documentation

The full documentation is available on ReadTheDocs:

Click here for Docs!


Usage

After installing the package, you can import the DataCube, read function, and plotter for quick HSI data analysis:

from wizard import DataCube, read, plotter

# Load an HSI datacube from a file
datacube = read('path_to_file')

# Visualize the datacube
plotter(datacube)

Modules

Core

DataCube

The DataCube class is the primary object for storing and working with hyperspectral data. It contains attributes for the data cube, wavelengths, and metadata, as well as methods for data manipulation.

Exploration

plotter

The plotter function enables you to easily visualize datacubes using various plotting methods, making it easier to explore hyperspectral data interactively.

Utils

helper

Helper functions, such as find_nex_greater_wave and find_nex_smaller_wave, provide utilities for working with spectral data. These functions allow you to quickly find neighboring wavelengths based on a given value and a deviation.

decorator

This module contains decorators used throughout the package. Key decorators include:

check_load_dc: Ensures that loading functions return valid numpy arrays. check_path: Validates file paths before processing. track_execution_time: Measures and prints the execution time of functions for performance tracking.

File Loaders

The package supports various file formats for hyperspectral data, including .nrrd, .pickle, .tdms, and .xlsx. Each file format has a dedicated loader function.


Key Concepts

DataCube

  • A DataCube is a 3D array of shape (v, x, y):
    • x and y represent the pixel dimensions.
    • v represents the spectral depth (wavelength).

Example:

from hsi_wizard import DataCube

# Define an empty DataCube
datacube = DataCube()

# Access a spectrum for a specific pixel
spectrum = datacube[:, 3, 3]

# Access a 2D slice of the cube at a specific wavelength
img_2d = datacube[3]

Difference Between read and load

  • read: Used for importing dedicated file types (e.g., .csv, .fsm).
  • load: Used for loading pre-processed data (e.g., existing numpy arrays).

Pre-Processing Levels

Based on the idea from DOI, we categorize the processing stages:

  • Level 0: Raw data captured directly from the sensor.
  • Level 1: Data processed in a straightforward manner (e.g., noise reduction).
  • Level 2: Heavily processed data, ready for advanced analysis.

To-Do List

  • Improved hyperparameter tuning using evol
  • R-support with patsy
  • Enhanced template creator.
  • Functions for merging multiple spectra.
  • Append spectra to existing datasets.
  • Saving files as .nrrd.
  • Data normalization.
  • Gaussian filter application.
  • Reflectance calculation: [ I_{\text{ref}} = \frac{I_{\text{raw}} - I_{\text{dark}}}{I_{\text{white}} - I_{\text{dark}}} ]
  • Optical density calculation: [ I_{\text{abs}} = -\log\left(\frac{I_{\text{raw}}}{I_{\text{ref}}}\right) ]
  • Principal Component Analysis (PCA).
  • Classification using Support Vector Machines (SVM).

Changelog

The changelog will be added when the beta version is stable.


Contributing

If you would like to contribute to this project, feel free to fork the repository, make changes, and submit a pull request. Please ensure that you adhere to the code style and include tests for any new features.


Acknowledgements

Thanks to Shopify for providing a free logo-building tool via Hatchful.

Icons made by Good Ware from Flaticon.

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

hsi_wizard-0.1.3.tar.gz (144.0 kB view details)

Uploaded Source

Built Distribution

hsi_wizard-0.1.3-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

Details for the file hsi_wizard-0.1.3.tar.gz.

File metadata

  • Download URL: hsi_wizard-0.1.3.tar.gz
  • Upload date:
  • Size: 144.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for hsi_wizard-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e64099b43e5db659a58c18db091b0c7234e934847f3905050fb02e81182bbbfb
MD5 b455a6a2f00975752c48db7f52f78825
BLAKE2b-256 affb7804565f6a5eda91751bacf4f5002fd319c3c35b0ae1776f190e71cb6ba9

See more details on using hashes here.

File details

Details for the file hsi_wizard-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: hsi_wizard-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 35.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for hsi_wizard-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2042b235c76cd3e73843fec43d1cff27da577764fd9673dc484b8c6a68f9017b
MD5 ce7e4f910acf84c0cb488f2df024828b
BLAKE2b-256 473fecf1bce870164b0218d71f051c7745554df2917c5a00bf54a833bad799e1

See more details on using hashes here.

Supported by

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