Column transformations¶
Phonometrica lets you create new numeric columns by applying a mathematical formula to an existing column. To transform a column, right-click on its header in a dataset or concordance view and choose Transform… from the context menu. This opens the transform dialog.
Transform dialog¶
The dialog contains the following elements:
Formula: enter a mathematical expression using
xas the variable representing each cell value.New column name: automatically generated from the formula (e.g.
bark(F1)), but you can edit it.Preview: shows the first few values of the column along with the computed result, updated in real time as you type.
The formula is validated as you type. If there is an error, it is displayed in red below the formula field and the OK button is disabled.
Syntax¶
Formulas follow standard mathematical notation:
Variable:
xrepresents the value in each cell of the source column.Constants:
pi(3.14159…) ande(2.71828…).Operators:
+,-,*,/,^(exponentiation).Parentheses: use
(and)to group sub-expressions.Unary minus:
-xnegates a value. Unary plus (+x) is also accepted.
Operator precedence follows standard conventions (from lowest to highest):
Addition and subtraction (
+,-)Multiplication and division (
*,/)Unary minus and plus
Exponentiation (
^, right-associative)
For example, -x^2 is interpreted as -(x^2), and 2 * x ^ 3 is interpreted as 2 * (x^3).
Math functions¶
The following general-purpose mathematical functions are available:
Function |
Description |
|---|---|
|
Natural logarithm (base e). Requires x > 0. |
|
Base-10 logarithm. Requires x > 0. |
|
Base-2 logarithm. Requires x > 0. |
|
Square root. Requires x ≥ 0. |
|
Absolute value. |
|
Exponential function (ex). |
|
Power function (xn). Equivalent to |
|
Round to the nearest integer. |
|
Round down to the nearest integer. |
|
Round up to the nearest integer. |
Phonetic scale functions¶
The following functions convert acoustic values (typically in Hertz) to perceptual scales commonly used in phonetics:
Function |
Description |
|---|---|
|
Convert x Hz to the Bark scale (Traunmüller 1990). Formula: 26.81 / (1 + 1960 / x) − 0.53. Requires x > 0. |
|
Convert x Hz to the ERB-rate scale (Glasberg & Moore 1990). Formula: 21.4 × log10(0.00437 × x + 1). |
|
Convert x Hz to the mel scale (O’Shaughnessy 1987). Formula: 2595 × log10(1 + x / 700). |
|
Convert x Hz to semitones relative to 100 Hz. Formula: 12 × log2(x / 100). Requires x > 0. |
|
Convert x Hz to semitones relative to ref Hz. Formula: 12 × log2(x / ref). Requires x > 0 and ref > 0. |
Handling of special values¶
If the input value is NaN (not a number), the result is NaN.
If a function receives an input outside its domain (e.g.
log(-1)orsqrt(-2)), the result is NaN.Division by zero produces NaN.
After the transform is applied, a message indicates how many values produced NaN (if any).
Examples¶
Here are some common transformations:
Formula |
Purpose |
|---|---|
|
Log-transform (e.g. for normalizing skewed distributions) |
|
Convert formant values from Hz to Bark |
|
Convert formant values from Hz to ERB-rate |
|
Convert F0 in Hz to semitones (ref = 100 Hz) |
|
Convert F0 in Hz to semitones (ref = 200 Hz) |
|
Convert milliseconds to seconds |
|
Center and scale a variable |
|
Square the values |
|
Inverse (e.g. for speech rate from duration) |
|
Round to the nearest integer |
References¶
Glasberg, B. R. & Moore, B. C. J. (1990). Derivation of auditory filter shapes from notched-noise data. Hearing Research, 47(1–2), 103–138.
O’Shaughnessy, D. (1987). Speech Communication: Human and Machine. Addison-Wesley.
Traunmüller, H. (1990). Analytical expressions for the tonotopic sensory scale. Journal of the Acoustical Society of America, 88(1), 97–100.