Fitspy

Fitspy: A Python package for spectral decomposition - Published in JOSS (2024)

https://github.com/cea-metrocarac/fitspy

Science Score: 98.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 10 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

decomposition fitting gaussian lmfit lorentzian map python spectral-analysis spectrum
Last synced: 4 months ago · JSON representation ·

Repository

Generic tool dedicated to fit spectra in python

Basic Info
Statistics
  • Stars: 7
  • Watchers: 2
  • Forks: 0
  • Open Issues: 7
  • Releases: 10
Topics
decomposition fitting gaussian lmfit lorentzian map python spectral-analysis spectrum
Created over 2 years ago · Last pushed 5 months ago
Metadata Files
Readme License Citation

README.md

PyPI Github Doc DOI status

Fitspy is a generic tool dedicated to fit spectra in python with GUIs that aims to be as simple and intuitive to use as possible.

Illustration of the PySide GUI (left) and Tkinter GUI (right).

Processed spectra may be independent of each other or may result from 2D-maps acquisitions.


Example of fitspy 2D-map frame interacting with the main GUI.

Demo

The predefined peak models considered in Fitspy are Gaussian, Lorentzian, Asymetric Gaussian, Asymetric Lorentzian and Pseudovoigt. Some Bichromatic models related to bichromatic sources are also available as explained here

A Constant, Linear, Parabolic, Exponential or Power Law background model can also be added in the fitting.

In both cases, user-defined models can be added.

Fitspy main features:

  • Fitspy uses the lmfit library to fit the spectra
  • The fit processing can be multi-threaded
  • Bounds and constraints can be set on each peaks models parameter
  • From an automatic noise level estimation, according to the local noise, peak models can be automatically deactivated
  • Fitspy also includes automatic outlier detection to be excluded during the fitting process

All actions allowed with the GUI can be executed in script mode (see examples here). These actions (like baseline and peaks definition, parameters constraints, ...) can be saved in a Fitspy model and replayed as-is or applied to other new spectra datasets.

Installation

From PyPI (recommended)

bash pip install fitspy

From GitHub (latest version)

bash pip install git+https://github.com/CEA-MetroCarac/fitspy

(See the documentation for more details)

Upgrade

In the case of 'just' a Fitspy upgrade:

bash pip uninstall fitspy pip install fistspy # considering here the install from Pypi

For a full upgrade (Fitspy and its dependencies):

bash pip install fitspy --upgrade # considering here the install from Pypi

Tests and examples execution

pip install pytest git clone https://github.com/CEA-MetroCarac/fitspy.git cd fitspy pytest python examples/ex_gui_auto_decomposition.py python examples/ex_.......

(See the documentation for more details)

Quick start

Since its 2025.1 version, Fitspy can be launched using two interfaces: either the one corresponding to the original GUI built with Tkinter, or a more recent and advanced one, using PySide. As of 2025, both GUIs offer nearly identical features, but future efforts regarding fixes and updates will primarily focus on the PySide GUI.

PySide GUI:

Launch the application:

fitspy

From the right to the left, select the files to work with (considering the drag and drop capabilities). Then, use the Model panel to set the model parameters to be used during the fitting process. Peaks and an optional baseline associated with the model can be defined interactively by clicking on the desired position in the figure after activating Peak points (or Baseline points resp.) from the Click Mode radiobuttons located under the figure. Once the model build, The Fit can be launched. The corresponding model can be saved (in the Model panel) to be reload later (from the bottom-central panel) as-it with the same spectra (if the pathnames are still available) or just as a model for other spectra to be processed.

Tkinter GUI:

Launch the application:

fitspy-tk

From the top to the bottom of the right panel:

  • Select file(s)
  • (Optional) Define the X-range
  • Define the baseline to subtract (left or right click on the figure to add or delete (resp.) a baseline point)
  • (Optional) Normalize the spectrum/spectra
  • Click on the Fitting panel to activate it
  • Select Peak model and add peaks (left or right click on the figure to add or delete (resp.) a peak)
  • (Optional) Add a background (BKG model) to be fitted
  • (Optional) Use Parameters to set bounds and constraints
  • Fit the selected spectrum/spectra
  • (Optional) Save the parameters in .csv format
  • (Optional) Save the Model in a .json file (to be replayed later)

(See the documentation for more details)

Acknowledgements

This work, carried out on the CEA - Platform for Nanocharacterisation (PFNC), was supported by the “Recherche Technologique de Base” program of the French National Research Agency (ANR).

