nmrlineshapeanalyser


Namenmrlineshapeanalyser JSON
Version 0.1.15 PyPI version JSON
download
home_pageNone
Summaryss-NMR peak deconvolution and lineshape analysis
upload_time2025-01-26 19:55:18
maintainerNone
docs_urlNone
authorNone
requires_python<3.13,>=3.10
licenseNone
keywords lineshape analysis peak deconvolution ss-nmr
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ``nmrlineshapeanalyser``: ss-NMR peak shape deconvolution and line shape analysis made easy

``nmrlineshapeanalyser`` is an open-source Python package designed to make peak deconvolution or line shape analysis in 1D NMR spectrum easier.

This package is compatible with Bruker's NMR data and spectrum data saved in a CSV files (see User's guide).

# Why ``nmrlineshapeanalyser``?
  - it offers an easy and fast processing of either lineshape spectral analysis or peak deconvolution
  - it requires the path to processed Bruker's data ``data\single_peak\10\pdata\1`` 
  - for the optimisation, you only need to input the peak position(s) -- it does the rest
  - it gives you the freedom to decide if you want to either optimise or fix the peak peak position(s) while other peak parameters are refined
  - it provides you a detailed analysis of the optimised Pseudo-Voigt parameters that describe your peak(s) -- saved in a txt file
  - for peak deconvolution, it calculates the percentage of each peaks 
  - it saves fit and data in a CSV file in case you decide to visualise in your preferred software
  - it saves your fit as a publication-quality png file 

# Key Features

 - Load and process Bruker NMR data
 - Select and analyse specific spectral regions
 - Perform peak fitting using Pseudo-Voigt profiles
 - Calculate detailed peak metrics and statistics
 - Generate publication-quality visuals
 - Export results in various formats:
       - txt: calculated peak metrics and statistics
       - png: visualisation of the fitted spectral regions
       - csv: save plots to a file
  
# Install

```bash
pip install nmrlineshapeanalyser
```

# Dependencies

The following packages are required:

```bash
nmrglue 
numpy >= 1.26.0
scipy 
matplotlib >= 3.9.0
pandas >= 2.2.0
```

You can install these dependencies using pip:

```bash
pip install nmrglue numpy>=1.26.0 scipy matplotlib>=3.9.0 pandas>=2.2.0
```

# A Single Peak Fitting Example
```python
from nmrlineshapeanalyser.core import NMRProcessor

#create NMRProcessor object

processor = NMRProcessor()

#Load filepath: always include the '\\'
filepath = r"..\data\single_peak\10\pdata\1\\"

# Load the data

processor.load_data(filepath)

#Select the region of interest

x_data, y_data = processor.select_region(512, 650)

#Normalize the data and return normalised y_axis and the corresponding x_axis

x_data, y_normalized = processor.normalize_data(x_data, y_data)

#define initial parameters for the fitting
#this example is for a single peak
#format of the parameters is [x0, amplitude, width, eta, offset]
# x0 (position), amplitude, width, eta (mixing parameter), offset
#x0 has to be close to the peak position
initial_params = [
581, 0.12, 40.51, 0.89, -143.115, 
  ]
#Specify the number of peaks to be fitted

number_of_peaks = 1

# fixed_x0 controls whether peak positions should be fixed during fitting
# False means position can vary, True means position is fixed
fixed_x0 = [False] * number_of_peaks

# You can alternatively set it up as:

#fixed_x0 = [False] 

#Where the number of False reflects the number of peaks you want to optimise 
# i.e. [False, False] means you want to optimise two peak positions and so on

#FIt the data
popt, metrics, fitted = processor.fit_peaks(x_data, y_normalized, initial_params, fixed_x0)

#popt is the optimized parameters
#metrics is the metrics of the fitting
#fitted is the fitted curve data

#Plot and examine the results of the fitting
fig, axes, components = processor.plot_results(x_data, y_normalized, fitted, popt)

#Save the figure as png file and the results as a csv file
processor.save_results(filepath, x_data, y_normalized, fitted, metrics, popt, components)
```
This should generate the image below.

![Single Peak FIt](data/single_peak/10/pdata/1/pseudoVoigtPeakFit.png)

And a cell looking like:

