Cara Menampilkan Citra kepala MRI (axial, sagittal, dan coronal) menggunakan GUI Matlab


Citra kepala hasil pemindaian Magnetic Resonance Imaging (MRI) yang terdapat pada Matlab terdiri dari 27 slice axial. Berikut ini merupakan pemrograman GUI Matlab untuk menampilkan citra kepala tersebut dalam bentuk 3 dimensi pada tampang aksial, sagittal, dan coronal. Proses ini diawali dengan mentransformasi potongan slice citra tampang aksial menjadi 35 slice sagittal dan 45 slice coronal menggunakan transformasi radon. Setelah itu dilakukan rekonstruksi citra sehingga dapat divisualisasikan dalam bentuk tiga dimensi.

Source code GUI Matlab untuk menampilkan citra kepala MRI secara tiga dimensi dapat diunduh pada link berikut: Source Code

Sedangkan tampilan kodingnya adalah:

function varargout = medik(varargin)
% MEDIK MATLAB code for medik.fig
%      MEDIK, by itself, creates a new MEDIK or raises the existing
%      singleton*.
%
%      H = MEDIK returns the handle to a new MEDIK or the handle to
%      the existing singleton*.
%
%      MEDIK('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MEDIK.M with the given input arguments.
%
%      MEDIK('Property','Value',...) creates a new MEDIK or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before medik_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to medik_OpeningFcn via varargin.
%
%      *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 medik

% Last Modified by GUIDE v2.5 05-Mar-2014 11:25:49

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @medik_OpeningFcn, ...
    'gui_OutputFcn',  @medik_OutputFcn, ...
    'gui_LayoutFcn',  [] , ...
    'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

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 medik is made visible.
function medik_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   command line arguments to medik (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);
movegui(hObject, 'center');

% UIWAIT makes medik wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = medik_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 on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
image_num = str2double(get(handles.edit1,'string'));

if image_num > 1
    image_num = image_num-1;
else
    image_num = 1;
end

load mri
D = squeeze(D);

axes(handles.axes1);
imagesc(D(:,:,image_num));
axis image;
colormap(map);
title ('Horizontal');
set(handles.edit1, 'string', image_num);

handles.D = D(:,:,image_num);
guidata(hObject, handles)

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
image_num = str2double(get(handles.edit1,'string'));

if image_num < 27
    image_num = image_num+1;
else
    image_num = 27;
end

load mri
D = squeeze(D);

axes(handles.axes1);
imagesc(D(:,:,image_num));
axis image;
colormap(map);
title ('Horizontal');
set(handles.edit1, 'string', image_num);

handles.D = D(:,:,image_num);
guidata(hObject, handles)


function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (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 edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
load mri
R3 = makeresampler({'cubic','nearest','nearest'},'fill');
T3 = maketform('affine',[-2.5 0 0; 0 1 0; 0 0 0.5; 68.5 0 -14]);
S = tformarray(D,T3,R3,[4 1 2],[1 2 4],[66 128 35],[],0);
S2 = padarray(S,[6 0 0 0],0,'both');
S2 = squeeze(S2);

image_num = str2double(get(handles.edit2,'string'));

if image_num > 1
    image_num = image_num-1;
else
    image_num = 1;
end

axes(handles.axes2);
imagesc(S2(:,:,image_num));
axis image;
colormap(map);
title ('Sagittal');
set(handles.edit2, 'string', image_num);

% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
load mri
R3 = makeresampler({'cubic','nearest','nearest'},'fill');
T3 = maketform('affine',[-2.5 0 0; 0 1 0; 0 0 0.5; 68.5 0 -14]);
S = tformarray(D,T3,R3,[4 1 2],[1 2 4],[66 128 35],[],0);
S2 = padarray(S,[6 0 0 0],0,'both');
S2 = squeeze(S2);

image_num = str2double(get(handles.edit2,'string'));

if image_num < 35
    image_num = image_num+1;
else
    image_num = 35;
end

axes(handles.axes2);
imagesc(S2(:,:,image_num));
axis image;
colormap(map);
title ('Sagittal');
set(handles.edit2, 'string', image_num);


function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (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 edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
load mri
R3 = makeresampler({'cubic','nearest','nearest'},'fill');
T4 = maketform('affine',[-2.5 0 0; 0 1 0; 0 0 -0.5; 68.5 0 61]);
C = tformarray(D,T4,R3,[4 2 1],[1 2 4],[66 128 45],[],0);
C2 = padarray(C,[6 0 0 0],0,'both');


image_num = str2double(get(handles.edit3,'string'));

if image_num > 1
    image_num = image_num-1;
else
    image_num = 1;
end

axes(handles.axes3);
imagesc(C2(:,:,image_num));
axis image;
colormap(map);
title ('Coronal');
set(handles.edit3, 'string', image_num);

% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
load mri
R3 = makeresampler({'cubic','nearest','nearest'},'fill');
T4 = maketform('affine',[-2.5 0 0; 0 1 0; 0 0 -0.5; 68.5 0 61]);
C = tformarray(D,T4,R3,[4 2 1],[1 2 4],[66 128 45],[],0);
C2 = padarray(C,[6 0 0 0],0,'both');

image_num = str2double(get(handles.edit3,'string'));

if image_num < 45
    image_num = image_num+1;
else
    image_num = 45;
end

axes(handles.axes3);
imagesc(C2(:,:,image_num));
axis image;
colormap(map);
title ('Coronal');
set(handles.edit3, 'string', image_num);


function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (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 edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
hold off
axes(handles.axes4);
load mri.mat
D = squeeze(D);
Ds = smooth3(D);
hiso = patch(isosurface(Ds,5),...
    'FaceColor',[1,.75,.65],...
    'EdgeColor','none');
isonormals(Ds,hiso)

hcap = patch(isocaps(D,5),...
    'FaceColor','interp',...
    'EdgeColor','none');

view(35,30)
axis tight
colormap(map)
daspect([1,1,.4])

lightangle(45,30);
set(gcf,'Renderer','zbuffer'); lighting phong
set(hcap,'AmbientStrength',.6)
set(hiso,'SpecularColorReflectance',0,'SpecularExponent',50)


% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
tulisan1 = get(hObject,'String');
tulisan2 = 'Rotate Off';
C = strcmp(tulisan2,tulisan1);
if C == 0;
    set(hObject,'String','Rotate Off');
    rotate3d on;
elseif C == 1
    set(hObject,'String','Rotate On');
    rotate3d off;
end

Save

Posted on October 28, 2013, in Pengenalan Matlab, Pengolahan Citra and tagged , , , , , , , , , , , , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: