Home > SuperSegger > viz > editSegmentsGui.m

editSegmentsGui

PURPOSE ^

editSegmentsGui : gui used to turn on/off segments

SYNOPSIS ^

function varargout = editSegmentsGui(varargin)

DESCRIPTION ^

 editSegmentsGui : gui used to turn on/off segments

 Copyright (C) 2016 Wiggins Lab
 Written by Silas Boye Nissen.
 University of Washington, 2016
 This file is part of SuperSegger.

 SuperSegger is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 SuperSegger is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = editSegmentsGui(varargin)
0002 % editSegmentsGui : gui used to turn on/off segments
0003 %
0004 % Copyright (C) 2016 Wiggins Lab
0005 % Written by Silas Boye Nissen.
0006 % University of Washington, 2016
0007 % This file is part of SuperSegger.
0008 %
0009 % SuperSegger is free software: you can redistribute it and/or modify
0010 % it under the terms of the GNU General Public License as published by
0011 % the Free Software Foundation, either version 3 of the License, or
0012 % (at your option) any later version.
0013 %
0014 % SuperSegger is distributed in the hope that it will be useful,
0015 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017 % GNU General Public License for more details.
0018 %
0019 % You should have received a copy of the GNU General Public License
0020 % along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.
0021 
0022 gui_Singleton = 1;
0023 gui_State = struct('gui_Name',       mfilename, ...
0024                    'gui_Singleton',  gui_Singleton, ...
0025                    'gui_OpeningFcn', @editSegmentsGui_OpeningFcn, ...
0026                    'gui_OutputFcn',  @editSegmentsGui_OutputFcn, ...
0027                    'gui_LayoutFcn',  [] , ...
0028                    'gui_Callback',   []);
0029 if nargin && ischar(varargin{1})
0030     gui_State.gui_Callback = str2func(varargin{1});
0031 end
0032 if nargout
0033     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0034 else
0035     gui_mainfcn(gui_State, varargin{:});
0036 end
0037 
0038 function varargout = editSegmentsGui_OutputFcn(hObject, eventdata, handles) 
0039 
0040 % Global functions
0041 
0042 function clickOnImage(hObject, eventdata, handles)
0043 global settings
0044 FLAGS.im_flag = settings.handles.im_flag;
0045 currentData = load([settings.handles.dirname, settings.handles.contents(str2double(settings.handles.frame_no.String)).name]);
0046 [data, list] = updateTrainingImage(currentData, FLAGS, eventdata.IntersectionPoint(1:2));
0047 save([settings.handles.dirname, settings.handles.contents(str2double(settings.handles.frame_no.String)).name], '-STRUCT', 'data');
0048 updateUI(settings.hObject, settings.handles);
0049 
0050 function data = loaderInternal(filename)
0051 data = load(filename);
0052 data.segs.segs_good = double(data.segs.segs_label>0).*double(~data.mask_cell);
0053 data.segs.segs_bad = double(data.segs.segs_label>0).*data.mask_cell;
0054 
0055 function editSegmentsGui_OpeningFcn(hObject, eventdata, handles, varargin)
0056 handles.dirname = fixDir(getappdata(0, 'dirname_seg'));
0057 handles.dirname_xy = fixDir(getappdata(0, 'dirname_xy'));
0058 handles.dirname_cell = fixDir(getappdata(0, 'dirname_cell'));
0059 handles.frame_no.String = num2str(getappdata(0, 'nn'));
0060 handles.CONST = getappdata(0, 'CONST');
0061 handles.contents = dir([handles.dirname '*_seg.mat']);
0062 handles.num_im = length(handles.contents);
0063 handles.im_flag = 1;
0064 axis tight;
0065 updateUI(hObject, handles);
0066 
0067 function updateUI(hObject, handles)
0068 global settings
0069 delete(get(handles.axes1, 'Children'));
0070 data = loaderInternal([handles.dirname, handles.contents(str2double(handles.frame_no.String)).name]);
0071 data.mask_cell = double((data.mask_bg - data.segs.segs_good - data.segs.segs_3n) > 0);
0072 showSegData(data, handles.im_flag, handles.axes1);
0073 settings.handles = handles;
0074 settings.hObject = hObject;
0075 set(handles.axes1.Children, 'ButtonDownFcn', @clickOnImage);
0076 guidata(hObject, handles);
0077 
0078 function figure1_CloseRequestFcn(hObject, eventdata, handles)
0079 setappdata(0, 'dirname', handles.dirname(1:end-8));
0080 delete(hObject);
0081 superSeggerViewerGui();
0082 
0083 % Frame no.
0084 
0085 function frame_no_Callback(hObject, eventdata, handles)
0086 c = round(str2double(handles.frame_no.String));
0087 if c > handles.num_im
0088     handles.frame_no.String = num2str(handles.num_im);
0089 elseif isnan(c) || c < 1;
0090     handles.frame_no.String = '1';
0091 else
0092     handles.frame_no.String = num2str(c);
0093 end
0094 updateUI(hObject, handles)
0095 
0096 function frame_no_CreateFcn(hObject, eventdata, handles)
0097 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0098     set(hObject,'BackgroundColor','white');
0099 end
0100 
0101 function previous_Callback(hObject, eventdata, handles)
0102 handles.frame_no.String = num2str(str2double(handles.frame_no.String)-1);
0103 frame_no_Callback(hObject, eventdata, handles);
0104 
0105 function next_Callback(hObject, eventdata, handles)
0106 handles.frame_no.String = num2str(str2double(handles.frame_no.String)+1);
0107 frame_no_Callback(hObject, eventdata, handles);
0108 
0109 function figure1_KeyPressFcn(hObject, eventdata, handles)
0110 if strcmpi(eventdata.Key,'leftarrow')
0111     previous_Callback(hObject, eventdata, handles);
0112 end
0113 if strcmpi(eventdata.Key,'rightarrow')
0114     next_Callback(hObject, eventdata, handles);
0115 end
0116 
0117 % Radio buttons
0118 
0119 function mask_Callback(hObject, eventdata, handles)
0120 handles.im_flag = 2;
0121 handles.phase.Value = 0;
0122 handles.segment.Value = 0;
0123 updateUI(hObject, handles)
0124 
0125 function phase_Callback(hObject, eventdata, handles)
0126 handles.im_flag = 3;
0127 handles.mask.Value = 0;
0128 handles.segment.Value = 0;
0129 updateUI(hObject, handles)
0130 
0131 function segment_Callback(hObject, eventdata, handles)
0132 handles.im_flag = 1;
0133 handles.mask.Value = 0;
0134 handles.phase.Value = 0;
0135 updateUI(hObject, handles)
0136 
0137 function relink_Callback(hObject, eventdata, handles)
0138 choice = questdlg('Are you sure you want to relink and remake the cell files?', 'Re-link the cells?', 'Yes', 'No', 'No');
0139 if strcmp(choice, 'Yes')
0140     skip = 1;
0141     
0142     % deleting old linking files
0143     startEnd = [4 20]; % from linking to the end
0144     cleanSuperSegger (handles.dirname_xy, startEnd, skip);
0145 
0146     header = 'Relink: ';
0147     trackOpti(handles.dirname_xy,skip, handles.CONST, header, startEnd);
0148 end

Generated on Thu 19-Jan-2017 13:55:21 by m2html © 2005