Imm 6090
Imm 6090
Imm 6090
segmentation
IMM-MSC: ISSN
Summary
The PET scanners show the metabolic activity of the studied biological
tissues and they are very important in the clinical diagnosis of brain diseases.
They generate low resolution images that can be improved with the estimated
GM volume of the brain. The MRI scanners provide high resolution and can
be optimized for the segmentation of anatomical structures. Therefore, the goal
of this project is the improvement of a state-of-the-art automatic method that
segments MRI brain volumes into GM, WM and CSF tissues.
The ’New Segmentation’ method implemented in SPM8 allows multispec-
tral input data, but it assumes non-correlated modalities. Therefore, this thesis
modifies this method and its Matlab implementation in order to include correla-
tion between modalities in the generative model, and hence use all the potential
of multispectral approaches.
The modified method was compared to other uni-modal and multi-modal
methods in the segmentation of two different datasets. The results showed that
the multi-modal approaches were better that the uni-modal. In addition, the
obtained Dice scores of the modified method were slightly higher than the ones
of the original method. It was also visually checked the segmented volumes from
original and modified method, and it showed that the latter is able to segment
better the voxels that lie in the interface among several tissues.
ii
Preface
Lyngby, 2011
I wish to thank all the people involved in this thesis who helped me to
overcome the difficulties of this challenging project. I would like to thank my
supervisors prof. Rasmus Larsen and Ph.D. Koen Van Leemput for his guidance
and technical feedback. A special thanks goes to my supervisor Ph.D. Claus
Svarer for his personal support and for sharing with me his wide MRI expertise
in numerous interesting discussions.
I would like also to thank the external collaborators Ph.D. William Baare
and Ph.D. Arnold Skimminge, who introduced the acquisition setup and pro-
vided the mri dataset. I thank as well the collaboration of prof. Knut Conradsen
to help me to develop a critical and rigorous approach to the problems.
And last but not least, I wish to thank the company and support of my
partner, family and friends.
Mange tak,
vi
Contents
Summary i
Preface iii
Acknowledgements v
Contents ix
Acronyms xi
1 Introduction 1
1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Baseline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Project goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.5 Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.6 Thesis Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 Background 9
2.1 Brain Anatomy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2 Magnetic Resonance Imaging . . . . . . . . . . . . . . . . . . . . 12
2.3 Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3 Neuroimaging Processing 23
3.1 Intensity model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.2 Registration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.3 Bias Field Correction . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.4 Scalp-Stripping . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.5 Smoothing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.6 Priors and Templates . . . . . . . . . . . . . . . . . . . . . . . . . 48
viii CONTENTS
5 Validation 87
5.1 Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
5.2 Golden Standard . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
5.3 Brain f4395 - Visualization . . . . . . . . . . . . . . . . . . . . . 92
5.4 BrainWeb phantoms - Dice Score . . . . . . . . . . . . . . . . . . 104
5.5 CIMBI database - Age-Profile . . . . . . . . . . . . . . . . . . . . 112
6 Discussion 115
6.1 Resume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
6.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
6.3 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Bibliography 128
Appendices 129
B Mathematics 137
B.1 Gaussian distribution . . . . . . . . . . . . . . . . . . . . . . . . . 138
B.2 2D Gaussian expression . . . . . . . . . . . . . . . . . . . . . . . 142
B.3 Cost Function of M-step . . . . . . . . . . . . . . . . . . . . . . . 145
B.4 Central and non-central moments . . . . . . . . . . . . . . . . . . 146
B.5 Solution to a third degree equation . . . . . . . . . . . . . . . . . 149
B.6 Registration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
C SPM 155
C.1 Input Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
C.2 Original Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
C.3 Modified Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
C.4 Modified Code (version 2) . . . . . . . . . . . . . . . . . . . . . . 162
E Volumes 191
E.1 MRI Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
E.2 Tissue Probability Maps for Prior Templates . . . . . . . . . . . 194
E.3 Segmentation of volumes from subject f4395. . . . . . . . . . . . 202
AD Alzheimer Disease.
AIDS Acquired Immune Deficiency Syndrome.
ANN Artificial Neural Network.
BG Background.
BIC Brain Imaging Centre.
BSE Brain Surface Extractor.
BST Brain Extraction Tool.
EM Expectation Maximization.
EMS Expectation Maximization Segmentation.
EPI Echo-Planar Imaging.
HC Healthy Control.
HMM Hidden Markov Model.
HMRF Hidden Markov Random Field.
HWA Hybrid Watershed Algorithm.
LC Linear Combination.
LE Least Squares.
LM Levenberg-Marquardt.
PD Proton Density.
PET Positron Emission Tomography.
ppm parts per million.
PVE Partial Volume Effect.
TE echo time.
TN True Negative.
TP True Positive.
TPM Tissue Probability Map.
TR time repetition.
WM White Matter.
Chapter 1
Introduction
1.1 Motivation
The Neurobiology Research
Unit (NRU) of Rigshospitalet in
Copenhagen (Denmark) has a
particular interest in the pre-
cise segmentation of sub-cortical
structures of the brain with
Positron Emission Tomography
(PET) scans. This kind of neu-
roimaging technique shows the
metabolic activity of the studied
biological tissues, and it is usually Figure 1.1: Neurobiology Research Unit.
corrupted by artifacts that can be
compensated with the anatomy of
the associated structures. For this anatomy estimation is used the Magnetic
Resonance (MR) images [89]. In addition, MRI scans have a higher resolution
(∼ 1mm) over PET (∼ 8mm) that allows an improved Partial Volume Effect
(PVE) correction [64].
2 Introduction
The high resolution MR images are segmented into Grey Matter (GM),
White Matter (WM) and CerebroSpinal Fluid (CSF) with a certain probability
to generate Volume Of Interest (VOI) brain templates that are used afterwards
in the reconstruction (co-registration) of PET images, as described by C. Svarer
et al. [79]. In this way, it is possible to correlate the number of receptors in
PET scans with the GM volume in MR images.
1.2 Dataset
The MRI dataset includes approximately 200 T1 and T2 weighted volumes
from a 3T scanner. The original resolution for T1 and T2 modalities is ∼ 1mm
and ∼ 1.1mm, respectively. Although, they are re-sliced to have a final resolu-
tion of ∼ 1mm isotropic voxels. The scans are recorded at the DRCMR [53] of
Hvidovre Hospital as part of the Center for Integrated Molecular Brain Imag-
ing (CIMBI) project [58]. There are also available another 200 images with an
old scanner and other images from brains with some pathologies, like Tourette
syndrome, Obsessive Compulsive Disorders, Obesity, Winter Blues depression,
and others; but they have been initially discarded for this project. All the scans
were acquired with the Magnetom Trio scanner of Siemens [57].
The whole data set have been recorded with the same scan and acquisition
protocol, which did not suffer any update or modification. The images have been
co-registered in order that T1 and T2 scans are in the same spatial coordinate
system and with the same resolution. However, the number of scans that have
been re-sliced after the normalization is much smaller. None of the volumes
have been hand-segmented, as it is a hard and time consuming process with
high variability.
1.2 Dataset 3
The Figure 1.3 depicts the T1 and T2 MRI scan of the subject f4395, who
is a real volunteer of the CIMBI project. This kind of representation is the
usual 2D way of representing 3D image data with the three orthogonal planes
(coronal, sagittal and transverse).
The MR images are based on received intensity, thus the visual representa-
tion is a grey scale volume, where brighter voxels are associated with a larger
intensity values. The subfigures of the top row represent the T1 scans. In a wide
sense, it can be stated that the dark voxels correspond to fluid-based tissues like
GM, and bright voxels to fat-based tissues like WM. The CSF is basically water,
thus it appears almost black. On the other hand, the bottom row represents the
T2 scans, and the intensity associations in this case are in general the opposite
than for the previously presented T1 scan. It can be seen in the figure that black
stripes have been added to give a regular cubic shape to the 3D scans with final
dimensions of 256 × 256 × 256 voxels. For the case of T2 MRI, the head is not
perfectly centered, and the back part of the head appears in the left of the image
for the sagittal plane, and in the top part of the image for the transverse plane.
This error is due to inhomogeneities of the magnetic field that are not corrected
by a shimming calibration.
Figure 1.3: Preview of some slices of the T1 and T2 MRI data from subject
f4395. Left column: Coronal plane. Middle column: Sagittal plane. Right
column: Transverse plane. The first row corresponds to the T1 scan, and the
second to T2 .
4 Introduction
1.3 Baseline
The baseline of this project corresponds to the original pipeline for the MRI
brain segmentation, which is based on the ’Unified Segmentation’ method devel-
oped by J. Ashburner, K. Friston et al. [26]. This method is implemented in the
Matlab software of Statistical Parametric Mapping (SPM) [60]. It combines in
the same generative model the classification, bias field correction and template
registration. In fact, the segmentation itself is done by fitting the mixture pa-
rameters of a Mixture of Gaussians (MoG) model, where each cluster is modeled
by a Gaussian. Therefore, the tissue segmentation is done by an unsupervised
clustering technique.
The segmented volumes that DRCMR provides to the NRU are processed by
the SPM5 software plus the voxel-based morphometry (VBM)5 toolbox. How-
ever, at the DRCMR, they are working for other projects with SPM8 plus the
toolboxes VBM8 and template’o’matic, both from the Structural Brain Imaging
Group at the University of Jena [52]. According to the NRU, the reason for not
using the last version of the software lies on the fact that not clear improve-
ments of the new versions have been stated that justifies the migration of all the
previous segmented images into a new pipeline. However, it is now intended to
do this update, thus the starting point for further improvements is SPM8.
In the original pipeline, the T2 volumes are used to generate a binary mask
of brain voxels. This mask is used in the scalp-stripping step to hide T1 voxels
that correspond to air, skin, fat, muscle, bone or meninges. After this brain
tissue extraction, it is done the segmentation itself on the T1 volumes, where a
certain probability of being GM, WM, and CSF is assigned to the voxels inside
of the brain to generate the Tissue Probability Map (TPM)‘s.
The Figure 1.4 depicts the main steps of the segmentation procedure as
described previously. The top row corresponds to the original T1 scan. The
second row presents the brain mask extracted from T2 data as a red overlapping
layer on the T1 original slices. For the transverse plane, it can be seen how the
mask wrongly classifies part of the left eye muscle as brain tissue, namely as
CSF. The bottom row corresponds to the voxels after the scalp-stripping, which
are coloured according to their associated tissue class, where GM is in purple,
WM in turquoise and CSF in beige.
1.3 Baseline 5
Figure 1.4: Representation of the three main steps of MRI brain segmentation
done by the original pipeline, which consists on a T2 masking and SPM5+VBM5
applied on the T1 modality. The presented data correspond to subject f4395.
Left column: Coronal plane. Middle column: Sagittal plane. Right column:
Transverse plane. The top row corresponds to the original T1 scan. The second
row presents the brain mask extracted from T2 data as a red overlapping layer on
the T1 original slices. The bottom row corresponds to the brain tissue generated
by SPM5+VBM5, where GM is in purple, WM in turquoise and CSF in beige.
6 Introduction
1.5 Specifications
Several meetings and discussions were needed to give shape of a specific
project description. It was needed to take into account what is feasible to do in
the available time according to the requirements of all involved entities. In this
sense, it must be appreciated the technical advices received from DTU, NRU
and DRCMR supervisors. Finally, it was agreed on several points that could be
improved during this thesis:
• Multispectral segmentation. The available dataset includes T1 and T2
MRI scans. Therefore, both modalities can be combined in the segmenta-
tion process, where T2 is not used just for masking. The tissues generally
have different intensity contrast in each modality. Therefore, the use of
both of them can increase the discrimination between different tissues.
• Increase the number of tissues. The current segmentation is based on
4 labels, i.e. GM, WM, CSF and rest. Several authors have proposed to
include more tissues in order to do a more realistic and robust character-
ization of the head tissues.
• Increase the number of clusters per tissue. The original baseline
characterizes each tissue with one cluster. Therefore, this number can be
increased in order to fit better the intensity distribution of each class.
During the development of this thesis, it was discovered that the Seg toolbox
(’New Segmentation’) in SPM8 has already implemented these three improve-
ments. However, the multispectral implementation of this method assumes
non-correlation among modalities. Therefore, the goal of this project is the
modification of the Seg toolbox in order that the method deals with correlated
modalities. Therefore, the baseline is the Seg toolbox of SPM8, and the valida-
tion is based on the visual inspection of the generated TPM, the Dice score after
the segmentation of brain phantoms and the estimation of a volume age-profile
for each tissue.
1.6 Thesis Outline 7
Background
The brain is composed by more than 100 billions of neurons and it is the
centre of the Central Nervous System (CNS), where all the nervous connections
merge. It is placed inside of the head and fills most of its volume, which is around
1450 cm3 on average for human adults. Under the skin, fat, muscles and scalp,
the meninges are the last protection of the brain. They are composed by three
layers: dura mater, arachnoid mater, and pia mater. The brain is composed by
four main structures: cerebrum, diencephalon, brain stem and cerebellum, which
are depicted in the Figure 2.2 with colors red, violet, blue and green.
Figure 2.2: Human brain representation where the main anatomical structures
are highlighted. The four main parts of the brain are presented: cerebrum (red),
diencephalon (violet), brain stem (blue) and cerebellum (green). Besides, the
cortical and subcortical structures of the cerebrum are also presented: cerebral
cortex (pink), basal ganglia (orange) and limbic system (dark blue). [3D brain
images generated by Google Body [61].]
The goal of this project is the segmentation of White Matter (WM) and
Grey Matter (GM). The WM has a high content of fat, and the GM contains
more water. In turn, the CerebroSpinal Fluid (CSF) is mostly composed by
water. The different composition of these tissues gives a contrast in the MR
scans that permits its differentiation. This phenomenon is the basement of the
segmentation process, and it is presented with more details in the next section.
There are different brain imaging modalities, like Magnetic Resonance Im-
age (MRI), Positron Emission Tomography (PET), Diffusion Tensor Imaging
(DTI), Computed Tomography (CT) and Single Photon Emission Computed
Tomography (SPECT).
The MRI was mainly developed around 1980 as an application of the already
studied phenomenon of Nuclear Magnetic Resonance (NMR), which leaded to
several Nobel prizes. It applies static and variant magnetic fields to make res-
onate the molecules of the body. The effect of stopping the variant magnetic
field generates signals that can be measured by a conductive field coil around
the body and processed to obtain a 3D grey-scale image. The intensity, recov-
ering time and frequency of the molecular vibrations determines the acquired
intensity pattern.
Advantages
The MRI technique has several advantages compared to other neuroimaging
techniques. For example, it is fast and it does not use ionizing radiation; there-
fore, it can be used several times on the patients because the absorbed radiation
is minimal. Its isotropic resolution is around 1 mm3 with 3T MRI scanners,
which outperforms the 8 mm3 of PET. It has a high versatility, because it can
be used to study structural and functional brain features with different con-
figurations. Besides, it is not affected by the hardening beam effect of CT [5]
because the range of frequencies is small, and the attenuation coefficient of the
tissues is almost homogeneous.
Disadvantages
On the other hand, it is an expensive and complex technique. There are
many parameters that must be tuned up correctly in order to optimize the
image acquisition depending on the circumstances [72]. In addition, all the
metal objects of the patients should be removed before the scanning starts,
which is impossible for some kind of surgical implants. Besides, this technique
is only suited to analyse soft tissues because the bones have not a significant
contrast in the images.
In the sections A.1 and A.2 of the Appendices, it is explained in details the
relation between the acquired intensities by different modalities and the kind
of tissue in the body. In short, it can be stated that the T1 MR images
have brighter voxels for WM, darker for GM, and almost black for
CSF. The T1 images show a tumour with larger intensity value than a normal
tissue. Therefore, some lesions in the WM areas can look alike GM in T1 images
due to the increase of water. Besides, the voxels with muscle tissue appear
brighter than for fat. Almost the opposite intensity contrast will be expected
in T2 images. However, the exact intensity value for each tissue slightly vary
depending on which part of the brain is located.
Figure 2.3: Intensity histogram of the segmentation for the subject f4395 using
T1 and T2 MRI. The black line corresponds to the GM, the blue one to the WM,
the green line to the CSF, and the red line to the total brain. The units of the
x-axis correspond to intensity values, and the y-axis to the number of voxels for
each intensity bin. All the histograms are built with 300 bins.
The MR images from the DRCMR are stored in a NIfTI-1 file format created
by the Neuroimaging Informatics Technology Initiative (NIfTI) [56], which is the
most spread standard. It allows several coordinate systems -like Montreal Neu-
rological Institute (MNI) space (MNI-152) or Talairach-Tournoux-, two affine
coordinate definitions -orthogonal transform with 6 parameters or general affine
transform with 12 parameters-, single (Nifti) or dual (Analize) file storage (.nii
or .hdr/.img), affine data scaling -truevalue = α · datavalue + β-, several units
of spatio-temporal dimensions, and others.
Figure 2.4: Representation of the brain slices format for the sagittal, transverse
and coronal planes.
Figure 2.5: Preview of the T1 MRI data from subject f4395. The presented
planes correspond to coronal, sagittal and transverse.
16 Background
2.3 Segmentation
The segmentation of the brain stands for its decomposition into different
volumes with similar structural or functional features. In the case of structural
MRI brain segmentation, the available data corresponds to a 3D map of voxels,
which are the analogous of pixels in a 2D map. These voxels are grouped
according to quantitative characteristics like intensity, colour or texture [72];
which implies that after the segmentation process, each voxel has an associated
label explaining to which group it belongs to. The usual labels are WM, GM
and CSF. The scalp, fat, skin, muscles, eyes and bones are preferable removed in
a previous step or modeled with a mask during a process called scalp stripping,
which will be briefly explained in the section 3.4.
The Figure 2.6 represents graphically the brain segmentation result on a
transverse slice of MRI T1 . On the left, it appears the acquired image after
pre-processing with darker colour for fluid-composed tissues (GM) and brighter
colour for fat-based tissues (WM). On the right, it appears the estimated 2D seg-
mentation represented with three colours, where each tone represents each label.
In this way, red, green and blue stands for GM, WM and CSF, respectively.
There are several free available tools to perform automatic MRI brain seg-
mentation. The most popular is SPM, which is based on the ’Unified Segmenta-
tion’ method. It uses a voxel-based approach with a statistical inference on the
GMM. This Matlab software is developed from the theory of K. Friston and J.
Ashburner from the University College of London [26] [26] [24]. As stated previ-
ously, this software/method is the baseline for this project. This implementation
has several extensions, one of them is the Expectation Maximization Segmenta-
tion (EMS) created by Koen Van Leemput [82] [47] [83]. This SPM extension
is a model-based automated segmentation with Markov Random Field (MRF)
as regularization that uses multispectral data to improve accuracy of lesions
segmentation. The VBM toolbox from the University of Jena applies a modu-
lation to include spatial constraints in the tissue volumes. Besides, it can work
without prior templates by using Maximum A Posteriori (MAP) techniques. It
also includes DARTEL normalization and PVE estimation.
FMRIB Automated Segmentation Tool (FAST)/FMRIB Software Library
(FSL) is a library developed by the Analysis Group of Functional Magnetic
Resonance Imaging of the Brain (FMRIB) in the Oxford University [76] [90].
The 3D segmentation and the inhomogeneity correction is done with a method
based on a Hidden Markov Random Field (HMRF) model and an Expectation
Maximization (EM) algorithm. In addition, FreeSurfer is another important
segmentation tool that is compatible with FSL and developed by the Martinos
Center for Biomedical Imaging in the Massachusetts General Hospital [8] [16].
Klauschen et al. [37] compared FSL, SPM5 and FreeSurfer with the same
images from the BrainWeb MRI database [55] in terms of GM and WM volumes.
In general, the three methods had a deviation up to >10% from the reference
values of gray and white matter. The best sensitivity corresponds to SPM.
The volumetric accuracy was similar in SPM5 and FSL, but better than for
FreeSurfer. The robustness against changes of image quality was also tested,
and FSL showed the highest stability for white (<5%), while FreeSurfer (6.2%)
scored the best for gray matter.
Although the previously mentioned software package are the most well-
known, there are several more available. However, there will not be further dis-
cussion about the methods in the rest of this thesis because of two main reasons.
First, because because the scope of this project and its goals are oriented on
an improvement of its current baseline with SPM, and not a comparison among
methods. Second, because the task of comparing methods is tough. It requires
high rigour, with a validation and a dataset equally fair for all the methods, and
with an implementation done with a deep knowledge and understanding of the
algorithms.
20 Background
Thus, the iterative process optimizes locally each of the three group of
parameters until convergence. A detailed description of these steps are included
in the two following sections.
It is not the intention of the thesis to modify the bias field correction and
registration. However, it is needed to understand how they work due to the high
coupling with the classification step.
22 Background
Chapter 3
Neuroimaging Processing
This chapter includes the processing done after the acquisition of the MR
images. Although, this project focuses on the brain segmentation of SPM, there
are other steps in the pipeline that should be mentioned and understood. Some
of them improve slightly the result, but others are strictly needed. Each segmen-
tation method uses different layouts, different order of the blocks or different
algorithms. In the case of SPM some steps are even done iteratively [26] [83].
Each section of this chapter presents the definition of a different processing
step and several possible implementations of the same are discussed. Finally,
it is explained how SPM implements this step, and it is presented one example
with real MRI data.
The first section of Intensity Model describes the MoG model and justi-
fies several improvements from the baseline of ’Unified Segmentation’, like the
inclusion of more tissues and more clusters per class, or the multispectral ap-
proach with several modalities. In the section Registration and Bias Field
Correction, it is explained how the templates are spatially aligned to the raw
volumes and how the intensities inhomogeneities are corrected.
Finally, the last three sections include the results of the Scalp Stripping,
the effects of the Smoothing and the main features of Priors and Templates.
24 Neuroimaging Processing
Figure 3.1: Intensity histograms of the brain voxels for the subject f4395 us-
ing T1 and T2 MRI. It is overlapped three red Gaussian that approximate the
expected class distribution of GM, WM and CSF. The units of the y-axis cor-
respond to the number of voxels, and the units of the x-axis are the intensity
values. All the histograms are built with 300 bins of the same size. For the
T1 histogram, from the leftmost to the rightmost distribution, the tissues corre-
spond to CSF, GM and WM. Likewise, the order is inverse for the T2 histogram.
There is a big overlap among classes, which means that one voxel is not
purely composed by one single tissue. Due to the PVE, some voxels lie in the
interface between two (or more) classes. The resolution of the scanner is finite;
thus, the acquired intensity at this point is a mix of the different tissues. In
addition, the assumption of each tissue modeled by a Gaussian is not realistic.
An increase in the number of clusters makes the distribution non-Gaussian and
it can fit better the actual intensity distribution.
26 Neuroimaging Processing
Figure 3.2: Slices of the T1 MRI scan from the subject f4395. The top row
contains head tissues, and the bottom row shows just Bone and ST.
Figure 3.3: Intensity histogram of the head voxels for the subject f4395 using
T1 and T2 MRI. The black line corresponds to the GM, the blue one to the WM,
the green line to the CSF, the yellow one to the ST+Bone, and the red line to
the head voxels. The units of the x-axis correspond to intensity values, and the
y-axis is the number of voxels for each intensity bin. All the histograms are built
with 300 bins. The voxels with intensity values lower than 50 are dismisses, as
they can be considered BG.
28 Neuroimaging Processing
3.1.3 Multispectral
In the previous sections, it was presented some histograms that showed the
important overlap between classes. In fact, the overlap between GM and WM
is higher than 10% for T1 [22]. Therefore, a segmentation method cannot be
just based on the intensity distribution from one modality. One way to solve
this problem is with the use of priors that give spatial information about where
is more feasible to find each tissue. Another improvement is the combination
of several modalities with different intensity contrasts that increases the dimen-
sionality of the clustering and makes more feasible the discrimination among
several classes. For example, the multispectral approaches are better in the de-
tection of the WM lesions, where the uni-modal methods missclassify them as
GM. The ’New Segmentation’ method already includes prior templates and a
basic multispectral approach. However, the algorithm assumes non-correlation
among modalities, which will be modified in this project.
Therefore, the multispectral approach stands for the use of several imaging
techniques from the same anatomical structures. In order to gain something, it is
needed that the tissues have different responses to the MR pulse frequencies, i.e.
different intensity contrast from T1 than for T2 . This constraint also imposes the
modifications of the algorithms that are based on intensity similarities, because
the intensity patterns between both modalities are different.
The Figure 3.5 depicts the joint 2D intensity histogram for T1 and T2 with
the associated individual histograms, T1 on the left and T2 on the top. In the
individual histograms, it is overlapped three red Gaussian that approximates
the expected class distribution of GM, WM and CSF. It can be seen that the
increase of dimensionality by adding T2 allows a better separation of classes.
Hence, the fully multispectral approach that is developed in this thesis seems a
good improvement of MRI segmentation.
Figure 3.5: Joint 2D intensity histogram for the segmentation of the MRI scans
from the subject f4395, which is done by the original baseline. On the edges, it
is presented the associated 1D histograms of each modality, T1 on the left and
T2 on the top. In the individual histograms, it is overlapped three red Gaussian
that approximates the expected class distribution of GM, WM and CSF.
30 Neuroimaging Processing
3.2 Registration
The brain volumes are represented in a 3D coordinate reference system,
where each intensity value is a voxel located using three coordinates (x, y, z). In
case the volumes are acquired from different scanners, patients or time epochs,
the spatial correspondence of anatomical structures is partially lost. Therefore,
it is needed to apply a one-by-one mapping between both coordinate spaces [23].
The term image registration refers to the general transformation from two
different spaces. There are special cases of registration, like co-registration that
is used for intra-subjects registrations, re-alignment that is used for motion
correction within the same subject, and normalization that is used for inter-
subjects registrations. The latter usually implies the registration to a standard
stereotactic space, like MNI or Talairach [25].
SPM applies an affine (12 parameters) and non-linear (∼ 1000 parameters)
transformation. Both of them are encoded with a reduce number of parameters
in order to achieve an overall good shape matching without increasing the com-
plexity of the model. All the cortical structures are not perfectly matched due
to the low number of parameters. However, it is impractical to try a perfect
match between real brains, as there is no a one-to-one relationship and some
structures -like sulcus and gyrus- would need to be created. Therefore, it is
preferred an overall good registration, which will be followed by a smoothing
step that increases the Signal to Noise Ratio (SNR).
In case of using several scans from the same patient, either uni- or multi-
modal data, intra-subject registration is applied in the form of affine or rigid-
body transformation. When templates are used or studies are carried out
through several population groups, an inter-subject registration is used, which
applies an affine transformation followed by a non-linear warping. Some authors
also propose the use of just an affine transformation for inter-subject registration
in order to account only the overall brain dimension differences.
After applying the transformation, the images are re-sliced in order to have
intensity values associated to a spatially homogeneous cubic grid. This re-slicing
implies an interpolation that can be either done by Nearest Neighbour (NN) (0th
order), tri-linear (1st order), Lagrange polynomial (nth order), sinc or B-splines.
In addition, the interpolation can be also done using windowing techniques with
similar smoothing results. The interpolation method applied in SPM can be
checked in the Matlab function spm slice vol(), where the default is tri-linear.
The implicit low pass filtering of the transformation, re-sampling and inter-
polation decrease the quality (resolution) of the volumes. Thus, the question of
when and how it should be applied must be analyzed in order to avoid unnec-
essary data degradation. For this reason, it is usual to store the volumes in the
original space with the transformation parameters in the header.
3.2 Registration 31
The Equation 3.1 presents the affine transformation T () from the original
volume X to the target volume Y , X → Y , where A is the transformation
matrix, and b is the intercept. The 3D volumes have dimensions 3xN , where
N is the number of variables in the volume. In the case of the MRI scans
from the DRCMR, the dimensions of the volumes are 256 × 256 × 256, thus
N = 17, 367, 040. The intercep encodes the translation, thus the expression
(.+) represents the addition of b to all the N variables of dimensions 3x1 in X,
which would be equivalent to add directly repmat(b, 1, N ).
A b
Aaf f ine = = Atranslation · Arotation · Ascaling · Ashear (3.3)
0 1
The SPM function spm matrix() creates the previous transformation matrix
Aaf f ine . The default multiplication order of individual transformation matri-
ces is defined as: Translation, Rotation, Scale and Shear. As SPM uses pre-
multiplication format for the transformation matrix, the transformations will
be applied in the opposite order to the original volume.
The appendix B.6 includes a short Matlab example about the formation
and use of the matrix, and how affects the coordinates.
32 Neuroimaging Processing
The Figure 3.6 depicts in different skews the four steps of the affine trans-
formation: translation, rotation, scale and shear. For simplicity, the figure cor-
responds to a 2D space, however the same criteria will be applied for a 3D case.
In the tri-dimensional case, the translation and scale would have an additional
parameters in the z-axis, and the rotation and shear would have two additional
parameters accounting for the dimensionality increase.
1 0 0 tx
0 1 0 ty
Atranslation = (3.4)
0 0 1 tz
0 0 0 1
3.2 Registration 33
1 0 0 0
0 cos(ux ) −sin(ux ) 0
Arotation = Apitch · Aroll · Ayaw = · (3.5)
0 sin(ux ) cos(ux ) 0
0 0 0 1
cos(uy ) 0 sin(uy ) 0 cos(uz ) −sin(uz ) 0 0
0 0 0 0 · sin(uz ) cos(uz ) 0 0
·
−sin(uy ) 0 cos(uy ) 0 0 0 0 0
0 0 0 1 0 0 0 1
zx 0 0 0 1 sx sy 0
0 zy 0 0 0 1 sz 0
Ascaling = Ashear = (3.6)
0 0 zz 0 0 0 1 0
0 0 0 1 0 0 0 1
3.2.2 Non-linear
The basis functions of one dimension dj (xi ) for the the first M coefficients
can be obtained from the Equation 3.8, which expression has been extracted
from [31]. The first coefficient d (i, m = 1) for all the variables is constant. The
index i = 1..I goes through all the variables of the volume in one dimension.
q
1 m = 1, i = 1..I
I
d (i, m) = q (3.8)
2 · cos π(2i−1)(m−1) m = 2..N, i = 1..I
I 2I
The SPM function spm dctmtx generates the basic functions for DCT.
For example, the Figure 3.7 presents the first basis functions generated from
spm dctmtx(N = 5, K = 5).
Figure 3.7: First basis functions of DCT, which correspond to the lowest fre-
quencies. They are generated from SPM in the same way that they are used for
the warping registration.
In case that the spatial mapping between origin and source is not given, the
transformation parameters must be estimated using a similarity or dissimilarity
function that gives a metric about how good/bad two images fit. These functions
can be based on intensity (correlation metrics) or features (points, lines, etc). In
case of using multi-modal scans, only feature-based similarity function can be
used because the intensity pattern does not match among modalities. Therefore,
SPM includes Mutual Information (MI), Normalized Mutual Information (NMI)
and Entropy Correlation Coefficient for multi-modal studies.
The Equation 3.10 presents the MI similarity function for volumes X and
Y as the Kullback–Leibler distance, where H() is the entropy [44] [81]. The
indexes i, j go through all the intensity values of each volume.
X pXY (i, j)
SM I (X, Y ) = pXY (i, j)log = H(X) + H(Y ) − H(X, Y ) (3.9)
i,j
pX (i)pY (j)
The NMI is shown in the Equation 3.10, where it can be checked the re-
lation between the similarity and dissimilarity function: SN M I (X, Y ) = 1 −
DN M I (X, Y ). To achieve a good registration, similarity and dissimilarity must
be maximized and minimized, respectively.
SM I (X, Y ) H(X, Y )
SN M I (X, Y ) = =1− (3.10)
H(X) + H(Y )) H(X) + H(Y ))
The term H(X) stands for the entropy of X, and H(X, Y ) is the joint
entropy of X and Y , as presented in the equation 3.11. When the registration
is improved, the joint entropy is decreased.
X
H(X) = − pX (i)log (pX (i)) (3.11)
i
X
H(X, Y ) = − pXY (i, j)log (pXY (i, j))
i,j
3.2.4 Regularization
3 X
3
XX ∂uij
hreg = (3.13)
i j=1 k=1
∂xki
X ∂u1j 2 ∂u1j 2 2 !
∂u1j
hreg = + +2 + (3.14)
i
∂x1i ∂x2i ∂x1i ∂x2i
X ∂u2j 2 ∂u2j 2 2 !
∂u2j
+ + +2
i
∂x1i ∂x2i ∂x1i ∂x2i
Finally, the Equation 3.15 presents the Linear-Elastic Energy with the two
elasticity constants λ and µ.
3 X
3 X
X λ ∂uji ∂uki µ ∂uji ∂uki
+ + (3.15)
j=1 k=1 i
2 ∂xji ∂xki 4 ∂xki ∂xji
38 Neuroimaging Processing
The 2D histograms of the registration can be seen in the Figure 3.8, where
the middle plot represents the starting point. The left plot depicts the transfor-
mation from canonical to the subject f4505; and the right one the transformation
from the subject f4505 to canonical. The final histograms (right and left) have
higher and less diffuse values. This increase in the concentration of points in-
dicates that the matching of similar areas with different intensity patterns is
higher, thus better registration (smaller joint probability).
The Figure 3.9 depicts the original (in red square) and transformed volumes
in both directions. The main change can be seen in the sagittal plane (top-right)
where the canonical brain is looking down, and thus the angle of the original
brain is changed through a rotation. This rotation also change the visibility
of the eyes on the coronal plane. Although both volumes belong to the same
modality, the chosen dissimilarity function is the NMI because the intensity
patterns are slightly different between both volumes.
Figure 3.9: Example of volume registration in SPM. Four volumes are presented,
two original (with a red square) and two transformed. Each one is represented by
the three orthogonal planes: coronal, sagittal, transverse. The upper-left volume
corresponds to the original T1 volume of subject f4395, and the lower-right
corner is the original canonical T1 from SPM that is averaged from 152 brains.
The upper-right volume is the transformed T1 of subject f4505 taking as a
reference the T1 canonical, and the lower-left volume presents the transformation
of the T1 canonical to fit the T1 of subject f4505 .
40 Neuroimaging Processing
µi
yi = + ni (3.17)
pi
3.3 Bias Field Correction 41
(µi + ni )
yi = (3.18)
pi
(µi + ni )
yi = + n0i (3.19)
pi
The last approach log-transforms the intensities of the first model in order
to use the advantages of the multiplicative field.
µi ni
log (yi ) = log (µi ) − log (pi ) + ni ⇒ yi = e (3.20)
pi
The SPM methods includes the second model, where it is assumed a good
quality scanner that does not introduces strong noise.
For example, the Figure 3.10 depicts the process of bias field correction in
SPM. The T1 volume used in the example corresponds to a simulated scan from
BrainWeb using the ICBM protocol [55]. The data has 1mm isotropic voxel
resolution, and it has been generated with 3% of noise (relative to the brightest
tissue), and 40% of intensity non-uniformity.
The two subfigures 3.10a and 3.10b, present the non-corrected and corrected
brain volumes, respectively. The non-corrected volume is the one obtained in
the scanner, and the corrected is the estimation of the original intensities by
assuming negligible noise. Finally, the subfigure 3.10c depicts the multiplicative
bias field that modulates the original intensities. The results of the corrected
volumes show brighter intensity values.
42 Neuroimaging Processing
Figure 3.10: Example of bias field correction in SPM. The T1 brain volume has
1mm isotropic voxel, and it has been generated with 3% of noise, and 40% of
intensity non-uniformity. Each row presents a different step of the bias field
correction process with the 3 orthogonal planes: coronal, sagittal, transverse.
3.4 Scalp-Stripping 43
3.4 Scalp-Stripping
This step classifies the voxels as either brain or non-brain. The result can be
either a new image with just brain voxels or a binary mask, which have a value
of ’1’ for brain voxels and ’0’ for the rest of tissues. In general, the brain-voxels
comprises GM, WM, and CSF of the cerebral cortex and subcortical structures,
including the brain stem and cerebellum, but not the cervical spinal cord. The
Figure 2.2 can help to visualize these parts. The scalp, dura matter, fat, skin,
muscles, eyes and bones are always classified as non-brain voxels.
For some methods, this step is mandatory and must be done before the
segmentation itself. However, other methods can take benefit of a brain mask,
like SPM, in order to decrease the misclassification errors of non-brain voxels.
Several methods have been proposed for this processing [42], e.g. Minneapolis
Consensus Strip (McStrip) [66], Hybrid Watershed Algorithm (HWA), SPM,
Brain Extraction Tool (BST) and Brain Surface Extractor (BSE). In the ’New
Segmentation’ of SPM8, new tissue templates are included to model non-brain
voxels, which helps indirectly the brain extraction. Besides, it is possible to use
masks of brain voxels to reduce the computation time because less number of
voxels are used, and also it avoids problems when spatial dependencies are taken
into account, like in the smoothing step.
In the Figure 3.11, it is presented an example of scalp stripping done by
the BST method of FSL on T1 MRI brain images. In the middle image, the
brain edge is depicted with a green line. The right-most subfigure presents the
remaining brain tissue after removing the scalp. In addition, it is also presented
the segmentation done by FAST.
Figure 3.11: Example of scalp stripping done by the BST method of FSL on
T1 MRI brain images. In the middle image, the brain edge is depicted with a
green line. The right-most subfigure presents the remaining brain tissue after
removing the scalp. In addition, it is also presented the segmentation done by
FAST. [Courtesy of S.M. Smith et al. [76]]
44 Neuroimaging Processing
The Figure 3.12 shows the brain extraction result done by the original
pipeline on the scan from the subject f4395. In this case, the T2 MR im-
ages are used to estimate the brain mask. The coronal, sagittal, and transverse
planes are presented in different states. In the first row, it is presented the row
T1 data, the second row depicts the estimated binary mask, and the bottom row
presents the overlapped mask in red on the original T1 images. In the transverse
plane can be seen that the masking is not perfect and some tissue that belongs
to the muscles of the right eye is included as brain tissue.
Figure 3.12: Result of the scalp stripping with the original pipeline on a T1
MR image from subject f4395. First, second and third columns correspond to
coronal, sagittal, and transverse planes, respectively. The top row shows the
original T1 volumes. The middle row depicts the estimated mask for each plane,
where ’0’ is associated to non-brain (black) and ’1’ is associated to brain (bright).
Finally, the last row presents an overlap of the mask on the raw images.
3.4 Scalp-Stripping 45
The previously presented graphical scalp stripping can be also analyzed with
the associated intensity histograms. Likewise, the Figure 3.13 depicts the inten-
sity distribution of each step. The main source of no-brain voxels is associated
with the air, which appears as a big peak in the low intensity values for both
modalities. In addition, there are also small lobes of no-brain that correspond to
the skin, eyes, muscles, and other no-brain tissues. After the brain extraction,
it is easier to recognize from the histogram the pattern of intensities associated
with GM, WM, and CSF.
Figure 3.13: Intensity histogram of the scalp stripping done by the original
baseline for T1 and T2 MR image from subject f4395. The first and second
columns correspond to T1 and T2 histograms, respectively. The first row contains
the original histogram of the scans. In both cases, there is a big peak in the low
intensity values that corresponds to the voxels that do not belong to the human
body and they appear in black. The second row contains the histogram of the
scans after removing no-brain voxels. In this case, it is easier to recognize the
pattern of intensities associated with GM, WM, and CSF. Finally, the last row
depicts the histogram of the no-brain voxels for T1 and T2 . The main source
of them is associated with the air, although there are also small lobes that
correspond to the skin, eyes, muscles, and other no-brain tissues.
46 Neuroimaging Processing
3.5 Smoothing
The voxel-wise segmentation has an intrinsic spatial dependency because
voxels of the same tissue class tend to be close, i.e. if one voxel is classified as
one tissue, it implies that close voxels have more probabilities to belong to the
same class. Therefore, spatial information must be included in the model by
averaging over neighboring voxels, which blurs the intensity data in the same
way that a low pass filtering.
The main goal of this step is to remove isolated dissimilarities among close
voxels, which increases the SNR and sensitivity. However, strong smoothness
can eliminate the edge information [72]. Therefore, there is a trade off between
SNR and image resolution. Besides, it provides an enhanced class overlapping
that deals better with PVE, which occurs when a voxel is composed by several
tissue classes. This process can be applied before or after the segmentation. In
the former case, it reduces the acquisition noise or residual differences after the
registration. In the latter case, it generates more uniform TPM’s.
Several methods have been proposed for that purpose. One of the most
used is based on MRF that ensures continuity of the tissue classes [43]. Other
approaches include active contour models like snakes or a Bayesian segmentation
based on local histograms [41]. For fMRI analysis, it is usually applied a weighted
average, where each voxel represents a weighted average over its close Region Of
Interest (ROI). Other neuroimgaing steps also introduces indirectly smoothness
in the segmentation, like the interpolation done during the registration or the
prior template matching.
In the case of SPM, the smoothing is done by the convolution of the volumes
with a Gaussian kernel. The process is parameterized by the Full Width at Half
Maximum (FWHM) of the Gaussian for each direction (x, y ,z). The proposed
values are 6mm for single subject analyses, and 8-10mm for group analysis.
3.5 Smoothing 47
The Figure 3.14 presents the effect of smoothing. In this case the segmented
GM tissue volume of the subject f4395 obtained from the original baseline is
smoothed by a Gaussian kernel of FWHM=[8mm,8mm,8mm].
Figure 3.15: Templates for GM, WM and CSF in the ’New Segmentation’ of
SPM8 for the coronal, transverse and sagittal planes. The last row corresponds
to a coloured overlap of the previous tissue probability maps.
50 Neuroimaging Processing
Chapter 4
This chapter presents the method and mathematical concepts that are ap-
plied in the proposed MRI brain segmentation method, which is a modification
of the ’New Segmentation’ SPM8 toolbox.
In the Objective Function section, it is introduced the mathematical
framework of the segmentation method. It comprises a MoG as the generative
model of the intensity distribution for the tissue classes, and a Bayes inference
that allows the inclusion of the prior templates into the model. The objective
function is also extended to include bias field correction and registration. In
addition, a regularization term is added in order to avoid unfeasible results of
the inhomogeneity correction and registration.
The Optimization section presents the minimization of the objective func-
tion, which is done iteratively with the EM algorithm due to the high coupling
of the parameters. The expressions of the mixture parameters for each iteration
are calculated with the Gauss-Newton method.
The main parts of the Matlab code are included in the Implementation
section, where several versions of the algorithm are analyzed.
52 Method & Implementation
4.1.2 Classes
Several classes
For each tissue class in which is aimed to segment the brain, it is needed a
template that encodes the prior probability of each voxel belonging to the class.
Although the brain segmentation is mainly focused in the detection of GM, WM
and CSF voxels, the increase in the number of classes can help to avoid classify-
ing non-brain tissues as part of the brain. The ’Unified Segmentation’ method,
implemented in SPM8, uses 4 tissue classes (Kb = 4), namely GM, WM, CSF,
and non-brain. The last class is a way to include the brain extraction within
the generative models in order to increase the robustness; and it is estimated
as one minus the rest of classes. However, already scalp stripped brains save
time because it is only needed to operate with brain voxels, I ↓. In the ’New
Segmentation’ method, implemented in the Seg-toolbox of SPM8, six different
tissue templates (Kb = 6) are used, namely GM, WM, CSF, bone, ST and BG.
The background class includes mainly air and subjects’t hair. In this project,
the same priors are used, therefore the number of tissue classes is fixed to six,
Kb = 6. Some slices of the used templates can be found in the Appendix E.2.
1 1 T −1
N (Y | µk , Σk ) = N 1 exp − (Y − µ k ) Σ k (Y − µk ) (4.3)
(2π) 2 |Σk | 2 2
4.1 Objective Function 55
1
N (Y = yi | µk , Σk ) = q (4.4)
2 2 2
2π σk,T 1 · σk,T 2 − σk,T 1T 2
"
2 2 2 2 #
−σk,T 1 · σk,T 2
yi,T 1 − µk,T 1 yi,T 2 − µk,T 2
· exp · +
2 σ2 · σ2 − σ2 σk,T 1 σk,T 2
k,T 1 k,T 2 k,T 1T 2
σk,T 1T 2
· exp · [(yi,T 1 − µk,T 1 ) (yi,T 2 − µk,T 2 )]
σ2 · σ2 − σ2
k,T 1 k,T 2 k,T 1T 2
2
The terms σk,nn0 are covariances, and σk,nn = σk,n are variances, where
σk,n stands for the Standard Deviation (s.t.d.). As a Gaussian, the covari-
ance matrix is symmetric σk,nn0 = σk,n0 n , their terms are real σk,nn0 ∈ R, and
2
their variances are non-negative σk,n ≥ 0. Therefore, the covariance matrix is
0
positive-semidefinite, x Σk x ≥ 0, ∀x ∈ Rn , and its determinant is non-negative,
det (Σk ) ≥ 0. If non-singularity is imposed in order to have simple inverse of the
covariance matrix, the matrix is positive-definite, x0 Σk x > 0, ∀x ∈ Rn , and its
determinant is always strictly positive, det (Σk ) > 0 [15].
56 Method & Implementation
σk,nn0 σk,nn0
ρk = =√ (4.6)
σk,n · σk,n0 σk,nn · σk,n0 n0
This parameter shows the degree of correlation between the nth and n0 th
modality. In case this parameter vanishes to zero, ρk → 0, both modalities
would be uncorrelated for the kth-cluster. In addition, due to the Gaussian
distribution of the intensities, in case of non-correlation, the modalities would be
also independent. The ’unified Segmentation’ and ’New Segmentation’ methods
consider that the probability distribution of both modalities is uncorrelated,
2
σk,T 1T 2 = σk,T 2T 1 = 0, which leads to Σk = diag(σk,n ). This assumption shifts
the number of independent parameters to 2 · N = 4. Although this assumption
is not true, it is applied in order to simplify the expressions.
In the proposed method of this thesis, this non-correlation is not assumed.
Therefore, the number of independent parameters is N · (N + 3)/2 = 5. This
small number of the degrees of freedom implies fast computation, however it
also implies a restriction on the shape of the intensity distribution. The total
number of parameters increases quadratically with the number of modalities,
although for small number of modalities (N ↓), like in this project (N = 2),
this point is not relevant. In this case, the 5 parameters correspond to the two
2 2
means µk,T 1 µk,T 2 , the two variances σk,T 1 σk,T 2 , and the covariance σk,T 1T 2 ,
which in details correspond to:
P (Y | θ, M ) · P (θ | M )
P (θ | Y, M ) = (4.7)
P (Y | M )
In conclusion, it can be stated that the ML and MAP estimation of the pa-
rameters θ of the model M from the observed data Y is obtained by maximizing
the conditional probability P (Y | θ, M ). In this case, the model is a MoG, where
the set of parameters correspond to γ, µ, Σ. Therefore, the likelihood function
has the expression P (Y | γ, µ, Σ), and is presented in the Equation 4.8.
I
Y
P (Y | γ, µ, Σ) = P (Yi = yi | γ, µ, Σ) (4.8)
i=1
I K
!
Y X
= P (Yi = yi , ci = k | γk , µk , Σk )
i=1 k=1
I K
!
Y X
= P (ci = k | γk ) · P (Yi = yi | ci = k, µk , Σk )
i=1 k=1
P (Yi = yi | ci = k, µk , Σk ) = N (Y = yi | µk , Σk ) |N =2 (4.9)
4.1.5 Priors
P (ci = k | γk ) = γk (4.10)
However, if spatial priors are introduced from TPM, the term bik is added,
which stands for the probability of the ith-voxel belonging to the kth-cluster.
As the probability bik depends on the location, this modification helps to in-
clude spatial dependency in the model and compensate the assumption of voxels
independence.
γk · bik
P (ci = k | γk ) = PK (4.11)
j=1 γj · bij
The templates used as priors are generated from previously segmented im-
ages; thus, it is needed to register the tissue templates into the same space than
the MR images. The set of parameters α characterizes the image registration
with a non-linear warping using 3D DCT. This method is a low-dimensionality
(∼ 1000 parameters) approach, which implies a fast and simple processing. A
further description of the method was presented in the section 3.2.
γk · bik (α)
P (ci = k | γk , α) = PK (4.12)
j=1 γj · bij (α)
60 Method & Implementation
These expressions are calculated by using the general property of the co-
variance Cov(aX, bY ) = ab · Cov(X, Y ), where a, b ∈ R and X, Y are Random
Variable (r.v.).
The number of modalities in this project is two, T1 and T2 , therefore the
modified mean vector and covariance matrix corresponds to the expressions of
the Equation 4.14 and 4.15, respectively.
µ
k,T 1
ρi,T 1 (β)
µ̆
µ̆k = k,T 1 = (4.14)
µ̆k,T 2
µk,T 2
ρi,T 2 (β)
2
σk,T 1 σk,T 1T 2
2
σ̆k,T σ̆k,T 1T 2
ρi,T 1 (β) ρi,T 1 (β) · ρi,T 2 (β)
1
Σ̆k = 2 =
σ̆k,T 1T 2 σ̆k,T 2 2
σk,T 1T 2 σk,T 2
ρi,T 1 (β) · ρi,T 2 (β) ρi,T 2 (β)
(4.15)
Finally, the Equation 4.16 presents the intensity distribution with the in-
clusion of the intensity inhomogeneity parameterized by the vector β.
As it would be expected, the probability has higher values the closer are
the intensity values to their corresponding means. The maximization of the
likelihood function has singularities that makes this task not well posed. When
the intensity value is close to the mean and the variance is small, the likelihood
function values goes to infinity, the same would happen when the variance is
too small σ → 0. Therefore, these singularities must be detected and heuristic
methods to solve them should be proposed [6].
The inclusion of registered priors and bias field correction increases the
total number of parameters, i.e. θ = {γ, µ, Σ, α, β}. Therefore, the likelihood
function has the form of the Equation 4.17, where the expressions for the prior
and conditional probability have been already estimated.
P (Y | θ) = P (Y | γ, µ, Σ, α, β) = (4.17)
I K
!
Y X
= P (ci = k | γk , α) · P (Yi = yi | ci = k, µk , Σk , β)
i=1 k=1
62 Method & Implementation
4.1.7 Regularization
The estimated bias field must model smooth variations of intensity due to
RF field inhomogeneities and not fast intensity variations due different tissues,
which must be modeled by the different clusters. Therefore, a regularization
term P (α) is added in order to penalize unfeasible values of the parameters
according to prior information, which corresponds to the bending energy. Simi-
larly, the deformations of the registration can be also penalized in case of param-
eters too big or small from the expected values. In both cases, the probability
densities of the parameters are assumed to follow a centered Gaussian distribu-
tion, i.e. α ∼ N (0, Cα ) and β ∼ N (0, Cβ ).
The Equation 4.18 presents the regularization terms for prior registration
and bias field correction in terms of the parameters α β and their covariance
matrices Cα Cβ .
Cα −1 α} Cβ −1 β }
P (α) = exp{− 2 α P (β) = exp{− 2 β
1 T 1 T
, (4.18)
Therefore, fitting the MoG model with the regularization terms implies
maximizing the Equation 4.19.
1 T 1
= ε + α Cα −1 α + β T Cβ −1 β
2 2
From the previous expression, the cost function ε corresponds to the objec-
tive function F without the regularization terms, and its expression corresponds
to the Equation 4.21.
I K
!!
Y X
= −log P (ci = k | γk , α) · P (Yi = yi | ci = k, µk , Σk , β)
i=1 k=1
I K
!!
X X
= − log P (ci = k | γk , α) · P (Yi = yi | ci = k, µk , Σk , β)
i=1 k=1
1 T 1
F = −log (P (Y, α, β | γ, µ, Σ)) = −log (P (Y | θ)) − log (P (α)) − log (P (β)) = ε + α Cα −1 α + β T Cβ −1 β =
2 2
I K
!!
X X 1 T 1
= − log P (ci = k | γk , α) · P (Yi = yi | ci = k, µk , Σk , β) + α Cα −1 α + β T Cβ −1 β =
i=1
2 2
k=1
I K
X X γk · bik (α) ρ (β) · ρi,T 2 (β)
= − log PK · q i,T 1 · (4.22)
2 2 2
i=1 k=1 j=1 γj · bij (α) 2π σk,T 1 · σk,T 2 − σk,T 1T 2
2
−σk,T 2
· exp · (ρi,T 1 (β) · yi,T 1 − µk,T 1 )2 ·
2 2
σk,T · 2 − 2
1 σk,T 2 σk,T 1T 2
2
−σk,T 1
· exp · (ρi,T 2 (β) · yi,T 2 − µk,T 2 )2 ·
2 2
σk,T · 2 − 2
1 σk,T 2 σk,T 1T 2
σk,T 1T 2 1 1
· exp · (ρi,T 1 (β) · yi,T 1 − µk,T 1 ) (ρi,T 2 (β) · yi,T 2 − µk,T 2 ) + αT Cα −1 α + β T Cβ −1 β
σ2 · σ2 − σ2 2 2
k,T 1 k,T 2 k,T 1T 2
Method & Implementation
4.2 Optimization 65
4.2 Optimization
Once the expression of the objective function F has been obtained, this
section describes how it is minimized, which implies fitting the model. Due to
the high coupling of the parameters θ, there is not a closed formulation to find
the solution. The chosen approach by the ’Unified Segmentation’ method is
based on Iterated Conditional Modes (ICM) [3], where each parameter is locally
optimized until the convergence criteria are satisfied. Each iteration comprises
the individual optimization of all the parameters, where in each individual op-
timization one parameter value is minimized while keeping the values of the
rest. Therefore, this local optimization requires a good starting point in order
to avoid convergence to a local minima.
The mixture parameters -γ, µ, Σ- comprise six variables for each cluster,
2 2
{γk , µk,T 1 , µk,T 2 , σk,T 1 , σk,T 2 , σk,T 1T 2 }, which can be easily updated with the
EM method. However, the registration α and bias field correction β are charac-
terized by ∼ 1000, thus they are better optimized by the Levenberg-Marquardt
(LM) method. The modification of the original ’Unified Segmentation’ done in
this project does not involve any change in how the vector parameters α and
β are optimized, thus this section will focus just on the mixture parameters
that are optimized by the EM scheme. Therefore, it is enough to minimize the
objective function ε instead of F, because the regularization terms P (α) and
P (β) do not depend on the mixture parameters.
4.2.1 EM optimization
I
X
ε = − log (P (Yi = yi | θ)) (4.24)
i=1
The Equation 4.25 presents the Kullback-Leibler distance DKL , where the
term qi,k stands for some probability that is expected to be similar to the poste-
PK
rior probability P (ci = k | Yi = yi , θ). It must satisfy that k=1 qi,k = 1 after
applying the Bayesian rule.
K
I X
X qi,k
DKL = qi,k log = (4.25)
i=1 k=1
P (ci = k | Yi = yi , θ)
I X
X K I X
X K
= qi,k log (qi,k ) − qi,k log (P (ci = k | Yi = yi , θ))
i=1 k=1 i=1 k=1
Therefore the final upper bound of the the cost function corresponds to the
expression of Equation 4.26.
I
X
εEM = ε + DKL = − log (P (Yi = yi | θ)) + (4.26)
i=1
I X
X K I X
X K
+ qi,k log (qi,k ) − qi,k log (P (ci = k | Yi = yi , θ))
i=1 k=1 i=1 k=1
In order to minimize εEM , the method alternates between the E-step and
the M-step for each iteration. The former minimizes εEM with respect to qi,k ,
while the latter does it with respect to θ. Each step has a slightly different
reformulation of the cost function, which is minimized to obtain a close equation
of the variables for the next iteration. The method stops when the convergence
criteria have been satisfied.
4.2 Optimization 67
E-step
In this step, the upper bound εEM is minimized with respect to the proba-
bility qi,k . The cost function ε does not depend on qi,k , thus the minimization
in this step only includes the Kullback-Leibler distance, εEM = DKL . When
the probability qi,k is equal to the posterior probability, the KL-distance is min-
imum. This minimum value corresponds to zero, DKL = 0, which also implies
that the upper bound of the cost function is equal to the cost function, ε = εEM .
(n)
The value of the posterior probability for the (n)th-iteration, qi,k , is calcu-
lated from the parameters of the (n − 1)th-iteration, θ (n−1) . The Equation 4.28
presents this expression, where the Bayesian rule has been applied.
(n)
qi,k = P ci = k | Yi = yi , θ (n−1) = (4.28)
P Yi = yi , ci = k | θ (n−1) P Yi = yi , ci = k | θ (n−1)
= =P
K
P Yi = yi | θ (n−1) k=1 P Yi = yi , ci = k | θ
(n−1)
The conditional probability P Yi = yi , ci = k | θ (n−1) of the previous ex-
pression is calculated from the Equation 4.29. It combines the MoG model, the
bias field correction and the priors that were explained in the previous section.
P Yi = yi , ci = k | θ (n−1) = P ci = k | θ (n−1) ·P Yi = yi | ci = k, θ (n−1) =
!
γk · bik (α) ρ (β) · ρi,T 2 (β)
= PK · q i,T 1 ·
j=1 γj · bij (α) 2 2
2π σk,T 1 · σk,T 2
2 − σk,T 1T 2
2
−σk,T 2 2
· exp · (ρi,T 1 (β) · yi,T 1 − µk,T 1 ) · (4.29)
2 2 2
σk,T 1 · σk,T 2 − σk,T 1T 2
2
2
−σk,T 1
· exp · (ρi,T 2 (β) · yi,T 2 − µk,T 2 )2 ·
2 σ2 · σ2 − σ2
k,T 1 k,T 2 k,T 1T 2
σk,T 1T 2
· exp · (ρi,T 1 (β) · yi,T 1 − µk,T 1 ) (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
σ2 · σ2 − σ2
k,T 1 k,T 2 k,T 1T 2
68 Method & Implementation
M-step
In this step, the upper bound of the cost function εEM is minimized with
respect to the parameters θ. Therefore, the updating equations of the parame-
ters for the (n)th-iteration, θ (n) , are estimated from the resulting cost function
(n)
and the posterior probability for the (n)th-iteration, qi,k , which was previously
updated in the E-step.
The first term of the Kullback-Leibler distance does not depend on the
parameters θ, therefore it is not included in the upper bound of the cost function
in this step, as showed in the Equation 4.30. This expression is a reformulation
of the Equation 4.26 where the Bayes’ rule has been applied in several steps.
Besides, the expression for the conditional probability P (Yi = yi , ci = k | θ)
was presented in the Equation 4.29.
I
X I X
X K
εEM = − log (P (Yi = yi | θ)) − qi,k log (P (ci = k | Yi = yi , θ))
i=1 i=1 k=1
I I X
K
X X P (Yi = yi , ci = k | θ)
= − log (P (Yi = yi | θ)) − qi,k log
i=1 i=1 k=1
P (Yi = yi | θ)
I X
X K
= − qi,k log (P (Yi = yi , ci = k | θ)) (4.30)
i=1 k=1
Although the values of the mixture parameters are different for each clus-
ter, the updating expression of each parameter is the same for all the clusters.
Therefore, the function to minimize corresponds to the upper bound of the func-
tion cost for the kth-cluster, εEMk . The complete expression is presented in the
Equation B.8 of the Appendix B.3.
Therefore, the upper bound of the cost function for the kth-cluster of the
M-step is minimized with respect to the parameters θ. This process imply to
take derivatives of this expression with respect to each mixture parameter -
2 2
{γk , µk,T 1 , µk,T 2 , σk,T 1 , σk,T 2 , σk,T 1T 2 }- and forced them to be zero. This
way, an updating expression for each mixture parameters is obtained.
4.2 Optimization 69
Mixing Coefficient
The cost function of the Equation B.8 is derived with respect to γk and
forced to be equal to zero.
I I
!
∂ εEMk 1 X X bik (α)
= qi,k − qi,k PK = 0 (4.31)
∂ γk γk i=1 i=1 j=1 γj · bij (α)
Therefore, the updating equation for the mixing coefficient corresponds to:
PI
q (n)
γk (n) = i,k
i=1 (4.32)
PI
i=1 qi,k
(n) PK bik(n)
(α)
γj ·bij (α)
j=1
The Equation 4.32 can be compared with the original ’Unified Segmentation’
method, which corresponds to the equation (27) of [3], and it is presented in the
Equation 4.33. The original method has a slightly different expression because
it was probed empirically its convergence to a smaller cost function in each
iteration. Thus, the Equation 4.33 is also used in this project.
PI
q (n)
(γ̇k )
(n)
= i=1 i,k (4.33)
PI
i=1
PK bik(n)
(α)
γj ·bij (α)
j=1
70 Method & Implementation
Mean
The cost function of the Equation B.8 is derived with respect to µT 1,k and
forced to be equal to zero.
2 I
∂ εEMk σk,T 2
X
= − qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 )
∂ µk,T 1 2
σk,T · σ 2 − σ 2
i=1
1 k,T 2 k,T 1T 2
I
σk,T 1T 2 X
+ qi,k (ρi,T 2 (β) · yi,T 2 − µk,T 2 ) = 0 (4.34)
2
σk,T · σ 2 − σ 2
1 k,T 2 k,T 1T 2 i=1
The derivative of the cost function with respect to µT 2,k has similar expres-
sion, where the modality indexes are interchanged, T 1 ↔ T 2. Therefore, the
updating equations for the means corresponds to:
!
(n) (n) σk,T 1T 2 coefµ1
µk,T 1 = (µ̇k,T 1 ) + 2 · PI (4.35)
σk,T 2 i=1 qi,k
!
(n) (n) σk,T 1T 2 coefµ2
µk,T 2 = (µ̇k,T 2 ) + 2 · PI (4.36)
σk,T 1 i=1 qi,k
The coefficients of the updating formulas of the mean for T1 and T2 are
presented in the Equation 4.39 and 4.40.
I
X
coefµ1 = − qi,k (ρi,T 2 (β) · yi,T 2 − µk,T 2 ) (4.39)
i=1
I
X
coefµ2 = − qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 ) (4.40)
i=1
4.2 Optimization 71
Variance
The cost function of the Equation B.8 is derived with respect to σT2 1,k and
forced to be equal to zero.
2 I
∂ εEMk σk,T 2
X
2 = 0 = qi,k (4.41)
∂ σk,T 2 2 2
2 σk,T 1 · σk,T 2 − σk,T 1T 2 i=1
1
4 I
σk,T 2
X 2
− 2 qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 )
2 2 2
2 σk,T 1 · σk,T 2 − σk,T 1T 2
i=1
2 I
σk,T 1T 2
X 2
− 2 qi,k (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
2 2 2
2 σk,T 1 · σk,T 2 − σk,T 1T 2
i=1
2 I
σk,T 1T 2 σk,T 2
X
+ 2 qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 ) (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
2 2 2
σk,T 1 · σk,T 2 − σk,T 1T 2
i=1
The derivative of the cost function with respect to σT2 2,k has similar ex-
pression than with respect to σT2 2,k , except from the interchange of modality
indexes, T 1 ↔ T 2. Thus, the updating formula for the variance are presented
in the Equation 4.42 and 4.43.
!
(n)
2 (n) 2
(n) σk,T 1T 2 coefσ
σk,T 1 = σ̇k,T 1 + 2 · PI 1 (4.42)
σk,T 2 i=1 qi,k
!
(n)
2 (n) 2
(n) σk,T 1T 2 coefσ
σk,T 2 = σ̇k,T 2 + 2 · PI 2 (4.43)
σk,T 1 i=1 qi,k
2 (n)
Therefore, the updating equation for the variance σk,m corresponds to a
2 (n)
combination of the original formula (σ̇k,m
plus a coefficient coefσ scaled by
)
the cross variance σk,T 1T 2 . This formulation allows to see clearly that when the
cross variance is zero, σk,T 1T 2 → 0, the original and modified method have the
same updating scheme.
72 Method & Implementation
The updating formulas of the original method for the T1 and T2 variances
are presented in the Equation 4.44 and 4.44, respectively. The equations are
presented as dependent on the central moments and as dependent of the non-
central moments.
PI 2
2
(n) i=1 qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 )
σ̇k,T 1 = PI = (4.44)
i=1 qi,k
PI 2 PI PI
i=1 qi,k (ρi,T 1 (β) · yi,T 1 ) − 2µk,T 1 i=1 qi,k (ρi,T 1 (β) · yi,T 1 ) + µ2k,T 1 i=1 qi,k
PI
i=1 qi,k
PI 2
2
(n) i=1 qi,k (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
σ̇k,T 2 = PI = (4.45)
i=1 qi,k
PI 2 PI PI
i=1 qi,k (ρi,T 2 (β) · yi,T 2 ) − 2µk,T 2 i=1 qi,k (ρi,T 2 (β) · yi,T 2 ) + µ2k,T 2 i=1 qi,k
PI
i=1 qi,k
Finally, the coefficients that modify the original updating formulas of the
variance in order to include correlation between modalities T1 and T2 are pre-
sented in the Equation 4.46 and 4.47.
I
! I
X σk,T 1T 2 X 2
coefσ1 = σk,T 1T 2 qi,k + 2 qi,k (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
i=1
σk,T 2 i=1
I
X
−2 qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 ) (ρi,T 2 (β) · yi,T 2 − µk,T 2 ) (4.46)
i=1
I
! I
X σk,T 1T 2 X 2
coefσ2 = σk,T 1T 2 qi,k + 2 qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 )
i=1
σk,T 1 i=1
I
X
−2 qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 ) (ρi,T 2 (β) · yi,T 2 − µk,T 2 ) (4.47)
i=1
4.2 Optimization 73
Cross Variance
The cost function of the Equation B.8 is derived with respect to σT 1T 2,k
and forced to be equal to zero.
I
∂ εEMk σk,T 1T 2 X
= 0 = − qi,k (4.48)
∂ σk,T 1T 2 2
σk,T · σ 2 − σ 2
i=1
1 k,T 2 k,T 1T 2
2 I
σk,T 2 · σk,T 1T 2
X 2
+ 2 qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 )
2 2 2
σk,T 1 · σk,T 2 − σk,T 1T 2
i=1
2 I
σk,T 1 · σk,T 1T 2
X 2
+ 2 qi,k (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
2
σk,T · 2
σk,T − 2
σk,T i=1
1 2 1T 2
2 2 I
σk,T 1 · σk,T 2
X
− 2 qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 ) (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
2 2 2
σk,T 1 · σk,T 2 − σk,T 1T 2
i=1
2 I
σk,T 1T 2
X
− 2 qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 ) (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
2 2 2
σk,T 1 · σk,T 2 − σk,T 1T 2
i=1
The solution of this expression for the unknown factor x = σk,T 1T 2 is a third
degree equation in the form:
ax3 + bx2 + cx1 + dx0 = 0 (4.49)
I
X
a = qi,k
i=1
I
X
b = − qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 ) (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
i=1
I
X I
X
2 2 2 2
c = − σk,T 1 σk,T 2 qi,k + σk,T 2 qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 )
i=1 i=1
I
X
2 2
+ σk,T 1 qi,k (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
i=1
I
X
2 2
d = − σk,T 1 σk,T 2 qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 ) (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
i=1
74 Method & Implementation
The previous expressions were defined in terms of the central moments for
a 2-dimensional variable; therefore, they can be reformulated in an easier way
by introducing specific variables for these expressions.
I
X
mom1cT 2 = qi,k (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
i=1
I
X 2
mom2cT 2 = qi,k (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
i=1
I
X
mom2cT 1T 2 = qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 ) (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
i=1
Therefore, the coefficients of the updating formulas where the moments are
substituted by the previous variables are:
!
σk,T 1T 2
coefσ1 = σk,T 1T 2 mom0 + 2 mom2cT 2 − 2 · mom2cT 1T 2 (4.52)
σk,T 2
!
σk,T 1T 2
coefσ2 = σk,T 1T 2 mom0 + 2 mom2cT 1 − 2 · mom2cT 1T 2 (4.53)
σk,T 1
a = mom0
b = − mom2cT 1T 2
2 2 2 2
c = − σk,T 1 σk,T 2 mom0 + σk,T 2 mom2cT 1 + σk,T 1 mom2cT 2
2 2
d = − σk,T 1 σk,T 2 mom2cT 1T 2
The mixing coefficient is not presented here because the equation of the
original and modified approach are the same.
76 Method & Implementation
4.3 Implementation
This section introduces the Matlab code of the updating expressions for the
(n) (n) (n)
E-step (qi,k ) and M-step (γk (n) , µk,T 1 (n) , µk,T 2 (n) , σk,T
2
1
2
, σk,T 2 , σk,T 1T 2 (n) ).
The implementations starts with the creation of a toolbox with the name
SegT1T2, which is a modification of the Seg toolbox of ’New Segmentation’.
It allows the inclusion of only two input channels for the segmentation, which
must correspond to T1 and T2 MRI modalities. The extension of the filenames
for the program files and volume results of this toolbox is ’seg8T1T2’.
Several parts of the code from different files of the toolbox have been mod-
ified in order that the calls among functions works well with the new variables,
paths and filenames. However, the most important modifications from the orig-
inal toolbox can be found in the following files:
• tbx cfg preproc8T1T2.m: Configuration file that is modified conveniently
to use the corresponding paths, the new help/comments hints, and the
modified filename extension for the results. It also launches the function
spm preproc runT1T2() with the corresponding parameters.
• spm preproc runT1T2.m: Function that loads the priors, creates the ini-
tial affine registration between input volumes and templates, launches the
function spm preproc8T1T2(), and eventually saves the results.
• spm preproc8T1T2.m: Function that does the segmentation itself (fitting
the model), where the modified expressions for the optimization of the
mixture parameters are included. The input and output variables of this
function are deeply explained in the Appendix C.
Therefore, the rest of this section about Matlab implementation will focus
on the file spm preproc8T1T2.m.
4.3 Implementation 77
The variable buf has the following fields for each value of z:
• buf(z).msk <d0(3)xd0(3)> Logical 2D-mask with a value of ’1’ for voxels
of this slice to analyze, and zero for the rest. This mask is a combination
of the input mask (optional) and an additional mask where zero, infinite
and NaN values are also discarded.
• buf(z).nm <1x1 double> Number of voxels inside of the mask for this
slice, i.e. Iz . If this number is zero, it is not needed to analize this slice.
• buf(z).f <1x2 cell> Masked input MRI data in the form presented in the
Equation 4.1 for Y. Each one of the two elements of the cell is an array of
intensity values <nmx1 single>. Therefore, the first and second elements
of the cell are YT1 and YT2 . They are mapped into memory with the
function spm sample vol().
• buf(z).dat <nmxKb single> Tissue Probability Maps that are sampled for
the xy-slice of the z-coordinate. This variable stands for the term bi,k in
the Equation 4.12. There are Kb different tissue classes; thus, there also
Kb different prior templates.
• buf(z).bf <1x2 cell> Masked bias field for each modality, TT 1 and TT 2 ,
where each channel is an array <nmx1 single>. Therefore, the first ele-
ment of the cell is ρi,T 1 (β), and the second is ρi,T 2 (β).
78 Method & Implementation
Afterwards, the starting estimates of the parameters for the mixture model -
γ, µ, Σ-, the prior registration -α- and the bias field correction -β- are calculated
with the original method. The new updating expressions for the mixture model
parameters have not been included to calculate the initial values in order to
ensure stability in the first iteration.
The actual estimation of the parameters starts from the line 380 (aprox.)
of the file spm prepoc8T1T2.m. It comprises a maximum of 12 iterations,
iter1=1:12, and each iteration has three blocks: estimation of cluster param-
eters, estimation of bias field parameters, and estimation of deformation param-
eters. For each iter1 iteration, the log-likelihood value is eventually calculated in
order to check the convergence. For this thesis, only the first block (estimation
of cluster parameters) is relevant because the rest do not suffer any modifica-
tion from the original method. This block runs iteratively 20 times, subit=1:20,
which means a maximum of 240 times in total. Each iteration comprises the
evaluations of the updating equations for the E-step and M-step with the newly
calculated values. The evaluation of these expressions is done for each xy-slice
individually, z=1:length(z0). To gather all the previously mentioned steps in a
clear form, the Algorithm 1 presents the main control flow of this program.
The numbers of the lines for the presented Maltab code in the rest of this
section are approximately the real numbering of the files. However, small dif-
ferences can arise due to the inclusion/deletion of comments or the elimination
of test code in the release version of the code that is used just for debugging.
In addition, some parts of the code are re-arrange from the original method in
order to have a more clear structure, although the logical flow remains the same.
4.3 Implementation 79
This step updates the value of the probability qi,k . The updating expressions
are the same than in the original method, but they are repeated here to justify
that they are also useful for the modified multispectral approach. The reason
to re-use the code is that the assumption of non-correlation among modalities
is not applied here, although it was assumed in the original article [3].
function p = likelihoods(f,bf,mg,mn,vr)
K = numel(mg);
N = numel(f);
M = numel(f{1});
cr = zeros(M,N);
for n=1:N,
cr(:,n) = double(f{n}(:)).∗double(bf{n}(:));
end
p = zeros(numel(f{1}),K);
for k=1:K,
amp = mg(k)/sqrt((2∗pi)^N ∗ det(vr(:,:,k)));
d = cr − repmat(mn(:,k)’,M,1);
p(:,k) = amp ∗ exp(−0.5∗ sum(d.∗(d/vr(:,:,k)),2));
end
390 q = likelihoods(buf(z).f,buf(z).bf,mg,mn,vr);
391 for k1=1:Kb,
392 b = double(buf(z).dat(:,k1));
393 for k=find(lkp==k1),
394 q(:,k) = q(:,k).∗b;
395 end
396 clear b
397 end
398 sq = sum(q,2);
399 for k=1:K,
400 q(:,k) = q(:,k)./(sq+tiny);
401 end
80 Method & Implementation
In this step, the central and non-central moments are calculated, then the
values of the original mixture parameters are estimated, and finally the modified
updating formulas of the mixture parameters are evaluated using the moments
and original mixture paramters previously estimated.
The estimation of the moments starts with the calculation of the variable cr,
which is the equivalent of the intensity modulated by the bias field (P (β) · Y ),
i.e. cr(i, n) = ρi,n (β) · yi,n . In the line 407 of the following code, the variable
buf (z).f {n} is the masked intensity value for the z-slice in the nth-channel, and
the variable buf (z).bf {n} is the exponential of the masked bias field for the z-
slice in the nth-channel. With this variables is finally obtained the non-central
moments of zero, first and second order.
Afterwards, the mean value is removed from the intensity values of the
variable cr and stored in the variable crc, i.e. crc(i, n) = ρi,n (β) · yi,n − µk,n , in
order to obtain the central moments of first and second order.
405 cr = zeros(size(q,1),N);
406 for n=1:N,
407 cr(:,n) = double(buf(z).f{n}.∗buf(z).bf{n});
408 end
409 for k=1:K,
410 % Non−central moments
411 mom0(k) = mom0(k) + sum(q(:,k));
412 mom1(:,k) = mom1(:,k) + (q(:,k)’∗cr)’;
413 mom2(:,:,k) = mom2(:,:,k) + (repmat(q(:,k),1,N).∗cr)’∗cr;
414 % Central moments
415 crc = cr − repmat(mn(:,k)’,size(q,1),1);
416 mom1c(:,k) = mom1c(:,k) + (q(:,k)’∗crc)’;
417 mom2c(:,:,k) = mom2c(:,:,k) + (repmat(q(:,k),1,N).∗crc)’∗crc;
418 end
It must be highlighted that the computation and the variables cr, mom0(k),
mom1(:, k), and mom2(:, :, k) was already implemented in the original method,
thus this part of the code is not genuine. They are reproduced here for a
clear visualization of the environment needed to calculated the central moments,
which implementation is genuine. In order to check that the equations of the
central moments and their Matlab implementation is correct, they are estimated
in other ways to check their validity. The other different approaches and the
results are presented in the Appendix B.4.
4.3 Implementation 81
Once the moments are estimated, the updating formulas of the original
method are evaluated. The equations are implemented in a matrix form and
stored in the variables mgX, mnX and vrX, which corresponds to the mixing
coefficient, mean vector and covariance matrix, respectively.
In the previous code, the term tpm stands for PK bik (α) .
γj ·bij (α)
j=1
The Equation 4.33 gives value for the mixture coefficient, while the Equa-
tions 4.37 and 4.38 give value for the two elements of the mean vector. However,
the variance is calculated with the Equation 4.54, in contrast to the previously
presented Equations 4.44 and 4.45. The main difference among them is that the
equation presented here is defined in terms of the non-central moments, and the
others are presented in terms of the central moments.
PI 2 PI
2
(n) i=1 qi,k (ρi,m (β) · yi,m ) − µk,m i=1 qi,k (ρi,m (β) · yi,m )
σ̇k,m = PI
i=1 qi,k
(4.54)
Besides, in the original implementation of the variance, it is used the value
of the mean from the current iteration, (µk )(n) . Although, this implementation
seems to work for the original method, some instability problems arose during
the implementation of the modified method that were solved by adding after-
wards two additional lines. These two lines over-write the values of the variances
for an expression in terms of the central moments, where the mean corresponds
to the previous iteration, (µk )(n−1) .
The next step is to update the previous values of the mixture parameters
with the formulas of the modified method. For each parameter, it is estimated its
coefficient and then the final value is calculated as a combination of the original
value and this coefficient. As a reminder, the original values were calculated
with the the original method, except for the case of the variances.
The expression of the mixture value is the same than in the original method.
The values of the coefficients are estimated with the Equations 4.50 and 4.51 for
the mean, while the Equations 4.52 and 4.52 are used for the variances. Finally,
2 2
the values µk,T 1 , µk,T 2 , σk,T 1 and σk,T 2 are updated with the Equations 4.35,
4.36, 4.42 and 4.43, respectively.
In this implementation, it is used the term ovr, which stands for the previous
value of the covariance matrix, i.e. ovr(n) = vr(n−1) , in order to ensure stability.
4.3 Implementation 83
Finally, in case that none of the solutions satisfy the criteria, the original
cross-variance value is chosen in order to ensure the stability of the method.
However, it has been empirically probed with the available dataset that this
point is never reached.
84 Method & Implementation
sol ← get(sol2)
if σT2 1 · σT2 2 − sol2 < tiny OR abs(imag(sol) > 10−4 then
sol ← get(sol3)
if σT2 1 · σT2 2 − sol2 < tiny OR abs(imag(sol) > 10−4 then
sol ← get(solOriginal)
end if
end if
end if
sol ← real(sol)
The solution of the equation y = coef 3ẋ3 + coef 2ẋ2 + coef 1ẋ + coef 0 is
implemented in the following code, and corresponds to the previous algorithm.
In the previous code, it is used a Matlab function that returns one of the
three possible solutions of the cubic equation with coefficients coef3, coef2, coef1
and coef0. It corresponds to solution3th(coef3,coef2,coef1,coef0,opt), where opt
is an index to select one of the three possible solutions, opt ∈ {1, 2, 3}.
In the last line of code, a term vr0 is added to the covariance matrix in
order to ensure stability. By default, the interpolation method is NN, which
implies that the term is estimated as in the presented code, where pinfo(1,1)
satisfies that intensity = voxelvalue · pinf o(1) + pinf o(2).
Stopping criterion
In each iteration, the log-likelihood value is estimated in the variable ll in
order to check how well fitted is the model with the current value of the param-
eters. It is calculated as a combination of the log-likelihoods from the mixture
parameters (llm), the registration parameters (llr), and the bias field parame-
ters (llrb). The approximate equations to obtain these values are presented in
the following code. In the case of the mixture log-likelihood, the variable sq
was previously calculated in the E-step, and it is also added a small vale tiny in
order to avoid instability when the argument of the logarithm is small.
4.3.2 Modifications
Therefore, the combination of the two points generates four different ver-
sions of the modified algorithm. It must be highlighted that all these versions
use the modified updating equations that include correlation among modalities.
• The version 1 updates the parameters with the results of the previous it-
eration and the initialization equations correspond to the original method.
• The version 2 also uses just the values from the previous iteration, but
in the initialization step, it is used the modified updating equations.
• The version 3 updates the parameters with the most updated values of
the current iteration and uses the initialization of the original method.
• Finally, the version 4 updates the values with the most recently updated
parameters, but uses the updating equations of the modified method for
the initialization step.
All these combination will be analyzed in the next section in order to check
their performance. In the Appendices, it is included the relevant parts of code
for the original method (Appendix C.2), the modified method (Appendix C.3),
and the modified method with faster value propagation (Appendix C.4).
Chapter 5
Validation
5.1 Outputs
The first section of this chapter presents a short description about the out-
puts of the segmentation method, and how the generated probability maps for
each tissue are analyzed. The main output variables are the mixture parame-
ters and the final likelihood value. The former ones determine the shape of the
clusters, and the latter indicates how well these parameters fit the MRI dataset
according to the generative model. The variables are:
• Mixing coefficient (mg): <Kx1 double> array with the final γ values.
• Mean (mn): <2xK double> 2D matrix with the final µ values.
• Covariance (vr): <2x2xK double> 3D matrix with the final Σ values.
• Log Likelihood (ll): <1x1 double> final log-likelihood value.
For example, in the Table 5.1, it is presented the values of the mixing coeffi-
cient for the subject f4395, where the version 1 of the modified method has been
applied with default parameters. As it was stated, the ’New Segmentation’ deals
in a different way with this factor, and they represent the contribution/propor-
tion of each cluster to the corresponding tissue class. In this case, the number
of clusters is K = 15 and the number of tissue classes is Kb = 6, where the
specific associations among them is done with the variable lkp.
Table 5.1: Results of the brain tissue segmentation for the brain scans from
the subject f4395 with T1 and T2 MR modalities. The applied algorithm is the
version 1 of the modified method with default parameters.
Class name BG
Class number (lkp) 6 6
Mixing factor (mg) 0.891 0.109
Due to the applied Bayesian framework, the result is not a direct association
between voxels and tissues, as in the previous case. The method generates
one probability map for each tissue class. Therefore, the previous expression
is expanded by Kb rows, as presented in the Equation 5.2, where each row
corresponds to a different tissue class and the term Ci,k stands for the probability
of the ith-voxel belonging to the kth-class.
T
C1,1 ··· Ci,1 ··· CI,1
.. .. ..
. . .
C1,k
··· Ci,k ··· CI,k (5.2)
. .. ..
.. . .
C1,Kb ··· Ci,Kb ··· CI,Kb KbxI
The previous expression is a stochastic matrix, which must satisfy that the
sum over all the classes must be one for each voxel. The matrix elements cor-
respond to probability values in the range [0, 1], where high probabilities are
associated to high intensities in the images (white), and vice versa.
Kb
X
0 ≤ Ci,k ≤ 1 , ∀i, k and Ci,k = 1 (5.3)
k=1
Each row of the Equation 5.2 is stored in a different file, where is resized
into a 3D matrix that must satisfy I = height×width×depth. For example, the
generated tissue probability maps for the subject f4395 are stored in the files:
’c1gf4395 mpr.nii’, ’c2gf4395 mpr.nii’, ’c3gf4395 mpr.nii’, ’c4gf4395 mpr.nii’,
and ’c5gf4395 mpr.nii’. These files correspond to the GM, WM, CSF, bone
and ST. The BG map is not directly stored, but it can be generated as one
minus the rest of volumes. In the Appendix E.3, some slices of these generated
probability maps are presented.
90 Validation
For volume studies, where it is not needed to specify an unique class for each
voxel, it is assumed that each voxel is composed by several tissues. Therefore,
the total voxel volume is split up into different classes. The volume ratio of each
tissue corresponds to the associated value of the probability map, and the total
volume of each class is obtained by simple integration over each TPM. This
formulation deals better with the PVE that happens when a voxel is composed
by several tissues, thus the acquired intensity value is a combination of different
intensity patterns. However, in case it is needed to associate each voxel to one,
and only one, tissue class in order to apply validation tests, there are three ways
to generate a result like the Equation 5.1 from the TPM of the Equation 5.2.
The second option is the one applied in this thesis, and its effect on the
probability maps will be also analyzed in the following section.
5.2 Golden Standard 91
The last option is the one selected for this thesis because it provides a
reliable ground truth. However, it is not possible to make a generalization of
the obtained results as the brain and scanning variability is not totally included.
92 Validation
Although, the image registration and bias field correction have not been
directly changed from the original method, these steps are also analyzed in
order to check that the modification of the mixture parameters equations does
not decrease their performance.
5.3 Brain f4395 - Visualization 93
Figure 5.1: Original MRI brain volumes of the subject f4395. The top row
contains the T1 modality, and the bottom row has the T2 modality. The planes
of each column correspond to coronal, sagittal and transverse.
In the T2 images, it can be seen that the back part of the head is placed
in front of the nose. This effect is due to the field shim, which is a magnetic
field inhomogeneity generated by the ferromagnetic coil. This perturbation in-
troduces errors in the circular k-space needed to reconstruct the image from
the Discrete Fourier Transform (DFT). In order to avoid this effect, the scanner
must be correctly calibrate before the scan in a process called shim correction,
which can be active or passive. This error reduces the performance of the prior
template regularization, as the structures differ.
94 Validation
In the previous chapter, it was stated that both modalities must be aligned,
which implies that it is needed a previous step to register T1 and T2 in the
same space. This pre-processing step is done at the DRCMR, and the result
is presented in the Figure 5.2. In addition, the brain volumes are normalized
into the ICBM/MNI space. They can be compared with the phantoms of the
Figure 5.9, which are originally created in this space. The position, shape and
intensities look alike; therefore, the brain volumes seem correctly aligned and
normalized. This previous normalization of the images implies a soft wrapping
of the prior templates. Besides, it can be seen in this figure the effect of the
shim artefact after the registration.
Figure 5.2: Registered brain volumes of the subject f4395 in the ICBM/MNI
space. The top row contains the T1 modality, and the bottom row has the T2
modality. The planes correspond to coronal, sagittal and transverse.
These volumes are segmented with the original (Seg) and the four versions
of the modified method (SegT1T2) with default parameters. The main results
are presented in the following points.
5.3 Brain f4395 - Visualization 95
5.3.2 Convergence
Table 5.2: Performance of the original (Seg toolbox) and the modified methods
(SegT1T2 toolbox) in the segmentation of the brain from the subject f4395 with
default parameters. The results are expressed in terms of the final log-likelihood
value and the number of iterations until convergence.
The original method fits slightly better the model parameters than most of
the modified versions. However, the differences are really small, and this value
does not show directly the quality of the real segmentation but gives an idea
about how well the method converges. On the other hand, one result that is
more evident is the number of iterations. The original method needed much less
number of iterations, which in practice implies a smaller computation time.
The fact that the modified methods need more iterations to converge implies
that the improvement in each iteration is smaller. As the stopping criterion is
based on the log-likelihood difference between two consecutive iterations, there
are more chances to stop the optimization before it reaches the optimal point
because the fitting process is too slow. Besides, it seems contradictory that the
modified versions with ’fast’ propagation (v.3 & v.4) needed more iterations than
the versions with ’slow’ propagation (v.1 & v.2). However, they finally achieved
a good fitting with even better log-likelihood values, which could imply a bad
initialization (far from the local minimum) but a good updating (proper cost-
function minimization).
96 Validation
The Figure 5.3 presents the evolution of the log-likelihood values at each
iteration for the original (red line) and the modified methods (blue or black
lines). The blue color corresponds to the modified versions with ’slow’ value
propagation (v.1 & v.2), while the ’fast’ propagation versions are in black (v.3
& v.4). The solid lines represent the versions with original starting equations
(v.1 & v.3), while the dotted ones are associated to the versions that apply
modified equations also for the parameter initialization (v.2 & v.4).
Figure 5.3: Log-likelihood value at each iteration for the original method (Seg
toolbox), and the four versions of the modified method (SegT1T2 toolbox). The
red line corresponds to the original method. The blue color corresponds to the
modified versions with ’slow’ value propagation, while the ’fast’ propagation
versions are in black. The solid lines represent the versions with original start-
ing equations, while the dotted ones are associated to the versions that apply
modified equations also for the parameter initialization.
The first 15/20 iterations correspond to the initialization step, which implies
much worse log-likelihood values. If the initialization equations cannot improve
further the log-likelihood value, the method starts using the updating equations.
This criterion makes that each method finishes the initialization at different
epoch, which can be seen in the plot as a jump. The version 2 (dotted blue line)
is the fastest in the beginning, but then it has problems in the last iterations to
minimize the cost function. The initialization step (iterations 1-20) for versions
3 and 4 places them in a worse starting situation, although they have a stable
evolution that reaches a good fitting in the end. The versions with modified
initialization equations (dotted lines) are slightly faster than with the original
initialization equations (solid lines) in all the cases. Although the version 3 of
the modified method is slow, the final fitting is very good; therefore, the rest of
this section will show the results for this method.
5.3 Brain f4395 - Visualization 97
Table 5.3: Values of the mixture parameters after the segmentation of the MRI
brain scans from the subject f4395. The applied segmentation algorithms in-
clude the original and the version 3 of the modified method (*).
As it was previously stated, the order of the clusters inside each tissue class
is random. In addition, one cluster for one method can model the intensities
associated to several clusters by other method. Therefore, it cannot be directly
done a comparison one by one. The level of intensity inhomogeneity correction
also affects these cluster parameters, and this discrepancy of values between
original and modified method is due to this effect.
It is seen that all the presented tissues have a negative covariance, which
implies that larger T1 intensity values are associated with smaller T2 intensity
values, as it is explained with more details in the Appendix B.1. This result is
something expected, and it was previously commented in the Section A.2, where
the properties of the MRI scan were presented.
98 Validation
Figure 5.4: Zoom of the cluster representation done by the original and the
version 3 of the modified method. The lines correspond to the contour of the
Gaussians cut at FWHM, and weighted by the mixing coefficient. The contours
of the clusters done by the original method are presented with dotted lines,
the centers with the symbol *, and the text labels in red. The version 3 of
the modified method presents the contours with solid lines, the center with
the symbol +, and the text labels in blue. The depicted tissues comprise GM
(black), WM (blue), CSF (green), ST (red), bone (yellow), and BG (magenta).
5.3 Brain f4395 - Visualization 99
The Figure 5.5 presents the results for the version 3 of the modified method
with default parameters on the brain f4395. The six columns correspond to the
three planes (coronal, sagittal and transverse) for T1 and T2 modalities. The
top row contains the original volumes, and the middle row presents the volumes
after the intensity inhomogeneity correction. Finally, the bottom row represents
the estimated bias field. In this figure, the images have been intensity scaled
and re-sized for visualization reasons.
In the figure, it can be seen two examples of how the bias field modulates the
intensity. The left-most circle presents an area of the brain than it was acquired
darker than it should be, while the right-most circle presents the opposite. In
addition, it can be seen how the central WM of the T2 volumes is corrected to be
more white. This increase in the brightness of the volumes could be the reason
why the mean and variances are much higher than in the modified method.
Figure 5.5: Bias Field correction for both T1 and T2 modalities. The top row
contains the original volumes for T1 and T2 in the three planes. The middle
row presents the volumes after the intensity inhomogeneity correction, and the
bottom row represents the estimated bias field.
100 Validation
The Figure 5.6 presents the intensity histogram of the volumes before and
after the bias field correction for both modalities and methods. The presentation
is zoomed into the brain voxel intensities, and the big peak of dark intensities,
which correspond to BG voxels, is cropped. After the correction, the expected
Gaussian for each tissue appear more narrow and with less overlap among them.
Thus, it is easier to split them up. In addition, the intensity distributions are
more smooth and spread afterwards.
It can be seen that the modified method applies a stronger non-homogeneity
correction that shifts all the intensities to higher values (more bright). This effect
explains why the obtained cluster parameters have much higher mean, variance
and covariance values for the original method. Besides, there are more voxels
that are shifted from intensities of BG to intensities of brain tissues, which makes
that the number of brain voxels increases.
Figure 5.6: Effect of the bias field correction in terms of the intensity histogram.
The results corresponds to the segmentation of the T1 and T2 MRI scans from
the subject f4395 done by the original and the version 3 of the modified method.
The units of the y-axis correspond to the number of voxels, and the units of the
x-axis are the intensity values. All the histograms are built with 300 bins of the
same size.
5.3 Brain f4395 - Visualization 101
Comparison with baseline: The segmentation result for the modified v.3
method can be compared with the original segmentation baseline, i.e. SPM5 +
VBM5. The segmentation for the subject f4395 done by the original baseline
was presented in the Figure 1.4 and 2.7, and the segmentation for the v.3 method
is presented in the Figure 5.7. For a clear visualization of the comparison, the
Figure 5.8 presents the overlap of tissue volumes between the original baseline
(red) and the modified v.3 method (green). The former detects more GM voxels
in the occipital lobe, in the lower part of the brain stem, and in the utter part
of the parietal lobe. However, the latter method finds in general more GM
voxels in the brain, which are classified as CSF by the original baseline. The
version 3 of the modified method finds more WM voxels in the brain stem,
cerebellum and inner part of the occipital lobe. Although it cannot be seen in
this plot, the v.3 method classifies correctly the right eye muscle as ST, instead
of as CSF like the original baseline does. The spinal cord is more expected
to be WM, as a continuation of the brain stem; however, the original baseline
classifies it as GM. The segmentation of the cerebellum is hard, because the
cortex has less than 1mm of width, smaller than the voxel resolution; therefore,
PVE problems arise. However, without a ground truth segmentation is not
possible to estimate objectively the quality differences between both methods,
although some segmentation errors were solved by the modified method.
Apart from the visual inspection of volumes and parameters done in this
section, the next section addresses the quality of the modified method with a
more objective approach.
102 Validation
Figure 5.7: Probability and overlapped segmented tissues of MRI data from
subject f4395. The first three rows correspond to GM, WM and CSF, respec-
tively. The bottom row is a representation of the overlapped tissues for GM
(red), WM (green) and CSF (blue). The color of each pixel is an RGB combi-
nation weighted by the associated tissue probability. The images correspond to
the coronal, sagittal and transverse planes of the central brain slices.
5.3 Brain f4395 - Visualization 103
Figure 5.9: BrainWeb phantoms for T1 and T2 modalities with 3% level of noise
and 20% of intensity non-uniformity level.
Figure 5.10: BrainWeb phantoms for T1 and T2 modalities with 9% level of noise
and 20% of intensity non-uniformity level.
106 Validation
The original tissue classes for each voxel of the simulated MRI data are
available in a set of probaility maps called atlas. Hence, it is possible to com-
pare the results of the different segmentation methods with respect to a ground
truth. The chosen metric to evaluate the performance corresponds to the Dice
Similarity Coefficient (DSC) [18] [92]. This coefficient is widely used in the
quality evaluation of segmentation algorithms [67] [68] [82]. The generated re-
sult is a number between 0 and 1 for each label (tissue class), where the per-
fect segmentation gives a value of 1, and the random classification gives values
around 0.5. This coefficient is related to the Jaccard index with the expression:
J = D/(2 − D). The DSC is a measurement of the similarity (overlapping)
between two groups (volumes), and it does not give further information about
which is the source of errors in the segmentation, either type I or II.
In the Equation 5.4, it is presented the expression to obtain the Dice Co-
efficient for the tissue class k. The variables Ak and Bk represent two groups
of voxels. The former includes the voxels that are classified as the kth-class
by the method A, and the latter includes voxels classified as the kth-class by
the method B. The symbol ∩ stands for the intersection of two groups and
|.| for cardinality, Therefore, the expression |Ak ∩ Bk | refers to the numbers of
voxels classified as the kth-class by both methods at the same voxels. In the
second term of this equation, the Dice Coefficient is presented in terms of the
confusion matrix elements, i.e. True Positive (TP), True Negative (TN), False
Positive (FP) and False Negative (FN). These values are obtained after applying
majority voting (or thresholding) to the TPM’s generated by each method.
|Ak ∩ Bk | T Pk
Dicek = 2 = 2 (5.4)
|Ak | + |Bk | (T Pk + F Pk ) + (T Pk + F Nk )
In this case, the group A is obtained from the segmentation done by any of
the automatic algorithms, and the group B includes the true labels for each voxel
(atlas). Therefore, for each class and each dataset, six DSC values are obtained,
which correspond to the 2 original methods and the 4 modified methods. As
it was previously stated, two datasets are used with two different noise levels.
Finally, the tissues are grouped into 6 classes, which are GM, WM, CSF, Bone-
ST, BG and total.
5.4 BrainWeb phantoms - Dice Score 107
Once the TPM’s are obtained with the segmentation methods, they are
converted into binary maps, i.e. [0, 1] → {0, 1}. These maps have either one
or zero values, which represents tissue or not at each voxel. In this case, the
Majority Voting technique is applied. The process can be seen in the Figure
5.11 for the sagittal plane of the GM tissue maps. The slices of the middle
column have a noise reduction with respect to the first column. Besides, the
last column presents the probability change at each voxel with the overlapping
of the two previous columns, where yellow voxels indicate almost not change of
probability, red voxels show a decrease, and green voxels an increase. In the
case of the atlas, there are more probability changes (red/green voxels) after
Majority Voting than for the segmentation methods. This fact implies that the
generated TPM’s have values closer to either 1 or 0, which could imply problems
to deal with PVE. In the Appendix D.4, all the results are presented.
Figure 5.11: Majority Voting process for the original and modified v.3 segmen-
tation method. It is depicted the sagittal plane of the GM tissue maps. The
dataset correspond to the BrainWeb phantoms for T1 and T2 modalities with
3% level of noise and 20% of intensity non-uniformity level. The overlapped rep-
resentation in the last column depicts in yellow the voxels that barely changed
their values, in red the voxels that are not finally classified as tissue although
thay had a high probability value, and in green the voxels that are eventually
labelled as the tissue class without a high probability value.
108 Validation
After the segmentation and the majority voting process, the binary tissue
maps are voxel-wise compared to the atlases with the true tissue labels. This
comparison produces the confusion matrix values (TP, TN, FP and FN) that
are combined to generate the final DSC for each class and method.
Figure 5.12: Comparison of six segmentation methods in terms of the Dice score
after applying majority voting on the probability maps. The methods includes:
original method with T1, original method with T1 and T2, modified method
(ver.1) with T1 and T2, modified method (ver.2) with T1 and T2, modified
method (ver.3) with T1 and T2, and modified method (ver.4) with T1 and T2.
The segmentation is analyzed for the labels: GM, WM, CSF, Bone-ST, BG and
total. The two dots for each type are associated with the BrainWeb phantoms
with 3% and 9% of noise level.
5.4 BrainWeb phantoms - Dice Score 109
Noise analysis: In all the cases, the results with 9% of noise give worse
performance (smaller Dice coefficient value) than for a level of 3%. This result
is expected becasue the visual inspection of the Figures 5.9 and 5.10 already
showed the strong quality degradation in the volumes when the noise level is
high. The uni-modal original method is less robust and scores much worse with
important levels of noise. Besides, the versions 3 and 4 are very stable in the
detection of ST, Bone and BG, where they show good results even on noisy
scans. The results for the last class is not too much representative because it is
biased by the results of the BG, which is the class with the biggest number of
voxels.
The final part of this section compares visually the version 3 of the modified
method with the original method in order to analyze from where the improve-
ments come. Namely, it is presented one example for GM and other for CSF.
However, the results are very similar between both methods. It is not pre-
sented and example for WM because the differences between both method in
the segmentation of this tissue are not significant.
110 Validation
The Figure 5.13 shows the segmentation results of the T1 and T2 MRI brain
volumes of the BrainWeb phantoms with 3% level of noise. The colours are
associated with the confusion matrix elements: yellow (TP), black (TN), green
(FP), and red (FN). It can be seen that both methods fail in the detection
of the corpus callosum border (green) and the main part of the brain stem
(red). The problem with the corpus callosum is that it is composed by pure
WM tissue, and it appears very brigth in the T1 scans. Therefore, the border
voxels between the corpus callosum (bright) and the water (dark) combines both
intensity contrasts, which implies a PVE. The brain stem is composed by WM,
although several detection methods missclasify it as GM. In the figure, it is
zoomed an area where the modified v.3 has less number of FP (green) and FN
(red) in an interface between GM and CSF.
The Figure 5.15 presents the volume estimation for 6 subjects of the CIMBI
project. The cohort includes 4 females (26, 30, 54 and 64 years old) and 2 males
(53 and 56 years old). These brain have been segmented with default parameters
by the original and the version 3 of the modified method into GM, WM and
CSF. The volumes of each class are normalized by the ICC volume of each
subject. Besides, at the end of the Appendix D.5, it is presented a simple linear
regression analysis of the volume age profile of these subjects.
The results show a small decrease of GM, an increase of CSF, and con-
stant value of WM. In addition, there is not significant differences between both
methods. However, due to the small used dataset, it is not possible to infer any
further conclusions.
5.5 CIMBI database - Age-Profile 113
Figure 5.15: Volume age profile for GM, WM and CSF generated from the the
segmentation of six volumes. The methods applied correspond to the original
and version 3 of the modified method with default parameters. The tissue classes
corresponds to GM, WM and CSF, which are depicted in black, blue and green,
respectively. The volumes of each class are normalized by the ICC volume of
each subject.
114 Validation
Chapter 6
Discussion
This final chapter presents a resume of the the main conclusions gathered
from the literature study and the obtained segmentation results. Besides, several
ways are proposed to improve the performance of the modified segmentation
method developed in this thesis.
6.1 Resume
In the beginning of this report, it was analyzed the SPM implementation
for MRI brain segmentation, which is based on a MoG model. In this imple-
mentation, the mixture parameters that characterize each cluster are iteratively
optimized in order to minimize the cost function. This cost function also in-
cludes the template registration and the bias field correction. In a wide sense, it
could be said that the MoG introduces intensity information and the prior tem-
plates include spatial information in the model, while the bias field correction
reduces the intensity inhomogeneity perturbations. The result of the segmenta-
tion is a TPM that encodes the probability of belonging to a specific tissue class
at each voxel.
116 Discussion
The results obtained from the segmentation of the first dataset showed that
the modified methods need longer computation time than the original method;
although their final log-likelihood values were similar. Besides, it was visually
analyzed the generated tissue maps and the volume age-profile. The results
were correct for the original and the modified methods, but without a refer-
ence it was not possible to address quality differences. It was surprising that
the value of the mixture parameters obtained by the modified methods were
much higher than the ones obtained by the original one. This effect is due to
the strong estimated bias field correction that spreads the intensities and shifts
them towards larger values, i.e. the image is brighter. It must be reminded
that the bias field correction implementation is the same in the original and
modified method. Hence, the interaction between original bias field estimation
and modified updating equations of the mixture parameters generates this ef-
fect. Although the estimated bias field is stronger, the segmentation results
are correct, which means that the intensity inhomogeneity correction behaves
more like a kernel that transforms the intensities into another space where the
segmentation is easier.
The second dataset includes the atlas with the true labels for each voxel,
therefore it was possible to compare objectively the results. In this case, six
methods were compared, namely the original method with T1 , the original
method with T1 and T2 , and the four versions of the modified method with
T1 and T2 modalities. The Dice score showed that the multispectral approaches
were better that the uni-modal one for all the situations. In addition, the best
method was the version 3 of the modified method, which Dice scores were slightly
higher than the original method for all the classes. In addition, the performance
of v.3 method was much better for the CSF detection and much more stable for
non-brain tissues than the original method. Finally, it was visually inspected
the segmented volumes from original and v.3 method, which showed that the
latter method is able to segment better the voxels that lie in the interface be-
tween several tissues. Therefore, the version 3 of the modified method deals
better with PVE. However, both of them had problems in the detection of the
brain stem and the water around the corpus callosum.
118 Discussion
6.3 Conclusions
Graphically, it was seen that the multispectral approach with T1 and T2 MRI
modalities could improve the brain tissue segmentation. The results of several
multispectral methods on two different datasets showed that this hypothesis
came to be true. In fact, the fully multispectral implementation proposed in this
thesis, where the modalities are not supposed to be non-correlated, is slightly
more accurate and robust than multispectral methods were this assumption is
kept. Therefore, future improvements in this study line seem to be promising.
120 Discussion
Bibliography
[1] M.J. Ackerman. The visible human project. Proceedings of the IEEE,
86(3):504–511, 2002.
[4] M.S. Atkins and B.T. Mackiewich. Fully automatic segmentation of the
brain in MRI. Medical Imaging, IEEE Transactions on, 17(1):98–107, 1998.
[5] J.F. Barrett and N. Keat. Artifacts in CT: Recognition and Avoidance1.
Radiographics, 24(6):1679, 2004.
[6] C.M. Bishop and SpringerLink (Online service). Pattern recognition and
machine learning, volume 4. Springer New York:, 2006.
[7] G. Bouchard and B. Triggs. The tradeoff between generative and discrim-
inative classifiers. In IASC International Symposium on Computational
Statistics (COMPSTAT), pages 721–728. Citeseer, 2004.
[10] M.C. Clark, L.O. Hall, D.B. Goldgof, L.P. Clarke, R.P. Velthuizen, and M.S.
Silbiger. MRI segmentation using fuzzy clustering techniques. Engineering
in Medicine and Biology Magazine, IEEE, 13(5):730–742, 2002.
122 BIBLIOGRAPHY
[11] L.P. Clarke, R.P. Velthuizen, M.A. Camacho, J.J. Heine, M. Vaidyanathan,
L.O. Hall, R.W. Thatcher, and M.L. Silbiger. MRI segmentation: methods
and applications. Magnetic resonance imaging, 13(3):343–368, 1995.
[12] C.A. Cocosco, V. Kollokian, K.S.K. Remi, G.B. Pike, and A.C. Evans.
Brainweb: Online interface to a 3d mri simulated brain database. In Neu-
roImage. Citeseer, 1997.
[13] D.L. Collins, A.P. Zijdenbos, V. Kollokian, J.G. Sled, NJ Kabani, C.J.
Holmes, and A.C. Evans. Design and construction of a realistic digital
brain phantom. Medical Imaging, IEEE Transactions on, 17(3):463–468,
1998.
[14] D.L. Collins, A.P. Zijdenbos, V. Kollokian, J.G. Sled, N.J. Kabani, C.J.
Holmes, and A.C. Evans. Design and construction of a realistic digital
brain phantom. Medical Imaging, IEEE Transactions on, 17(3):463–468,
2002.
[15] K. Conradsen. An Introduction to Statistics. IMSOR, DTU, 1976.
[16] A.M. Dale, B. Fischl, and M.I. Sereno. Cortical Surface-Based Analy-
sis: Segmentation and Surface Reconstruction. Neuroimage, 9(2):179–194,
1999.
[17] A.P. Dempster, N.M. Laird, and D.B. Rubin. Maximum likelihood from
incomplete data via the em algorithm. Journal of the Royal Statistical
Society. Series B (Methodological), 39(1):1–38, 1977.
[18] L.R. Dice. Measures of the amount of ecologic association between species.
Ecology, 26(3):297–302, 1945.
[19] R.O. Duda, P.E. Hart, and D.G. Stork. Pattern classification john wiley &
sons. Inc., New York, 2000.
[20] R.R. Ernst, G. Bodenhausen, and A. Wokaun. Principles of nuclear mag-
netic resonance in one and two dimensions. Oxford University Press, USA,
1990.
[21] A.G. Filler. The history, development and impact of computed imaging in
neurological diagnosis and neurosurgery: CT, MRI, and DTI. 2009.
[22] B. Fischl, D.H. Salat, E. Busa, M. Albert, M. Dieterich, C. Haselgrove,
A. van der Kouwe, R. Killiany, D. Kennedy, S. Klaveness, et al. Whole
Brain Segmentation:: Automated Labeling of Neuroanatomical Structures
in the Human Brain. Neuron, 33(3):341–355, 2002.
[23] J.M. Fitzpatrick, D.L.G. Hill, and C.R. Maurer Jr. Image registration.
Handbook of Medical Imaging: Medical Image Processing and Analysis,
2:447–514.
BIBLIOGRAPHY 123
[25] K.J. Friston, J. Ashburner, C.D. Frith, J.B. Poline, J.D. Heather, and R.S.J.
Frackowiak. Spatial registration and normalization of images. Human brain
mapping, 3:165–189, 1995.
[26] K.J. Friston, A.P. Holmes, K.J. Worsley, J.P. Poline, C.D. Frith, and R.S.J.
Frackowiak. Statistical parametric maps in functional imaging: a general
linear approach. Human brain mapping, 2(4):189–210, 1994.
[27] T.V. Gestel, JAK Suykens, G. Lanckriet, A. Lambrechts, B.D. Moor, and
J. Vandewalle. Bayesian framework for least-squares support vector ma-
chine classifiers, Gaussian processes, and kernel fisher discriminant analysis.
Neural Computation, 14(5):1115–1147, 2002.
[28] C.D. Good, I.S. Johnsrude, J. Ashburner, R.N.A. Henson, K.J. Friston,
and R.S.J. Frackowiak. A voxel-based morphometric study of ageing in 465
normal adult human brains. Neuroimage, 14(1):21–36, 2001.
[29] C.R.G. Guttmann, F.A. Jolesz, R. Kikinis, R.J. Killiany, M.B. Moss,
T. Sandor, and M.S. Albert. White matter changes with normal aging.
Neurology, 50(4):972, 1998.
[30] G. Hamarneh and X. Li. Watershed segmentation using prior shape and
appearance knowledge. Image and Vision Computing, 27(1-2):59–68, 2009.
[35] B. Kevles. Naked to the bone: Medical imaging in the twentieth century.
Rutgers Univ Pr, 1997.
124 BIBLIOGRAPHY
[36] V.S. Khoo, D.P. Dearnaley, D.J. Finnigan, A. Padhani, S.F. Tanner, and
M.O. Leach. Magnetic resonance imaging (MRI): considerations and ap-
plications in radiotherapy treatment planning. Radiotherapy and Oncology,
42(1):1–15, 1997.
[39] R.K.S. Kwan, A. Evans, and G. Pike. An extensible mri simulator for post-
processing evaluation. In Visualization in Biomedical Computing, pages
135–140. Springer, 1996.
[40] R.K.S. Kwan, A.C. Evans, and G.B. Pike. Mri simulation-based evaluation
of image-processing and classification methods. Medical Imaging, IEEE
Transactions on, 18(11):1085–1097, 1999.
[41] K.W. Laidlaw, D.H. Fleischer and A.H. Barr. Partial-volume bayesian clas-
sification of material mixtures in mr volume data using voxel histograms.
Medical Imaging, IEEE Transactions on, 17(1):74–86, 1998.
[42] K.K. Leung, J. Barnes, M. Modat, G.R. Ridgway, J.W. Bartlett, N.C. Fox,
and S. Ourselin. Brain MAPS: An automated, accurate and robust brain
extraction technique using a template library. NeuroImage, 2010.
[43] S.Z. Li. Markov random field modeling in image analysis. Springer-Verlag
New York Inc, 2009.
[45] G.J. McLachlan and D. Peel. Finite mixture models, volume 299. Wiley-
Interscience, 2000.
[46] A.K.H. Miller, R.L. Alston, and J. Corsellis. Variation with age in the
volumes of grey and white matter in the cerebral hemispheres of man:
measurements with an image analyser. Neuropathology and applied neuro-
biology, 6(2):119–132, 1980.
[47] N. Moon, E. Bullitt, K. Van Leemput, and G. Gerig. Automatic brain and
tumor segmentation. Medical Image Computing and Computer-Assisted
Intervention—MICCAI 2002, pages 372–379, 2002.
BIBLIOGRAPHY 125
[49] R.M. Neal and G.E. Hinton. A view of the em algorithm that justifies incre-
mental, sparse, and other variants. Learning in graphical models, 89:355–
368, 1998.
[50] R.W.D. Nickalls. A new approach to solving the cubic: Cardan’s solution
revealed. The Mathematical Gazette, 77(480):354–359, 1993.
[53] Online: Hvidovre Hospital. Danish research centre for magnetic resonance.
http://www.drcmr.dk/, February 2011.
[55] Online: McConnell Brain Imaging Centre (BIC), The Lundbeck Founda-
tion. Brainweb: Simulated brain database. http://www.bic.mni.mcgill.
ca/brainweb/, May 2011.
[58] Online: The Lundbeck Foundation. Center for integrated molecular brain
imaging (cimbi). http://http://www.cimbi.dk/, February 2011.
[61] Online: Zygote Media Group Inc. & Google. Google body. http:
//bodybrowser.googlelabs.com, 2011.
126 BIBLIOGRAPHY
[74] S. Simon. The brain: our nervous system. William Morrow & Co, 1997.
[75] J.G. Sled, A.P. Zijdenbos, and A.C. Evans. A nonparametric method for
automatic correction of intensity nonuniformity in mri data. Medical Imag-
ing, IEEE Transactions on, 17(1):87–97, 1998.
[76] S.M. Smith, M. Jenkinson, M.W. Woolrich, C.F. Beckmann, T.E.J.
Behrens, H. Johansen-Berg, P.R. Bannister, M. De Luca, I. Drobnjak, D.E.
Flitney, et al. Advances in functional and structural MR image analysis
and implementation as FSL. Neuroimage, 23:S208–S219, 2004.
[77] P. Subbiah, P. Mouton, H. Fedor, J.C. McArthur, and J.D. Glass. Stere-
ological analysis of cerebral atrophy in human immunodeficiency virus-
associated dementia. Journal of Neuropathology & Experimental Neurology,
55(10):1032, 1996.
[78] H. Suzuki and J. Toriwaki. Automatic segmentation of head MRI images by
knowledge guided thresholding. Computerized medical imaging and graph-
ics, 15(4):233–240, 1991.
[79] C. Svarer, K. Madsen, S.G. Hasselbalch, L.H. Pinborg, S. Haugbøl, V.G.
Frøkjær, S. Holm, O.B. Paulson, and G.M. Knudsen. MR-based automatic
delineation of volumes of interest in human brain PET images using prob-
ability maps. Neuroimage, 24(4):969–979, 2005.
[80] T. Tasdizen, D. Weinstein, and J.N. Lee. Automatic tissue classification
for the human head from multispectral mri. 2004.
[81] P. Thévenaz and M. Unser. Optimization of mutual information for mul-
tiresolution image registration. Image Processing, IEEE Transactions on,
9(12):2083–2099, 2000.
[82] K. Van Leemput, F. Maes, D. Vandermeulen, and P. Suetens. Automated
model-based tissue classification of MR images of the brain. Medical Imag-
ing, IEEE Transactions on, 18(10):897–908, 2002.
[83] K. Van Leemput, F. Maes, D. Vandermeulen, and P. Suetens. A unifying
framework for partial volume segmentation of brain MR images. Medical
Imaging, IEEE Transactions on, 22(1):105–119, 2003.
[84] Y. Wang, T. Adali, S.Y. Kung, and Z. Szabo. Quantification and segmen-
tation of brain tissues from MR images: A probabilistic neural network
approach. Image Processing, IEEE Transactions on, 7(8):1165–1181, 2002.
[85] S. Warfield, J. Dengler, J. Zaers, C.R.G. Guttmann, W.M. Wells, G.J.
Ettinger, J. Hiller, and R. Kikinis. Automatic identification of gray matter
structures from MRI to improve the segmentation of white matter lesions.
Journal of Image Guided Surgery, 1(6):326–338, 1995.
128 BIBLIOGRAPHY
[87] S.K. Warfield, K.H. Zou, and W.M. Wells. Simultaneous truth and per-
formance level estimation (STAPLE): an algorithm for the validation of
image segmentation. Medical Imaging, IEEE Transactions on, 23(7):903–
921, 2004.
[88] N. Weiskopf, A. Lutti, G. Helms, M. Novak, J. Ashburner, and C. Hutton.
Unified segmentation based correction of r1 brain maps for rf transmit field
inhomogeneities (unicort). NeuroImage, 54(3):2116 – 2124, 2011.
[89] R.P. Woods, J.C. Mazziotta, et al. MRI-PET registration with automated
algorithm. Journal of computer assisted tomography, 17(4):536, 1993.
[93] K.H. Zou, S.K. Warfield, A. Bharatha, C.M.C. Tempany, M.R. Kaus, S.J.
Haker, W.M. Wells III, F.A. Jolesz, and R. Kikinis. Statistical validation
of image segmentation quality based on a spatial overlap index: scientific
reports. Academic radiology, 11(2):178, 2004.
Appendices
Appendix A
Magnetic Resonance
This section describes the MRI physics, specially the NMR effect. The
information is based on [9] [20] [23] [32].
The Equation A.1 shows the dependency of the spin frequency wL respect
to the gyromagnetic radio γ and the intensity of the applied magnetic field B0 .
The magnetic field unit is Tesla T , which is equivalent to 1e4 gauss.
wL = −γ · B0 (A.1)
A.1.1 Perturbation
In the nature, the magnetic moments m of each nuclei are usually pointing
in random directions and with different phases. As explained previously, if an
external magnetic field B0 is applied, the nucleus will torque its precession axis
following the magnetic field. It is considered that this applied field is static
and space homogeneous. However, the lack of phase coherence makes that the
overall macroscopic magnetic field net M can be almost neglected. For example,
the Equation A.2 represents the ratio of nucleus with parallel and anti-parallel
spin according from the Boltzmann’s equation, where h stands for the Planck’s
constant and k for the Boltzmann’s constant. At an ambient temperature of
T = 27◦ + 273.15◦ , the excess of spin-up particles accounts for just 10 parts per
million (ppm).
spin up γ · h · B0
= exp (A.2)
spin down k·T
From a quantum point of view, this perturbation will excite the nucleus and
flip the spin of some particles. If they were in a lower energy state (spin-up or
parallel direction), they will shift to a higher energy one (spin-down or anti-
parallel direction). On the other hand, if they were already in a high energy
state, they will release energy as a photon at the resonance frequency and they
will shift to a low energy state. This growing number of anti-parallel particles
increases the flip angle, which could reaches values close to 180o . Although, a
single particle can only have two precession angles, i.e. parallel 0o and anti-
parallel 180o , a volume of several particles can have values between 0o and 180o
as an average over all the particles included in the volume.
134 Magnetic Resonance
During this phase, the number of particles of both spins are equal. The
macroscopic magnetization M precesses at the Larmour frequency in the trans-
verse plane, i.e. xy-plane. After this 90◦ flip, the longitudinal component in the
z-direction of the magnetic field vanishes.
A.1.2 Relaxation
Once the perturbation is over, the relaxation period starts and the thermal
equilibrium is recovered. The signal received in the coils during this phase is
called free-induction decay (FID) signal. During this process, the total mag-
netic moment M gradually goes back to the original z-direction and the phase
coherence is lost. This decay can be characterized by two relaxation times, T1
and T2 , related to the exponential nature of this process that follows the Bloch
Equations. T1 lasts longer than T2 , T1 > T2 . As presented in the Figure A.3,
after the 90◦ flip, the transverse field Mxy is maximum and the longitudinal Mz
is minimum. The decay of both fields to the the 63% of its respective maximum
value determines the corresponding values. In addition, other parameters can
also been acquired from the FID with NMR imaging, like PD and T2∗ , which
stand for the proton density and envelope of the T2 decay, respectively. However
they are not included in the dataset of this project, so no further comment will
be done.
The solids, like the scalp, have no signal in MRI due to the short relaxation
time. The gases and the free pure water have both equal T1 and T2 , which
for the water can last even for some seconds because of the great absorption of
the RF signal that keeps them in phase. In liquids, the T1 is bigger than T2 .
Therefore, the GM has bigger value for T1 than for T2 , while the opposite occurs
with the WM.
The shorter is the relaxation time, the brighter is the acquired MR image.
Thus, a T1 image will have brighter voxels for WM, darker for GM,
and almost black for CSF. In addition, for T1 , a tumour has bigger acquired
intensity value than a normal tissue, and muscle tissue bigger than fat. There-
fore, some lesions can resemble GM in T1 images. Almost the opposite contrast
will be expected in T2 images.
136 Magnetic Resonance
Figure A.3: Relaxation time T1 (red) and T2 (ble) during the perturbance and
relaxation processes. The epoch of the 90◦ flip is marked with a vertical dashed
line. The top plot presents the time-evolution of the longitudinal component of
the magnetic field Mz (in red), from where it is extracted the T1 value. The
bottom plot includes the transverse field Mxy and the T2 time.
Mathematics
1 x−µ
f (x) = √ e− 2σ2 (B.1)
2πσ
The Equation B.2 presents the bi-dimensional Normal distribution for the
variables x1 and x2 . It is characterized by the mean (µ1 ,µ2 ) and variance (σ1 ,σ2 )
for each variable. In addition, it counts with an additional parameter that
measures the correlation between them, the cross covariance σ12 .
n h io
−σ 2 ·σ 2 (x1 −µ1 )2 (x2 −µ2 )2 (x1 −µ1 )(x2 −µ2 )
1 2
1 2(σ 2 ·σ 2 −σ 2 )
·
σ2
+
σ2
−2σ12 ·
σ 2 ·σ 2
f (x1 , x2 ) = p e 1 2 12 1 2 1 2
2π σ12 · σ22 − σ12
2
(B.2)
B.1 Gaussian distribution 139
The tan() function is π-periodic, thus it gives two valid solutions in the
interval [0, 2π), which correspond to ϕ and ϕ + π. In addition, in case the axis
of
the Gaussian are equal, σ 1 = σ2 , the angle has four solution in [0, 2π), namely
ϕ, ϕ + π2 , ϕ + π, ϕ + 3 π2 . The obtained angle has the same sign than the
cross covariance and the correlation. Therefore, for a positive cross covariance
higher values of x1 implies higher values of x1 , and the apposite.
x1 ↑ ⇒ x2 ↑ x1 ↑ ⇒ x2 ↓
σ12 > 0 ⇒ σ12 < 0 ⇒
x1 ↓ ⇒ x2 ↓ x1 ↓ ⇒ x2 ↑
The values of the covariance depends on the scale and units of the dataset.
Therefore, in order to compare the dispersion of values between two variables,
it is usually applied the correlation coefficient, which normalized each centered
variable by its covariance.
x−µ
x →
σ
The following code collects these ideas in order to estimate from the 2D
covariance matrix the rotation angle.
Figure B.2: 2D Gaussian with 0 degrees rotation. The parameters are µ = [2, 3]
and σ = [1, 4], and σ12 = 0. The symbol ’+’ is to the center of the bell.
Figure B.3: 2D Gaussian with -45 degrees clockwise rotation. The parameters
are µ = [1, 1] and σ = [10, 10], and σ12 = −5. The symbol ’+’ corresponds to
the center of the bell.
B.1 Gaussian distribution 141
(a) Only one Gaussian detected. (b) Gaussian means are shifted.
Figure B.4: Example of two problems in the MOG model. In blue is drawn the
original two distributions, and in red is presented the aggregation of them.
B.2 2D Gaussian expression
142
The k-cluster of the MoG is modeled by a 2-dimensional Gaussian due to the inclusion of two modalities/channels.
It is characterized by its mean and variance. In this section, it is presented the steps to generate the expression of a
Gaussian distribution in two dimensions from the general multidimensional expression, i.e. N (Y | µk , Σk ) |N =2 .
The Equation B.4 corresponds to the multivariate Gaussian distribution for an N -dimensional variable Y, which is
parameterized by the mean vector µk , and the covariance matrix Σk , which rank corresponds to the dimensionality N .
In the expression, |·| stands for the determinant, and ()−1 is the inverse matrix.
1 1 T −1
N (Y | µk , Σk ) = N 1 exp − (Y − µk ) Σ k (Y − µk ) (B.4)
(2π) 2 |Σk | 2 2
The dimension N stands for the number of modalities, in this case is fixed to N = 2 , i.e. T1 and T2 . Thus, the
T
variable Y corresponds to Y = YT 1 YT 2 , µk is the mean vector with dimensions 2x1, and Σk is the covariance
matrix with dimensions 2x2. The expressions presented here correspond to the distribution of the kth-cluster, where
C (Y) stands for the class of the variable Y.
E{YT1 | C (Y) = k} µk,T 1
µk = E(Y | C (Y) = k) = =
E{YT2 | C (Y) = k} 2,1 µk,T 2 2,1
E{YT1 − µT 1 · YT1 − µT 1 | C (Y) = k} E{YT1 − µT 1 · YT2 − µT 2 | C (Y) = k}
Σk = Cov(Y | C (Y) = k) =
E{YT2 − µT 2 · YT1 − µT 1 | C (Y) = k} E{YT2 − µT 2 · YT2 − µT 2 | C (Y) = k} 2,2
2
2
σk,T 1T 1 σk,T 1T 2 σk,T 1 σk,T 1T 2 σk,T 1 ρk σk,T 1 σk,T 2
= = 2 = 2
σk,T 2T 1 σk,T 2T 2 2,2 σk,T 1T 2 σk,T 2 2,2 ρk σk,T 1 σk,T 2 σk,T 2 2,2
Mathematics
The distribution is normal, thus the covariance matrix is symmetric, which implies that the cross-correlation terms
are equal, i.e. σk,T 1T 2 = σk,T 2T 1 . In case that the Gaussians are uncorrelated, i.e. ρk = 0, the cross-correlation terms are
also null and the covariance matrix is diagonal.
2 2
σk,T 1 σk,T 1T 2 2 2 2
|Σk | = det (Σk ) = det 2 = σk,T 1 · σk,T 2 − σk,T 1T 2
σk,T 1T 2 σk,T 2
B.2 2D Gaussian expression
σ2 σ2
h 2 2 i
k,T 1 k,T 2 YT 1 −µk,T 1 YT 2 −µk,T 2 σk,T 1T 2
− · σk,T 1 + σk,T 2 + ·[(YT 1 −µk,T 1 )(YT 2 −µk,T 2 )]
2 σ2 σ2 −σ 2 σ2 σ2 −σ 2
exp k,T 1 k,T 2 k,T 1T 2 k,T 1 k,T 2 k,T 1T 2
N (Y | µk , Σk ) = q
2π 2
σk,T 2 2
1 · σk,T 2 − σk,T 1T 2
(B.5)
If the correlation factor ρk is introduced in the previous equation, the Equation B.7 is generated.
σk,T 1T 2 σk,T 1T 2
ρk = =√ (B.6)
σk,T 1 · σk,T 2 σk,T 1T 1 · σk,T 2T 2
The following equation can be compared with the expression in K. Conradsen et al. [Page 78, [15]]. Both equations
are equal, thus the 2-dimensional Gaussian expression of Equation B.5 is correct.
h 2 2 i
− 1 YT 1 −µk,T 1
+
YT 2 −µk,T 2
+
ρk (YT 1 −µk,T 1 )(YT 2 −µk,T 2 )
2 1−ρ2
σk,T 1 σk,T 2 1−ρ2 σk,T 1 ·σk,T 2
( k ) k
exp
N (Y | µk , Σk ) = p (B.7)
2π σk,T 1 σk,T 2 1 − ρ2k
Mathematics
B.3 Cost Function of M-step
The Equation B.8 presents the complete upper bound of the function cost for the kth-cluster, εEMk . It is generated
from the Equation 4.30.
I
X I
X XK
εEMk = − log (γk )· qi,k + qi,k log γj · bij (α)
i=1 i=1 j=1
B.3 Cost Function of M-step
I I
X ρi,T 1 (β) · ρi,T 2 (β) · bik (α) 1 2 2 2
X
− qi,k log − log σk,T 1 · σk,T 2 − σk,T 1T 2 · qi,k
i=1
2π 2 i=1
2 I
σk,T 2
X 2
+ qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 )
2 2 · 2 − 2
σk,T 1 σk,T 2 σk,T 1T 2 i=1
2 I
σk,T 1
X 2
+ qi,k (ρi,T 2 (β) · yi,T 2 − µk,T 2 )
2 2 2 2
σk,T 1 · σk,T 2 − σk,T 1T 2 i=1
I
σk,T 1T 2 X
− qi,k (ρi,T 1 (β) · yi,T 1 − µk,T 1 ) (ρi,T 2 (β) · yi,T 2 − µk,T 2 ) (B.8)
2 2 2
σk,T 1 · σk,T 2 − σk,T 1T 2 i=1
145
B.4 Central and non-central moments
146
In the implementation of the segmentation method, the moments of a 2-D discrete variable are used. Namely, the
original ’New segmentation’ method just uses non-central moments, while the modified method uses the central moments
as well. The two dimensions are because the inclusion of the two modalities: T1 and T2 .
Non-central moments
The non-central moment of nth-order for the discrete variable Y belonging to the kth-cluster corresponds to the
Equation B.9, where E stands for the expectation operator, qik is the probability of the intensity value yi included in the
kth cluster, and I is the number of elements (voxels) that are analyzed.
I
X
n
E {Y }k = qik · yin (B.9)
i=1
In this case, the random variable is Y is modulated in amplitude by the bias field, thus the discrete variable correspond
to P (β) · Y , where P (β) stands for the bias field parameterized by β. The zero, first (mean), and second moments for
the kth-cluster are presented here:
I
#
I
"P
X qik (pi,T 1 (β) · yi,T 1 )
mom0(k) = Σ0k = qik , mom1(:, k) = Σ1k = PIi=1
#
I 2
"P PI
qik (pi,T 1 (β) · yi,T 1 ) i=1 qik (pi,T 1 (β) · yi,T 1 ) (pi,T 2 (β) · yi,T 2 )
mom2(:, :, k) = Σ2k = I
Pi=1 PI 2
i=1 qik (pi,T 2 (β) · yi,T 2 ) (pi,T 1 (β) · yi,T 1 ) i=1 qik (pi,T 2 (β) · yi,T 2 ) 2x2
Mathematics
Central moments
If the moments are considered once the mean µ has been subtracted from the variable, i.e. Y −µ, then they correspond
to the central moments, which are presented in the Equation B.10 for nth-order of the discrete variable Y belonging to
the kth-cluster. E corresponds to the expectation operator, qik is the probability of the intensity value yi included in the
kth cluster, and I is the number of elements (voxels) that are analyzed.
I
n n
X
E {(Y − µ) }k = qik · (yi − µ) (B.10)
i=1
Likewise, the random variable Y is modulated in amplitude by the bias field P (β), thus the discrete variable cor-
respond to P (β) · Y . The zero central moment is the same than the zero non-central moment, thus it is not needed to
repeat the expression. The first and second (variance) moments for the kth-cluster are presented here:
B.4 Central and non-central moments
#
I
"P
qik (pi,T 1 (β) · yi,T 1 − µk,T 1 )
mom1c(:, k) = Σ̂1k = Σ1k −µk ·Σ0k = I
Pi=1
i=1 qik (pi,T 1 (β) · yi,T 2 − µk,T 2 )
2x1
T
mom2c(:, :, k) = Σ̂2k = Σ2k + µk · Σ0k · µk T − µk · Σ1k − Σ1k · µk T =
#
I 2
"P PI
i=1 qik (pi,T 1 (β) · yi,T 1 − µk,T 1 ) i=1 qik (pi,T 1 (β) · yi,T 1 − µk,T 1 ) (pi,T 2 (β) · yi,T 2 − µk,T 2 )
PI PI 2
i=1 qik (pi,T 2 (β) · yi,T 2 − µk,T 2 ) (pi,T 1 (β) · yi,T 1 − µk,T 1 ) i=1 qik (pi,T 2 (β) · yi,T 2 − µk,T 2 ) 2x2
The variables µk and Σ1k corresponds to the first non-central moment. However, they do not express the same. The
former includes all the values of the variable Y , and the latter just i = 1..I values from variable Y . Therefore, when I
includes all the values, both are equal and Σ̂2k = Σ2k − µk · µk T . The method analyzes one slice at each time, thus I
147
stands for the number of voxels of each slice, while µk is the mean intensity value of the kth-cluster for the whole brain.
Test of the implementation of the central moments in Matlab
148
In order to check that the equations and the Matlab code of the central moments are correct, they are estimated in
other ways (different that the proposed in the Matlab implementation of Section 4.3) to check their validity.
The second option includes the decomposition of each element of the first and second central moments. As the
dimensionality is low, the extra effort compensates in order to ensure correct values.
Finally, the central moments are calculated following the original expression and also following these two additional
forms. The three results give the same values, thus it has been numerically checked that the equations and the Matlab
implementation matches.
Mathematics
B.5 Solution to a third degree equation 149
% Closed−form equations
x = solution3th(coef3,coef2,coef1,coef0,1);
if ((vr(1,1,k)∗vr(2,2,k)−x^2)<tiny)||(abs(imag(x))>1e−4)
x = solution3th(coef3,coef2,coef1,coef0,2);
if (vr(1,1,k)∗vr(2,2,k)−x^2)<tiny)||(abs(imag(x))>1e−4)
x = solution3th(coef3,coef2,coef1,coef0,3);
if (vr(1,1,k)∗vr(2,2,k)−x^2)<tiny||(abs(imag(x))>1e−4)
x = vrX(1,2,k);
end
end
end
solution = real(solution);
This function returns the solution of a 3rd degree equation with coefficients
coef3, coef2, coef1 and coef0.
switch opt
case 1
solution = (((coef0/(2∗coef3) + coef2^3/(27∗coef3^3) ...
− (coef1∗coef2)/(6∗coef3^2))^2 + (coef1/(3∗coef3) ...
− coef2^2/(9∗coef3^2))^3)^(1/2) − coef2^3/(27∗coef3^3) ...
− coef0/(2∗coef3) + (coef1∗coef2)/(6∗coef3^2))^(1/3) ...
− (coef1/(3∗coef3) − coef2^2/(9∗coef3^2))/(((coef0/(2∗coef3) ...
+ coef2^3/(27∗coef3^3) − (coef1∗coef2)/(6∗coef3^2))^2 ...
+ (coef1/(3∗coef3) − coef2^2/(9∗coef3^2))^3)^(1/2) ...
− coef2^3/(27∗coef3^3) − coef0/(2∗coef3) ...
+ (coef1∗coef2)/(6∗coef3^2))^(1/3) − coef2/(3∗coef3);
case 2
solution = (coef1/(3∗coef3) ...
− coef2^2/(9∗coef3^2))/(2∗(((coef0/(2∗coef3) ...
+ coef2^3/(27∗coef3^3) − (coef1∗coef2)/(6∗coef3^2))^2 ...
+ (coef1/(3∗coef3) − coef2^2/(9∗coef3^2))^3)^(1/2) ...
− coef2^3/(27∗coef3^3) − coef0/(2∗coef3) ...
+ (coef1∗coef2)/(6∗coef3^2))^(1/3)) ...
− (((coef0/(2∗coef3) + coef2^3/(27∗coef3^3) ...
− (coef1∗coef2)/(6∗coef3^2))^2 + (coef1/(3∗coef3) ...
− coef2^2/(9∗coef3^2))^3)^(1/2) − coef2^3/(27∗coef3^3) ...
150 Mathematics
The second method consist on looking for the roots of the equations, i.e. find
the zero-crossing points where the sign of the function changes. In this case, it is
used the Matlab function fzeros() that applies a bisection method. As a starting
point, the chosen values are {varOriginal, −varOriginal, +varOriginal}.
% Bilinear interpolation
[x_value,fval,exitflag] = ...
fzero(@(x) coef3∗x^3+coef2∗x^2+coef1∗x+coef0,vrX(1,2,k));
if ((vr(1,1,k)∗vr(2,2,k)−x_value^2)<tiny) || ¬exitflag
[x_value,fval,exitflag] = ...
fzero(@(x) coef3∗x^3+coef2∗x^2+coef1∗x+coef0,10∗vrX(1,2,k));
if (vr(1,1,k)∗vr(2,2,k)−x_value^2)<tiny || ¬exitflag
[x_value,fval,exitflag] = ...
fzero(@(x) coef3∗x^3+coef2∗x^2+coef1∗x+coef0,−10∗vrX(1,2,k));
if (vr(1,1,k)∗vr(2,2,k)−x_value^2)<tiny || ¬exitflag
x_value = vrX(1,2,k);
end
end
end
B.5 Solution to a third degree equation 151
% Parameters
N = 1000;
time1 = 0; time2 = 0;
% N iterations
for i=1:N
% Coefficints
coef3 = 100∗randn(1);
coef2 = 100∗randn(1);
coef1 = 100∗randn(1);
coef0 = 100∗randn(1);
% Exact solution
tic
solution1 = solution3th(coef3,coef2,coef1,coef0,1);
solution2 = solution3th(coef3,coef2,coef1,coef0,2);
solution3 = solution3th(coef3,coef2,coef1,coef0,3);
time1 = time1 + toc;
% Bilinear interpolation
tic
x_value1 = fzero(@(x) coef3∗x^3+coef2∗x^2+coef1∗x+coef0, 0);
x_value2 = fzero(@(x) coef3∗x^3+coef2∗x^2+coef1∗x+coef0, −1000);
x_value3 = fzero(@(x) coef3∗x^3+coef2∗x^2+coef1∗x+coef0, 1000);
time2 = time2 + toc;
end
% Display
disp([’Averaged time by exact method: ’,num2str(time1/N),’secs’]);
disp([’Averaged time by bilinear interp: ’,num2str(time2/N),’secs’]);
The final time per iteration was time1 = 0.0046 and time2 = 0.00010836,
both of them in seconds. It means that the exact method is 40 times faster.
In addition, the bilinear interpolation method was not always able to find the
three solution; although when it did it, the magnitude difference between both
methods was neglectable.
152 Mathematics
B.6 Registration
Example in Matlab, where a 1-unit square is transformed according to the
four individual affine transformations. The code uses the pre-multiplication of
the 2D affine transformation matrix.
Figure B.5: Affine Transformation example in 2D. The original shape is a blue
square with vertices [0,0], [0,1], [1,0] and [1,1]. In the top-left figure, it is applied
a scaling of {2,4}. In the top-righ figure, it is applied a translation of {3,-1}. In
the top-left figure, it is applied a rotation of π/4. In the bottom-right figure, it
is applied a shear of 2.
B.6 Registration 153
1 % Original square
2 X=[0 0 1 1;0 1 0 1];
3 X_ext=[X; 1 1 1 1];
4
5 % Scaling
6 scaling=[2 4];
7
8 A=[scaling(1) 0; 0 scaling(2)];
9 A_ext=[A(1,:) 0; A(2,:) 0; 0 0 1];
10
11 Y_ext=A_ext∗X_ext;
12 Y=Y_ext(1:2,:);
13
14 figure,
15 subplot(2,2,1)
16 title([’Scaling (zoom), z_{x}=’,num2str(scaling(1)),...
17 ’ and z_{y}=’,num2str(scaling(2))])
18 hold on
19 scatter(X(1,:),X(2,:),’b’);
20 scatter(Y(1,:),Y(2,:),’r’);
21 line([X(1,1) X(1,2) X(1,1) X(1,3) X(1,4) X(1,3) X(1,4) X(1,2)],...
22 [X(2,1) X(2,2) X(2,1) X(2,3) X(2,4) X(2,3) X(2,4) X(2,2)],...
23 ’Color’,’b’)
24 line([Y(1,1) Y(1,2) Y(1,1) Y(1,3) Y(1,4) Y(1,3) Y(1,4) Y(1,2)],...
25 [Y(2,1) Y(2,2) Y(2,1) Y(2,3) Y(2,4) Y(2,3) Y(2,4) Y(2,2)],...
26 ’Color’,’r’)
27 hold off
28 axis([−5 5 −5 5])
29 grid on
30
31
32 % Translation
33 trans=[3 −1];
34
35 A=[1 0; 0 1];
36 A_ext=[A(1,:) trans(1); A(2,:) trans(2); 0 0 1];
37
38 Y_ext=A_ext∗X_ext;
39 Y=Y_ext(1:2,:);
40
41 subplot(2,2,2)
42 title([’Translation, t_{x}=’,num2str(trans(1)),...
43 ’ and t_{y}=’,num2str(trans(2))])
44 hold on
45 scatter(X(1,:),X(2,:),’b’);
46 scatter(Y(1,:),Y(2,:),’r’);
47 line([X(1,1) X(1,2) X(1,1) X(1,3) X(1,4) X(1,3) X(1,4) X(1,2)],...
48 [X(2,1) X(2,2) X(2,1) X(2,3) X(2,4) X(2,3) X(2,4) X(2,2)],...
49 ’Color’,’b’)
50 line([Y(1,1) Y(1,2) Y(1,1) Y(1,3) Y(1,4) Y(1,3) Y(1,4) Y(1,2)],...
51 [Y(2,1) Y(2,2) Y(2,1) Y(2,3) Y(2,4) Y(2,3) Y(2,4) Y(2,2)],...
52 ’Color’,’r’)
53 hold off
54 axis([−5 5 −5 5])
154 Mathematics
55 grid on
56
57
58 % Rotation (yaw)
59 angle=pi/4;
60
61 A=[cos(angle) −sin(angle); sin(angle) cos(angle)];
62 A_ext=[A(1,:) 0; A(2,:) 0; 0 0 1];
63
64 Y_ext=A_ext∗X_ext;
65 Y=Y_ext(1:2,:);
66
67 subplot(2,2,3)
68 title([’Rotation, \alpha=\pi/’,num2str(pi/angle(1))])
69 hold on
70 scatter(X(1,:),X(2,:),’b’);
71 scatter(Y(1,:),Y(2,:),’r’);
72 line([X(1,1) X(1,2) X(1,1) X(1,3) X(1,4) X(1,3) X(1,4) X(1,2)],...
73 [X(2,1) X(2,2) X(2,1) X(2,3) X(2,4) X(2,3) X(2,4) X(2,2)],...
74 ’Color’,’b’)
75 line([Y(1,1) Y(1,2) Y(1,1) Y(1,3) Y(1,4) Y(1,3) Y(1,4) Y(1,2)],...
76 [Y(2,1) Y(2,2) Y(2,1) Y(2,3) Y(2,4) Y(2,3) Y(2,4) Y(2,2)],...
77 ’Color’,’r’)
78 hold off
79 axis([−5 5 −5 5])
80 grid on
81
82
83 % Shear
84 shear=[2];
85
86 A=[1 shear(1); 0 1];
87 A_ext=[A(1,:) 0; A(2,:) 0; 0 0 1];
88
89 Y_ext=A_ext∗X_ext;
90 Y=Y_ext(1:2,:);
91
92 subplot(2,2,4)
93 title([’Shear, s_{x}=’,num2str(shear(1))])
94 hold on
95 scatter(X(1,:),X(2,:),’b’);
96 scatter(Y(1,:),Y(2,:),’r’);
97 line([X(1,1) X(1,2) X(1,1) X(1,3) X(1,4) X(1,3) X(1,4) X(1,2)],...
98 [X(2,1) X(2,2) X(2,1) X(2,3) X(2,4) X(2,3) X(2,4) X(2,2)],...
99 ’Color’,’b’)
100 line([Y(1,1) Y(1,2) Y(1,1) Y(1,3) Y(1,4) Y(1,3) Y(1,4) Y(1,2)],...
101 [Y(2,1) Y(2,2) Y(2,1) Y(2,3) Y(2,4) Y(2,3) Y(2,4) Y(2,2)],...
102 ’Color’,’r’)
103 hold off
104 axis([−5 5 −5 5])
105 grid on
Appendix C
SPM
This chapter includes a deeper explanation of the variables and the Matlab
code of the file spm preproc8T1T2.m of the ’SegT1T2’ toolbox for SPM8.
A common variable struct used for both MRI data and templates corre-
sponds to the output of the function spm vol(). From the complete filename of
the volumes, this function creates a struct with the following fields:
• V.fname <string> path, name and extension of the file with the volumes,
which can be stored in either format .nii or .hdr/.img.
• V.mat <4x4 double> pre-multiplication affine transformation matrix.
• V.dim <1x3 double> dimensions of the original volume for the x, y and z
coordinates.
• V.dt <1x2 double> format of the NIFTI-1 files according to spm type().
• V.pinfo <3x1 double> scaling factor of each plane.
The following two sections present the main input and output variables with
information about its dimensions and a short description. It can be assumed
that: N = 2, Kb = 6, and K = 15.
156 SPM
Volumes: MRI individual brain volumes to segment. There are two modal-
ities, T1 and T2 , which are stored in obj.image(1) and obj.image(2). Afterwards,
the volumes are stored in V =obj.image.
• obj.image <2x1 struct> individual volumes in the format of spm vol().
Gaussians per tissue: Look-up table with the number of clusters associ-
ated to each tissue class.
• obj.lkp <Kx1 double> lkp=[1,1,2,2,3,3,4,4,4,5,5,5,5,6,6];
Part of the code from the file spm preproc8.m that corresponds to the Seg
toolbox. This extract shows how the values for the mixture parameters are
estimated.
374 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
375 % Estimate cluster parameters
376 %−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
377 for subit=1:20,
378 oll = ll;
379 mom0 = zeros(K,1)+tiny;
380 mom1 = zeros(N,K);
381 mom2 = zeros(N,N,K);
382 ll = llr+llrb;
383 for z=1:length(z0),
384 if ¬buf(z).nm, continue; end
385 q = likelihoods(buf(z).f,buf(z).bf,mg,mn,vr);
386 for k1=1:Kb,
387 b = double(buf(z).dat(:,k1));
388 for k=find(lkp==k1),
389 q(:,k) = q(:,k).∗b;
390 end
391 clear b
392 end
393 sq = sum(q,2)+tiny;
394 ll = ll + sum(log(sq + tiny));
395 cr = zeros(size(q,1),N);
396 for n=1:N,
397 cr(:,n) = double(buf(z).f{n}.∗buf(z).bf{n});
398 end
399 for k=1:K, % Moments
400 q(:,k) = q(:,k)./sq;
401 mom0(k) = mom0(k) + sum(q(:,k));
402 mom1(:,k) = mom1(:,k) + (q(:,k)’∗cr)’;
403 mom2(:,:,k) = mom2(:,:,k) + (repmat(q(:,k),1,N).∗cr)’∗cr;
404 end
405 clear cr
406 end
407
408 %fprintf(’MOG:\t%g\t%g\t%g\n’, ll,llr,llrb);
409
410 % Priors
411 %nmom = struct(’mom0’,mom0,’mom1’,mom1,’mom2’,mom2);
412 if exist(’omom’,’var’) && isfield(omom,’mom0’) && ...
413 numel(omom.mom0) == numel(mom0),
414 mom0 = mom0 + omom.mom0;
415 mom1 = mom1 + omom.mom1;
416 mom2 = mom2 + omom.mom2;
417 end
418
419 % Mixing proportions, Means and Variances
158 SPM
Part of the code from the file spm preproc8T1T2.m that corresponds to the
SegT1T2 toolbox. This extract shows how the values for the mixture parameters
are estimated.
376 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
377 % Estimate cluster parameters
378 %−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
379 for subit=1:20,
380 oll = ll;
381 mom0 = zeros(K,1)+tiny;
382 mom1 = zeros(N,K);
383 mom2 = zeros(N,N,K);
384 mom1c = zeros(N,K);
385 mom2c = zeros(N,N,K);
386 ll = llr+llrb;
387 for z=1:length(z0),
388 if ¬buf(z).nm, continue; end
389 q = likelihoods(buf(z).f,buf(z).bf,mg,mn,vr);
390 for k1=1:Kb,
391 b = double(buf(z).dat(:,k1));
392 for k=find(lkp==k1),
393 q(:,k) = q(:,k).∗b;
394 end
395 clear b
396 end
397 sq = sum(q,2)+tiny;
398 for k=1:K,
399 q(:,k) = q(:,k)./sq;
400 end
401 ll = ll + sum(log(sq + tiny));
402 cr = zeros(size(q,1),N);
403 for n=1:N,
404 cr(:,n) = double(buf(z).f{n}.∗buf(z).bf{n});
405 end
406 for k=1:K, % Moments
407 % Non−centered moments
408 mom0(k) = mom0(k) + sum(q(:,k));
409 mom1(:,k) = mom1(:,k) + (q(:,k)’∗cr)’;
410 mom2(:,:,k) = mom2(:,:,k) + (repmat(q(:,k),1,N).∗cr)’∗cr;
411 % Central moments
412 crc = cr − repmat(mn(:,k)’,size(q,1),1);
413 mom1c(:,k) = mom1c(:,k)+(q(:,k)’∗crc)’;
414 mom2c(:,:,k) = mom2c(:,:,k)+(repmat(q(:,k),1,N).∗crc)’∗crc;
415 end
416 clear cr crc
417 end
418
419 %fprintf(’MOG:\t%g\t%g\t%g\n’, ll,llr,llrb);
420
421 % Priors
160 SPM
Part of the code from the file spm preproc8T1T2.m that corresponds to the
SegT1T2 toolbox. This extract shows how the values for the mixture parameters
are estimated. This second version corresponds to an implementation where the
updating equations use the most-updated values of the current iteration, and
not the values from the previous iteration.
376 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
377 % Estimate cluster parameters
378 %−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
379 for subit=1:20,
380 oll = ll;
381 mom0 = zeros(K,1)+tiny;
382 mom1 = zeros(N,K);
383 mom2 = zeros(N,N,K);
384 ll = llr+llrb;
385 for z=1:length(z0),
386 if ¬buf(z).nm, continue; end
387 q = likelihoods(buf(z).f,buf(z).bf,mg,mn,vr);
388 for k1=1:Kb,
389 b = double(buf(z).dat(:,k1));
390 for k=find(lkp==k1),
391 q(:,k) = q(:,k).∗b;
392 end
393 clear b
394 end
395 sq = sum(q,2)+tiny;
396 for k=1:K,
397 q(:,k) = q(:,k)./sq;
398 end
399 ll = ll + sum(log(sq + tiny));
400 cr = zeros(size(q,1),N);
401 for n=1:N,
402 cr(:,n) = double(buf(z).f{n}.∗buf(z).bf{n});
403 end
404 for k=1:K, % Moments
405 % Non−centered moments
406 mom0(k) = mom0(k) + sum(q(:,k));
407 mom1(:,k) = mom1(:,k) + (q(:,k)’∗cr)’;
408 mom2(:,:,k) = mom2(:,:,k)+(repmat(q(:,k),1,N).∗cr)’∗cr;
409 end
410
411 clear cr
412 end
413
414 % Central moments
415 mom1c = zeros(N,K);
416 mom2c = zeros(N,N,K);
417 for z=1:length(z0),
418 if ¬buf(z).nm, continue; end
419 q = likelihoods(buf(z).f,buf(z).bf,mg,mn,vr);
C.4 Modified Code (version 2) 163
530
531 if subit>1 || iter>1,
532 spm_chi2_plot(’Set’,ll);
533 end
534 if ll−oll<tol1∗nm,
535 % Improvement is small, so go to next step
536 break;
537 end
538 end
166 SPM
Appendix D
This chapter includes the results of the segmentation for the original method
and modified versions with more details.
First, it is included the evolution of the mixture parameter values at each
iteration in the segmentation of the T1 and T2 MRI scan from the subject f4395.
The used methods comprise the original method and the four versions of the
modified method.
Secondly, it is presented a representation of the clusters for the original and
the four versions of the modified method in the segmentation of the MR scan
from the subject f4395. It must be highlighted that due to the strong bias field
correction, the intensity values are much different.
The third section presents 3 tables with the Dice scores and likelihood values
of the original and modified methods in the segmentation of BrainWeb phan-
toms with several noise levels. In addition, it is included the results for several
probability processing methods, i.e. majority voting and threshold, where the
extracranial class is a compendium of ST, bone and BG.
The fourth section presents and overlapped representation of the confusion
matrix elements for each voxel in the segmentation of the BrainWeb phantoms
by original and v.3 modified method.
Finally, the fourth section presents the effect of the atrophy in the volumes
of several brain tissues.
D.1 Mixture parameters at each iteration for f4395.
168
Figure D.1: Mixture Coefficient through iterations. Results for the segmentation of the T1 and T2 MRI scan from the
subject f4395. The red line corresponds to the original method. The blue color correspond to the modified versions with
slow value propagation, while the ’fast’ propagation versions are in black. The solid lines correspond to the versions with
original starting equations, while the dotted ones are associated to the versions that apply modified equations also for the
parameter initialization. The first 15-20 first iterations are removed as they correspond to the initialization.
Results & Validation
D.1 Mixture parameters at each iteration for f4395.
Figure D.2: T1 Mean Value through iterations. Results for the segmentation of the T1 and T2 MRI scan from the subject
f4395. The red line corresponds to the original method. The blue color correspond to the modified versions with slow
value propagation, while the ’fast’ propagation versions are in black. The solid lines correspond to the versions with
original starting equations, while the dotted ones are associated to the versions that apply modified equations also for the
parameter initialization. The first 15-20 first iterations are removed as they correspond to the initialization.
169
170
Figure D.3: T2 Mean Value through iterations. Results for the segmentation of the T1 and T2 MRI scan from the subject
f4395. The red line corresponds to the original method. The blue color correspond to the modified versions with slow
value propagation, while the ’fast’ propagation versions are in black. The solid lines correspond to the versions with
original starting equations, while the dotted ones are associated to the versions that apply modified equations also for the
parameter initialization. The first 15-20 first iterations are removed as they correspond to the initialization.
Results & Validation
D.1 Mixture parameters at each iteration for f4395.
Figure D.4: T1 Variance Value through iterations. Results for the segmentation of the T1 and T2 MRI scan from the
subject f4395. The red line corresponds to the original method. The blue color correspond to the modified versions with
slow value propagation, while the ’fast’ propagation versions are in black. The solid lines correspond to the versions with
original starting equations, while the dotted ones are associated to the versions that apply modified equations also for the
parameter initialization. The first 15-20 first iterations are removed as they correspond to the initialization.
171
172
Figure D.5: T2 Variance Value through iterations. Results for the segmentation of the T1 and T2 MRI scan from the
subject f4395. The red line corresponds to the original method. The blue color correspond to the modified versions with
slow value propagation, while the ’fast’ propagation versions are in black. The solid lines correspond to the versions with
original starting equations, while the dotted ones are associated to the versions that apply modified equations also for the
parameter initialization. The first 15-20 first iterations are removed as they correspond to the initialization.
Results & Validation
D.1 Mixture parameters at each iteration for f4395.
Figure D.6: T1-T2 Covariance Value through iterations. Results for the segmentation of the T1 and T2 MRI scan from
the subject f4395. The red line corresponds to the original method. The blue color correspond to the modified versions
with slow value propagation, while the ’fast’ propagation versions are in black. The solid lines correspond to the versions
with original starting equations, while the dotted ones are associated to the versions that apply modified equations also
for the parameter initialization. The first 15-20 first iterations are removed as they correspond to the initialization.
173
174 Results & Validation
Figure D.7: Representation of the clusters for all the tissue classes done bu
the version 1 of the modified method. The lines correspond to the contour
of the Gaussian cut at FWHM, and weighted by the mixing coefficient. The
contours of the clusters done by the original method are presented with dotted
lines, the centers with the symbol *, and the text labels in red. The version 1
of the modified method presents the contours with solid lines, the center with
the symbol +, and the text labels in blue. The depicted tissues comprise GM
(black), WM (blue), CSF (green), ST (red), bone (yellow), and BG (magenta).
D.2 Representation of the clusters for all the tissue classes. 175
Figure D.8: Representation of the clusters for all the tissue classes done bu
the version 2 of the modified method. The lines correspond to the contour
of the Gaussian cut at FWHM, and weighted by the mixing coefficient. The
contours of the clusters done by the original method are presented with dotted
lines, the centers with the symbol *, and the text labels in red. The version 2
of the modified method presents the contours with solid lines, the center with
the symbol +, and the text labels in blue. The depicted tissues comprise GM
(black), WM (blue), CSF (green), ST (red), bone (yellow), and BG (magenta).
176 Results & Validation
Figure D.9: Representation of the clusters for all the tissue classes done bu
the version 3 of the modified method. The lines correspond to the contour
of the Gaussian cut at FWHM, and weighted by the mixing coefficient. The
contours of the clusters done by the original method are presented with dotted
lines, the centers with the symbol *, and the text labels in red. The version 3
of the modified method presents the contours with solid lines, the center with
the symbol +, and the text labels in blue. The depicted tissues comprise GM
(black), WM (blue), CSF (green), ST (red), bone (yellow), and BG (magenta).
D.2 Representation of the clusters for all the tissue classes. 177
Figure D.10: Representation of the clusters for all the tissue classes done bu
the version 4 of the modified method. The lines correspond to the contour
of the Gaussian cut at FWHM, and weighted by the mixing coefficient. The
contours of the clusters done by the original method are presented with dotted
lines, the centers with the symbol *, and the text labels in red. The version 4
of the modified method presents the contours with solid lines, the center with
the symbol +, and the text labels in blue. The depicted tissues comprise GM
(black), WM (blue), CSF (green), ST (red), bone (yellow), and BG (magenta).
D.3 Dice coefficient for BrainWeb phantoms.
178
Table D.1: Result of the validation in terms of the Dice coefficient and the log-likelihood value. Six different methods
are used for the segmentation of a BrainWeb phantom with noise=0%, RF=20% and 1mm isotropic resolution. The
processing of the tissue probability maps have been done with Majority Voting and with several thresholds.
Table D.3: Result of the validation in terms of the Dice coefficient and the log-likelihood value. Six different methods
are used for the segmentation of a BrainWeb phantom with noise=9%, RF=20% and 1mm isotropic resolution. The
processing of the tissue probability maps have been done with Majority Voting and with several thresholds.
D.5 Atrophy.
The brain functions decline after certain age in different manners, as the
decrease of short-term memory, verbal ability, and intellectual performance, or
the increase of the reaction time. This lost of capacity is due to the brain
atrophy, i.e. loss of brain parenchyma and changes in the associated anatomical
structures (e.g. decreased efficiency of neurotrasmitters in survival neurons).
Taking into account that the variations of human neocortex volume are equally
distributed among different people, it is possible to study the pattern of changes
on average.
In the ageing process, it is detected a large decrease of cortex volume that
goes together with a large decrease of the pial surface (external boundary of the
cortex) and a small decrease of the neocortical thickness. This process contrasts
with the known effects in the brain of some common diseases, like Acquired
Immune Deficiency Syndrome (AIDS) or Alzheimer Disease (AD), where the
neocortical thickness is the most affected [65] [77]. Thus, it can be isolated the
age-related changes in the brain from diseases that affect the brain.
B. Pakkenberg et al. [62] did a study with 94 human brains from Danish
dead people between 20 years and 90 years old. The study showed that the brain
variation was mostly determined by the gender and age. Specifically for the age,
taking into account the overall life span, it was observed a 12.3% decrease of
cortex volume, 28% of white matter, but not significant variations were found
in neocortical thickness or gray matter volume. In addition, the volume losses
appeared together with an increase of CSF.
Another study of the brain atrophy was done by T. L. Jernigan et al. [33]
with MRI from healthy volunteers aged from 30 to 99 years. The results showed
that the hippocampus losses were significant, and the frontal lobes were affected
by a decrease of cortical volume and an increase of white matter abnormalities.
In addition, the decrease of white matter over the life range in the cerebral and
cerebellar structures was bigger that the gray matter, with 14% in the cerebral
cortex, 35% in the hippocampus, and 26% in the cerebral white matter.
The Figure D.15 depicts the results of this last study as the correlation
between volume and age for different tissues. Each subfigure presents a different
tissue: cerebral cortex, and cerebral white matter. It can be seen a big brain loss
around the 55 years old. The graph shows a scarce number of samples around
the mentioned age because it is usually hard to include an important number
of volunteers in this range of years. This problem is also concerning the CIMBI
projects, where the volunteers in range around 40 years old is limited.
186 Results & Validation
Figure D.15: Estimated volumes related to the age. The filled line corresponds
to the smooth trend and the dashed lines to the variability. Three subjects of
32, 80 and 81 years are highlighted. [Courtesy of B. Pakkenberg et al. [62]]
D.5 Atrophy. 187
Table D.4: Atrophy of the brain related to the ageing, as a measure of the ICC
volume variation of different tissues. Mean value and deviation are presented.
[Data from C. R. G. Guttmann [29]]
The results of the study are presented in the Table D.4. It can be seen
how GM volume slightly decreases and the WM suffers an important decrease.
However, there is a in increase of GM after the 50-years that is not expected.
Although, it is not explained in the article, sometimes the increase of GM in old
patients is due to the missclassification of lesions as GM.
Figure D.16: Linear regression analysis of the volume age profile of six sub-
jects. Six brains from the CIMBI database have been segmented by the original
method into GM, WM and CSF.
D.5 Atrophy. 189
Figure D.17: Linear regression analysis of the volume age profile of six subjects.
Six brains from the CIMBI database have been segmented by the modified v.3
method into GM, WM and CSF.
190 Results & Validation
Appendix E
Volumes
This chapter presents different brain volumes for several slices in the three
planes (coronal, sagittal, transversal).
Figure E.3: Tissue Probability Map for Prior Templates - Grey Matter.
Volumes
E.2 Tissue Probability Maps for Prior Templates
Figure E.4: Tissue Probability Map for Prior Templates - White Matter.
195
196
Figure E.5: Tissue Probability Map for Prior Templates - CerebroSpinal Fluid.
Volumes
E.2 Tissue Probability Maps for Prior Templates
Figure E.7: Tissue Probability Map for Prior Templates - Soft Tissue.
Volumes
E.2 Tissue Probability Maps for Prior Templates
Figure E.9: Template Tissue Probability Maps - GM/WM/CSF overlap. GM, WM and CSF are presented in red, green
and blue, respectively.
Volumes
E.2 Tissue Probability Maps for Prior Templates
Figure E.10: Template Tissue Probability Maps - Bone/ST/BG overlap. ST, Bone and BG are presented in red, green
and blue, respectively.
201
E.3 Segmentation of volumes from subject f4395.
202
Figure E.17: Segmentation of volumes from subject f4395 - GM/WM/CSF overlap. GM, WM and CSF are presented in
red, green and blue respectively.
Volumes
E.3 Segmentation of volumes from subject f4395.
Figure E.18: Segmentation of volumes from subject f4395 - ST/Bone/BG overlap. ST, Bone and BG are presented in
red, green and blue, respectively.
209
210 Volumes
Appendix F
Matlab code
This chapter includes the Matlab code of several functions that have been
used to depicts volumes generated by SPM segmentation.
• classify voxels(): Function that coverts a probability map into a binary
map. It applies majority voting or thresholding on the tissue volumes.
• plot volume(): Scrip that plots several slices of one volume in the three
planes (coronal, sagittal and transverse).
• plot volume overlap(): Script that presents the overlap of 2 or three vol-
umes for several planes.
• GenerateRGB(): Function that combines three images into one RGB im-
age with different levels of scaling.
212 Matlab code
classify voxels()
plot volume()
1 function plot_volume(vol,num_slices,opt)
2 % Script that plots slices of the three planes of the brain volume
3 % vol: 3D matrix of the brain intensity values of each voxel
4 % num_slices: total (odd) number of plotted slices per plane
5 % opt: plot option, opt=0 uses imagesc(), opt=1 uses image()
6 %
7 % Author: Angel Diego Cuñado Alonso (diegoalonso@ieee.org)
8 % Technical University of Denmark, DTU (2011)
9 %
10
11 % Default options
12 if nargin < 2, num_slices = 5; end
13 if nargin < 3, opt = 0; end
14
15 figure
16 colormap(gray)
17
18 % Estimate slices to represent (odd number)
19 if mod(num_slices+1,2), num_slices = num_slices+1; end
20 half_slice = round(size(vol)/2)’;
21 step_slice = floor(half_slice/(((num_slices−1)/2)+1));
22 slice = zeros(3,num_slices);
23 slice(:,(num_slices+1)/2) = half_slice;
24 for i=1:(num_slices−1)/2
25 slice(:,((num_slices+1)/2)−i) = half_slice−i∗step_slice;
26 slice(:,((num_slices+1)/2)+i) = half_slice+i∗step_slice;
27 end
28
29 % Coronal
30 for i=1:num_slices
31 subplot(3,num_slices,i)
32 plane=fliplr(rot90(reshape(vol(:,slice(2,i),:),size(vol,1),
size(vol,3))));
33 if opt, image(plane); else imagesc(plane); end
34 title([’Coronal (’,num2str(slice(2,i)),’)’]);
35 axis image; set(gca,’XTick’,[],’YTick’,[]);
36 end
37
38 % Sagittal
39 for i=1:num_slices
40 subplot(3,num_slices,i+num_slices)
41 plane = fliplr(rot90(reshape(vol(slice(1,i),:,:),size(vol,2),
size(vol,3))));
42 if opt, image(plane); else imagesc(plane); end
43 title([’Sagittal (’,num2str(slice(1,i)),’)’]);
44 axis image; set(gca,’XTick’,[],’YTick’,[]);
45 end
46
47 % Transverse
48 for i=1:num_slices
49 subplot(3,num_slices,i+2∗num_slices)
215
50 plane = rot90(reshape(vol(:,:,slice(3,i)),size(vol,1),size(vol
,2)));
51 if opt, image(plane); else imagesc(plane); end
52 title([’Transverse (’,num2str(slice(3,i)),’)’]);
53 axis image; set(gca,’XTick’,[],’YTick’,[]);
54 end
55
56 % Maximize figure window
57 set(gcf, ’Position’, get(0,’Screensize’));
58
59 end
1 function plot_volume_overlap(vols,num_slices,opt)
2 % Script that plots several slices of the three planes of the
3 % overlaped brain volume
4 % vols: cell of 3D matrices of brain intensity values, with
5 % maximum 3 co−registered volumes with the same dimensions
6 % num_slices: total (odd) number of plotted slices per plane
7 % opt: plot option, opt=0 uses imagesc(), opt=1 uses image()
8 %
9 % example: plot_volume_overlap({vol1, vol2, vol3},[100,90,100])
10 %
11 % Author: Angel Diego Cuñado Alonso (diegoalonso@ieee.org)
12 % Technical University of Denmark, DTU (2011)
13 %
14
15 % Different number of input volumes
16 switch numel(vols),
17 case 1,
18 Nvol = 1;
19 dim = size(vols{1});
20 vols = {vols{1},zeros(dim,’uint16’),zeros(dim,’uint16’)};
21 case 2,
22 Nvol = 2;
23 dim = size(vols{1});
24 vols = {vols{1},vols{2},zeros(dim,’uint16’)};
25 case 3,
26 Nvol = 3;
27 dim = size(vols{1});
28 otherwise,
29 Nvol = 1;
30 dim = size(vols);
31 vols = {vols,zeros(dim,’uint16’),zeros(dim,’uint16’)};
32 end
33
34 % Default options
35 if nargin < 2, num_slices = 5; end
36 if nargin < 3, opt = 0; end
37
216 Matlab code
GenerateRGB()