Skip to content

JRay-Lin/SpectraLab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FTIR Tools

A modern Python application for analyzing FTIR (Fourier Transform Infrared) spectroscopy data with an intuitive PyQt6 GUI interface. This tool processes FTIR spectral data from Jasco .jws files, providing visualization, baseline correction, and correlation analysis capabilities.

Python License PyQt6

Features

  • File Processing: Direct conversion of Jasco .jws files to custom YLK (JSON) format
  • Modern GUI: Clean PyQt6 interface with tabbed layout and embedded matplotlib plots
  • Spectral Visualization: Real-time plotting with toggle between raw and baseline-corrected data
  • Baseline Correction: Interactive baseline creation with live preview and parameter adjustment
  • Correlation Analysis: Pearson correlation matrix computation between multiple spectra
  • Data Management: Organized file lists with drag-and-drop selection
  • Recent Files: Persistent history of recently opened folders
  • Export Capabilities: PNG export functionality for visualizations

Prerequisites

uv Package Manager

This project uses uv for fast, reliable Python package management. Install uv first:

macOS and Linux:

curl -LsSf https://astral.sh/uv/install.sh | sh

Windows:

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Alternative installation methods:

# Via pip
pip install uv
# Via Homebrew (macOS)
brew install uv
# Via pipx
pipx install uv

System Requirements

  • Python: 3.12 or higher
  • Operating System: Windows, macOS, or Linux
  • Memory: 4GB RAM minimum, 8GB recommended
  • Storage: 100MB for installation plus space for your FTIR data

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/ftir-tools.git
    cd ftir-tools
  2. Install dependencies:

    uv sync

    This will automatically create a virtual environment and install all required packages.

  3. Run the application:

    uv run python main.py

Quick Start

  1. Launch the application:

    uv run python main.py
  2. Open a folder containing .jws files:

    • Go to File → Open Folder or use the recent folders menu
    • Select a folder containing your FTIR .jws files
  3. Select spectra for analysis:

    • Double-click files in the "All Files" list to add them to "Selected for Analysis"
    • Selected files will automatically appear in the plot
  4. View and analyze data:

    • Use the "Toggle Data Display" button to switch between raw and baseline-corrected views
    • Right-click on selected files to create custom baselines
    • Access correlation analysis from the Tools menu

Usage Guide

File Management

The application automatically converts .jws files to .ylk format (JSON-based) for faster processing:

  • Input: Jasco .jws files from your selected folder
  • Processing: Files are converted and stored in a converted_ylk/ subfolder
  • Output: Self-contained .ylk files with raw data, baseline, and metadata

Baseline Correction

  1. Right-click on a file in the "Selected for Analysis" list
  2. Choose "Create Baseline"
  3. A new tab opens with interactive baseline creation tools
  4. Adjust parameters and see live preview
  5. Save the baseline back to the .ylk file

Data Format (YLK)

The custom YLK format stores all spectral information in JSON:

{
  "name": "spectrum_name",
  "range": [min_wavenumber, max_wavenumber],
  "raw_data": {
    "x": [wavenumber_array],
    "y": [absorbance_array]
  },
  "baseline": {
    "x": [wavenumber_array],
    "y": [baseline_array]
  },
  "metadata": {
    "created": "timestamp",
    "source_file": "original_jws_filename",
    "baseline_params": {...}
  }
}

Project Structure

ftir-tools/
├── main.py                  # Main application entry point and FTIRAnalyzer class
├── modules/                 # Core functionality modules
│   ├── baseline.py          # Baseline correction algorithms
│   ├── data_processing.py   # Data preprocessing and analysis
│   ├── file_converter.py    # JWS to YLK conversion
│   └── plotting.py          # Matplotlib integration and visualization
├── pyproject.toml           # Project configuration and dependencies
├── uv.lock                  # Locked dependency versions
└── README.md                # This file

Key Dependencies

  • PyQt6 (>=6.5.0) - Modern cross-platform GUI framework
  • matplotlib (>=3.8.5) - Scientific plotting and visualization
  • pandas (>=2.2.1) - Data manipulation and analysis
  • scikit-learn (>=1.5.1) - Machine learning utilities
  • scipy - Signal processing and statistical functions
  • jws2txt (>=1.0.0) - Jasco file format conversion utility

Advanced Usage

Command Line Options

# Run with specific Python version
uv run --python 3.12 python main.py
# Run in development mode with debugging
uv run python main.py --debug

Custom Data Processing

The modular architecture allows for easy extension:

  • Modify modules/data_processing.py for custom preprocessing
  • Add new baseline algorithms to modules/baseline.py
  • Extend file format support in modules/file_converter.py

Troubleshooting

Common Issues

  1. "No module named 'PyQt6'"

    uv sync # Reinstall dependencies
  2. JWS file conversion fails

    • Ensure jws2txt is properly installed
    • Check file permissions and format validity
  3. Application won't start

    uv run --python 3.12 python main.py # Specify Python version

Performance Tips

  • Close unused baseline tabs to free memory
  • Process files in smaller batches for large datasets
  • Use the YLK format for faster subsequent loading

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-feature)
  3. Make your changes
  4. Run tests and ensure code quality
  5. Submit a pull request

License

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

Support

  • Issues: Report bugs and feature requests via GitHub Issues
  • Documentation: Check the CLAUDE.md file for detailed technical documentation
  • Community: Contribute to discussions and improvements

Acknowledgments

  • Built with PyQt6 for cross-platform compatibility
  • Uses matplotlib for high-quality scientific visualization
  • Supports Jasco .jws file format for FTIR spectroscopy data
  • This README was generated with the assistance of AI

如果您需要進一步的指導,例如如何在 GitHub 上建立儲存庫或上傳此檔案,請提供更多細節,我將提供詳細步驟說明。

About

A modern Python application for analyzing FTIR spectroscopy data.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages