35
JongHoon Lee 1 ECE 738 PROJECT REPORT Simultaneous Simultaneous Brain segmentation and Brain segmentation and Phase unwrapping Phase unwrapping in in f f MR MR I I data data JongHoon Lee 5.13.2003

Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

JongHoon Lee5.11.2003

1

ECE 738 PROJECT REPORT

SimultaneousSimultaneousBrain segmentation and Brain segmentation and Phase unwrappingPhase unwrapping in in ffMRMRI dataI data

JongHoon Lee5.13.2003

University of WisconsinDepartment of Computer and Electrical

Page 2: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

Outlines

- Overview of MRI

- Overview of General problem and significance

- Definition of Specific problems

A. Brain Area Segmentation

B. Phase Unwrapping

- Goal and Approach

- Approach details and results

A. Pole field generation

B. Pole field modification: Noise-pole field generation

C. Seed growing: merging and unwrapping

D. Post-Processing and Segmentation data

E. Application of fieldmap for Geometric distortion of fast MRI images

F. Implementation

- Conclusion and future work

Review of general problem

Review of my motivation

Review of my goal and contribution

Future works

2

Page 3: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

Overview of MRI

Magnetic Resonance Imaging (MRI) is one of the most popular imaging techniques in the

modern clinical field. MRI provides detailed images of living tissues, and is used for both

human body and brain studies. Data obtained from MR images is used for detecting

tissue deformities such as cancers and injuries [1]. MRI is also used extensively in studies

of brain pathology and functional connectivity of our brain (fMRI: functional MRI).

a) b) c) d)

Figure 1. a) Distorted EPI image (128 x 128), b) Distortionless anatomical image (256 x 256), c) Corrected

EPI data using fieldmap, d) Fieldmap

Overview of General problem and significance

In order to catch temporal change of physiological signals, in fMRI, the unique (e.g. fast

and sensitive to oxygenation level of blood) type of image acquisition technique is used.

EPI (Echo Planar Imaging) has met the requirements and a large scale of studies using

EPI has been made. In contrast to its superb temporal resolution, its spatial resolution is

poor and it is also inherently sensitive to the inhomogeneity of the main/static magnetic

field. Without any object inside, magnetic field in the bore of MRI scanner is

homogeneous. A human body contains water (soft tissues), bone, fat, and air; each has

different magnetic susceptibility respectively and the susceptibility differences make the

3

Page 4: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

magnetic field inhomogeneous. Since each tissue has its own frequency (Larmor

frequency) for resonance under a magnetic field, off-resonance effects are generated from

the field homogeneities. The distortion in x and y direction by the off-resonance effect is

described by (1).

(1)

x, y : amounts of shift (misplacement) in x, y directions in mm : gyromagnetic ratio of tissue

: deviation of magnetic field from resonanceFOVx, FOVy : field of view in x, y direction in mmtx, ty : sampling interval in x, y direction ( 1/reampling rate)

As shown in (1), with deviation of magnetic field from resonance, the off-resonance

effect can be interpreted as a non-uniform sampling problem and it is actually shown as

misplacement of images pixels in spatial domain, namely geometrical distortion. In

image registration, alignment of a low-resolution functional image and a high-resolution

anatomical image, the geometrical distortion leads to incorrect registration of

corresponding regions in two different images, even after linear transformation of

distorted EPI image. Figure shows an example of the distorted EPI data and its

corresponding anatomical image acquired by using distortionless conventional method.

Note that distortion direction is dominant in horizontal direction. Deformation of overall

shape is evident and the distortion amount and pattern is different for individuals and

main field strength (usually 1 ~ 3 Tesla). New acquisition methods have been proposed to

reduce the distortion and keep the acquisition speed. However, some other issues, such as

SNR, contrast, blur effect, and etc., have to be considered with increased speed and

reduced distortion and none has met the requirements satisfactorily. Meanwhile, another

way of reducing the distortion, i.e. post-processing, has been developed even more

4

Page 5: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

vigorously. The most popular technique is called fieldmap method, which utilizes field

map data, estimated from two different images using different time parameters, for more

