Segment#
- class pyCGM2.Model.model.Segment(label: str, index: int, sideEnum: SegmentSide, calibration_markers: List[str] | None = [], tracking_markers: List[str] | None = [])#
Represents a rigid body segment in a biomechanical model.
A Segment is a fundamental component in biomechanical modeling, representing a part of the body like a limb or a section of the spine. It holds information about the segment’s markers, technical and anatomical referentials, body segment parameters (BSP), and other relevant biomechanical data.
- Parameters:
label (str) – Label of the segment.
index (int) – Unique index of the segment.
sideEnum (enums.SegmentSide) – Side of the body this segment belongs to.
calibration_markers (List[str], optional) – Labels of calibration markers associated with this segment. Defaults to [].
tracking_markers (List[str], optional) – Labels of tracking markers associated with this segment. Defaults to [].
- __init__(label: str, index: int, sideEnum: SegmentSide, calibration_markers: List[str] | None = [], tracking_markers: List[str] | None = [])#
Initializes a new instance of the Segment class
Methods
__init__
(label, index, sideEnum[, ...])Initializes a new instance of the Segment class
addCalibrationMarkerLabel
(labels)Add one or multiple calibration markers to the segment.
addExternalDeviceWrench
(btkWrench)Add an external device wrench to the segment.
addMarkerLabel
(label)Add a marker label to the segment.
addTechnicalReferential
(label)Add a technical referential to the segment.
addTrackingMarkerLabel
(labels)Add one or multiple tracking markers to the segment.
Downsample external device wrenches associated with the segment.
getAngularAcceleration
(sampleFrequency)Calculate the angular acceleration of the segment.
getAngularVelocity
(sampleFrequency[, method])Calculate the angular velocity of the segment.
getComAcceleration
(pointFrequency[, method])Calculate the global linear acceleration of the center of mass of the segment.
getComTrajectory
([exportBtkPoint, btkAcq])Get the trajectory of the center of mass of the segment.
getComVelocity
(pointFrequency[, method])Calculate the linear velocity of the center of mass of the segment.
Returns the list of frame numbers where the segment exists.
getReferential
(label)Get a technical referential from the segment.
Check if any external device wrenches are connected to the segment.
removeTrackingMarker
(labels)Remove one or multiple tracking markers from the segment.
Reset the marker labels for the segment.
setComPosition
(array3)Set the local position of the center of mass of the segment.
setExistFrames
(lstdata)Sets the frame numbers where the segment exists in the biomechanical model.
setInertiaTensor
(array33)Set the inertia tensor of the segment.
setLength
(value)Set the length of the segment.
setMass
(value)Set the mass of the segment.
setRog
(value)Set the radius of gyration of the segment.
Zeroing (reset) the external device wrenches associated with the segment.
Zeroing (reset) the proximal wrench associated with the segment.
- addCalibrationMarkerLabel(labels: str | List[str])#
Add one or multiple calibration markers to the segment.
- Parameters:
labels (Union[str, List[str]]) – Label or list of labels of the calibration markers to be added.
- addExternalDeviceWrench(btkWrench: btkWrench)#
Add an external device wrench to the segment.
- Parameters:
btkWrench (btk.btkWrench) – A BTK wrench instance to be added.
- addMarkerLabel(label: str)#
Add a marker label to the segment.
- Parameters:
label (str) – Label of the marker to be added.
- addTechnicalReferential(label: str)#
Add a technical referential to the segment.
- Parameters:
label (str) – The label of the technical referential to be added.
- addTrackingMarkerLabel(labels: str | List[str])#
Add one or multiple tracking markers to the segment.
- Parameters:
labels (Union[str, List[str]]) – Label or list of labels of the tracking markers to be added.
- downSampleExternalDeviceWrenchs(appf: int)#
Downsample external device wrenches associated with the segment.
- Parameters:
appf (int) – Analog points per frame rate for downsampling.
- getAngularAcceleration(sampleFrequency: float) ndarray #
Calculate the angular acceleration of the segment.
- Parameters:
sampleFrequency (float) – The sample frequency of the motion data.
- Returns:
np.ndarray – An array representing the angular acceleration of the segment.
- getAngularVelocity(sampleFrequency: float, method: str = 'conventional') ndarray #
Calculate the angular velocity of the segment.
- Parameters:
sampleFrequency (float) – The sample frequency of the motion data.
method (str, optional) – The method used for computing the angular velocity (‘conventional’ or ‘pig’). Defaults to ‘conventional’.
- Returns:
np.ndarray – An array representing the angular velocity of the segment.
Notes:
The conventional method computes angular velocity through the matrix product $dot{R}R^t$
The pig method duplicates a bodybuilder code of the plug-in gait in which the velocity is computed from differentation between the next and previous pose
- getComAcceleration(pointFrequency: float, method: str = 'spline', **options) ndarray #
Calculate the global linear acceleration of the center of mass of the segment.
- Parameters:
pointFrequency (float) – The point frequency for the calculation.
method (str, optional) – The method for calculation (‘spline’ or ‘spline fitting’). Defaults to ‘spline’.
**options – Additional options for filtering.
- Returns:
np.ndarray – An array representing the center of mass linear acceleration.
- getComTrajectory(exportBtkPoint: bool = False, btkAcq: btkAcquisition | None = None) ndarray #
Get the trajectory of the center of mass of the segment.
- Parameters:
exportBtkPoint (bool, optional) – If True, export as btk.point. Defaults to False.
btkAcq (Optional[btk.btkAcquisition], optional) – A btk acquisition instance if export is needed. Defaults to None.
- Returns:
np.ndarray – An array representing the center of mass trajectory.
- getComVelocity(pointFrequency: float, method: str = 'spline') ndarray #
Calculate the linear velocity of the center of mass of the segment.
- Parameters:
pointFrequency (float) – The point frequency for the calculation.
method (str, optional) – The method for calculation (‘spline’ or ‘spline fitting’). Defaults to ‘spline’.
- Returns:
np.ndarray – An array representing the center of mass linear velocity.
- getExistFrames() List[int] #
Returns the list of frame numbers where the segment exists.
- Returns:
List[int] – Frame numbers where the segment is present.
- getReferential(label: str) TechnicalReferential #
Get a technical referential from the segment.
- Parameters:
label (str) – The label of the technical referential to retrieve.
- Returns:
TechnicalReferential – The requested technical referential.
- isExternalDeviceWrenchsConnected() bool #
Check if any external device wrenches are connected to the segment.
- Returns:
bool – True if external device wrenches are connected, False otherwise.
- removeTrackingMarker(labels: str | List[str])#
Remove one or multiple tracking markers from the segment.
- Parameters:
labels (Union[str, List[str]]) – Label or list of labels of the tracking markers to be removed.
- resetMarkerLabels()#
Reset the marker labels for the segment.
- setComPosition(array3: ndarray)#
Set the local position of the center of mass of the segment.
- Parameters:
array3 (np.ndarray) – A 3-element array representing the center of mass position.
- setExistFrames(lstdata: List[int])#
Sets the frame numbers where the segment exists in the biomechanical model.
- Parameters:
lstdata (List[int]) – List of frame numbers where the segment is present.
- setInertiaTensor(array33: ndarray)#
Set the inertia tensor of the segment.
- Parameters:
array33 (np.ndarray) – A 3x3 matrix representing the inertia tensor.
- setLength(value: float)#
Set the length of the segment.
- Parameters:
value (float) – The length value to be set for the segment.
- setMass(value: float)#
Set the mass of the segment.
- Parameters:
value (float) – The length value to be set for the segment.
- setRog(value: float)#
Set the radius of gyration of the segment.
- Parameters:
value (float) – The radius of gyration value to be set for the segment.
- zeroingExternalDevice()#
Zeroing (reset) the external device wrenches associated with the segment.
- zeroingProximalWrench()#
Zeroing (reset) the proximal wrench associated with the segment.