443 lines
16 KiB
Matlab
443 lines
16 KiB
Matlab
function varargout = untitled(varargin)
|
|
% UNTITLED MATLAB code for untitled.fig
|
|
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
|
|
% singleton*.
|
|
%
|
|
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
|
|
% the existing singleton*.
|
|
%
|
|
% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
|
|
% function named CALLBACK in UNTITLED.M with the given input arguments.
|
|
%
|
|
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
|
|
% existing singleton*. Starting from the left, property value pairs are
|
|
% applied to the GUI before untitled_OpeningFcn gets called. An
|
|
% unrecognized property name or invalid value makes property application
|
|
% stop. All inputs are passed to untitled_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 untitled
|
|
|
|
% Last Modified by GUIDE v2.5 23-Feb-2016 13:35:24
|
|
|
|
% Begin initialization code - DO NOT EDIT
|
|
gui_Singleton = 1;
|
|
gui_State = struct('gui_Name', mfilename, ...
|
|
'gui_Singleton', gui_Singleton, ...
|
|
'gui_OpeningFcn', @untitled_OpeningFcn, ...
|
|
'gui_OutputFcn', @untitled_OutputFcn, ...
|
|
'gui_LayoutFcn', [] , ...
|
|
'gui_Callback', [] ,...
|
|
'userData', struct());
|
|
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
|
|
%{
|
|
imsrc = {[]};
|
|
circule = {[] []};
|
|
coordinates = [0 0];
|
|
%}
|
|
|
|
% --- Executes just before untitled is made visible.
|
|
function untitled_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 untitled (see VARARGIN)
|
|
global data_struct
|
|
% Choose default command line output for untitled
|
|
handles.output = hObject;
|
|
|
|
handles.imsrc = {[]};
|
|
handles.circule = {[] []};
|
|
handles.coordinates = [0 0];
|
|
handles.FileName ='';
|
|
handles.PathName = './';
|
|
handles.FilterIndex= 0;
|
|
|
|
|
|
% Update handles structure
|
|
guidata(hObject, handles);
|
|
|
|
% UIWAIT makes untitled wait for user response (see UIRESUME)
|
|
% uiwait(handles.figure1);
|
|
|
|
|
|
% --- Outputs from this function are returned to the command line.
|
|
function varargout = untitled_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;
|
|
|
|
|
|
|
|
% --------------------------------------------------------------------
|
|
function Open_Callback(hObject, eventdata, handles)
|
|
% hObject handle to Open (see GCBO)
|
|
% eventdata reserved - to be defined in a future version of MATLAB
|
|
% handles structure with handles and user data (see GUIDATA)
|
|
%handles = guidata(hObject);
|
|
handles = guidata(hObject);
|
|
[handles.FileName,handles.PathName,handles.FilterIndex] = uigetfile({'*.tif; *.nd2','bio-format image file(*.tif; *.nd2)';'*.tif','TIFF file(*.tif)';'*.nd2','ND2 file(*.nd2)';},'Select the bio-format image file');
|
|
global imsrc cmpt
|
|
cmpt=0;
|
|
|
|
|
|
format = handles.FileName(end-3:end);
|
|
if format == '.tif'
|
|
imsrc{1}= imread([handles.PathName handles.FileName],'tif','Index',1);
|
|
imsrc{2}= imread([handles.PathName handles.FileName],'tif','Index',2);
|
|
imsrc{3}= imread([handles.PathName handles.FileName],'tif','Index',3);
|
|
imsrc{4}= imread([handles.PathName handles.FileName],'tif','Index',4);
|
|
imsrc{5}= imread([handles.PathName handles.FileName],'tif','Index',5);
|
|
end
|
|
if format == '.nd2'
|
|
imsrc{1}= uint16(imreadBF([handles.PathName handles.FileName],1, 1, 1));
|
|
imsrc{2}= uint16(imreadBF([handles.PathName handles.FileName],1, 1, 2));
|
|
imsrc{3}= uint16(imreadBF([handles.PathName handles.FileName]',1, 1, 3));
|
|
imsrc{4}= uint16(imreadBF([handles.PathName handles.FileName],1, 1, 4));
|
|
imsrc{5}= uint16(imreadBF([handles.PathName handles.FileName],1, 1, 5));
|
|
end
|
|
%disp (hObject);
|
|
handles.imsrc=imsrc;
|
|
%plot
|
|
%axes(handles.axes1)
|
|
RI = imref2d(size(handles.imsrc{1}));
|
|
RI.XWorldLimits = [0 1];
|
|
RI.YWorldLimits = [0 1];
|
|
c=colormap(handles.axes1,gray);
|
|
close (clf);
|
|
axes(handles.axes1);
|
|
hold(handles.axes2,'off');
|
|
%c=colormap(handles.axes1,gray);
|
|
|
|
h = imagesc(imsrc{1},'Parent',handles.axes1);
|
|
|
|
|
|
set(handles.axes1, 'XTick', []);
|
|
set(handles.axes1, 'YTick', []);
|
|
set ( h, 'ButtonDownFcn', {@axes1_ButtonDownFcn, handles} );
|
|
axes(handles.axes2);
|
|
%hold(handles.axes2,'on')
|
|
h=imagesc(imsrc{2},'Parent',handles.axes2);
|
|
%c = colormap(handles.axes2,gray);
|
|
set(handles.axes2, 'XTick', []);
|
|
set(handles.axes2, 'YTick', []);
|
|
% Update handles structure
|
|
guidata(hObject, handles);
|
|
|
|
|
|
|
|
|
|
% --- Executes on mouse press over axes background.
|
|
function axes1_ButtonDownFcn(hObject, eventdata, handles)
|
|
% hObject handle to axes1 (see GCBO)
|
|
% eventdata reserved - to be defined in a future version of MATLAB
|
|
% handles structure with handles and user data (see GUIDATA)
|
|
%get click location
|
|
handles = guidata(hObject);
|
|
global cmpt imsrc p1 p2
|
|
[RX RY] =size(imsrc{1});
|
|
Rx = .01*RX;
|
|
Ry = .01*RY;
|
|
coordinates = get(handles.axes1,'CurrentPoint');
|
|
coordinates = coordinates(1,1:2);
|
|
handles.coordinates = coordinates;
|
|
disp( coordinates);
|
|
|
|
%compute circule
|
|
radius = linspace(0,2*pi,360);
|
|
x = Rx*cos(radius)+coordinates(1,1) ;
|
|
y = Ry*sin(radius)+coordinates(1,2) ;
|
|
handles.circule = {x ,y};
|
|
%drawing
|
|
axes(handles.axes1);
|
|
|
|
|
|
cmpt = cmpt+1;
|
|
|
|
hold(handles.axes1,'on')
|
|
if cmpt ==1
|
|
p1= coordinates;
|
|
plot(handles.axes1, handles.circule{1},handles.circule{2},'r.');
|
|
|
|
elseif cmpt ==2
|
|
p2= coordinates;
|
|
plot(handles.axes1, handles.circule{1},handles.circule{2},'m.');
|
|
|
|
else
|
|
h = imagesc(handles.imsrc{1},'Parent',handles.axes1);
|
|
cmpt = 0;
|
|
set ( h, 'ButtonDownFcn', {@axes1_ButtonDownFcn, handles} );
|
|
set(handles.axes1, 'XTick', []);
|
|
set(handles.axes1, 'YTick', []);
|
|
end
|
|
|
|
% Update handles structure
|
|
guidata(hObject, handles);
|
|
|
|
|
|
% --- 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)
|
|
global imsrc p1 p2 result
|
|
handles = guidata(hObject);
|
|
[Lrgb, sk, grayMorph, gradMag, binMorph, L, skl,list_labelsk , labelStat, c,TabPlotX, TabPlotY ]=computeRun(imsrc, p1,p2, handles.axes1);
|
|
for i=1:length(TabPlotX)
|
|
rectangle('Position',[TabPlotX(i), TabPlotY(i),2,2],...
|
|
'EdgeColor','r','Curvature',1,'LineWidth',1,'Parent',handles.axes1);
|
|
end
|
|
f=rectangle('Position',[TabPlotX(1), TabPlotY(1),2,2],...
|
|
'EdgeColor','b','Curvature',1,'LineWidth',1,'Parent',handles.axes1);
|
|
e=rectangle('Position',[TabPlotX(length(TabPlotX)), TabPlotY(length(TabPlotX)),2,2],...
|
|
'EdgeColor','b','Curvature',1,'LineWidth',1,'Parent',handles.axes1);
|
|
|
|
|
|
|
|
result = {grayMorph, gradMag, binMorph, L,Lrgb,sk, skl,list_labelsk, labelStat, c };
|
|
axes(handles.axes3);
|
|
hold(handles.axes3,'on')
|
|
if ~iscell(c)
|
|
h = msgbox('Operation Faild','Faild');
|
|
return;
|
|
end
|
|
Ic=cell2mat(c);
|
|
h = imagesc(Ic,'CDataMapping','scaled','Parent',handles.axes3);
|
|
|
|
% set ( h, 'ButtonDownFcn', {@axes3_ButtonDownFcn, handles} );
|
|
set(handles.axes3, 'XTick', []);
|
|
set(handles.axes3, 'YTick', []);
|
|
hold(handles.axes3,'off')
|
|
h = msgbox('Operation Completed','Success');
|
|
% Update handles structure
|
|
guidata(hObject, handles);
|
|
|
|
|
|
% --- 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)
|
|
global imsrc result
|
|
h = axes
|
|
i=imagesc(imsrc{1},'Parent',h);
|
|
%set(i, 'AlphaData', .7,'AlphaDataMapping','scaled');
|
|
set(h, 'XTick', []);
|
|
set(h, 'YTick', []);
|
|
hold(h,'on');
|
|
for k=1:length(result)
|
|
if k ==1
|
|
h1 = imagesc(result{k},'Parent',h);
|
|
set(h1, 'AlphaData', 0.3,'AlphaDataMapping','scaled');
|
|
end
|
|
if k ==2
|
|
h2 = imagesc(result{k},'Parent',h);
|
|
set(h2, 'AlphaData', 0.3,'AlphaDataMapping','scaled');
|
|
end
|
|
|
|
end
|
|
|
|
|
|
% --- Executes on button press in pushbutton5.
|
|
function pushbutton5_Callback(hObject, eventdata, handles)
|
|
global result
|
|
% 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)
|
|
[fileName,pathName] = uiputfile({'*.csv; *.xls','Comma-Separated Values file(*.csv; *.xls)';'*.csv','Comma-Separated Values file(*.csv)';'*.xls','Exel file(*.xls)';},'Select the data file type');
|
|
f = fullfile(pathName,fileName);
|
|
%cell2csv(f,result{9}', ',',2007,'.');
|
|
ExportCSV(f,cell2mat(result{9}{2}),cell2mat(result{9}{3}),cell2mat(result{9}{4}),cell2mat(result{9}{5}));
|
|
celldisp(result{9})
|
|
% --- Executes on button press in radiobutton1.
|
|
function radiobutton1_Callback(hObject, eventdata, handles)
|
|
% hObject handle to radiobutton1 (see GCBO)
|
|
% eventdata reserved - to be defined in a future version of MATLAB
|
|
% handles structure with handles and user data (see GUIDATA)
|
|
|
|
% Hint: get(hObject,'Value') returns toggle state of radiobutton1
|
|
global imsrc
|
|
if (get(hObject,'Value') == get(hObject,'Max'))
|
|
display('Selected');
|
|
axes(handles.axes2);
|
|
hold(handles.axes2,'off')
|
|
h = imagesc(imsrc{2},'Parent',handles.axes2);
|
|
set(handles.axes2, 'XTick', []);
|
|
set(handles.axes2, 'YTick', []);
|
|
else
|
|
display('Not selected');
|
|
end
|
|
% --- Executes on button press in radiobutton2.
|
|
function radiobutton2_Callback(hObject, eventdata, handles)
|
|
% hObject handle to radiobutton1 (see GCBO)
|
|
% eventdata reserved - to be defined in a future version of MATLAB
|
|
% handles structure with handles and user data (see GUIDATA)
|
|
|
|
% Hint: get(hObject,'Value') returns toggle state of radiobutton1
|
|
global imsrc
|
|
if (get(hObject,'Value') == get(hObject,'Max'))
|
|
display('Selected');
|
|
axes(handles.axes2);
|
|
hold(handles.axes2,'off')
|
|
h = imagesc(imsrc{3},'Parent',handles.axes2);
|
|
set(handles.axes2, 'XTick', []);
|
|
set(handles.axes2, 'YTick', []);
|
|
else
|
|
display('Not selected');
|
|
end
|
|
|
|
|
|
% --- Executes on button press in radiobutton1.
|
|
function radiobutton3_Callback(hObject, eventdata, handles)
|
|
% hObject handle to radiobutton1 (see GCBO)
|
|
% eventdata reserved - to be defined in a future version of MATLAB
|
|
% handles structure with handles and user data (see GUIDATA)
|
|
|
|
% Hint: get(hObject,'Value') returns toggle state of radiobutton1
|
|
global imsrc
|
|
if (get(hObject,'Value') == get(hObject,'Max'))
|
|
display('Selected');
|
|
axes(handles.axes2);
|
|
hold(handles.axes2,'off')
|
|
h = imagesc(imsrc{4},'Parent',handles.axes2);
|
|
set(handles.axes2, 'XTick', []);
|
|
set(handles.axes2, 'YTick', []);
|
|
else
|
|
display('Not selected');
|
|
end
|
|
|
|
|
|
% --- Executes on button press in radiobutton1.
|
|
function radiobutton4_Callback(hObject, eventdata, handles)
|
|
% hObject handle to radiobutton1 (see GCBO)
|
|
% eventdata reserved - to be defined in a future version of MATLAB
|
|
% handles structure with handles and user data (see GUIDATA)
|
|
|
|
% Hint: get(hObject,'Value') returns toggle state of radiobutton1
|
|
global imsrc
|
|
if (get(hObject,'Value') == get(hObject,'Max'))
|
|
display('Selected');
|
|
axes(handles.axes2);
|
|
hold(handles.axes2,'off')
|
|
h = imagesc(imsrc{5},'Parent',handles.axes2);
|
|
set(handles.axes2, 'XTick', []);
|
|
set(handles.axes2, 'YTick', []);
|
|
else
|
|
display('Not selected');
|
|
end
|
|
|
|
|
|
|
|
% --- 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)
|
|
global imsrc result
|
|
[fileName,pathName] = uiputfile({'*.png; *.tif','imagefile(*.png; *.tif)';'*.png','PNG(*.png)';'*.tif','TIFF(*.tif)';},'Select the data file type');
|
|
f = fullfile(pathName,fileName);
|
|
|
|
saveResult(f,imsrc{1},result);
|
|
|
|
|
|
% --- Executes on button press in checkbox1.
|
|
function checkbox1_Callback(hObject, eventdata, handles)
|
|
% hObject handle to checkbox1 (see GCBO)
|
|
% eventdata reserved - to be defined in a future version of MATLAB
|
|
% handles structure with handles and user data (see GUIDATA)
|
|
|
|
% Hint: get(hObject,'Value') returns toggle state of checkbox1
|
|
global result
|
|
v = get(hObject,'Value');
|
|
afficheResult(result{1},1,v);
|
|
|
|
% --- Executes on button press in checkbox2.
|
|
function checkbox2_Callback(hObject, eventdata, handles)
|
|
% hObject handle to checkbox2 (see GCBO)
|
|
% eventdata reserved - to be defined in a future version of MATLAB
|
|
% handles structure with handles and user data (see GUIDATA)
|
|
|
|
% Hint: get(hObject,'Value') returns toggle state of checkbox2
|
|
global result
|
|
v = get(hObject,'Value');
|
|
afficheResult(result{2},2,v);
|
|
|
|
% --- Executes on button press in checkbox3.
|
|
function checkbox3_Callback(hObject, eventdata, handles)
|
|
% hObject handle to checkbox3 (see GCBO)
|
|
% eventdata reserved - to be defined in a future version of MATLAB
|
|
% handles structure with handles and user data (see GUIDATA)
|
|
|
|
% Hint: get(hObject,'Value') returns toggle state of checkbox3
|
|
global result
|
|
v = get(hObject,'Value');
|
|
afficheResult(result{3},3,v);
|
|
|
|
% --- 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)
|
|
|
|
|
|
% --- Executes on button press in checkbox4.
|
|
function checkbox4_Callback(hObject, eventdata, handles)
|
|
% hObject handle to checkbox4 (see GCBO)
|
|
% eventdata reserved - to be defined in a future version of MATLAB
|
|
% handles structure with handles and user data (see GUIDATA)
|
|
|
|
% Hint: get(hObject,'Value') returns toggle state of checkbox4
|
|
global result
|
|
v = get(hObject,'Value');
|
|
afficheResult(result{4},4,v);
|
|
|
|
|
|
|
|
% --- Executes on button press in checkbox5.
|
|
function checkbox5_Callback(hObject, eventdata, handles)
|
|
% hObject handle to checkbox5 (see GCBO)
|
|
% eventdata reserved - to be defined in a future version of MATLAB
|
|
% handles structure with handles and user data (see GUIDATA)
|
|
|
|
% Hint: get(hObject,'Value') returns toggle state of checkbox5
|
|
global result
|
|
global imsrc
|
|
im=imsrc{1};
|
|
%v = get(hObject,'Value');
|
|
Ls=result{8};
|
|
M=labelmatrix(Ls);
|
|
Lrgb = label2rgb(M,'jet',[.5 .5 .5]);
|
|
figure(5); clf; imshow(im); hold on; title('Selected Cells Superposed on Source Image');
|
|
himage = imshow(Lrgb);
|
|
set(himage, 'AlphaData', 0.3);
|
|
% afficheResult(result{8},5,v);
|
|
|
|
% --- Executes on button press in checkbox6.
|
|
function checkbox6_Callback(hObject, eventdata, handles)
|
|
% hObject handle to checkbox6 (see GCBO)
|
|
% eventdata reserved - to be defined in a future version of MATLAB
|
|
% handles structure with handles and user data (see GUIDATA)
|
|
|
|
% Hint: get(hObject,'Value') returns toggle state of checkbox6
|
|
global result
|
|
v = get(hObject,'Value');
|
|
afficheResult(result{7},6,v);
|