precise mapping of EPI data. In order to obtain fieldmap, two visually identical images

are acquired. Only difference between those images is echo time, passed time from

beginning when the intensity of the signal is at the peak, and fieldmap can be estimated in

pixel dimension (i.e. pixel shift map) from the two images by the equation:

(2)

TE1, TE2 : Echo time in image 1, 2(TE1), (TE2) : phase data of image 1, 2 TE = TE2 – TE1 : echo time difference between image 1, 2Ry : amount of pixel shift in spatial domainN : number of pixels in y direction in spatial domain

Fieldmap, or pixel shift map, leads to re-mapping of EPI image to where the pixels are

supposed to be mapped. Figure 1.c) shows undistorted (corrected) EPI of Figure 1.a) and

the fieldmap is shown in Figure 1.d).

Definition of Specific problems

There are two critical procedures to generate a fieldmap from a pair of images with

different echo times – brain segmentation and phase unwrapping.

Since, in MRI, the detected signal comes from revolving magnetization vectors, the raw

data from scanner is in frequency domain. MR images are reconstructed by taking

discrete Fourier transform (DFT) and consequently the reconstructed images are complex

images in nature, which can be decomposed into amplitude images and phase maps [2].

The phase of any complex signal represents a rotation, with direction and amplitude.

5

Page 6: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

However, given any complex data, the rotation is wrapped into the range [-, +], and to

obtain a measure of the parameter of interest the missing multiples of 2 must be

replaced – a process known as phase unwrapping [3]. Since phase unwrapping in low

SNR area (Background) and boundary area (brain - nonbrain) often makes phase errors

and also non-brain area is not the region of interest (ROI), masked out (segmentation) the

nonbrain area is essential pre-processing prior to solid phase unwrapping. Herein I will

discuss those procedures in depth.

A. Brain Area Segmentation

There are broadly two categories in brain segmentation techniques. One is manual

method and the other is computer-aided or automated method.

Manual brain/non-brain segmentation methods are, as a result of the complex

information understanding involved, probably more accurate than fully automated

methods are ever likely to achieve. There are serious enough problems with manual

segmentation to prevent it from being a viable solution in most applications. The first

problem is time cost. Manual brain/non-brain segmentation typically takes between 15

min and 2 hr per 3D volume. The second is the requirement for sufficient training, and

care during segmentation, that subjectivity is reduced to an acceptable level [4].

Automated algorithms combine image-processing techniques such as

thresholding, clustering, region growing, edge detection, morphological operations,

surface modeling and etc. The key to any automatic method is that it must be robust, so

that it produces reliable results on every image acquired from any MR scanner using

different imaging parameters. There are some typically proposed automatic brain

6

Page 7: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

extraction methods. Among them, there are seed growing algorithm-based method,

histogram-based method, anisotropic filter and “snakes” contouring technique-based

method, morphology-based method, and deformable surface modeling method. Each

technique has its own strength and weakness and none has been proved to be the best

method yet because applications of segmented mask data are varied and often some areas

are not discernable even by clinical researchers. In other words, there is not an absolute

criterion for the best segmentation result. In addition, all the segmentation techniques are

intensity based such that their application to phase maps may cause some erroneous

results: noisy jumps may be included in smooth phase map. This is because, at the

boundary of brain and nonbrain area, phase varies rapidly so that real phase difference

between two pixels becomes bigger than 2 and even up-to-date unwrapping method may

be fooled by the jumps. In the end, the phase jumps may affect unwrapped phase map and

distorted EPI unless they are not handled appropriately. Figure shows the example of

phase jump at the boundary and its result in undistorted image: the penetration of

nonbrain pixel into the brain or escaping of brain pixel from brain.

7

a) b)

Page 8: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

Figure 2. In clockwise, a) Distorted EPI, b) Undistorted EPI using fieldmap without phase jumps, c)

Fieldmap, d) Undistorted EPI using fieldmap with phase jumps

B. Phase Unwrapping

As discussed earlier, the phase can only be derived as modulo 2 which gives a scalar

value (known as the principal value) contained in a given range, usually [- +] and the

true phase rotation cannot be known unambiguously from a single scalar value. For

example, rotation of /2 and -3/2 are indistinguishable since -3/2 falls outside the

unambiguous range [- +] and is hence wrapped around to give a principle value of /2.

Figure a) shows the true phase variation and Figure b) is wrapped phase of Figure a). In

Figure b), from left to right, we can identify that the change from to - at A and B

indicates that phase wrapping has occurred in the negative direction, and to unwrap we

need to add 2 to subsequent values. Conversely, after C and D we need to subtract -2

from subsequent values. When certain level of noise is presented in the phase map as

shown in Figure c), conventional 1D phase unwrapping method is fooled by the noise

such that all the subsequent values are not unwrapped correctly (Figure d). As witnessed,

in principle phase unwrapping is simple but in practice it is rather more difficult to

implement. The problem is that it is highly sensitive to errors and noise in regions with

8

c) d)

Page 9: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

low signal-to-noise ratio and the boundaries where real phase difference is bigger than

2.

Figure 3. a) True phase variation, b) wrapped phase into [- ] range, c) wrapped phase with noise at one of

the phase jumps, d) incorrectly unwrapped phase because of noise

In figure a) arrows indicate the phase jumps at the boundary between brain and nonbrain

area and the incorrect unwrapping of phase map of brain image from conventional 1D

unwrapping method is Figure b).

a) b)

Figure 4. a) Phase map before unwrapping with jumps at the boundary, b) Incorrectly unwrapped phase

map from a)

9

Page 10: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

Since the limitation of conventional unwrapping method is very obvious and other

sophisticated method have been developed by many researchers for the applications of

medical imaging, or Synthetic Aperture Radar(SAR) imaging [5]. In medical imaging

application, specifically, it is important to have a method which takes into account the 3D

nature of phase maps. A 2D method may be applied on a slice-by-slice basis, but can

result in phase wraps existing in the slice plane direction and omission of islands in a

slice image when seed growing method is used. The former must be fixed by some other

post-processing option and multiple seed or 3D seed growing can correct the latter. The

number of pixels inside of 3D volume image is much bigger than typical 2D images such

that the processing speed is relatively slow and a memory problem may occur with a

certain type of computational implementation. Existing unwrapping techniques for

medical imaging are based on various approaches including region growing, cost function

optimization, neighborhood voting and phase path integration [5]. In my project, 3D seed

growing unwrapping guided by noise-pole map is implemented and tested to find smooth

varying phase map, finally which is used for brain segmentation.

Goal and Approach

Specific and critical problem in segmentation and unwrapping of brain MRI data and

significance of developing an appropriate procedure are just addressed. My goal of this

project is to segment brain area by exploiting the fact that the variation of phase in brain

area is relatively gradual over the whole brain area because human brain itself is a soft

10

Page 11: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

tissue and its main composition is water: in brief, the simultaneous phase unwrapping and

segmentation of brain area.

3D seed growing unwrapping method guided pole field map is implemented and it

merges adjacent pixels with values within difference from the seed pixel or unwraps

adjacent pixels into their true values. In the end, 3D unwrapped phase map is constructed

and the segmented mask data is obtained simultaneously. In [3], Cusack explained how

pole field map is derived and as shown in Figure in smooth varying phase map the sum of

a loop in the map must be zero in noise-free map. However, also seen in Figure b), if the

sum around the loop is non-zero, then at least one of the sums around the 2x2 pixel

rectangle must be nonzero. After screening all regions of a phase map with a square (2x2)

loop, we can obtain pole field map and by the guidance of this map seed grows to unwrap

the phase starting from low noise area to high noise area such that phase jumps have less

chance to affect subsequent pixels. The seed growing stops at the final threshold and after

some simple post-processing segmentation data is acquired from unwrapped phase map.

Here some details of each step are described.

Approach details and results

A. Pole field generation

a) b)

11

AAA’A’

AAA’A’

Page 12: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

Figure 5. a) A=A’: Noise free loop, b) AA’: Pole at noise

