Loading and saving

Loading

NMRTools.NMRIO.loadnmr — Function
loadnmr(filename, experimentfolder=nothing)

Main function for loading NMR data. experimentfolder contains the path to an experiment directory, for identification of metadata, if the filename is not directly within an experiment.

Returns an NMRData structure, or throws an NMRToolsError is there is a problem.

Examples

nmrPipe import:

loadnmr("exampledata/1D_1H/1/test.ft1");
loadnmr("exampledata/1D_19F/1/test.ft1");
loadnmr("exampledata/2D_HN/1/test.ft2");
loadnmr("exampledata/pseudo2D_XSTE/1/test.ft1");
loadnmr("exampledata/pseudo3D_HN_R2/1/ft/test%03d.ft2");

Bruker pdata import:

loadnmr("exampledata/1D_19F/1");
loadnmr("exampledata/1D_19F/1/");
loadnmr("exampledata/1D_19F/1/pdata/1");
loadnmr("exampledata/1D_19F/1/pdata/1/");

ucsf (Sparky) import:

loadnmr("exampledata/2D_HN/1/hmqc.ucsf");
loadnmr("exampledata/1D_19F/1/");
loadnmr("exampledata/1D_19F/1/pdata/1");
loadnmr("exampledata/1D_19F/1/pdata/1/");
source
loadnmr(expt::NMRExperiment; pdatadir=1, allcomponents=false) -> NMRData

Load the full NMR spectrum for an experiment previously discovered by scanexperiments.

source
NMRTools.NMRIO.loadfid — Function
loadfid(filename; removefilter=true, firstpoint=nothing) -> NMRData

Load raw Bruker time-domain data (fid for 1D, ser for nD) as an NMRData with Multicomplex elements and TimeDimension axes, ready for processing. filename is the fid or ser file or the experiment folder.

Phase-sensitive indirect dimensions (States, States-TPPI, echo/anti-echo) are combined into extra imaginary units, so a 2D experiment has Multicomplex{Float64,2,4} elements and even 1D data use Multicomplex{Float64,1,2}. Each time dimension records its imaginary unit in :mcindex (T1Dim → 1, T2Dim → 2, …). Non-Fourier dimensions such as a relaxation series become X2Dim/X3Dim with :mcindex == nothing. Intensities match TopSpin's: the raw data are scaled by 2^NC as TopSpin scales them, and ft applies no normalisation.

Keywords

  • removefilter: account for the digital filter's group delay. The filter's build-up points stay in the FID, on a time axis that starts GRPDLY dwell times before zero, and the delay is recorded in the direct dimension's :grpdly metadata. ft removes it with a linear phase ramp, as TopSpin and NMRPipe do. With false, the time axis starts at zero and no delay is recorded.
  • firstpoint: scaling factor for the t = 0 point of each time dimension, as a number for all dimensions or a dictionary keyed by dimension type, for example Dict(T2Dim => 1.0). The default is 0.5, except in the direct dimension of baseopt data (DIGMOD = 3), where the spectrometer already gives the t = 0 point its half weight, and 1.0 is used.

FIDs modified by TopSpin's cryoproc1d (DSPFVS outside 10–23) have had their first points removed. loadfid compares TD in acqu and acqus to find how many points after t = 0 are missing, starts the time axis there, and warns. The missing points leave a ripple around strong lines; linearpredict with direction=:backward can rebuild them.

Annotations (annotate) and sample metadata (addsampleinfo) are applied as for loadnmr.

Examples

fid = loadfid("myexperiment/1")
spec = fid |> apodize(Cos2Window()) |> zerofill |> ft |> autophase |> realest

See also autoprocess, savefid.

source
NMRTools.NMRIO.loadmetadata — Function
loadmetadata(experimentfolder) -> Dict{Symbol,Any}

Load all text-based metadata from a Bruker experiment folder without reading any binary data (ser, fid, 2rr, etc.). Returns a metadata dictionary compatible with NMRData metadata.

source
NMRTools.NMRIO.loadjdx — Function
loadjdx(filename::String) -> Dict{Symbol, Any}

Load a JCAMP-DX (.jdx) file and return a dictionary of parsed parameters.

Power levels are converted to Power objects, durations to seconds, and frequency lists to FQList objects.

source
NMRTools.NMRIO.exampledata — Function
exampledata(name; fid=false, path=false, kwargs...)

Load example NMR data provided with NMRTools.jl.

Call exampledata() to list the available data sets. The ubiquitin data sets (1D_1H, 2D_HN, 3D_HNCA, 3D_HNCA_pipe and 3D_HNCA_ucsf) can be compared with the assigned chemical shifts of ubiquitin in BMRB_ubiquitin (BMRB entry 17769), which loads as a Vector{ChemicalShift}.

