computers in medicine bone visualization and analyses - an introduction to matlab - presented by:...

105
Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich [email protected] Prepared by: Steven Boyd University of Calgary

Upload: domenic-stevenson

Post on 20-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Computers in Medicine

Bone visualization and analyses - An introduction to Matlab -

Presented by: Kathryn Stok

ETH Zurich

[email protected]

Prepared by: Steven Boyd

University of Calgary

Page 2: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Objectives (I)

Provide an overview of Matlab– What is Matlab?– Basic commands– Accessing online help– Writing M-files– Programming style– Create plots

Page 3: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Objectives (II)

Work through examples– Reading an image file– Probe the data– Filtering– Create a histogram– Thresholding– Counting voxels– Calculating 2nd moment of area

Page 4: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Why bone visualization?

Carries the body→ it should be strong

But in many cases, bone strength is impaired.– congenital deformities– osteoporosis– fracture– fatigue (stress fracture)

Page 5: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Bone architecture

Page 6: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Bone structure – femoral head

Young Normal Osteoporotic

Page 7: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Bone structure – lumbar spine

Young Normal Osteoporotic

Page 8: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Why bone visualization?

Bone (structure) analyses and visualization are of great importance in – Diagnosis– Treatment– Prevention

Page 9: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Why Matlab?

High-performance language for technical computing.– Matrix Laboratory

Advantages– Easy to use:

– No dimensioning required.– No compiling– Good for prototyping, testing

– Functionality is greatly expanded by toolboxes. – Many fields of application.

Disadvantages:– Uses much memory (slow for large applications)– Not good for final software design

Page 10: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

What is matlab?

Matlab language– matrix/array language– control flow (if, for, while)– functions

Working environment– workspace for computing, importing, and

exporting data– text editor for creating M-files

Page 11: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

This Matlab course

It covers: • Using the development environment.• Syntax of the language. • Basic matrix operations. • Basic graphics features. • Writing Matlab scripts and functions (m-files)

It does not cover: • Any of the toolboxes including Simulink. • c-mex and f-mex files, Matlab compilers.

Page 12: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Possibilities…

Develop tools for:– Image processing and basic analysis.– Visualization: 2D and 3D.– Simulation: Simulate bone loss.

Page 13: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Matlab Environment

Page 14: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Matrices

Albrecht Dürer

Magic square

Page 15: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Matrices

semicolon

Entering matrices– explicitly

Page 16: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Matrices

Sum, transpose

Page 17: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Matrices

Diagonal (diag)

Page 18: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Matrices

Subscripts: A(i,j)

row column

Page 19: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Matrices

Colon operator ' : '

Page 20: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Matrices

Colon operator ' : '

Matlab is 1-based

Page 21: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Matrix multiplication ( * )

Page 22: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Matrix multiplication ( .* )

Page 23: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Variables

Scalar, vector, matrix

Page 24: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Variables

Check workspace– command line– window

Page 25: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Numbers

Integer

Real

Exponential

Imaginary

-3

0.0001

1.60210e-20

5 + 2i

Page 26: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Operators: Arithmetic

+ Addition - Subtraction * Multiplication (or .* element-wise) / Division ^ Power (or .^ element-wise) ' Transpose () Brackets for evaluation order

A = [ 4 1 3]A.^2 = [16 1 9]A.*2 = [ 8 2 6]

A '* A 16 4 124 1 312 3 9

Page 27: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Operators: Relational

< Less than

<= Less than or equal to

> Greater than

>= Greater than or equal to

== Equal to

~= Not equal to

Page 28: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Operators: Logical

& AND

| OR

~ NOT

Type help ops to see: the arithmetic,relational and logical functions.

Page 29: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Matrices

Entering matrices– explicitly– load from external file– your own M-files– built-in function

Albrecht Dürer

Page 30: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Generating matrices

Loaddata file

Page 31: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Generating matrices

M-files

Page 32: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Generating matrices

Built-in functions

Page 33: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Help

Help Window– pop-up window

Type help

Page 34: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Online help

Page 35: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Online help

Page 36: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Online help

Page 37: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Useful commands

(up arrow)– recall previous command– p recalls previous command starting with ‘p’

