Example 219c: Fitting a prolate spheroidal surface mesh to measured data of the endocardial and epicardial surfaces.

Fitting a prolate spheroidal surface mesh to measured data of the endocardial and epicardial surfaces. 38 nodes defines an ellipsoid. The first 19 nodes defines the endocardial surface while the last 19 defines the epicardial surface. By running through the executable example file twice, first with the variable $surface = 'endo' and then with $surface = 'epi', the initial nodes are fitted to the respective surfaces. The result will be written out in files called endo_fitted.ipnode and epi_fitted.ipnode. These two files can be merged by running the command "perl createMergedNodeFile.p" from the commandline (if you have perl installed). For each fit, the result can be viewed in CMGUI by running the draw.com file.


The comfile run by this example is as follows:

#Example_219c: Fitting of surface prolate spheroidal mesh to measured data of endocardial and epicardial surfaces.

fem define para;r;heart;example
fem define coor;r;ellipsoid;example       # prolate spheriodal coords
fem define nodes;r;;example               # 38 nodes, 19 per surface
fem define bases;r;2CubicHermite;example  # bicubic in lambda
fem define ;add bases;r;2Linear;example   # bilinear in mu and theta

$surface = 'endo'                         # choose what surface to fit
#$surface = 'epi' 
fem define elements;r;$surface;example    # 6 elem circumferentially, 3 longitudinally

# Export the initial geometry for viewing in CMGUI
$file = 'heart'
fem export nodes;$file as $file
fem export elements;$file as $file
# This command is temporary until bug in CMISS is fixed:
system "perl -p -i.bak -e 'if(/theta/){s/no modify/decreasing in xi1/}' $file.exelem"

fem define data;r;$surface;example        # read in data for specified surface
fem define xi;c orthog                    # calculate projection of datapoints onto surfacemesh
fem li data err                           # list the RMS of the projection error

# Export the data with error projections for viewing in CMGUI
$file = "${surface}1"
fem export data;$file as $file error
# This command is temporary until bug in CMISS is fixed:
system "perl -p -i.bak -e 'if(/coordinates,/){s/coordinates,/RC coordinates,/}' $file.exdata"

fem define field;r;$surface;example       # create list over nodes to fit including derivatives
fem define elements;r;;example field      # set up element file for field variable
fem define fit;r;surface;example geometry # specify fit problem

#
# First fit
fem fit
fem update node scale_factor
fem update node fit

# Have to read in data again because data is changed to prolate in memory.
# Shouldn't have to do this though. Might be changed in the future...
fem define data;r;$surface;example
fem def xi;c orthog
fem li data err 

# Export the data with error projections for viewing in CMGUI
$file = "${surface}2"
fem export data;$file as $file error offset 20000
# This command is temporary until bug in CMISS is fixed:
system "perl -p -i.bak -e 'if(/coordinates,/){s/coordinates,/RC coordinates,/}' $file.exdata"

# Export fittet geometry after first fit
$file = 'heart_fit1'
fem export node;$file fit as $file offset 1000          
fem export element;$file fit as $file offset_elem 1000
# This command is temporary until bug in CMISS is fixed:
system "perl -p -i.bak -e 'if(/theta/){s/no modify/decreasing in xi1/}' $file.exelem"

#
# Second fit (if not happy with first fit)
fem define fit;r;surface;example geometry
fem fit
fem update node scale_factor
fem update node fit

# Export fittet geometry after second fit
$file = 'heart_fit2'
fem export node;$file fit as $file offset 2000          
fem export element;$file fit as $file offset_elem 2000
# This command is temporary until bug in CMISS is fixed:
system "perl -p -i.bak -e 'if(/theta/){s/no modify/decreasing in xi1/}' $file.exelem"

# Write fitted nodes to file
fem define nodes;w;"${surface}_fitted"



Additional testing commands:

fem list nodes

Files used by this example are:

Name                    Modified     Size

example_219c.com 16-Nov-2000 3.0k 2CubicHermite.ipbase 14-Nov-2000 1.5k 2Linear.ipbase 14-Nov-2000 1.1k createMergedNodeFile.p 14-Nov-2000 1.1k draw.com 22-Nov-2001 903 ellipsoid.ipcoor 14-Nov-2000 725 ellipsoid.ipelem 14-Nov-2000 11k ellipsoid.ipnode 14-Nov-2000 29k endo.ipdata 14-Nov-2000 69k endo.ipelem 14-Nov-2000 7.6k endo.ipelfd 14-Nov-2000 2.5k endo.ipfiel 14-Nov-2000 5.4k endo_fitted.ipnode 14-Nov-2000 32k endoepi_fitted.ipnode 14-Nov-2000 32k epi.ipdata 14-Nov-2000 66k epi.ipelem 14-Nov-2000 7.7k epi.ipelfd 14-Nov-2000 2.5k epi.ipfiel 14-Nov-2000 5.5k epi_fitted.ipnode 14-Nov-2000 32k heart.ippara 12-Nov-2002 5.9k surface.ipfit 13-Apr-2007 1.6k test_output.com 14-Nov-2000 15

Download the entire example:

Name                           Modified     Size

examples_2_21_219_219c.tar.gz 14-Apr-2007 60k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmSuccessSun Mar 6 00:04:25 20164
cm-debugSuccessSat Mar 5 00:20:32 201612
mips-irix
cmSuccessSun Aug 19 02:03:47 200734
cm-debugSuccessWed Aug 15 02:21:19 2007127
cm-debug-clear-mallocSuccessSat Aug 18 02:38:31 2007132
cm-debug-clear-malloc7SuccessMon Aug 20 02:37:32 2007133
cm64SuccessSun Aug 19 02:07:47 200740
cm64-debugSuccessTue Aug 21 02:19:02 2007125
cm64-debug-clear-mallocSuccessThu Apr 1 10:11:51 200454
rs6000-aix
cmSuccessWed Mar 4 01:11:25 20095
cm-debugSuccessMon Mar 2 01:15:22 200943
cm64SuccessWed Mar 4 01:11:26 20095
cm64-debugSuccessTue Mar 3 01:23:50 200946
x86_64-linux
cmSuccessSun Mar 6 00:01:02 20162
cm-debugSuccessSat Mar 5 00:02:05 20165

Testing status by file:


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

Input last modified: Fri Apr 13 10:30:42 2007


CMISS Help / Examples / 2 / 21 / 219 / 219c