Classification of bone microstructures using PCA and 2 ......2 The composition of bone tissue is...
Transcript of Classification of bone microstructures using PCA and 2 ......2 The composition of bone tissue is...
i
Classification of Bone Microstructures Using PCA and
2-Point Statistics
A Thesis
Submitted to the Faculty
Of
Drexel University by
Alka Basnet
in partial fulfillment of the
requirements for the degree
of
Masters of Science
September 2012
ii
iii
ABSTRACT
A database framework that could automatically classify and organize characterized microstructure
datasets based on a rigorous reduced variable representation of the microstructure rather than relying
on ad-hoc selected metrics, can be a powerful tool in the field of materials science and engineering.
Classification using lower order descriptors has been shown to improve the quantification of
microstructures. Principal component analysis over a classification structure is suggested as an
effective method for reduced order representation of a microstructure.
In this paper, 2 point correlation functions and Principal Component Analysis (PCA) is used as an
effective tool for classification of 3-D microstructures. [19].The central hypothesis of this paper is
that on the first 3 PC weights, bone microstructure would depict some classification based on the
wedge location within the cross. Although there was no distinct classification based on wedge
location, we see that microstructures clustered together in the low dimensional PCA representations
actually look similar to each other i.e. visually, compared to the microstructures that are far apart
from each other.
iv
ACKNOWLEDGEMENT
I would like to thank my advisor Prof. Surya Kalidindi, who supported and instructed my
performance throughout my research work with much patience and guidance. I also would like to
thank David Turner, my mentor for his immense support and guidance in all the steps as well as
Anne Hanna for all her help.
I would also like to thank Dr. Haviva Goldman and Naomi Hampson for providing the data used in
my thesis. In the mean time I would like to acknowledge all the help from my lab mates.
At last but not the least, I would like to thank my family for their immense support.
v
TABLE OF CONTENTS
Abstract ii
Acknowledgement iv
List of Figures vi
Chapter 1: Introdcution 1
1.1 Background: 1
1.2 Bone Composition and Remodeling 2
1.3 Sample Details 5
1.4 Classification Using Data Science Approaches 7
Chapter 2: Extracting cubical RVE’s from Micro Ct Imgaes 8
Chapter 3: Two Point Statistics 10
Chapter 4: Principal Component Analysis 12
Chapter 5 Results 16
Chapter 6: Conclusion and Future Studies 23
Appendix A: 25
Appendix B: 36
Appendix C: 36
Appendix D: 40
References 49
vi
LIST OF FIGURES
Figure 1 Compact Bone 2
Figure 2 Bone remodeling 4
Figure 3 pQCT: Tibia length sectioned at 38% and 66 6
Figure 4 Radial sections of bone 6
Figure 5 Binarized posterior wedge with 3 radially extracted boxes 9
Figure 6 Phase microsructure and Autocorrelation 11
Figure 7 Schematic representation of principal component analysis 12
Figure 8 Explained Variance for First 10 PCA Weights 14
Figure 9 Classification of Microstructure in PCA space 16
Figure 10 Categorization of Tibia Wedges based on Classification Showed in Fig.9 17
Figure 11 Tibia Length 17
Figure 12 Tibia Crosssection divided into 6 wedges 17
Figure 13 Pore Structure of Wedge 1_38% 18
Figure 14 Pore Structure of Wedge 1_38% 18
Figure 15 Pore Structure of Wedge 5_38% 18
Figure 16 Pore Structure of Wedge 5_38% 18
Figure 17 Pore Structure of Wedge 6_38% 19
Figure 18 Pore Structure of Wedge 6_38% 19
vii
Figure 19 Pore Structure of Wedge 3_38% 19
Figure 20 Pore Structure of Wedge 3_38% 19
Figure 21 Pore Structure of Wedge 6_66% 20
Figure 22 Pore Structure of Wedge 6_66%..........…..……………..…………………………… 20
Figure 23 Pore Structure of Wedge 6_66%...........….……………………………...…………... 20
Figure 24 Pore Structure of Wedge 6_66%.............……….………………………………........ 20
Figure 25 Pore Structure of Wedge 1_66% …………………………………………………...... 21
Figure 26 Pore Structure of Wedge 2_66%………………………..……………………………. 21
Figure 27 Pore Structure of Wedge 1_66%………………………………………...………….... 21
Figure 28 Pore Structure of Wedge 3_66%……….……………………………………….......... 21
Figure 29 Pore Structure of Wedge 4_66%…………………………………………………...... 22
Figure 30 Pore Structure of Wedge 5_66%………………..……………………………………. 22
Figure 31 Pore Structure of Wedge 2_38%………………..……………………………………. 22
Figure 32 Pore Structure of Wedge 4_38%………………..……………………………………. 22
1
CHAPTER 1: INTRODUCTION
BACKGROUND:
As new and rapid materials characterization tools became widely available, large datasets
are been generated at a faster pace which results into challenges. Some of which, are
rapid acquisition of large datasets, predictive capabilities in materials systems using the
information from dataset, and analysis of the increasing volumes of data. One of the
solutions to these challenges can be combination of classification methodology and
principal component analysis for effective reduced-order representation of 3D
microstructures which is demonstrated in the following paper. Instead of using several
higher-order measures for the mathematical representation of 3D microstructures, a
principal component analysis (PCA) technique is introduced for enabling reduced-order
representation. In this case, classification technique based on lower-order descriptors is
shown to increase the efficiency of representation. [20]. The dataset used in the analysis
in this thesis is from 10 individuals (average age 36.7 +/-8.4 years) from 2 specific
location 38% and 66% of total tibia length.
2
The composition of bone tissue is more complex than most engineering composites. [4]
The bone is composed of mineralized collagen fibrils which are composed of fibrous
protein collagen. At the macro scale bone is made of two basic structures, cortical bone
and trabecular bone. Cortical bone is densely packed with around 5-10% porosity and
forms the outer shell of all bones. The shafts of long bones are made primarily of cortical
bone with the midshaft being almost entirely cortical. My research is focused on human
cortical bone, specifically found at the midshaft of the tibia. 80% of the skeleton is made
of cortical bone and it plays a vital role in the majority of the skeleton’s supportive and
protective function.
Figure 1: Compact Bone
1.1 Bone Composition and Remodeling:
Bone composition and organization at the tissue level can play a very important role in
mechanical strength of the bone at the whole bone level. At the finest level of bones
hierarchical structure, bone has an organic matrix which is deposited as unmineralized
3
osteoid and contains primarily Type I collagen, proteoglycans and water. The collagen
provides flexibility as well as tensile strength to the bone. The organization, orientation,
and cross-linking of the collagen fibrils have been shown to be related to the mechanical
properties of the bone [11]. The mineral adds compressive strength and rigidity to the
bone and the degree of mineralization can have a huge impact on the mechanical
properties. Heavily mineralized bone has a higher breaking stress compared to less
mineralized bone, however overly mineralized bone can become brittle. [12] Bone
mineralization density, collagen fiber organization and porosity are discussed below,
relative to their relationship to bone remodeling and bone strength. [3]
There are two ways to measure mineralization - volumetric mineralization and specific
mineralization. Volumetric mineralization, otherwise known as bone mineral density is a
measure of the amount of mineral per unit volume of bone and is a function of both
mineralization and porosity. It can be measured with computed tomography which is a non-
invasive technique. [13, 14] Specific mineralization is the amount of mineral in a bone. It
can be measured a number of ways (ex vivo), ash fraction analysis being [15] the one used
in the present study. As bone ages, the amount of mineral contained in the bone matrix
increases and this causes the bone to be brittle. Tibia is also known as the long bone.
Proximally and distally of the midshaft will mostly will be cortical but have some
cancellous bone.
As bone grows it needs to be reshaped and thus starts remodeling. Bone is deposited on
one surface and reabsorbed on another. It gives bones its adult shape. The bone formed
during growth and development is very different in organization and properties from the
bone of an adult.
4
Figure 2: Bone Growth and Remodeling
Bone is reabsorbed and deposited. The remodeling rates are different at different
locations around the cortex. Bone gets more mineralized over time. New bone can be
right next to older bone. More osteons lead to greater porosity. As an individual grows
the bone does not just increase in length, the shape also changes, with areas that had been
very wide such as the bone ends becoming narrow and part of the shaft. During this
5
process bone must be removed through osteoclastic activity in some areas while in other
areas bone is laid down via osteoblastic activity. This process is called “growth
remodeling” [6, 7, 8] or modeling. During this process, bone is deposited on one cortex
and resorbed on the opposite cortex which leads to shift in the position of bone laid down
at an earlier time compared to newer bone.
1.3 SAMPLE DETAILS:
Our research sample acquired from the Musculoskeletal Transplant Foundation (Edison,
NJ, USA) represents a subset of an existing collection of donor tibiae with a total of 10
average age 37 +/- 8 years old and 17 male donors average age 33 +/- 10 years old. The
information on donor body weight and height are available, and only donors with no
known skeletal pathology were included in the collection. The tibiae were freshly
harvested, wrapped in wet gauze and stored frozen at -40 degrees Celsius in plastic bags.
Each of the tibiae in the sample were thawed, sectioned at 33% and 68% of total tibial
length, resulting in 3mm thick diaphyseal cross-sections at each location (see Figure 4).
Each cross section was cut into 6 wedges and labeled 1 through 6 starting with the
anterior wedge and ending with the medial anterior wedge. Cuts were based of the line
from the anterior tip through the centroid as shown in fig 4. Three 200 x 200 x 200 cubic
matrix with planes parallel to the subchondral plate was extracted from each wedge -
periosteal, midosteal and endosteal.
6
Figure 3: pQCT: Tibia length sectioned at 38% and 66%
Figure 4: Tibia cross section divided into 6 radial sections
7
1.5 CLASSIFICATION USING DATA SCIENCE APPROACHES:
Often in Materials Science, we deal with a large set of data especially while defining
a microstructure. In the study of human tibia properties, it is crucial to have a
classification of datasets we use to perform the analysis, based on their
microstructure. An efficient classification based on the microstructure saves time and
reduces redundancy in the acquired datasets. Developing a framework for accurate
analysis of this complex microstructure dataset has vital clinical applications as it can
provide insights into indications of high bone fragility. Given the several hundred
thousands of distinct engineered and natural materials of interest, the critical need for
new computationally efficient approaches for archival, retrieval, and real-time
exploration of the microstructure datasets by the broader scientific community is
self-evident. Efforts in these activities are hindered by the lack of a rigorous
mathematical definition of the internal structure or microstructure of a material.
The n-point correlation functions have been shown to be capable of recovering the
original micrograph to within a linear translation and/or an inversion, and as such
will serve as a primary descriptor of the statistics underlying the stochastic nature of
the microstructure [1]. Decomposition of the n-point statistics via principal
component analysis (PCA) offers a highly efficient data science approach for
classifying and cataloguing the microstructure datasets.
8
CHAPTER 2: EXTRACTING CUBICAL ROI’S FROM MICRO CT IMGAES
The samples studied in this research were prepared by a member of my research group,
Naomi Hampson. Naomi obtained the subset of donor tibiae that were obtained from the
Musculoskeletal Transplant Foundation, and were used in related studies at Mount Sinai
School of Medicine. For this project, nine donor (5 M, 4 F, 23-46 years.) tibia cross
sections were used, each 2.5 mm thick and extracted from a distance of 38% and 66% of
the total length of the bone from its distal end. The samples were pre-cut into six radial
sections and all the wedges were used for the study. These (number of wedges) were
imaged by micro computed tomography using a Sky-Scan 1172 at 100 kV and a 5 micron
voxel size. To facilitate image processing, a four-fold reduced versions of the micro-CT
scans were used so that every wedge had a corresponding set of approximately 110
images of 992 x 992 pixels each and a voxel size of 20 microns. The images from each
wedge were reconstructed to create a set of binarized images in the form of a pliable 3D
matrix model.
Using a matlab program shown in Appendix A, developed as a part of my thesis, cubic
regions of interest were radially extracted from each wedge. Three cubes, each of size
200 by 200 by 200 pixels were extracted from each rotated and binarized wedge
(Appendix A has the matlab code that shows how the images are rotated) which gave a
total of 18 cubes from a single cross section. Figure 5 depicts a binarized rotated posterior
wedge with 3 regions of interest.
9
Figure 5: Binarized posterior wedge with 3 radially extracted boxes
The data sets obtained from processing images for all 10 individuals were fairly large and
required a lot of time to be processed and saved. Thus, to save time and obtain objective
reduced-order representations of the microstructure, we extracted principal components
of the 2-point statistics from each microstructure. Such a database can dramatically
increase the speed and efficacy with which we can build datasets that can be shared by
the broader scientific community, while minimizing duplication of effort.
Endosteal
Box 1
Periosteal
(external)
Outline
Periosteal
Box 3
Mid-cortex Box 2
10
CHAPTER 3: TWO POINT STATISTICS
Due to recent advances in computational algorithms, it has been possible to obtain
higher-order statistical descriptions of microstructure with advanced computational
resources. More specifically, a microstructure is quantified through a selected list of
statistical measures. [20] In this thesis, this is explored in the framework of n-point
statistics. In this approach, the statistics of the microstructure are described by a set of
distributions that systematically provide more information about the microstructure with
increasing order of statistics [16, 17]. For example, 1-point statistics capture the
probability associated with finding a specific local state of interest at any point selected
randomly in the microstructure. At the next hierarchical level, 2-point statistics describe
the probability density associated with finding the specific local states at two ordered
points, specified by a vector, thrown randomly into the microstructure [1]
Among the various techniques to update the 2-point statistics, use of Fast Fourier
Transforms (FFTs) for rapid computation of two point statistics shows tremendous
promise [1]. We employ FFTs to calculate the 2-point statistics with an assumption that
the structure is periodic. We calculated the 2-point correlation by using an FFT
convolution. [1, 2]
The discretized two point statistics for a two phase material system is expressed as
1' '
0
1 snn n n
t s s t
s
f m ms
(Equation1)
where the superscripts n and n’ denote the local states of interest and the subscript t
denotes the vectors that can be thrown into the microstructure. The enumerator "s + t "
11
denotes the grid point reached in the microstructure by adding the vector t to the grid
point s. The details on how to calculate 2 point statistics is described in [1, 2].
Fig. 6. (a) An example of two-phase microstructure. (b) Autocorrelation for the
black phase.
12
CHAPTER 4: PRINCIPAL COMPONENT ANALYSIS
Principal Component Analysis (PCA) is a way of sorting high dimensional data based on
the directions exhibiting the highest variances. This is most easily understood as a
projection of a high dimensional data set into a new orthogonal (perpendicular)
coordinate frame where the axes are defined by the directions of highest variance. These
directions are known as the principal components of the dataset. Each principal
component is a linear transformation of the entire data set. The principal components are
identified such that the first principal component contains the highest variance. The
second principal component contains the second highest variance and is orthogonal
(uncorrelated) to the first principal component, so on and so forth, as depicted in Fig. 10.
The importance of each principal direction is given by its associated eigenvalue. PCA has
been proven to be the optimum linear technique at reduced order representation. Basic
background on the PCA technique can be found in [18].
Figure 7: Left – Schematic representation of principal component analysis of
multidimensional data. Right – Projection of the data onto the 1 and 2 principal
directions
13
PCA can be performed either by using Covariance matrix or by the method of eigen
vector decomposition. Using the latter, the data set is defined by the 2-point statistics on
the tibia bone samples from 10 individuals. From a total of 10 individuals, 93 distinct
microstructure datasets were extracted (excluding the 3 data sets that were not usable -
1226_66_Part 4, 6318_38_Part 2 and 6318_ 38_Part 5) and their 2-point statistics were
computed.. The steps involved in the method are as follows:
If we consider an ensemble of L vectors, the PCA decomposition of l the member is
given by
1
1
Ll l
i i
i
f a f (Equation 2)
where f represents the mean vector. In Eq. (2), i represent the orthogonal basis set and
l
ia represent the corresponding weights of the lth
member. Mathematically, the
decomposition can be envisioned as a few basic steps
1. Mean center the data.
l lf f
2. Calculate the covariance matrix of the data.
1( )l l T
LC
L
3. Perform eigenvalue decomposition.
i i iC b
4. Project mean centered data into the eigenspace to find the weights.
( )l T l
i ia
14
Our approach differs in that the PCA decomposition is used to provide a reduced
representation of the n-point correlations of microstructure.[11] The advantage of our
approach is that the statistics are smooth analytic functions with a natural origin. PCA
decomposition results in an uncorrelated orthogonal basis that spans the same space as
the original n-point correlations of microstructures.
The following figure projects the weights for first 10 Principal components.
Figure 8: Explained Variance for first 10 PCA weights
It is evident that first three Principal components account for 98.5 % of the variance in
the observed variables. This basically means that the first principal accounts for the
maximum amount of variance in the data set which we assume to be the volume fraction
of the bone. The second component extracted will account for a maximal amount of
variance in the data set that was not accounted for by the first component and will be
15
uncorrelated to the first component. Thus for my preceding analyses, I only took into
account the first PCA as the rest of them contain trivial information.
16
CHAPTER 5: RESULTS
Figure 9: Classification of Bone Microstructure on First 3 PCA Weights
Data from all the individuals were plotted in first three PCA space, using a convex
representation. It was seen that Wedge 1_38%, Wedge 3_38%, Wedge 5_38%,Wedge
6_38% clustered together that is labeled as Group 1, Wedge 6 separated out as Group 2
and the remaining sample from Individuals were clustered together that is labeled as
Group 3in Figure 11 as well as Figure 12. The size of the hull varies within the samples
and represents the variance in the data. In group 3, the large blue hull i.e. Wedge 1_66%
Group 3 Group 2
Group 1
17
has much larger variance in the data set compared to the small green hull i.e. Wedge
3_66% of the same group 3.
Group 1 Group 2 Group 3
Wedge 1_38% Wedge_6_66% Wedge 2_38%
Wedge 3_38% Wedge 4_38%
Wedge 6_38% Wedge 1_66%
Wedge 5_38% Wedge 2_66%
Wedge 3_66%
Wedge 4_66%
Wedge 5_66%
Figure 10: Categorization of Tibia Wedges based on Classification Showed in Fig.9
Figure.11 Tibia length Figure.12 CS divided into 6 wedges
The initial hypothesis was that bone microstructure would depict some fine classification
based on their placement within the cross section i.e. wedge location. Plotting the first 3
PC weights (as it covered 98.5% of total variance in the data set) of all the
microstructures we did not see any classification based on the wedge location. However,
we see that microstructures clustered together in the low dimensional PCA
18
representations actually look similar to each other i.e. visually, compared to the
microstructures that are far apart from each other. The pore structures of the
microstructures shown in Group 1, Group 2 and Group 3 vary from each other with
respect to the pore size. Pore space from each category (Group1, 2 and 3) are shown
below. Figures 14 – 29 were plotted using isosurface, as shown in Appendix D, such that
we can visualize the pore space of each microstructure.
Group 1
Figure 13: Wedge 1_38% Figure 14: Wedge 1_38%
Figure 15: Wedge 1_38% Figure 16: Wedge 1_38%
19
Figure 17: Wedge 6_38% Figure 18: Wedge 6_38%
Figure 19: Wedge 3_38% Figure 20: Wedge 3_38%
Group 2
20
Figure 21: Wedge 6_66% Figure 22: Wedge 6_66%
Figure 23: Wedge 6_66% Figure 24: Wedge 6_66%
Group 3
21
Figure 25: Wedge 1_66% Figure 26: Wedge 2_66%
Figure 27: Wedge 1_66% Figure 28: Wedge 3_66%
22
Figure 29: Wedge 4_66% Figure 30: Wedge 5_66%
Figure 31: Wedge 2_38% Figure 32: Wedge 4_38%
23
CHAPTER 6: CONCLUSION AND FUTURE STUDIES
Summing the results obtained from Principal Component Analysis and two point
statistics on a set of binarized micro-CT scan images we see that microstructures
clustered together in the low dimensional PCA representations actually look similar to
each other i.e. visually, compared to the microstructures that are far apart from each
other. If we compare the pore structure of all three categories or group, we see that the
pore size is the basis of classification. Group 3 has few but large pore size compared to
Group 1 which has more but smaller pore size. Group 2 does not have a distinct has some
large and some small pore size. There is a possibility that a better classification of
microstructure would have been possible with a larger data size. I used 10 individuals
with 9 data sets for 38% and 7 for 66% location of the tibia length which is fairly small
compared to large amount of data being gathered routinely.
The continuation to this work should be using a larger data set to see if a better
classification could be achieved. A better classification would result in better predictive
capabilities and analysis in materials science and engineering system. It would also be
very interesting work to see if the relation between reduced order representation of
microstructure using Two point statistics and PCA, vs. mechanical properties like
effective modulus and strain energy distribution on different locations in the tibia length
to see if there is any distinct pattern of bone remodeling. Obtaining such results will aid
in better understanding of fracture risk and aging, improving our understanding of
structure / property relationships in bone and better understanding of relationships ahead
24
of improved clinical imaging techniques. I think a larger data set can depict a better
classification of microstructure.
25
APPENDIX A:
A1: EXTRACTING ROI FROM THE WEDGE_I
% Function that picks out parameters for boxes of specified side lengths
% for an image that is already binarized and lined up correctly.
% Returns box parameters for user with the other images.
function [xMin xMax yMin yMax] = lineUp(saveFile, name, numBoxes, sides, buffer)
%[xMin xMax yMin yMax] = lineUp(saveFile, name, numBoxes, sides, buffer)
%saveFile = str, directory where to save files
%name = str, name of files to be saved as
%numBoxes = int, number of boxes to take up for each section
%sides = int, number of pixels of each box side
%buffer = int, number of pixels to cushion on extreme sides of first and
%last boxes
% yMin, yMax = int, int, locations of y limits for string
% xMin = [numBoxes x 1], location of x minimun limit for boxes
% xMax = [numBoxes x 1], location of x maximum limit for boxes
% Get images
[fileName,pathName] = uigetfile('*.bmp','Select a good file to process');
imag = imread([pathName fileName]);
imag = ~imag; %inverting image
buffSides = sides;
26
%%
% Get outline
outlines = bwboundaries(imag);
index= 1;
for ii=1:size(outlines,1)
if size(outlines{ii},1) > size(outlines{index},1)% change it to more than equal to
index= ii;
end
end
imgOutline = [outlines{index}(:,2) outlines{index}(:,1)];
clear outlines;
centroid = round(mean(imgOutline));
yCentroid = centroid(2);
xCentroid = centroid(1);
%%
%Find locIn, locOut that will delineate the strip
indexIn = find(round(yCentroid-buffSides/2)<=imgOutline(:,2)...
& round(yCentroid+buffSides/2)>=imgOutline(:,2)...
& xCentroid<imgOutline(:,1));
indexOut = find(round(yCentroid-buffSides/2)<=imgOutline(:,2) ...
& round(yCentroid+buffSides/2)>=imgOutline(:,2)...
27
& xCentroid>imgOutline(:,1));
%Keep the most extreme boundaries on the outline for the boxes
locIn = min(imgOutline(indexIn,1));
locOut = max(imgOutline(indexOut,1));
figure; imshow(imag); hold on;
plot([locOut locIn], [yCentroid yCentroid], '+c');
% Ask if user would like to manually designate edges
% ask = input('Manually designate edge of rightmost box (y or n): ', 's');
% if ask == 'y'
title(gca,'Click location of right side of rightmost box');
LocIn = ginput(1); % picks the coordinates of the first click
plot(LocIn(1), LocIn(2),'*m');
pause(0.5);
% end
% To draw lines across the image
S = size(imag);
plot ([1 S(1)],[LocIn(2)-100 LocIn(2)-100], '-m');
plot ([1 S(1)],[LocIn(2)+100 LocIn(2)+100], '-r');
% Ask if user would like to manually designate edges
% ask = input('Manually designate edge of leftmost box (y or n): ', 's');
28
% if ask == 'y'
title(gca,'Click location of left side of leftmost box');
LocOut = ginput(1);
plot(LocOut(1), LocIn(2), '*m');
pause(0.5);
% end
% Take out boxes
y1=round(LocIn(2)-sides/2);
y2=round(LocIn(2)+sides/2);
yMin = min(y1,y2);
yMax = max(y1,y2);
%Find the centers of the boxes
center(1) = LocIn(1) - round(buffSides/2);
center(numBoxes) = LocOut(1) + round(buffSides/2);
diff = abs(center(1)-center(numBoxes));
for m=2:numBoxes-1
center(m) = center(1)-diff/2/(numBoxes-2)*(m-1);
end
close all;
figure(1)
29
imshow(imag)
hold on;
for j=1:numBoxes
%find verteces of boxes
x1=round(center(j) - sides/2);
x2=round(center(j) + sides/2);
figure(1)
hold on;
%plot location of boxes on image
plot([x1 x2], [y1 y1], 'r-', 'LineWidth', 2);
plot([x1 x2], [y2 y2], 'r-', 'LineWidth', 2);
plot([x1 x1], [y1 y2], 'r-', 'LineWidth', 2);
plot([x2 x2], [y1 y2], 'r-', 'LineWidth', 2);
plot(center(j), LocIn(2), '*c');
%plot actual box images
xMin(j) = min(x1,x2);
xMax(j) = max(x1,x2);
figure(2)
hold on;
30
subplot(1,numBoxes, j);
imshow(imag(yMin:yMax,xMin(j):xMax(j)));
end
%save image with boxes
saveas(1, [saveFile, name, '_3DImage.bmp']);
end
31
A2 : EXTRACTING ROI FROM THE WEDGE
% LineUp_Multiple.m
% Script.m file that processes a set of image files (already binarized,
% rotated, and cropped). It allows the user to pick one sample file to
% create parameters in order to pick out a specified number of boxes out of
% each image to create a cube of image data that can be used for FEM. Also
% saves a text file specifying the information for the parameters used.
% Boxes_NAME.mat will contain cell array of size 1xn of all necessary image
% data for n boxes of size s for all m images:
% { [s x s x m] [s x s x m] [s x s x m] ... }
%%
%Get user inputs
numBoxes = input('Number of Boxes to pull out: ');
sides = input('Number of pixels for each side of each box: ');
buffer = input('Buffer on extreme sides of first and last box (zero): ');
%Get all image files (bmp)
filesLocation = uigetdir(pwd, 'Pick folder with image files: ');
cd(filesLocation);
32
files = ls('*bmp');
parentFolder = uigetdir(pwd, 'Select directory to place new folder with saved data');
%Specify Sample and Wedge Name
%This should be changed to either show what the name of the imags chosen is
%or get the name automatically from the file name or folder name
% SampleName = input('Name of Sample and Wedge Number (e.g. 1226-38Part1) No
Underscores: ', 's');
%Specify location of saved data
name = input('Name of images (to be saved as): ', 's');
%name='results';
saveFile = [parentFolder,'\', name,'\'];
mkdir(parentFolder,name);
%Line up one piece to get parameters
cd(..);
[xMin xMax yMin yMax] = lineUp(saveFile, name, numBoxes, sides, buffer);
cd(filesLocation);
box = cell([1, numBoxes]);
fprintf('\n Number of images to be loaded: %d \n', size(files,1));
33
%%
% Process each image file
tic
for jj=1:size(files,1)
%Read each image
file = files(jj,:);
imag = imread(file);
imag = ~imag;
%Take out boxes
for ii = 1:numBoxes
imagBox = imag(yMin:yMax,xMin(ii):xMax(ii));
box{ii}(:,:,jj) = imagBox;
end
end
% Record information
fid = fopen([saveFile, name, '_3DBoxParameters.txt'],'a');
fprintf(fid, '3D Box Parameters for: %s\r\n', name);
fprintf(fid, 'Total number of images: %d\r\n', size(files,1));
fprintf(fid, 'Dimensions of boxes: %d pixels (%d pixel buffer)\r\n\r\n', sides, buffer);
34
fprintf(fid, 'y lower bound: %d\r\n', yMin);
fprintf(fid, 'y upper bound: %d\r\n', yMax);
for j=1:numBoxes
fprintf(fid, 'x lower and upper bounds for Box %d: (%d, %d)\r\n', ...
j, xMin(j), xMax(j));
end
fprintf(fid, '\r\nBoxes go from endsteal outward radially to periosteal\r\n');
fclose(fid);
% Save boxes as mat file
save([saveFile, 'Boxes_', name, '.mat'], 'box');
%%
% Extract the names of the file
Samples = uigetdir(pwd, 'Pick folder to name the image: ');
for ii=length(Samples):-1:1 ;
if(Samples(ii) == '\') break;
end;
end;
SampleName = Samples(ii+1:end);
%%
% Create folders to save the images
cd (saveFile);
mkdir('periosteal');
35
mkdir('midcortex');
mkdir('endosteal');
cd...
% To generate the images for each ROI
for j = 0 : size(files,1)-1 % number of images from each ROI
data =(box{1}(:,:,j+1) );
data1=imrotate(data,-90);
imwrite(data1,['endosteal/', SampleName,'_ENDO_', num2str(j,'%04i'),'.bmp']); %
change part number for each wedge
end
for k = 0 : size(files,1)-1 % number of images from each ROI
data =(box{2}(:,:,k+1) );
data1=imrotate(data,-90);
imwrite(data1,['midcortex/', SampleName,'_MID_', num2str(k,'%04i'),'.bmp']); % change
part number for each wedge
end
for l = 0 : size(files,1)-1 % number of images from each ROI
data =(box{3}(:,:,l+1) );
data1=imrotate(data,-90);
imwrite(data1,['periosteal/', SampleName,'_PERI_', num2str(l,'%04i'),'.bmp']); % change
part number for each wedge
end
36
APPENDIX B:
CALCULATING TWO POINT STATISTICS:
% This m file creates the elements and defines the nodes for the two point
% stats of ROI.
function [nodes elements] = MakeMesh(M) % nodes and elements are output and M is
the input from twopoint stats
%meshgrid -
[X Y Z] = meshgrid(0:size(M,1),0:size(M,2),0:size(M,3));
A = size(X)
% creates the mesh
nodes = [X(:) Y(:) Z(:)];
[nodes sort_map] = sortrows(nodes, [-1 -3 -2]);
% Sort map tells us where a row in the sorted matrix comes from in the
% unsorted one
% Inverse sort map tells us where a row in the unsorted matrix wound up in
% the sorted one.
inv_sort_map(sort_map) = 1:length(sort_map);
37
%elements = zeros(sum(M(:)), 8);
num_elements = 0;
for ii=1:size(M, 1)
for jj=1:size(M, 2)
for kk=1:size(M, 3)
if(M(ii, jj, kk) == 1)
num_elements = num_elements + 1;
els = [ii, jj, kk; ii+1, jj, kk; ii, jj+1, kk; ii+1 jj+1 kk; ...
ii, jj, kk+1; ii+1, jj, kk+1; ii, jj+1, kk+1; ii+1 jj+1 kk+1;];
% keyboard
% This is the point when the 3d subscripts for each node
% are being converted to linear indices. The error is being
% caused by the passing of the incorrect size to the
% sub2ind function. This error will occur when the matrix
% that we are tryin to convert has unequal dimension
els_linear = sub2ind(size(X), els(:, 1), els(:, 2), els(:, 3));
elements(num_elements, :) = inv_sort_map(els_linear);
end
end
38
APPENDIX C
CALCULATING PCA WEIGHTS
close all
D = dir('/mnt/nfs01/users/alka/matlab/stats');
% Get rid of this LATER!!!! When files are done copying!!!!
D = D(3:end-16);
D(10) = [];
D(51) = [];
NUM_SAMPLES = size(D, 1);
A = [];
%NUM_SAMPLES = 20;
kk = 1;
for ii=1:NUM_SAMPLES
fprintf(1, 'Loading Sample %d of %d\n', ii, NUM_SAMPLES);
in_file = D(ii).name;
G = load(sprintf('/mnt/nfs01/users/alka/matlab/stats/%s', in_file), 'G'); G = G.G;
if(ii == 1)
39
fprintf(1, ' Allocating A Matrix ... ');
A = zeros(size(G,2)*size(G,3)*size(G,4), NUM_SAMPLES);
fprintf(1, 'Done\n');
end
%
% T = squeeze(G(1, :, :, :)); A(:, kk) = T(:);
% T = squeeze(G(2, :, :, :)); A(:, kk+1) = T(:);
% T = squeeze(G(3, :, :, :)); A(:, kk+2) = T(:);
T = mean(G,1) ; A(:,ii) = T(:);
% kk = kk + 3;
end
fprintf(1, 'Mean Centering Data ... ');
A = A - repmat(mean(A, 2), [1 size(A, 2)]);
fprintf(1, 'Done\n');
[~, S, V] = pca(A, size(A, 2));
[~, S, V] = pca(A, 10);
L = S * V';
E = S * S';
fprintf(1, 'Saving Results ... ');
save -v7.3 results_averaged.mat L S V E
fprintf(1, 'Done\n');
40
APPENDIX D
PLOTTING CONVEX HULL FOR EACH DATA SET
clc
%Reading data from Excel
X_1 = xlsread('MeanPCA','wedge1','F4:H12');
X_2 = xlsread('MeanPCA','wedge1','N4:P10');
Y_1 = xlsread('MeanPCA','wedge2','N4:P10');
Y_2 = xlsread('MeanPCA','wedge2','F4:H12');
Z_1 = xlsread('MeanPCA','wedge3','F4:H12');
Z_2 = xlsread('MeanPCA','wedge3','N4:P10');
A_1 = xlsread('MeanPCA','wedge4','F4:H12');
A_2 = xlsread('MeanPCA','wedge4','N4:P10');
B_1 = xlsread('MeanPCA','wedge5','F4:H12');
B_2 = xlsread('MeanPCA','wedge5','N4:P10');
C_1 = xlsread('MeanPCA','wedge6','F4:H12');
C_2 = xlsread('MeanPCA','wedge6','N4:P10');
% calculating Convex Hull indices
K1 = convhulln(X_1);
K2 = convhulln(X_2);
K3 = convhulln(Y_1);
K4 = convhulln(Y_2);
K5 = convhulln(Z_1);
K6 = convhulln(Z_2);
41
K7 = convhulln(A_1);
K8 = convhulln(A_2);
K9 = convhulln(B_1);
K10 = convhulln(B_2);
K11 = convhulln(C_1);
K12 = convhulln(C_2);
colormap('default')
trisurf(K1,X_1(:,1),X_1(:,2),X_1(:,3), ones(9,1))
hold on
trisurf(K2,X_2(:,1),X_2(:,2),X_2(:,3), 2*ones(7,1))
hold on
trisurf(K3,Y_1(:,1),Y_1(:,2),Y_1(:,3), 3*ones(9,1))
hold on
trisurf(K4,Y_2(:,1),Y_2(:,2),Y_2(:,3), 4*ones(7,1))
hold on
trisurf(K5,Z_1(:,1),Z_1(:,2),Z_1(:,3),5*ones(9,1))
hold on
trisurf(K6,Z_2(:,1),Z_2(:,2),Z_2(:,3),6*ones(7,1))
hold on
trisurf(K7,A_1(:,1),A_1(:,2),A_1(:,3),7*ones(9,1))
hold on
trisurf(K8,A_2(:,1),A_2(:,2),A_2(:,3),8*ones(7,1))
hold on
trisurf(K9,B_1(:,1),B_1(:,2),B_1(:,3),9*ones(9,1))
hold on
trisurf(K10,B_2(:,1),B_2(:,2),B_2(:,3),10*ones(7,1))
42
hold on
trisurf(K11,C_1(:,1),C_1(:,2),C_1(:,3),11*ones(9,1))
hold on
trisurf(K12,C_2(:,1),C_2(:,2),C_2(:,3),12*ones(7,1))
xlabel('PCA 1');
ylabel('PCA 2');
zlabel('PCA 3');
title('Classification of Bone Microstructure')
hold off
43
REFERENCES
1. Niezgoda SR, Fullwood DT, Kalidindi SR. Delineation of the space of 2-point
correlations in a composite material system. Acta Materialia. 2008;56(18):5285-5292.
Available at: http://linkinghub.elsevier.com/retrieve/pii/S1359645408004886. Accessed
August 8, 2012.
2. Fullwood DT, Niezgoda SR, Kalidindi SR. Microstructure reconstructions from 2-point
statistics using phase-recovery algorithms. Acta Materialia. 2008;56(5):942-948.
Available at: http://linkinghub.elsevier.com/retrieve/pii/S1359645407007458. Accessed
August 8, 2012.1. Bazarra-fernández A. Evolutionary Pathways of Diagnosis in
Osteoporosis. Bone. 2001.
3. Bazarra-fernández A. Evolutionary Pathways of Diagnosis in Osteoporosis. Bone. 2001.
4. Jepsen, K. J., Centi, A., Duarte, G. F., Galloway, K., Goldman, H., Hampson, N., Lappe,
J. M., Cullen, D. M., Greeves, J., Izard, R., Nindl, B. C., Kraemer, W. J., Negus, C. H.
and Evans, R. K. (2011), Biological constraints that limit compensation of a common
skeletal trait variant lead to inequivalence of tibial function among healthy young adults.
J Bone Miner Res, 26: 2872–2885. doi: 10.1002/jbmr.497
5. 1. Rho JY, Kuhn-Spearing L, Zioupos P. Mechanical properties and the hierarchical
structure of bone. Medical engineering & physics. 1998;20(2):92-102. Available at:
http://www.ncbi.nlm.nih.gov/pubmed/21885114.
6. Boyde, A. and Lester, K. S. (1972), 'Elemental particles in bone and dentine', Calcif
Tissue Res, 10 (3), 256.
44
7. Enlow, D. H. (1962), 'A study of the post-natal growth and remodeling of bone', Am J
Anat, 110,79-101.
8. Enlow, Donald H. (1963), Principles of bone remodeling; an account of post-natal growth
and remodeling processes in long bones and the mandible (American lecture series.;
Springfield, Ill.,: Thomas) 131 p.
9. Enlow, Donald H., Moyers, Robert E., and Merow, William W. (1982), Handbook of
facial growth (2nd edn.; Philadelphia: Saunders) xiii, 486 p.
10. Augat, P., Reeb, H., and Claes, L. E. (1996), 'Prediction of fracture load at different
skeletal sites by geometric properties of the cortical shell', J Bone Miner Res, 11 (9),
1356-63.
11. Nordin, Margareta and Frankel, Victor H. (2001), Basic biomechanics of the
musculoskeletal system (3rd edn.; Philadelphia: Lippincott Williams & Wilkins) xvii,
467 p.
12. Knott, L. and Bailey, A. J. (1998), 'Collagen cross-links in mineralizing tissues: a review
of their chemistry, function, and clinical relevance', Bone, 22 (3), 181-7.
13. Bonfield, W. and Clark, E. A. (1973), 'Microstrain measurements of the deformation of
compact bone', J Physiol, 229 (1), 5P.
14. Delmas, P. D. and Seeman, E. (2004), 'Changes in bone mineral density explain little of
the reduction in vertebral or nonvertebral fracture risk with anti-resorptive therapy', Bone,
34(4), 599-604.
15. Engelke, K., et al. (2009), 'Quantitative computed tomography (QCT) of the forearm
using general purpose spiral whole-body CT scanners: accuracy, precision and
comparison with dual-energy X-ray absorptiometry (DXA)', Bone, 45 (1), 110-8.
45
16. Tommasini, S. M., et al. (2005), 'Relationship between bone morphology and bone
quality in male tibias: implications for stress fracture risk', J Bone Miner Res, 20 (8),
1372-80.
17. Blair, J. M. et al. 2007. Modeling three-dimensional microstructure in heterogeneous
media. Soil Science Society of America Journal. 71(6). pp.1807
18. Hornbogen E. A systematic description of microstructure. Journal of Materials Science
1986;21:3737-3747
19. Fukunaga K. Introduction to statistical pattern recognition. Boston: Academic Press,
1990
20. Simmons J. LARGE DATASET GENERATION , INTEGRATION AND
SIMULATION IN MATERIALS SCIENCE ( PREPRINT ). Work. 2011.
46
47
48
49
50
51