Given a phase map (Figure a)), a small loop with size 2x2 pixels move around the image

from top-left to bottom-right in zigzag way and if pole (non-zero sum of the loop) is

found pole value, let’s say it is one, is marked at the pole field map (P). Complete pole

field (P) contains only ones for poles and zeros elsewhere (Figure b)).

a) b)

Figure 6. a) Brain phase map, b) Corresponding pole filed

B. Pole field modification: Noise-pole field generation

The pole filed map created in step A (Figure b)) doesn’t show distinctive boundary

between brain and nonbrain areas and, therefore, it needs a mask data which masks out

nonbrain parts (air, fat, bone, and etc.), by which we can reduces computation time and

set the boundary of unwrapping procedure. As explained in brain segmentation section,

extraction of the mask data itself is another computationally expensive procedure and this

increases the complexity of the whole system.

Here I tried different way instead of using the mask data from fancy algorithms in order

to reduce overall computational complexity and time. An initial coarse mask data is

generated by thresholding and added to pole filed. The threshold is decided by analyzing

image histogram and using the formula: th = 0.75 * t02 + 0.25 * t98 , where t98 is the

12

Page 13: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

intensity below which lies 2% of the cumulative histogram. As shown in Figure c), the

modified pole field has sharper boundary and less ‘bridges’ because pole field and mask

data compensate their shortcoming each other. Now I call the modified pole field as

‘noise-pole filed’ because in noise-pole pixels have more weight than only noise or pole

presented pixels and which information can guide unwrapping more precisely.

a) b)

Figure 7. a) Initial mask data (thresholded intensity image), b) modified pole filed: noise-pole filed

C. Seed growing: merging and unwrapping

Gaussian filter (FWHM = 4 mm) is applied to smoothen the NP map repeatedly so that

the values vary gradually from a lowest point at noise free areas to higher points at noise-

pole areas (Figure ). Therefore we can set the lowest point as a seed and let it grow in

when certain requirements are met within the brain. This is called flood-fill procedure.

Figure 8. Profile plot of dotted line in Figure b)

When a seed grows, unwrapping and merging new pixels happens according to certain

criteria. The minimum and maximum NP field values are set. First, the 26 nearest

neighbor pixels are all checked for their NP field and any between the current high and

low thresholds are unwrapped, and this stage recursively repeated on each pixels. When

this is done, the threshold is increased by a single step and any further unwrapped pixels.

13

Page 14: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

This procedure was repeated until all of the steps had been done and all pixels with NP

values under the last high threshold are unwrapped. In this procedure, there are two

parameters to be chosen carefully. One is optimum smoothing kernel and the other is

optimum value of step increasing value, in other words the number of iteration. While

finer step sizes require more computational cost, we have a less chance to have phase

jumps in unwrapped fieldmap, and while larger kernels enable us to use finer steps, it

removes the details of boundary at the same time. Some unwrapped images in each stage

with different threshold are shown in Figure .

a) b) c) d) e) f)

Figure 9. a) Noise-pole map, b) ~ e) Unwrapped and merged fieldmap from different stages, f) Fully

unwrapped fieldmap

D. Post-Processing and Segmentation data

When all iteration and all pixels within the highest threshold are unwrapped and merged,

there still are some chances to have phase jumps either because of true change or noise as

shown in Figure. These jumps make a same error in corrected EPI images shown in

Figure 2, and can be easily canceled by 2-dimensional median filter. Since median filter

is especially robust to salt and pepper type noise, sudden jumps in smooth varying phase

14

Page 15: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

map are killed (Figure a) and its effect on the other parts, gradually changing areas, are

negligible (Figure b)).

a) b)

Figure 10. a) After all iteration with some erroneous phase jumps, b) After applying 2D median filter to a)

E. Application of fieldmap for Geometric distortion of fast MRI images

In Figure gray scale bar indicates how far a pixel with a certain value is shifted from its

original location. For example, one pixel in the brain area with a corresponding fieldmap

value 3 must move 3 pixels to downward and a pixel with a minus fieldmap value must

go upward. This procedure is called pixel shifting and after all pixels inside of brain are

shifted, overall shape of brain becomes closer to its distortionless high-resolution image.

Figure shows an example of geometrical distortion correction in EPI using fieldmap data

and this correction tends to cause better result in image registration stage, where low

resolution functional images and high resolution anatomical images are aligned in a plane

to map same part of brain.

a) b) c) d)

Figure 11. Example of distortion correction and corrected mapping after the correction, a) Distorted EPI

image (64x64 pixels) and markers, b) Anatomical image(256x256 pixels) and markers at the same position

as a), c) Corrected EPI image (64x64 pixels) and markers, d) Anatomical image(256x256 pixels) and

markers at the same position as c)

15

Page 16: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

F. Implementation

All procedures are implemented using Matlab because of its strong visualization features

and facility of handling 3D matrix data. However memory manipulation in Matlab is

somewhat poor so that recursive seed growing algorithm makes ‘Out of Memory’ error

often. This problem is solved by repeating for-loops in the recursive function to reduce

the number of function call, the major reason generating memory error. As shown in

Figure 12 a GUI(Graphic User Interface) program is built for user friendly interface.

Firstly, two original MRI data file with different TE times are loaded to generate a

fieldmap. By adjusting threshold value for initial mask data and some other parameters,

wrapped phase map becomes unwrapped and merged, and finally a fieldmap is generated

and saved. The saved fieldmap is loaded anytime and used as a reference data for pixel

shifting procedure, or distortion correction.

16

Page 17: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

Figure 12. EPI geometric distortion correction program package including the new unwrapping and

segmentation technique, First part generates fieldmap using new method, second part corrects distorted

images using the fieldmap, and third part is to reconstruct distortionless high resolution images for

comparison.

Conclusion and future work

Overall procedure of the fieldmap correction is presented in Figure 13.

17

Page 18: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

Figure 13. a), b) Original wrapped phase maps from MRI scanner, c) Distortionless high resolution

intensity image, d) Distorted low resolution image using EPI, e) masking data from brain segmentation, f),

g) Phase maps after nonbrain parts are masked out, h), i) Unwrapped phase maps, j) Fieldmap calculated by

(2), k) Final corrected EPI image by pixel-shifting guided by the fieldmap

Review of general problem

The ultimate goal of all the processes is generating final less distorted EPI images for

better image registration results such that we have a better chance to have better

alignment between high resolution reference images and low resolution functional images

and eventually for the analysis stage we have more statistical power about our results.

Higher statistical power, of course, increases the reliability of the results and so the

contribution of this correction is significant. However the whole process is a bit complex

and the each stages has its own problems.

18

Page 19: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

Review of my motivation

My motivation of this project came out from the general problems. If we can reduce the

complexity of the whole system, we would have less chance to have erroneous results

from each stage and consequently which can reduce whole processing time significantly.

Finally with simpler and more robust system, it becomes easier developing a user-

friendly correction program for everyone.

Review of my goal and contribution

The purpose of this project is developing a method which binds the brain-segmentation

and phase unwrapping together and those procedures are done simultaneously. By that

we can reduce the complexity of overall process by about 30 % and the time by about

half for segmentation and unwrapping procedures, which also takes about 30% of all

processing time.

Future works

The new method, current method, is somewhat slow (20 min. for 30 iterations with

64x64x30 pixel volume) and optimum parameters in each stage are not so easy to obtain.

In the future, parameter optimizing should be solved and so human intervention level

may be decreased. Also, the new method is phase information and intensity information

combined algorithm, and this is a little different from my first intention that is phase

information only segmentation. This is possible research area when intensity image

doesn’t give enough edge information. However, ultimately, the new fast MRI

acquisition method, which makes less geometric distortion, will get rid of our need for

segmentation and unwrapping procedures but until that time newer methods for those two

main procedures will be the core part of research.

19

Page 20: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

Matlab Code

% Uwrap_3D.m% 4/11/03 by JongHoon Lee% new phase unwrapping algorithm in 3D

