Tools

btkTools

This module contains convenient functions for working with btk

check out test_btkTools for examples

pyCGM2.Tools.btkTools.GetAnalogNames(acq)

return analog labels

Parameters

acq (btk.acquisition) – a btk acquisition instance

pyCGM2.Tools.btkTools.GetMarkerNames(acq)

return marker labels

Parameters

acq (btk.acquisition) – a btk acquisition instance

pyCGM2.Tools.btkTools.applyOnValidFrames(acq, validFrames)

set zeros to all points if the frame is not valid

Parameters
  • acq (btkAcquisition) – a btk acquisition inctance

  • validFrames (list) – list of n frames with 1 or 0 indicating if the frame is valid or not

pyCGM2.Tools.btkTools.applyRotation(acq, markers, globalFrameOrientation, forwardProgression)

apply a rotation to markers

Args

acq (btkAcquisition): a btk acquisition instance markers (list): marker labels globalFrameOrientation (str): orientation of the global frame ( eg XYZ stands for X:long, y: transversal, Z:normal) forwardProgression (bool): indicate progression along the positive axis of the progression frame

pyCGM2.Tools.btkTools.applyTranslators(acq, translators)

Rename marker from translators

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

  • translators (dict) – translators

pyCGM2.Tools.btkTools.applyValidFramesOnOutput(acq, validFrames)

set model outputs to zero if not a valid frame

Parameters
  • acq (btkAcquisition) – a btk acquisition inctance

  • validFrames (list) – valid frame flags

pyCGM2.Tools.btkTools.automaticKineticDetection(dataPath, filenames, acqs=None)

check presence of force plate events (ie Left-FP”, “Right-FP”) in a list of files

Args

dataPath (str): data folder dataPath filenames ([str..]): filenames acqs ([btk.acquisition,…],Optional): list of btk.acquisition instances. default set to None

pyCGM2.Tools.btkTools.buildTrials(dataPath, filenames)

build acquisitions

Args

dataPath (str): data folder dataPath filenames(list): c3d filenames

pyCGM2.Tools.btkTools.changeSubjectName(acq, subjectName)

change subject name in all section of the acquisition

Args

acq (btkAcquisition): a btk acquisition instance subjectName (str): subject name

pyCGM2.Tools.btkTools.checkForcePlateExist(acq)

check force plate presence

Args

acq (btkAcquisition): a btk acquisition instance

pyCGM2.Tools.btkTools.checkGap(acq, markerList, frameBounds=None)

check if there are any gaps from a list of markers

Parameters
  • acq (btkAcquisition) – a btk acquisition inctance

  • markerLabels ([str...]) – marker labels

  • frameBounds ([double,double]) – frame boundaries

pyCGM2.Tools.btkTools.checkMarkers(acq, markerList)

check marker presence. Raise an exception if fails

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

  • markerList (list) – marker labels

pyCGM2.Tools.btkTools.checkMetadata(acq, firstLevel, secondLevel)

check presence of a metadata

Args

acq (btkAcquisition): a btk acquisition instance firstLevel (str): metadata first-level label secondLevel (str): metadata second-level label

pyCGM2.Tools.btkTools.checkMultipleSubject(acq)

check if multiple subject detected in the acquisition

Parameters

acq (btkAcquisition) – a btk acquisition inctance

pyCGM2.Tools.btkTools.cleanAcq(acq)

clean an aquisition ( remove zero points)

Args

acq (btkAcquisition): a btk acquisition instance

pyCGM2.Tools.btkTools.clearEvents(acq, labels)

remove events from their label

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

  • label (list) – event labels

pyCGM2.Tools.btkTools.clearPoints(acq, pointlabelList)

Remove points

Parameters
  • acq (btk.acquisition) – a btk acquisition instance

  • pointlabelList (list) – point labels

pyCGM2.Tools.btkTools.constructMarker(acq, label, markers, numpyMethod=<function mean>, desc='')

construct a marker from others

Args

acq (btkAcquisition): a btk acquisition inctance label (str): marker label of the constructed marker markers ([str…]): markers labels numpyMethod (np.function, Optional): [default:np.mean]: numpy function used for handle markers desc (str,optional) - description

pyCGM2.Tools.btkTools.constructPhantom(acq, label, desc='')

construct a phantom

Args

acq (btkAcquisition): a btk acquisition inctance label (str): marker label of the constructed marker desc (str,optional) - description

pyCGM2.Tools.btkTools.createPhantoms(acq, markerLabels)

construct phantoms

Args

acq (btkAcquisition): a btk acquisition instance markerLabels (list): phantom marker labels

pyCGM2.Tools.btkTools.deleteContextEvents(acq, context)

remove events with the same context ( eg Left,Right, or General )

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

  • context (str) – event context

pyCGM2.Tools.btkTools.findMarkerGap(acq)

return markers with detected gap

Parameters

acq (btk.acquisition) – a btk acquisition instance

pyCGM2.Tools.btkTools.findValidFrames(acq, markerLabels)

find valid frames to process from markers

Parameters
  • acq (btkAcquisition) – a btk acquisition inctance

  • markerLabels (list) – marker labels

pyCGM2.Tools.btkTools.getAllParamAnalysis(acq)

get all analysis parameters

Args

acq (btkAcquisition): a btk acquisition instance

pyCGM2.Tools.btkTools.getForcePlateWrench(acq, fpIndex=None)

get force plate wrench

Args

acq (btkAcquisition): a btk acquisition instance

pyCGM2.Tools.btkTools.getFrameBoundaries(acq, markerLabels)

get frame boundaries from a list of markers

Parameters
  • acq (btkAcquisition) – a btk acquisition inctance

  • markerLabels (list) – marker labels

pyCGM2.Tools.btkTools.getNumberOfForcePlate(acq)

return number of force plate

Args

acq (btkAcquisition): a btk acquisition instance

pyCGM2.Tools.btkTools.getNumberOfModelOutputs(acq)

return the size of model outputs

Parameters

acq (btk.Acquisition) – a btk acquisition instance

pyCGM2.Tools.btkTools.getParamAnalysis(btkAcq, name, context, subject)

get an analysis parameter

Args

acq (btkAcquisition): a btk acquisition instance name (str): parameter labels context (str): event contexts subject (str): subject name

pyCGM2.Tools.btkTools.getStartEndEvents(acq, context, startLabel='Start', endLabel='End')

return frames of the start and end events.

Args

acq (btkAcquisition): a btk acquisition instance context (str): event context startLabel (str,optional). label of the start event. default set to Start endLabel (str,optional). label of the end event. default set to End

pyCGM2.Tools.btkTools.getValidFrames(acq, markerLabels, frameBounds=None)

get valid frames of markers

Parameters
  • acq (btkAcquisition) – a btk acquisition inctance

  • markerLabel (str) – marker label

  • frameBounds ([int,int],optional) – frame boundaries

pyCGM2.Tools.btkTools.getVisibleMarkersAtFrame(acq, markers, index)

return markers visible at a specific frame

Parameters

acq (btk.Acquisition) – a btk acquisition instance

pyCGM2.Tools.btkTools.isAnalogExist(acq, label)

Check if a point label exists inside an acquisition

Args

acq (btkAcquisition): a btk acquisition inctance label (str) - analog label

pyCGM2.Tools.btkTools.isGap(acq, markerLabel)

check gap

Parameters
  • acq (btk.acquisition) – a btk acquisition instance

  • markerLabel (list) – marker labels

pyCGM2.Tools.btkTools.isKineticFlag(acq)

check presence of force plate events (ie Left-FP”, “Right-FP”)

Args

acq (btkAcquisition): a btk acquisition instance

pyCGM2.Tools.btkTools.isPhantom(acq, label)

check if a point is a phantom ( ie zero point)

Parameters
  • acq (btkAcquisition) - a btk acquisition inctance

  • label (str) - point label

pyCGM2.Tools.btkTools.isPointExist(acq, label, ignorePhantom=True)

check if a point exist

Parameters
  • acq (btk.acquisition) – a btk acquisition instance

  • label (str) – marker label

  • ignorePhantom (bool,optional) –

