Model
anthropometricMeasurement
bodySegmentParameters
- class pyCGM2.Model.bodySegmentParameters.Bsp(iModel)
Body Segment Parameter of the lower limb according Dempster 1995
Reference
Dempster. (1955). Body Segment Parameter Data for 2-D Studies
- compute()
Compute body segment parameters of a Model
- classmethod setParameters(bspSegmentLabel, segmentLength, bodymass)
Compute body parameter of a selected lower limb segment
- Parameters
bspSegmentLabel (str) – segment label defined in the class object TABLE
segmentLength (double) – length of the segment
bodymass (double) – mass of the subject
- pyCGM2.Model.bodySegmentParameters.updateFromcustomMp(model, custom_mp)
update the anthropometric parameters fo your model
- Parameters
model (pyCGM2.Model) – a model instance.
custom_mp (dict) – mp from the file mp.settings
frame
this module gathers two classes (Node and Frame), important for the construction of a model
A Frame is a representation of a coordinate system at a specific time. Its main attributes are the rotation matrix and the translation vectors.
A Frame can collect Node instances. A Node represents a 3d point expressed in a local coordinate system
- class pyCGM2.Model.frame.Frame
A Frame represents a coordinate system
- addNode(nodeLabel, position, positionType='Global', desc='')
Append a Node to a Frame
- Parameters
nodeLabel (str) – node label
position (array(3,)) – a translation vector
positionType (str,Optional) – two choice Global or Local
desc (str,Optional) – description
- copyNode(nodeLabel, nodeToCopy)
Copy a node and add it or update a existant node
- Parameters
nodeLabel (str) – the node label
nodeToCopy (str) – the label of the node to copy
- eraseNodes()
Erase all nodes
- getAngleAxis()
Get the angle axis
- getGlobalPosition(nodeLabel)
Return the global position
- Parameters
nodeLabel (str) – the node label
- getNodeIndex(nodeLabel)
Get the node index
- Parameters
nodeLabel (str) – the node label
- getNodeLabels(display=True)
Display all node labels
- getNode_byIndex(index)
Get a node from its index
- Parameters
index (int) – index of the node within the list
- getNode_byLabel(label)
Get a node from its label
- Args:
label(str): the node label
- getNodes()
Return all node instances
- getRotation()
Get rotation matrix
- Returns
array ((3,3) – a rotation matrix
- getTranslation()
Get translation vector
- isNodeExist(nodeLabel)
Check if a node exists from its label
- Parameters
nodeLabel (str) – the node label
- setRotation(R)
Set the rotation matrix
- Parameters
R (array(3,3) – a rotation matrix
- setTranslation(t)
Set the translation vector
- Parameters
t (array(3,)) – a translation vector
- update(R, t)
Update both the rotation matrix and the translation vector
- Parameters
R (array(3,3) – a rotation matrix
t (array(3,)) – a translation vector
- updateAxisFromRotation(R)
Update the rotation matrix
- Parameters
R (array(3,3) – a rotation matrix
- updateNode(nodeLabel, localArray, globalArray, desc='')
Update a node
- Parameters
nodeLabel (str) – the node label
localArray (array(3)) – local position
globalArray (array(3)) – global position
desc (str,Optional) – description
- class pyCGM2.Model.frame.Node(label, desc='')
A node is a local position of a 3D point in a coordinate system
Note
Automatically, the suffix “_node” ends the node label
- Parameters
label (str) – desired label of the node
desc (str,Optional) – description
- computeGlobal(rot, t)
Compute global position from local
- Parameters
rot (array((3,3)) – a rotation matrix
t (array((1,3)) – a translation vector
- computeLocal(rot, t)
Compute local position from global position
- Parameters
rot (array(3,3)) – a rotation matrix
t (array((1,3))) – a translation vector
- getDescription()
Get the node description
- getGlobal()
Get the global coordinates of the node
- getLabel()
Get the node label
- getLocal()
Get the local coordinates of the node
- setDescription(description)
Set description of the node
- Parameters
description (str) – description
- pyCGM2.Model.frame.angleAxisFromQuaternion(Quaternion)
Calculates the AngleAxis representation from a quaternion
- Parameters
Quaternion (array(4)) – a quaternion
- pyCGM2.Model.frame.getQuaternionFromMatrix(RotMat)
Calculates the quaternion representation from a rotation matrix.
Algorithm in Ken Shoemake’s article in 1987 SIGGRAPH course notes article “Quaternion Calculus and Fast Animation”.
- Parameters
RotMat (array(3,3)) – Rotation matrix
- pyCGM2.Model.frame.setFrameData(a1, a2, sequence)
Set axes and rotation matrix of a coordinate system from 2 vectors and a sequence
The sequence can be all combinaison of XYZ. If the second letter is prefixed by i, the opposite vector to the cross product a1, a2 is considered
- Parameters
a1 (array(1,3)) – first vector
a2 (array(1,3)) – second vector
sequence (str) – construction sequence (XYZ, XYiZ,…)
model
modelDecorator
modelFilters
modelQualityFilter
motion
This module contains pose algorithms
- pyCGM2.Model.motion.segmentalLeastSquare(A, B)
Compute the transformation between two coordinate systems using SVD.
- Parameters
A (numpy.array(n,3)) –
B (numpy.array(n,3)) –
CGM2
cgm
cgm2
decorators
Opensim
opensimFilters
osimProcessing
This module contains convenient functions and classes for working with opensim.
- pyCGM2.Model.Opensim.osimProcessing.globalTransformationLabToOsim(acq, R_LAB_OSIM)
transform all markers into the the opensim global coordinate system
- Parameters
acq (Btk.Acquisition) – an acquisition
R_LAB_OSIM (array(3,3)) – rotation matrix for passing from the lab to opensim coordinate sytem
- pyCGM2.Model.Opensim.osimProcessing.mot2pointValues(motFilename, labels, orientation=[1, 1, 1])
convert an element of an opensim mot file into a btk-point values (ie array(n,3) with n: the number of frames)
- Parameters
motFilename (str) – full filename of the mot file
label (str) – label to convert
orientation (list) – scales to apply before returning final values. Default is [1,1,1]
- pyCGM2.Model.Opensim.osimProcessing.setGlobalTransormation_lab_osim(axis, forwardProgression)
return the rotation matrix expressing the opensim global coordinate system to the laboratory coordinate system
- Parameters
axis (str) – defined progression axis (ie X or Y ).
forwardProgression (bool) – forward progression flag.
True ((if) –
of (the movement progression is along the positive value) –
) (your progression axis) –
- pyCGM2.Model.Opensim.osimProcessing.smartTrcExport(acq, filenameNoExt)
save as a trc file
- Parameters
acq (Btk.Acquisition) – an acquisition
filenameNoExt (str) – filename without extension
- pyCGM2.Model.Opensim.osimProcessing.sto2pointValues(storageObject, label, R_LAB_OSIM)
transform an element of a storage instance into the Laboratory coordinate system.
- Parameters
storageObject (opensim.Storage) – an opensim storage instance.
label (str) – label to extract from the storage instance
R_LAB_OSIM (array(3,3)) – rotation matrix for passing from the lab to opensim coordinate sytem