```bash
Peak Fitting Results:
===================

Peak 1 (Position: 582.01 ± 0.01):
Amplitude: 0.993 ± 0.002
Width: 12.33 ± 0.03 in ppm
Width: 835.74 ± 2.36 in Hz
Eta: 1.00 ± 0.01
Offset: -0.004 ± 0.000
Gaussian Area: 0.00 ± 0.10
Lorentzian Area: 19.23 ± 0.16
Total Area: 19.23 ± 0.19
--------------------------------------------------
Peak 1 Percentage is 100.00% ± 1.39%
Overall Percentage is 100.00% ± 1.39%
```



# Contact

For questions and support, please open an issue in the GitHub repository.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "nmrlineshapeanalyser",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.10",
    "maintainer_email": null,
    "keywords": "lineshape analysis, peak deconvolution, ss-NMR",
    "author": null,
    "author_email": "Abdulkadir Olatunbosun Biffo <biffokadir13@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/65/4b/01436e5d6c30a44203de1719478dd5b9b4a70d67d6dd4b73c0a4af6d3a74/nmrlineshapeanalyser-0.1.15.tar.gz",
    "platform": null,
    "description": "# ``nmrlineshapeanalyser``: ss-NMR peak shape deconvolution and line shape analysis made easy\n\n``nmrlineshapeanalyser`` is an open-source Python package designed to make peak deconvolution or line shape analysis in 1D NMR spectrum easier.\n\nThis package is compatible with Bruker's NMR data and spectrum data saved in a CSV files (see User's guide).\n\n# Why ``nmrlineshapeanalyser``?\n  - it offers an easy and fast processing of either lineshape spectral analysis or peak deconvolution\n  - it requires the path to processed Bruker's data ``data\\single_peak\\10\\pdata\\1`` \n  - for the optimisation, you only need to input the peak position(s) -- it does the rest\n  - it gives you the freedom to decide if you want to either optimise or fix the peak peak position(s) while other peak parameters are refined\n  - it provides you a detailed analysis of the optimised Pseudo-Voigt parameters that describe your peak(s) -- saved in a txt file\n  - for peak deconvolution, it calculates the percentage of each peaks \n  - it saves fit and data in a CSV file in case you decide to visualise in your preferred software\n  - it saves your fit as a publication-quality png file \n\n# Key Features\n\n - Load and process Bruker NMR data\n - Select and analyse specific spectral regions\n - Perform peak fitting using Pseudo-Voigt profiles\n - Calculate detailed peak metrics and statistics\n - Generate publication-quality visuals\n - Export results in various formats:\n       - txt: calculated peak metrics and statistics\n       - png: visualisation of the fitted spectral regions\n       - csv: save plots to a file\n  \n# Install\n\n```bash\npip install nmrlineshapeanalyser\n```\n\n# Dependencies\n\nThe following packages are required:\n\n```bash\nnmrglue \nnumpy >= 1.26.0\nscipy \nmatplotlib >= 3.9.0\npandas >= 2.2.0\n```\n\nYou can install these dependencies using pip:\n\n```bash\npip install nmrglue numpy>=1.26.0 scipy matplotlib>=3.9.0 pandas>=2.2.0\n```\n\n# A Single Peak Fitting Example\n```python\nfrom nmrlineshapeanalyser.core import NMRProcessor\n\n#create NMRProcessor object\n\nprocessor = NMRProcessor()\n\n#Load filepath: always include the '\\\\'\nfilepath = r\"..\\data\\single_peak\\10\\pdata\\1\\\\\"\n\n# Load the data\n\nprocessor.load_data(filepath)\n\n#Select the region of interest\n\nx_data, y_data = processor.select_region(512, 650)\n\n#Normalize the data and return normalised y_axis and the corresponding x_axis\n\nx_data, y_normalized = processor.normalize_data(x_data, y_data)\n\n#define initial parameters for the fitting\n#this example is for a single peak\n#format of the parameters is [x0, amplitude, width, eta, offset]\n# x0 (position), amplitude, width, eta (mixing parameter), offset\n#x0 has to be close to the peak position\ninitial_params = [\n581, 0.12, 40.51, 0.89, -143.115, \n  ]\n#Specify the number of peaks to be fitted\n\nnumber_of_peaks = 1\n\n# fixed_x0 controls whether peak positions should be fixed during fitting\n# False means position can vary, True means position is fixed\nfixed_x0 = [False] * number_of_peaks\n\n# You can alternatively set it up as:\n\n#fixed_x0 = [False] \n\n#Where the number of False reflects the number of peaks you want to optimise \n# i.e. [False, False] means you want to optimise two peak positions and so on\n\n#FIt the data\npopt, metrics, fitted = processor.fit_peaks(x_data, y_normalized, initial_params, fixed_x0)\n\n#popt is the optimized parameters\n#metrics is the metrics of the fitting\n#fitted is the fitted curve data\n\n#Plot and examine the results of the fitting\nfig, axes, components = processor.plot_results(x_data, y_normalized, fitted, popt)\n\n#Save the figure as png file and the results as a csv file\nprocessor.save_results(filepath, x_data, y_normalized, fitted, metrics, popt, components)\n```\nThis should generate the image below.\n\n![Single Peak FIt](data/single_peak/10/pdata/1/pseudoVoigtPeakFit.png)\n\nAnd a cell looking like:\n\n```bash\nPeak Fitting Results:\n===================\n\nPeak 1 (Position: 582.01 \u00b1 0.01):\nAmplitude: 0.993 \u00b1 0.002\nWidth: 12.33 \u00b1 0.03 in ppm\nWidth: 835.74 \u00b1 2.36 in Hz\nEta: 1.00 \u00b1 0.01\nOffset: -0.004 \u00b1 0.000\nGaussian Area: 0.00 \u00b1 0.10\nLorentzian Area: 19.23 \u00b1 0.16\nTotal Area: 19.23 \u00b1 0.19\n--------------------------------------------------\nPeak 1 Percentage is 100.00% \u00b1 1.39%\nOverall Percentage is 100.00% \u00b1 1.39%\n```\n\n\n\n# Contact\n\nFor questions and support, please open an issue in the GitHub repository.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "ss-NMR peak deconvolution and lineshape analysis",
    "version": "0.1.15",
    "project_urls": {
        "Documentation": "https://biffoq.github.io/nmrlineshapeanalyser/",
        "Homepage": "https://github.com/BiffoQ/nmrlineshapeanalyser",
        "Repository": "https://github.com/BiffoQ/nmrlineshapeanalyser.git",
        "changelog": "https://github.com/BiffoQ/nmrlineshapeanalyser/blob/main/CHANGELOG.md"
    },
    "split_keywords": [
        "lineshape analysis",
        " peak deconvolution",
        " ss-nmr"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "600822ea5777d73a9feb5daa3834f7decb42f101ba379f40565eb815c8c2f046",
                "md5": "fcfd97ef4a268c18c43cde262cc1e053",
                "sha256": "c492403be1d500cebfbbe717e2283a7edff0ab8035bdd239a99d7ab986e71ee3"
            },
            "downloads": -1,
            "filename": "nmrlineshapeanalyser-0.1.15-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fcfd97ef4a268c18c43cde262cc1e053",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.10",
            "size": 11495,
            "upload_time": "2025-01-26T19:54:45",
            "upload_time_iso_8601": "2025-01-26T19:54:45.252267Z",
            "url": "https://files.pythonhosted.org/packages/60/08/22ea5777d73a9feb5daa3834f7decb42f101ba379f40565eb815c8c2f046/nmrlineshapeanalyser-0.1.15-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "654b01436e5d6c30a44203de1719478dd5b9b4a70d67d6dd4b73c0a4af6d3a74",
                "md5": "2f311bf5e1467b9f6512b2882e27fd8e",
                "sha256": "ff0e98ca95b9b5c07a6ff96e7801a1b8ec256600035e7f32b4a98dd3e9ac9887"
            },
            "downloads": -1,
            "filename": "nmrlineshapeanalyser-0.1.15.tar.gz",
            "has_sig": false,
            "md5_digest": "2f311bf5e1467b9f6512b2882e27fd8e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.10",
            "size": 56366877,
            "upload_time": "2025-01-26T19:55:18",
            "upload_time_iso_8601": "2025-01-26T19:55:18.447968Z",
            "url": "https://files.pythonhosted.org/packages/65/4b/01436e5d6c30a44203de1719478dd5b9b4a70d67d6dd4b73c0a4af6d3a74/nmrlineshapeanalyser-0.1.15.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-26 19:55:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "BiffoQ",
    "github_project": "nmrlineshapeanalyser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "nmrlineshapeanalyser"
}
        
Elapsed time: 0.45953s