Skip to content

About

Interactive TOF-SIMS mass spectrum and depth profile analysis tool built with Streamlit and Plotly

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

TOF-SIMS Analyzer

日本語: TOF-SIMS(飛行時間型二次イオン質量分析)のマススペクトル・深さ方向プロファイル・PCA解析をブラウザ上で行えるPython/Streamlitアプリです。

English: A Python/Streamlit application for interactive analysis of TOF-SIMS (Time-of-Flight Secondary Ion Mass Spectrometry) data — mass spectra, depth profiles, and PCA-based multivariate analysis.


Contents


What is TOF-SIMS?

TOF-SIMS (Time-of-Flight Secondary Ion Mass Spectrometry) is a surface-sensitive analytical technique that provides:

  • Elemental and molecular composition of the top 1–2 nm of a surface
  • Depth profiles of chemical species by sequential ion sputtering
  • 2D chemical imaging of lateral elemental distribution

It is widely used in semiconductor, electronic materials, polymer, and life-science research.


Features

Implemented

Feature Module
Multi-file mass spectrum overlay app.py
TIC / mean-centering / autoscaling / Poisson normalization app.py
m/z alignment across spectra app.py
PCA score plot and loading plot app.py, legacy/TOF-SIMS_data_PCA.py
Hierarchical clustering (dendrogram) app.py
Difference spectrum between two samples app.py, legacy/TOF-SIMS_spectrum_viewer.py
Peak detection in difference spectrum (scipy) legacy/TOF-SIMS_spectrum_viewer.py
Interactive spectrum viewer (Plotly) legacy/Spectrum_Viewer_Plotly.py
CSV export of aligned spectra / PCA scores app.py
One-click demo mode (synthetic spectra, no data needed) app.py

Standalone desktop scripts that predate the Streamlit app live in legacy/ — see its README for details.

Not Yet Implemented / Planned

  • Depth profile visualization and quantification
  • 2D ion image display and RGB overlay
  • Automated peak assignment from mass library
  • Batch processing of large datasets
  • Accurate mass calibration
  • Docker containerization

Intended Users

  • Surface analysis researchers (XPS, AES, TOF-SIMS, SIMS)
  • Materials scientists and thin-film engineers
  • Semiconductor process engineers
  • Researchers interested in research DX / data-driven analysis

Installation

Requirements

  • Python >= 3.10
  • pip
git clone https://github.com/yharada520/tof-sims-analyzer.git
cd tof-sims-analyzer
pip install -r requirements.txt

Optional dependencies

# Desktop GUI scripts (PySimpleGUI-based)
pip install PySimpleGUI

# Static image export from Plotly
pip install kaleido

Usage

Main Streamlit App

streamlit run app.py

Open http://localhost:8501 in your browser.

Try it without your own data: check "デモデータを使用" (Use demo data) in the sidebar — six synthetic spectra are generated in memory (or open http://localhost:8501/?demo=1).

Upload one or more .asc, .txt, or .csv spectrum files from the sidebar. The app will:

  1. Parse and align spectra to a common m/z grid
  2. Apply the selected normalization
  3. Display overlaid spectra, PCA, and clustering

You can deep-link to a specific tab with ?tab=raw|diff|pca|hca.

Legacy Desktop Scripts

# Interactive spectrum viewer (Plotly)
python legacy/Spectrum_Viewer_Plotly.py

# PCA analysis tool
python legacy/TOF-SIMS_data_PCA.py

# Difference spectrum between two files
python legacy/TOF-SIMS_spectrum_viewer.py

Input Data Format

The app accepts two formats:

Format A — ASCII spectrum (.asc)

Space-delimited, 3 columns, no header:

    510,     0.7225411,      6
   1022,     0.6806757,      2
   ...
Column Description
1 m/z index (integer, bin number)
2 Normalized intensity (0–1)
3 Raw ion counts

Format B — CSV with header

mz,intensity,counts
1.008,0.650,8000
12.000,0.248,3050
...

See examples/ for sample files.


Output

Output Format Description
aligned_spectra.csv CSV m/z-aligned intensity matrix
pca_scores.csv CSV PCA score per sample
Interactive plots Plotly (browser) Spectra, PCA, dendrogram
PNG graph PNG Static export (legacy scripts)

Sample Data

All files in examples/ are synthetic / simulated data.
They do NOT originate from real measurements.

# Regenerate sample data
python examples/generate_sample_data.py

Screenshots

All screenshots below use the built-in demo mode (synthetic data — no real measurements).

Spectrum overlay — upload multiple ASC files and compare them on a common m/z axis:

Spectrum overlay

PCA score plot — sample groups separate automatically (demo: Si-rich group A vs. organically contaminated group B):

PCA score plot

Difference spectrum — which m/z increased or decreased between two samples, with the top peaks tabulated (demo: m/z 73 PDMS contamination marker):

Difference spectrum


Roadmap

  • Depth profile viewer
  • 2D ion image RGB overlay
  • Automated peak assignment
  • Mass calibration tool
  • Docker support
  • English UI option

Disclaimer

  • This software is provided for research and educational purposes only.
  • The author does not guarantee the accuracy of analysis results.
  • Use of this software in any commercial, medical, or safety-critical context is at the user's own risk.
  • This project is a personal development effort and is not affiliated with any organization or company.

License

MIT License — see LICENSE.


Author

Yoshihiro Harada — materials scientist / thin-film engineer
GitHub: @yharada520

About

Interactive TOF-SIMS mass spectrum and depth profile analysis tool built with Streamlit and Plotly

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages