Modules

Anomaly

Anomaly Filter

This module contains pyCGM2 anomaly filters to deal with either an anomaly detector procedure or an anomaly correction procedure

check out the script : Teststest_anomalies.py for examples

class pyCGM2.Anomaly.anomalyFilters.AnomalyCorrectionFilter(acq, filename, procedure)

anomaly corrector filter

Parameters
class pyCGM2.Anomaly.anomalyFilters.AnomalyDetectionFilter(acq, filename, procedure, **kwargs)

Anomaly detector filter

Parameters
Kwargs:

frameRange (list): frame boundaries

AnomalyDetectionProcedure

This module gathers anomaly detectors on markers, events, force plate signals and anthropometric data

check out the script : Teststest_anomalies.py for example

class pyCGM2.Anomaly.anomalyDetectionProcedures.AnomalyDetectionProcedure

abstract marker detector procedure

class pyCGM2.Anomaly.anomalyDetectionProcedures.AnthropoDataAnomalyProcedure(mp)

atnthropometric data anomaly detector

run(acq, filename, options)

run the procedure

Parameters
  • acq (btk.Acquisition) – a btk acquisition instantce

  • filename (str) – filename

  • options (dict) – passed options ( Not used so far)

class pyCGM2.Anomaly.anomalyDetectionProcedures.ForcePlateAnomalyProcedure

force plate anomaly detector

run(acq, filename, options)

run the procedure

Parameters
  • acq (btk.Acquisition) – a btk acquisition instantce

  • filename (str) – filename

  • options (dict) – passed options

Note

frameRange ([int, int]) is one key of the options argument

class pyCGM2.Anomaly.anomalyDetectionProcedures.GaitEventAnomalyProcedure

gait event anomaly detector

run(acq, filename, options)

run the procedure

Parameters
  • acq (btk.Acquisition) – a btk acquisition instantce

  • filename (str) – filename

  • options (dict) – passed options ( Not used so far)

class pyCGM2.Anomaly.anomalyDetectionProcedures.MarkerAnomalyDetectionRollingProcedure(markers, plot=False, **kwargs)

marker anomaly detection from rolling statistics

Parameters
  • markers (list) – marker labels;

  • plot (bool) – enable plot

Kwargs:

aprioriError (double): a priori error on the marker trajectory window (int): size of the rolling windows treshold (int) : detector threshold assoiated to the standard deviation method (str) : mean or median

run(acq, filename, options)

run the procedure

Parameters
  • acq (btk.Acquisition) – a btk acquisition instantce

  • filename (str) – filename

  • options (dict) – passed options from the filter

AnomalyCorrectionProcedure

class pyCGM2.Anomaly.anomalyCorrectionProcedures.MarkerAnomalyCorrectionProcedure(markers, anomalyIndexes, plot=False, **kwargs)

procedure to correct marker anomaly

Parameters
  • markers (list) – marker labels

  • anomalyIndexes (list) – indexes of the detected anomalies

  • plot (bool) – enable plot

Keyword Arguments

distance_threshold (float) – distance threshold between indexes

run(acq, filename)

run the procedure

Parameters
  • acq (btk.Acquisition) – a btk acquisition instantce

  • filename (str) – filename

EMG module

emgManager

class pyCGM2.EMG.emgManager.EmgManager(DATA_PATH, emgSettings=None)

Class to manage emg settings ( ie the emg.settings file)

Parameters
  • DATA_PATH (str) – data folder path

  • emgSettings (str,Optional[None]) – content of the emg.settings file

getChannelSection()

return the channel section of the emg settings

getChannels()

return the channel labels

getMuscles()

return the muscles

getNormalActivity()

return the normal activity muscle reference

getProcessingSection()

return the processing section of the emg settings

getSides()

return side of each emg

emgFilters

coactivationProcedures

This module contains co-activation procedures

check out the script : Tests est_EMG.py for examples

class pyCGM2.EMG.coactivationProcedures.FalconerCoActivationProcedure

Coactivation index according falconer and Winter

Falconer K, Winter DA. Quantitative assessment of cocontraction at the ankle joint in walking. Electromyogr Clin Neurophysiol. 1985;25:135–149. [PubMed] [Google Scholar]

run(emg1, emg2)

run the procedure.

Parameters
  • emg1 (str) – emg label .

  • emg2 (str) – emg label

Returns

list – Coactivation index

class pyCGM2.EMG.coactivationProcedures.UnithanCoActivationProcedure

Coactivation procedure according Unithan et al, 1996

Unnithan VB, Dowling JJ, Frost G, Volpe Ayub B, Bar-Or O. Cocontraction and phasic activity during GAIT in children with cerebral palsy. Electromyogr Clin Neurophysiol. 1996;36:487–494.

run(emg1, emg2)

run the procedure.

Parameters
  • emg1 (str) – emg label .

  • emg2 (str) – emg label

Returns

list – Coactivation index

discreteEmgProcedures

Module containes Filter and Procedure for extracting discrete value ( e.g : amplitude) from each emg signal

class pyCGM2.EMG.discreteEmgProcedures.AmplitudesProcedure

This procedure computes EMG amplitude for each gait phases

detect(analysisInstance, emgLabels, emgMuscles, emgContexts)

Compute amplitudes

Parameters
  • analysis (pyCGM2.Processing.analysis.Analysis) – A pycgm2 analysis instance

  • emgLabels (list) – emg labels

  • emgMuscles (list) – muscle matching emg labels

  • emgContexts (list) – side of each eamg labels

normalActivation

The module contains convenient function for getting the normal emg activity of the muscles listed in the file (pyCGM2/Data/normativeData/emg/normalActivation.json).

pyCGM2.EMG.normalActivation.getNormalBurstActivity(muscle, fo)

get onsets and offsets of a specific muscle.

Parameters
  • muscle (str) – muscle label listed in normalActivation.json

  • fo (int) – foot off frame

pyCGM2.EMG.normalActivation.getNormalBurstActivity_fromCycles(muscle, ff, begin, fo, end, apf)

get onsets and offsets of a specific muscle from .

Parameters
  • muscle (str) – muscle label listed in normalActivation.json

  • ff (int) – first frame of the btk.acquisition

  • begin (int) – initial frame of cycle

  • fo (int) – foot off frame

  • end (int) – final frame of the cycle

  • apf (int) – nNumber of analog sample per frame

Event

eventFilters

The module contains filter for detecting foot contact events.

check out the script : Tests est_events.py for examples

class pyCGM2.Events.eventFilters.EventFilter(procedure, acq)

Event filter to handle an event procedure

detect()

Run the motion filter

eventProcedures

force Plates module

forcePlates

Gap

GapFilters

The module contains filter and procedure for filling gap

check out the script : Tests est_gap.py for examples

class pyCGM2.Gap.gapFilters.GapFillingFilter(procedure, acq)

Gap filter

Parameters
  • procedure (pyCGM2.Gap.gapFillingProcedures.GapProcedure) – a gap filling procedure instance

  • acq (Btk.Acquisition) – a btk acquisition instance

fill(markers=None)

fill gap according the specified procedure

GapProcedures

Inspector

inspectorFilters

Module contain the filter for running inspector procedure.

class pyCGM2.Inspector.inspectorFilters.InspectorFilter(acq, filename, procedure, **kwargs)

pyCGM2 filter

inspectorProcedures

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

QTM

qtmTools

Module contains convenient functions dealing with the session.xml file generated from QTM.

pyCGM2.QTM.qtmTools.SubjectMp(soup)

return the antropometric parameters

Parameters

soup (bs4.soup) – content of the session.xml

pyCGM2.QTM.qtmTools.detectMeasurementType(soup)

return the type of each measurement section

Parameters

soup (bs4.soup) – content of the session.xml

pyCGM2.QTM.qtmTools.findDynamic(soup)

return the dynamic files from the bs4.soup instance representing the content of the session.xml

Parameters

soup (bs4.soup) – content of the session.xml

pyCGM2.QTM.qtmTools.findKneeCalibration(soup, side)

return the knee functional calibration file from the bs4.soup instance representing the content of the session.xml

Parameters
  • soup (bs4.soup) – content of the session.xml

  • side (str) – lower limb side

pyCGM2.QTM.qtmTools.findStatic(soup)

return the static file from the bs4.soup instance representing the content of the session.xml

Parameters

soup (bs4.soup) – content of the session.xml

pyCGM2.QTM.qtmTools.getFilename(measurement)

return the filename of the measurement section

Parameters

measurement (bs4.soup) – a measurement section of the session.xml file.

pyCGM2.QTM.qtmTools.getForcePlateAssigment(measurement)

return the force plate assigment from the measurement section

Parameters

measurement (bs4.soup) – a measurement section of the session.xml file.

pyCGM2.QTM.qtmTools.getKneeFunctionCalibMethod(measurement)

return the method used for the knee calibration

Parameters

measurement (bs4.soup) – a measurement section of the session.xml file.

pyCGM2.QTM.qtmTools.isType(measurement, type)

check type of measurement section

Parameters
  • measurement (bs4.soup) – a measurement section of the session.xml file.

  • type (str) – type

Processing

analysis

analysisHandler

pyCGM2.Processing.analysisHandler.getAnalysisSection(analysisInstance, label, context)

return the section ( ie kinematic, kinetic or emg) of a given label and its context

Parameters
  • analysisInstance (pyCGM2.Processing.analysis.Analysis) – an analysis instance

  • label (str) – givel ouput label (eg LKneeAngles)

  • context (str) – event context

pyCGM2.Processing.analysisHandler.getNumberOfCycle(analysisInstance, label, context)

return the number of cycle from a given ouput and its event context.

Parameters
  • analysisInstance (pyCGM2.Processing.analysis.Analysis) – an analysis instance

  • label (str) – givel ouput label (eg LKneeAngles)

  • context (str) – event context

pyCGM2.Processing.analysisHandler.getPhases(dataStats, context='Both')

get phases

Parameters
  • dataStats (pyCGM2.Processing.analysis.Analysis.kinematicStats.data) – data level

  • instance (of the kinematicStats or kineticStats attributes of an Analysis) –

  • context (str) – event context

pyCGM2.Processing.analysisHandler.getValues(analysisInstance, label, context)

return the values from a given ouput and its event context.

Parameters
  • analysisInstance (pyCGM2.Processing.analysis.Analysis) – an analysis instance

  • label (str) – givel ouput label (eg LKneeAngles)

  • context (str) – event context

pyCGM2.Processing.analysisHandler.isKeyExist(analysisInstance, label, context, exceptionMode=False)

check if the combinaison label/context exist in the analysis instance

Parameters
  • analysisInstance (pyCGM2.Processing.analysis.Analysis) – an analysis instance

  • label (str) – givel ouput label (eg LKneeAngles)

  • context (str) – event context

  • exceptionMode (bool) – enable exception raising

analysisProcessing

cycle

exporter

This module contains 2 classes (XlsAnalysisExportFilter and AnalysisExportFilter) for exporting an analysis instance in xls fomat and json respectively.

the class XlsExportDataFrameFilter is a generic filter for exporting Pandas.DataFrame in xls.

class pyCGM2.Processing.exporter.AnalysisExportFilter

Filter exporting an analysis instance as json.

export(outputName, path=None)

Export as json

Parameters
  • outputName (str) – filename without extension

  • path (str) – Path

setAnalysisInstance(analysisInstance)

set the analysis instance

Parameters

analysisInstance (pyCGM2.analysis.Analysis) – an analysis instance

class pyCGM2.Processing.exporter.XlsAnalysisExportFilter

Filter exporting an analysis instance as spreadheet.

Exported spreadsheet can organize either by row (Advanced mode) or column (basic mode). In Advanced mode, a row is made up of 101 columns representing a time normalized cycle.

export(outputName, path=None, excelFormat='xls', mode='Advanced')

Export spreadsheet

Parameters
  • outputName (str) – filename without extension

  • path (str) – Path

  • excelFormat (str) – format (xls,xlsx)

  • mode (str) – structure mode of the spreadsheet (Advanced,Basic)

setAnalysisInstance(analysisInstance)

set the analysis instance

Parameters

analysisInstance (pyCGM2.analysis.Analysis) – an analysis instance

class pyCGM2.Processing.exporter.XlsExportDataFrameFilter

Filter exporting a pandas.dataFrame or a list of pandas.dataFrame as xls spreadsheet(s)

export(outputName, path=None, excelFormat='xls')

Export spreadsheet

Parameters
  • outputName (str) – filename without extension

  • path (str) – Path

  • excelFormat (str) – format (xls,xlsx)

setDataFrames(dataframes)

Set the dataFrame

Parameters

dataframes (pandas.dataFrame or list) – dataframe or list of dataframe

c3dManager

c3dManagerFilters

c3dManagerProcedures

Classification

classificationFilters

classificationProcedures

DiscretePoints

discretePointFilters

A discrete point is a value at a specific frame of a cycle.

In this module, through the filter DiscretePointsFilter, the goal is to get series of discrete values extracted according a specific strategy (ie a procedure). For instance, the BenedettiProcedure extracts dicrete points recommanded in Benededdi et al (1998):

References:

Benedetti, M. G.; Catani, F.; Leardini, A.; Pignotti, E.; Giannini, S. (1998) Data management in gait analysis for clinical applications. In : Clinical biomechanics (Bristol, Avon), vol. 13, n° 3, p. 204–215. DOI: 10.1016/s0268-0033(97)00041-7.

class pyCGM2.Processing.DiscretePoints.discretePointFilters.DiscretePointsFilter(discretePointProcedure, analysis, modelInfo=None, subjInfo=None, condExpInfo=None)

Discrete point filter

Parameters
  • discretePointProcedure (pyCGM2.Processing.DiscrePoints.discretePointProcedures.DiscretePointProcedure) – a procedure

  • analysis (pyCGM2.Processing.analysis.Analysis) – an analysis instance

  • modelInfo (dict) – information about the model

  • subjInfo (dict) – information about the subject

  • condExpInfo (dict) – information about the experiment

getOutput()

get the output dataframe with all discrete values according to the procedure

setCondExpInf(condExpInfo)

Set experimental information

Parameters

condExpInfo (dict) – experimental information

setModelInfo(modelInfo)

Set model information

Parameters

modelInfo (dict) – model information

setSubjInfo(subjInfo)

Set subject information

Parameters

subjInfo (dict) – subject information

discretePointProcedures

class pyCGM2.Processing.DiscretePoints.discretePointProcedures.BenedettiProcedure(pointSuffix=None)

discrete points recommanded by benededdi et al(1998).

Parameters

pointSuffix (str) – suffix added to model ouputs

References:

Benedetti, M. G.; Catani, F.; Leardini, A.; Pignotti, E.; Giannini, S. (1998) Data management in gait analysis for clinical applications. In : Clinical biomechanics (Bristol, Avon), vol. 13, n° 3, p. 204–215. DOI: 10.1016/s0268-0033(97)00041-7.

detect(analysisInstance)

extract discrete points

Parameters

analysisInstance (pyCGM2.Processing.analysis.Analysis) – an analysis instance

class pyCGM2.Processing.DiscretePoints.discretePointProcedures.GoldbergProcedure(pointSuffix=None)

discrete points recommanded by Goldberg et al(1998).

Parameters

pointSuffix (str) – suffix added to model ouputs

References:

Goldberg, Saryn R.; Ounpuu, Sylvia; Arnold, Allison S.; Gage, James R.; Delp, Scott L. (2006) Kinematic and kinetic factors that correlate with improved knee flexion following treatment for stiff-knee gait. In : Journal of biomechanics, vol. 39, n° 4, p. 689–698. DOI: 10.1016/j.jbiomech.2005.01.015.

detect(analysisInstance)

extract discrete points

Parameters

analysisInstance (pyCGM2.Processing.analysis.Analysis) – an analysis instance

class pyCGM2.Processing.DiscretePoints.discretePointProcedures.MaxMinProcedure(pointSuffix=None)

extract extrema values.

Parameters

pointSuffix (str) – suffix added to model ouputs

detect(analysisInstance)

extract discrete points

Parameters

analysisInstance (pyCGM2.Processing.analysis.Analysis) – an analysis instance

JointPatterns

jointPatternFilters

class pyCGM2.Processing.JointPatterns.jointPatternFilters.JointPatternFilter(jointPatternProcedure, analysis)

jointPatternProcedures

ProgressionFrame

progressionFrameFilters

progressionFrameProcedures

Representative

representativeFilters

representativeProcedures

Scores

scoreFilters

This module is dedicated to the quantification of a Score, i e a Global index caracterizing the movement performed

The filter ScoreFilter calls a specific procedure, and return scores values.

class pyCGM2.Processing.Scores.scoreFilters.ScoreFilter(scoreProcedure, analysis, normativeDataSet)

the score filter

Parameters
  • scoreProcedure (pyCGM2.processing.Scores.scoreProcedures.ScoreProcedure) – a procedure instance

  • analysis (pyCGM2.Processing.analysis.Analysis) – and analysis instance

  • normativeDataSet (pyCGM2.Report.normativeDatasets.NormativeData) – normative data instance

scoreProcedures

class pyCGM2.Processing.Scores.scoreProcedures.CGM1_GPS(pointSuffix=None)

Gait profile score accordin Baker et al. 2009

Parameters

pointSuffix (str,Optional[None]) – suffix added to model ouputs

Reference

Baker, Richard; McGinley, Jennifer L.; Schwartz, Michael H.; Beynon, Sarah; Rozumalski, Adam; Graham, H. Kerr; Tirosh, Oren (2009) The gait profile score and movement analysis profile. In : Gait & posture, vol. 30, n° 3, p. 265–269. DOI: 10.1016/j.gaitpost.2009.05.020.

Report

normativeDatasets

Module deals with normative datasets.

Normative datasets are embedded in pyCGM2. they are placed in the folder pyCGM2/Data as a json file.

The construction of a NormativeData instance automatically populate its attribute data, an intuitive dictionary with model ouput as key, reporting mean and standard deviation as sub-key.

The NormativeSTP class replicates the process for the spatio-temporal excel file (normal_stp.xlsx) placed in the folder pyCGM2/Data/stp

class pyCGM2.Report.normativeDatasets.NormalSTP

Normative spatio-temporal dataset.

The instance contruction populates the attribute data which reports normative data as a dictionary

class pyCGM2.Report.normativeDatasets.NormativeData(filenameNoExt, modality)

Normative dataset.

The instance contruction populates the attribute data which reports normative data as a dictionary

Parameters
  • filenameNoExt (str) – filename of the targeted json file.

  • modality (str) – modality.

plot

plotFilters

plotUtils

Viewers

plotViewers

emgPlotViewers

comparisonPlotViewers

Signal

anomaly

pyCGM2.Signal.anomaly.anomaly_rolling(values, aprioriError=0, window=10, threshold=3, method='median', plot=False, label='Unknow', referenceValues=None)

anomaly detection from rolling windows

Parameters
  • values (np.array) – values

  • aprioriError (int,Optional[0]) – a priori error.

  • window (int,Optional[10]) – size of the window.

  • threshold (int,Optional[3]) – standard deviation factor

  • method (str,Optional[median]) – descriptive statistic method

  • plot (bool,Optional[False]) – enable plot

  • label (str,Optional[Unknown]) – Description of parameter label

  • referenceValues (np.array,Optional[None]) – values used as reference instead of the values computing from the rolling windows

detect_changes

The module only contains the function “detect_changes” implemenented by Marcos Duarte, available in [BMC](https://github.com/demotu/BMC)

see BMC documentation for details

pyCGM2.Signal.detect_changes.detect_cusum(x, threshold=1, drift=0, ending=False, show=True, ax=None)

Cumulative sum algorithm (CUSUM) to detect abrupt changes in data

detect_onset

The module only contains the function “detect_onset” implemenented by Marcos Duarte, available in [BMC](https://github.com/demotu/BMC)

see BMC documentation for details

pyCGM2.Signal.detect_onset.detect_onset(x, threshold=0, n_above=1, n_below=0, threshold2=None, n_above2=1, show=False, ax=None)

Detects onset in data based on amplitude threshold.

detect_peaks

The module only contains the function “detect_peaks” implemenented by Marcos Duarte, available in [BMC](https://github.com/demotu/BMC)

see BMC documentation for details

pyCGM2.Signal.detect_peaks.detect_peaks(x, mph=None, mpd=1, threshold=0, edge='rising', kpsh=False, valley=False, show=False, ax=None)

Detect peaks in data based on their amplitude and other features.

signal_processing

The module only contains functions for filtering data

pyCGM2.Signal.signal_processing.arrayLowPassFiltering(valuesArray, freq, order=2, fc=6)

Low-pass filtering of a numpy.array

Parameters
  • valuesArray (numpy.array(n,n)) –

  • fc (float,Optional) – cut-off frequency. Default set to 6 Hz

  • order (int,optional) – order of the low-pass filter, Default set to 2

pyCGM2.Signal.signal_processing.enveloppe(array, fc, fa)

Get signal enveloppe from a low pass filter

Parameters
  • array (numpy.array(n,n)) – array

  • fc (float) – cut-off frequency

  • fa (float) – sample frequency

pyCGM2.Signal.signal_processing.forcePlateFiltering(btkAcq, order=4, fc=5)

Low-pass filtering of Force plate outputs

Parameters
  • btkAcq (btk.Acquisition) – btk acquisition instance

  • fc (float,Optional) – cut-off frequency. Default set to 5 Hz

  • order (int,optional) – order of the low-pass filter, Default set to 4

pyCGM2.Signal.signal_processing.highPass(array, lowerFreq, upperFreq, fa)

butterworth bandpass filter.

Parameters
  • array (numpy.array(n,n)) – array

  • lowerFreq (float) – lower frequency

  • upperFreq (float) – upper frequency

  • fa (float) – sample frequency

pyCGM2.Signal.signal_processing.markerFiltering(btkAcq, markers, order=2, fc=6, zerosFiltering=True)

Low-pass filtering of all points in an acquisition

Parameters
  • btkAcq (btk.Acquisition) – btk acquisition instance

  • fc (float,Optional) – cut-off frequency. Default set to 6 Hz

  • order (int,optional) – order of the low-pass filter, Default set to 2

  • zerosFiltering (bool,optional) – enable zero filtering, Default set to True

pyCGM2.Signal.signal_processing.rectify(array)

rectify a signal ( i.e get absolute values)

Parameters

array (numpy.array(n,n)) – array

pyCGM2.Signal.signal_processing.remove50hz(array, fa)

Remove the 50Hz signal

Args

array (array(n,n): array fa (float): sample frequency

Tools

btkTools

pythonTools

class pyCGM2.Tools.pythonTools.ordict(*args, **kwargs)

ordered dictionary

clear()

clear the dictionary

copy()

copy dict

items()

return items (key,value)

iteritems()

iterator returning tuples (key, value)

iterkeys()

iterator returning key

itervalues()

iterator returning value

keys()

get keys

pop(key, value=None)

remove a key and return its value

popitem()

remove a key an return the key an its value

setdefault(key, value=None)

set a default item

update(*args, **kwargs)

update the dictionary

values()

return values

Utils

files

pyCGM2.Utils.files.copyPaste(src, dst)

file copy/paste

Parameters
  • src (str) – source

  • dst (str) – destination

pyCGM2.Utils.files.copyPasteDirectory(src, dst)

folder copy/paste

Parameters
  • src (str) – source

  • dst (str) – destination

pyCGM2.Utils.files.copySessionFolder(folderPath, folder2copy, newFolder, selectedFiles=None)

copy a vicon-session folder

Parameters
  • folderPath (str) – new session folder path

  • folder2copy (str) – session folder path to copy

  • selectedFiles (str,Optional[none]) – selected files to copy

pyCGM2.Utils.files.createDir(fullPathName)

Create a folder

Parameters

fullPathName (str) – path

pyCGM2.Utils.files.deleteDirectory(dir)

Delete a folder

Parameters

dir (str) – folder path

pyCGM2.Utils.files.getC3dFiles(path, text='', ignore=None)

get all c3d files in a folder

Parameters
  • path (str) – folder path

  • text (str,Optional[""]) – included text in the filename

pyCGM2.Utils.files.getDirs(folderPath)

get all folders

Parameters

folderPath (str) – folder path

pyCGM2.Utils.files.getFileCreationDate(file)

return file creation date

Parameters

file (str) – full filename (path+filename)

pyCGM2.Utils.files.getFiles(path, extension, ignore=None, raiseFlag=False)

get all files in a folder

Parameters
  • path (str) – folder path

  • extension (str) – file extension

  • ignore (str,Optional[None]) – ignored filenames

  • raiseFlag (bool,Optional[False]) – raise exception

pyCGM2.Utils.files.getIKweightSet(DATA_PATH, ikwf)

get marker weights for kinematic fitting

Parameters
  • DATA_PATH (str) – data folder path

  • ikwf (str) – weights filename

pyCGM2.Utils.files.getMp(mpInfo, resetFlag=True)

return required and optional anthropometric parameters

Parameters
  • mpInfo (dict) – global mp dictionary

  • resetFlag (bool,Optional[True]) – reset optional parameters

pyCGM2.Utils.files.getMpFileContent(DATA_PATH, file, subject)

get anthropometric data

Parameters
  • DATA_PATH (str) – data folder path

  • file (str) – Filename

  • subject (str) – subject name

pyCGM2.Utils.files.getTranslators(DATA_PATH, translatorType='CGM1.translators')

get CGM marker translators

Parameters
  • DATA_PATH (str) – data folder path

  • translatorType (str,Optional[CGM1.translators]) – translator filename

pyCGM2.Utils.files.loadAnalysis(path, FilenameNoExt)

load an analysis instance

Parameters
  • path (str) – data folder path

  • FilenameNoExt (str) – analysis filename without extension

pyCGM2.Utils.files.loadModel(path, FilenameNoExt)

load a pyCGM2 model instance

Parameters
  • path (str) – data folder path

  • FilenameNoExt (str) – model filename wthout extension

pyCGM2.Utils.files.loadModelSettings(DATA_PATH, expertsettings_filename)

Load a pyCGM2 model settings.

Parameters
  • DATA_PATH (str) – data folder path

  • expertsettings_filename (str) – setting filename

pyCGM2.Utils.files.loadMp(path, filename)

load a mp file.

Parameters
  • path (str) – data folder path

  • filename (str) – filename with Extension

pyCGM2.Utils.files.openFile(path, filename)

open a json/yaml file.

Parameters
  • path (str) – data folder path

  • filename (str) – filename with Extension

pyCGM2.Utils.files.openPickleFile(path, filename)

open a serialized file.

Parameters
  • path (str) – data folder path

  • filename (str) – filename with Extension

pyCGM2.Utils.files.readContent(stringContent)

read a json/yaml content

Parameters

stringContent (str) – json or yaml content

pyCGM2.Utils.files.readXml(DATA_PATH, filename)

Read a xml file

Parameters
  • DATA_PATH (str) – folder path

  • filename (str) – xlm filename

pyCGM2.Utils.files.saveAnalysis(analysisInstance, path, FilenameNoExt)

save a pyCGM2 analysis instance

Parameters
  • pyCGM2.Processing.analysis.Analysis) (model) – an analysis instance

  • path (str) – data folder path

  • FilenameNoExt (str) – model filename wthout extension

pyCGM2.Utils.files.saveJson(path, filename, content, ensure_ascii=False)

save as json file

Parameters
  • path (str) – data folder path

  • filename (str) – json filename

  • content (dict) – dictionary to save

pyCGM2.Utils.files.saveModel(model, path, FilenameNoExt)

save a pyCGM2 model instance

Parameters
  • pyCGM2.Model.model.Model) (model) – a model instance

  • path (str) – data folder path

  • FilenameNoExt (str) – model filename wthout extension

pyCGM2.Utils.files.saveMp(mpInfo, model, DATA_PATH, mpFilename)

Save anthropometric parameters as json

Parameters
  • mpInfo (dict) – global anthropometric parameters

  • model (pyCGM2.Model.model.Model) – a model instance

  • DATA_PATH (str) – data folder path

  • mpFilename (str) – filename

pyCGM2.Utils.files.savePickleFile(instance, path, filename)

serialized a pyCGM2 instance , then save it.

Parameters
  • instance (object) – a object instance

  • path (str) – data folder path

  • filename (str) – filename with Extension

pyCGM2.Utils.files.saveYaml(path, filename, content)

save as yaml file

Parameters
  • path (str) – data folder path

  • filename (str) – json filename

  • content (dict) – dictionary to save

Note: Do not work well with orderdict

utils

pyCGM2.Utils.utils.isInRange(val, min, max)

check if value is in range

Parameters
  • val (double) – value

  • min (double) – minimim value

  • max (double) – maximum value

pyCGM2.Utils.utils.toBool(text)

convert text to bool

Parameters

text (str) – text

Enums