Reference
Top-Level API
NMRflux.AutoPhaseCorrectChen — Method
function AutoPhaseCorrectChen(dim::Integer;verbose=false,γ=0.0)returns a processor that performs automatic phase correction of a spectrum along the dimension dim using the minimum entropy algorithm by Chen et al. in Journal of Magnetic Resonance 158 (2002) 164–168. The parameter γ can be used to add a penalty term to the optimisation target, which penalises negative peaks in the spectrum. This can be useful to avoid overcorrection in noisy spectra.
NMRflux.Derivative — Type
function Derivative(dim::Integer)returns a processor that computes the first derivative of a spectrum along the dimension dim.
NMRflux.FourierTransform — Method
function FourierTransform(SI::Vector,dims::Vector; fftshift=true)Fourier transform processor for data sets of size SI. dims is a Vector of the dimensions along which a Fourier transform will be computed. The corresponding coordinates are automatically replaced by frequencies, based on the Nyqvist theorem. The zero frequency appears in the centre of the spectrum.
The function produces a FFTW plan for the Fourier transform, which is stored ^in the returned FourierTransform object. This makes it more efficient to apply the Fourier transform to multiple data sets of the same size. If the size of the data set changes, a new FourierTransform object should be created.
NMRflux.Integral — Type
function Integral(dim::Integer)returns a processor that computes the integral of a spectrum along the dimension dim.
NMRflux.MedianBaselineCorrect — Method
function (mb::MedianBaselineCorrect)(s::SpectData)subtract baseline for the real part of s by the algorithm of M. S. Friedrichs, Journal of Biomolecular NMR, 5 (1995) 147 153.
NMRflux.NMRProcessor — Type
abstract type NMRProcessor <: Function endAbstract data type for NMR processing routines. New processing tools should be declared as subtypes of NMRProcessor.
NMRflux.NMRProcessor — Method
(m::NMRProcessor)(A::AbstractArray)here is some fallback behaviour. NMR processors are defined for SpectData objects. However, they can also be applied to any AbstractArray, by promoting it to a SpectData, and then extracting the data part.
NMRflux.NMRProcessor1D — Type
abstract type NMRProcessor1D <: NMRProcessorData type for processing tools that apply to a single dimension, i.e., that are inherently 1D. They need to be defined as functors that act on a AbstractVector{T}. They must contain a field .dim that indicates which dimension in a multidimensional array they should be applied to.
NMRflux.PeakAlign — Type
function PeakAlign(dim::Integer, readpos::Float64, wdw::Integer)returns a processor that aligns a spectrum along the dimension dim to a specific position readpos. It works by finding a maximum in the spectrum within a window wdw that is closest to readpos, and then shifting the spectrum such that this maximum is exactly at readpos. This can be useful to align spectra to a reference peak, e.g., TMS.
NMRflux.SpectData — Type
struct SpectData{T,N} <: AbstractArray{T,N}Basic structure for spectral data.
NMRflux.Chain — Method
Chain(fs::Vararg{NMRProcessor})returns a chain of processing tools, which will be applied in order (the first in the argument list is applied first)
NMRflux.conv — Method
function conv(X::AbstractArray{T1,N}, y::AbstractVector{T2},dim::Integer) where {N>1,T1,T2}computes the convolution of the array X with the vector y along the dimension dim. The ends of X are zero-padded such that the result is guaranteed to have the same size as X. NMRflux.conv() uses a direct algorithm for the convolution, not fft. It is therefore efficient when the length of y is much less than the corresponding dimension of X. If this is not the case and performance is critical, a different algorithm should be used.
NMRflux.coords — Method
function coords(S::SpectData)
function coords(S::SpectData,k::Integer)returns a tuple with the coordinates of S, analogous to axes(S). The second form returns the coordinate of the k-th dimension.
NMRflux.entropy — Method
function `entropy(s::SpectData{T,1})`computes the entropy of the first derivative in the real part of an NMR spectrum as defined by Chen et al. in Journal of Magnetic Resonance 158 (2002) 164–168. This quantity can be optimised with respect to zero- and first-order phase correction for automatic (unsupervised) phase correction.
NMRflux.extrema — Method
function extrema(X::AbstractArray{T,N}, dim::Integer)returns an array of booleans indicating all extremal values of X along the dimension dim.
NMRflux.find_spdta — Method
A = find_spdta(As) returns the first SpectData among the arguments.
NMRflux.load — Method
function load(path::String,vendor::Symbol)Load a data set located at path, and return a dictionary with the acquisition parameters as well as a SpectData object with the actual (time domain) data. vendor designates the origin data format. Currently implemented are
:Bruker: the path points to a directory with a Bruker NMR data set.:JEOL: the path points to a JEOL.jdffile
NMRflux.FileIO — Module
module FileIOcontains low-level code to import vendor-specific NMR data files.
NMRflux.FileIO.readBrukerFID — Method
Bruker.readBrukerFID(s::String; format=Float64)reads a Bruker fid or ser file and returns the data contained in it as a complex array. For files generated by TopSpin 4.0 and higher, the default format (Float64) will work. For TopSpin 2.0, use format=Int32.
NMRflux.FileIO.readBrukerParameterFile — Method
readBrukerParameterFile(s::String)reads a Bruker JCAMP-DX parameter file, and returns a dict with the values. Arrays such as D0 D1 D2 etc are returned as a Julia array. Note that the Bruker parameter D0 appears as param["D"][1] due to Julia using 1-based arrays.
NMRflux.FileIO.readJEOL — Method
function readJEOL(s::IOStream) -> (header,params,data)reads a JEOL .jdf file from the stream s. header contains a dictionary with the file header values, params is a dictionary of parameters. Each parameter contains a tuple (scaler::Int,units,value).
data is a raw data vector, which needs to be reshaped into the correct form depending on the parameters. This is handled by a separate function.
NMRflux.FileIO.reshapeJEOL — Method
function reshapeJEOL(header,params,data<:AbstractArray)
uses the header and parameter data to reshape the data. Returns an Array with the correctly shaped data.
GISSMO API
NMRflux.GISSMO — Module
module GISSMO
Interface routines with GISSMO database.
Hesam Dashti, Jonathan R. Wedell, William M. Westler, Marco Tonelli, David Aceti, Gaya K. Amarasinghe, John L. Markley, and Hamid R. Eghbalnia, Applications of Parametrized NMR Spin Systems of Small Molecules, Anal. Chem., 2018, 90 (18), pp 10646–10649, DOI: 10.1021/acs.analchem.8b02660 Hesam Dashti, William M. Westler, Marco Tonelli, Jonathan R. Wedell, John L. Markley, and Hamid R. Eghbalnia, Spin System Modeling of Nuclear Magnetic Resonance Spectra for Applications in Metabolomics and Small Molecule Screening, Analytical Chemistry, 2017, 89 (22), pp 12201–12208, doi: 10.1021/acs.analchem.7b02884
NMRflux.GISSMO.Hamiltonian — Function
function Hamiltonian(fn::String;freq=600.0,ctr=4.8)
function Hamiltonian(system::XMLElement;freq=600.0,ctr=4.8)
function Hamiltonian(SpM::AbstractMatrix{T};freq=600.0,ctr=4.8) where {T<:Number}computes the Hamiltonian of an entry in the GISSMO database and returns it in the natural basis as a sparse matrix. fn is the GISSMO reference name of the compound. Keyword parameters are used to indicate spectrometer base frequency (in MHz) and the spectral zero point (carrier position) in ppm. maxSpin represents the maximum size of the spin system that will be simulated. If the spin system size exceeds maxSpin, the function returns (-1,nothing).
NMRflux.GISSMO.SpinMatrix — Function
function SpinMatrix(id::String)returns the spin matrix, with chemical shifts (on the diagonal) and J-couplings (on the off-diagonal elements) for the GISSMO entry specified by the identifier id.
NMRflux.GISSMO.search — Function
function search(term::String)searches the online GISSMO database for term and returns a JSON object with the search result.
SpinSim API
NMRflux.SpinSim.Spectrum — Function
function Spectrum(ρ,H,Ψ;tol=1e-3,nev=400)compute the frequencies and intensities of the spectrum given by the the initial density operator ρ, the Hamiltonian H, and the observation operator Ψ. The results are returned as a tuple (freq,int) of two one-dimensional arrays. tol is a cutoff; transitions with absolute amplitudes less than this value are suppressed. The algorithm computes the eigenvalues and eigenvectors of the Hamiltonian, transforms the density operator and observation operator into the eigenbasis, and computes the transition frequencies and amplitudes. For large Hamiltonians, only a subset of eigenvalues and eigenvectors are computed, using the Arpack package. This may lead to missing transitions, but is much faster. The number of eigenvalues and eigenvectors to compute can be set with the nev keyword argument.
NMRflux.SpinSim.PeakSpect — Function
function PeakSpect(p,i,r;lw=0.0001)compute the the spectrum with Lorentzian peaks at locations given in array p and (complex) amplitudes in array i, over the range r, which can be either an array or a range. lwis the line width. AData1D` object is returned.
NMRflux.SpinSim.clorentzian — Function
clorentzian(x0::Float64,σ::Float64,x::Float64)returns the complex Lorentzian
$L(x) = \sqrt{\sigma}\dfrac{1+i\sqrt{\sigma}(x-x_0)}{1+\sigma(x-x_0)^2}$
NMRflux.SpinSim.expm — Function
function expm(A::SparseMatrixCSC)
compute the matrix exponential of A, using the dividing and squaring algorithm, as described by I. Kuprov, "Spin", Springer, Zürich, 2024, pp 173ff.
Examples API
NMRflux.Examples — Module
module ExamplesProvides a range of example data sets that can be used for tests, training, and documentation.
NMRflux.Examples.Data — Constant
global Datacontains a dictionary of example data sets. The entries are dictionaries that contain information such as the name, file paths, and tags.
To get a list of available examples, use keys(Examples.Data).
Index
NMRflux.ExamplesNMRflux.FileIONMRflux.GISSMONMRflux.Examples.DataNMRflux.AutoPhaseCorrectChenNMRflux.DerivativeNMRflux.FourierTransformNMRflux.IntegralNMRflux.MedianBaselineCorrectNMRflux.NMRProcessorNMRflux.NMRProcessorNMRflux.NMRProcessor1DNMRflux.PeakAlignNMRflux.SpectDataNMRflux.ChainNMRflux.FileIO.readBrukerFIDNMRflux.FileIO.readBrukerParameterFileNMRflux.FileIO.readJEOLNMRflux.FileIO.reshapeJEOLNMRflux.GISSMO.HamiltonianNMRflux.GISSMO.SpinMatrixNMRflux.GISSMO.searchNMRflux.SpinSim.PeakSpectNMRflux.SpinSim.SpectrumNMRflux.SpinSim.clorentzianNMRflux.SpinSim.expmNMRflux.convNMRflux.coordsNMRflux.entropyNMRflux.extremaNMRflux.find_spdtaNMRflux.load