Modeling with Vicon Nexus
Nexus 2 offers the following options for modeling:
- Plug-in Gait (and the Oxford Foot Model). If you are new to modeling with Nexus, this provides a good introduction: the Plug-in Gait model is supplied with Nexus and all the operations necessary to run the model are easily accessible and ready to use. For more information, see Modeling with Plug-in Gait in the Vicon Nexus User Guide.
- MATLAB. If you are familiar with MATLAB, you can use the supplied examples to create your own custom model. See Modeling with MATLAB.
- Python. If you are familiar with Python, you can use the supplied examples to create your own custom models. See Modeling with Python.
- CGM2. You can use the Conventional Gait Model 2 (CGM2) from within Nexus so that you can execute CGM2 models on your data. See Modeling with CGM2.
For research and experimental purposes, a version of Plug-in Gait in open MATLAB script is available. For further details, contact Vicon Support.
About modeling terminology
For a clear understanding of the way modeling is represented in Nexus, bear in mind the following definitions:
- Labeling Any process, operation or algorithm that is used in Vicon Nexus to assign a label to a reconstruction
- Modeling Takes labeled reconstructions and uses these to perform calculations whose results are new variables.
- Models Files or operations that produce new calculations after labeling. Plug-in Gait and the Oxford Foot Model are models, as are MOD files built in BodyBuilder.
- Subject The representation in Nexus of a physical entity (eg a patient)
- Labeling skeleton template (VST): Contains information and definitions related to labeling.
- Labeling skeleton (VSK) A subject that has a labeling skeleton template attached to it and subject-specific properties that are required for modeling (after labeling)
The following examples show the distinction between labeling and modeling:
- Labeling VSTs/VSKs, labeling skeleton calibration (labeling calibration)
- Modeling PlugInGait.MOD, scripts in Bodybuilder, PECS, MATLAB calculations
API functions for digital device data
Two functions, GetDeviceChannelForFrame
and GetDeviceChannelForFrameGlobal
, enable you to access digital device data that corresponds to optical measurements.
These functions are available in the the SDK for Python and MATLAB.
They address the issue that while the existing function GetDeviceChannelAtFrame
provides the analog frame that contains the requested optical measurement (ie, the frame number in Nexus), for digital devices the analog frame may not align with the optical measurements. These functions return the analog samples that correspond to the optical frame requested.
Note that these functions are not available in the Datastream.
import ViconNexus vicon = ViconNexus.ViconNexus() # ... stuff to work out what IDs are available... # demonstrate that the frame counters are different for the system and the force plate (output results are different) # demonstrate that frame length is different (different number of samples, 16 vs 10) vicon.GetDeviceChannelAtFrame(10, 1, 1, 100) # output ([-0.475459, 1.28333, 0.554047, -0.855607, -3.24367, -2.81851, -1.16626, -0.394893, -2.00863, -3.02354, -2.41265, -0.732007, -0.266873, -0.487017, -0.627091, 0.381795], True, 1000.0) vicon.GetDeviceChannelForFrame(10, 1, 1, 100) # output ([-2.00863, -3.02354, -2.41265, -0.732007, -0.266873, -0.487017, -0.627091, 0.381795, 1.51932, 1.49286], True, 1000.0) # demonstrate that the force plate has an initial sample offset # (ForFrame initial sample is AtFrame's 11th sample at frame 1) vicon.GetDeviceChannelAtFrame(10, 1, 1, 1) # output ([0.18679, 0.174022, 0.191151, 0.301362, 0.0804058, -0.479919, -1.002, -1.38398, -1.51135, -1.14212, -0.547826, -0.127377, -0.0933952, -0.106104, -0.190911, -0.428488], True, 1000.0) # compare this to the graphed value, initial sample here is the value at frame 1 vicon.GetDeviceChannelForFrame(10, 1, 1, 1) # output ([-0.547826, -0.127377, -0.0933952, -0.106104, -0.190911, -0.428488, -0.649677, -0.551753, -0.666456, -0.713149], True, 1000.0
Help on GetDeviceChannelAtFrame
:
Help on GetDeviceChannelForFrame
:
Close trials using the SDK
You can use the SDK to close the current trial without saving. This functionality is available for both MATLAB and Python.
The function requires the following call:
vicon.CloseTrial(timeout)
timeout
is in milliseconds and specifies the length of time during which the function tries to run.
Note that the command can only be used from an external application such as MATLAB or Python, and cannot be used in a script that is executed from within Nexus.
The following example uses Python:
import ViconNexus
vicon = ViconNexus.ViconNexus()
subject = vicon.GetSubjectNames()
vicon.CloseTrial(200)
Note that this call function is not listed by using DisplayCommandList
. To display details about the call, use vicon.DisplayCommandHelp('CloseDontSave')
.