Personal tools
You are here: Home / cmgui / Wiki / Fit the muscles (irregular shapes)
Navigation
Log in


Forgot your password?
 

Fit the muscles (irregular shapes)

  • ** First create nodal points **
  • Read in the exdata file of the object that is to be fitted, e.g. Medial Rectus Muscle.
  • Create a group to save the new nodal points in, e.g. MedRect with "gfx create dgroup MedRect".
  • Select the data points in the graphical window that would be converted to nodal points when we want to create elements for fitting.
  • Add the selected data points into the group previously created using "gfx modify dgroup MedRect add selected".
  • Write out a file e.g. medrect.exnode of the data points chosen as nodal points with "gfx write data group MedRect medrect.exnode".
  • Write out a file e.g. medrect.exdata of the data points chosen with "gfx write data group MedRect medrect.exdata". This would be used if you need to modify the nodal points in the future because there's not enough nodes or they are not correctly spaced etc.
  • To remove nodes that were selected incorrectly... "gfx mod dgroup MedRect remove selected', and remember to write the file again.
  • ** then create elements **
  • using the new exnode files that has the nodal points selected from the previous steps.
  • Select "Element Creator" under the "Model" menu.
  • Put into "region" the name of the mesh, e.g. MedRect from above. Choose dimension 2 or 3 depending if you are creating 2D elements (a face), or 3D elements (a cube).
  • Toggle on "Create elements" once all settings are correct, then in the Graphics Window, toggle on "Node" and create elements accordingly.
  • There's this standard convention of creating elements. The first two points you click, 1 & 2 will define the xi 1 direction (from point 1 to 2), and points 1 and 3 will determine the xi 2 direction (from point 1 to 3). It's probably important to get it right when you first create the elements otherwise you might have to keep redoing it.
  • Once the elements are created nicely, then use "gfx write element group MedRect medrect.exelem" to write it out into an exelem file.
  • To remove any wrong element, use "gfx destroy element selected" or "gfx destroy element (no.)"
  • Sometimes once all this is done, you might want to move the nodes so that the element looks nicer and hugs the datapoint better, do this by clicking "Node" at the Graphics Window twice. And toggle on "Edit", once that's done you will be able to move the nodal points and align everything better. Remember to write out the exelem, exnode and exdata file again.
  • You will probably need to renumber the nodes and the elements, otherwise later on there'll be some problems. There are different ways to do this:
  1. you can use "gfx change_id element_off 1 node_off 1 ".
  2. Renumber the elements by the xi direction, go to "Reordering Elements By Xi":http://www.cmiss.org/cmgui/wiki/ReorderingElementsByXi.
  3. There's also an example that you can use to renumber both the nodes and elements using the xi coordinates in the mesh, "Renumber Mesh":http://cmiss.bioeng.auckland.ac.nz/development/examples/a/renumber_mesh/
  • ** now can do fitting **
  • Convert exnode and exelem files of initial mesh into ipfiles by using cmgui 1_convertex2ip.com

  • At the moment, the ipbase and ipelem file generated are incorrect, so must modify accordingly.

    in ipbase, ' The interpolant in the Xi(1) direction is {1} ' should be 5, if you're using 3D mesh, and ie: cubic hermite. in ipelem, for each element number, ' The number of geometric Xj-coordinates is {3}: 3 '

  • Add ipfit file, and change weighting of the fits and elements to fit.

    Enter element #s/name [EXIT]: 1..144
    The 5 weights on derivs wrt Xi_1/_11/_2/_22/_12 are [prev]:
        1E-1 1E-1 1E-1 1E-1 2.5E-1
    Enter element #s/name [EXIT]: 0
    
  • Convert the datapoints into ipdata to use in fit with perl 2_exnode2ipdata.pl Although the name is exnode2ipdata, but it reads in exdata instead. If you open the perl script, the top will show the usage of it.

    #Usage: perl exnode2ipdata.pl < test.exnode > test.ipdata

  • Modify 3_six_fit.com accordingly so cm reads in the correct initial mesh, datapoints and output results correctly.

  • Draw the fitted muscle with 4_draw.com

    ** NB: ** while in fitting, the initial xi projections are calculated and sometimes they aren't projected onto the correct surface (esp. on the ends of the muscle when it's thin). To fix this I need to manually change the ipxi file so that the nodal points project to the right face. To do this, we need to read in the initial ipdata and export it as exdata2 (because initally the exdata files are all numbered randomly). Then read into cmgui the new exdata2 file and inital mesh, choose the data pointa and the element it is suppose to project to and change the ipxi file (the element number is changed so the projection of the elements and it's corresponding datapoints are correct).

    Make sure that from now on, in the fitting.com, the ipxi is read in, and not calculated and write out anymore, otherwise all the hard effort of manually modifying the ipxi file will be lost.

  • ** create volumes for the muscles **

The muscle that was fitted above, is only a muslce with no elements on the inside, ie: it is only a surface mesh. To convert this into volume elements, Shane had written a code, fittedsurfacetovolume2.pl . This reads in the fitted surface muscle elements and create nodal points in the middle of the mesh so that it forms a volume mesh. The start node that user to input has to be selected on a collapsed node. This is specific in my case because I had run refine.com on my muscle first to create extra elements at the top and bottom of the muscle and these extra nodes created are collapsed nodes.

<a href="1_convertex2ip.bob">1_convertex2ip.bob</a>

<a href="2_exnode2ipdata.pl">2_exnode2ipdata.pl</a>

<a href="3_six_fits.com">3_six_fits.com</a>

<a href="4_draw.com">4_draw.com</a>

<a href="fittedsurfacetovolume2.pl">fittedsurfacetovolume2.pl</a>