Example 21j: Fitting volume element to image-plane data where out of plane error is ignored

This example uses the command "fem fit in_plane". It is meant to be used in the following case: An initial mesh is fitted to the structure at time T0, in this example the cube. In 2D images of the structure, data points are traced between the initial state and the deformed state (T1). A point p0 at the initial state corresponds to point p1 in the deformed state. Since the image-plane is fixed in space and time, p1 may not be the material point p0 as it is likely to move out of the image-plane. p1 may rather be an approximation of the projection of the material point onto the image-plane at T1. In a standard fitting the structure would move only in the direction of the p1-p0 direction in the imaging plane and we would miss out on the out-of-plane motion. The "in_plane" option of the fit command takes care of that by ignoring any error-component that is along the image-plane normal vector given as the weights of the data point in the ipdata file.

In this example we have a cube that is purely translated dx=-0.2, dy=0, dz=0.2. The first 8 data-points landmark.ipdata are in imaging planes parallel to the xy-plane. As is seen in the target.ipdata these points miss the dz translation. The last 8 data points are parallel to the yz-plane and they thus have no dx translation. In a standard fitting procedure we would only get half of the true translation as half the points say we are moving -0.2 in x-direction and the other half says no movement in x-direction. The same is the case for the movement in the z direction. (Running this example with $nFits=1 in the com-file will produce that result.)

This is a non-linear fitting problem and it is done by running several iterations of the fit, each being a piece-wise linear fit.

Created by Espen Remme April 2003.


The comfile run by this example is as follows:

#Example_21j  Fitting volume element to image-plane data where out of plane error is ignored

fem def para;r;fitting;example;       # Declares array dimensions
fem def coord;r;rcCoord;example;      # Defines the coordinate system
fem define base;r;3Lin;example;       # Defines tri-linear Hermite basis functions

$name="cube"
fem def node;r;$name;example;         # Reads in nodal information
fem def elem;r;$name;example;         # Reads in element information
# Export original geometry to view in Cmgui
fem export node;$name as $name offset 100
fem export elem;$name as $name offset_elem 100

fem def data;r;landmark;example;      # Defines the data-points for time T0
fem def xi;c contain                  # Calculates the xi positions of the data points inside the mesh
fem def xi;w;landmark                 # Writes the xi positions to file 
fem export data;landmark as landmark offset 100

fem def data;r;target;example;        # Defines the data-points for time T1 (deformed state)
fem def xi;r;landmark                 # Read in the xi-positions to calculate error between landmark and target points
fem export data;target as target error offset 200 

fem update field from geometry        # Prepare the field variables
fem def fit;r;fitCube;example geom    # Setting the fit options
fem fit in_plane                      # execute the fit with the in_plane option, i.e. ignoring out-of-plane movement of the data-point

$nFits=5        # Set the number of fit iterations
for($n=2;$n<=$nFits;$n++)
{
  print "\n\n\************************************\n"
  print "\n\n\Fit number $n\n"
  print "\n\n\************************************\n"

  fem update node fit
  fem def data;r;landmark;example;
  $name = "newLandmark";
  fem define data;c from_xi
  fem define data;w;$name

  fem update field from geometry
  fem def data;r;newLandmark
  fem def xi;c contain
  fem def xi;w;landmark
  fem def data;r;target;example;
  fem def xi;r;landmark

  fem def fit;r;fitCube;example geom 
  fem fit in_plane
}

# Update the geometry, write it to file and export it to be viewed in CMGUI
fem update node fit 
$name = "transformed_cube"
fem def node;w;$name
fem def elem;w;$name
fem export node;$name as $name offset 000
fem export elem;$name as $name offset_elem 000

# Write the final positions of the data points to file and export them to be viewed in CMGUI
fem export data;projections as projections error offset 300 
fem def data;r;landmark;example;
$name = "finalDataPts";
fem define data;c from_xi
fem define data;w;$name
fem export data;$name as $name error offset 0


Additional testing commands:



Files used by this example are:

Name             Modified     Size

example_21j.com 07-Apr-2003 2.5k 3Lin.ipbase 02-Apr-2003 4.2k cube.ipelem 02-Apr-2003 479 cube.ipnode 02-Apr-2003 1.8k draw.com 02-Apr-2003 1.3k fitCube.ipfit 13-Apr-2007 1.6k fitting.ippara 07-Apr-2003 5.9k landmark.ipdata 02-Apr-2003 1.2k rcCoord.ipcoor 02-Apr-2003 678 target.ipdata 02-Apr-2003 1.2k test_output.com 07-Apr-2003 0

Download the entire example:

Name                      Modified     Size

examples_2_21_21j.tar.gz 14-Apr-2007 8.2k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmFailureSun Mar 6 00:04:58 20160
last breakThu Sep 27 00:20:00 20122
last successSun Feb 6 00:47:00 20111
cm-debugFailureSun Mar 6 00:04:59 20160
last breakThu Sep 27 00:20:00 20121
last successFri Feb 18 01:09:00 20111
mips-irix
cmSuccessSun Aug 19 01:29:50 20074
cm-debugSuccessWed Aug 15 01:25:13 20077
cm-debug-clear-mallocSuccessSat Aug 18 01:27:40 200711
cm-debug-clear-malloc7SuccessMon Aug 20 01:25:00 200712
cm64SuccessSun Aug 19 01:29:00 20074
cm64-debugSuccessTue Aug 21 01:22:57 20077
cm64-debug-clear-mallocSuccessThu Apr 1 10:11:55 20044
rs6000-aix
cmSuccessWed Mar 4 01:06:52 20091
cm-debugSuccessMon Mar 2 01:06:53 20091
cm64SuccessWed Mar 4 01:06:52 20091
cm64-debugSuccessTue Mar 3 01:12:04 20092
x86_64-linux
cmFailureSun Mar 6 00:01:23 20160
last breakThu Sep 27 00:23:00 20121
last successSun Mar 6 00:25:00 20110
cm-debugFailureSun Mar 6 00:01:23 20160
last breakThu Sep 27 00:24:00 20122
last successFri Feb 18 00:28:00 20111

Testing status by file:


Html last generated: Sun Mar 6 05:50:11 2016

Input last modified: Fri Apr 13 10:31:07 2007


CMISS Help / Examples / 2 / 21 / 21j