Skip to main content

Crate openreadout_nmr

Crate openreadout_nmr 

Source
Expand description

Readers for NMR data.

  • Bruker TopSpin / XWIN-NMR experiment directories (bruker-nmr): a directory <expno>/ with JCAMP-DX-style parameter files (acqus, acqu2s, …), the time-domain samples (fid or ser) and processed spectra under pdata/<procno>/. Notes and vocabulary: docs/formats/bruker-nmr.md; provenance: docs/provenance/bruker-nmr.md.
  • Varian/Agilent VnmrJ data directories (varian-nmr): a <name>.fid/ directory with the binary fid (file header, block headers, int16/int32/float32 samples) and the procpar parameter text. Notes and vocabulary: docs/formats/varian-nmr.md; provenance: docs/provenance/varian-nmr.md.
  • JEOL Delta .jdf files (jeol-jdf): a binary header, a parameter section and 1D or 2D data sections. Notes and vocabulary: docs/formats/jeol-jdf.md; provenance: docs/provenance/jeol-jdf.md.
  • Magritek Spinsolve benchtop NMR experiment directories (magritek-spinsolve): acqu.par/proc.par parameter text and Prospa .1d/.2d data files (FID first). Notes and vocabulary: docs/formats/magritek-spinsolve.md; provenance: docs/provenance/magritek-spinsolve.md.
  • JCAMP-DX (jcamp-dx): the IUPAC text format for spectra (NMR, IR, UV-Vis, MS), with ASDF-compressed tables, NTUPLES and compound (LINK) files. Notes and vocabulary: docs/formats/jcamp-dx.md; provenance: docs/provenance/jcamp-dx.md.

All five expose sampled data as core traces (TraceInfo / Dataset::read_trace).

export_jcamp writes any evenly sampled trace (an NMR FID or spectrum, a JCAMP-DX spectrum, a chromatogram) as JCAMP-DX 5.01: ##XYDATA=(X++(Y..Y)) in DIFDUP (with Y-value checks) or AFFN, NTUPLES pages for complex or multi-sweep data. The file is re-read with the JCAMP-DX reader and verified before it is renamed into place.

§Example

Every reader implements openreadout_core::FormatReader: descriptor says what it reads, sniff recognises a file from its first bytes, and open returns a openreadout_core::Dataset with a header-only info() summary and lazy data access.

use openreadout_core::FormatReader;
use openreadout_nmr::BrukerReader;

let format = BrukerReader.descriptor();
assert_eq!(format.id, openreadout_nmr::BRUKER_FORMAT_ID);
println!("{} ({}): .{}", format.name, format.family, format.extensions.join(", ."));

Reading a file:

use std::path::Path;

use openreadout_core::FormatReader;
use openreadout_nmr::BrukerReader;

let mut dataset = BrukerReader.open(Path::new("experiment/1"))?;
let info = dataset.info()?; // headers only
let trace = &info.traces[0];
println!("{} sweep(s) at {} Hz, {} channel(s)", trace.sweep_count, trace.sample_rate_hz, trace.channels.len());
// The first 1000 samples of sweep 0, every channel, scaled to physical units.
let samples = dataset.read_trace(0, 0, 0, 1000)?;
for (channel, values) in trace.channels.iter().zip(&samples.channels) {
    println!("{} ({}): {:?}", channel.name, channel.unit.as_deref().unwrap_or("?"), values.first());
}

Applications that accept any instrument file usually register every reader in an openreadout_core::Registry and let it detect the format; that is what the openreadout command-line tool does.

§API stability

The supported API is what this page documents. The parser modules are public only so that tests and fuzz targets can reach them: they are hidden from this documentation and may change in any release.

Structs§

BrukerReader
The Bruker TopSpin reader.
JcampExportOptions
What to write.
JcampExportReport
Output of export --format jcamp.
JcampReader
The JCAMP-DX reader.
JeolReader
The JEOL Delta .jdf reader.
SpinsolveReader
The Magritek Spinsolve reader (experiment directories with acqu.par and Prospa .1d/.2d data files).
VarianReader
The Varian/Agilent VnmrJ reader (<name>.fid/ directories with fid and procpar).

Enums§

JcampEncoding
How ordinates are written.

Constants§

BRUKER_FORMAT_ID
Format id of Bruker TopSpin experiment directories.
JCAMP_FORMAT_ID
Format id of JCAMP-DX files.
JEOL_FORMAT_ID
Format id of JEOL Delta .jdf files.
SPINSOLVE_FORMAT_ID
Format id of Magritek Spinsolve experiment directories.
VARIAN_FORMAT_ID
Format id of Varian/Agilent VnmrJ data directories.

Functions§

default_jcamp_output
Default output path: <stem>.jdx (<stem>.traceT.jdx, <stem>.sweepS.jdx when selected).
export_jcamp
Export one trace of ds to output as JCAMP-DX.