Skip to content
Snippets Groups Projects
Commit 3e88b62a authored by Eric Wait's avatar Eric Wait
Browse files

Fixed Reopen and Globals

parent 26613aed
No related branches found
No related tags found
No related merge requests found
function ClearAllGlobals()
global CellFamilies CellTracks HashedCells CONSTANTS CellHulls Costs GraphEdits
global CachedCostMatrix ConnectedDist CellPhenotypes SegmentationEdits ReplayEditActions
CellFamilies = [];
CellTracks = [];
HashedCells = [];
CONSTANTS = [];
CellHulls = [];
Costs = [];
GraphEdits = [];
CachedCostMatrix = [];
ConnectedDist = [];
CellPhenotypes = [];
SegmentationEdits = [];
ReplayEditActions = [];
end
\ No newline at end of file
function bOpened = ImageFileDialog()
global CONSTANTS
oldCONSTANTS = CONSTANTS;
load('LEVerSettings.mat');
%find the first image
......@@ -13,17 +11,16 @@ bOpened = 0;
while ( ~bOpened )
[settings.imageFile,settings.imagePath,filterIndexImage] = uigetfile(imageFilter,'Open First Image in dataset: ');
if (filterIndexImage==0)
CONSTANTS = oldCONSTANTS;
return
end
[sigDigits imageDataset] = Helper.ParseImageName(settings.imageFile);
if ~isfield(CONSTANTS,'datasetName')
CONSTANTS.datasetName = imageDataset;
Load.AddConstant('datasetName', imageDataset, 1);
end
if (strcmp(imageDataset,[CONSTANTS.datasetName '_']))
CONSTANTS.datasetName = [CONSTANTS.datasetName '_'];
Load.AddConstant('datasetName', [CONSTANTS.datasetName '_'], 1);
bOpened = 1;
elseif (~strcmp(imageDataset,CONSTANTS.datasetName))
answer = questdlg('Image does not match dataset would you like to choose another?','Image Selection','Yes','No','Close LEVer','Yes');
......@@ -31,7 +28,7 @@ while ( ~bOpened )
case 'Yes'
continue;
case 'No'
CONSTANTS.imageNamePattern = '';
Load.AddConstant('imageNamePattern', '', 1);
bOpened = 1;
case 'Close LEVer'
return
......@@ -40,9 +37,9 @@ while ( ~bOpened )
end
end
CONSTANTS.rootImageFolder = settings.imagePath;
CONSTANTS.imageSignificantDigits = sigDigits;
CONSTANTS.matFullFile = [settings.matFilePath settings.matFile];
Load.AddConstant('rootImageFolder', settings.imagePath, 1);
Load.AddConstant('imageSignificantDigits', sigDigits, 1);
Load.AddConstant('matFullFile', [settings.matFilePath settings.matFile], 1);
bOpened = 1;
end
......
......@@ -29,8 +29,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function opened = OpenData()
global Figures Colors CONSTANTS GraphEdits ReplayEditActions SegmentationEdits softwareVersion
global Figures Colors CONSTANTS softwareVersion
if(isempty(Figures))
fprintf('LEVer ver %s\n***DO NOT DISTRIBUTE***\n\n', softwareVersion);
......@@ -61,6 +60,7 @@ if (~isfield(settings,'matFilePath'))
settings.matFilePath = '.\';
end
save('LEVerSettings.mat','settings');
goodLoad = 0;
opened = 0;
......@@ -89,12 +89,9 @@ if(~isempty(Figures))
end
end
% Clear edits when new data set is opened
SegmentationEdits.newHulls = [];
SegmentationEdits.changedHulls = [];
oldCONSTANTS = CONSTANTS;
GraphEdits = [];
ReplayEditActions = [];
Helper.ClearAllGlobals();
answer = questdlg('Run Segmentation and Tracking or Use Existing Data?','Data Source','Segment & Track','Existing','Existing');
switch answer
......@@ -105,13 +102,14 @@ switch answer
load('LEVerSettings.mat');
Load.AddConstant('version',softwareVersion,1);
CONSTANTS.cellType = [];
Load.AddConstant('cellType', [], 1);
Load.InitializeConstants();
errOpen = Segmentation.SegAndTrack();
if(~errOpen)
opened = 1;
else
CONSTANTS = oldCONSTANTS;
return
end
case 'Existing'
......@@ -136,16 +134,18 @@ switch answer
save('LEVerSettings.mat','settings');
CONSTANTS.matFullFile = [settings.matFilePath settings.matFile];
Load.AddConstant('matFullFile', [settings.matFilePath settings.matFile], 1);
if (~isfield(CONSTANTS,'imageNamePattern') || exist(Helper.GetFullImagePath(1),'file')~=2)
if (~Helper.ImageFileDialog())
CONSTANTS = oldCONSTANTS;
return
end
end
if(exist('objHulls','var'))
errordlg('Data too old to run with this version of LEVer');
CONSTANTS = oldCONSTANTS;
return
end
......
......@@ -37,7 +37,7 @@ phenoScratch.phenoColors = hsv(length(CellPhenotypes.descriptions));
phenoScratch.phenoLegendSet = zeros(length(CellPhenotypes.descriptions),1);
if(~isfield(CONSTANTS,'timeResolution'))
CONSTANTS.timeResolution = 10;
Load.AddConstant('timeResolution', 10, 1);
end
if(isempty(CellFamilies(familyID).tracks)),return,end
......
......@@ -25,13 +25,12 @@
function LEVer()
global Figures softwareVersion
global Figures softwareVersion ReplayEditActions CONSTANTS
%if LEVer is already opened, save state just in case the User cancels the
%open
previousOpened = 0;
if(~isempty(Figures))
Editor.History('Push');
previousOpened = 1;
end
......@@ -42,7 +41,9 @@ if(Load.OpenData())
elseif(previousOpened)
try
Editor.History('Top');
UI.InitializeFigures();
%UI.InitializeFigures();
temp = load(CONSTANTS.matFullFile,'ReplayEditActions');
ReplayEditActions = temp.ReplayEditActions;
catch err
end
end
......
......@@ -29,7 +29,6 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [objs features levels] = Segmentor(tStart,tStep,tEnd,imageAlpha,rootImageFolder,imageNamePattern)
global CONSTANTS
objs=[];
features = [];
......@@ -44,8 +43,8 @@ try
fprintf(1,'%s\n',rootImageFolder);
fprintf(1,'%s\n',imageNamePattern);
CONSTANTS.rootImageFolder = rootImageFolder;
CONSTANTS.imageNamePattern = imageNamePattern;
Load.AddConstant('rootImageFolder', rootImageFolder, 1);
Load.AddConstant('imageNamePattern', imageNamePattern, 1);
numImages = tEnd/tStep;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment