Skip to content

Commit

Permalink
modify constants gui and loadConstants now loads anything in the sett…
Browse files Browse the repository at this point in the history
…ings folder
  • Loading branch information
stellastyl committed May 5, 2016
1 parent 6956ef4 commit d375454
Show file tree
Hide file tree
Showing 18 changed files with 1,433 additions and 146 deletions.
Binary file added batch/modifyConstValuesGUI.fig
Binary file not shown.
643 changes: 643 additions & 0 deletions batch/modifyConstValuesGUI.m

Large diffs are not rendered by default.

Binary file modified batch/superSeggerGui.fig
Binary file not shown.
105 changes: 39 additions & 66 deletions batch/superSeggerGui.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,19 @@

function superSeggerGui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
load_listbox(handles)
set(handles.figure1, 'units', 'normalized', 'position', [0.25 0.2 0.35 0.7])
guidata(hObject, handles);


function load_listbox(handles)
[possibleConstants] = getConstantsList();
[sorted_names,sorted_index] = sortrows({possibleConstants.resFlag}');
handles.file_names = sorted_names;
handles.sorted_index = sorted_index;
set(handles.constants_list,'String',handles.file_names,...
'Value',1)

function varargout = superSeggerGui_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;

Expand Down Expand Up @@ -105,40 +114,12 @@ function segment_images_Callback(hObject, eventdata, handles)
return
end

if (handles.ec60.Value + handles.ec100.Value + handles.pa100.Value + ...
handles.pa60.Value + ...
handles.bay60.Value+handles.eclb60.Value) > 1
errordlg ('Please select only one constant.')
return
end

text = '';

if handles.ec60.Value;
text = '60XEc';
elseif handles.ec100.Value;
text = '100XEc';
elseif handles.pa100.Value;
text = '100XPa';
elseif handles.pa60.Value;
text = '60XPa';
elseif handles.eclb60.Value;
text = '60XEcLB';
elseif handles.bay60.Value;
text = '60XBay';
end


% get values for constants
% load constants
parallel = handles.parallel_flag.Value;
if ~strcmp(text,'');
CONST = loadConstantsNN(text, parallel);
elseif isfield(handles,'CONST') && ~isempty(handles.CONST)
CONST = handles.CONST;
else
errordlg ('No constants selected');
return
end
resValue = get(handles.constants_list,'Value');
res = handles.constants_list.String{resValue};
CONST = loadConstantsNN (res,parallel);


% set constants
CONST.trackOpti.NEIGHBOR_FLAG = handles.neighbor_flag.Value;
Expand All @@ -151,7 +132,6 @@ function segment_images_Callback(hObject, eventdata, handles)
CONST.trackOpti.MIN_CELL_AGE = str2num(handles.cell_age.String);
CONST.trackOpti.REMOVE_STRAY = handles.remove_stray.Value;


linkVal = get(handles.link_list,'Value');
if linkVal == 1
CONST.trackOpti.linkFun = @multiAssignmentFastOnlyOverlap;
Expand All @@ -176,37 +156,8 @@ function bthai60_Callback(hObject, eventdata, handles)

% tries different constants
function try_constants_Callback(hObject, eventdata, handles)
resFlags = {};
if handles.ec60.Value;
resFlags{end+1} = '60XEc';
end
if handles.ec100.Value;
resFlags{end+1} = '100XEc';
end
if handles.pa100.Value;
resFlags{end+1} = '100XPa';
end
if handles.pa60.Value;
resFlags{end+1} = '60XPa';
end
if handles.bay60.Value;
resFlags{end+1} = '60XBay';
end
if handles.eclb60.Value;
resFlags{end+1} = '60XEcLB';
end
tryDifferentConstants(handles.directory.String);

tryDifferentConstants(handles.directory.String, resFlags);

% loads constants that user selects
function loadConstMine_Callback(hObject, eventdata, handles)
if get(hObject,'Value')
[filename,path] = uigetfile('*.mat', 'Pick a superSegger constants file');
handles.CONST = load([path,'/',filename]);
else
handles.CONST = [];
end
guidata(hObject, handles)


% opens superSeggerViewer
Expand Down Expand Up @@ -250,8 +201,6 @@ function cell_age_CreateFcn(hObject, eventdata, handles)
end




% --- Executes on selection change in constants_list.
function link_list_Callback(hObject, eventdata, handles)
% hObject handle to constants_list (see GCBO)
Expand All @@ -269,6 +218,30 @@ function link_list_CreateFcn(hObject, eventdata, handles)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: listbox 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 selection change in constants_list.
function constants_list_Callback(hObject, eventdata, handles)
% hObject handle to constants_list (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns constants_list contents as cell array
% contents{get(hObject,'Value')} returns selected item from constants_list


% --- Executes during object creation, after setting all properties.
function constants_list_CreateFcn(hObject, eventdata, handles)
% hObject handle to constants_list (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
Expand Down
53 changes: 28 additions & 25 deletions batch/tryDifferentConstants.m
Original file line number Diff line number Diff line change
@@ -1,63 +1,66 @@
function tryDifferentConstants(dirname,resFlags)
function data = tryDifferentConstants(filename,resFlags)
% tryDifferentConstants : displays images of cells segmented with
% different constants set in resFlags. It only does the initial
% segmentation (only the doSeg part) and not the regions decisions,
% linking and error resolution that come after.
% Images need to have the right naming convention - if they don't use
% Images need to have the right naming convention - if they don't use
% renameImages before this script.
%
% INPUT :
% dirname : directory with images
% dirname : directory with images or filename of image (must be .tif)
% OUTPUT :
% data.SegFile: _seg file from segmentation
% .res: constants resolution for each seg file
%
% Copyright (C) 2016 Wiggins Lab
% Copyright (C) 2016 Wiggins Lab
% Written by 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/>.

% modify this accoding to the constants you want to try
if nargin < 1 || isempty( dirname ) || strcmp(dirname,'.')
dirname = pwd;
if nargin < 1 || isempty( filename ) || strcmp(filename,'.')
filename = pwd;
end

if ~exist('resFlags','var') || isempty(resFlags)
%resFlags = {'60XEc','60XA','60XEcLB',...
% '60XPa','60XPaM','60XPaM2','60XBthai','100XEc','100XPa'};
resFlags = {'60XEc','100XEc','60XEcLB','60XBay','60XPa','100XPa'};
[possibleConstants] = getConstantsList();
resFlags = {possibleConstants.resFlag};
end



dirname = fixDir(dirname);
images = dir([dirname,'*c1*.tif']);


if isempty (images)
disp('no images found in the directory with c1.tif.Select an image');
[lastPhaseImage,dirname , ~] = uigetfile('*.tif', 'Pick an image file');
if lastPhaseImage == 0
return;
if strcmp(filename(end-3:end), '.tif')
tempImage = imread(filename);
else % it is a folder
filename = fixDir(filename);
images = dir([filename,'*c1*.tif']);
if isempty (images)
disp('no images found in the directory with c1.tif.Select an image');
[lastPhaseImage,filename , ~] = uigetfile('*.tif', 'Pick an image file');
if lastPhaseImage == 0
return;
end
else
lastPhaseImage = images(end).name;
end
else
lastPhaseImage = images(end).name;
tempImage = imread([filename,lastPhaseImage]);
end

phase = intCropImage (imread([dirname,lastPhaseImage]));
phase = intCropImage (tempImage);


numFlags = numel(resFlags);
numCols = 3;
numRows = ceil(numFlags / numCols);
Expand Down
Loading

0 comments on commit d375454

Please sign in to comment.