clear allglobal V NM2 F FM c g fin_th up_th szset(0,'RecursionLimit',1000000)

% Load dataload('Y:\core\025\FM\phase.mat');

%|||||||||||||||||||||||||||||||||||||||% PART 1 - Noise-pole field making%|||||||||||||||||||||||||||||||||||||||

plane = 2; % plane: Image Orientation -{ Saggital - 4} { Axial - 2 } { Coronal - 8 }mat = length(image);

vol =1:39 ;vo = length(vol);

NM = zeros(mat,mat,vo); for z = vol; xy_plane = image(:,:,z); maxx = max(max(xy_plane)); th = maxx*0.98*0.25 +maxx*0.02*0.75; mask = xy_plane>th;

% Finding poles in phase map for y = 11:mat-10; for x = 11:mat-10; Kn = ([ WF(y-1,x-1,z) WF(y-1,x,z) WF(y-1,x+1,z) WF(y,x-1,z) WF(y,x,z) WF(y,x+1,z)… WF(y+1,x-1,z) WF(y+1,x,z) WF(y+1,x+1,z) ]); K = ( [ Kn(1) Kn(2) Kn(5) Kn(4) Kn(1) ] ); NK = unwrap(K); if NK(1) ~= NK(5) NM(y,x,z) = 1; end end end NM(:,:,z) = 1.2*(1- mask) + 0.8*NM(:,:,z); end NM = reshape(NM,[mat,mat,1,vo]); plane = 2; % plane: Image Orientation -{ Saggital - 4} { Axial - 2 } { Coronal - 8 }mat = size(field,1);%|||||||||||||||||||||||||||||||||||||||

%|||||||||||||||||||||||||||||||||||||||% PART 2 - Unwrapping

20

Page 21: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

%|||||||||||||||||||||||||||||||||||||||

vol =1:30;vo = length(vol); sz =vo;

th0 = 0.0; th =0.08; up_th = 0.01; fin_th = .25; c = 0; g =0;

%Set up the volume data NM2 F V FMNM2 = reshape(NM(:,:,vol),[mat mat 1 vo]);NM2 = round(100*NM2)/100;H = fspecial('gaussian',3);

for z = 1:vo; xy_plane = NM2(:,:,1,z); NM2(:,:,1,z) = imfilter(imfilter(xy_plane,H),H); NM2(:,:,1,z) = imfilter(NM2(:,:,1,z),H);end

minn = min(min(NM2(:,:,1,zzz)));[cy,cx,cz] = find(NM2(:,:,1,zzz) == minn);yyy = round(mean(cy))

xxx = round(mean(cx))

F = reshape(field(:,:,vol),[mat mat 1 vo]);V = (zeros(mat,mat,1,vo)); V(yyy,xxx,1,zzz) = 1;FM = zeros(mat,mat,1,vo); FM(yyy,xxx,1,zzz) = F(yyy,xxx,1,zzz);

% Unwrapping in 3D Volumeunw(xxx,yyy,zzz,th); % This is the actual 3D seed growing unwrapping program (Code is provided below)fieldmap(:,:,1,1:vo) = FM;%-----------------------------------

% Threshold Upgrading and merging higher level partwhile th + up_th <= fin_th th = th + up_th

for iz =1:vo;

for iy = 5:mat-5 for ix = 5:mat-5 if V(iy,ix,1,iz) == 1 & V(iy,ix+1,1,iz) == 0; unw(ix,iy,iz,th); end end for ix = 5:mat-5 if V(iy,ix,1,iz) == 1 & V(iy,ix-1,1,iz) == 0; unw(ix,iy,iz,th); end end end for ix = 5:mat-5 for iy = 5:mat-5 if V(iy,ix,1,iz) == 1 & V(iy+1,ix,1,iz) == 0; unw(ix,iy,iz,th); end end for iy = mat-5:-1:5 if V(iy,ix,1,iz) == 1 & V(iy-1,ix,1,iz) == 0; unw(ix,iy,iz,th); end end end endfieldmap(:,:,1,1:vo) = FM;

21

Page 22: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

end

for iz = 1:vo; fieldmap(:,:,1,iz) = (medfilt2(fieldmap(:,:,1,iz)));end %|||||||||||||||||||||||||||||||||||||||% PART 3 - Pixel shifting Correction%|||||||||||||||||||||||||||||||||||||||

image_data = (image);field_data = (fieldmap);

i = 0;for ii = 1:num_of_slice; i = i+1; if plane == 4 %sagittal image = image_data(:,:,:,ii); image = rot90(image,-1); field = -1.*rot90(field_data(:,:,:,ii),-1); elseif plane == 2 %Axial image = (image_data(:,:,ii)); field = -1.*(field_data(:,:,ii)); else image = mask(:,:,:,ii).*image_data(:,:,:,ii); field = -1.*field_data(:,:,:,ii); end %--------------------------------------------------------------------------------------------------------- mat = length(field); %size of interpolated matrix

% Field map expansion field = rot90(field); for iiy = 10:1:mat-9; for iix = 10:mat-9; if field(iiy,iix) ~= 0 & field(iiy,iix+1) == 0; field(iiy,iix+1) = field(iiy,iix); end end for iix = mat-9:-1:10; if field(iiy,iix) ~= 0 & field(iiy,iix-1) == 0; field(iiy,iix-1) = field(iiy,iix); end end end for iix = 10:1:mat-9; for iiy = 10:mat-9; if field(iiy,iix) ~= 0 & field(iiy+1,iix) == 0; field(iiy+1,iix) = field(iiy,iix); end end for iiy = mat-9:-1:10; if field(iiy,iix) ~= 0 & field(iiy-1,iix) == 0; field(iiy-1,iix) = field(iiy,iix); end end end

22

Page 23: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

field = rot90(field,-1); % Field map Smoothing - Results seem better with smoothing H = fspecial('gaussian'); field = imfilter(field,H); c_image = zeros(mat,mat);

% Actual Correction part for ix = 15:mat-14; fimage = zeros(mat,1); for iy = 15:mat-14; if field(iy,ix) ~= 0; ff = floor(field(iy,ix)); if ff < 0 & iy + ff -1 > 0; fimage(iy) = image( (iy + ff), ix ) * ( ( field(iy,ix) - ff ) )... + image( (iy + ff - 1), ix ) * ( 1- ( field(iy,ix) - ff )); elseif ff>=0 & iy +ff + 1> 0; fimage(iy) = image( (iy + ff), ix ) * ( 1 - ( field(iy,ix) - ff ) )... + image( (iy + ff + 1), ix ) * ( field(iy,ix) - ff ); end end end c_image(:,ix) = fimage; end if plane == 4 [corrected(:,:,1,ii)] = rot90(image); elseif plane == 2 [corrected(:,:,1,i)] = (c_image); uncorrected(:,:,1,i) = image; else [corrected(:,:,1,ii)] = (image); end end

figure,subplot(1,1,1)montage(uncorrected,[])figure,subplot(1,1,1)montage(corrected,[])

filename = 'Y:\bgmri\bgmri005.02.11.03\anatomicals\field_distorted.mat';save(filename,'field')

The Actual 3D seed growing unwrapping function

function unw(xx,yy,zz,th)global V NM2 F FM c g sz fin_th up_thc = c+1;

try for z = zz - 1: zz + 1 if z * (sz - z +1) ~= 0 for y = yy -1 : yy + 1 for x = xx -1 : xx + 1 if (z-zz) + (y -yy) + (x-xx) ~= 0; if V(y,x,1,z) == 0 & NM2(y,x,1,z) < th g = g+1;

23

Page 24: Magnetic Resonance Imaging (MRI) is one of the …homepages.cae.wisc.edu/~ece738/projs03/lee.doc · Web viewMagnetic Resonance Imaging (MRI) is one of the most popular imaging techniques

V(y,x,1,z) = 1; new = unwrap([FM(yy,xx,1,zz) F(y,x,1,z)]); FM(y,x,1,z) = new(2); unw(x,y,z,th); end end end end end end catch return xx,yy,zz

lasterrend

24