clear– clear workspace– clear A Z Q clears only A, Z, and Q.

size– size(A) returns size of matrix A

Page 38: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Multidimensional matrices

page k,Z

rowi, X

column j, Y

Page 39: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Multidimensional matrices

Generate a 3D array manually

Page 40: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Advanced indexing

Matrices are always stored as columns– subscripts (i,j,k)– array dimension [d1 d2 d3]

– if A is of dimension 3 x 3 x 3 then A(3,3,3) = A(27) = 8

3 2 7 5 1 1 4 6 8 6 2 6 1 4 9 3 6 7 5 6 7 9 5 6 1 2 8

3 5 4 2 1 6 7 1 8

3 5 4 2 1 6 7 1 8

6 1 3 2 4 6 6 9 7

6 1 3 2 4 6 6 9 7

5 9 1 6 5 2 7 6 8

5 9 1 6 5 2 7 6 8

ij

k

Page 41: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Characters and Text

s = 'myimage'– 7 character array (string)

num2str() - convert a number to string

Page 42: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

User input

Keyboard inputa_number = input('Enter number');a_string = input('Enter filename', 's');

[filename,path] = uigetfile('*.*');

Using GUI

Page 43: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Graphics: plot

Page 44: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Graphics: plot(s)

‘hold on’allows more plots to be added

Page 45: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Graphics: contours

Page 46: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Graphics: subplots

Page 47: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Graphics: labels and titles

Page 48: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Graphics: labels and titles

… or use the Figure window !

Page 49: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Graphics: mesh

Page 50: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Flow control

if, else, and elseif

switch

while

for

Page 51: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

if, else, and elseif

if logical_expression statementsend

if (rem(a,2) == 0) disp(‘a is even’)end

if (n<0) disp(‘Input must be positive’)elseif (rem(n,2) == 0) disp(‘a is even’)else disp(‘a is odd’)end

Page 52: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

switch

switch expression case value1 statements case value2 statements otherwise statementsend

switch (input_num) case (-1) disp(‘negative one’) case (0) disp(‘zero’) case (1) disp(‘positive one’) otherwise disp(‘othervalue’)end

Page 53: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

while, for

while expression statementsend

n = 1;while (prod(1:n) < 1e10) n = n + 1;end

for index = start:inc:end statementsend

for i = 2:6 x(i) = 2*x(i-1);end

for i = 1:m for j = 1:n A(i,j) = 1/(i + j - 1); endend

Page 54: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Vectorization

Efficiency!– Example: Table of logarithms

–Find log10 of numbers between 0 and 10.

x = 0;for k = 1:1001 y(k) = log10(x); x = x + 0.01;end

x = 0:0.01:10;y = log10(x);

Looped code Vectorized code

AVOID LOOPS!

Page 55: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Scripts and functions

Scripts– No input arguments nor

output arguments.

– Operate on data in the workspace

– Useful for automating a series of steps that will be performed many times

Functions– Can accept input

arguments and return output arguments

– Variables are local to the function

– Useful for extending the MATLAB language beyond the built-in functions

Page 56: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Script example

Comment lines

Computations

Graphicsoutput

Create m-files:– type edit – use the interface

Page 57: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Script example

Hit return to advance plot

Page 58: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Script Example

Page 59: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Function example

Function definition

Help comments

Error check

Calculations

function [y] = average(x)

keyword

output argumentfunction name

input argument

Page 60: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Function example

semi-colon

Page 61: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

M-files

Tips:– use descriptive variable names

–e.g. number_students = 20– functions end with “_fcn”

–e.g. an_example_fcn(number_students)– indent if, for, while statements 3-4 spaces– add comments using ‘%’– develop with smaller portions of data– debug by pasting line-by-line from M-file

Page 62: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Online tutorial

http://www.imrtweb.ethz.ch/matlab/

Or google “mathworks tutorial”

Fundamentals

Exercises

Examples

Page 63: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Part II: Practical Programming

Image analysis on 2D section– Read image data (micro-CT)– Plot the image– Examine image– Filter the image– Create a histogram– Threshold (distinguish between bone and marrow)

– Calculate porosity– Centroid, principal axes

Page 64: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Read 2D Image

Want to import the image from micro-CT

