Skip to main content

A Python Ramanome Analysis Toolkit for ML/DL-friendly analysis

Project description

PyRamEx

A Python Ramanome Analysis Toolkit for Machine Learning and Deep Learning

CI/CD codecov PyPI version Python Versions License: MIT


๐ŸŽฏ Overview

PyRamEx is a Python reimplementation of RamEx (R package), specifically optimized for machine learning and deep learning workflows. It provides comprehensive tools for Raman spectroscopic data analysis with seamless integration with modern ML/DL frameworks.

Key Features

โœ… ML/DL-Native Design - NumPy/Pandas data structures, Scikit-learn/PyTorch/TensorFlow integration
โœ… Method Chaining - Fluent API for preprocessing pipelines
โœ… Modern Python - Type hints, async support, comprehensive testing
โœ… GPU Acceleration - Optional CUDA support (replaces OpenCL)
โœ… Interactive Visualization - Plotly/Matplotlib support
โœ… Jupyter Friendly - Designed for notebook-based exploration


๐Ÿš€ Quick Start

Installation

# Basic installation
pip install pyramex

# With ML/DL dependencies
pip install pyramex[ml]

# With GPU support
pip install pyramex[gpu]

Basic Usage

from pyramex import Ramanome, load_spectra

# Load data
data = load_spectra('path/to/spectra/')

# Preprocess with method chaining
data = data.smooth(window_size=5) \
           .remove_baseline(method='polyfit') \
           .normalize(method='minmax')

# Quality control
qc = data.quality_control(method='icod', threshold=0.05)
data_clean = data[qc.good_samples]

# Dimensionality reduction
data_clean.reduce(method='pca', n_components=2)
data_clean.plot_reduction(method='pca')

# Machine Learning integration
from sklearn.ensemble import RandomForestClassifier
X_train, X_test, y_train, y_test = data_clean.to_sklearn_format()
model = RandomForestClassifier()
model.fit(X_train, y_train)
print(f"Accuracy: {model.score(X_test, y_test):.2%}")

๐Ÿ“š Documentation


๐ŸŽ“ Comparison with RamEx (R)

Feature RamEx (R) PyRamEx (Python)
Language R Python 3.8+
ML Integration Limited Native (sklearn, PyTorch, TF)
GPU Support OpenCL CUDA (optional)
Data Format S4 objects NumPy/Pandas
Visualization ggplot2 Plotly/Matplotlib
Interactivity Shiny Jupyter + Streamlit
API Style R functions Python method chaining

๐Ÿ“Š Project Structure

pyramex/
โ”œโ”€โ”€ pyramex/
โ”‚   โ”œโ”€โ”€ __init__.py              # Package entry point
โ”‚   โ”œโ”€โ”€ core/                    # Core data structures
โ”‚   โ”œโ”€โ”€ io/                      # Data loading
โ”‚   โ”œโ”€โ”€ preprocessing/           # Spectral preprocessing
โ”‚   โ”œโ”€โ”€ qc/                      # Quality control
โ”‚   โ”œโ”€โ”€ features/                # Feature engineering
โ”‚   โ”œโ”€โ”€ ml/                      # ML/DL integration
โ”‚   โ””โ”€โ”€ visualization/           # Plotting tools
โ”œโ”€โ”€ tests/                       # Unit tests
โ”œโ”€โ”€ examples/                    # Jupyter notebooks
โ”œโ”€โ”€ docs/                        # Documentation
โ”œโ”€โ”€ setup.py                     # Package configuration
โ”œโ”€โ”€ requirements.txt             # Dependencies
โ”œโ”€โ”€ LICENSE                      # MIT License
โ”œโ”€โ”€ README.md                    # This file
โ””โ”€โ”€ .github/workflows/           # CI/CD

๐Ÿ”ฌ Features

Data Loading

  • Support for multiple Raman file formats
  • Automatic format detection
  • Batch loading from directories

Preprocessing

  • Smoothing (Savitzky-Golay)
  • Baseline removal (polyfit, ALS, airPLS)
  • Normalization (minmax, zscore, area, max, vecnorm)
  • Spectral cutoff and derivatives

Quality Control

  • ICOD (Inverse Covariance-based Outlier Detection)
  • MCD (Minimum Covariance Determinant)
  • T2 (Hotelling's T-squared)
  • SNR (Signal-to-Noise Ratio)
  • Dis (Distance-based)

Dimensionality Reduction

  • PCA (Principal Component Analysis)
  • UMAP (Uniform Manifold Approximation and Projection)
  • t-SNE (t-Distributed Stochastic Neighbor Embedding)
  • PCoA (Principal Coordinate Analysis)

Machine Learning Integration

  • Scikit-learn format conversion
  • PyTorch Dataset creation
  • TensorFlow Dataset creation
  • Pre-defined model architectures (CNN, MLP)

Visualization

  • Static plots (Matplotlib)
  • Interactive plots (Plotly)
  • Spectral plots, reduction plots, QC plots

๐Ÿ“– Example: Complete Workflow

from pyramex import Ramanome, load_spectra
from sklearn.ensemble import RandomForestClassifier

# 1. Load data
data = load_spectra('data/spectra/')

# 2. Preprocess
data = data.smooth() \
           .remove_baseline() \
           .normalize()

# 3. Quality control
qc = data.quality_control(method='icod')
data = data[qc.good_samples]

# 4. Dimensionality reduction
data.reduce(method='pca', n_components=50)

# 5. Train ML model
X_train, X_test, y_train, y_test = data.to_sklearn_format()
model = RandomForestClassifier(n_estimators=100)
model.fit(X_train, y_train)

# 6. Evaluate
accuracy = model.score(X_test, y_test)
print(f"Test Accuracy: {accuracy:.2%}")

๐Ÿค Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

# Clone the repository
git clone https://github.com/openclaw/pyramex.git
cd pyramex

# Install development dependencies
pip install -e .[dev]

# Run tests
pytest

# Run linting
black pyramex/
flake8 pyramex/
mypy pyramex/

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

Note: PyRamEx is derived from RamEx (R package), which is licensed under GPL. The original RamEx license and attribution are preserved in the NOTICE file.


๐Ÿ™ Acknowledgments


๐Ÿ“ž Contact


๐Ÿ“ˆ Roadmap

v0.1.0-alpha (Current)

  • โœ… Core functionality
  • โœ… Basic preprocessing
  • โœ… Quality control
  • โœ… ML/DL integration

v0.2.0-beta (Planned: March 2026)

  • Complete unit tests
  • Example datasets
  • Streamlit web app
  • GPU acceleration

v0.3.0-rc (Planned: April 2026)

  • Marker analysis
  • IRCA analysis
  • Phenotype analysis
  • Spectral decomposition

v1.0.0-stable (Planned: June 2026)

  • Complete feature set
  • Pre-trained models
  • Plugin system
  • Academic paper

Developer: ๅฐ้พ™่™พ1ๅท ๐Ÿฆž
Status: ๐ŸŸข Active Development

Made with โค๏ธ for the Raman spectroscopy community

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

pyramex-0.1.0.tar.gz (51.3 kB view details)

Uploaded Source

Built Distribution

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

pyramex-0.1.0-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file pyramex-0.1.0.tar.gz.

File metadata

  • Download URL: pyramex-0.1.0.tar.gz
  • Upload date:
  • Size: 51.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for pyramex-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ec7a0c3182c0d6137802bc84e11f5d903e1f84c71fbf462a441d85f68c22f0b1
MD5 31ba3edfe0c143ad3d68571bf4042aed
BLAKE2b-256 09fedf8becef6f1c494ece4753216766dd75ed571b52f9034f8979924077053d

See more details on using hashes here.

File details

Details for the file pyramex-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyramex-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 30.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for pyramex-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a1a81860d02c031f00e3f3ee77b060a3006cc20aed78ae6f9fc1b790f3b0917
MD5 adfc8e59816099df441d7221c1df3e23
BLAKE2b-256 bd88681166eb1b834edbf7d1af4da7b6b51cc2b0d3901e28781710cd8fa6070e

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