Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Documentation for the C3DFIleAdapter is located here.  

 

...

There is a working example Matlab script in your resources directory /Code/Matlab/c3dExport.m

We have included a Matlab side class that can be used to perform some common operations, such as rotating data, converting data into Matlab data types, and writing marker and force data to OpenSim file format. The Matlab file can be found in your resources directory /Code/Matlab/Utilities/osimC3D.m

Code Block
%% Read C3D into memory
% Import OpenSim Library
import org.opensim.modeling.*

% Use the osimC3D utlity class
c3d = osimC3D('Walking_trial.c3d',1);

% Rotate the Marker and force data by 90 degrees
c3d.rotateData('x',-90);

% Get the Marker and Force data as Matlab Structures
[markers forces] = c3d.getAsStructs();

% Get the Marker and Force data as OpenSim TimeSeriesTables()
markerTable = c3d.getTable_markers();
forcesTable = c3d.getTable_forces();

% Get Number of Markers and Forces
nMarkers = c3d.getNumTrajectories();
nForces = c3d.getNumForces();

% Get Data rate for Markers and Forces
markerRate = c3d.getRate_marker();
forceRate = c3d.getRate_force();

% Get the Start and End time of the data
startTime = c3d.getStartTime();
endTime = c3d.getEndTime();

% Write the Marker and Force data. Writing function can take (i) no input
% (writes file to path of the input c3d), (ii) output file name (writes to 
% the same folder as the c3d, but with the specified filename), or (iii) a 
% full path to file (writes file to the full path specified). 
c3d.writeTRC('Output.trc') 
c3d.writeMOT('/Users/person/experiment/data/Output.mot') 
 
 
 
 

 

To use the OpenSim classes directly, follow the code below. This code will give you OpenSim Times Series Tables for both markers and forces. 

Code Block
%% Read C3D into memory
% Import OpenSim Library
import org.opensim.modeling.*
 
% Instantiate a C3DFileAdapter()
c3dAdapter = C3DFileAdapter();
% Read c3d data
data = c3dAdapter.read('walking2.c3d');
% Get a TimesSeriesTable with all the marker Data
markers = data.get('markers');
% Get a TimeSeriesTable with all the Force Data
forces = data.get('forces');

Reading Data through Python and C++

Code Block
 

For C++

Code Block
 

Marker Data 

 

 

...