Skip to content

API Reference

Python API documentation for Hyperseed.

Overview

Hyperseed provides a Python API for programmatic control of the hyperspectral analysis pipeline. This allows you to:

  • Integrate Hyperseed into your own workflows
  • Customize processing beyond CLI capabilities
  • Build custom applications using Hyperseed components

Modules

Quick Start Example

from hyperseed import ENVIReader, Settings
from hyperseed.core.calibration import ReflectanceCalibrator
from hyperseed.core.preprocessing import PreprocessingPipeline
from hyperseed.core.segmentation import SeedSegmenter
from hyperseed.core.extraction import SpectralExtractor

# Load data
reader = ENVIReader("path/to/data.hdr")
data = reader.read_data()
wavelengths = reader.get_wavelengths()

# Calibrate (automatically handles bad pixel correction)
calibrator = ReflectanceCalibrator(clip_negative=True, clip_max=1.0)
calibrated, reader = calibrator.calibrate_from_directory("path/to/dataset")

# Preprocess
settings = Settings()
preprocessor = PreprocessingPipeline(settings.preprocessing)
processed = preprocessor.fit_transform(calibrated)

# Segment
segmenter = SeedSegmenter(settings.segmentation)
mask, n_seeds = segmenter.segment(processed)

# Extract spectra
extractor = SpectralExtractor()
results = extractor.extract(calibrated, mask, wavelengths)

# Save results
extractor.save_csv("results.csv")

Installation for API Use

# Install from PyPI
pip install hyperseed

# Or from source for development
git clone https://github.com/nishad/hyperseed
cd hyperseed
pip install -e ".[dev]"

Jupyter Notebooks

Hyperseed works great in Jupyter notebooks for interactive analysis:

# In Jupyter
import hyperseed
from hyperseed import ENVIReader

# Load and visualize
reader = ENVIReader("data.hdr")
data = reader.read_data()

# Plot RGB composite
import matplotlib.pyplot as plt
rgb = data[:, :, [100, 50, 10]]  # Select R, G, B bands
plt.imshow(rgb)

Next Steps

Explore detailed API documentation for each module: