The class to define tracking data.
More...
|
Property | comment |
| String: Personal comment.
|
|
Property | filename |
| String: Filename with path, without extension.
|
|
Constant Property | VARIABLEIDENTIFIER = {'type', 'name', 'unit', 'position', 'direction', 'segment'} |
| Cell containing Strings: Column names of TrackingData.variables which are needed to identify an unique variable row.
|
|
|
Property | nSamples |
| Double: Number of samples (same for each variable)
|
|
Property | nTrials |
| Double: Number of trials.
|
|
Property | nVariables |
| Double: Number of variables.
|
|
|
function | correctGyroSum (in obj, in plotIt) |
| Function to set the sum of a periodic gyro signal to 0.
|
|
function | correctVariance (in obj, in plotIt) |
| Function to prevent small variances of the variables.
|
|
function | extractData (in obj, in type, in names, in directions, in positions, in units) |
| Function to extract only specific data from the TrackingData object.
|
|
function | inclineGRF (in obj, in incline) |
| Function to change a treadmill's incline.
|
|
function | preprocessData (in obj, in nNodes) |
| Function to preprocess tracking data.
|
|
function | resampleData (in obj, in nNodes, in plotIt, in plotSamples, in plotVariance) |
| Function to resample tracking data.
|
|
function | trimData (in obj, in iStart, in iEnd, in plotIt, in plotSamples, in plotVariance) |
| Function to trim tracking data.
|
|
function | useHalfGaitCycleData (in obj) |
| Function to cut the tracking data such that only half is used.
|
|
function | writeMotionToOsim (in obj, in model, in filename) |
| Function to write motion from tracking data object to OpenSim files.
|
|
|
Property | computerName |
| String: Name of the computer (Will be automatically set in the constructor)
|
|
Property | creationTime |
| Datetime: Creation date with 'dd-MMM-yyyy HH:mm:ss' (Will be automatically set in the constructor)
|
|
Property | gitHashString |
| String: Git hash of the current commit (Will be automatically set in the constructor)
|
|
Property | gitURL |
| String: Url of git repository (Will be automatically set in the constructor)
|
|
Property | isSymmetric |
| Boolean: 1 if symmetry assumption can be used, i.e.
|
|
Property | movementDescription |
| String: More detailed description of the movement.
|
|
Property | movementEvents |
| Table: Movement events saved with name and index.
|
|
Property | movementType |
| String: Movement type which was recorded (e.g. walking)
|
|
Property | participantAge |
| Double: Age of participant in years.
|
|
Property | participantGender |
| String: Gender of participant ('female' or 'male')
|
|
Property | participantHeight |
| Double: Height of participant in m.
|
|
Property | participantMass |
| Double: Mass of participant in kg.
|
|
Property | participantName |
| String: Name of the participant.
|
|
Property | performedProcessing |
| Table: Information about performed processing.
|
|
Property | runningStyle |
| String: Running style of the participant (i.e. 'rearfoot', 'midfoot', 'forefoot')
|
|
Property | studyDate |
| Datetime: dd-MMM-yyyy of the study created using:
|
|
Property | studyName |
| String: Name of the study.
|
|
Property | trialList |
| Cell array of strings: Description of the single data trials (nTrials x 1)
|
|
Property | userName |
| String: User name of the computer (Will be automatically set in the constructor)
|
|
Property | variables |
| Table: Data with columns type, name, mean, var (=variance), unit, and optionally segment, position, and direction for IMU and marker data.
|
|
The class to define tracking data.
This class was implemented to ensure a consistent data structure of tracking data
This class contains methods which are generally applicable to load or process tracking data. Project specific methods should be saved in our personal scripts folder!
This class inherits from matlab.mixin.Copyable. This means that we can make a deep copy of a TrackingData object:
trackingData2 = copy(trackingData);
The method plotVarTable(trackingData.variables) can be used for visualization:
function plotVarTable(in varTable, in style, in plotStance)
Function to plot all variables within a variables table.
- Todo:
- The property isSymmetric is very confusing. Because it is not telling something about the symmetry of the data. If we would like to track other movements later we should have both isSymmetric and isPeriodic.
- Todo:
- Test the implementation with IMU data.
- Examples
- /home/runner/work/BioMAC-Sim-Toolbox/BioMAC-Sim-Toolbox/ExampleScripts/+IntroductionExamples/script2D.m, /home/runner/work/BioMAC-Sim-Toolbox/BioMAC-Sim-Toolbox/ExampleScripts/+IntroductionExamples/script3D.m, /home/runner/work/BioMAC-Sim-Toolbox/BioMAC-Sim-Toolbox/ExampleScripts/+IntroductionExamples/scriptPlotting.m, and /home/runner/work/BioMAC-Sim-Toolbox/BioMAC-Sim-Toolbox/ExampleScripts/+Treadmill/script2D.m.
◆ TrackingData()
Constructor setting default TrackingData object.
- Parameters
-
varargin | (optional) Parameter settings: Parameter name as string followed by the parameter value. Multiple parameters can be set. E.g.: TrackingData('sourceInfo', sourceInfo, 'triallist', triallist); |
- Return values
-
◆ correctGyroSum()
function correctGyroSum |
( |
in |
obj, |
|
|
in |
plotIt |
|
) |
| |
|
private |
Function to set the sum of a periodic gyro signal to 0.
- Parameters
-
obj | TrackingData class object which should be corrected |
plotIt | (optional) Boolean: If true, plot the signal before and after correction for comparison. (default: 0) |
◆ correctVariance()
function correctVariance |
( |
in |
obj, |
|
|
in |
plotIt |
|
) |
| |
|
private |
Function to prevent small variances of the variables.
- Parameters
-
obj | TrackingData class object which should be corrected |
plotIt | (optional) Boolean: If true, plot the signal before and after correction of the variance for comparison. (default: 0) |
◆ createDefaultProcessingTable()
static function createDefaultProcessingTable |
( |
| ) |
|
|
staticprivate |
Function to load the data into an object which was previously saved using saveStruct()
Fields:
- Return values
-
◆ extractData()
function extractData |
( |
in |
obj, |
|
|
in |
type, |
|
|
in |
names, |
|
|
in |
directions, |
|
|
in |
positions, |
|
|
in |
units |
|
) |
| |
|
private |
Function to extract only specific data from the TrackingData object.
All inputs except type can also be empty. If it is empty it is ignored.
Example:
trackingDataExtracted = trackingData.extractData('gyro', '', [1, 0, 0]);
- Parameters
-
obj | TrackingData class object which should be used to extract data. This object will not be manipulated. |
type | Char: Type which will be extracted |
names | (optional) Char or cell of chars: Names which will be extracted |
directions | (optional) Vector or cell of vectors: Directions which will be extracted (Used for IMUs) |
positions | (optional) Vector or cell of vectors: Positions which will be extracted (Used for IMUs) |
units | (optional) Char or cell of chars: Units which will be extracted |
- Return values
-
◆ getVariableIdx()
function getVariableIdx |
( |
in |
obj, |
|
|
in |
subtable |
|
) |
| |
Function to get indices of a specific row.
- Parameters
-
obj | TrackingData class object |
subtable | Table: Subtable with one row containing all columns which should be identical |
- Return values
-
idxRow | Double array: Indices of the rows which are identically to the entries in the subtable |
◆ inclineGRF()
function inclineGRF |
( |
in |
obj, |
|
|
in |
incline |
|
) |
| |
|
private |
Function to change a treadmill's incline.
- Parameters
-
obj | TrackingData class object which should be corrected |
incline | Angle of treadmill incline, rad |
◆ loadStruct()
static function loadStruct |
( |
in |
filename | ) |
|
|
static |
◆ preprocessData()
function preprocessData |
( |
in |
obj, |
|
|
in |
nNodes |
|
) |
| |
|
private |
Function to preprocess tracking data.
This function calls:
- Parameters
-
obj | TrackingData class object which should be processed |
nNodes | Double: Number of nodes |
◆ resampleData()
function resampleData |
( |
in |
obj, |
|
|
in |
nNodes, |
|
|
in |
plotIt, |
|
|
in |
plotSamples, |
|
|
in |
plotVariance |
|
) |
| |
|
private |
Function to resample tracking data.
- This function uses interp1().
It resamples only data of the type 'angle', 'translation', 'moment','GRF', 'CoP', 'GRM', 'acc', 'gyro', 'marker', or 'time'. Thus 'speed' and 'duration' are not resampled.
- Todo:
- Rethink the adaption of the events. Currently we keep only the start at 1 and the end at nSamples+1. However, the events are not exactly at the index 1 or nSamples+1
- Parameters
-
obj | TrackingData class object which should be resampled |
nNodes | Double: Number of nodes |
plotIt | (optional) Boolean: If true, plot the signal before and after resampling for comparison. (default: 0) |
plotSamples | (optional) Boolean: If true, plot the single sample points explecitly. (default: 0) |
plotVariance | (optional) Boolean: If true, plot the variance. (default: 0) |
◆ save()
Function to save the TrackingData object.
The TrackingData object will be saved in a variable called 'data' and saved using the given filename.
- Parameters
-
◆ saveStruct()
function saveStruct |
( |
in |
obj, |
|
|
in |
filename |
|
) |
| |
Function to save the TrackingData object as struct.
The TrackingData object will be saved in a struct called 'dataStruct' and saved using the given filename.
- Parameters
-
◆ setProperty()
function setProperty |
( |
in |
obj, |
|
|
in |
name, |
|
|
in |
value |
|
) |
| |
Function to set a property.
Warning: It is not checked weather the type of the value is correct!
- Parameters
-
obj | TrackingData class object |
name | String: Name of the property |
value | Not defined: Value of the property |
◆ struct2object()
static function struct2object |
( |
in |
dataStruct | ) |
|
|
static |
Function to get a TrackingData object from a struct.
- Parameters
-
- Return values
-
◆ takeMeanAndVar()
function takeMeanAndVar |
( |
in |
plotIt, |
|
|
in |
varargin |
|
) |
| |
|
staticprivate |
Function to compute the mean and variance of several data sets.
It will set the properties using the following rules:
We compute the mean and the variance using the data saved in the column 'mean' without considering the column 'var'.
Warning:
Examplary function call using filenames:
datafiles = {'file1.mat', 'file2.mat', 'file3.mat'};
The class to define tracking data.
Definition: TrackingData.m:38
function takeMeanAndVar(in plotIt, in varargin)
Function to compute the mean and variance of several data sets.
Examplary function call using TrackingData objects:
- Todo:
- We have to ensure if we can simply take the mean of the translations. If we do this, we are assuming that the cycle is always at the same position in the global reference frame.
- Parameters
-
plotIt | Boolean: If true, plot all signals and the mean and variance |
varargin | String: Filenames of files containing TrackingData struct
... or ...
TrackingData: TrackingData objects
Requirements:
- varargin must contain at least two entries to compute the mean and the variance out of them.
- Same studyName, subjectName, movementType, isSymmetric
- Start and end with the same movmentEvents if there are events listed
- Contain the same variables (Consitent type, name and unit)
|
- Return values
-
meanTrackingData | TrackingData: Containing the mean and variance of the input.
|
◆ trimData()
function trimData |
( |
in |
obj, |
|
|
in |
iStart, |
|
|
in |
iEnd, |
|
|
in |
plotIt, |
|
|
in |
plotSamples, |
|
|
in |
plotVariance |
|
) |
| |
|
private |
Function to trim tracking data.
- It trims the data of the type 'angle', 'translation', 'moment','GRF', 'CoP', 'GRM', 'acc', 'gyro', 'marker', or 'time'.
- Thus 'speed' and 'duration' are only single samples and are currently not trimmed, but removed since they are not valid anymore. But there might be another better approach.
- Only the events between iStart and iEnd+1 are kept. If there no events for 1 and N+1, "Start" and "End" are added since they are required in other functions.
- Parameters
-
obj | TrackingData class object which should be trimmed |
iStart | Int: Index of start sample (inclusive) |
iEnd | Int: Index of end sample (inclusive) |
plotIt | (optional) Boolean: If true, plot the signal before and after resampling for comparison. (default: 0) |
plotSamples | (optional) Boolean: If true, plot the single sample points explecitly. (default: 0) |
plotVariance | (optional) Boolean: If true, plot the variance. (default: 0) |
◆ useHalfGaitCycleData()
Function to cut the tracking data such that only half is used.
Function to use only half the tracking data if the motion is symmetric but the data is of the complete gait cycle.
It is just taking the half without taking the movement events into account for cutting.
It cuts data of the type 'angle', 'translation', 'moment','GRF', 'CoP', 'GRM', 'acc', 'gyro', 'marker', 'time'. It also halves the 'duration'. The 'speed' is not changed.
- Parameters
-
◆ writeMotionToOsim()
function writeMotionToOsim |
( |
in |
obj, |
|
|
in |
model, |
|
|
in |
filename |
|
) |
| |
|
private |
Function to write motion from tracking data object to OpenSim files.
Saves the motion to the following files:
- <filename>_kinematics.mot containing the joint angles
- <filename>_kinetics_GRFs.mot containing GRFs
- <filename>_kinetics_moments.sto containing moments
No resampling is applied.
- Parameters
-
obj | TrackingData class object which should saved to OpenSim files. It has to contain the following fields:
Type | Name |
duration | |
angle | all joint angles of the model |
translation | all translations of the model |
GRF | 'GRF_x_r', 'GRF_y_r', 'GRF_z_r', 'GRF_x_l', 'GRF_y_l', 'GRF_z_l' |
CoP | 'CoP_x_r', 'CoP_y_r', 'CoP_z_r', 'CoP_x_l', 'CoP_y_l', 'CoP_z_l' |
GRM | 'GRM_x_r', 'GRM_y_r', 'GRM_z_r', 'GRM_x_l', 'GRM_y_l', 'GRM_z_l' |
moment | all DOFs of the model |
|
model | Model: Model associated with the tracking data. This is required to obtain names of DOFs, bodymass, and gravity |
filename | String: Filename to save the results. See details for the used postfixes |
◆ comment
String: Personal comment.
◆ computerName
String: Name of the computer (Will be automatically set in the constructor)
◆ creationTime
Datetime: Creation date with 'dd-MMM-yyyy HH:mm:ss' (Will be automatically set in the constructor)
◆ filename
String: Filename with path, without extension.
◆ gitHashString
String: Git hash of the current commit (Will be automatically set in the constructor)
◆ gitURL
String: Url of git repository (Will be automatically set in the constructor)
◆ isSymmetric
Boolean: 1 if symmetry assumption can be used, i.e.
only one half of the movement (e.g. a half gait cycle) is contained in the tracking data and we assume that the second have is identically to get a periodic movement. 0 if we have already a periodic movement which can directy be used in the periodicity constraint.
◆ movementDescription
Property movementDescription |
|
private |
String: More detailed description of the movement.
Like that they were walking at prefered speed
◆ movementEvents
Table: Movement events saved with name and index.
This is should contain at least a description of the start and the end of the data.
◆ movementType
String: Movement type which was recorded (e.g. walking)
◆ nSamples
Double: Number of samples (same for each variable)
◆ nTrials
Double: Number of trials.
◆ nVariables
Double: Number of variables.
◆ participantAge
Double: Age of participant in years.
◆ participantGender
Property participantGender |
|
private |
String: Gender of participant ('female' or 'male')
◆ participantHeight
Property participantHeight |
|
private |
Double: Height of participant in m.
◆ participantMass
Double: Mass of participant in kg.
◆ participantName
String: Name of the participant.
◆ performedProcessing
Property performedProcessing |
|
private |
Table: Information about performed processing.
The default table is created in TrackingData.createDefaultProcessingTable where all the fields are explained. If you are writing a new function manipulating the data, please also log this in performedProcessing.
◆ runningStyle
String: Running style of the participant (i.e. 'rearfoot', 'midfoot', 'forefoot')
◆ studyDate
Datetime: dd-MMM-yyyy of the study created using:
◆ studyName
String: Name of the study.
◆ trialList
Cell array of strings: Description of the single data trials (nTrials x 1)
◆ userName
String: User name of the computer (Will be automatically set in the constructor)
◆ VARIABLEIDENTIFIER
Constant Property VARIABLEIDENTIFIER = {'type', 'name', 'unit', 'position', 'direction', 'segment'} |
Cell containing Strings: Column names of TrackingData.variables which are needed to identify an unique variable row.
Position, direction, and segment are only needed for IMU and marker data.
◆ variables
Table: Data with columns type, name, mean, var (=variance), unit, and optionally segment, position, and direction for IMU and marker data.
- Each row must have an unique identifier defined by the columns specified in TrackingData.VARIABLEIDENTIFIER
- The following types are supported in this class: 'angle', 'translation', 'moment', 'GRF', 'CoP', 'GRM', 'acc', 'gyro', 'marker', 'duration', 'speed'
- If only one trial was used, the variance of a variable has to be a zero vector.
- Data can be extracted using for example:
trackingData.variables.mean{strcmp(trackingData.variables.type, 'speed')}
- Examples
- /home/runner/work/BioMAC-Sim-Toolbox/BioMAC-Sim-Toolbox/ExampleScripts/+IntroductionExamples/script3D.m.
The documentation for this class was generated from the following file: