A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    P    Q    R    S    T    U    V    W    X    Y    Z
 
iNMR icon
 

  commands the console responds to:

This page contains the Lua functions defined by iNMR. The embedded Lua interpreter also recognizes many standard functions and the default Lua libraries. You can easily add your own functions: write them into a file called "Lua.init" and specify (into the Preferences dialog) the name of the folder surrounding it. Your functions will be automatically loaded whenever you open the console.

The iNMR console is not a unix shell. Before using io.read() be sure to reopen the corresponding input stream. Better yet: define "io.read = nil" into your "Lua.init" file. Doing so, you avoid calling "read()" and hanging iNMR. Use "ask()" instead.

The list is growing! If you can't find the command you need, ask for its inclusion into the next release of iNMR.

  
 

abc()

Equivalent to the palette command to perform fully automated baseline correction.

acut( [min], [merge], [max_ratio], [DoCut] )

Performs automatic 1D integration. Min = minimum number of points into each integral region; merge = amount, in ppm, that is added on both sides of each region; max_ratio = the allowed ratio between the most intense and the less intense integral; DoCut = if you want to perform automatic scale fragmentation (instead of integration), pass this optional Boolean value (pass true).

adj()

Equivalent to a double click: changes the amplification so that the highest peak fits exactly into the window.

heightperpix = amp( [factor] )

Amplifies the spectrum by the given factor. If factor < 1, a deamplification occurs. Use without arguments to redraw the spectrum (most of the console commands do not update the display!). Returns the height of a peak that would fill a single point on the spectrum.

aph( baseline_is_flat )

Automatic phase correction. Accepts a boolean argument. If "true", applies the more accurate metabolomic method.

string = ask( prompt )

Asks the user to enter a string. Returns the string. Ex:
x = ask "enter a number"
Lua performs automatic conversions from strings to numbers.

  
 

bidi( code_letter )

Family of 2D-related commands that have menu equivalents:

bidi "A"=Arrayed Plot
bidi "B"=ChessBoard Plot
bidi "C"=Contour Plot
bidi "F"=Fast Plot
bidi "S"=Stacked Plot
bidi "Y"=Symmetrize Square Matrix
bidi "T"=Tilt
bidi "J"=Symmetrize J-resolved 2D
bidi "N"=Reduce t1 noise

bin( from, to, bin_size )

Performs binning in the specified region. All arguments are in ppm units.

bline( degree, filter )

Performs a baseline correction by a Whittaker Smoother along X.

  
 

clear()

Clears the console history log.

table = clip( index )

Returns the given note as a table with fields named: kind, x, y, data. Arrows and frames also contain the additional fields xx and yy.

string = cliptext( [string] )

If a string is passed as parameter, it is moved onto the clipboard. Otherwise, if the clipboard contains any text, this function returns a copy of it.

closex()

Close Extract.

cmd( command )

DEPRECATED. Shortcut to all the menu commands directed to a document. The 4-letters codes can be discerned from the file “main.nib”.

color( { r; g, b; } [, { r; g, b; } [, ...] ] )

Sets the main color or sets one or more gradient of colors in all open window. In the latter case, check the console option “For All Windows”. Ex.:

red = {r=1; g=0; b=0;}
blue = {r=0; g=0; b=1;}
color( red )
color( red, blue ) -- creates a gradient across the windows
color{ r=0; g=0; b=0; } amp() -- makes the spectrum black
There is no limit to the number of colors you can pass to this command.

table = copy()

Returns the real data points into the selected region. The returned table contains the number of points into the 3 fields x, y and z and the single values into the elements [1] .. [x*y*z]. Ex.:

perm() -- makes permanent the 1D baseline correction
region( 4, 3 )
T = copy()
print( T.x ) -- prints the number of selected points
print( T[1] ) -- prints the height of the spectrum at 4 ppm

copylog()

Copies into the clipboard the console history log.

  
 

window = dec([window, row/command])

The deconvolution windows can be created, closed and completely controlled with this single command. Find the description here.

delint()

Deletes all integrals.

  
 

exact()

Expands and shrinks the integral regions until their values are as near as possibe to the nearest integer.

export( “/absolute/path” )

Equivalent to the namesake menu command. It's an error if the file already exists. You can remove it with:
os.execute("rm -rf /absolute/path") You can open it with:
os.execute("open \"/absolute/path/plist.inmr\"")
or:
open "/absolute/path/plist.inmr"

extract()

Equivalent to the namesake menu command.

  
 

fill( new_size[, use_LP] )

Sets a couple of FT parameters but does no processing.

name, size = font( [fontname[, fontsize]] )

Sets and returns the font used for notes (not the one used for scales and integrals).

Boolean forall()

Returns the value of the option “For All Documents”.

ft( swap, mirror, real, subtractDC )

Sets 4 Boolean options but performs no processing.

full()

Equivalent to the menu command with the same name.

  
 

table = getf([index] or [“x”/“y”/“z”])

Returns information about the specified dimension (default = X dimension). Ex.
t = getf(1) print( t.atom, t.mass, t.size, t.start, t.width, t.MHz )
fy = getf(“y”)

  
 

[f1[, f2[, ...]] = getmarks([“h”])

Returns the ordered values of the vertical marks (horizontal if the optional parameter “h” is passed).

  
 

number = hat( x[, y[, z]])

Returns the intensity of the spectrum at the given ppm frequency.

  
 

number = intreg( )

area, left, right[, bottom, top[, Zmax, Zmin]] = intreg( index )

intreg( index, newvalue)

If invoked without arguments, returns the number of integrals. In invoked with a valid index (starting from 1) returns the value of the integral, followed by the limits of the integral region. If invoked with a non valid index, returns nil. If invoked with two values, changes the normalization factor.

  
 
  
 
  
 

little( true / false )

Tells iNMR about the endian-ness of the data. The effect is visible the next time you reload the spectrum.

  
 

magn()

Equivalent to the menu command “Magnitude”.

mark( [[“h”],][f1[, f2[, ... ]]] )

The first parameter can be “h” (to work on the horizontal marks). Otherwise omit this parameter to work on the vertical marks. The selected pool (vertical or horizontal) is deleted. New marks are created with the optional parameters that follows.

  
 

next_window()

The foremost window is sent behind all others. After this command, all the operations are performed on the next window only.

noneg()

All negative points are set to zero.

number = numdim()

Returns the number of dimensions of the active spectrum.

  
 

open( “/absolute/path” )

It's equivalent to dragging a folder or a file onto the iNMR icon.

  
 

[width, height] = paper( [width, height] )

Changes the window size. Arguments in units of points. This handy command is ideal to determine the size of bitmaps before creating them. If invoked without arguments, returns the dimensions of the topmost window.

paste( points )

Pastes the points into the selected region. The argument of this function is a table obtained with the command “copy” or any table in the same simple format. It is YOUR responsibility to ensure that the table and the selection have matching sizes. If the table is smaller than the selection, it is filled with zeroes. You can use “copy” and “paste” to sum a peak to another one. Passing the empty table is the way to set the selected data points to zero: “paste {}”.

string = pathtofile()

Returns the POSIX path to the original file (e.g.: “fid”) from which the current spectrum has been loaded. Ex.:
print( pathtofile() )

number = peak( )

x[, y[, z ]] = peak( index )

If invoked without arguments, returns the number of entries in the peak-picking list. In invoked with a valid index (starting from 1) returns the frequency(es) of the peak, in ppm units. If invoked with a non valid index, returns nil.

perm( from, to )

Makes permanent the baseline correction in the specified range (accepts ppm units). This command lets you correct different spectral regions with different polynomials. Has no equivalent in the GUI. If you don't pass argument, the assumed range is the whole spectral width.

ph0, ph1 = phase( ph0[, ph1] )

Sets or returns the phase correction parameters.

picture( “/Users/home/path/to/file”, “type” )

Creates a picture file. Valid types are: “PDF ”, “PNGf”, “JPEG”, “TIFF”, “BMP ”, “PICT”.

poly( degree, filter[, partial] )

Performs a polynomial baseline correction along X.

predict( first, last, coefficients, base_points )

Performs Linear Prediction: “first” and “last” are in units of points.

press( code_letter )

Simulates the pressing of a keyboard key. Ex.:
region( 8, 6 ) press "z" -- expands the region from 8 to 6 ppm
press "\28" -- simulates the "left arrow" key

print( list, of, arguments, ... )

This is a handy Lua command !

  
 
  
 

refer( center, max_distance )

Finds the maximum in the range center ± max_distance. Changes the scale reference so that the maximum falls exactly at “center”. Ex.:
refer( 7.26, 0.05 ) -- finds CDCl3 and adopts it as the reference
refer() -- equivalent to refer( 0 , 0.1 )
Works with 1D spectra only. max_distance is optional but, if given, must be positive.

region( left, right[, bottom, top[, Zmax, Zmin]] )

Selects a region for integration, zooming, cut...

reload()

Equivalent to the menu command with the same name. If an optional number is passed, and if it is zero, the reloaded FID is treated as a frequency domain spectrum. This change is permanent. The only way to undo it is the command "Revert to Saved".

run "script name without .lua extension"

Runs a user defined script (a Lua program written by you). You specify the base path in the Preferences dialog and the rest of the path as the argument to “run”. Similar to the Lua function “dofile” (also working, but only with absolute paths).

  
 

shift( amount[, index] )

Changes the scale reference by the specified amount (in ppm units). If you don't specify the dimension (1 for f1, 2 for f2...), the X axis is assumed.

shuffle( numeric_code )

Sets the shuffling protocol. 0 = none. 1 = phase sensitive. 2 = echo-antiecho.

small( first_pt, last_pt, f_index )

Extracts a submatrix from the spectrum. The new size will be: last_pt - first_pt. Repeat for each dimension. FIDs always start from point zero, even if the scale says it differently.

[n, x[], z[]] = stripes([n, x[], z[], δx])

For 3D spectra only, creates n stripes (if all the 4 parameters are given) or returns the corresponding parameters. x[] and z[] are the ppm coordinates of each stripe, δx is the width of each stripe. For the command to work, it is imperative to set x.M and z.M to the values of the isotopes corresponding to the x and z axes, e.g.: x.M = 1; z.M = 15.

straight()

Equivalent to the menu command “Straight Line”.

suppress( selectivity[, ppm1[, ppm2...]] )

Suppresses the given frequency(es). If no frequency is specified, the transmitter offset is assumed.

  
 

string = title( new_title )

Sets or returns the meta-information.

text( “your note”, ppmX, Y[, unicode] )

Creates a new ASCII note at position [ppmX, Y]. Set the last optional parameter to TRUE if you want a Unicode note.

number = todo( index )

Sets or returns the index of the next dimension to be transformed. Ex.:
old_index = todo()
todo( new_index )
-- do something...
todo( old_index ) -- always remember to restore the correct index !

  
 
  
 

Xindex, Yindex = transpose( [newXindex, newYindex] )

Transposes a 2D spectrum or, if you omit the arguments, returns the current indeces.

  
 

weight( exponential, gaussian, sine, sine_sqr )

Sets some FT parameters but does no processing. All arguments are optional.

wft( [weight[, transform[, hyperize ]]] )

Performs weighting, zero-filling and Fourier Transform. Accepts 3 optional Boolean arguments which, if set to false, skip part of the processing.

  
 
  
 
  
 

See also

Starting with Lua

Lua built-in functions on the web

Console

Keyboard: what you can do with it