Report - CAE Users

advertisement

ECE533 - Project

PROCESSING OF DIFFUSION WEIGHTED MRI Images

By

Shilpa R. Panth

Diana R. Palsetia

1

Table of Contents

Problem Statement .............................................................................................................. 5

Approach ............................................................................................................................. 6

Analysis............................................................................................................................... 7

Conclusion/Future Work ................................................................................................... 13

References ......................................................................................................................... 14

Appendix A: Erosion-Dilation Code ................................................................................ 15

Appendix B: Dilation – Erosion code ............................................................................... 18

Appendix C - ADCGUI .................................................................................................... 21

Course Project Workload Analysis Table ......................................................................... 34

2

BACKGROUND

The human respiratory system consists of the nose leading into the trachea, the trachea divide into the bronchi which enter the right and left lung respectively. The bronchi divide into the bronchioles and finally into the alveoli (Figure 1). The alveoli resemble small balloons; it is in the alveoli that the exchange of gases takes place. In diseases like emphysema the alveoli rupture causing a decrease in the amount of gas being exchanged.

This causes the person to experience difficulty in breathing.

Figure 1: The Human Respiratory System

The gold standard in measuring lung function is spirometry. This technique does not provide us with visual images of the lung. The only information we obtain from spirometry is measures of lung volume.

Introduction

Magnetic resonance imaging (MRI) is an imaging technique used primarily in medical settings to produce high quality images of the insides of the human body. Clinical MRI uses the magnetic properties of hydrogen and its interaction with both a large external magnetic field and radio waves to produce high resolution images. Hyperpolarized

Helium-3 (

3

HHe) lung MRI is a recently developed technique to visualize lung function and physiology.

The water content in the lung being very low, the lung is not an ideal candidate for proton

MRI. Figure 2 shows a proton MRI image. The signal outside the lung is higher than

3

inside since the water content in the tissue is higher. Figure 3: is the image of the lung obtained using

3

HHe.The lung parenchyma is clearly seen along with the bronchi.

Figure 2: Proton MRI image of the lung

Figure 3: lung

3 HHe image of the

3 HHe MRI technique is capable of producing high spatial resolution MR images of the lung air spaces after inhalation of laser polarized helium gas. This technique is capable of differentiating the healthy lungs from those with diseases such as chronic obstructive pulmonary disease, asthma, emphysema and cystic fibrosis. The contrast in these MR images is determined by regional spin density of the helium and reflects the gas distribution in the ventilated portion of the lung. The application of diffusion MR imaging methods to

3

HHe imaging presents the opportunity to probe the lung microstructure.

Diffusion-weighted MRI (DW-MRI) is a technique used for relating image intensities to the relative mobility of endogenous tissue water molecules. Two equal and opposite large magnetic field gradients are applied before the data is acquired. In the absence of any motion of the water molecules, the magnetic spins will be de-phased by the first gradient, and then completely re-phased by the second gradient. However, because the actual motion of the water molecules is that of a random walk, the second gradient will not completely re-phase the spins. The signal intensity will therefore be exponentially attenuated proportional to the mean diffusion length. Areas with relatively high mean diffusion length will appear dark on the MRI images relative to areas with low mean diffusion length [3]. As water protons diffuse and thus interact with the lattice and spin micro environment, their traveled path (L) along anyone direction can be described as the following:

L

2 

2

T ( ADC ) where

T is the observation time (typically 20-50 ms for most clinical scanners) and the proton displacement is expressed by an Apparent Diffusion Coefficient(ADC).

Diffusion weighted imaging is performed on the human lung to obtain the Apparent

Diffusion Coefficient (ADC) values. In the lung, diffusive movement of

3

HHe atoms is

4

restricted by bronchial and alveolar walls, to a degree, which is dependent on the dimensions of the respective airspace and the local gas composition. The use of DW-MRI allows determination and mapping of Apparent Diffusion Coefficient (ADC) of 3 HHe.

The ADC in lung parenchyma is related to alveolar size, and has consequently been found to increase with age and emphysema. Calculating the ADC values, provide knowledge of the activity of the lung. For example, if there are ruptured alveoli in a person’s lung, there is increased air space in the lung that implies an increase in ADC value. This increase in ADC value is due to the increased area available for the proton to diffuse (i.e. the proton is not confined by alveoli) an indicator of emphysema.

Problem Statement

The diffusion weighted images have high signal in the major airways (see Figure 4) biasing the ADC parameters to be calculated. The high signal intensity values vary between slices and subjects. Normally in DWI we obtain 18 or 20 images from which we calculate ADC maps. 9 or 10 ADC maps along with histograms are obtained. The whole lung ADC (including major airways) calculated shows substantially larger ADC values compared to the ADC values from the lung parenchyma. The trachea being larger in size than the alveoli contains more gas giving high signal in the MRI image.

In order to obtain the ADC mean from the lung parenchyma we need to segment out the major airways. This implies high signal from the airways skews the ADC values. We need to obtain ADC values from the lung parenchyma without the influence of the airways.

Figure 4: High Signal in Lung Airway

5

Approach

Our group applied processing technique of image segmentation such as thresholding; morphological processing such as erosion – dilation and region of interest (ROI) method such as manual selection.

PartI

First we applied a threshold to the original image based on, the maximum signal intensity specific to the slice. There is a lot of variability in the signal between slices and subjects that are dependent on the lung physiology. Then we applied erosion followed by dilation and also dilation followed by erosion on the thresholded image. The erosion/ dilation were performed using structural elements that were arrived by trial and error again they were dependent on the slice and the subject. From the two images obtained we created two binary masks. Then, we repeated the erosion/dilation step. The images obtained were multiplied with the original image. A flowchart of our approach is as shown in Figure 5.

Thresholding

Erosion/Dilation

Binary Mask

Erosion/Dilation

Multiply with Original Image

Figure 5 – Flowchart of Processing Techniques

PartII

To perform manual selection of the region, we used an MR specific image-processing tool called “MR View” to segment out the major airways. With this tool we could segment out the major airways and also perform regional segmentation. We then used the new set of images for mean and standard deviation ADC calculations.

6

Analysis

PartI: The image segmentation and morphological techniques results are as follows:

Thresholding

To remove the regions of high signal we applied a threshold to the image. The threshold value was obtained after finding the maximum signal intensity for each slice and then manually varying the threshold value to obtain the optimum result. Since the trachea divides into the bronchi and then the bronchioles, they have high signal too and it is difficult to delineate the bronchioles from the lung parenchyma. Thus thresholding did remove some part of the trachea along with parts of the lung parenchyma (see Figure 6).

Figure 6 – Thresholded Image

Erosion/Dilation

Sequence I:

The application of erosion followed by dilation is as follows:

Using a structuring element of [1 1 1] we eroded the thresholded image. We find that more high intensity regions were removed. However some lung parenchyma was also lost

(see Figure 7). To grow back the lung parenchyma region we dilated the eroded image with a structuring element (Figure 9) but we did not obtain the desired result i.e. removal of the airways without the loss of lung parenchyma (see Figure 8).

7

Figure 7: Eroded Image

Figure 8: Dilated Image

Sequence II:

0 0 0 0 0 1 0 0 0 0 0

0 0 0 0 1 1 1 0 0 0 0

0 0 0 1 1 1 1 1 0 0 0

0 0 1 1 1 1 1 1 1 0 0

0 1 1 1 1 1 1 1 1 1 0

1 1 1 1 1 1 1 1 1 1 1

0 1 1 1 1 1 1 1 1 1 0

0 0 1 1 1 1 1 1 1 0 0

0 0 0 1 1 1 1 1 0 0 0

0 0 0 0 1 1 1 0 0 0 0

0 0 0 0 0 1 0 0 0 0 0

Figure 9: Structuring Element for dilation

The application of dilation followed by erosion is as follows:

Using a structuring element of [1 1 1] we dilated the thresholded image (Figure 10). Then we eroded the image (Figure 11). In the eroded image some lung parenchyma is still lost although more of the high signal has been removed from the airway compared to sequence I. The results obtained from both the sequences were not satisfactory. Refer to

Appendix A for code of erosion followed by dilation and Appendix B for the code of dilation followed by erosion.

8

Figure 10: Dilated Image Figure 11: Eroded Image

Binary mask:

Since erosion dilation did not remove much of the trachea region, we created a binary mask from the dilated image of sequence I (Figure 12) and eroded image of sequence II

(Figure 13). The binary mask was constructed by replacing a pixel value in the image to 1 where it is greater than 0 and 0 otherwise.

Figure 12: Binary Mask obtained Figure 13: Binary Mask obtained after Erosion followed by Dilation after Dilation followed by Erosion

9

After obtaining the binary mask for the dilated image from sequence I and eroded image from sequence II we further eroded them with a structural elements as shown in Figure

14. The results then were dilated with same structural element in Figure 14. The results produced were better than erosion/dilation on the thresholded image because we had more airway taken away. However, the images shown in Figure 15 and 16 also lost some parenchyma tissue and hence cannot be used for ADC calculation. (Refer to Appendix A and B for the code).

0 0 0 1 0 0 0

0 0 1 1 1 0 0

0 1 1 1 1 1 0

1 1 1 1 1 1 1

0 1 1 1 1 1 0

0 0 1 1 1 0 0

0 0 0 1 0 0 0

Figure 14: Structural Element to erode Binary Mask

Figure 15: Final result after sequence

I and Binary Mask

Figure 16: Final result after sequence II and Binary

10

Part II

Manual:

From the above analysis we found that the techniques in PartI could not delineate the major airways without removing parts of the lung parenchyma and hence we needed to use manual selection method. This method enabled us to remove the major airways without affecting the lung parenchyma. Using the region of interest (ROI) tool we selected the large airways and set the pixel values within the selected region to zero. We performed the same operation on all the slices and saved them as a volume. Then we divided the each lobe of the lung into three regions: apical, middle and basal. For each of the regions we set the pixels outside the region to zero. Thus we had nine volumes for each subject (Right: apical, middle, basal and right whole; Left: apical, middle, basal and left whole; Whole: both the lobes). We used these volumes to calculate the mean and the standard deviation of the ADC values. We used the results obtained for further statistical analysis.

Figure 17: Manually segmented image of the central slice of the lung

Graphical User Interface (GUI)

Since there are 18 or 20 images from which we obtain 9 or 10 ADC maps, calculating the mean ADC from these images give us 9 to 10 color ADC maps with the histograms. The end user needs the results from the overall histogram for further statistical analysis. In

11

order to provide the most useful results at a single glance we created a graphical user interface (GUI).

The GUI is a convenient and user friendly interface to perform ADC mean and standard deviation calculations on lung images. The GUI provides the user with all the data required for further statistical analysis on a single screen. The user has to enter in the details of the image of interest like the subject number, the unique name and the number of images and then click on the button “calcADC and Hist”. This will give the user the required histogram with the ADC mean and standard deviation values for the whole lung.

If the user needs regional analysis, he/she has to enter the region (apical, middle or basal) along with the lobe (left or right) and then click on the “Regional Analysis button” to obtain an image of the region along with the histogram and the ADC mean and standard deviation values.

The GUI also provides a ‘clear’ button to refresh the selected GUI axis for different set of data. See Figure 18 and 19 for GUI snapshot (See code for the ADCGUI in Appendix C –

I and Notes in Appendix C - II).

Figure 18: ADCGUI

12

Figure 19: ADCGUI with left Axes cleared

Conclusion/Future Work

At the end of the project we were successfully able to solve our problem using manual selection region of interest based method. The automation problem of the design did not provide us with the desired result i.e. the elimination of the airways from lung parenchyma image. Since some of the lung parenchyma was lost in the process, the images could not be used to calculate the mean and standard deviation of ADC. The manual selection using an MRI specific tool was able to eliminate most the airways except from the bronchioles that are inside the lung parenchyma region.

The GUI built for further analysis of the image enabled user obtain faster and easy to read results as there are 18 to 20 images from which we obtain 9 to 10 ADC maps, and then calculate the mean ADC from these images providing us with 9 to 10 color ADC maps with the histograms and a combined total histogram.

13

However, our GUI takes input images of the manually segmented airways. Hence, in our future work we intend to combine the manual region of selection within the GUI followed by the analysis to have robust lung image analysis.

References

1] Basic MRI http://www.t2star.com/modules/Basic_MR.pdf

, December 2004.

2] Diffusion Weighted Imaging, http://spinwarp.ucsd.edu/NeuroWeb/Text/br-

710dwi.htm

, December 2004.

3] Principle of Diffusion Weighted Imaging http://www.irc.cchmc.org/Research_Areas/brain/Diffusion/dwiabout.htm

, December

2004.

4] MR Imaging of Diffusion of He-3 Gas in Healthy and Diseased Lungs – Saam et.al.

MRM 44: 174-179 (2000 )

5] Dynamic functional lung MRI using hyperpolarized gases

Albert, M.S.; BMES/EMBS Conference, 1999. Proceedings of the First Joint, Volume:

2, 13-16 Oct. 1999, Pages: 1327 vol.2

14

Appendix A: Erosion-Dilation Code

%%%%%%%%%%%%%%%%%%%%%%%%

%thresh.m

%%%%%%%%%%%%%%%%%%%%%%%%

%%%% Reading in the file filename = '1.2.840.113619.2.5.1762813321.1426.1002801877.982.dcm'; f = fopen(filename, 'rb', 'ieee-le'); fseek(f, -256*256*2, 1); x1d = fread(f, 256*256, 'int16'); x = reshape(x1d, [256 256]); x = shiftdim(x, 1);

%figure(1);

subplot(3,3,1);

imshow(x,[]);

title('Original Image');

%----------------------Thresholding-------------------------

%%%% Finding the max max_val = max(max(x)); disp(max_val)

x1d_sorted = sort(x1d);

top_10percent = x1d_sorted(59000);

top_percent = x1d_sorted(64900);

%%%%%%%% Finding the threshold

% zero out everything over threshold

%threshold = top_percent; threshold = 175; x_thresholded = x .* (x <= threshold);

%figure(2); subplot(3,3,2); imshow(x_thresholded,[]); title('Thresholded Image');

%----------------------------------------------------------

%---------------Erosion folowed by Dilation---------------

%Eroding the thresholded iamge

15

% Erosion

SE = strel('arbitrary',ones(1,3));

%SE = strel('diamond',1);

BW2 = imerode(x_thresholded,SE); subplot(3,3,3); imshow(BW2,[]); title('Eroded threshold');

% Dilating the Erosion

IM2 = imdilate(BW2,SE);

SE = strel('diamond',5);

%SE = strel('arbitrary',ones(3,1)); subplot(3,3,4); imshow(IM2,[]); title('Dilation of the Eroded Image');

%--------------------------------------------------------

%----------------------Binary Mask-----------------------

%Creating Binary Mask

[a,b] = size(IM2); for i = [1:a*b]

if IM2(i) > 0

IM2(i) = 1;

else

IM2(i) = 0;

end end subplot(3,3,5); imshow(IM2,[]); title('Binary Mask'); im = zeros(256,256); im = IM2;

%Erosion on Binary Mask

%SE1 = strel('arbitrary',ones(1,3));

SE = strel('diamond',3);

BW2 = imerode(im,SE);

16

subplot(3,3,6); imshow(BW2,[]); title('Erosion on the mask')

% Dilation on the eroded mask

IM2 = imdilate(BW2,SE);

SE = strel('diamond',3); subplot(3,3,7); imshow(IM2,[]); title('Dilation on the Eroded mask')

%

%---------------Multiply with Original Image----------------

% Multiplying with S0

J = x.*IM2;

% J = x.*BW2;

%J = immultiply(BW2,x);

%figure; subplot(3,3,8); imshow(J,[]); title('Multiplying with the original')

%-----------------------------------------------------------

17

Appendix B: Dilation – Erosion code

%%%%%%%%%%%%%%%%%%

%Threshset1.m

%%%%%%%%%%%%%%%%%%

% Reading in the file filename = '1.2.840.113619.2.5.1762813321.1426.1002801877.982.dcm'; f = fopen(filename, 'rb', 'ieee-le'); fseek(f, -256*256*2, 1); x1d = fread(f, 256*256, 'int16'); x = reshape(x1d, [256 256]); x = shiftdim(x, 1);

%figure(1);

subplot(3,3,1);

imshow(x,[]);

title('Original Image');

%%%------------------------------------------------------------------------

%%%%%Finding the max value max_val = max(max(x)); disp(max_val)

x1d_sorted = sort(x1d);

top_10percent = x1d_sorted(59000);

top_percent = x1d_sorted(64900);

%%%%%%%%%%%%% Thresholding

% zero out everything over threshold

%threshold = top_percent; threshold = 175; x_thresholded = x .* (x <= threshold);

%figure(2); subplot(3,3,2); imshow(x_thresholded,[]); title('Thresholded Image');

%%%------------------------------------------------------------------------

%%%%% Dilating the thresholded image with diamond structuring element

%SE = strel('diamond',1);

18

SE = strel('arbitrary',ones(1,3));

BW1 = imdilate(x_thresholded,SE); subplot(3,3,3); imshow(BW1,[]); title('Dilated Image');

%%%%% _--------------------------------------------------------------------

%%%% Eroding the dilated iamge with diamond structuring element

% Erosion

SE = strel('arbitrary',ones(3,1));

%SE = strel('diamond',1);

BW2 = imerode(BW1,SE); subplot(3,3,4); imshow(BW2,[]); title('Eroded Image');

%%%%----------------------------------------------------

%Creating Binary Mask

[a,b] = size(BW2); for i = [1:a*b]

if BW2(i) > 0

BW2(i) = 1;

else

BW2(i) = 0;

end end subplot(3,3,5); imshow(BW2,[]); title('Binary Mask') im = zeros(256,256); im = BW2;

%Erosion on Binary Mask

%SE1 = strel('arbitrary',ones(1,3));

SE = strel('diamond',3);

BW2 = imerode(im,SE); subplot(3,3,6);

19

imshow(BW2,[]); title('Eroded mask');

% Dilation on the eroded mask

IM2 = imdilate(BW2,SE);

SE = strel('diamond',3); subplot(3,3,7); imshow(IM2,[]); title('Dilate the eroded mask');

%

% Multiplying with S0

J = x.*IM2;

% J = x.*BW2;

%J = immultiply(BW2,x);

%figure; subplot(3,3,8); imshow(J,[]); title('Multiplying with S0');

20

Appendix C - ADCGUI

I) Code

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%ADCGUI.m

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function varargout = ADCGUI(varargin)

% ADCGUI M-file for ADCGUI.fig

% ADCGUI, by itself, creates a new ADCGUI or raises the existing

% singleton*.

%

% H = ADCGUI returns the handle to a new ADCGUI or the handle to

% the existing singleton*.

%

% ADCGUI('Property','Value',...) creates a new ADCGUI using the

% given property value pairs. Unrecognized properties are passed via

% varargin to ADCGUI_OpeningFcn. This calling syntax produces a

% warning when there is an existing singleton*.

%

% ADCGUI('CALLBACK') and ADCGUI('CALLBACK',hObject,...) call the

% local function named CALLBACK in ADCGUI.M with the given input

% arguments.

%

% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one

% instance to run (singleton)".

%

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help ADCGUI

% Last Modified by GUIDE v2.5 13-Dec-2004 21:29:25

% Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @ADCGUI_OpeningFcn, ...

'gui_OutputFcn', @ADCGUI_OutputFcn, ...

'gui_LayoutFcn', [], ...

'gui_Callback', []); if nargin & isstr(varargin{1})

gui_State.gui_Callback = str2func(varargin{1}); end

21

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else

gui_mainfcn(gui_State, varargin{:}); end

% End initialization code - DO NOT EDIT

% --- Executes just before ADCGUI is made visible. function ADCGUI_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn.

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% varargin unrecognized PropertyName/PropertyValue pairs from the

% command line (see VARARGIN)

% Choose default command line output for ADCGUI handles.output = hObject;

% Update handles structure guidata(hObject, handles);

% UIWAIT makes ADCGUI wait for user response (see UIRESUME)

% uiwait(handles.figure1);

%--------------------------------------------------------------------------

% --- Outputs from this function are returned to the command line. function varargout = ADCGUI_OutputFcn(hObject, eventdata, handles)

% varargout cell array for returning output args (see VARARGOUT);

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure varargout{1} = handles.output;

%--------------------------------------------------------------------------

% --- Executes during object creation, after setting all properties. function Input_Subject_Number_CreateFcn(hObject, eventdata, handles)

% hObject handle to Input_Subject_Number (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

22

% See ISPC and COMPUTER. if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

%-------------------------------------------------------------------------- function Input_Subject_Number_Callback(hObject, eventdata, handles)

% hObject handle to Input_Subject_Number (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Input_Subject_Number as text

% str2double(get(hObject,'String')) returns contents of Input_Subject_Number as a double

%val = get(hObject,'Value');

%%str = get(hObject, 'String');

%%handles.Input_Subject_Number = str;

%%num_images = str2num(str);

%--------------------------------------------------------------------------

% --- Executes during object creation, after setting all properties. function Input_number_of_images_CreateFcn(hObject, eventdata, handles)

% hObject handle to Input_number_of_images (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER. if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

%varargout{2} = handles.output;

%-------------------------------------------------------------------------- function Input_number_of_images_Callback(hObject, eventdata, handles)

% hObject handle to Input_number_of_images (see GCBO)

23

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Input_number_of_images as text

% str2double(get(hObject,'String')) returns contents of Input_number_of_images as a double

%num_images =str2num(get(handles.Input_Number_of_Images,'string')); %load the ecg

%%val = get(hObject,'Value');

%%str = get(hObject, 'String');

%--------------------------------------------------------------------------

% --- Executes on button press in Calculate_Mean_ADC_and_Hist. function Calculate_Mean_ADC_and_Hist_Callback(hObject, eventdata, handles)

% hObject handle to Calculate_Mean_ADC_and_Hist (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% calcADCandHist my code

% %%201 day = input('Day 1 or 2? ');

% %%201 sub_str = sprintf('HPG201-003-%04d Day %1d',sub_number, day);

% %%102 sub_str = sprintf('HPG102-003-%04d', sub_number);

%num_images = input('How many images are in the ADC series? ');

str = get(handles.Input_number_of_images,'String');

handles.num_images = str2num(str);

%image_commonname = input('What is the file name common to all the images ');

str = get(handles.Input_Common_File_Name,'String');

handles.image_commonname = str;

%image_uniquename = input('What is the unique image number of the first image ');

str = get(handles.Input_Unique_Name,'String');

handles.image_uniquename = str2num(str);

24

%sub_number = input('What is the subject number? ');

%sub_str = sprintf('ICS-%04d', sub_number);

str = get(handles.Select_Subject_Number,'String');

val = get(handles.Select_Subject_Number,'Value');

switch str{val}; case '002'

% st =002 ;

%set(handles.Select_Subject_Number,'String',002 )

handles.sub_str = 002; case '003' handles.sub_str = 003; case '004'

handles.sub_str = 004; case '005'

handles.sub_str = 005; case '006'

handles.sub_str = 006;

end handles.sub_str = str{val};

%%%%%%%%%%%%%%%%%%%%

%Code section is intellectual property

%%%%%%%%%%%%%%%%%%%%

% Added for the GUI h= handles.Histogram; axes(h) hold off

%%%%%%%%%%%%%%%%%%%%

%Code section is intellectual property

%%%%%%%%%%%%%%%%%%%% hold off guidata(hObject,handles);

% --- Executes on button press in Regional_ADC_Mean_and_Hist. function Regional_ADC_Mean_and_Hist_Callback(hObject, eventdata, handles)

25

% hObject handle to Regional_ADC_Mean_and_Hist (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Regional Code my code

%sub_number = input('What is the subject number? ');

%Get Subject_Number str = get(handles.Select_Subject_Number,'String'); val = get(handles.Select_Subject_Number,'Value'); str_temp_ssn = str{val}; for k=1:length(str_temp_ssn)

if (str_temp_ssn(k)==' '| str_temp_ssn(k) == 0 )

k=k+1;

else

str_finds_snn = str_temp_ssn(k:length(str_temp_ssn));

end end

switch str_finds_snn case '002'

handles.sub_str = 002; case '003' handles.sub_str = 003; case '004'

handles.sub_str = 004; case '005'

handles.sub_str = 005; case '006'

handles.sub_str = 006;

end

handles.sub_str = str{val};

str_temp_ssn = handles.sub_str;

%Just get '2' of 002 for k=1:length(str_temp_ssn)

if (str_temp_ssn(k)==' '| str_temp_ssn(k) == 0 )

k=k+1;

else

str_finds_ssn = str_temp_ssn(k:length(str_temp_ssn));

26

end end

%num_images = input('How many images are in the ADC series? '); str = get(handles.Input_number_of_images,'String'); handles.num_images = str2num(str);

%region = input('Which region are you calculating the ADC mean = ');

%Get Region str = get(handles.Input_Region,'String'); val = get(handles.Input_Region,'Value'); str_temp = str{val}; for k=1:length(str_temp)

if (str_temp(k)==' ')

k=k+1;

else

str_find = str_temp(k:length(str_temp));

end end

switch str_find

case 'W'

handles.Region ='W';

case 'RA'

handles.Region = 'RA';

case 'RM'

handles.Region = 'RM';

case 'RB'

handles.Region = 'RB';

case 'RW'

handles.Region = 'RW';

case 'LA'

handles.Region = 'LA';

case 'LM'

handles.Region = 'LM';

case 'LB'

handles.Region = 'LB';

case 'LW'

handles.Region = 'LW';

end

27

handles.Region =str{val}; img_pairs = handles.num_images/2; fulldata = zeros(256,256,img_pairs); fileRegion = [str_finds_ssn, handles.Region, 'VOL']; fid = fopen(fileRegion,'r+');

[A,counts] = fread(fid,img_pairs*256*256,'int16');

B = reshape(A, [ 256 256 img_pairs]);

%figure(5);

% Added for the GUI

m = handles.Lung_Image;

axes(m)

%%%%%%%%%%%%%%

%Code section is intellectual property

%%%%%%%%%%%%%%%%%%

% Added for the GUI l = handles.Histogram1; axes(l) hold off

%%%%%%%%%%%%%%%%%%%%

%Code section is intellectual property

%%%%%%%%%%%%%%%%%%%% xlabel('ADC cm2/s','FontSize',14); ylabel('Pixel Count','FontSize',14); title(['Regional Histogram of ADC Data '],'FontSize',14); text(0.6, 3000,['Lobe = ',handles.Region],'Fontsize',14); text(0.6, 3500,['SD = ',num2str(sd_full),handles.Region],'FontSize',14); text(0.6, 4000,['Mean = ',num2str(mean_full),handles.Region],'FontSize',14); text(0.6, 4500,['Numb = ',num2str(numb_full)],'FontSize',14);

%%%% %201 text(0.40, 6800,sub_str,'FontSize',14); text(0.55, 6500,handles.sub_str,'FontSize',14); axis([0 maxadc 0 7000]); guidata(hObject,handles);

%--------------------------------------------------------------------------

28

% --- Executes during object creation, after setting all properties. function Input_Common_File_Name_CreateFcn(hObject, eventdata, handles)

% hObject handle to Input_Common_File_Name (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER. if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Input_Common_File_Name_Callback(hObject, eventdata, handles)

% hObject handle to Input_Common_File_Name (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Input_Common_File_Name as text

% str2double(get(hObject,'String')) returns contents of Input_Common_File_Name as a double

%val = get(hObject,'Value');

%str = get(hObject, 'String');

%handles.Input_Common_File_Name = str;

% --- Executes during object creation, after setting all properties. function Input_Unique_Name_CreateFcn(hObject, eventdata, handles)

% hObject handle to Input_Unique_Name (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER. if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end guidata(hObject,handles);

%--------------------------------------------------------------------------

29

function Input_Unique_Name_Callback(hObject, eventdata, handles)

% hObject handle to Input_Unique_Name (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Input_Unique_Name as text

% str2double(get(hObject,'String')) returns contents of Input_Unique_Name as a double

%val = get(hObject,'Value');

%str = get(hObject, 'String');

%handles.Input_Unique_Name = str2num(str);

%guidata(hObject,handles);

% --- Executes on selection change in Select_Subject_Number. function Select_Subject_Number_Callback(hObject, eventdata, handles)

% hObject handle to Select_Subject_Number (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns Select_Subject_Number contents as cell array

% contents{get(hObject,'Value')} returns selected item from Select_Subject_Number

% --- Executes during object creation, after setting all properties. function Select_Subject_Number_CreateFcn(hObject, eventdata, handles)

% hObject handle to Select_Subject_Number (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.

% See ISPC and COMPUTER. if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end val = get(hObject,'Value'); str = get(hObject, 'String');

%--------------------------------------------------------------------------

% --- Executes on selection change in Side_of_Lung.

30

function Side_of_Lung_Callback(hObject, eventdata, handles)

% hObject handle to Side_of_Lung (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns Side_of_Lung contents as cell array

% contents{get(hObject,'Value')} returns selected item from Side_of_Lung

% --- Executes during object creation, after setting all properties. function Side_of_Lung_CreateFcn(hObject, eventdata, handles)

% hObject handle to Side_of_Lung (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.

% See ISPC and COMPUTER. if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

%-------------------------------------------------------------------------- function edit5_Callback(hObject, eventdata, handles)

% hObject handle to edit5 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text

% str2double(get(hObject,'String')) returns contents of edit5 as a double

% --- Executes during object creation, after setting all properties. function edit5_CreateFcn(hObject, eventdata, handles)

% hObject handle to edit5 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER. if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));

31

end

% --- Executes on selection change in Which_Region. function Which_Region_Callback(hObject, eventdata, handles)

% hObject handle to Which_Region (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns Which_Region contents as cell array

% contents{get(hObject,'Value')} returns selected item from Which_Region

%--------------------------------------------------------------------------

% --- Executes during object creation, after setting all properties. function Which_Region_CreateFcn(hObject, eventdata, handles)

% hObject handle to Which_Region (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.

% See ISPC and COMPUTER. if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

%--------------------------------------------------------------------------

% --- Executes on selection change in Input_Region. function Input_Region_Callback(hObject, eventdata, handles)

% hObject handle to Input_Region (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns Input_Region contents as cell array

% contents{get(hObject,'Value')} returns selected item from Input_Region

% --- Executes during object creation, after setting all properties. function Input_Region_CreateFcn(hObject, eventdata, handles)

% hObject handle to Input_Region (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

32

% Hint: popupmenu controls usually have a white background on Windows.

% See ISPC and COMPUTER. if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

% --- Executes on button press in button_clear. function button_clear_Callback(hObject, eventdata, handles)

% hObject handle to button_clear (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA) cla reset

%%%%%%%%%%%END OF ADCGUI.%%%%%%%%%%%%%%%

II) Notes

The ADCGUI was developed using MATLAB 7.0. The MATLAB GUI using GUIDE tool aided our process in the building of the GUI. Upon executing the GUI make sure that all code files (.m and .fig) as well as the images to be analyzed are placed in the working directory. To execute the GUI, type ‘ADCGUI’ in the MATLAB command window.

After the ADCGUI appears, the user must type in the desired information to see the result of ADC values. Also note that the GUI uses some routines that are intellectual property to the Department of Biomedical Engineering – University of Wisconsin and hence not provided in the source code. The file provided as code is the edited version and hence if executed will not run. If a demo is required, that can be arraged.

33

Course Project Workload Analysis Table

Tasks performed

Literature search

Algorithm derivation

Diana R. Palsetia Shilpa R. Panth

50%

50%

50%

50%

Matlab programs

Report writing

50%

50%

50%

50%

Power point presentation

Overall

50%

50%

50%

50%

Team Member #1: Diana R. Palsetia _________________________________

Signature

Team Member #2: Shilpa R. Panth _________________________________

Signature

34

Download