Home > SuperSegger > trainingConstants > modifyConstValuesGUI.m

modifyConstValuesGUI

PURPOSE ^

modifyConstValuesGUI : gui to interactively modify parameters in constants.

SYNOPSIS ^

function varargout = modifyConstValuesGUI(varargin)

DESCRIPTION ^

 modifyConstValuesGUI : gui to interactively modify parameters in constants.

 Copyright (C) 2016 Wiggins Lab
 Written by Stella Styliandou.
 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 = modifyConstValuesGUI(varargin)
0002 % modifyConstValuesGUI : gui to interactively modify parameters in constants.
0003 %
0004 % Copyright (C) 2016 Wiggins Lab
0005 % Written by Stella Styliandou.
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 % Last Modified by GUIDE v2.5 17-May-2016 11:22:51
0023 
0024 % Begin initialization code - DO NOT EDIT
0025 
0026 gui_Singleton = 1;
0027 gui_State = struct('gui_Name',mfilename, ...
0028     'gui_Singleton',  gui_Singleton, ...
0029     'gui_OpeningFcn', @modifyConstValuesGUI_OpeningFcn, ...
0030     'gui_OutputFcn',  @modifyConstValuesGUI_OutputFcn, ...
0031     'gui_LayoutFcn',  [] , ...
0032     'gui_Callback',   []);
0033 if nargin && ischar(varargin{1})
0034     gui_State.gui_Callback = str2func(varargin{1});
0035 end
0036 
0037 if nargout
0038     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0039 else
0040     gui_mainfcn(gui_State, varargin{:});
0041 end
0042 % End initialization code - DO NOT EDIT
0043 
0044 % --- Executes just before modifyConstValuesGUI is made visible.
0045 function modifyConstValuesGUI_OpeningFcn(hObject, eventdata, handles, varargin)
0046 % This function has no output args, see OutputFcn.
0047 % hObject    handle to figure
0048 % eventdata  reserved - to be defined in a future version of MATLAB
0049 % handles    structure with handles and user data (see GUIDATA)
0050 % varargin   command line arguments to modifyConstValuesGUI (see VARARGIN)
0051 global settings_mod;
0052 
0053 handles.output = hObject;
0054 set(handles.figure1, 'units', 'normalized', 'position', [0.1 0.1 0.8 0.8])
0055 load_listbox(handles)
0056 handles.directory.String = 'Image filename';
0057 handles.display_flag = 3;
0058 settings_mod.data = [];
0059 settings_mod.phaseImage = [];
0060 settings_mod.axisFlag = 0;
0061 settings_mod.loadDirectory = [];
0062 
0063 % phase : 1, mask : 2, seg : 3
0064 handles.seg_radio.Value = 1;
0065 initialize_all(handles)
0066 
0067 guidata(hObject, handles);
0068 settings_mod.handles = handles;
0069 updateUI(handles);
0070 
0071 % UIWAIT makes modifyConstValuesGUI wait for user response (see UIRESUME)
0072 % uiwait(handles.figure1);
0073 
0074 
0075 % --- Outputs from this function are returned to the command line.
0076 function varargout = modifyConstValuesGUI_OutputFcn(hObject, eventdata, handles)
0077 % varargout  cell array for returning output args (see VARARGOUT);
0078 % hObject    handle to figure
0079 % eventdata  reserved - to be defined in a future version of MATLAB
0080 % handles    structure with handles and user data (see GUIDATA)
0081 % Get default command line output from handles structure
0082 varargout{1} = handles.output;
0083 
0084 
0085 
0086 % --- Executes on button press in try_const.
0087 function try_const_Callback(hObject, eventdata, handles)
0088 % hObject    handle to try_const (see GCBO)
0089 % eventdata  reserved - to be defined in a future version of MATLAB
0090 % handles    structure with handles and user data (see GUIDATA)
0091 
0092 dirname = (handles.directory.String);
0093 if ~strcmp(dirname(end-3:end), '.tif')
0094     errordlg('Please select an image');
0095 end
0096 tryDifferentConstants(dirname, []);
0097 
0098 function load_listbox(handles)
0099 [~,resFlags] = getConstantsList();
0100 [sorted_names,sorted_index] = sortrows(resFlags');
0101 handles.file_names = sorted_names;
0102 handles.sorted_index = sorted_index;
0103 set(handles.constants_list,'String',handles.file_names,'Value',1)
0104 
0105 % --- Executes on selection change in constants_list.
0106 function constants_list_Callback(hObject, eventdata, handles)
0107 % hObject    handle to constants_list (see GCBO)
0108 % eventdata  reserved - to be defined in a future version of MATLAB
0109 % handles    structure with handles and user data (see GUIDATA)
0110 
0111 % Hints: contents = cellstr(get(hObject,'String')) returns constants_list contents as cell array
0112 %        contents{get(hObject,'Value')} returns selected item from constants_list
0113 getValuesFromConst(handles)
0114 
0115 function getValuesFromConst(handles)
0116 global settings_mod;
0117 resValue = get(handles.constants_list,'Value');
0118 res = handles.constants_list.String{resValue};
0119 CONST = loadConstants (res,0,0);
0120 handles.cut_intensity.Value = CONST.superSeggerOpti.CUT_INT;
0121 handles.max_wid.Value = CONST.superSeggerOpti.MAX_WIDTH ;
0122 handles.mask_th2.Value = CONST.superSeggerOpti.THRESH2;
0123 handles.mask_th1.Value = CONST.superSeggerOpti.THRESH1 ;
0124 handles.magic_thresh.Value = CONST.superSeggerOpti.MAGIC_THRESHOLD;
0125 handles.magic_radius.Value = CONST.superSeggerOpti.MAGIC_RADIUS ;
0126 handles.maxLengRegOpti.String = CONST.regionOpti.MIN_LENGTH ;
0127 handles.gaus_wid.Value = CONST.superSeggerOpti.SMOOTH_WIDTH;
0128 update_text_values (handles)
0129 settings_mod.CONST = CONST;
0130 
0131 
0132 function putValuesInConstants(handles)
0133 global settings_mod
0134 resValue = get(handles.constants_list,'Value');
0135 res = handles.constants_list.String{resValue};
0136 CONST = loadConstants (res,0,0);
0137 CONST.superSeggerOpti.CUT_INT = handles.cut_intensity.Value;
0138 CONST.superSeggerOpti.MAX_WIDTH = handles.max_wid.Value;
0139 CONST.superSeggerOpti.THRESH2 = handles.mask_th2.Value;
0140 CONST.superSeggerOpti.THRESH1 = handles.mask_th1.Value;
0141 CONST.superSeggerOpti.MAGIC_THRESHOLD = handles.magic_thresh.Value;
0142 CONST.superSeggerOpti.MAGIC_RADIUS = handles.magic_radius.Value;
0143 CONST.regionOpti.MIN_LENGTH = handles.maxLengRegOpti.Value;
0144 CONST.superSeggerOpti.SMOOTH_WIDTH = handles.gaus_wid.Value;
0145 settings_mod.CONST = CONST;
0146 
0147 % --- Executes during object creation, after setting all properties.
0148 function constants_list_CreateFcn(hObject, eventdata, handles)
0149 % hObject    handle to constants_list (see GCBO)
0150 % eventdata  reserved - to be defined in a future version of MATLAB
0151 % handles    empty - handles not created until after all CreateFcns called
0152 
0153 % Hint: listbox controls usually have a white background on Windows.
0154 %       See ISPC and COMPUTER.
0155 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0156     set(hObject,'BackgroundColor','white');
0157 end
0158 
0159 
0160 function directory_Callback(hObject, eventdata, handles)
0161 % hObject    handle to directory (see GCBO)
0162 % eventdata  reserved - to be defined in a future version of MATLAB
0163 % handles    structure with handles and user data (see GUIDATA)
0164 
0165 % Hints: get(hObject,'String') returns contents of directory as text
0166 %        str2double(get(hObject,'String')) returns contents of directory as a double
0167 
0168 
0169 % --- Executes during object creation, after setting all properties.
0170 function directory_CreateFcn(hObject, eventdata, handles)
0171 % hObject    handle to directory (see GCBO)
0172 % eventdata  reserved - to be defined in a future version of MATLAB
0173 % handles    empty - handles not created until after all CreateFcns called
0174 
0175 % Hint: edit controls usually have a white background on Windows.
0176 %       See ISPC and COMPUTER.
0177 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0178     set(hObject,'BackgroundColor','white');
0179 end
0180 
0181 
0182 % --- Executes on button press in save.
0183 function save_Callback(hObject, eventdata, handles)
0184 % hObject    handle to save (see GCBO)
0185 % eventdata  reserved - to be defined in a future version of MATLAB
0186 % handles    structure with handles and user data (see GUIDATA)
0187 global settings_mod;
0188 putValuesInConstants(handles)
0189 CONST = settings_mod.CONST;
0190 [FileName,PathName,~] = uiputfile('newConstantsName.mat');
0191 if FileName~=0
0192     save([PathName,FileName], '-struct', 'CONST');
0193 end
0194 
0195 
0196 % --- If Enable == 'on', executes on mouse press in 5 pixel border.
0197 % --- Otherwise, executes on mouse press in 5 pixel border or over constants_list.
0198 function constants_list_ButtonDownFcn(hObject, eventdata, handles)
0199 % hObject    handle to constants_list (see GCBO)
0200 % eventdata  reserved - to be defined in a future version of MATLAB
0201 % handles    structure with handles and user data (see GUIDATA)
0202 
0203 
0204 % --------------------------------------------------------------------
0205 function image_folder_ClickedCallback(hObject, eventdata, handles)
0206 % hObject    handle to image_folder (see GCBO)
0207 % eventdata  reserved - to be defined in a future version of MATLAB
0208 % handles    structure with handles and user data (see GUIDATA)
0209 [imageName,directoryName , ~] = uigetfile('*.tif', 'Pick an image file');
0210 if imageName~=0
0211     handles.directory.String = [directoryName,filesep,imageName];
0212     settings_mod.phaseImage = imread(handles.directory.String);
0213     axes(handles.viewport_modify);
0214     imshow(settings_mod.phaseImage,[]);
0215 end
0216 
0217 
0218 function updateUI(handles)
0219 global settings_mod;
0220 if ~isempty(settings_mod.data)
0221     if handles.display_flag == 3
0222         showSegDataPhase(settings_mod.data, handles.viewport_modify);
0223     elseif handles.display_flag == 2
0224         axes(handles.viewport_modify);
0225         imshow(settings_mod.data.mask_bg,[])
0226     elseif handles.display_flag == 1
0227         axes(handles.viewport_modify);
0228         imshow(settings_mod.data.phase,[])
0229     end
0230 end
0231 if numel(handles.viewport_modify.Children) > 0
0232     set(handles.viewport_modify.Children(1),'ButtonDownFcn',@imageButtonDownFcn);
0233     hold on;
0234 end
0235 
0236 % --- Executes on slider movement.
0237 function slider3_Callback(hObject, eventdata, handles)
0238 % hObject    handle to slider3 (see GCBO)
0239 % eventdata  reserved - to be defined in a future version of MATLAB
0240 % handles    structure with handles and user data (see GUIDATA)
0241 
0242 % Hints: get(hObject,'Value') returns position of slider
0243 %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
0244 
0245 
0246 % --- Executes during object creation, after setting all properties.
0247 function slider3_CreateFcn(hObject, eventdata, handles)
0248 % hObject    handle to slider3 (see GCBO)
0249 % eventdata  reserved - to be defined in a future version of MATLAB
0250 % handles    empty - handles not created until after all CreateFcns called
0251 
0252 % Hint: slider controls usually have a light gray background.
0253 if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0254     set(hObject,'BackgroundColor',[.9 .9 .9]);
0255 end
0256 
0257 
0258 % --- Executes on slider movement.
0259 function magic_thresh_Callback(hObject, eventdata, handles)
0260 % hObject    handle to magic_thresh (see GCBO)
0261 % eventdata  reserved - to be defined in a future version of MATLAB
0262 % handles    structure with handles and user data (see GUIDATA)
0263 
0264 % Hints: get(hObject,'Value') returns position of slider
0265 %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
0266 val = hObject.Value;
0267 hObject.Value = round(val);
0268 handles.magic_val.String = num2str(hObject.Value);
0269 
0270 
0271 % --- Executes during object creation, after setting all properties.
0272 function magic_thresh_CreateFcn(hObject, eventdata, handles)
0273 % hObject    handle to magic_thresh (see GCBO)
0274 % eventdata  reserved - to be defined in a future version of MATLAB
0275 % handles    empty - handles not created until after all CreateFcns called
0276 
0277 % Hint: slider controls usually have a light gray background.
0278 if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0279     set(hObject,'BackgroundColor',[.9 .9 .9]);
0280 end
0281 
0282 % --- Executes on slider movement.
0283 function cut_intensity_Callback(hObject, eventdata, handles)
0284 % hObject    handle to cut_intensity (see GCBO)
0285 % eventdata  reserved - to be defined in a future version of MATLAB
0286 % handles    structure with handles and user data (see GUIDATA)
0287 
0288 % Hints: get(hObject,'Value') returns position of slider
0289 %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
0290 val = hObject.Value;
0291 hObject.Value = round(val);
0292 handles.cut_int_text.String = num2str(handles.cut_intensity.Value);
0293 
0294 % --- Executes during object creation, after setting all properties.
0295 function cut_intensity_CreateFcn(hObject, eventdata, handles)
0296 % hObject    handle to cut_intensity (see GCBO)
0297 % eventdata  reserved - to be defined in a future version of MATLAB
0298 % handles    empty - handles not created until after all CreateFcns called
0299 
0300 % Hint: slider controls usually have a light gray background.
0301 if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0302     set(hObject,'BackgroundColor',[.9 .9 .9]);
0303 end
0304 
0305 
0306 % --- Executes on slider movement.
0307 function mask_th1_Callback(hObject, eventdata, handles)
0308 % hObject    handle to mask_th1 (see GCBO)
0309 % eventdata  reserved - to be defined in a future version of MATLAB
0310 % handles    structure with handles and user data (see GUIDATA)
0311 
0312 % Hints: get(hObject,'Value') returns position of slider
0313 %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
0314 val = hObject.Value;
0315 hObject.Value = round(val);
0316 handles.mask_th1_text.String = num2str(hObject.Value);
0317 
0318 % --- Executes during object creation, after setting all properties.
0319 function mask_th1_CreateFcn(hObject, eventdata, handles)
0320 % hObject    handle to mask_th1 (see GCBO)
0321 % eventdata  reserved - to be defined in a future version of MATLAB
0322 % handles    empty - handles not created until after all CreateFcns called
0323 % Hint: slider controls usually have a light gray background.
0324 if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0325     set(hObject,'BackgroundColor',[.9 .9 .9]);
0326 end
0327 
0328 function update_text_values (handles)
0329 handles.magic_val.String = num2str(handles.magic_thresh.Value);
0330 handles.magic_rad_text.String = num2str(handles.magic_radius.Value);
0331 handles.cut_int_text.String = num2str(handles.cut_intensity.Value);
0332 handles.mask_th1_text.String = num2str(handles.mask_th1.Value);
0333 handles.mask_th2_text.String = num2str(handles.mask_th2.Value);
0334 handles.max_wid_text.String = num2str(handles.max_wid.Value);
0335 handles.gaus_wid_text.String = num2str(handles.gaus_wid.Value);
0336 
0337 % --- Executes on slider movement.
0338 function mask_th2_Callback(hObject, eventdata, handles)
0339 % hObject    handle to mask_th2 (see GCBO)
0340 % eventdata  reserved - to be defined in a future version of MATLAB
0341 % handles    structure with handles and user data (see GUIDATA)
0342 
0343 % Hints: get(hObject,'Value') returns position of slider
0344 %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
0345 val = hObject.Value;
0346 hObject.Value = round(val);
0347 handles.mask_th2_text.String = num2str(hObject.Value);
0348 
0349 % --- Executes during object creation, after setting all properties.
0350 function mask_th2_CreateFcn(hObject, eventdata, handles)
0351 % hObject    handle to mask_th2 (see GCBO)
0352 % eventdata  reserved - to be defined in a future version of MATLAB
0353 % handles    empty - handles not created until after all CreateFcns called
0354 
0355 % Hint: slider controls usually have a light gray background.
0356 if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0357     set(hObject,'BackgroundColor',[.9 .9 .9]);
0358 end
0359 
0360 % --- Executes on slider movement.
0361 function magic_radius_Callback(hObject, eventdata, handles)
0362 % hObject    handle to magic_radius (see GCBO)
0363 % eventdata  reserved - to be defined in a future version of MATLAB
0364 % handles    structure with handles and user data (see GUIDATA)
0365 
0366 % Hints: get(hObject,'Value') returns position of slider
0367 %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
0368 val = round(hObject.Value);
0369 hObject.Value =val;
0370 handles.magic_rad_text.String = num2str(hObject.Value);
0371 
0372 % --- Executes during object creation, after setting all properties.
0373 function magic_radius_CreateFcn(hObject, eventdata, handles)
0374 % hObject    handle to magic_radius (see GCBO)
0375 % eventdata  reserved - to be defined in a future version of MATLAB
0376 % handles    empty - handles not created until after all CreateFcns called
0377 
0378 % Hint: slider controls usually have a light gray background.
0379 if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0380     set(hObject,'BackgroundColor',[.9 .9 .9]);
0381 end
0382 
0383 
0384 % --- Executes on slider movement.
0385 function min_thresh_Callback(hObject, eventdata, handles)
0386 % hObject    handle to min_thresh (see GCBO)
0387 % eventdata  reserved - to be defined in a future version of MATLAB
0388 % handles    structure with handles and user data (see GUIDATA)
0389 
0390 % Hints: get(hObject,'Value') returns position of slider
0391 %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
0392 val = hObject.Value;
0393 hObject.Value = round(val);
0394 handles.min_thresh_text.String = num2str(hObject.Value);
0395 
0396 
0397 % --- Executes during object creation, after setting all properties.
0398 function min_thresh_CreateFcn(hObject, eventdata, handles)
0399 % hObject    handle to min_thresh (see GCBO)
0400 % eventdata  reserved - to be defined in a future version of MATLAB
0401 % handles    empty - handles not created until after all CreateFcns called
0402 
0403 % Hint: slider controls usually have a light gray background.
0404 if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0405     set(hObject,'BackgroundColor',[.9 .9 .9]);
0406 end
0407 
0408 
0409 
0410 % --- Executes during object creation, after setting all properties.
0411 function max_thresh_CreateFcn(hObject, eventdata, handles)
0412 % hObject    handle to max_thresh (see GCBO)
0413 % eventdata  reserved - to be defined in a future version of MATLAB
0414 % handles    empty - handles not created until after all CreateFcns called
0415 
0416 % Hint: slider controls usually have a light gray background.
0417 if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0418     set(hObject,'BackgroundColor',[.9 .9 .9]);
0419 end
0420 
0421 
0422 % --- Executes on slider movement.
0423 function max_wid_Callback(hObject, eventdata, handles)
0424 % hObject    handle to max_wid (see GCBO)
0425 % eventdata  reserved - to be defined in a future version of MATLAB
0426 % handles    structure with handles and user data (see GUIDATA)
0427 
0428 % Hints: get(hObject,'Value') returns position of slider
0429 %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
0430 val = round(hObject.Value);
0431 hObject.Value=val;
0432 handles.max_wid_text.String = num2str(hObject.Value);
0433 
0434 % --- Executes during object creation, after setting all properties.
0435 function max_wid_CreateFcn(hObject, eventdata, handles)
0436 % hObject    handle to max_wid (see GCBO)
0437 % eventdata  reserved - to be defined in a future version of MATLAB
0438 % handles    empty - handles not created until after all CreateFcns called
0439 
0440 % Hint: slider controls usually have a light gray background.
0441 if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0442     set(hObject,'BackgroundColor',[.9 .9 .9]);
0443     set(hObject,'Max',50,'Min',5)
0444     hObject.Value = get(hObject,'Min');
0445     handles.max_wid_text.String = num2str(hObject.Value);
0446 end
0447 
0448 
0449 
0450 % --- Executes on slider movement.
0451 function max_thresh_Callback(hObject, eventdata, handles)
0452 % hObject    handle to max_thresh (see GCBO)
0453 % eventdata  reserved - to be defined in a future version of MATLAB
0454 % handles    structure with handles and user data (see GUIDATA)
0455 
0456 % Hints: get(hObject,'Value') returns position of slider
0457 %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
0458 val = round(hObject.Value);
0459 hObject.Value=val;
0460 handles.max_thresh_text.String = num2str(hObject.Value);
0461 guidata(hObject,handles);
0462 
0463 
0464 function initialize_all (handles)
0465 % magic thresh
0466 set(handles.magic_thresh,'Max',30,'Min',0)
0467 set(handles.magic_thresh,'SliderStep',[0.1 1])
0468 
0469 % magic radius
0470 set(handles.magic_radius,'Max',15,'Min',0.1)
0471 set(handles.magic_radius,'SliderStep',[0.1 1])
0472 
0473 % cut_intensity
0474 set(handles.cut_intensity,'Max',150,'Min',10)
0475 set(handles.cut_intensity,'SliderStep',[0.1 1])
0476 
0477 % gaussian smooth/blur width
0478 set(handles.gaus_wid,'Max',1,'Min',0.1)
0479 set(handles.gaus_wid,'SliderStep',[0.1 1])
0480 
0481 % mask_th1
0482 set(handles.mask_th1,'Max',100,'Min',10)
0483 set(handles.mask_th1,'SliderStep',[0.1 1])
0484 
0485 % mask_th2
0486 set(handles.mask_th2,'Max',100,'Min',0)
0487 set(handles.mask_th2,'SliderStep',[0.1 1])
0488 
0489 % maximum width
0490 set(handles.max_wid,'Max',20,'Min',5)
0491 set(handles.max_wid,'SliderStep',[0.1 1])
0492 
0493 getValuesFromConst(handles)
0494 
0495 
0496 % --- Executes on button press in run.
0497 function run_Callback(hObject, eventdata, handles)
0498 % hObject    handle to run (see GCBO)
0499 % eventdata  reserved - to be defined in a future version of MATLAB
0500 % handles    structure with handles and user data (see GUIDATA)
0501 
0502 global settings_mod;
0503 putValuesInConstants(handles)
0504 CONST = settings_mod.CONST;
0505 imageName = handles.directory.String;
0506 if numel(imageName)<3 || ~strcmp(imageName(end-3:end), '.tif')
0507     image_folder_ClickedCallback([],[],handles);
0508 end
0509 phaseIm = imread(handles.directory.String);
0510 
0511 set(gcf,'Pointer','watch');
0512 settings_mod.data = superSeggerOpti(phaseIm,[],0,CONST);
0513 
0514 guidata(hObject, handles);
0515 updateUI(handles);
0516 set(gcf,'Pointer','arrow');
0517 
0518 function max_width_regOpt_Callback(hObject, eventdata, handles)
0519 % hObject    handle to max_width_regOpt (see GCBO)
0520 % eventdata  reserved - to be defined in a future version of MATLAB
0521 % handles    structure with handles and user data (see GUIDATA)
0522 
0523 % Hints: get(hObject,'String') returns contents of max_width_regOpt as text
0524 %        str2double(get(hObject,'String')) returns contents of max_width_regOpt as a double
0525 
0526 % --- Executes during object creation, after setting all properties.
0527 function max_width_regOpt_CreateFcn(hObject, eventdata, handles)
0528 % hObject    handle to max_width_regOpt (see GCBO)
0529 % eventdata  reserved - to be defined in a future version of MATLAB
0530 % handles    empty - handles not created until after all CreateFcns called
0531 
0532 % Hint: edit controls usually have a white background on Windows.
0533 %       See ISPC and COMPUTER.
0534 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0535     set(hObject,'BackgroundColor','white');
0536 end
0537 
0538 function maxLengRegOpti_Callback(hObject, eventdata, handles)
0539 % hObject    handle to maxLengRegOpti (see GCBO)
0540 % eventdata  reserved - to be defined in a future version of MATLAB
0541 % handles    structure with handles and user data (see GUIDATA)
0542 
0543 % Hints: get(hObject,'String') returns contents of maxLengRegOpti as text
0544 %        str2double(get(hObject,'String')) returns contents of maxLengRegOpti as a double
0545 
0546 % --- Executes during object creation, after setting all properties.
0547 function maxLengRegOpti_CreateFcn(hObject, eventdata, handles)
0548 % hObject    handle to maxLengRegOpti (see GCBO)
0549 % eventdata  reserved - to be defined in a future version of MATLAB
0550 % handles    empty - handles not created until after all CreateFcns called
0551 
0552 % Hint: edit controls usually have a white background on Windows.
0553 %       See ISPC and COMPUTER.
0554 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0555     set(hObject,'BackgroundColor','white');
0556 end
0557 
0558 % --- Executes on mouse press over axes background.
0559 function imageButtonDownFcn(hObject, eventdata, handles)
0560 % hObject    handle to viewport_modify (see GCBO)
0561 % eventdata  reserved - to be defined in a future version of MATLAB
0562 % handles    structure with handles and user data (see GUIDATA)
0563 global settings_mod;
0564 updateUI(settings_mod.handles);
0565 point = round(eventdata.IntersectionPoint(1:2));
0566 if isempty(settings_mod.data)
0567     errordlg('Press find segments first');
0568 end
0569 if ~isfield(settings_mod.data,'regs')
0570     settings_mod.data = intMakeRegs( settings_mod.data, settings_mod.CONST, [], [] );
0571 end
0572 
0573 data = settings_mod.data;
0574 ss = size(data.phase);
0575 tmp = zeros([51,51]);
0576 tmp(26,26) = 1;
0577 tmp = 8000-double(bwdist(tmp));
0578 rmin = max([1,point(2)-25]);
0579 rmax = min([ss(1),point(2)+25]);
0580 cmin = max([1,point(1)-25]);
0581 cmax = min([ss(2),point(1)+25]);
0582 rrind = rmin:rmax;
0583 ccind = cmin:cmax;
0584 pointSize = [numel(rrind),numel(ccind)];
0585 tmp = tmp(26-point(2)+rrind,26-point(1)+ccind).*data.mask_cell(rrind,ccind);
0586 [~,ind] = max( tmp(:) );
0587 
0588 [sub1, sub2] = ind2sub( pointSize, ind );
0589 ii = data.regs.regs_label(sub1-1+rmin,sub2-1+cmin);
0590 hold on;
0591 plot( sub2-1+cmin, sub1-1+rmin, 'o', 'MarkerFaceColor', 'g' );
0592 
0593 if ii ~=0
0594     settings_mod.handles.width_length_image.String =  (['length : ', num2str(data.regs.info(ii,1)), ...
0595         ' max width : ',  num2str(data.regs.info(ii,4))]);
0596 else
0597     disp ('empty')
0598 end
0599 
0600 
0601 % --------------------------------------------------------------------
0602 function help_button_ClickedCallback(hObject, eventdata, handles)
0603 % hObject    handle to help_button (see GCBO)
0604 % eventdata  reserved - to be defined in a future version of MATLAB
0605 % handles    structure with handles and user data (see GUIDATA)
0606 
0607 message = ({'SuperSeggerOpti - Modifying Constants Module'
0608     '------------------------------------------------------------'
0609     '   '
0610     'Hover over the names to get more information about the different variables. Choose a constant, change the slider''s values and click run to see the result. Save the constants in the settings_mod folder to use them immediately.  '
0611     '   '
0612     });
0613 
0614 msgbox(message,'HELP');
0615 
0616 
0617 % --- Executes on button press in phase_radio.
0618 function phase_radio_Callback(hObject, eventdata, handles)
0619 % hObject    handle to phase_radio (see GCBO)
0620 % eventdata  reserved - to be defined in a future version of MATLAB
0621 % handles    structure with handles and user data (see GUIDATA)
0622 if get(hObject,'Value') == 1
0623     handles.display_flag = 1;
0624     handles.mask_radio.Value = 0;
0625     handles.seg_radio.Value = 0;
0626 end
0627 guidata(hObject, handles);
0628 updateUI(handles);
0629 % Hint: get(hObject,'Value') returns toggle state of phase_radio
0630 
0631 
0632 % --- Executes on button press in mask_radio.
0633 function mask_radio_Callback(hObject, eventdata, handles)
0634 % hObject    handle to mask_radio (see GCBO)
0635 % eventdata  reserved - to be defined in a future version of MATLAB
0636 % handles    structure with handles and user data (see GUIDATA)
0637 if get(hObject,'Value') == 1
0638     handles.display_flag = 2;
0639     handles.seg_radio.Value = 0;
0640     handles.phase_radio.Value = 0;
0641 end
0642 guidata(hObject, handles);
0643 updateUI(handles);
0644 % Hint: get(hObject,'Value') returns toggle state of mask_radio
0645 
0646 % --- Executes on button press in seg_radio.
0647 function seg_radio_Callback(hObject, eventdata, handles)
0648 % hObject    handle to seg_radio (see GCBO)
0649 % eventdata  reserved - to be defined in a future version of MATLAB
0650 % handles    structure with handles and user data (see GUIDATA)
0651 if get(hObject,'Value') == 1
0652     handles.display_flag = 3;
0653     handles.mask_radio.Value = 0;
0654     handles.phase_radio.Value = 0;
0655 end
0656 guidata(hObject, handles);
0657 updateUI(handles);
0658 % Hint: get(hObject,'Value') returns toggle state of seg_radio
0659 
0660 % --- Executes on slider movement.
0661 function gaus_wid_Callback(hObject, eventdata, handles)
0662 % hObject    handle to gaus_wid (see GCBO)
0663 % eventdata  reserved - to be defined in a future version of MATLAB
0664 % handles    structure with handles and user data (see GUIDATA)
0665 
0666 % Hints: get(hObject,'Value') returns position of slider
0667 %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
0668 handles.gaus_wid_text.String = num2str(hObject.Value);
0669 
0670 
0671 % --- Executes during object creation, after setting all properties.
0672 function gaus_wid_CreateFcn(hObject, eventdata, handles)
0673 % hObject    handle to gaus_wid (see GCBO)
0674 % eventdata  reserved - to be defined in a future version of MATLAB
0675 % handles    empty - handles not created until after all CreateFcns called
0676 
0677 % Hint: slider controls usually have a light gray background.
0678 if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0679     set(hObject,'BackgroundColor',[.9 .9 .9]);
0680 end

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