API Documentationο
This section provides comprehensive API documentation for developers who want to:
Extend the application with new features
Integrate the application into other workflows
Understand the codebase architecture
Contribute to development
Documentation Organizationο
The API documentation is organized by module:
Core Modulesο
Application entry point and global state management
main.py- Application bootstrap and lifecycleutils.py- Global utility functionsconfigs/- Configuration management system
Pagesο
Application pages and views
pages/home_page.py- Project management interfacepages/data_package_page.py- Data import and organizationpages/preprocess_page.py- Preprocessing pipeline interfacepages/analysis_page.py- Analysis method launcherpages/machine_learning_page.py- ML training and evaluationpages/workspace_page.py- Workspace management
Componentsο
Reusable UI components
components/app_tabs.py- Tab management systemcomponents/toast.py- Notification systemcomponents/page_registry.py- Page registration and routingcomponents/widgets/- Custom widget library
Functionsο
Core processing algorithms
functions/preprocess/- Preprocessing methods (40+ algorithms)functions/visualization/- Plotting and visualizationfunctions/ML/- Machine learning pipelinefunctions/data_loader.py- Data import and parsingfunctions/utils.py- Processing utilities
Widgetsο
Custom widget library
Parameter input widgets (sliders, spin boxes, choice lists)
Matplotlib integration widgets
Results display panels
Grouping and selection widgets
Quick Referenceο
Key Classesο
Application Coreο
# Main application class
class RamanApp(QMainWindow):
"""Main application window with page management."""
# Configuration manager
class ConfigManager:
"""Load and manage application configuration."""
Data Managementο
# Dataset container
class RamanDataset:
"""Container for spectral data with metadata."""
# Data package manager
class DataPackageManager:
"""Manage multiple datasets and groups."""
Preprocessingο
# Base preprocessing method
class PreprocessingMethod(ABC):
"""Abstract base class for preprocessing methods."""
# Pipeline executor
class RamanPipeline:
"""Execute preprocessing pipelines."""
Analysisο
# Analysis method base
class AnalysisMethod(ABC):
"""Abstract base class for analysis methods."""
# Visualizer
class RamanVisualizer:
"""Generate plots and visualizations."""
Machine Learningο
# Model trainer
class ModelTrainer:
"""Train and evaluate ML models."""
# Model evaluator
class ModelEvaluator:
"""Generate evaluation metrics and plots."""
Common Patternsο
Adding a New Preprocessing Methodο
from functions.preprocess.registry import register_method
from functions.preprocess.base import PreprocessingMethod
@register_method(
name="My Method",
category="Baseline Correction",
description="Brief description"
)
class MyMethod(PreprocessingMethod):
"""
Detailed docstring following Google style.
Args:
spectrum: Input spectrum
param1: Description
param2: Description
Returns:
Processed spectrum
"""
@staticmethod
def get_parameters():
"""Define method parameters."""
return {
'param1': {'type': 'int', 'default': 10, 'range': (1, 100)},
'param2': {'type': 'float', 'default': 0.5, 'range': (0.0, 1.0)}
}
def process(self, spectrum, **params):
"""Process spectrum."""
# Implementation
return processed_spectrum
Adding a New Analysis Methodο
from pages.exploratory_analysis_page_utils.registry import register_analysis
from pages.exploratory_analysis_page_utils.base import AnalysisMethod
@register_analysis(
name="My Analysis",
category="Exploratory",
description="Brief description"
)
class MyAnalysis(AnalysisMethod):
"""Detailed docstring."""
def run(self, dataset, **params):
"""Execute analysis."""
# Implementation
return {
'primary_figure': fig1,
'secondary_figure': fig2,
'data_table': df,
'summary_text': summary,
'raw_results': results_dict
}
Creating Custom Widgetsο
from PySide6.QtWidgets import QWidget
from components.widgets.parameter_widgets import create_parameter_widget
class MyCustomWidget(QWidget):
"""Custom widget with proper signals."""
# Define signals
valueChanged = Signal(object)
def __init__(self, parent=None):
super().__init__(parent)
self.setup_ui()
def setup_ui(self):
"""Build UI components."""
# Layout and widgets
pass
def get_value(self):
"""Return current value."""
return self._value
def set_value(self, value):
"""Set value programmatically."""
self._value = value
self.valueChanged.emit(value)
Development Setupο
Prerequisitesο
# Clone repository
git clone https://github.com/zerozedsc/Raman-Spectroscopy-Analysis-Application.git
cd Raman-Spectroscopy-Analysis-Application
# Install with development dependencies
uv pip install -e ".[dev]"
Running Testsο
# Run all tests
uv run pytest
# Run specific test file
uv run pytest tests/test_preprocessing.py
# Run with coverage
uv run pytest --cov=functions --cov-report=html
Building Documentationο
# Install documentation dependencies
cd docs
pip install -r requirements.txt
# Build HTML documentation
make html
# View documentation
# Open docs/_build/html/index.html in browser
Code Styleο
We follow PEP 8 with Black formatting:
# Format code
black .
# Check formatting
black --check .
# Run linter
ruff check .
Architecture Overviewο
Module Dependenciesο
graph TD
A[main.py] --> B[pages/]
A --> C[configs/]
B --> D[components/]
B --> E[functions/]
D --> F[widgets/]
E --> G[preprocess/]
E --> H[visualization/]
E --> I[ML/]
Data Flowο
graph LR
A[Raw Data] --> B[data_loader]
B --> C[DataPackageManager]
C --> D[RamanPipeline]
D --> E[AnalysisMethod]
E --> F[RamanVisualizer]
F --> G[Results]
Signal/Slot Connectionsο
Key signals used throughout the application:
# Data signals
data_imported = Signal(str) # dataset_name
data_updated = Signal(str) # dataset_name
data_removed = Signal(str) # dataset_name
# Processing signals
processing_started = Signal()
processing_progress = Signal(int) # percentage
processing_finished = Signal(dict) # results
# UI signals
parameter_changed = Signal(str, object) # param_name, value
selection_changed = Signal(list) # selected_items
Extension Pointsο
Plugin System (Planned)ο
Future plugin system will allow:
Custom preprocessing methods
Custom analysis methods
Custom visualizations
Custom exporters
Integration APIsο
REST API (Planned)ο
Future REST API for:
Remote processing
Batch operations
Integration with LIMS systems
Command Line Interface (Planned)ο
Future CLI for:
Automated processing pipelines
Batch analysis
Continuous integration
Contributingο
See Contributing Guide for:
Code contribution guidelines
Pull request process
Testing requirements
Documentation standards
API Versioningο
This API follows semantic versioning:
Major version: Breaking changes
Minor version: New features, backward compatible
Patch version: Bug fixes
Current version: 1.0.0
Deprecation Policyο
Deprecated APIs will:
Emit warnings for at least one minor version
Be documented in Changelog
Suggest migration path
Be removed in next major version
Supportο
For API-related questions:
Check FAQ
Search GitHub Issues
Ask on GitHub Discussions
Licenseο
This API is part of the Raman Spectroscopy Analysis Application, licensed under MIT License.
See LICENSE for details.