Metadata
NMRData
objects contain comprehensive metadata on processing and acquisition parameters. These are populated automatically when loading a spectrum. Entries are divided into spectrum metadata – associated with the experiment in general – and axis metadata, that are associated with a particular dimension of the data.
Examples of spectrum metadata include: number of scans, receiver gain, pulse program, experiment title, number of dimensions, noise level (calculated when the spectrum is loaded), acquisition parameters (pulse lengths etc, from the acqus
file), contents of auxilliary files (e.g. vclists and vdlists).
Examples of axis metadata include: the number of points, the original time domain size (before zero filling, linear prediction or extraction of a subregion), carrier frequency, spectrum width, window function used for processing.
Accessing spectrum metadata
Metadata are stored in a dictionary labelled by symbols such as :ns
or :pulseprogram
. This dictionary can be accessed using the metadata
function.
using NMRTools
# load an example 2D 1H,15N HMQC spectrum
spec = exampledata("2D_HN")
metadata(spec)
Dict{Symbol, Any} with 14 entries:
:filename => "/Users/runner/.julia/artifacts/278430abd2b28a265273e707…
:label => "13C,15N ubiquitin"
:ns => 2
:format => :pdata
:noise => 502.842
:experimentfolder => "/Users/runner/.julia/artifacts/278430abd2b28a265273e707…
:pulseprogram => "sfhmqcf3gpph.cw"
:ndim => 2
:title => "13C,15N ubiquitin\n500 uM in 10% D2O, 20 mM Pi pH 6.5, …
:acqusfilename => "/Users/runner/.julia/artifacts/278430abd2b28a265273e707…
:topspin => v"6.0.0"
:acqus => Dict{Symbol, Any}(:fcuchan=>Dict(0=>0, 4=>0, 5=>0, 6=>0,…
:acqu2s => Dict{Symbol, Any}(:origin=>nothing, :sw=>21.9971, :sw_h=…
:rg => 203
For convenience, entries can be accessed by passing a second argument to the metadata
function:
metadata(spec, :title)
"13C,15N ubiquitin\n500 uM in 10% D2O, 20 mM Pi pH 6.5, 277 K, SOFAST-HMQC"
or directly from the spectrum using a dictionary-style lookup:
spec[:ns]
2
Accessing axis metadata
Axis metadata can be accessed by providing an additional argument to the metadata
function, specifying the axis numerically:
metadata(spec, 1)
Metadata{FrequencyDimension} of Dict{Symbol, Any} with 19 entries:
:aq => 0.0946176
:label => "1H"
:region => 600:1815
:sf => 600.203
:swppm => 18.0315
:bf => 600.2
:offsethz => 2819.0
:window => Cos²Window(0.0946176)
:offsetppm => 4.69677
:pseudodim => false
:npoints => 1216
:referenceoffset => 0.0
:swhz => 10822.5
:td => 1024
:units => nothing
:coherence => nothing
:tdzf => 4096
:mcindex => nothing
:procs => Dict{Symbol, Any}(:alpha=>0, :ymin_p=>-44320020, :pscal=>…
Axes can also be accessed by their type, e.g. F1Dim
or F2Dim
:
metadata(spec, F2Dim)
Metadata{FrequencyDimension} of Dict{Symbol, Any} with 19 entries:
:aq => 0.0478336
:label => "15N"
:region => missing
:sf => 60.8249
:swppm => 21.9997
:bf => 60.8177
:offsethz => 7176.49
:window => CosWindow(0.0478336)
:offsetppm => 118.0
:pseudodim => false
:npoints => 512
:referenceoffset => 0.0
:swhz => 1337.97
:td => 64
:units => nothing
:coherence => nothing
:tdzf => 512
:mcindex => nothing
:procs => Dict{Symbol, Any}(:alpha=>0, :ymin_p=>-44320020, :pscal=>…
Again, for convenience entries can be accessed by passing an additional argument to the metadata
function:
metadata(spec, F1Dim, :label)
"1H"
or directly from the spectrum object using a dictionary-style lookup alongside an axis reference:
spec[2, :offsetppm]
117.99995292412437
Accessing acquisition parameters
Spectrometer acquisition parameters are automatically parsed from the acqus
file when data are loaded. This is stored as a dictionary in the :acqus
entry of the spectrum metadata, but can more conveniently be accessed through the function acqus(spec, parametername)
. Parameter names can be provided either as strings (case insensitive, e.g. "TE"
for the temperature) or as lowercase symbols (e.g. :te
).
acqus(spec, :te)
276.9988
Arrayed parameters such as pulse lengths are returned as dictionaries:
acqus(spec, :p)
Dict{Int64, Float64} with 64 entries:
5 => 16.5
56 => 500.0
16 => 1000.0
20 => 2000.0
35 => 160.0
55 => 1300.0
60 => 400.0
30 => 160.0
19 => 600.0
0 => 9.2
32 => 20000.0
6 => 25.0
49 => 100000.0
45 => 78.0
44 => 200.0
9 => 25.0
31 => 810.0
61 => 120.0
29 => 4000.0
⋮ => ⋮
For convenience, particular entries can be accessed directly by supplying an additional index parameter:
acqus(spec, :cnst, 4)
92.0
Arrayed parameters such as pulse lengths, delays, etc. are returned as dictionaries rather than lists to avoid indexing confusion between Bruker arrays, which are zero-based, and Julia arrays, which are unit-based.
Auxiliary files
If present, files such as vclist
and vdlist
are imported and can be accessed through the acqus
function:
relaxation_experiment = exampledata("pseudo3D_HN_R2")
acqus(relaxation_experiment, :vclist)
11-element Vector{Int64}:
0
1
2
3
4
6
8
10
12
14
16
Window functions
The window functions used for data processing are identified when experiments are loaded. These are represented by subtypes of WindowFunction
, which contain appropriate parameters specifying the particular function applied together with the acquisition time $t_\mathrm{max}$ (calculated at the point of application, i.e. after linear prediction but before zero filling).
Window functions are stored as axis metadata and can be accessed through the :window
parameter:
spec[2, :window] # get the window function for the second dimension
CosWindow(0.04783359999999993)
Available window functions are:
NullWindow(tmax)
: no window function appliedUnknownWindow(tmax)
: unrecognised window functionExponentialWindow(lb, tmax)
: line broadening specified in HzSineWindow(offset, endpoint, power, tmax)
: a supertype encompassing some special casesCosWindow(tmax)
: apodization by a pure half-cosine windowCos²Window(tmax)
: apodization by a pure half-cosine-squared windowGeneralSineWindow(offset, endpoint, power, tmax)
: other general cases
GaussWindow(expHz, gaussHz, center, tmax)
: a supertype encompassing some special casesLorentzToGaussWindow(expHz, gaussHz, tmax)
GeneralGaussWindow(expHz, gaussHz, center, tmax)
: other general cases