face2stdFace | R Documentation |
The heads of the participants are of different sizes. This function rescales
the x/y values according to a standardized face. The standardized face is of
height 1 and width 1, while the pupil-pupil distance is defined as 1/3 and the
left-pupil – left-mouth-corner distance is defined as 1/3. Accordingly, for resizing
the x-axis, the distance between the pupils of the subject is used. For resizing the y-axis,
the distance between the left pupil and the left mouthcorner is used.
Optionally, the distance between the mouthcorners for the x-axis, and the distance between
the right pupil and the right mouthcorner for the y-axis may be provided in addition.
If provided, a mean of both measures is computed. Be aware that if you previously rescaled
the data into millimeter by the function bu2mm
, you also have to
rescale the scaling parameters e.g., the pupil-pupil distance into millimeter first
and use the millimeter values as scaling parameters!
face2stdFace(
data,
colNames,
colNameSubj,
pupilDist,
leftPMDist,
mouthcornerDist = NA,
rightPMDist = NA,
verbose = FALSE
)
data |
Data frame containig the columns which should be rescaled. Remaining colums will be returned unchanged (e.g., the z-values because no information for rescaling is available). |
colNames |
Character vector with names of the columns which should be rescaled. To differ between x-, and y-axis scaling, the variable names containing horizontal movement (left-right) should end with '_x', whereas variable names containing vertical movement (up-down) should end with '_y'. |
colNameSubj |
Character vector with a single value containig the name of the subject column of the data data-frame. |
pupilDist |
Numeric vector of measurement of the distance from left to right pupil for each subject, measured in blender units. This vector is used to rescale the x-axis. |
leftPMDist |
Numeric vector of measuremet of the distance from left pupil to left mouthcorner for each subject, measured in blender units. This vector is used to rescale the y-axis. |
mouthcornerDist |
Optional numeric vector of measurement of the distance from left to right
mouthcorner for each subject measured in blender units. If provided, a mean
of |
rightPMDist |
Optional numeric vector of measurement of the distance from right pupil to right
mouthcorner for each subject, measured in blender units. If provided, a mean
of |
verbose |
Logical value. If TRUE, the function provides verbose console output. |
Data frame with columns rescaled to a standard face.
Axel Zinkernagel zinkernagel@uni-wuppertal.de, Rainer Alexandrowicz rainer.alexandrowicz@aau.at
# Load the file "Blender_Scalingdata.csv"
scaledata <- read.csv(system.file("extdata", "Blender_Scalingdata.csv",
package = "blenderFace"), header = TRUE, sep =",")
# Make sure to have the data sorted by subjects
scaledata <- scaledata[with(scaledata, order(scaledata$subject)), ]
# Determin the dataframe columns which should be scaled:
names(rawdata)
# -> Frame, Stimulustype, subject and z-axis values should not be scaled
# -> removed for variable colNames
colNames <- c("A7_x", "A7_y", "A8_x", "A8_y",
"BL2_x", "BL2_y", "BL4_x", "BL4_y",
"BL5_x", "BL5_y", "BL7_x", "BL7_y",
"BR2_x", "BR2_y", "BR4_x", "BR4_y",
"BR5_x", "BR5_y", "BR7_x", "BR7_y",
"CL4_x", "CL4_y", "CL7_x", "CL7_y",
"CR4_x", "CR4_y", "CR7_x", "CR7_y",
"DL2_x", "DL2_y", "DR2_x", "DR2_y")
# To not overwrite existing data, use a new data frame
# (dataStdF means data of standaradized faces)
dataStdF <- face2stdFace(data = rawdata, colNames = colNames,
colNameSubj = "subject", pupilDist = scaledata$PupilPupilDistance,
leftPMDist = scaledata$LeftPupilLeftMouthcornerDistance)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.