Generated banner for Nmrglue
Generated logo for Nmrglue

Nmrglue

K-DenseCommunityCreated by K-Dense Inc.

  • Skill
  • Workflow
  • Science and research
  • MIT
  • Low risk
  • Has scripts

From the author

Processes calibrated one-dimensional complex NMR free-induction decays with nmrglue into phased spectra, peak candidates, and signed integration regions. Use for raw 1D NMR processing, ppm-axis verification, apodization, Fourier transformation, manual phasing, baseline correction, or reproducible spectral integration.
— the description by K-Dense Inc.

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a structured, reproducible approach to processing 1D NMR free-induction decay (FID) data. It leverages the nmrglue library to perform essential spectral processing steps, including apodization, Fourier transformation, manual phasing, and baseline correction. The workflow is designed for users who need to convert raw time-domain data into calibrated frequency-domain spectra with verifiable peak candidates and integration regions. It emphasizes explicit parameter management and validation, ensuring that processing choices like line broadening and phase angles are documented and reproducible.

What it does

  • Processes 1D complex FIDs from NumPy arrays or NMRPipe files.
  • Applies exponential apodization and zero-filling for spectral enhancement.
  • Performs Fourier transformation and manual phase correction.
  • Executes linear baseline correction using user-defined signal-free regions.
  • Generates peak candidates and calculates signed region integrals.
  • Produces a comprehensive report including settings, versions, and spectral data.

When to use it

  • When you have a uniformly sampled 1D FID and need a reproducible processing pipeline.
  • When you require precise control over phase, baseline, and integration parameters.
  • When you need to verify spectral calibration and peak positions against references.
  • When you need to generate standardized output for further quantitative analysis.

Advantages

  • Ensures reproducibility through explicit configuration and version tracking.
  • Provides a clear, step-by-step procedure for complex NMR data processing.
  • Includes validation checks for peak locations and integral ratios.
  • Maintains transparency by preserving negative areas for diagnostic review.

Usage examples

“Process my raw 1D FID file using the provided processing parameters.”
The agent executes the processing script with your FID and JSON configuration, outputting a phased spectrum, peak list, and integration report.
“How do I perform baseline correction on my NMR spectrum?”
The agent guides you to define signal-free regions in your configuration file and applies a linear baseline correction to the spectrum.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/k-dense-ai/nmrglue/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip nmrglue.zip -d .agents/skills

Documentation by K-Dense Inc.

nmrglue: calibrated 1D FID processing

When to use

Use for a uniformly sampled complex 1D FID whose acquisition parameters and complex frequency convention are available. The helper produces a descending ppm spectrum, positive peak candidates, signed region integrals, and a reproducible processing report. It does not identify compounds or assign resonances.

The executable accepts a NumPy .npz containing exactly one complex fid array or a canonical 1D complex time-domain NMRPipe file. NMRPipe reading is tested with a synthetic write/read round trip, known-spectrum recovery, and a small upstream NMRPipe-generated binary fixture. Experimental Bruker, Varian, and JEOL imports are not verified by this suite. For those formats, first inspect the relevant nmrglue reader and acquisition metadata. Opening a converted file does not validate the original acquisition decoding. Read references/acquisition-and-validation.md for conversion boundaries, axis calibration, and quantitative limits.

Workflow

  1. Preserve the raw FID. Establish spectral width in Hz, positive observation frequency in MHz, carrier in ppm, observed nucleus, and the sign convention from the acquisition or a known reference. Determine whether digital-filter/group-delay removal has already occurred. Do not infer these from array length or typical instrument defaults.

  2. Copy assets/processing.json and replace its synthetic example values with the measured parameters and explicit processing choices. Its sign -i means a resonance at offset f = (ppm - carrier_ppm) * observation_mhz has time dependence exp(-2*pi*i*f*t). Select +i only for the opposite convention; the helper conjugates it before processing. Validate with a known reference peak.

  3. Choose nonnegative exponential line broadening (Hz), an even zero-filled size at least as large as the acquired FID, first-point scaling, and phase angles. Zero filling improves interpolation, not acquired spectral resolution. First-point scaling 0.5 is suitable for the supplied causal synthetic example; acquisition and prior preprocessing may require another value.

  4. Run the helper, inspect the real and imaginary spectra, and revise manual phase if needed. phase0_deg + phase1_deg * index / zero_fill_points is applied after FT; index zero is the high-ppm edge. There is no implicit pivot or automatic phase estimate.

  5. Only fit a linear baseline when explicitly supplied ppm regions are signal-free. Set baseline to linear and add baseline_regions_ppm containing at least two regions. Inspect residuals and broad peaks; fitting through signals biases integrals.

  6. Compare peak positions with references, inspect peak candidates for artifacts, and integrate specified regions. Report overlapped peaks as overlapped. Preserve negative areas as diagnostic evidence of phase/baseline problems instead of taking absolute values.

Execute

Tested with Python 3.12, nmrglue 0.12, NumPy 2.5.3, and SciPy 1.18.1:

uv run --no-project --python 3.12 --with nmrglue==0.12 --with numpy==2.5.3 --with scipy==1.18.1 \
  python skills/nmrglue/scripts/process_1d.py fid.npz processing.json nmr-result

Paths assume the collection root. Adjust them when installed elsewhere. The output directory must be new, so repeated processing keeps previous results reviewable.

For an existing 1D NMRPipe FID, add --input-format nmrpipe and supply its path in place of fid.npz. The helper requires the canonical FDF2 direct dimension, complex quadrature, a time-domain flag, and agreement between header and JSON spectral width, observation frequency, and carrier. JSON settings remain explicit; a mismatch fails instead of silently recalibrating. FDF2TDSIZE must equal the stored complex-point count, and FDF2CENTER / FDF2ORIG must describe a canonical centered axis. Previously zero-filled, truncated, or recentered files need a separate acquisition-aware workflow. The nucleus/complex sign and previous digital-filter corrections still need acquisition evidence. A time-domain flag alone does not establish an unprocessed FID.

This executable synthetic example matches the supplied settings, generates resonances at 3 and 7 ppm in a 1:2 amplitude ratio, and does not represent an experimental sample:

import numpy as np

t = np.arange(8192) / 4000.0
fid = sum(a * np.exp(-np.pi * 2.0 * t)
          * np.exp(-2j * np.pi * (ppm - 5.0) * 400.0 * t)
          for ppm, a in [(3.0, 1.0), (7.0, 2.0)])
np.savez("fid.npz", fid=fid)

Run it with assets/processing.json as the settings argument. The repository suite executes this signal and the CLI, checks both peak locations within 0.001 ppm, checks integral ratio and analytic area, and checks phase and baseline recovery. The NMRPipe round-trip test writes this FID using ng.pipe.create_dic/ng.pipe.write, reads it through the CLI, and verifies the recovered peaks and integral ratio. Processed frequency-domain files and conflicting calibration metadata are rejected.

The 2,176-byte upstream fixture checks complex sample order and header calibration using a file generated by NMRPipe's simTimeND / SET tools. Those native tools were not run in this review; this is fixture compatibility, not a live NMRPipe processing comparison.

Deliverables and interpretation

  • spectrum.csv: descending ppm, real signal after baseline correction, phased imaginary signal, and the fitted real baseline. Plot NMR with the high-ppm end on the left.

  • report.json: input/settings SHA-256, package versions, all settings, acquired duration, zero-filled digital spacing, positive peak candidates, and signed region areas.

Integrals use endpoint interpolation and trapezoidal integration along increasing ppm; area units are arbitrary signal times ppm, independent of display direction. Regions outside the sampled ppm axis fail rather than being silently clipped. Peak prominence is a fraction of the largest positive real intensity; it is not a noise-derived detection limit. Strong solvent signals can obscure weak candidates at the default threshold.

For quantitative NMR, additionally establish relaxation delay, pulse angle, saturation, receiver behavior, internal/external reference amount, and integration uncertainty. The helper does not calculate concentrations or correct unequal relaxation. Preserve these limits with the result rather than converting arbitrary areas to molecule counts.

Upstream contracts

The hosted latest documentation identified itself as 0.9-dev when checked; the actual 0.12 package APIs and numerical behavior were tested. Its proc_base.fft uses the negative-exponent NumPy FFT followed by fftshift; NMRPipe's FT convention corresponds to fft_positive, so do not substitute it without revisiting the FID sign and phase. See the v0.12 processing source. Multidimensional processing, nonuniform sampling, automated assignment, and experimental vendor imports remain outside this helper's validated scope.

Files

references/acquisition-and-validation.md

Acquisition evidence and integration checks

Before converting a vendor file

A readable array is not proof that it is a correctly decoded FID. Confirm complex quadrature, direct-dimension length, acquisition order, digital filtering/group delay, spectral width, observation frequency, transmitter offset, and observed nucleus from vendor parameters. Keep the vendor files alongside the conversion record. Hash the source acquisition files and record the reader/version and any corrections; the helper hashes the supplied NPZ or NMRPipe file and processing JSON, not an earlier vendor acquisition.

A processed frequency-domain file must not be fed through this FID pipeline. Echo, nonuniform sampling, real-only acquisition, indirect dimensions, and data requiring receiver-specific phase cycling need a different processing derivation. The bundled helper rejects real arrays and multidimensional arrays but cannot distinguish an incorrectly labeled complex spectrum from a complex FID.

