Writes 3D marker trajectories (and optional analog channels) from a
PhysioExperiment to a binary C3D file via the c3dr package. This
is the inverse of readC3D(): a readC3D() -> writeC3D() -> readC3D()
round-trip reproduces the marker coordinates (within 32-bit float
precision) and preserves the point/analog sampling-rate ratio.
Arguments
- x
A
PhysioExperimentwith"position_x","position_y", and"position_z"assays (as produced byreadC3D()orreadTRC()), or aMultiRatePhysioExperimentwhose marker stream carries those assays.- path
Character string giving the output
.c3dpath.- include_analog
Logical; if
TRUE(default) and the object carries analog data (inmetadata(x)$analog_data, or as an"analog"stream of aMultiRatePhysioExperiment), that data is written as C3D analog channels. IfFALSE, a marker-only C3D file is written.
Details
The point (marker) rate is taken from samplingRate(x). When analog data
is written, the analog rate and the integer point/analog ratio
(ANALOG:RATE / POINT:RATE, i.e. analog subframes per point frame) are
derived from the analog block so the ratio round-trips exactly. Force
platform metadata is not written (the marker and analog signals are
preserved; force-plate corner/calibration parameters are dropped).
References
C3D.org. "The C3D File Format." https://www.c3d.org/.
Examples
if (requireNamespace("c3dr", quietly = TRUE)) {
pe <- readC3D(c3dr::c3d_example(), include_analog = TRUE)
out <- tempfile(fileext = ".c3d")
writeC3D(pe, out)
pe2 <- readC3D(out)
}