Title: | Ultrasound Tongue Imaging |
---|---|
Description: | A tool for processing Articulate Assistant Advanced™ (AAA) export files and plot tongue contour data from any system. |
Authors: | Stefano Coretta [aut, cre] |
Maintainer: | Stefano Coretta <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.7.4 |
Built: | 2024-12-07 10:50:05 UTC |
Source: | CRAN |
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 ultrasond 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)
).
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
gam
It plots the smooths of a polar GAM fitted with polar_gam()
.
plot_polar_smooths( model, series, comparison = NULL, origin = NULL, facet_terms = NULL, conditions = NULL, exclude_random = TRUE, series_length = 100, split = NULL, sep = "\\.", time_series )
plot_polar_smooths( model, series, comparison = NULL, origin = NULL, facet_terms = NULL, conditions = NULL, exclude_random = TRUE, series_length = 100, split = NULL, sep = "\\.", time_series )
model |
A |
series |
An unquoted expression indicating the model term that defines the series on which smoothing is applied. This is the term that is displayed on the x-axis when plotting. |
comparison |
An unquoted expression indicating the model term for which the comparison will be plotted. |
origin |
The coordinates of the origin as a vector of |
facet_terms |
An unquoted formula with the terms used for faceting. |
conditions |
A list of quosures with |
exclude_random |
Whether to exclude random smooths (the default is |
series_length |
An integer indicating how many values along the time series to use for predicting the outcome term. |
split |
Columns to separate as a named list. |
sep |
Separator between columns (default is |
time_series |
Deprecated, use |
An object of class ggplot
.
library(dplyr) tongue_it01 <- filter(tongue, speaker == "it01") pgam <- polar_gam(Y ~ s(X, by = as.factor(label)), data = tongue_it01) plot_polar_smooths(pgam, X, label)
library(dplyr) tongue_it01 <- filter(tongue, speaker == "it01") pgam <- polar_gam(Y ~ s(X, by = as.factor(label)), data = tongue_it01) plot_polar_smooths(pgam, X, label)
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 behaves like predict_gam but it converts the
coordinates from polar to cartesian automatically. Check
vignette("predict-gam", package = "tidymv")
to an overview of the
predict method.
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, column_names, fan_lines = 42, coordinates = "cartesian", na_rm = FALSE, format = "long" )
read_aaa( file, column_names, fan_lines = 42, coordinates = "cartesian", na_rm = FALSE, format = "long" )
file |
The path of the file with AAA data. It can also be a character vector with multiple paths as separate strings.. |
column_names |
The names of the columns without including the splines columns. |
fan_lines |
The number of fan lines (the default is |
coordinates |
A string specifying the coordinate system. Possible values are |
na_rm |
Remove NAs (the default is |
format |
A string specifying the data format. Possible values are |
A tibble. An .index
column is added which indexes (groups) each tongue contour.
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, columns, na_rm = TRUE)
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, columns, na_rm = TRUE)
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).