Introduction
A .sto (storage) file is OpenSim’s text table of values over time:
joint angles, muscle forces, activations, simulation states, orientations. The
.mot (motion) file is its close relative, created for SIMM (Software for
Interactive Musculoskeletal Modeling) and also read by OpenSim, where it commonly
carries joint angles and ground reaction forces. Both are a free-form header ending in
endheader, a line of column labels and rows of numbers. Marker positions
are normally kept in TRC files instead.
Structure
Coordinates
version=1
nRows=2
nColumns=3
inDegrees=yes
endheader
time hip_flexion knee_angle
0.000000 15.1261 -21.6693
0.008000 13.8255 -21.2797
endheader, tab-separated labels and rows.| Part | Content |
|---|---|
| Header | Lines of keywords, a name and free text |
endheader | A line holding this word closes the header |
| Column labels | One line, one label per column |
| Data | One row of numbers per time step or sample |
The documented difference between the two names is the time column. A
.sto file must have time as its first column, and the steps may be
uneven. A .mot file is documented as having uniformly spaced time, and
in SIMM files the first column may hold something else, or there may be no time
column at all.
Header generations
| Form | Marks |
|---|---|
| SIMM motion header | name, datacolumns, datarows, usually range; keyword and value separated by a space; no version, so it counts as version 0 |
| OpenSim version 1 (from OpenSim 2.3.2) | Name on the first line, then version=1, nRows=, nColumns=, inDegrees= |
| OpenSim version 3 (table writer) | key=value lines including DataType=, version=3 and OpenSimVersion=; no row or column counts |
OpenSim decides how to read a .sto or .mot file from the
version. Version 0 or 1 files go to the older storage reader, which needs the row or
column count in the header. Higher versions go to the newer table reader; if that
fails on a .sto file, OpenSim falls back to the older one.
Version 0 and 1 header
Each header line is trimmed, and blank lines are skipped. The keyword ends at the
first space, tab or =; the value is what follows after any further
spaces, tabs or =. Keywords are case-sensitive.
| Keyword | Value |
|---|---|
name | Name of the data set. A first line that is not a known keyword is also taken as the name. |
nr, nRows, datarows | Number of data rows |
nc, nColumns, datacolumns | Number of columns, including time |
version | Header version; absent means 0 |
inDegrees | yes or y, in any case, means angles are in degrees; anything else means radians |
units | A unit name, as listed for TRC files |
Angles are in degrees. | The whole sentence, honoured while no version has been seen |
Angles are in radians. | Likewise, for radians |
endheader | End of the header |
Other lines, such as Units are S.I. units (second, meters, Newtons, ...),
are ignored by the parser. With no version, OpenSim takes the angles of a
.mot file to be in degrees. Without inDegrees or an angle
sentence, its default is radians, and the documentation likewise says old
.sto files are assumed to be in radians.
SIMM motion keywords
These are the header keywords of SIMM’s own motion file, from section 3.5 of the SIMM 4.0 user guide and the motion reader of its Dynamics Pipeline (MusculoGraphics, 1996–2004). SIMM’s keywords must be in lower case, and case matters throughout the file.
| Keyword | Value and meaning |
|---|---|
name | The rest of the line: the name of the motion |
datacolumns | Number of columns of data |
datarows | Number of rows of data. SIMM warns if the file holds fewer, but still loads it. |
range | Two numbers: first and last value of time, or of whatever the motion runs over, such as 0.0 to 100.0 per cent of a gait cycle |
keys | One or two keys, on the same line, that animate the model through the motion, for example g_key |
wrap | No value: the motion wraps round, so that a walk can continue |
cursor | An RGB colour: a vertical bar of this colour moves along plots of the motion as the model is animated |
event | A time within the range, then the name of an event, such as event 40.0 heelstrike. It is marked in plots. The pipeline reader accepts any number of these lines. |
event_color | An RGB colour for the event marks, for example 1.0 0.0 1.0, magenta, which is also the pipeline reader’s default. If any part is above 1.0 that reader takes the colour to be in the old 0 to 255 form and divides by 255; negative parts become 0. |
enforce_loops | One word: whether SIMM’s solver enforces the model’s loops when the motion is played, by adjusting the generalized coordinates. The guide shows no, which its Motion Module and Dynamics Pipeline write so that the solver does not run needlessly. The pipeline reader reads the word and ignores it. |
enforce_constraints | The same for constraints |
calc_derivatives | The time in seconds between rows. SIMM then takes the rows to be equally spaced, fits natural cubic splines to every column and takes from them the velocities not given in the file. |
units | The rest of the line; the pipeline reader reads and ignores it |
accept_realtime_motion, sliding_time_scale | No value; the pipeline reader accepts both and does nothing with them |
endheader | End of the header |
The pipeline reader skips the line when a header word starts with #, and reports any word it
does not know. It first runs the file through a C preprocessor, and the guide’s example and a
MusculoGraphics sample motion of 1992 carry C-style /* ... */ comments at the top, after
keyword values and, in the sample, between endheader and the column labels. SIMM does not
keep comments when it saves a file.
That sample also has otherdata, with the number of columns that are not generalized
coordinates, used for plotting. The guide does not list it as a header keyword: SIMM works out by itself
which columns are other data. The pipeline reader accepts otherdata only in its
.ktx kinetics files.
OpenSim keeps SIMM keywords as name and value pairs and writes them back; of them it uses only
range. Its reserved list holds range and Range, wrap,
Wrap and WRAP, calc_derivatives, event,
enforce_loops, enforce_constraints and #.
SIMM column names
SIMM matches column labels, which may not contain spaces, with the parts of a model.
| Label | Content |
|---|---|
| Name of a generalized coordinate | Its value, such as a joint angle |
The same with _vel | Its velocity |
| Name of a muscle | Activation, from 0.0 to 1.0 |
Name of a muscle with any suffix, such as semimem_force | Another muscle quantity, only for plotting |
Body segment, motion object and component, such as ground_force_vx | Animation of an object attached to the segment. Position _px _py _pz, scale _sx _sy _sz, vector _vx _vy _vz, colour _cr _cg _cb. The built-in objects are force, ball, contact, joint_force, joint_torque and spring_force. |
A column label with _std | One standard deviation, not negative, for the column of that name; not for muscle activations or motion objects |
| Any other | Other data, for plotting |
Version 0 and 1 data
After endheader, blank lines and leading white space are skipped. The
next line is split on spaces, tabs and line ends into column labels. The older reader
then takes exactly the stated number of rows, reading numbers separated by any white
space. If a label time or range is present, the first
number of each row is the time and the rest are the data. If neither is present,
the rows are numbered from 0.
For a SIMM file with no time column, OpenSim then repairs the table. A
time column elsewhere is moved to the front. If there is none, one is
built from range: the step is (end − start) / (rows − 1)
and row i, counted from 0, gets i × step. With no
range the file is refused.
Version 3 header and data
DataType=Quaternion
version=3
OpenSimVersion=4.5
endheader
time pelvis_imu torso_imu
0 1,0,0,0 0.7071,0,0.7071,0
- The header ends at a line that is
endheader, optionally surrounded by spaces or tabs. A line that looks like data before it is an error. key=valuelines are metadata; the key is trimmed of spaces and the value of white space.versionandOpenSimVersionare not kept; all unknown keys are.- Other header lines are kept as free text.
- The next non-blank line holds the labels, separated by tabs. The first must be
time. - Each row has one field per label, separated by tabs. The components of a vector field are separated by commas.
- The data ends at an empty line or the end of the file.
- A field that is not a number reads as not-a-number. Numbers always use a point as the decimal mark.
- OpenSim writes numbers with the precision of a double plus one digit.
DataType values
DataType | Numbers per field | Content |
|---|---|---|
double | 1 | Plain number; also assumed when there is no DataType |
Vec2 to Vec12 | 2 to 12 | Vector of that length |
UnitVec3 | 3 | Direction vector |
Quaternion | 4 | Rotation, scalar part first (w, x, y, z); normalised on reading |
SpatialVec | 6 | Two three-component vectors, one after the other |
Any other type name is refused.
Ground reaction labels
OpenSim’s documentation gives this column set for force plate data in a motion file. Names must be unique, and each group of three force, point or torque columns should share a prefix.
| Columns | Labels | Content |
|---|---|---|
| 1 | time | Time |
| 2–4 | ground_force_vx, _vy, _vz | Right foot ground reaction force |
| 5–7 | ground_force_px, _py, _pz | Right foot centre of pressure |
| 8–10 | l_ground_force_vx, _vy, _vz | Left foot force |
| 11–13 | l_ground_force_px, _py, _pz | Left foot centre of pressure |
| 14–16 | ground_torque_x, _y, _z | Right foot ground reaction moment |
| 17–19 | l_ground_torque_x, _y, _z | Left foot moment |
The labels are a convention that the loading setup refers to; other prefixes occur,
for example 1_ground_force_vx in the OpenSim sample. The documentation
warns that not-a-number values must be removed from force files.
What OpenSim’s storage writer puts out
The older writer emits the name line, version=1, nRows=,
nColumns=, inDegrees=yes or no, then any
description text, endheader and tab-separated labels (or
time, state_0, state_1 and so on). When asked
for a SIMM header it adds, after those lines:
# SIMM Motion File Header:
name walking
datacolumns 3
datarows 2
otherdata 1
range 0.000000 0.008000
range.OpenSim’s marker reader can also take positions from a storage file, from
consecutive columns named name.x, name.y,
name.z (case does not matter); it then assumes metres and 250 frames a
second.
Divergence from the documentation
- The documentation says the first line of the SIMM header must start with
name. Its own example, and OpenSim’s sample ground reaction file, start with a bare file name, and the parser accepts that. - The documentation requires
rangein the SIMM header. The parser needs it only to build a missing time column. - When building that column from
range, OpenSim starts at 0 rather than at the first value of the range. - The SIMM sample places a comment block between
endheaderand the labels. OpenSim’s older reader skips only blank space there, so it would read the start of the comment as the labels.
In the explorer
Every header line, column label and row is in the tree, for version 0 and 1 files and
for typed tables, with SIMM’s keywords and events named and C comments set aside.
Each column opens as a plot with its values, 500,000 rows to a plot, and each row as a
table of all its values; a time column is built from range where a SIMM
file has none. Force vectors drawn from their points of application, markers given as
.x, .y and .z columns and quaternion columns,
as sets of axes, are shown in three dimensions and played. Row and column counts,
components and numbers are checked. A .mot file without this header is
still opened as Motorola S-record. Files up to
256 MB are read.
Not described
This reference is built from OpenSim’s documentation, readers and writers, the SIMM 4.0 user guide, the motion reader of SIMM’s Dynamics Pipeline and a sample SIMM motion.
Known, not yet covered
- Viewer: joint angles and other model coordinates are plotted, not posed on a model, since the file holds no model and an OpenSim or SIMM model file is not read beside it. C preprocessor directives are not run. Files over 256 MB are not read.
Unknown
- Reference: what the
accept_realtime_motionandsliding_time_scalekeywords do. - Reference: which words other than
noSIMM accepts afterenforce_loopsandenforce_constraints. - Reference: whether versions of SIMM after 4.0 added further header keywords.
Also used for
- Motorola S-record – Firmware as lines of S-records, each with a type, address and checksum.
Links
Software
- OpenSim – musculoskeletal modelling program that reads and writes storage and motion files (Windows, macOS, Linux)
Developers
- Storage.cpp – OpenSim’s older reader and writer, with the SIMM handling (C++)
- DelimFileAdapter.h – the version 3 table reader and writer (C++)
- STOFileAdapter.cpp – selection by data type (C++)
Reference
- Motion (.mot) files – OpenSim documentation
- Storage (.sto) files – OpenSim documentation
- SIMM 4.0 for Windows, user guide – MusculoGraphics; section 3.5 defines motion files
- readtools.c – the motion and kinetics file reader of SIMM’s Dynamics Pipeline, MusculoGraphics (C)
- Single-leg walking motion – commented SIMM sample file, MusculoGraphics, 1992
- subject01_walk1_grf.mot – sample ground reaction file from the OpenSim models