helpers

ArrayNth

Extract every n-th element from an array.

Parameters

Examples

ArrayNth( [ 1, 2, 3, 4, 5, 6], 2, 2 );
// returns [3, 5]
Returns **(Array<number> void)** Every n-th element.

ArrayRange

This is a flexible function to generate an array of arithmetic progressions. All arguments must be integers.

Parameters

Examples

ArrayRange(10);
// returns [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

ArrayRange(1,11);
// returns [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

ArrayRange(0, 30, 5);
// returns [0, 5, 10, 15, 20, 25]

ArrayRange(0, 10, 3);
// returns [0, 3, 6, 9]

ArrayRange(0, 10, 3, "x2");
// returns [0, 9, 36, 81]

ArrayRange(0, -10, -1);
// returns [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]

ArrayRange(0);
// returns []

ArrayRange(1,0);
// returns []
Returns **(Array<number> void)**

ArrayUnZip

This function transforms an array of [x, y] pairs into an object with an array of x and an array of y values

Parameters

Examples

ArrayUnZip( [ [1, 4], [2, 5], [3, 6] ] );
//returns {x: [1, 2, 3], y: [4, 5, 6]}
Returns **(object void)** { x: [x1, x2, …, xn], y: [y1, y2, …, yn] }

ArrayZip

This function transforms two arrays into one array of x,y pairs Both arrays supplied need to have the same size.

Parameters

Examples

var x = [1, 2, 3];
var y = [4, 5, 6];
ArrayZip(x,y)
//returns [ [1, 4], [2, 5], [3, 6] ]
Returns **(Array<number> void)** [ [x1,y1], [x2,y2], …, [xn,yn] ].

danger

Add a Danger Message for the User. These messages will be shown in the data viewer as well. Use these messages to indicate a problematic issue that will most likely result in an invalid measurement.

Parameters

Examples

danger('Your Danger Message', output);
// output['messages']['info']['Your Danger Message']

Returns object pushes the message into the output object.

GetIndexByLabel

Find the positions for protocols within a protocol set matching the provided label. If only one label exists within a set, a number is returned. When multiple protocols in the set have the same label an array with all indexes of matching labels is returned.

Parameters

Examples

GetIndexByLabel( "PAM", json );
// returns e.g. 1 or [1,2]

GetIndexByLabel( "PAM", json, true );
// returns e.g. [1] or [1,2]
Returns **(number Array<number>)** Single index or an array of indexes

GetLabelLookup

Generate a protocol lookup table for a protocol set.

Parameters

Examples

GetLabelLookup(json);
// returns e.g. { "PAM": [0,2], "ECS": [1]}

Returns object Lookup table

GetProtocolByLabel

Returns the protocol from within the protocol set matching the provided label. If only one label exists, one protocol object is returned. When multiple protocols in the set have the same label an array with all protcol objects of matching labels is returned.

Parameters

Examples

GetIndexByLabel( "PAM", json );
// returns e.g. { "label": "PAM", ...} or [{ "label": "PAM", ...}, { "label": "PAM", ...}]

GetIndexByLabel( "PAM", json, true );
// returns e.g. [{ "label": "PAM", ...}] or [{ "label": "PAM", ...}, { "label": "PAM", ...}]
Returns **(Object Array<Object>)** Single protocol or an array of protocols

info

Add an Info Message for the User. Use these messages to give additional information (if necessary).

Parameters

Examples

info('Your Info Message', output);
// output['messages']['info']['Your Info Message']

Returns object pushes the message into the output object.

Math.abs

Math.abs(x) returns the absolute value of x.

Parameters

Examples

Math.abs(4.7);
// returns 5
Math.abs(4.4);
// returns 4;

Returns number

Math.acos

Math.acos(x) returns the arccosine of x, in radians.

Parameters

Examples

Math.acos(0.5);
// returns 1.0471975511965979

Returns number

Math.asin

Math.asin(x) returns the arcsine of x, in radians.

Parameters

Examples

Math.asin(0.5);
// returns 0.5235987755982989

Returns number

Math.atan

Math.atan(x) returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians.

Parameters

Examples

Math.atan(0.5);
// returns 0.4636476090008061

Returns number

Math.atan2

Math.atan2(y, x) returns the arctangent of the quotient of its arguments.

Parameters

Examples

Math.atan2(0.5,2);
// returns 0.24497866312686414

Returns number

Math.ceil

Math.ceil(x) returns the value of x rounded up to its nearest integer.

Parameters

Examples

Math.ceil(4.7);
// returns 5

Returns number

Math.cos

Math.cos(x) returns the cosine of x (x is in radians).

Parameters

Examples

Math.cos(1);
// returns 0.5403023058681398

Returns number

Math.E

Euler’s number (approx. 2.718).

Examples

Math.E;
// returns 2.718281828459045

Returns number 2.718281828459045

Math.exp

Math.exp(x) returns the value of Ex.

Parameters

Examples

Math.exp(3);
// returns 20.085536923187668

Returns number

Math.floor

Math.floor(x) returns the value of x rounded down to its nearest integer.

Parameters

Examples

Math.floor(4.7);
// returns 4

Returns number

Math.LN10

Natural logarithm of 10 (approx. 2.302).

Examples

Math.LN10;
// returns 2.302585092994046

Returns number 2.302585092994046

Math.LN2

Natural logarithm of 2 (approx. 0.693).

Examples

Math.LN2;
// returns 0.6931471805599453

Returns number 0.6931471805599453

Math.log

Math.log(x) returns the natural logarithm (base E) of x.

Parameters

Examples

Math.log(4.7);
// returns 1.547562508716013

Returns number

Math.LOG10E

Base-10 logarithm of E (approx. 0.434).

Examples

Math.LOG10E;
// returns 0.4342944819032518

Returns number 0.4342944819032518

Math.LOG2E

Base-2 logarithm of E (approx. 1.442).

Examples

Math.LOG2E;
// returns 1.4426950408889634

Returns number 1.4426950408889634

Math.max

Math.max(x, y, z, …, n) returns the number with the highest value.

Parameters

Examples

Math.max(0, 150, 30, 20, -8, -200);
// returns 150

Returns number

Math.min

Math.min(x, y, z, …, n) returns the number with the lowest value.

Parameters

Examples

Math.min(0, 150, 30, 20, -8, -200);
// returns -200

Returns number

Math.PI

PI (approx. 3.14)

Examples

Math.PI;
// returns 3.141592653589793

Returns number 3.141592653589793

Math.pow

Math.pow(x, y) returns the value of x to the power of y.

Parameters

Examples

Math.pow(3,2);
// returns 9

Returns number

Math.random

Random number

Examples

Math.random();
// returns a random number

Returns number between 0 and 1

Math.round

Math.round(x) returns the value of x rounded to its nearest integer.

Parameters

Examples

Math.round(4.7);
// returns 5
// Math.round(4.4);
// returns 4

Returns number

Math.sin

Math.sin(x) returns the sine of x (x is in radians).

Parameters

Examples

Math.sin(1);
// returns 0.8414709848078965

Returns number

Math.sqrt

Math.sqrt(x) returns the square root of x.

Parameters

Examples

Math.sqrt(2);
// returns 1.4142135623730951

Returns number

Math.SQRT1_2

Square root of 1/2 (approx. 0.707).

Examples

Math.SQRT1_2;
// returns 0.7071067811865476

Returns number 0.7071067811865476

Math.SQRT2

Square root of 2 (approx. 1.414).

Examples

Math.SQRT2;
// returns 1.4142135623730951

Returns number 1.4142135623730951

Math.tan

Math.tan(x) returns the tangent of an angle.

Parameters

Examples

Math.tan(1);
// returns 1.5574077246549023

Returns number

MathEXPINVREG

Fit exponential decay to Y = Y0 + Ae^(-x/t) A and t are the fitted variables, the provided input array needs to be an array of x,y pairs.

Parameters

Examples

MathEXPINVREG( [ [x1,y1], [x2,y2], ..., [xn,yn] ] );
// returns
{
  "points": [ [x1,y1], [x2,y2], ..., [xn,yn] ],
	 "results": [A, t],
	 "error": yError,
  "asymptote": asymptote,
  "rsquared": linReg.rsquared,
  "lifetime": lifetime,
	 "slope": slope
}

Returns object Results from fit including points, values for A and t, error, asymptote, rsquared, lifetime, slope.

MathLINREG

Function to perform a simple linear regression (y = mx +b), returning slope, y-intercent, correlation coefficient (R) and coefficient of determination (R²).

Parameters

Examples

MathLINREG([60,61,62,63,65], [3.1,3.6,3.8,4,4.1]);
// returns {
// 	"m": 0.188,    // slope
// 	"b": -7.964,   // y intercept
// 	"r": 0.912,    // correlation coefficient
// 	"r2": 0.832    // coefficient of determination
}

Returns object Linear regression results

MathLN

Returns the natural logarithm (base E) of a number.

Parameters

Examples

MathLN(10);
// returns 2.302585092994046

Returns number

MathLOG

Returns the logarithm (base 10) of a number.

Parameters

Examples

MathLOG(10);
// returns 1

Returns number

MathMAX

Get the maximum value from an array of numbers. The function fails if the array is empty or has invalid values.

Parameters

Examples

MathMAX([1,2,3,4.5]);
// returns 4.5

Returns number

MathMEAN

Calculate the mean from an array of numbers. The function fails if the array is empty or has invalid values.

Parameters

Examples

MathMEAN([1,2,3,4.5]);
// returns 2.625

Returns number

MathMEDIAN

Calculate the median from an array of numbers. The function fails if the array is empty or has invalid values.

Parameters

Examples

MathMEDIAN([1,2,3,4.5]);
// returns 2.5

Returns number

MathMIN

Get the minimum value from an array of numbers. The function fails if the array is empty or has invalid values.

Parameters

Examples

MathMIN([1,2,3,4.5]);
// returns 1

Returns number

MathMULTREG

Multiple Linear Regression

Parameters

Examples

MathEXPINVREG( [ [ [x1,y1], [x2,y2], ..., [xn,yn] ], [ [x1,y1], [x2,y2], ..., [xn,yn] ] ] );
// returns
{
  "rsquared": rSq,
  "slopes": [slope1, ...],
  "points": [ [x1, x2, ..., xn], [y1, y2, ..., yn] ]
}

Returns object Returns rsquared, slopes and points.

MathPOLYREG

Polynomial fit to y = a0 + a1x + a2x^2 + a3x^3….

Parameters

Examples

MathPOLYREG( [ [ [x1,y1], [x2,y2], ..., [xn,yn] ], [ [x1,y1], [x2,y2], ..., [xn,yn] ] ], degree );
// returns
{
  "points": points,
  "slopes": slopes,
  "error": yError
}

Returns object Returns points, slopes and error

MathROUND

Calculate the variance from an array of numbers. The function fails if the array is empty or has invalid values.

Parameters

Examples

MathROUND(1.23456789, 5);
// returns 1.2346

Returns number

MathSTDERR

Calculate the standard error from an array of numbers. The function fails if the array is empty or has invalid values.

Parameters

Examples

MathSTDERR([1,2,3,4.5]);
// returns 0.6465050270492876

Returns number

MathSTDEV

Calculate the variance from an array of numbers. The function fails if the array is empty or has invalid values.

Parameters

Examples

MathSTDEV([1,2,3,4.5]);
// returns 1.2930100540985752

Returns number

MathSTDEVS

Calculate the variance from an array of numbers. The function fails if the array is empty or has invalid values.

Parameters

Examples

MathSTDEVS([1,2,3,4.5]);
// returns 1.4930394055974097

Returns number

MathSUM

Calculate the sum from an array of numbers. The function fails if the array is empty or has invalid values.

Parameters

Examples

MathSum([1,2,3,4.5]);
// returns 10.5

Returns number

MathVARIANCE

Calculate the variance from an array of numbers. The function fails if the array is empty or has invalid values.

Parameters

Examples

MathVARIANCE([1,2,3,4.5]);
// returns 2.2292

Returns number

NonLinearRegression

Function to perform a non-linear regression.

Parameters

Examples

NonLinearRegression(
 [
	  [x1, y1],
	  [x2, y2],
	  ...,
	  [xn, yn]
 ],
 {
	  equation: "b + a * e(- x / c)",
	  initial: [a, b, c]
 }
)


// Available equations
// "b + a * e(- x / c)"
// "( a - c ) * e( - b * t ) + c"
// "( c + a / ( 1 + b / x ) )"
// "( c + a * a / ( 1 + b / x ) )"


// returns
// {
//   text: <string>,
//   ParameterEstimates: <string>,
//   CovarianceMatrix: <string>,
//   r2: <number>
//   parameters: {
//     name: <string>,
//     value: <number>,
//     sd_error: <number>,
//     p: <number>
//   },
//   RMS_error: <number>,
//   presets: <object>,
//   iterations: <number>,
//   RMS_errors: <array>
// }
// Use a custom fitting function
// The function can contain the following parameters:
// x, t, a, b, c, .. h
// Not all parameters have to be defined and they can
// be in a random order. Use parameter names in alphabetical
// order (e.g. a and b, a and c without b will not work)
var decay = function(x,a,b,c){
return b + a * Math.exp( -x / c );
};

NonLinearRegression(
 [
	  [x1, y1],
	  [x2, y2],
	  ...,
	  [xn, yn]
 ],
 {
	  equation: decay,
	  initial: [a, b, c]
 }
)
// The returned object has the same structure as object in
// in the previous example.

Returns object

TransformTrace

The function transforms a given array by providing a second same length array, or a single number.

Parameters

Examples

TransformTrace('subtract', [1, 2, 3, 4], [0, 1, 2, 1]);
// returns [1, 1, 1, 3]

TransformTrace('add', [1, 2, 3, 4], [0, 1, 2, 1]);
// returns [1, 3, 5, 5]

TransformTrace('add', [1, 2, 3, 4], 5);
// returns [6, 7, 8, 9]

TransformTrace('normToMin', [1.5, 2, 3, 4]);
// returns [1, 1.3333, 2, 2.6665]

TransformTrace('normToMax', [1.5, 2, 3, 4]);
// returns [0.375, 0.5, 0.75, 1]

TransformTrace('normToRange', [1.5, 2, 3, 4]);
// returns [0, 0.2, 0.6, 1]

TransformTrace('normToIdx', [1.5, 2, 3, 4], 1);
// returns [0.75, 1, 1.5, 2]

TransformTrace('normToVal', [1, 2, 3, 4], 2);
// returns [0.75, 1, 1.5, 2]

// Smoothing (ma= Moving average, sgf= Savitzky-Golay filter)

TransformTrace('ma', [1.5, 2, 3, 4]);
// returns [1.6667, 2.1665, 3, 3.6665]

TransformTrace('sgf', [1,2,3,4,3,2,1,1]);
// returns [1.3333333333333333,1.9523809523809523]

// Absorbance (abs) -log(I/I0)

// In case no value is provided, I0 is the fist value from the array
TransformTrace('abs', [1.5, 2, 3, 4]);
// returns [-0, -0.12494, -0.30103, -0.42597]

TransformTrace('absorbance', [1.5, 2, 3, 4]);
// returns [-0, -0.12494, -0.30103, -0.42597]

// The provided value is I0
TransformTrace('abs', [1.5, 2, 3, 4], 1);
// returns [-0.1761, -0.3010, -0.4771, -0.6021]

// Absolute numbers
TransformTrace('absolute', [1, -2, 3, -4]);
// returns [1, 2, 3, 4]
Returns **(Array<number> string void)** Transformed array, a string with an error message or null

warning

Add an Warning Message for the User. Use these messages to indicate a potential issue and direct the user to check the measurement again.

Parameters

Examples

warning('Your Warning Message', output);
// output['messages']['warning']['Your Warning Message']

Returns object pushes the message into the output object.