Warm thanks to the JOSS reviewers (@maurov and @FCMeng) and editor (@phibeck) for their contributions to enhancing Fitspy.

Citations

In case you use the results of this code in an article, please cite:

  • Quéméré P., (2024). Fitspy: A python package for spectral decomposition. Journal of Open Source Software. doi: 10.21105/joss.05868

  • Newville M., (2014). LMFIT: Non-Linear Least-Square Minimization and Curve-Fitting for Python. Zenodo. doi: 10.5281/zenodo.11813.

Owner

  • Name: CEA-MetroCarac
  • Login: CEA-MetroCarac
  • Kind: organization
  • Location: France

Metrology and Characterization activities at the French Alternative Energies and Atomic Energy Commission

JOSS Publication

Fitspy: A Python package for spectral decomposition
Published
April 15, 2024
Volume 9, Issue 96, Page 5868
Authors
Patrick Quéméré ORCID
Univ. Grenoble Alpes, CEA, Leti, F-38000 Grenoble, France
Editor
Sophie Beck ORCID
Tags
spectrum spectra decomposition fit

Citation (CITATION.cff)

cff-version: "1.2.0"
authors:
- family-names: Quéméré
  given-names: Patrick
  orcid: "https://orcid.org/0009-0008-6936-1249"
doi: 10.5281/zenodo.10812332
message: If you use this software, please cite our article in the
  Journal of Open Source Software.
preferred-citation:
  authors:
  - family-names: Quéméré
    given-names: Patrick
    orcid: "https://orcid.org/0009-0008-6936-1249"
  date-published: 2024-04-15
  doi: 10.21105/joss.05868
  issn: 2475-9066
  issue: 96
  journal: Journal of Open Source Software
  publisher:
    name: Open Journals
  start: 5868
  title: "Fitspy: A Python package for spectral decomposition"
  type: article
  url: "https://joss.theoj.org/papers/10.21105/joss.05868"
  volume: 9
title: "Fitspy: A Python package for spectral decomposition"

GitHub Events

Total
  • Create event: 18
  • Commit comment event: 2
  • Release event: 8
  • Issues event: 105
  • Watch event: 2
  • Delete event: 11
  • Issue comment event: 41
  • Push event: 205
  • Pull request event: 20
Last Year
  • Create event: 18
  • Commit comment event: 2
  • Release event: 8
  • Issues event: 105
  • Watch event: 2
  • Delete event: 11
  • Issue comment event: 41
  • Push event: 205
  • Pull request event: 20

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 912
  • Total Committers: 4
  • Avg Commits per committer: 228.0
  • Development Distribution Score (DDS): 0.299
Past Year
  • Commits: 521
  • Committers: 3
  • Avg Commits per committer: 173.667
  • Development Distribution Score (DDS): 0.434
Top Committers
Name Email Commits
patquem p****e@c****r 639
Crackvignoule k****n@g****m 258
Matthew Bryan 7****2 14
Crackvignoule k****n@û****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 65
  • Total pull requests: 29
  • Average time to close issues: 22 days
  • Average time to close pull requests: about 1 month
  • Total issue authors: 10
  • Total pull request authors: 3
  • Average comments per issue: 0.71
  • Average comments per pull request: 0.0
  • Merged pull requests: 27
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 59
  • Pull requests: 20
  • Average time to close issues: 10 days
  • Average time to close pull requests: less than a minute
  • Issue authors: 8
  • Pull request authors: 1
  • Average comments per issue: 0.61
  • Average comments per pull request: 0.0
  • Merged pull requests: 20
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • patquem (30)
  • Crackvignoule (20)
  • thibautmeyer (3)
  • AdrienT34490 (2)
  • h0anle (2)
  • maurov (2)
  • erickmartinez (1)
  • matbryan52 (1)
  • gfreychet (1)
  • kipavy (1)
Pull Request Authors
  • Crackvignoule (20)
  • patquem (7)
  • matbryan52 (4)
Top Labels
Issue Labels
pyside (30) UI (27) bug (25) enhancement (17) external-issue (1) tkinter (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 251 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 17
  • Total maintainers: 1
pypi.org: fitspy

Fitspy: a generic tool to fit spectra in python

  • Versions: 17
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 251 Last month
Rankings
Dependent packages count: 7.4%
Forks count: 30.3%
Average: 30.4%
Stargazers count: 39.2%
Dependent repos count: 44.8%
Maintainers (1)
Last synced: 4 months ago