Title: | Articulatory Data Processing in R |
---|---|
Description: | A tool for processing Articulate Assistant Advanced™ (AAA) ultrasound tongue imaging data and Carstens AG500/1 electro-magnetic articulographic data. |
Authors: | Stefano Coretta [aut, cre] |
Maintainer: | Stefano Coretta <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.0.1 |
Built: | 2025-02-20 14:24:04 UTC |
Source: | CRAN |
Filter a signal
filter_signal( signal, filter = "sgolay", order = 2, window_length = NULL, cutoff_freq = NULL, sampling_freq = NULL, type = "low", apply = 1 )
filter_signal( signal, filter = "sgolay", order = 2, window_length = NULL, cutoff_freq = NULL, sampling_freq = NULL, type = "low", apply = 1 )
signal |
Signal to filter. |
filter |
Type of filter (default is |
order |
Order of the filter. |
window_length |
Window length of the Savitzky-Golay filter. |
cutoff_freq |
Cut-off frequency of the Butterworth filter. |
sampling_freq |
Sampling frequency of the signal. |
type |
Butterworth band type (default is |
apply |
Apply the filter N times (default is |
The filtered signal.
Get acceleration of displacement
get_acceleration(signal)
get_acceleration(signal)
signal |
The signal to get the acceleration of. |
A vector with the second derivative of the signal.
Get gestural landmarks
get_landmarks(signal_vel, time, start, end, threshold = 0.2)
get_landmarks(signal_vel, time, start, end, threshold = 0.2)
signal_vel |
The velocity of the displacement signal. |
time |
The time of the signal. |
start |
Start time of interval in which to search for maximum displacement. |
end |
End time of interval in which to search for maximum displacement. |
threshold |
The velocity threshold (default is |
A tibble with one row and a column for each gestural landmark.
It returns the Cartesian x, y
coordinates of the virtual origin of the
ultrasonic waves/probe surface (see Details).
get_origin(data, fan_lines = c(10, 25))
get_origin(data, fan_lines = c(10, 25))
data |
The spline data (the cartesian coordinates must be in two columns
named |
fan_lines |
A numeric vector with two fan lines (the default is
|
The function estimates the origin of the ultrasound waves from the probe using the spline data and the provided fan lines. The estimation method is based on Heyne, Matthias & Donald Derrick (2015) Using a radial ultrasound probe's virtual origin to compute midsagittal smoothing splines in polar coordinates. The Journal of the Acoustical Society of America 138(6), EL509–EL514, DOI:10.1121/1.4937168.
A numeric vector with the Cartesian (x, y)
coordinates of the virtual origin of the
ultrasonic waves/probe surface.
The equations of the two fan lines (10 and 25 by
default) are set equal to find their intersection. The intersection is the
origin. In some cases, the linear estimation of the equation fails, and an
error related to fit is returned. In these cases, try different fan lines
by increasing the minimum fan line and/or changing the maximum fan line
(for example, if c(10, 25)
returns an error, try c(15, 30)
).
Get velocity of displacement
get_velocity(signal)
get_velocity(signal)
signal |
The signal to get the velocity of. |
A vector with the first derivative of the signal.
A dataset containing the palate profile of a single speaker.
palate
palate
A data frame with 42 rows and 14 variables.
speaker ID
time of coordinate, in seconds
date and time of recording
prompt string
label of annotation
smoothed displacement of tongue tip
velocity of tongue tip displacement
absolute velocity of tongue tip displacement
smoothed displacement of tongue dorsum
velocity of tongue dorsum displacement
absolute velocity of tongue dorsum displacement
fan line number
horizontal coordinate at time seconds
vertical coordinate at time seconds
It plots tongue contours from data imported from AAA.
plot_tongue(data, geom = "line", ..., palate = NULL, palate_col = "green")
plot_tongue(data, geom = "line", ..., palate = NULL, palate_col = "green")
data |
A data frame with splines data. |
geom |
Type of geom to plot. Possible values are: |
... |
List of arguments to be passed to |
palate |
An optional data frame with the palate spline. If provided, the palate is plotted. |
palate_col |
The colour of the palate spline (the default is |
An object of class ggplot
.
plot_tongue(tongue, geom = "point")
plot_tongue(tongue, geom = "point")
It fits a generalised additive model (GAM) to transformed polar tongue data
and it returns a model in polar coordinates. Use plot_polar_smooths()
for plotting.
polar_gam( formula, data, origin = NULL, fan_lines = c(10, 25), AR_start = NULL, ... )
polar_gam( formula, data, origin = NULL, fan_lines = c(10, 25), AR_start = NULL, ... )
formula |
A GAM formula. |
data |
A data set containing the spline coordinates (cartesian coordinates must be in columns named |
origin |
The coordinates of the origin as a vector of |
fan_lines |
A numeric vector with two fan lines (the default is
|
AR_start |
The |
... |
Arguments to be passed to |
It is advised to fit a separate model per speaker, unless you have a working method for inter-speaker normalisation of the coordinates.
An object of class "gam"
as described in
gamObject
.
library(dplyr) tongue_it01 <- filter(tongue, speaker == "it01") pgam <- polar_gam(Y ~ s(X, by = c2_place) + s(X, word, bs = "fs"), data = tongue_it01)
library(dplyr) tongue_it01 <- filter(tongue, speaker == "it01") pgam <- polar_gam(Y ~ s(X, by = c2_place) + s(X, word, bs = "fs"), data = tongue_it01)
It returns a tibble with the predictions from all the terms in a polar_gam model.
predict_polar_gam( model, origin = NULL, exclude_terms = NULL, length_out = 50, values = NULL, return_ci = FALSE, ci_z = 1.96 )
predict_polar_gam( model, origin = NULL, exclude_terms = NULL, length_out = 50, values = NULL, return_ci = FALSE, ci_z = 1.96 )
model |
A polar_gam model object. |
origin |
The coordinates of the origin as a vector of |
exclude_terms |
Terms to be excluded from the prediction. Term names should be given as they appear in the model summary (for example, |
length_out |
An integer indicating how many values along the numeric predictors to use for predicting the outcome term (the default is |
values |
User supplied values for numeric terms as a named list. |
return_ci |
Whether to return a tibble with cartesian confidence intervals (for use with geom_polar_ci). |
ci_z |
The z-value for calculating the CIs (the default is |
The function converts the coordinates from polar to cartesian automatically.
To see an example of plotting, see the examples in geom_polar_ci.
A tibble with predictions from a polar_gam model.
library(dplyr) tongue_it01 <- filter(tongue, speaker == "it01") it01_pol <- polar_gam(Y ~ s(X, by = c2_place) + s(X, word, bs = "fs"), data = tongue_it01) # get predictions it01_pred <- predict_polar_gam(it01_pol) # get predictions excluding the random smooth for word (the coefficient for # the random smooth is set to 0) it01_excl_rand <- predict_polar_gam(it01_pol, exclude_terms = "s(X,word)")
library(dplyr) tongue_it01 <- filter(tongue, speaker == "it01") it01_pol <- polar_gam(Y ~ s(X, by = c2_place) + s(X, word, bs = "fs"), data = tongue_it01) # get predictions it01_pred <- predict_polar_gam(it01_pol) # get predictions excluding the random smooth for word (the coefficient for # the random smooth is set to 0) it01_excl_rand <- predict_polar_gam(it01_pol, exclude_terms = "s(X,word)")
It reads a file or a list of files with data exported from AAA. The data are automatically transformed from a wide to a long format (each row has values of X or Y axes for each fan line). The imported tibble can then be used for plotting and statistical analysis.
read_aaa( file, coordinates = "cartesian", format = "long", na_rm = FALSE, knots = NULL, column_names = NULL, fan_lines = NULL )
read_aaa( file, coordinates = "cartesian", format = "long", na_rm = FALSE, knots = NULL, column_names = NULL, fan_lines = NULL )
file |
The path of the file with AAA data. It can also be a character vector with multiple paths as separate strings.. |
coordinates |
A string specifying the coordinate system. Possible values are |
format |
A string specifying the data format. Possible values are |
na_rm |
Remove NAs (the default is |
knots |
The number of spline knots or fan lines. |
column_names |
The names of the columns without including the splines columns. |
fan_lines |
The number of fan lines in legacy fan-line data. |
A tibble.
columns <- c("speaker","seconds","rec_date","prompt","label", "TT_displacement","TT_velocity","TT_abs_velocity","TD_displacement", "TD_velocity","TD_abs_velocity") file_path <- system.file("extdata", "it01.tsv", package = "rticulate") tongue <- read_aaa(file_path, knots = 42, column_names = columns)
columns <- c("speaker","seconds","rec_date","prompt","label", "TT_displacement","TT_velocity","TT_abs_velocity","TD_displacement", "TD_velocity","TD_abs_velocity") file_path <- system.file("extdata", "it01.tsv", package = "rticulate") tongue <- read_aaa(file_path, knots = 42, column_names = columns)
Read EMA data from AG500 pos files
read_ag500_pos(path, channels = 12, ch_values = 7, bytes = 4, fs = 200)
read_ag500_pos(path, channels = 12, ch_values = 7, bytes = 4, fs = 200)
path |
Path to the .pos file. |
channels |
Number of channels (default |
ch_values |
Number of values per channel (default |
bytes |
Number of bytes per value (default |
fs |
Sampling frequency (default |
A tibble.
Resample (up or down) a signal
resample_signal( signal, time, by = 2, to = NULL, from = NULL, method = "interpolation" )
resample_signal( signal, time, by = 2, to = NULL, from = NULL, method = "interpolation" )
signal |
The signal to resample. |
time |
The time vector of the signal to resample. |
by |
The factor by which to resample the signal (default is |
to |
The frequency to resample to. |
from |
The original sampling frequency. |
method |
Resampling method (default is |
A list with the resampled signal and time if methdo = "interpolate"
.
A dataset with linguistic information on the stimuli.
stimuli
stimuli
A data frame with 12 rows and 11 variables.
item ID
words of the form CVCV
IPA transcription of the words
first consonant
phonation of the first consonant, voiceless
first and second vowel
backness of the vowel, back
or central
height of the vowel, high
, mid
or low
second consonant
phonation of the second consonant, voiceless
or voiced
place of the second consonant, coronal
or velar
A dataset containing tongue contour coordinates of a single speaker.
tongue
tongue
A data frame with 3612 rows and 28 variables.
speaker ID
time of coordinate, in seconds
date and time of recording
prompt string
label of annotation
smoothed displacement of tongue tip
velocity of tongue tip displacement
absolute velocity of tongue tip displacement
smoothed displacement of tongue dorsum
velocity of tongue dorsum displacement
absolute velocity of tongue dorsum displacement
smoothed displacement of tongue root
velocity of tongue root displacement
absolute velocity of tongue root displacement
fan line number
horizontal coordinate at time seconds
vertical coordinate at time seconds
words of the form CVCV
item ID
IPA transcription of the words
first consonant
phonation of the first consonant, voiceless
first and second vowel
backness of the vowel, back
or central
height of the vowel, high
, mid
or low
second consonant
phonation of the second consonant, voiceless
or voiced
place of the second consonant, coronal
or velar
This function transforms the coordinates of spline data between Cartesian and polar coordinate systems. The origin x and y coordinates can be supplied by the user, or calculated automatically (see Details).
transform_coord( data, to = "polar", origin = NULL, fan_lines = c(10, 25), use_XY = FALSE )
transform_coord( data, to = "polar", origin = NULL, fan_lines = c(10, 25), use_XY = FALSE )
data |
A data set containing the spline coordinates (cartesian coordinates must be in columns named |
to |
Which system to convert to, as a string, either |
origin |
The coordinates of the origin as a vector of |
fan_lines |
A numeric vector with two fan lines (the default is
|
use_XY |
Whether to use the column names |
The transformation between the coordinate systems require the selection of an
origin in Cartesian coordinates (x and y). The origin ideally corresponds to
the virtual origin of the ultrasound waves from the probe. The origin
coordinates can be supplied by the user as a vector with the origin
argument, or they can be estimated automatically if origin = NULL
(the
default). The estimation is performed by get_origin
(see that
function documentation for details).
An object of class tbl_df-class
(a tibble).