Finite Element Tools

Bonemat

Back to FE Tools Home

 

These are the notes and updates to the original Bonemat software (see bonemat_v2.doc) taken from http://www.tecno.ior.it/back2net/ and adapted by Janna Balling.

 

This and other documentation can be found in /Bonemat/doc/.

The src code for these programs can be found in /Bonemat/src/. 

The compiled, usable programs can be found in /Bonemat/bin/. 

 

Contents

Main Program

bonemat dataset elements hashtable mesh types

USAGE

REQUIRED SRC FILES

PARAMETERS FILE

INPUT MESH REQUIREMENTS

DATASET OR DATAHEADER REQUIREMENTS

PSEUDOCODE

Utilities Programs

raw2SP raw2CT raw2RG

USAGE

SRC FILES

PARAMETERS

EXAMPLE OUTPUT

Running Programs

WINDOWS

UNIX/LINUX

 

Editing Programs

GUI’S (Tcl)

WINDOWS

UNIX/LINUX


 

Main Program

 

To map dataset attributes over a finite element structured or unstructured mesh.

 

 

USAGE: bonemat param_file

 

 

REQUIRED SRC FILES:

·         Main program: bonemat.cxx

·         Modules: (*.h and *.cxx)

·         mesh: to read, write and manage mesh informations.

·         elements: to perform element computations.

·         dataset: to read and manage dataset informations.

·         hashtable: to manage node keys.

·         Definitions: (*.h)

·         types: defines ID_TYPE as unsigned int.

 

 

PARAMETERS FILE:

 

REQUIREMENTS:

 

input mesh 

input mesh file (lsdyna .k format) location

dataset or dataheader

input dataset or dataheader location (output from Utilities Program)

output mesh

output mesh file location

output log printelements

output statistical log file location   printelements= if present, statistics for each element will be printed

nodes  elements

number of nodes and elements in input mesh

elementNodes

number of nodes per each element

ROa  Rob

Apparent density linear equation parameters

Ea  Eb  Ec

Young module power equation parameters

steps

number of integration steps for each direction inside an element

bins Egap gap

---or---

bins userbin num

   mat  in

   mat  in

   ...

userbin end

gap= size of modulus gap for equal material distribution

 

num= number of user defined materials

  mat= material number  in= max intensity value of that material

  list of user defined materials

 

OPTIONS:

 

cortical mat in

any elements with intensity values >= in(intensity) will be assigned to mat(material number)

minval mat in

any elements with intensity values < in(intensity) will be assigned to mat(material number)

testlog file

output file location for list of intensity values of the corners of the dataset.

 

 

INPUT MESH REQUIREMENTS:

 

Mesh files must be in lsdyna (.k) format with tabs (not commas). 

 

Supported element types (number of elementNodes) are:

·         Tetrahedron - 4

·         Hexahedron - 8  (Janna tested this case only)

·         Wedge - 6

·         Quadratic tetrahedron -10

 

DATASET OR DATAHEADER REQUIREMENTS:

 

Dataset files can be represented as ASCII, BINARY, or BINARY_FILE (Janna tested this type only) format.  See Utilities Programs for dataset information.

 

 

PSEUDOCODE:

§         Parameters file reading

§         Mesh reading

§         Dataset reading

§         Compute modulus for each element in mesh

               

HU=integrated average intensity value for the current element

                where:

                                (r,s,t) is the local reference system centered at p0 node

                               

                               

                               

                if ( doCortical && HU>=corticalHU)

                               

                               

                               

                else

                               

                               

§         Compute material bins and assign a material to each element

sort elProp by E in decreasing order

                if(doUserBins)

                                if  ( doCortical && E>= corticalE )

                                                assign to cortical mat

                                if ( doMin && HU<minHU )

                                                assign to min mat

                                else

                                                assign to mat for given user defined material bin

                else

                                if  ( doCortical && E>= corticalE )

                                                assign to cortical mat

                                if ( doMin && HU<minHU )

                                                assign to min mat

                                else

                                                assign to mat with given Egap width for each material bin

§         Write mesh with modulus values for shell thicknesses

 

Utilities Programs

 

To convert raw data set to "vtk like" format.

 

USAGE:

raw2SP infile outfile xdim ydim zdim xspc yspc zspc xorig yorig zorig data_type format

                raw2CT infile outfile xdim ydim zdim xspc yspc  xorig yorig locfile data_type format

                raw2RG infile outfile xdim ydim zdim xfile yfile zfile data_type format

 

 

SRC FILES:

·         Main program: raw2SP.c

·         Main program: raw2CT.c

·         Main program: raw2RG.c

 

PARAMETERS:

·         Raw dataset

The raw data needs to be in little endian format (use ImageJ to convert). 

 

·         Data type

·         unsigned char

·         short

·         unsigned short (Janna tested this case only)

 

·         Format

·         ASCII

Prints parameters header followed by data in ascii format

·         BINARY

Prints parameters header followed by data in binary format

·         BINARY_FILE  (Janna tested this case only)

Prints parameters header followed by file location of raw data in binary format

 

·         SP (structured points) (Janna tested this case only)

Uniform voxels in x, y, and z directions. 

·         Dimensions: xdim ydim zdim

·         Spacing: xspc yspc zspc

·         Origin: xorig yorig zorig

 

·         CT (CT scan)

Uniform voxels in x and y directions with varying z slice thicknesses.

·         Dimensions: xdim ydim zdim

·         Spacing: xspc yspc

·         Origin: xorig yorig

·         Locations: z0 z1 ... zzdim-1

 

·         RG (rectilinear grid)

Varying voxels x, y, and z directions.

·         Dimensions: xdim ydim zdim

·         X coordinates: x0 x1 ... xxdim-1

·         Y coordinates: y0 y1 ... yydim-1

·         Z coordinates: z0 z1 ... zzdim-1

EXAMPLE OUTPUT:

 

Heading

# vtk DataFile Version 2.0

Title

Output from C:/Bonemat/raw2SP.exe

Format

BINARY_FILE C:/mydata/data.raw

Voxel Info

DIMENSIONS 512 512 223

SPACING 0.439450 0.439450 0.600000

Origin 0.000000 0.000000 0.000000

Number Voxels

POINT_DATA 58458112

Data Type Info

SCALARS scalars unsigned_short

Lookup Info

LOOKUP_TABLE default

 

Running Programs

 

One of the three Utilities Programs should be used to first create a dataset or dataheader.  The Bonemat Program can then be used with a given mesh to calculate the elastic modulus for each element of the mesh based on the intensity values of the dataset.

 

 

WINDOWS:

·         Graphic User Interface (GUI)

·         The easiest way to run the programs is to use the GUI provided in /Bonemat/ with the *.tcl file extension.

·         In order to run these, you need to download and install Tcl/Tk and then open the GUI with /Program Files/Tcl/bin/wish84.exe (right click … open with->choose program … browse).  You can check the “Always use the selected program to open this kind of file” box so that you can double click to open the GUI from now on.

·         Once you open the GUI, it’s self explanatory.  Fill in the parameter values, Save them if applicable, and hit Run.

·         Command line

·         You can follow the USAGE directions for each program to run it from the command line (Start -> all programs -> accessories -> command prompt). 

·         You can also set up your user variables so that you can use the program command in any directory.  To do this, right click on My Computer.  Choose Properties.  Pick the Advanced tab at the top of the window.  Click on the Environment Variables button.  Under User variables (or System variables depending on which user), highlight Path then click on the Edit button.  Add the path to /Bonemat/bin/ on the end and click OK, OK, OK to finish.  Now you can type the program name at the command prompt and it will work.

·         Automatic bat files

·         This is similar to the command line usage.  Bat files for each program can be found in /Bonemat/bat/.  These can be edited (right click … edit) to execute the program on the command line with the given parameters (you will need to change these). 

·         This is incredibly useful if you have a need for running the program multiple times but you don’t want to sit and wait for the program to run each time.  Just copy the first line and change the parameters to execute the program again.

 

UNIX/LINUX:

·         Graphic User Interface (GUI)

·         The easiest way to run the programs is to use the GUI provided in /Bonemat/ with the *.tcl file extension.

·         In order to run these, you need to download and install Tcl/Tk and then open the GUI with the command:

>>           wish *.tcl

If you do not have the wish command, look for it in /Tcl/bin/wish84.exe and set your .aliases file to point to it.

·         You can set up your .aliases file to run each GUI with something like:

alias bonematGUI   ‘wish /Bonemat/bonemat.tcl’

alias raw2SPGUI    ‘wish/Bonemat/raw2SP.tcl’

·         Once you open the GUI, its self explanatory.  Fill in the parameter values, Save them if applicable, and hit Run.

·         Command line

You can follow the USAGE directions for each program to run it from the command line. 

 

Editing Programs

 

GUI’S (Tcl):

·         You can use your favorite text editor to make changes to the Tcl code found in /Bonemat/ with file extension .tcl.  For help with Tcl, I recommend the Tcl Manual and this Tcl GUI Tutorial I found (use the Contents link at the bottom). 

 

·         Make sure that you keep the parameters for executing the program in the “run” procedure compatible with the source code.

 

WINDOWS:

·         The source code can be found in /Bonemat/src/.  If you change the parameters for the main function, be sure to change the GUI to match it (see above).

 

·         After editing the source code, you can use the make.bat file to automatically compile all of the code.  You will need to edit the paths in this file to point to your Visual Studio files (just search for a file named something like vcvars*.bat).  If you don’t have Visual Studio, your guess is as good as mine to make the compiler that you do have work.

 

·         Once the source code has been compiled, move the newly created *.exe file to /Bonemat/bin/ so that the GUI will still work.

 

UNIX/LINUX:

·         The source code can be found in /Bonemat/src/.  If you change the parameters for the main function, be sure to change the GUI to match it (see above).

 

·         It is good to note that the headers for the unix/linux version of the src code files have been changed from the windows versions so that they will compile without Visual Studio.

 

·         After editing the source code, you need to compile the code in /Bonemat/src/ and save the output in /Bonemat/bin/.  It is easiest to do this in the /Bonemat/ directory.  On Unix the command is:

>>           CC –LANG:std src/program.cxx –o bin_Unix/program –lm 

On Linux the command is:

>>           g++ src/program.cxx –o bin_Linux/program

 

Created by Janna Balling j.balling@utah.edu

     For Andrew Anderson at Musculoskeletal Research Laboratories

University Of tah