Finite Element Modelling

From bone.wiki
Jump to navigation Jump to search

Scanco Finite Element Modelling

[edit]

We typically use our own FE solver, faim. This documentation may however be useful if you want for example to make comparisons with Scanco's FE solver.

Scanco FE Reference

[edit]


Return to Contents or Return to Main Page

Run FE code on VMS system

[edit]

Read the PDF file that is located in the "documents" directory for documentation and pick a problem number and output type. Make sure that your image is suitable for the slected analysis (see page 7 in the Scanco FE guide). You can use your segmented AIM from morphological analysis for FE analysis.

Edit the IPl file used in batch job mode DISK1:[MICROCT.EVAL]IPL_FE_VM.COM on percy to include the desired analysis, e.g.:

FE_PROBLEM :== 9 !combination of 1 - 6
FE_PAR_NO :== 42 ! von Mises equivalent stress

Start the evaluation as a batch job in queue SC3309_FE

$ fem DISK3:[MICROCT.PROJECTS.DEFROM.MODELS]SHAM_A12_W12_SEG.AIM

Look at the log file SYS$SCRATCH:SHAM_A12_W12_SEG_FE.LOG during execution to verify the process.

The job is submitted using:

SUBMIT/NOPRINT/NOTIF/LOG=SYS$SCRATCH:SHAM_A12_W12_SEG_FE.LOG/QUE=UCT_FE_QUEUE UE:IPL_FE_VM.COM/PARA=DISK3:[MICROCT.PROJECTS.DEFROM.MODELS]SHAM_A12_W12_SEG.AIM

You can copy the IPL_FE_VM.COM to your project directory and use the above command to submit it.

Alternatively, FE analysis can be run interactively

$ iplfe


Return to Contents or Return to Main Page

FAIM Finite Element Solver

[edit]

This is the lab finite element software.

The lab uses Numerics88 Solutions Faim finite element software. This software was developed in the lab and is now sold commercially.

The manual for Faim software is available in these formats:

FAIM is installed in the lab on the following machines:

  • mighty-mac, OS-X, Xeon E5462 (2.8GHz; 4 cores + HT), 32GB RAM
  • mavis, OS-X, 8 cores, 64GB RAM
  • toaster, GNU/Linux, Xeon X5650 (2.67GHz; 6 cores + HT), 24GB RAM, three Tesla C2045 GPUs


Return to Contents or Return to Main Page

FE Tutorial

[edit]


Return to Contents or Return to Main Page

Prepare AIMs for FE Analysis

[edit]

This is the first steps for processing microCT data for FE analysis.

Purpose

[edit]

This is a tutorial that will help you create the AIM file that you want to run through an FE Analysis.


Return to Contents or Return to Main Page

Create Original AIM File from Raw Data

[edit]

After you finish scanning, wait for the reconstruction to be completed. In a VMS terminal, type in "mcutout" to open the uCT Evaluation Program. If you are doing this remotely, open Terminal and connect to SCEVAL with the "invivo" username using ssh:

$ ssh -l invivo -X sceval.ucalgary.ca

Then type in "mcutout" once it has logged you in.

Open the desired measurement, and use the selection options on the left to create your contours. Click "Tasks" --> "Contouring" for more contouring options (if you want to apply the contours to all slices, for example).

Then Click "Tasks" --> "Evaluation 3D". Select a Task/Evaluation (just choose the top one on the list unless you are segmenting this sample for a second time) and decide on the optimal lower threshold, sigma, and support (leave upper threshold at 1000). Now save the gobj file by going to "File" --> "Save GOBJ as", selecting the required GOBJ file and clicking "OK". Now click "Start Evaluation" and wait for the evaluation to be completed. You may close uCT Evaluation Program now.

In the VMS terminal, go to the sample's directory. For example, if it was sample number 4800 and measurement number 10950, type:

$ cd ud *4800 10950

In here, you will find 7 files, two of those being the GOBJ file and the AIM file. They will have file names such as:

C0010659_1.GOBJ and
C0010659_1.AIM (you do not need the *_SEG.AIM file).


Return to Contents or Return to Main Page

Copy to Projects Disk

[edit]

Once your AIM file has been created, you want to copy that and your GOBJ file to the Projects Disk. In your folder (cd ur conway, for example), create a MODELS directory:

$ create/dir [.MODELS]