For Bruker, digital-filter removal is an acquisition-specific operation, not a universal first step. Determine whether it has already been applied; applying it twice distorts phase. Upstream bruker.read and bruker.remove_digital_filter are possible building blocks, but no vendor-reader workflow is claimed as tested here. Consult the Bruker reference before adapting it and verify against a trusted processed reference. remove_digital_filter(dic, data, truncate=True, post_proc=False) returns data, not a (dictionary, data) pair. post_proc=True returns a frequency-domain correction and must not be passed into this FID helper. Its default truncation may discard useful data; record the resulting point count and correction settings.

Verify frequency sign before fitting phase

The helper pairs proc_base.fft with the descending unit_conversion.ppm_scale() axis. The canonical FID therefore uses the negative complex exponential for positive ppm offsets. If a known reference appears mirrored about the carrier, revisit quadrature and sign convention. Reversing a plotted axis does not correct the data-to-ppm mapping. A reference offset correction should update the carrier and be recorded, rather than moving a plotted label without moving integration limits.

For the even zero-filled size N, the first sample is carrier_ppm + spectral_width_hz / (2 * observation_mhz) and each step is -spectral_width_hz / (N * observation_mhz) ppm. The final sample is one digital step above the lower bandwidth edge; the two Nyquist edges are not both sampled. unit_conversion receives carrier in Hz, whereas the NMRPipe FDF2CAR header is ppm. proc_base.em receives line_broadening_hz / spectral_width_hz, not Hz directly. proc_base.ps multiplies the complex spectrum by the positive phase exponential in degrees; first-order phase is measured across indices, with no implicit pivot.

Processing comparisons that change conclusions

  • Reprocess with less line broadening to see whether nearby peaks remain separable.

  • Compare no-baseline and justified signal-free baseline regions; broad resonances can be mistaken for a baseline. First-order polynomial correction is intentionally narrow.

  • Inspect the imaginary channel during manual phase adjustment. A visually positive spectrum alone does not establish absorption-mode phase across the full bandwidth.

  • Vary integration bounds and baseline anchors to assess area stability. Overlap, truncation ringing, solvent suppression, and acquisition dead time may dominate error.

  • Treat automatic local maxima as candidate peaks. Negative peaks, multiplet grouping, line-shape fitting, isotope patterns, and assignments are not performed.

The synthetic regression signal has two exponentially decaying components with identical linewidth and known amplitude ratio. Its exact area benchmark is a mathematical processing check, not external validation of a spectrometer, sample preparation, or quantitative assay.

Supported NMRPipe boundary

The NMRPipe reader requires one direct FDF2 dimension, complex samples, an untransformed FTFLAG, and a header size matching the decoded complex array. Spectral width (Hz), observation frequency (MHz), and carrier (ppm) must match the explicit processing JSON within float32 header rounding tolerance. Selected header fields are preserved in the report. The sign convention is still explicit: the file format alone does not establish the acquisition's physical frequency sign or whether vendor conversion conjugated it.

FDF2TDSIZE must also match the stored point count. This prevents known prior zero filling or truncation from being reported as acquired time. The centered axis checks use CENTER = floor(N / 2) + 1 and ORIG = CAR * OBS - SW * (N - CENTER) / N, following nmrglue 0.12's NMRPipe source. The ORIG tolerance allows float32 header rounding, including cancellation near zero. An inconsistent ORIG cannot be ignored: pipe.make_uc uses it to derive the carrier. Headers can still be wrong or incomplete; these checks do not authenticate acquisition history. For NPZ input, acquired duration assumes every supplied point was acquired.

Synthetic canonical files generated with nmrglue were round-trip validated. An upstream 2,176-byte fixture generated with simTimeND / nmrPipe -fn SET separately verifies stored real/imaginary order and calibration. Its source and checksum are recorded in the repository test fixtures. This exercises the actual binary reader and recovered spectral coordinates, but does not establish that every experimental converter writes equivalent headers or samples. Digital-filter removal and earlier apodization are not inferred or undone. Check the upstream acquisition and conversion record before applying the processing settings. Neither nmrPipe nor nmrDraw was available for an independent live comparison. Linear baseline least squares is tested; resonance line-shape fitting and automatic phase fitting are outside this helper's scope.

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs Python

The author says: Requires Python 3.12+, nmrglue, NumPy 2+, and SciPy. Installation needs network access; processing is local and needs no credentials.

Security

What our scanner noticed· Low risk

  • Scripts that your agent may run

This skill includes scripts that your agent may run. Read them before you use it.

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
K-Dense Inc.
Publisher
K-Dense (Community)
Source
K-Dense-AI/scientific-agent-skills · skills/nmrglue · commit a25cf9e
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE.md)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by K-Dense Inc. or K-Dense.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download nmrglue.zip