Child pages
  • z_*OBSOLETE* Calculate Rigid Body Motion in Matlab

This page was moved to

Click in the link above if you are not automatically redirected in 10 seconds.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »


README for leastSquaresRigidBodyMotion

what you need:
1. a markercoordinates.csv file 3 columns for each marker (xyz coordinates)
2. an *xyzpts.csv file from digitized data

Note: The number of columns must be a perfect match between the two files.
if you have 10 markers - you must have 30 columns in both files.

1. type rigidBodyMotionFromMarkers at the matlab prompt
2. select *xyzpts.csv file
3. select markercoords.csv file
4. type the number of bones in the input box
5. select the markers associated with each bone
6. save the file output.
7. To use this file in maya, you will
1. select the bones in the same order used above.
2. type impMatrix at the command prompt
3. select the file saved in step6

Note: After you run through steps 1-6 in matlab, the variables markerIdx and ct are stored in the workspace. If you need to do subsequent reconstructions, simply type rigidBodyMotionFromMarkers(markerIdx,ct) at the matlab prompt. This will elimate steps 3-5.

Despite the high precision of the biplanar fluoroscopy system, digitized data contain errors compounded from several potential sources. (1) The undistortion relies on accurately determining the centroids of the grid. Image quality and/or imperfection in flattening the grid may cause small error. (2) camera calibration provides a "best estimate" of camera position based on digitized clicks on the image and the "true" measured distances of the points on the calibration object. Digitizing error and/or offsets in the calibration object point distances can also add uncertaintly. (3) Digitizing, whether automated or by hand can also add error and finally (4) 3D reconstruction between the two cameras may also add error.

Even very small error for individual markers can cause larger and more noticeable errors in rigid object orientation. This is clearly visible as "jittery bones" when raw data are used to drive animations.

Two Smoothing Steps

1. "Smart" smoothing. - using "measured" intermarker distances from CT data to constrain digitized data

2. Standard smoothing - butterworth filter to remove high frequency noise from bone orientations

"Smart" smoothing - basic instructions

What you need:

  • CT Marker locator coordinates (from the "Create a Setup Scene" step)
  • xyzpts file from DLTdataviewer
  • smoothData.m, rigidFilter2.m, and rigidOrientation2.m, contained within the Xray_project folder. click here to download XrayProject.

What to do:

  • Open matlab and type smoothData
  • You will be asked for the [prefix]xyzpts file. Select it.

  • You will then be asked for the CT Marker coordinate file (from the "Create a Setup Scene" step). Select it.
  • Input how many bones
  • Select the markers associated with bone1 and click OK
  • Repeat last for all other bones
  • Save the output file (default is [prefix]xyzpointsBones.csv)

What you get:

  • The .csv file contains 6 columns per bone. 3 translations and 3 rotations
  • This format can be read in maya using imRg.
  • You will probably get a less jittery but not perfect animation using only this smoothing step. Continue to Standard smoothing for best results.

Standard Smoothing

In Matlab:

  • import your [prefix]xyzpointsBones.csv bones file

  • you will have 3 variables, colheaders, data, and textdata
  • type: plot(data)
  • click the Insert Legend button
  • pick a data column with some cyclic curves (the legend will allow you to match the column number with the color of the line)
  • type: plot(data(:,4)) %the number 4 being an example of the data column chosen)
  • There is probably still a bit of high frequency noise on the curve - we'll use a butterworth filter to smooth it out a touch more
  • use the following function: dataSmooth = tybutter(data,f,g) %f =  cutoff frequency and g = recording frequency
    • example: dataSmooth = tybutter(data(:,4),50,250)
  • type: hold on
  • type: plot(dataSmooth,'r-')
  • look at figure1. It should have a red curve showing the effect of the chosen filter cutoff against the original data
  • generally the filter cutoff ranges between 10 and 80, you just have to try several cutoff frequencies until you find the one that appears to get rid of the high frequency jitters without changing the general shape of the curve
  • Once you have a filter that you like, apply it to all of the data
  • example: dataSmooth = tybutter(data,50,250)
  • dataSmooth should have the same dimensions as data
  • Save your new data using csvWithHeaders
    • csvWithHeaders('fileName.csv', dataSmooth, colheaders)
  • No labels