Write a program to:– clear workspace– set filename– load file

– Image data to visualize:/Phalanx/hp2d_34-95_380.bmp

Page 65: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Set up main program (a script file)

comments

clear workspace

close all figure windows

file to load

load it

Note: You need to write the 2D image reading function.

Page 66: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Read in 2D image

Read the file

Convert data

Page 67: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Display input data

Page 68: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Display input data

Page 69: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Display input data

Page 70: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Examine image

min, max, mean

Page 71: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Examine image

min, max, mean

Page 72: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Image Processing

Filter

Thresholding– histogram

Porosity = 1 - (bone area / total area)

Moment of area– First moment of area– Centroid– Second moment of area

Page 73: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Filtering – example 1

Page 74: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Filtering – example 2

filtered original image filtered noisy image

original image noisy image

Page 75: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Filtering the data

Apply Gaussian filtration– Shape of filter depends on:

window size [n1 n2] and

Page 76: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Filtering

Window = 3 = 1.2

Filter

Page 77: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Filtering

Window = 5 = 1.2

Filter

Page 78: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Filtering

Window = 15 = 1.2

Filter

Page 79: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Filtering

Window = 15 = 7

Filter

Page 80: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Filtering

Window = 15 = 100

Filter

Page 81: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Filtering: Convolution

zyx fff

Page 82: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Filtering: Edge Effects

edge data nulled

• Important to begin with image dimensions large enough to account for edge effects

Page 83: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Filtering

Use built-in functions:– fspecial– imfilter– (smooth3)

Page 84: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Thresholding

• Good to try different thresholds to see the effect.

Segmentation of bone– divides bone from other tissue

Page 85: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Thresholding

threshold2D = zeros matrixFind all indices (i,j) where element(i,j) > threshold threshold2D(i,j) = 1

Page 86: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Thresholding

Page 87: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Thresholding

Threshold = 90 Threshold = 120

Page 88: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Histogram

– lookfor and help

Page 89: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Histogram

hist works on vectors, not 2D matrices– need reshape function to vectorize

Page 90: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Porosity

Porosity = 1 - (Bone volume divided by total volume)

Need total bone volume (area)– Create mask:

– filter image to remove holes– threshold filtered image

– Count total “mask” pixels– Count total “bone” pixels

within mask

Page 91: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Porosity

Create mask:

original image

filtered image

threshold filtered image

Image 3 super-imposedon image 1

1 2 3

Page 92: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Porosity

Porosity = 1 -Mask pixels

Bone pixels within mask

Thresholded image (bone)

Mask image

Image of bone within the mask

Page 93: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Image analysis – determine porosity

Original

Segmenting the boneFiltered Thresholded

Creating the maskFiltered Thresholded

Find bone within mask

Porosity = 1 - Areabone

Areamask

Page 94: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Erosion, dilation

Erode Erode = 2 Erode = 4

Dilate Dilate = 2 Dilate = 4

Page 95: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Part of MAIN program

Page 96: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Stress in Pure Bending

Mechanical stiffness– First moment of area– Centroid of area– Second moment of area

Page 97: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

First moment of an area

First moment of area with respect to the X axis:

First moment of area with respect to the Y axis:

Can be positive, negative, or zero depending on the axis location

(mm3)

(mm3)

Page 98: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Centroid of an area

Centroid of area defined as:

Knowing the first moment:

Page 99: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

First moment of area

Page 100: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Second moment of area

Stress resulting from bending: σ = My/I

Resistance against bending.– Take Ix, Iy, Ixy about centroid C

– Or use the parallel axis theorem: Ix = Ixc + Ad2

Page 101: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Second moment of area - rotation

Transformation of 2nd moments:

Page 102: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Second moment of area - principal axes

Two values of for which Ixy = 0.

Can calculate the max/min 2nd moments:

maximum associatedwith Ix

minimum associatedwith Iy

Page 103: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Principal axes & Transformation

Page 104: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

2D: Pompe Disease

Radius Tibia

Page 105: Computers in Medicine Bone visualization and analyses - An introduction to Matlab - Presented by: Kathryn Stok ETH Zurich kas@ethz.ch Prepared by: Steven

Mouse knees

NTRTCTRL