pyCGM2.Tools.btkTools.isPointsExist(acq, labels, ignorePhantom=True)

check if a list of points exist

Parameters
  • acq (btk.acquisition) – a btk acquisition instance

  • label (list) – marker labels

  • ignorePhantom (bool,optional) –

pyCGM2.Tools.btkTools.keepAndDeleteOtherPoints(acq, pointToKeep)

Remove points except ones

Parameters
  • acq (btk.acquisition) – a btk acquisition instance

  • pointToKeep ([str) – points to keep

pyCGM2.Tools.btkTools.markerUnitConverter(acq, unitOffset)

apply an offset to convert marker in an other unit

Args

acq (btkAcquisition): a btk acquisition inctance unitOffset (float) - offset value

pyCGM2.Tools.btkTools.modifyEventSubject(acq, newSubjectlabel)

update the subject name of all events

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

  • newSubjectlabel (str) – new subject

pyCGM2.Tools.btkTools.modifySubject(acq, newSubjectlabel)

update the subject name inside c3d metadata

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

  • newSubjectlabel (str) – new subject

pyCGM2.Tools.btkTools.smartAppendAnalog(acq, label, values, desc='')

append an analog output

Args

acq (btkAcquisition): a btk acquisition inctance label (str) - analog label label (np.array) - values desc (str,optional) - description

pyCGM2.Tools.btkTools.smartAppendParamAnalysis(acq, name, eventcontext, value, description='', subject='', unit='')

set an analysis parameter

Args

acq (btkAcquisition): a btk acquisition instance name (str): parameter label eventcontext (str): event context value (float): value subject (str,optional ): name of the subject. Defaut set to “” description (str,optional ): description. Defaut set to “” unit (str,optional ): unit. Defaut set to “”

pyCGM2.Tools.btkTools.smartAppendPoint(acq, label, values, PointType='Marker', desc='', residuals=None)

Append or Update a point

Parameters
  • acq (btk.acquisition) – a btk acquisition instance

  • label (str) – marker label

  • values (np.array(n,3)) – point values

  • PointType (str) – point type (choice : Marker,Angle,Moment,Force,Power,Reaction,Scalar)

  • desc (str,optional) – point description. Default set to “”

  • residuals (np.array(n,1)) – point residual values

pyCGM2.Tools.btkTools.smartCreateEvent(acq, label, context, frame, type='Automatic', subject='', desc='')

set an event

Args

acq (btkAcquisition): a btk acquisition instance label (str): event labels context (str): event context frame (int) event frameEnd type (btk.btkEvent enum,optional ): btk event type. Default set to btk.btkEvent.Automatic subject (str,optional ): name of the subject. Defaut set to “” desc (str,optional ): description. Defaut set to “”

pyCGM2.Tools.btkTools.smartGetEvents(acq, label, context)

return an event

Args

acq (btkAcquisition): a btk acquisition instance label (str): event label context (str): event context

pyCGM2.Tools.btkTools.smartGetMetadata(acq, firstLevel, secondLevel, returnType='String')

return metadata

Args

acq (btkAcquisition): a btk acquisition instance firstLevel (str): metadata first-level label secondLevel (str): metadata second-level label returnType (str,optional) : returned type of the metadata. defalut set to String

pyCGM2.Tools.btkTools.smartReader(filename, translators=None)

Convenient function to read a c3d with Btk

Parameters
  • filename (str) – filename with its path

  • translators (dict) – marker translators

pyCGM2.Tools.btkTools.smartSetMetadata(acq, firstLevel, secondLevel, index, value)

set a metadata

Args

acq (btkAcquisition): a btk acquisition instance firstLevel (str): metadata first-level label secondLevel (str): metadata second-level label index (int) : index value (str,optional) : metadata value

pyCGM2.Tools.btkTools.smartWriter(acq, filename)

Convenient function to write a c3d with Btk

Parameters
  • acq (btk.acquisition) – a btk acquisition instance

  • filename (str) – filename with its path

pyCGM2.Tools.btkTools.sortedEvents(acq)

sort events

Args

acq (btkAcquisition): a btk acquisition instance

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