Chapter 8 - Script-based processing with matNMR

NOTE: These routines still have not been tested enough yet and can contain minor bugs. Please report any bugs that you find!

It is also possible to use the processing facilities of matNMR in user-defined scripts. A number, but not all, processing actions have been created into separate functions that do not require the matNMR GUI to be open. They are, separated by mode:

Mode-independent 1D Processing2D Processing
  • matNMRReadBinaryFID
  • matNMRReadBrukerSpectra
  • matNMRTranspose
  • matNMRApodize1D
  • matNMRBaselineCorrection1D
  • matNMRConcatenate1D
  • matNMRConvertBrukerqseq1D
  • matNMRDCcorr1D
  • matNMRExtract1D
  • matNMRFlip1D
  • matNMRFT1D
  • matNMRLeftShift1D
  • matNMRLP1D
  • matNMRRegridSpectrum1D
  • matNMRRemoveBrukerDigitalFilter1D
  • matNMRSetPhase1D
  • matNMRSetSize1D
  • matNMRSolventSuppression1D
  • matNMRSwapEcho1D
  • matNMRApodize2D
  • matNMRConcatenate2D
  • matNMRConvertBrukerqseq2D
  • matNMRConvertEAE2D
  • matNMRConvertStates2D
  • matNMRDCcorr2D
  • matNMRExtract2D
  • matNMRFlip2D
  • matNMRFT2D
  • matNMRLeftShift2D
  • matNMRLP2D
  • matNMRRegridSpectrum2D
  • matNMRRemoveBrukerDigitalFilter2D
  • matNMRSetPhase2D
  • matNMRSetSize2D
  • matNMRShearingTransformationFD
  • matNMRShearingTransformationTD
  • matNMRSolventSuppression2D
  • matNMRSymmetrize2D
  • matNMRSwapEcho2D

The names should be self-explanatory in terms of what the functions do. The syntax for each function can be obtained by typing help "Name Function" in the Matlab command window. This should provide ample information. All the above-mentioned routines operate on matrices only and not on (matNMR) structures! In most cases, processing of hypercomplex matrices is not supported in the sense that both matrices cannot be entered at the same time, but must be called sequentially from the user-defined script.

It is possible to convert macros to scripts directly from the GUI. This currently only works for 1D actions but this will soon be extended to 2D actions as well.

Note that although most things can be done this way, baseline correction is not (yet) supported as this requires input of peak positions in matNMR. Furthermore, no spectral information is maintained by these functions.

Finally, an additional way of using matNMR in user-defined scripts is to record processing and/or plotting macro's, which can then be called by the function matNMRRunMacro. Again, the syntax to this function can be called by typing help matNMRRunMacro in the Matlab command window. This function does require matNMR windows to be open but doesn't rely on user input whilst processing, i.e. even though changes are made to the matNMR windows they may be hidden from view. This function can be used to either process a spectrum using a macro, OR to execute a plotting macro on the current window.

Here's an example of how one could use matNMRRunMacro in a script:

%example how to use matNMRRunMacro:
%This file loads all files from the current directory with names Epsilon$#$ where $#$ is a range from 0 to 90.
%The FIDs are then processed by macro "m" which was saved in file "Macro.mat". The output variable is called "Spec".

MacroFile = 'Macro';
MacroName = 'm';
Range = 0:90;

%load file with processing macro
eval(['load ' MacroFile]);

%start matNMR

for tel1 = 1:length(Range)
%load file
eval(['load Epsilon' num2str(Range(tel1))]);

%process the FID
eval(['MatrixOut = matNMRRunMacro(Epsilon' num2str(Range(tel1)) ', ' MacroName ');']);

%create spectral matrix in first iteration
if (tel1 == 1)
[x, y] = size(MatrixOut.Spectrum);
Spec = zeros(length(Range), x, y);

%fill in the matrix
Spec(tel1, :, :) = MatrixOut.Spectrum;

%clear FID from memory
eval(['clear Epsilon' num2str(Range(tel1))]);

Valid HTML 4.01!