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

LEVer 4.0

parent e8458d6e
Branches
Tags v4.0
No related merge requests found
mcc -m ../LEVer.m mcc -m ../LEVer.m
mcc -m ../Segmentor.m
if(isempty(dir('./MTC.exe')))
warndlg('Make sure that MTC.exe is in the same dir as LEVer.exe');
end
\ No newline at end of file
...@@ -10,6 +10,13 @@ global Figures CONSTANTS ...@@ -10,6 +10,13 @@ global Figures CONSTANTS
Figures.time = 1; Figures.time = 1;
oldCellsHandle = [];
oldTreeHandle = [];
if(isfield(Figures,'cells') && isfield(Figures.cells,'handle') && ~isempty(Figures.cells.handle))
oldCellsHandle = Figures.cells.handle;
oldTreeHandle = Figures.tree.handle;
end
Figures.cells.handle = figure(); Figures.cells.handle = figure();
Figures.tree.handle = figure(); Figures.tree.handle = figure();
...@@ -68,6 +75,16 @@ Figures.tree.timeLabel = uicontrol(Figures.tree.handle,... ...@@ -68,6 +75,16 @@ Figures.tree.timeLabel = uicontrol(Figures.tree.handle,...
'String',['Time: ' num2str(Figures.time)]); 'String',['Time: ' num2str(Figures.time)]);
FindLargestTree([],[]); FindLargestTree([],[]);
if(~isempty(oldCellsHandle) && ishandle(oldCellsHandle))
set(oldCellsHandle,'CloseRequestFcn','remove');
close(oldCellsHandle);
end
if(~isempty(oldTreeHandle) && ishandle(oldTreeHandle))
set(oldTreeHandle,'CloseRequestFcn','remove');
close(oldTreeHandle);
end
% DrawTree(1); % DrawTree(1);
% figure(Figures.tree.handle); % figure(Figures.tree.handle);
% %
......
...@@ -31,7 +31,7 @@ end ...@@ -31,7 +31,7 @@ end
filterIndexImage = 0; filterIndexImage = 0;
matFile = []; matFile = [];
matPath = []; matFilePath = [];
imageFile = []; imageFile = [];
imagePath = []; imagePath = [];
imageDataset = []; imageDataset = [];
...@@ -56,39 +56,40 @@ if(~isempty(Figures)) ...@@ -56,39 +56,40 @@ if(~isempty(Figures))
end end
oldCONSTANTS = CONSTANTS; oldCONSTANTS = CONSTANTS;
InitializeConstants();
%find the first image %find the first image
imageFilter = [settings.imagePath '*.TIF']; imageFilter = [settings.imagePath '*.TIF'];
while (filterIndexImage==0) while (filterIndexImage==0)
fprintf('\nSelect first .TIF image...\n\n'); fprintf('\nSelect first .TIF image...\n\n');
[imageFile,imagePath,filterIndexImage] = uigetfile(imageFilter,'Open First Image in dataset: '); [settings.imageFile,settings.imagePath,filterIndexImage] = uigetfile(imageFilter,'Open First Image in dataset: ');
if (filterIndexImage==0) if (filterIndexImage==0)
CONSTANTS = oldCONSTANTS; CONSTANTS = oldCONSTANTS;
return return
end end
end end
index = strfind(imageFile,'_t'); index = strfind(settings.imageFile,'_t');
frameT = '001'; frameT = '001';
if (~isempty(index) && filterIndexImage~=0) if (~isempty(index) && filterIndexImage~=0)
CONSTANTS.rootImageFolder = imagePath; CONSTANTS.rootImageFolder = settings.imagePath;
imageDataset = imageFile(1:(index(length(index))-1)); imageDataset = settings.imageFile(1:(index(length(index))-1));
CONSTANTS.imageDatasetName = imageDataset; CONSTANTS.imageDatasetName = imageDataset;
CONSTANTS.datasetName = imageDataset; CONSTANTS.datasetName = imageDataset;
index2 = strfind(imageFile,'.'); index2 = strfind(settings.imageFile,'.');
CONSTANTS.imageSignificantDigits = index2 - index - 2; CONSTANTS.imageSignificantDigits = index2 - index - 2;
fileName=[CONSTANTS.rootImageFolder imageDataset '_t' SignificantDigits(1) '.TIF']; fileName=[CONSTANTS.rootImageFolder imageDataset '_t' SignificantDigits(1) '.TIF'];
end end
while (isempty(index) || ~exist(fileName,'file')) while (isempty(index) || ~exist(fileName,'file'))
fprintf(['Image file name not in correct format: ' CONSTANTS.datasetName '_t' frameT '.TIF\nPlease choose another...\n']); fprintf(['Image file name not in correct format: ' CONSTANTS.datasetName '_t' frameT '.TIF\nPlease choose another...\n']);
[imageFile,imagePath,filterIndexImage] = uigetfile(settings.imagePath,'Open First Image'); [settings.imageFile,settings.imagePath,filterIndexImage] = uigetfile(settings.imagePath,'Open First Image');
if(filterIndexImage==0) if(filterIndexImage==0)
CONSTANTS = oldCONSTANTS; CONSTANTS = oldCONSTANTS;
return return
end end
index = strfind(imageFile,'t'); index = strfind(imageFile,'t');
CONSTANTS.rootImageFolder = [imagePath '\']; CONSTANTS.rootImageFolder = [settings.imagePath '\'];
imageDataset = imageFile(1:(index(length(index))-2)); imageDataset = imageFile(1:(index(length(index))-2));
fileName=[CONSTANTS.rootImageFolder imageDataSet '_t' SignificantDigits(t) '.TIF']; fileName=[CONSTANTS.rootImageFolder imageDataSet '_t' SignificantDigits(t) '.TIF'];
end end
...@@ -96,12 +97,13 @@ end ...@@ -96,12 +97,13 @@ end
answer = questdlg('Run Segmentation and Tracking or Use Existing Data?','Data Source','Segment & Track','Existing','Existing'); answer = questdlg('Run Segmentation and Tracking or Use Existing Data?','Data Source','Segment & Track','Existing','Existing');
switch answer switch answer
case 'Segment & Track' case 'Segment & Track'
save('LEVerSettings.mat','settings');
InitializeConstants(); InitializeConstants();
SegAndTrack(); SegAndTrack();
case 'Existing' case 'Existing'
while(~goodLoad) while(~goodLoad)
fprintf('Select .mat data file...\n'); fprintf('Select .mat data file...\n');
[matFile,matPath,filterIndexMatFile] = uigetfile([settings.matFilePath '*.mat'],... [settings.matFile,settings.matFilePath,filterIndexMatFile] = uigetfile([settings.matFilePath '*.mat'],...
'Open Data'); 'Open Data');
if (filterIndexMatFile==0) if (filterIndexMatFile==0)
...@@ -124,7 +126,7 @@ switch answer ...@@ -124,7 +126,7 @@ switch answer
imageSignificantDigits = CONSTANTS.imageSignificantDigits; imageSignificantDigits = CONSTANTS.imageSignificantDigits;
try try
load([matPath matFile]); load([settings.matFilePath settings.matFile]);
fprintf('\nFile open.\n\n'); fprintf('\nFile open.\n\n');
catch exception catch exception
%DEBUG -- Uncomment %DEBUG -- Uncomment
...@@ -132,21 +134,16 @@ switch answer ...@@ -132,21 +134,16 @@ switch answer
end end
end end
if(~isfield(CONSTANTS,'rootImageFolder'))
CONSTANTS.rootImageFolder = rootImageFolder; CONSTANTS.rootImageFolder = rootImageFolder;
end
if(~isfield(CONSTANTS,'imageSignificantDigits'))
CONSTANTS.imageSignificantDigits = imageSignificantDigits; CONSTANTS.imageSignificantDigits = imageSignificantDigits;
end InitializeConstants();
if(exist('objHulls','var')) if(exist('objHulls','var'))
fprintf('Converting File...'); fprintf('Converting File...');
InitializeConstants();
ConvertTrackingData(objHulls,gConnect); ConvertTrackingData(objHulls,gConnect);
fprintf('\nFile Converted.\n'); fprintf('\nFile Converted.\n');
CONSTANTS.datasetName = strtok(matFile,' '); CONSTANTS.datasetName = strtok(matFile,' ');
save([matPath CONSTANTS.datasetName '_LEVer'],... save([settings.matFilePath CONSTANTS.datasetName '_LEVer'],...
'CellFamilies','CellHulls','CellTracks','HashedCells','Costs','CONSTANTS'); 'CellFamilies','CellHulls','CellTracks','HashedCells','Costs','CONSTANTS');
fprintf(['New file saved as:\n' CONSTANTS.datasetName '_LEVer.mat']); fprintf(['New file saved as:\n' CONSTANTS.datasetName '_LEVer.mat']);
goodLoad = 1; goodLoad = 1;
...@@ -159,9 +156,6 @@ switch answer ...@@ -159,9 +156,6 @@ switch answer
end end
%save out settings %save out settings
settings.matFilePath = matPath;
settings.imageFile = imageFile;
settings.imagePath = [imagePath '\'];
save('LEVerSettings.mat','settings'); save('LEVerSettings.mat','settings');
Figures.time = 1; Figures.time = 1;
...@@ -176,7 +170,7 @@ if ( ~isfield(CellHulls, 'imagePixels') ) ...@@ -176,7 +170,7 @@ if ( ~isfield(CellHulls, 'imagePixels') )
fprintf('Adding Image Pixel Information...\n'); fprintf('Adding Image Pixel Information...\n');
AddImagePixelsField(); AddImagePixelsField();
fprintf('Image Information Added\n'); fprintf('Image Information Added\n');
save([matPath matFile],... save([settings.matFilePath settings.matFile],...
'CellFamilies','CellHulls','CellTracks','HashedCells','Costs','CONSTANTS'); 'CellFamilies','CellHulls','CellTracks','HashedCells','Costs','CONSTANTS');
end end
...@@ -186,12 +180,4 @@ if (~strcmp(imageDataset,CONSTANTS.datasetName)) ...@@ -186,12 +180,4 @@ if (~strcmp(imageDataset,CONSTANTS.datasetName))
warndlg({'Image file name does not match .mat dataset name' '' 'LEVer may display cells incorectly!'},'Name mismatch','modal'); warndlg({'Image file name does not match .mat dataset name' '' 'LEVer may display cells incorectly!'},'Name mismatch','modal');
end end
% if(~isempty(Figures) && ishandle(Figures.cells.handle))
% close(Figures.cells.handle);
% end
% Figures.time = 1;
% LogAction(['Opened file ' matFile],[],[]);
end end
...@@ -15,7 +15,7 @@ for i=1:size ...@@ -15,7 +15,7 @@ for i=1:size
%Get all the possible hulls that could have been connected %Get all the possible hulls that could have been connected
childHullID = CellTracks(childTrackID).hulls(1); childHullID = CellTracks(childTrackID).hulls(1);
if(childHullID>length(Costs)),continue,end if(childHullID>length(Costs) || childHullID==0),continue,end
parentHullCandidates = find(Costs(:,childHullID)); parentHullCandidates = find(Costs(:,childHullID));
if(isempty(parentHullCandidates)),continue,end if(isempty(parentHullCandidates)),continue,end
......
...@@ -8,7 +8,7 @@ global CellFamilies CellTracks HashedCells CONSTANTS Costs CellHulls Figures ...@@ -8,7 +8,7 @@ global CellFamilies CellTracks HashedCells CONSTANTS Costs CellHulls Figures
if (exist('LEVerSettings.mat','file')~=0) if (exist('LEVerSettings.mat','file')~=0)
load('LEVerSettings.mat'); load('LEVerSettings.mat');
else else
settings.matPath = ['.\' CONSTANTS.datasetName '_LEVer_edits.mat']; settings.matFilePath = '.\';
end end
%let the user know that this might take a while %let the user know that this might take a while
......
...@@ -8,7 +8,7 @@ global CellFamilies CellTracks HashedCells CONSTANTS Costs CellHulls Figures ...@@ -8,7 +8,7 @@ global CellFamilies CellTracks HashedCells CONSTANTS Costs CellHulls Figures
if (exist('LEVerSettings.mat','file')~=0) if (exist('LEVerSettings.mat','file')~=0)
load('LEVerSettings.mat'); load('LEVerSettings.mat');
else else
settings.matPath = ['.\' CONSTANTS.datasetName '_LEVer.mat']; settings.matFilePath = '.\';
end end
goodSave = 1; goodSave = 1;
...@@ -16,21 +16,25 @@ goodSave = 1; ...@@ -16,21 +16,25 @@ goodSave = 1;
while(goodSave) while(goodSave)
time = clock; time = clock;
fprintf('Choose a folder to save current data...\n'); fprintf('Choose a folder to save current data...\n');
[FileName,PathName,FilterIndex] = uiputfile('.mat','Save edits',... if(strcmp(settings.matFilePath,'.\'))
[settings.matFile,settings.matFilePath,FilterIndex] = uiputfile('.mat','Save edits',...
[CONSTANTS.datasetName '_LEVer.mat']);
else
[settings.matFile,settings.matFilePath,FilterIndex] = uiputfile('.mat','Save edits',...
[CONSTANTS.datasetName ' edits ' num2str(time(1)) '-' num2str(time(2),'%02d') '-' num2str(time(3),'%02d') '_LEVer.mat']); [CONSTANTS.datasetName ' edits ' num2str(time(1)) '-' num2str(time(2),'%02d') '-' num2str(time(3),'%02d') '_LEVer.mat']);
end
if (FilterIndex~=0) if (FilterIndex~=0)
save([PathName FileName],... save([settings.matFilePath settings.matFile],...
'CellFamilies','CellTracks','HashedCells','CONSTANTS','Costs','CellHulls'); 'CellFamilies','CellTracks','HashedCells','CONSTANTS','Costs','CellHulls');
goodSave = 0; goodSave = 0;
end end
end end
settings.matPath = [FileName PathName];
save('LEVerSettings.mat','settings'); save('LEVerSettings.mat','settings');
%no longer "dirty" %no longer "dirty"
set(Figures.tree.menuHandles.saveMenu,'Enable','off'); set(Figures.tree.menuHandles.saveMenu,'Enable','off');
set(Figures.cells.menuHandles.saveMenu,'Enable','off'); set(Figures.cells.menuHandles.saveMenu,'Enable','off');
LogAction(['Saved As: ' FileName],[],[]); LogAction(['Saved As: ' settings.matFile],[],[]);
end end
...@@ -43,6 +43,8 @@ for i=1:step:numberOfImages ...@@ -43,6 +43,8 @@ for i=1:step:numberOfImages
pause(1) pause(1)
end end
fprintf('Please wait...');
cellSegments = GetDarkConnectedHulls(cellSegments); cellSegments = GetDarkConnectedHulls(cellSegments);
save ( ['SegObjs_' CONSTANTS.datasetName '.mat'],'cellSegments'); save ( ['SegObjs_' CONSTANTS.datasetName '.mat'],'cellSegments');
WriteSegData(cellSegments,CONSTANTS.datasetName); WriteSegData(cellSegments,CONSTANTS.datasetName);
......
...@@ -2,6 +2,7 @@ function trackIDs = TrackSplitHulls(newHulls, forceTracks, COM) ...@@ -2,6 +2,7 @@ function trackIDs = TrackSplitHulls(newHulls, forceTracks, COM)
global CONSTANTS CellHulls HashedCells global CONSTANTS CellHulls HashedCells
t = CellHulls(newHulls(1)).time; t = CellHulls(newHulls(1)).time;
trackIDs = [CellHulls(newHulls).trackID];
if ( t <= 1 ) if ( t <= 1 )
return; return;
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment