Introduction

MocapMineR is an R package dedicated to the analysis of motion capture data. It was initially developed by Lou-Anne Guillotel and myself (Sébastien Lê) to analyze movements from blind Tae Kwon Do practitioners. The main idea, was to find a way to correct these practitioners automatically, based on graphical indicators. Actually, this package works for any kind of motion capture data. To use this package you will need two data sets. A first one, in which you store the coordinates of joints as a function of time, a second one in which you describe the structure of interest, i.e. the dependencies between the joints that define the segments of the structure.

A first step: visualization of the structure as a function of time with the skeleton function

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
options(rmarkdown.html_vignette.check_title = FALSE)
library(MocapMineR)

The human data set depicts the dependencies between the segments that compose the structure. It is constituted of three columns, a first one (segment) with the names of the segments, the two others with the names of the joints at the extremities of the segments (extr1 and extr2).

options(width = 100)
data(human)
head(human)

Then, the gaetan_apchagi data set contains the coordinates of the joints as a function of time. The first column is the moment when the information have been recorded. The second column is the joint that was measured. Columns 3 to 5 correspond to the dimensions that have been measured. Column 6 is the index of the frame. Column 7 is the number of frames per second and the last column is the name of the practitioner.

options(width = 100)
data(gaetan_apchagi)
head(gaetan_apchagi)

The skeleton function allows you to vizualize the movement you have recorded. The parameters num.joint, ..., num.name depend on the gaetan_apchagi data set.

options(width = 100)
data(gaetan_apchagi)
data(human)
skeleton(joint=gaetan_apchagi, structure=human, num.joint=2, 
         num.frame=6, num.x=3, num.y=4, num.name=8)

You may also want to highlight a particular segment or body part.

options(width = 100)
data(gaetan_apchagi)
data(human)
skeleton(joint=gaetan_apchagi, structure=human, num.joint=2, 
         num.frame=6, num.x=3, num.y=4, num.name=8,
         body.part = "tibia_r",color.part = "orange")

You can also represent a particular frame, and highlight a particular segment or body part.

options(width = 100)
data(gaetan_apchagi)
data(human)
skeleton(joint=gaetan_apchagi, structure= human, num.joint=2,num.frame=6,
         num.x=3, num.y=4, num.name=8, body.part = "tibia_r",frame.index=25,
         color.part = "orange")

A second step: visualization of the joints as a function of time with the joint function

Once you have a global understanding of what is going on, you may want to focus on the joints, i.e. you may want to aadopt a more local point of view (versus global).

To do so, let's apply the joint function. The idea is to represent the trajectory of each joint as a function of time: the index of the frame corresponds to the x-axis (num.frame), then you have to choose the dimension you want to represent on the y-axis (num.y).

options(width = 100)
data(gaetan_apchagi)
joint(joint=gaetan_apchagi, num.joint=2, num.frame=6, num.y=4, num.name=8,
      y.legend="y", fig.color="#FF0099")

Remark. This function can be used to compare different practitioners according to particular joints.

options(width = 100)
data(all_apchagi)
joint(joint=all_apchagi, num.joint=2, num.frame=6, num.y=4, num.name=8, y.legend="y",
fig.color=c("#3333FF", "#FF0099", "#00FFCC"),
vect.joint = c("RIGHT_KNEE", "RIGHT_ANKLE", "RIGHT_FOOT_INDEX"))

A third step: combining the visualization of the structure on the one hand, of the joints on the other hand, with the superskeleton function

In order to get a better understanding of the visualization of the structure, we first have to calculate numerical indicators. This is the role of the sidekick function. Here, we introduce the concept of singleton, couple and triplet.

A singleton is simply a joint, a couple is the association of two joints you want to compare in terms of relative positioning, and finally a triplet is the angle defined by the two vectors associated with the three joints of the triplet.

The sidekick function provides two options. The first one offers the possibility to represent a singleton (resp. a couple, resp. a triplet) as a function of time. The second one offers the possibility to represent a singleton (resp. a couple, resp. a triplet) as a function of another singleton.

The DNA of movement

Let's first study the singleton (resp. couple, resp. triplet) as a function of time. In the following example, we are interested into the right ankle. The sidekick function will provide the proper data set for the superskeleton function. The superskeleton function will provide a visualization of the structure enhanced with a visualization of the singleton of interest (resp. couple, resp. triplet). Let's first get the proper data set.

options(width = 100)
data(all_apchagi)
S1_right_ankle <- sidekick(joint=gaetan_apchagi, num.joint=2, num.name=8,
num.x=6, num.y=4, joint1="RIGHT_ANKLE", joint2=NULL)
head(S1_right_ankle)

Now that we have calculated the S1_right_ankle data set, we can use it as an input for the superskeleton function. The main inputs are the coordinates of the joints (joint parameter), the definition of the structure (structure parameter), the data set you want to visualize with the structure (sidekick parameter). Once you have these main inputs, you can tell the computer how you want to represent your structure. Here, as we are interested in the right ankle, we are going to highlight this joint on the structure.

options(width = 100)
data(gaetan_apchagi)
data(human)

S1_right_ankle <- sidekick(joint=gaetan_apchagi, num.joint=2, num.name=8,
num.x=6, num.y=4, joint1="RIGHT_ANKLE", joint2=NULL)

superskeleton(joint=gaetan_apchagi, structure=human, sidekick=S1_right_ankle,
num.joint=2, num.frame=6, num.x=3, num.y=4,  frame.index=NULL,
body.part="RIGHT_ANKLE", color.part="orange",
plot.title="Gaetan - right ankle trajectory", x.legend="Frame",
y.legend="Trajectory in y (cm)")

Of course, if you want to visualize this information for a given frame, all you have to do is to specify the index of the frame you want to represent.

options(width = 100)
data(gaetan_apchagi)
data(human)

S1_right_ankle <- sidekick(joint=gaetan_apchagi, num.joint=2, num.name=8,
num.x=6, num.y=4, joint1="RIGHT_ANKLE", joint2=NULL)

superskeleton(joint=gaetan_apchagi, structure=human, sidekick=S1_right_ankle,
num.joint=2, num.frame=6, num.x=3, num.y=4,  frame.index=25,
body.part="RIGHT_ANKLE", color.part="orange",
plot.title="Gaetan - right ankle trajectory", x.legend="Frame",
y.legend="Trajectory in y (cm)")

The RNA of movement

In this part, we are going to visualize the RNA of the movement, i.e. some kind of signature of the movement.



Sebastien-Le/MocapMineR documentation built on Dec. 18, 2021, 1:03 p.m.