﻿ Transformations and conversions
 Transformations and conversions

•    SIMPLE TRANSFORMATIONS...    T          This option allows various mathematical manipulations such as logarithms (base e and base 10), inverses, exponentiation, multiplication, division, square-roots, Q10 correction, etc.  Several cross-channel operations are also possible (addition, subtraction, multiplication, division).  A polynomial conversion with one to nine degrees is available.  Results are stored in the first source channel, or optionally (if the number of channels is less than 40) in a new channel.
If a block is selected, a button and edit field (not shown here) will let you set all the values within the block to a fixed value (the default is zero).

This sample window shows the addition of two channels, with the result stored in a new channel.  The multiply/divide option is set to 1 (meaning that no action is taken on the result of the addition operation).  If you set this number to something other than 1.0 and click either of the multiply or divide buttons, the result of the 'main' operation will be adjusted accordingly.

Two buttons at left toggle between transformations and unit conversions. The operations for transformations are selected from the smaller (right-most) of the two pop-up menus shown at near right.  Note that the last five transformations (addition, subtraction, multiplication, and division with different channels, and Q10 correction from a temperature channel) are only available if the file contains more than one channel.

Alternately, you can use a range of unit conversions from the pop-up menu shown at near right.  These pertain to commonly-used units of energy, flow rate, pressure, mass, speed, temperature, water vapor pressure, gas volume, and so forth.  Conversion into mass-specific units is also available.  The 'STP converter' option does not affect the channel data, but allows you to calculate an appropriate correction for temperature and pressure effects on gas volume (useful in respirometry).

For most of these operations, the conversion factors (i.e., the numerical coefficients in the conversion equations) can be edited as desired prior to calculations.  For example, you may wish to adjust the conversion factor for the heat of vaporization of water (which is set for a default evaporative surface temperature of 37 °C) to a value accurate at some other temperature.

Many of the conversions will attempt to adjust the channel label as appropriate.  For example, if you have chosen to convert a channel to mass-specific units, the program will append a "/g" or "/Kg" to the end of the current label.  Similarly, if you are converting a channel with units of watts to units of KJ/day, the program will search the label for the word "watts" and replace it with "KJ/day".  Keep in mind that automatic label modification is not always successful (depending on the format of your channel labels), so be sure to check.

Note that the transformations routines do not make any attempt to adjust labels to reflect changes.  You should be diligent in correcting the file labels appropriately in order to avoid confusion later on.

During mathematically complex operations that are time-consuming (such as calculating logs or computing vapor pressure from temperature), a progress bar appears.  This isn't shown for faster operations, since drawing the progress bar often is slower than the computations themselves!

Some special considerations for transformations and conversions:

• If the file contains less than 40 channels, you can copy the active channel to a new channel before transforming or converting it (this is a convenient way to duplicate channels), or route the converted file to a new channel.
• If a block has been selected, it can be set to a user-selectable value (default = zero) with the 'set block' button.
• If a block has been selected, you can optionally transform the all the data or just within the selected block.
• With many transformations, you can scale the results by multiplying or dividing them by a user-defined constant (select the 'multiply' or 'divide' button, as described above).
• The 'STP converter' option in the conversions menu is a small calculator that computes the flow rate at Standard Temperature and Pressure (STP) from the prevailing conditions of temperature, pressure, and flow.  It does not modify any channel data.
• The 'Info' button shows the A-D conversion data for the file.

The response correction option is similar to the 'effective volume' computation used for gas exchange.  It compensates for capacitance-like characteristics that slow response times and obscure rapid changes in measured variables, using the "Z-transformation".  The algorithm compares successive values and corrects them according to the following equation:

corrected value = [(value-last value)/Z factor] + last value

Typical Z factors are between 0.1 and 1.0 (other values are accepted).  It is reasonable to determine the correct value by trial-and-error, if you have a recording that contains a known step change (or near-instantaneous change).  Apply different Z factors until the results approximate a step change.

The breakpoint transforms option lets you use different transformation equations depending on whether data are less than or greater than a user-specified 'breakpoint' value. You enter the equations and the breakpoint in the following window (which appears whenever you select the breakpoint option):

After entering the breakpoint value, pick the type of equation for data below the breakpoint value, using the radio buttons at left.   Then click the 'use this equation for data < breakpoint' button, and enter the a, b, and c values in the first set of edit fields at the bottom of the window.   Then select the equation type for data equal to or greater than breakpoint, click the 'use this equation for data > breakpoint' button, and enter the a, b, and c values in the second set of edit fields.  In this example, a 2-way polynomial will be applied to data < breakpoint, and an exponential equation will be applied to data > breakpoint.   When all is correct, click the 'OK to transform' button to return to the main Transformations and Conversions window.

• If the screen width is sufficient, a scrolling edit field with instructions appears at the right of the window
• For all equation types, initial values always leave the data unchanged (i.e., they multiply by 1.0).

 NOTE:  LabAnalyst does not allow invalid or meaningless mathematical operations, such as division by zero, taking the log of a negative number, or using a non-integer exponent on a negative number.  If LabAnalyst encounters these situations during a transformation, the offending cases are set to zero, the computer beeps, and a warning message appears.  At this point you can click the 'Cancel' button to discard the transformed data, or accept the (partially invalid) transformation.

•          EXPRESSION TRANSFORMS...  This routine lets you write a mathematical expression to transform a channel.  The program parses the expression into components and performs the operations.   The expression evaluator understands the following symbols (upper or lower case entries are OK):

• Simple operators: + - * / ^ ( )
• Complex operators: EXP, LOG or LN, LOG10, SIN, COS, TAN, ATN or ATAN, ABS, INT, SQR (square), SQRT (square root)
• Two special variables (i.e., channels) named "X" and "Y", chosen with push-buttons (see image below)
• PI (or the equivalent Greek letter)
• Numbers (such as 5, -3.1889, and 1e-10)
• If you wish you can add a comment at the end of your expression, delineated with the " ` " character.

Results are stored in the first of the source channels, or optionally (if the number of channels is less than 40) in a new channel (edit the file label as appropriate).  If a data block has been selected, you can transform all the data or just within the block.   A typical expression transforms window looks like this:

Some general considerations:

• The 'Check expression' button does a preliminary parsing of the expression and indicates if there are any syntax errors (in the above example, this button has been clicked).
• The 'Run transform' button processes the channel data according to the expression in the upper left window.  The transformed data are re-written to the main plot area.  If any errors are found (see below), a warming message is shown.
• The 'undo' button reverses the effects of the last transformation.
• If a data block has been selected, you can transform all the data or just within the block.

NOTE: This will only 'catch' errors in the basic numeric expression. It may not detect invalid or meaningless math operations that may be attempted when channel data are processed, such as division by zero, or taking the log or a non-integer exponent of a negative number.  If such situations occur, results may be unpredicatable.  The algorithm does find most such errors during processing, however.

 The underlying code for the expression evaluator was largely developed by Robert Purves (fairly recently deceased and greatly missed).  I borrowed it -- with his permission -- and made some modifications for LabAnalyst.  But Robert P. deserves all the credit.

•    SCALE TO BLOCK...

Resets the scale and range of the data to values specified by the user, based on a block of data.  For example, you can rescale a block of data with an initial range of -.134 to .335 to a new range of zero to 100% (or any other upper and lower limits).

Note: although calculations are based on data within the selected block, the scale and range adjustment is applied to the entire file.

If you use the 'Block only' option, the rescaling is applied only to the selected block -- but keep in mind that it will now be out of calibration with the rest of the data in the channel.

•    BLOCK SCALE, 0-100%

This option automatically scales the selected block to a range of zero to 100.