In a new Terminal, go back to your sample directory on the Data disk (cd ud *4800 10950). Copy over the AIM and GOBJ files to your MODELS directory (you can get the path of the MODELS directory by typing "dir" into the terminal when you are in that directory:

$ copy C0010659_1.GOBJ DISK5:[BONELAB.PROJECTS.CONWAY.MODELS]
$ copy C0010659_1.AIM DISK5:[BONELAB.PROJECTS.CONWAY.MODELS]

Now rename those files to something appropriate, but MAKE SURE THEY HAVE THE SAME ROOT NAME. For example:

$ rename C0010659_1.GOBJ SAWBONE401.GOBJ
$ rename C0010659_1.AIM SAWBONE401.AIM

Do this for all your samples and keep the names similar (for example, the next sample might be called SAWBONE402.AIM).


Return to Contents or Return to Main Page

Create a Script to Make an AIM file for FE Analysis

[edit]

You will need to create a script file that performs all the IPL commands to create the constructed AIM file. Place all your script files in a directory called COM in your folder on the Projects disk. If you are currently in the MODELS directory, type:

$ cd ..                   (to go up one directory)
$ create/dir [.COM]       (to create the directory)
$ cd com                  (to change to the COM directory)

The program used to write IPL scripts is called EVE and their extensions are ".COM". To create a new EVE file, simply type:

$ eve filename.com

If you are doing this remotely, you will not be able to edit the file easily until you type "@eveconfig" into the command line at the bottom of the screen and press enter.

In this file (which I have called IPL_SAWBONE_I.COM), you will:

  • Define inputs
  • Start up IPL
  • Read in and scale your original AIM file
  • Segment the screw
  • Segment the bone
  • Construct the final AIM file

Examples of scripts can be found in:

$ cd ur conway com


Return to Contents or Return to Main Page

Define inputs

[edit]

This section is for defining constants that will be used throughout the script. Mainly, it consists of the scale factor, the values that the screw and bone will be set to, threshold/sigma/support values for the screw, inner bone and outer bone, dilation distances, and filenames.

The filenames are defined by the name of the input file. For example the input GOBJ file will be chosen by deleting the ".AIM" section off of the input AIM file and adding ".GOBJ" to the end. This is why it was important to keep the root of the AIM and GOBJ filenames the same when copying them over to the Projects disk.

Be aware that when adding lines, you must enter a dollar sign ($) at the beginning of each line for it to read when the file is executed. To comment out a line add an exclamation mark as well, so:

$! This is a comment and will not do anything when the script is executed. The next line is not a comment.
$  threshold = 30


Return to Contents or Return to Main Page

Start up IPL

[edit]

IPL does not require a dollar sign ($) before a command. To write a comment put an exclamation mark (!) at the beginning of the line.

To run IPL, type:

$ ipl_batch

Now any commands after this do not require a dollar sign ($).


Return to Contents or Return to Main Page

Read in and Scale your Original AIM File

[edit]

In IPL, the general format is as follows (using the read command as an example):

!
/read
   name           in
   filename       "input_aim_file
!

The "/read" is the command, "name" and "filename" are the inputs that need to be assigned variables for the "read" command. "in" is the variable name that corresponds to the "name" input. " "input_aim_file " is the variable name that corresponds to the "filename" input. The reason for the quotation mark in " "input_aim_file " is to call on it from above, as it was defined in the "Inputs" section of the script.

TO GET HELP ON A COMMAND, SUCH AS READ, TYPE "HELP READ" WHEN YOU ARE RUNNING IPL INTERACTIVELY (OPENING IPL IN A TERMINAL).

The steps for reading and scaling the AIM file are as follows:

  • Use "read" to read the input AIM file to a variable called "in".
  • Use "gobj_maskaimpeel_ow" to apply the GOBJ file to the aim (applies a value of 0 to all voxels outside the contours you made).
  • Use "bouding_box_cut" to make sure the dimensions of the file are as small as possible (as close to the voxels with values as possible).
  • Use "scale" to scale down the file and reduce the memory required.
  • Use "write" to write the final product to a file for viewing.

It is best to delete IPL variables that are no longer in use. Eg: You input "in" for the "scale" command, and the output variable is "out". You don't need the "in" variable anymore, so use the "delete" command after the "scale" command to get rid of it.


Return to Contents or Return to Main Page

Segment the Screw

[edit]

In this section, the screw will be segmented out, dilated and written to file:

  • Use "seg_gauss" to segment out the screw (the screw has a much higher threshold than the bone, so if you use a high lower threshold this command will output a variable that has no bone in it).
  • Use "dilation" to dilate the screw by a few voxels (this is done because when metal gets scanned, there is noise created, and a glow appears around the screw, so we are just considering this glow as the screw).
  • Use "cl_ow_rank_extract" to delete any unwanted stray parts (if there is a disconnected piece that shouldn't be there, this command will clean that up).
  • Use "write" to write the screw variable to a file.

Don't forget to delete any unneeded IPL variables again.


Return to Contents or Return to Main Page

Segment the Bone

[edit]

For Regular Sawbone AIM Construction

[edit]

Continuing from the last section, we now want to make one file that contains only bone that surrounds the screw, and one file that contains the rest of the bone. These files cannot have the screw in them either. These two sections of bone will be segmented differently because of noise from the screw that affects the bone closer in.

  • Use "dilation" to dilate the screw to the boundary between close bone and outside bone.
  • Use "set_value" to change the value of the screw file (the one that is just dilated to the glow distance) to -127.
  • Use "add_aims" to add the screw file (that is -127) to the dilated screw file (this will create a file that is a ring with a hole in the middle).
  • Use "write" to write this ring file to file (it will be used as a GOBJ file to separate the close bone from everything else).
  • Use "copy" to make a copy of the original input AIM file.
  • Use "gobj" to apply the ring file as a GOBJ to the copied input AIM file.
  • Use "seg_gauss" to segment the ring of bone close to the screw.
  • Use "write" to write the segment bone to file.
  • Use "invert_ow" on the dilated screw file to make give voxels with values of 0 a value of 127 and all voxels with values of 127 a value of 0.
  • Use "write" to write this inverted file to file to be used as a GOBJ to separate the rest of bone away.
  • Use "copy" to make another copy of the input AIM file.
  • Use "gobj_maskaimpeel_ow" to mask the copy with the mask you just made.
  • Use "seg_gauss" to segment just the bone away from the screw.


Return to Contents or Return to Main Page

For Position and Angle Analysis

[edit]

Having scanned a sample without any screw or drill hole in it, create an AIM and GOBJ for it as explained above. Now we want to segment it similar to the "Regular Sawbone AIM Construction":

  • Use "read" to read in the bone file.
  • Use gobj" to apply its corresponding GOBJ file.
  • Use "bound" to cut the bounds down to where there are voxels with values.
  • Use "scale" to scale it down by a factor of 3, matching the resolution of the screw.
  • Use "seg_gauss" to segment the bone with threshold values that are similar to the values used for segmenting bone away from the Al.
  • Use "write" to write the bone variable to file.


Return to Contents or Return to Main Page

Construct the Final AIM File

[edit]

For Regular Sawbone AIM Construction

[edit]

Here, we will add the bone that is close to the screw with the rest of the bone and then add the screw to make the final construct.

  • Use "add_aims" to add the outside bone to the closer bone to construct the complete bone.
  • Use "cl_rank_extract" to clean up any lose pieces.
  • Use "write" to write the complete bone to file.
  • Use "set_value" to set the value of the screw (to 90 in my case) and then do it again to set the value of the bone construct (to 127 in my case).
  • Use "add_aims" to add the screw and the complete bone together.
  • Use "write" to write the construct to file for viewing.

To close IPL and finish the script do the following (shown below is the last command and how to close IPL and finish the script):

!
  /write
    -name             construct
    -filename         "construct_file
    -compress-type    bin
    -version_020      true
!
..
$!
$  write sys$output "Finished."
$  exit
[END OF FILE]

The ".." closes IPL and the rest is just finishing the script.


Return to Contents or Return to Main Page

For Position Analysis Only

[edit]

Before we actually construct the bone and screw, we need to exit IPL (using .. as shown directly above) and find the positions and dimensions of the screw and bone. Below is how it is done:

$!                          PART II : FINDING SCREW AND BONE DIMENSIONS AND POSITION
$! ---------------------------------------------------------------------------------------------------
$!
$   aix == "$UT:D3_IO_EXAMINE.EXE"
$   PIPE AIX 'sawbone_file' | SEARCH SYS$PIPE "!> Dim"| (READ SYS$INPUT LINE ; DEFINE/JOB LINE_LOG &LINE)
$   line_sym = f$trnlnm("line_log")
$   dimxbone = f$extract(37,3,line_sym)
$   dimybone = f$extract(45,3,line_sym)
$   dimzbone = f$extract(53,3,line_sym)
$   pipe aix 'screw_file' | search sys$pipe "!> Dim"| (read sys$input line ; define/job line_log &line)
$   line_sym = f$trnlnm("line_log")
$   dimxscrew = f$extract(38,2,line_sym)
$   dimyscrew = f$extract(46,2,line_sym)
$   dimzscrew = f$extract(53,3,line_sym)
$   xpos = dimxbone/2 - dimxscrew/2 + changex
$   ypos = dimybone/2 - dimyscrew/2
$   zpos = 60
$!

AIX is a VMS command that shows the dimensions of a file. What this section does, is look for where "!> Dim" is in the AIX file and extract a certain number of characters starting at a certain character. For example, dimxbone takes 3 characters starting from the 37th character in that line.

Then the x-, y-, and z-positions are found by looking at the dimensions of the bone and placing the screw somewhere in the x-y plane and raising a bit in the z plane.

Now start up IPL again (using $ipl_batch).

  • Use "read" to read in the screw file that was created earlier.
  • Use "read" to read in the bone file that was created earlier.
  • Use "header" to position the screw at (xpos, ypos, zpos).
  • Use "header" to position the screw at (0, 0, 0).
  • Use "write" to write the new screw variable to file.
  • Use "copy" to make copy of the bone file you just read.
  • Use "gobj" to mask the copy of the bone file with the new screw file you just wrote. This creates bone in the shape of the screw.
  • Use "subtract" to subtract the screw-shaped bone from the original bone file you read in just above. This essentially creates a sample of bone that has a hole drilled in it.
  • Use "set" on the screw and the drilled bone to set the value of the screw and bone.
  • Use "add" to add the screw to the drilled bone.
  • Use "write" to write the construct to file.

Then close IPL and end the file, as shown in the previous section.


Return to Contents or Return to Main Page

For Angle Analysis Only

[edit]

Before we actually construct the bone and screw, we need to exit IPL (using .. as shown directly above) and find the positions and dimensions of the screw and bone. Below is how it is done:

$!                          PART II : FINDING SCREW AND BONE DIMENSIONS AND POSITION
$! ---------------------------------------------------------------------------------------------------
$!
$   aix == "$UT:D3_IO_EXAMINE.EXE"
$   PIPE AIX 'sawbone_file' | SEARCH SYS$PIPE "!> Dim"| (READ SYS$INPUT LINE ; DEFINE/JOB LINE_LOG &LINE)
$   line_sym = f$trnlnm("line_log")
$   dimxbone = f$extract(37,3,line_sym)
$   dimybone = f$extract(45,3,line_sym)
$   dimzbone = f$extract(53,3,line_sym)
$   pipe aix 'screw_file' | search sys$pipe "!> Dim"| (read sys$input line ; define/job line_log &line)
$   line_sym = f$trnlnm("line_log")
$   dimxscrew = f$extract(38,2,line_sym)
$   dimyscrew = f$extract(46,2,line_sym)
$   dimzscrew = f$extract(53,3,line_sym)
$   xpos = dimxbone/2 - dimxscrew/2
$   ypos = dimybone/2 - dimyscrew/2 + changey
$   zpos = 122 + changez
$!

AIX is a VMS command that shows the dimensions of a file. What this section does, is look for where "!> Dim" is in the AIX file and extract a certain number of characters starting at a certain character. For example, dimxbone takes 3 characters starting from the 37th character in that line.

Then the x-, y-, and z-positions are found so that no matter what the angle of insertion of the screw, the same point on the screw always intersect the top of the bone in the centre of the x-y plane.

Now start up IPL again (using $ipl_batch).

  • Use "read" to read in the screw file that was created earlier.
  • Use "read" to read in the bone file that was created earlier.
  • Use "header" to position the screw at (xpos, ypos, zpos).
  • Use "header" to position the screw at (0, 0, 0).
  • Use "turn_3d" to rotate the screw in the y-z plane.
  • Use "write" to write the rotated screw variable to file.
  • Use "copy" to make copy of the bone file you just read.
  • Use "gobj" to mask the copy of the bone file with the rotated screw file you just wrote. This creates bone in the shape of the rotated screw.
  • Use "subtract" to subtract the screw-shaped bone from the original bone file you read in just above. This essentially creates a sample of bone that has a hole drilled in it at an angle.
  • Use "set" on the screw and the drilled bone to set the value of the screw and bone.
  • Use "add" to add the screw to the drilled bone.
  • Use "write" to write the construct to file.

Then close IPL and end the file, as shown in the previous section.


Return to Contents or Return to Main Page

Run the Script to Produce the AIM File

[edit]

This may seem ridiculous but it is easiest to create another script that will run the script you just wrote. So in the Terminal, open an EVE file called something like "submit_sawbone.com".

Before you write the script, create a directory in your Projects directory alongside MODELS and COM, called LOG. Here is where the log files get saved to. It goes through each command that IPL did and you can see whether or not each command got executed correctly.

Here is an example of how it should look (the example below shows you how to apply the script to more than one sample at a time, although this is not necessary):

$  SUBMIT/NOPRINT/QUE=SYS$FAST/PRIORITY=170/NOTIFY -
   DISK5:[BONELAB.PROJECTS.CONWAY.COM]IPL_SAWBONE_I.COM -
   /PARAMS=(DISK5:[BONELAB.PROJECTS.MODELS]SAWBONE401.AIM) -
   /LOG=DISK5:[BONELAB.PROJECTS.CONWAY.LOGS]IPL_SCREW_SAWBONE401.LOG
$  SUBMIT/NOPRINT/QUE=SYS$FAST/PRIORITY=170/NOTIFY -
   DISK5:[BONELAB.PROJECTS.CONWAY.COM]IPL_SAWBONE_I.COM -
   /PARAMS=(DISK5:[BONELAB.PROJECTS.MODELS]SAWBONE402.AIM) -
   /LOG=DISK5:[BONELAB.PROJECTS.CONWAY.LOGS]IPL_SCREW_SAWBONE402.LOG
$ exit
[END OF FILE]

Line 1: Tells it what queue to put the process into, and what priority to give it.

Line 2: Tells it what script to run and its path.

Line 3: Gives the parameters of the script. If you need more parameters, just enter them before the closing round bracket, and separate parameters with commas.

Line 4: Tells it where to write the log file to and what name to give it.

The hyphens at the end of each line just tells the script that it is actually all on the same line, but it is easier to write it in separate lines.

To run this script, in the terminal, type:

$ @submit_sawbone.com

All the files get written to the directory that you pulled the original AIM file from (in this case to the MODELS directory).


Return to Contents or Return to Main Page

Get the File onto Splatter

[edit]

On your own computer, if you are still logged into SCEVAL, type "logout" to get back to your own computer's home. You now want to FTP the constructed file from SCEVAL to your computer. Make a folder on your own computer that you want to temporarily save the AIM file to. I made a folder called tmp:

$ mkdir tmp
$ cd tmp
$ ftp sceval.ucalgary.ca

It will now ask you for a username and password. Invivo is the username and the password is the same as when you SSH to SCEVAL.

ftp> bin
200 TYPE set to IMAGE
ftp> prompt off
Interactive mode off.
ftp> cd ur
ftp> cd conway
ftp> cd models
ftp> get SAWBONE401_CONSTRUCT.AIM
ftp> bye
  • You can only move one directory at a time.
  • You must type in the full directory name, and not use shortcuts.
  • Bye quits the FTP mode.
  • Bin changes the transfer type to an image. It will not work otherwise.
  • Prompt off is only for if you need to transfer multiple files at a time, so it will not prompt you for each file. This is how you would get multiple files:
ftp> get SAWBONE401_CONSTRUCT.AIM SAWBONE402_CONSTRUCT.AIM SAWBONE403_CONSTRUCT.AIM

Now, the file is in your tmp folder on your computer, and must be moved to Splatter using SCP. Make sure you are in the tmp folder when you do this step. You will need to set up an account on Splatter as well (ask Eric to do that for you). Once you have done that, here is the command:

$ scp sawbone401_construct.aim cconway@splatter.kin.ucalgary.ca:data/sawbone401

It will then ask you for your password, after which it will complete the transfer for you.

The "data/sawbone401" at the end is the path on Splatter where you want to put the file.

Your file is now ready for viewing by ParaView and ready to be put through an FE Analysis!


Return to Contents or Return to Main Page