Home > SuperSegger > batch > superSeggerGui.m

superSeggerGui

PURPOSE ^

superSeggerGui : gui for segmenting images with superSegger.

SYNOPSIS ^

function varargout = superSeggerGui(varargin)

DESCRIPTION ^

 superSeggerGui : gui for segmenting images with superSegger. 

 Copyright (C) 2016 Wiggins Lab 
 Written by Silas Boye Nissen & Stella Stylianidou.
 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 = superSeggerGui(varargin)
0002 % superSeggerGui : gui for segmenting images with superSegger.
0003 %
0004 % Copyright (C) 2016 Wiggins Lab
0005 % Written by Silas Boye Nissen & Stella Stylianidou.
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 
0023 gui_Singleton = 1;
0024 gui_State = struct('gui_Name',       mfilename, ...
0025     'gui_Singleton',  gui_Singleton, ...
0026     'gui_OpeningFcn', @superSeggerGui_OpeningFcn, ...
0027     'gui_OutputFcn',  @superSeggerGui_OutputFcn, ...
0028     'gui_LayoutFcn',  [] , ...
0029     'gui_Callback',   []);
0030 
0031 if nargin && ischar(varargin{1})
0032     gui_State.gui_Callback = str2func(varargin{1});
0033 end
0034 
0035 if nargout
0036     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0037 else
0038     gui_mainfcn(gui_State, varargin{:});
0039 end
0040 
0041 function superSeggerGui_OpeningFcn(hObject, eventdata, handles, varargin)
0042 handles.output = hObject;
0043 handles.directory.String = pwd;
0044 load_listbox(handles)
0045 set(handles.figure1, 'units', 'normalized', 'position', [0.25 0.2 0.38 0.8])
0046 guidata(hObject, handles);
0047 
0048 
0049 function load_listbox(handles)
0050 [~,reslist] = getConstantsList();
0051 [sorted_names,sorted_index] = sortrows(reslist');
0052 handles.file_names = sorted_names;
0053 handles.sorted_index = sorted_index;
0054 set(handles.constants_list,'String',handles.file_names,...
0055     'Value',1)
0056 
0057 function varargout = superSeggerGui_OutputFcn(hObject, eventdata, handles)
0058 varargout{1} = handles.output;
0059 
0060 function imageFolder_ClickedCallback(hObject, eventdata, handles)
0061 handles.directory.String = uigetdir;
0062 
0063 
0064 function help_ClickedCallback(hObject, eventdata, handles)
0065 msgbox('Examples for image conversion : ')
0066 
0067 function convert_names_help_Callback(hObject, eventdata, handles)
0068 Opt.Interpreter = 'tex';
0069 Opt.WindowStyle = 'normal';
0070 h = msgbox({'Your file names have to be on the format \bf[basename]t[number]xy[number]c[number].tif\rm, where the first number (after \bft\rm) indicates the time frame number, the second number (after \bfxy\rm) is for the different timelapse positions, and finally the third number (after \bfc\rm) are for the different channels (\bfc1\rm are the phase images while \bfc2\rm and onwards are for fluorescence channels), e.g. \bfMG1655{\_}t001xy1c1.tif\rm (where the basename is \bfMG1655{\_}\rm).',
0071 '',
0072 'If your image files do not have this name format you can use the GUI to convert the names. The way the name conversion works is that the user indicates the characters before and after the time frame numbers, before and after the xy numbers, and the characters that indicate the channel. The program can then find the numbers and rename the images to the required naming convention.',
0073 '',
0074 'The different fields are: \bfImage directory\rm: directory where the .tif images are stored. \bfBasename\rm: how you want your images to be named e.g. strain. \bfChannels\rm: an array of strings seperated by comma that indicate the different channels in your filenames e.g. BF,GFP. The one that will be converted to c1 (phase image) should be listed first. \bfTime prefix\rm: characters in you current filename before the number that indicates the time frame. \bfTime suffix\rm: characters in you current filename after the number that indicates the time frame. \bfXY prefix\rm: characters in you current filename before the number that indicates the xy position. \bfXY suffix\rm: characters in you current filename after the number that indicates the xy position.',
0075 '',
0076 'The program can segment images for snapshots (i.e. if \bft\rm is missing from the filename, \bf[basename]xy[number]c[number].tif\rm) or for one xy position (i.e. if \bfxy\rm is missing from the filename, \bf[basename]t[number]c[number].tif\rm).',
0077 '',
0078 'The program can still rename the images if you leave blank either the prefix or the suffix. If both the prefix and suffix are left blank the number 1 is set as default.',
0079 '',
0080 'Example 1: Suppose your images files currently are named \bfstrain-pos1-p-0001.tif\rm and \bfstrain-pos1-g-0001.tif\rm. Then in order to convert the names to the required naming convention, you will have to type: \bfBasename\rm: strain \bfChannels\rm: -p-,-g- \bfTime prefix\rm: - \bfTime suffix\rm: .tif \bfXY prefix\rm: pos \bfXY suffix\rm: - When you press the Name Conversion button, your image files will then be renamed to \bfstraint0001xy1c1.tif\rm and \bfstraint0001xy1c2.tif\rm.',
0081 '',
0082 'Example 2: Suppose your image files currently are named \bfstrain{\_}0001t{\_}BF.tif\rm and \bfstrain{\_}0001t{\_}GFP.tif\rm. Then in order to convert the names to the required naming convention, you will have to type: \bfBasename\rm: strain \bfChannels\rm: BF,GFP \bfTime prefix\rm: {\_} \bfTime suffix\rm: t{\_} \bfXY prefix\rm: (left empty) \bfXY suffix\rm: (left empty) When you press the Name Conversion button, your image files will then be renamed to \bfstraint001xy1c1.tif\rm and \bfstraint001xy1c2.tif\rm.',
0083 '',
0084 'Keep in mind that the program will search for the specified prefixes and suffixes in your current file names, and use them to identify which number in the current file names correspond for time and which number that correpond for xy position. It is therefore important that you type in as much as possible in the prefixes and suffixes fields so the program is able to uniquely identify the correct numbers.'
0085 }, 'Naming Conversion', 'none', Opt);
0086 
0087 function convert_names_help_CreateFcn(hObject, eventdata, handles)
0088 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0089     set(hObject,'BackgroundColor','white');
0090 end
0091 
0092 function directory_Callback(hObject, eventdata, handles)
0093 function directory_CreateFcn(hObject, eventdata, handles)
0094 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0095     set(hObject,'BackgroundColor','white');
0096 end
0097 
0098 function basename_Callback(hObject, eventdata, handles)
0099 function basename_CreateFcn(hObject, eventdata, handles)
0100 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0101     set(hObject,'BackgroundColor','white');
0102 end
0103 
0104 function channels_Callback(hObject, eventdata, handles)
0105 function channels_CreateFcn(hObject, eventdata, handles)
0106 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0107     set(hObject,'BackgroundColor','white');
0108 end
0109 
0110 function timeBefore_Callback(hObject, eventdata, handles)
0111 function timeBefore_CreateFcn(hObject, eventdata, handles)
0112 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0113     set(hObject,'BackgroundColor','white');
0114 end
0115 
0116 function timeAfter_Callback(hObject, eventdata, handles)
0117 function timeAfter_CreateFcn(hObject, eventdata, handles)
0118 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0119     set(hObject,'BackgroundColor','white');
0120 end
0121 
0122 function xyBefore_Callback(hObject, eventdata, handles)
0123 function xyBefore_CreateFcn(hObject, eventdata, handles)
0124 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0125     set(hObject,'BackgroundColor','white');
0126 end
0127 
0128 function xyAfter_Callback(hObject, eventdata, handles)
0129 function xyAfter_CreateFcn(hObject, eventdata, handles)
0130 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0131     set(hObject,'BackgroundColor','white');
0132 end
0133 
0134 % converts image names
0135 function convert_images_Callback(hObject, eventdata, handles)
0136 tbef = handles.timeBefore.String;
0137 taft = handles.timeAfter.String;
0138 xybef =  handles.xyBefore.String;
0139 xyaft = handles.xyAfter.String;
0140 
0141 % check if they are numbers
0142 
0143 [temp,status] = str2num(tbef)
0144 if status
0145     tbef = temp;
0146 end
0147 
0148 [temp,status] = str2num(taft)
0149 if status
0150     taft = temp;
0151 end
0152 
0153 [temp,status] = str2num(xybef)
0154 if status
0155     xybef = temp;
0156 end
0157 
0158 [temp,status] = str2num(xyaft)
0159 if status
0160     xyaft = temp;
0161 end
0162 
0163 
0164 convertImageNames(handles.directory.String, handles.basename.String, ...
0165     tbef,taft, xybef, xyaft, strsplit(handles.channels.String, ','));
0166 
0167 
0168 function crop_images_CreateFcn(hObject, eventdata, handles)
0169 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0170     set(hObject,'BackgroundColor','white');
0171 end
0172 
0173 function crop_images_Callback(hObject, eventdata, handles)
0174 tmp_name = trackOptiCropMulti(handles.directory.String);
0175 if ~isempty(tmp_name)
0176     handles.directory.String = tmp_name;
0177 end
0178 
0179 
0180 
0181 function segment_images_Callback(hObject, eventdata, handles)
0182 
0183 dirname = handles.directory.String;
0184 if isempty (dirname)
0185     errordlg ('Please select a directory');
0186     return
0187 end
0188 
0189 % load constants
0190 parallel = handles.parallel_flag.Value;
0191 resValue = get(handles.constants_list,'Value');
0192 res = handles.constants_list.String{resValue};
0193 CONST = loadConstants (res,parallel);
0194 
0195 
0196 % set constants
0197 CONST.trackOpti.NEIGHBOR_FLAG = handles.neighbor_flag.Value;
0198 CONST.trackLoci.fluorFlag = handles.fluor_flag.Value;
0199 CONST.parallel.verbose = handles.verbose.Value;
0200 CONST.imAlign.AlignChannel = str2double(handles.alignChan.String);
0201 CONST.trackLoci.numSpots = str2num(handles.fociNum.String);
0202 CONST.getLocusTracks.TimeStep = str2num(handles.timestep.String);
0203 CONST.trackOpti.MIN_CELL_AGE = str2num(handles.cell_age.String);
0204 CONST.trackOpti.REMOVE_STRAY = handles.remove_stray.Value;
0205 CONST.superSeggerOpti.REMOVE_STRAY = handles.remove_stray.Value;
0206 CONST.superSeggerOpti.segmenting_fluorescence = handles.segmenting_fluor.Value;
0207 
0208 clean_flag = handles.clean_flag.Value;
0209 skip = str2double(handles.skip.String);
0210 start_step = str2num(handles.start_step.String);
0211 end_step = str2num(handles.end_step.String);
0212 startEnd = [start_step end_step];
0213 BatchSuperSeggerOpti(dirname, skip, clean_flag, CONST, startEnd);
0214 
0215 
0216 % tries different constants
0217 function try_constants_Callback(hObject, eventdata, handles)
0218 tryDifferentConstants(handles.directory.String);
0219 
0220 % opens superSeggerViewer
0221 function view_button_Callback(hObject, eventdata, handles)
0222 setappdata(0, 'dirname', handles.directory.String);
0223 superSeggerViewerGui();
0224 
0225 % functions to get the state of the constants handles
0226 function pole_snapshot_Callback(hObject, eventdata, handles)
0227 function timestep_Callback(hObject, eventdata, handles)
0228 function timestep_CreateFcn(hObject, eventdata, handles)
0229 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0230     set(hObject,'BackgroundColor','white');
0231 end
0232 function fociNum_Callback(hObject, eventdata, handles)
0233 function fociNum_CreateFcn(hObject, eventdata, handles)
0234 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0235     set(hObject,'BackgroundColor','white');
0236 end
0237 function alignChan_Callback(hObject, eventdata, handles)
0238 function alignChan_CreateFcn(hObject, eventdata, handles)
0239 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0240     set(hObject,'BackgroundColor','white');
0241 end
0242 function remove_stray_Callback(hObject, eventdata, handles)
0243 function verbose_Callback(hObject, eventdata, handles)
0244 function clean_flag_Callback(hObject, eventdata, handles)
0245 function fluor_flag_Callback(hObject, eventdata, handles)
0246 function neighbor_flag_Callback(hObject, eventdata, handles)
0247 function parallel_flag_Callback(hObject, eventdata, handles)
0248 function skip_Callback(hObject, eventdata, handles)
0249 function skip_CreateFcn(hObject, eventdata, handles)
0250 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0251     set(hObject,'BackgroundColor','white');
0252 end
0253 
0254 function cell_age_Callback(hObject, eventdata, handles)
0255 function cell_age_CreateFcn(hObject, eventdata, handles)
0256 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0257     set(hObject,'BackgroundColor','white');
0258 end
0259 
0260 
0261 function constants_list_Callback(hObject, eventdata, handles)
0262 function constants_list_CreateFcn(hObject, eventdata, handles)
0263 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0264     set(hObject,'BackgroundColor','white');
0265 end
0266 
0267 
0268 % --- Executes on button press in segmenting_fluor.
0269 function segmenting_fluor_Callback(hObject, eventdata, handles)
0270 % hObject    handle to segmenting_fluor (see GCBO)
0271 % eventdata  reserved - to be defined in a future version of MATLAB
0272 % handles    structure with handles and user data (see GUIDATA)
0273 
0274 % Hint: get(hObject,'Value') returns toggle state of segmenting_fluor
0275 
0276 
0277 
0278 function start_step_Callback(hObject, eventdata, handles)
0279 % hObject    handle to start_step (see GCBO)
0280 % eventdata  reserved - to be defined in a future version of MATLAB
0281 % handles    structure with handles and user data (see GUIDATA)
0282 
0283 % Hints: get(hObject,'String') returns contents of start_step as text
0284 %        str2double(get(hObject,'String')) returns contents of start_step as a double
0285 
0286 
0287 % --- Executes during object creation, after setting all properties.
0288 function start_step_CreateFcn(hObject, eventdata, handles)
0289 % hObject    handle to start_step (see GCBO)
0290 % eventdata  reserved - to be defined in a future version of MATLAB
0291 % handles    empty - handles not created until after all CreateFcns called
0292 
0293 % Hint: edit controls usually have a white background on Windows.
0294 %       See ISPC and COMPUTER.
0295 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0296     set(hObject,'BackgroundColor','white');
0297 end
0298 
0299 
0300 
0301 function end_step_Callback(hObject, eventdata, handles)
0302 % hObject    handle to end_step (see GCBO)
0303 % eventdata  reserved - to be defined in a future version of MATLAB
0304 % handles    structure with handles and user data (see GUIDATA)
0305 
0306 % Hints: get(hObject,'String') returns contents of end_step as text
0307 %        str2double(get(hObject,'String')) returns contents of end_step as a double
0308 
0309 
0310 % --- Executes during object creation, after setting all properties.
0311 function end_step_CreateFcn(hObject, eventdata, handles)
0312 % hObject    handle to end_step (see GCBO)
0313 % eventdata  reserved - to be defined in a future version of MATLAB
0314 % handles    empty - handles not created until after all CreateFcns called
0315 
0316 % Hint: edit controls usually have a white background on Windows.
0317 %       See ISPC and COMPUTER.
0318 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0319     set(hObject,'BackgroundColor','white');
0320 end

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