Arguments

  • name: name of the example data set
  • fid: if true, load the raw time-domain data (fid or ser) with loadfid instead of the processed spectrum
  • path: if true, return the path of the data set instead of loading it
  • other keywords are passed to loadfid or loadnmr, for example firstpoint or allcomponents

Series (1D_19F_titration, 2D_HN_titration) return a vector.

Examples

spec = exampledata("2D_HN")                 # processed spectrum
fid = exampledata("2D_HN"; fid=true)        # raw data
fid = exampledata("2D_HN"; fid=true, firstpoint=Dict(T2Dim => 1.0))
dir = exampledata("2D_HN"; path=true)       # experiment directory
shifts = exampledata("BMRB_ubiquitin")      # assigned chemical shifts
source

Saving

NMRTools.NMRIO.savenmr — Function
savenmr(path, spec; procno=1, overwrite=false) -> String
savenmr(path; kwargs...)

Write a frequency-domain spectrum as Bruker processed data, and return the processed-data folder. path is an experiment folder (data go in path/pdata/<procno>) or a processed-data folder …/pdata/<n>. 1D, 2D and 3D spectra are supported, including pseudo-dimensions.

The forms without the data argument return a function for use with |>.

The real part is written to 1r, 2rr or 3rrr. For multicomplex 1D and 2D spectra the imaginary parts are written too (1i; 2ir, 2ri, 2ii), conjugated to TopSpin's sign convention. Data are stored as 32-bit integers, with the NC_proc exponent chosen to keep full precision. The processing parameter files, both current (proc, proc2, …) and status (procs, proc2s, …), record the axes, the window function and the phase correction applied (PHC0, PHC1).

If the experiment folder has no acquisition parameters, they are copied from the experiment the spectrum was loaded from or, failing that, generated from the dimension metadata, so that loadnmr can read the result.

Keywords

  • procno: processed-data number, used when path is an experiment folder.
  • overwrite: replace existing processed data.

Examples

spec = loadfid("myexperiment/1") |> autoprocess
savenmr("myexperiment/1", spec; procno=2)

See also savefid.

source
NMRTools.NMRIO.savefid — Function
savefid(path, spec; dtype=Float64, overwrite=false) -> String
savefid(path; kwargs...)

Write time-domain data as a raw Bruker experiment in the folder path, as fid (1D) or ser (nD) with acquisition parameter files, and return the path of the data file.

The forms without the data argument return a function for use with |>.

spec is time-domain data such as that from loadfid, possibly after time-domain processing such as linearpredict. The changes loadfid makes are undone, so the file has the layout TopSpin expects: t = 0 points are unscaled, the 2^NC intensity scaling is removed, phase-sensitive indirect dimensions are re-encoded with their original quadrature scheme (States, States-TPPI or echo/anti-echo), and the dimensions are put back in acquisition order. Digital-filter build-up points stay in the data, so they are written back unchanged. loadfid on the written experiment returns the original data.

Parameter files (acqus, acqu2s, the pulse programme, lists, …) are copied from the experiment the data were loaded from, with TD, DTYPA, BYTORDA and GRPDLY updated. Without a source experiment, minimal parameter files are generated from the dimension metadata.

Keywords

  • dtype: Float64 (DTYPA = 2, as written by Avance NEO spectrometers) or Int32 (DTYPA = 0, readable by older TopSpin versions; data are rounded and must fit in 32 bits).
  • overwrite: replace existing data in path.

Examples

fid = loadfid("myexperiment/1")
savefid("extended/1", linearpredict(fid, T2Dim))

See also savenmr.

source

Combining experiments

NMRTools.NMRIO.sumexpts — Function
sumexpts(inputexpts...; out, weights=[])

Sum a collection of Bruker NMR experiments, with optional weighting factors. Data will be truncated to fit the shortest data file.

Arguments

  • inputexpts...: Input experiment names (strings or integers)
  • out: Output experiment name (string or integer)
  • weights: Optional vector of weights for each input experiment

Details

  • Experiment names should be either strings with filenames or integers converted to strings
  • If weights are supplied, the length must match the number of input experiments
  • First input experiment is used as a template for the output experiment
  • For 1D experiments, 'fid' files are added; for nD experiments, 'ser' files are added
  • Processed data files in pdata/1 are removed, other pdata subdirectories are deleted
  • Updates the title file with information about the summed experiments
  • Updates the number of scans in the acqus file to be the sum of individual experiments
  • Prompts before overwriting any existing experiment
source