# pagoda.cooper.Markers¶

class pagoda.cooper.Markers(world)[source]
__init__(world)[source]

Methods

 __init__(world) attach(frame_no) Attach marker bodies to the corresponding skeleton bodies. create_bodies() Create physics bodies corresponding to each marker in our data. detach() Detach all marker bodies from their associated skeleton bodies. distances() Get a list of the distances between markers and their attachments. forces([dx_tm1]) Return an array of the forces exerted by marker springs. load_attachments(source, skeleton) Load attachment configuration from the given text source. load_c3d(filename[, start_frame, max_frames]) Load marker data from a C3D file. load_csv(filename[, start_frame, max_frames]) Load marker data from a CSV file. process_data() Process data to produce velocity and dropout information. reposition(frame_no) Reposition markers to a specific frame of data.

Attributes

 DEFAULT_CFM DEFAULT_ERP labels Return the names of our marker labels in canonical order. num_frames Return the number of frames of marker data. num_markers Return the number of markers in each frame of data.
attach(frame_no)[source]

Attach marker bodies to the corresponding skeleton bodies.

Attachments are only made for markers that are not in a dropout state in the given frame.

Parameters: frame_no : int The frame of data we will use for attaching marker bodies.
create_bodies()[source]

Create physics bodies corresponding to each marker in our data.

detach()[source]

Detach all marker bodies from their associated skeleton bodies.

distances()[source]

Get a list of the distances between markers and their attachments.

Returns: distances : ndarray of shape (num-markers, 3) Array of distances for each marker joint in our attachment setup. If a marker does not currently have an associated joint (e.g. because it is not currently visible) this will contain NaN for that row.
forces(dx_tm1=None)[source]

Return an array of the forces exerted by marker springs.

Parameters: dx_tm1 : ndarray An array of distances from markers to their attachment targets, measured at the previous time step. F : ndarray An array of forces that the markers are exerting on the skeleton.

Notes

The forces exerted by the marker springs can be approximated by:

F = kp * dx


where dx is the current array of marker distances. An even more accurate value is computed by approximating the velocity of the spring displacement:

F = kp * dx + kd * (dx - dx_tm1) / dt


where dx_tm1 is an array of distances from the previous time step.

labels

Return the names of our marker labels in canonical order.

load_attachments(source, skeleton)[source]

Load attachment configuration from the given text source.

The attachment configuration file has a simple format. After discarding Unix-style comments (any part of a line that starts with the pound (#) character), each line in the file is then expected to have the following format:

marker-name body-name X Y Z


The marker name must correspond to an existing “channel” in our marker data. The body name must correspond to a rigid body in the skeleton. The X, Y, and Z coordinates specify the body-relative offsets where the marker should be attached: 0 corresponds to the center of the body along the given axis, while -1 and 1 correspond to the minimal (maximal, respectively) extent of the body’s bounding box along the corresponding dimension.

Parameters: source : str or file-like A filename or file-like object that we can use to obtain text configuration that describes how markers are attached to skeleton bodies. skeleton : pagoda.skeleton.Skeleton The skeleton to attach our marker data to.
load_c3d(filename, start_frame=0, max_frames=1000000000000000052504760255204420248704468581108159154915854115511802457988908195786371375080447864043704443832883878176942523235360430575644792184786706982848387200926575803737830233794788090059368953234970799945081119038967640880074652742780142494579258788820056842838115669472196386865459400540160L)[source]

Load marker data from a C3D file.

The file will be imported using the c3d module, which must be installed to use this method. (pip install c3d)

Parameters: filename : str Name of the C3D file to load. start_frame : int, optional Discard the first N frames. Defaults to 0. max_frames : int, optional Maximum number of frames to load. Defaults to loading all frames.
load_csv(filename, start_frame=10, max_frames=1000000000000000052504760255204420248704468581108159154915854115511802457988908195786371375080447864043704443832883878176942523235360430575644792184786706982848387200926575803737830233794788090059368953234970799945081119038967640880074652742780142494579258788820056842838115669472196386865459400540160L)[source]

Load marker data from a CSV file.

The file will be imported using Pandas, which must be installed to use this method. (pip install pandas)

The first line of the CSV file will be used for header information. The “time” column will be used as the index for the data frame. There must be columns named ‘markerAB-foo-x’,’markerAB-foo-y’,’markerAB-foo-z’, and ‘markerAB-foo-c’ for marker ‘foo’ to be included in the model.

Parameters: filename : str Name of the CSV file to load.
num_frames

Return the number of frames of marker data.

num_markers

Return the number of markers in each frame of data.

process_data()[source]

Process data to produce velocity and dropout information.

reposition(frame_no)[source]

Reposition markers to a specific frame of data.

Parameters: frame_no : int The frame of data where we should reposition marker bodies. Markers will be positioned in the appropriate places in world coordinates. In addition, linear velocities of the markers will be set according to the data as long as there are no dropouts in neighboring frames.