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

LEVer 3.4

parent a12cf511
No related branches found
No related tags found
No related merge requests found
Showing
with 334 additions and 79 deletions
function AddHullToTrack(hullID,trackID,previousHullID) function AddHullToTrack(hullID,trackID,previousHullID)
% function AddHullToTrack(time,hullID,trackID,previousTime,previousHullID) % function AddHullToTrack(hullID,trackID,previousHullID)
%The hullID will be added to the track and hashed at the given time %The hullID will be added to the track
% %
%If trackID is given, previousTime & previousHullID are not used. Safe to %If trackID is given, previousHullID is not used. Safe to
%send [] or vice versa. %send [] for either trackID or previousHullID.
%Prereq to leave trackID empty - Track to be added to exists and the %Prereq to leave trackID empty - Track to be added to exists and the
%previousHullID at previousTime exists in that track. Also, it has been %previousHullID exists in that track. Also, it has been
%removed from any previous track assosiation. %removed from any previous track assosiation.
%--Eric Wait %--Eric Wait
......
function AddSingleHullToTrack(oldTrackID,newTrackID)
% AddSingleHullToTrack(oldTrackID,newTrackID)
% This function is indended for the oldTrack to be just a single hull,
% typicaly when a hull has been split and now that new hull is being added
% to a track. This function takes the hull and merges it into the
% newTrack. The parent and child relationships of the newTrack will be
% maintained.
%--Eric Wait
global CellTracks HashedCells CellFamilies Figures
if(~isempty(CellTracks(oldTrackID).parentTrack) && ...
~isempty(CellTracks(oldTrackID).childrenTracks) && ...
1~=length(CellTracks(oldTrackID).hulls))
error([num2str(oldTrackID) ' is not a single hull track or has a parent/child']);
end
if(CellTracks(oldTrackID).startTime<CellTracks(newTrackID).startTime)
%old before new
if(~isempty(CellTracks(newTrackID).parentTrack))
moveMitosisUp(CellTracks(oldTrackID).startTime,...
CellTracks(newTrackID).siblingTrack);
end
AddHullToTrack(CellTracks(oldTrackID).hulls(1),newTrackID,[]);
elseif(CellTracks(oldTrackID).startTime>CellTracks(newTrackID).endTime)
%new before old
if(~isempty(CellTracks(newTrackID).childrenTracks))
moveMitosisDown(CellTracks(oldTrackID).startTime,newTrackID);
end
AddHullToTrack(CellTracks(oldTrackID).hulls(1),newTrackID,[]);
else
%old within new
if(~isempty(find([HashedCells{Figures.time}.trackID]==newTrackID,1)))
SwapTrackLabels(CellTracks(oldTrackID).startTime,oldTrackID,newTrackID);
else
AddHullToTrack(CellTracks(oldTrackID).hulls(1),newTrackID,[]);
end
end
%clean out old track/family
familyID = CellTracks(oldTrackID).familyID;
CellFamilies(familyID).rootTrackID = [];
CellFamilies(familyID).tracks = [];
CellFamilies(familyID).startTime = [];
CellFamilies(familyID).endTime = [];
CellTracks(oldTrackID).familyID = [];
CellTracks(oldTrackID).parentTrack = [];
CellTracks(oldTrackID).siblingTrack = [];
CellTracks(oldTrackID).childrenTracks = [];
CellTracks(oldTrackID).hulls = [];
CellTracks(oldTrackID).startTime = [];
CellTracks(oldTrackID).endTime = [];
CellTracks(oldTrackID).timeOfDeath = [];
CellTracks(oldTrackID).color = [];
end
function moveMitosisUp(time,siblingTrackID)
global CellTracks
%remove hulls from parent
hash = time - CellTracks(CellTracks(siblingTrackID).parentTrack).startTime + 1;
hulls = CellTracks(CellTracks(siblingTrackID).parentTrack).hulls(hash:end);
CellTracks(CellTracks(siblingTrackID).parentTrack).hulls(hash:end) = 0;
RehashCellTracks(CellTracks(siblingTrackID).parentTrack,CellTracks(CellTracks(siblingTrackID).parentTrack).startTime);
%add hulls to sibling
for i=1:length(hulls)
AddHullToTrack(hulls(i),siblingTrackID,[]);
end
end
function moveMitosisDown(time,trackID)
global CellTracks CellFamilies
remove = 0;
children = {};
for i=1:length(CellTracks(trackID).childrenTracks)
if(CellTracks(CellTracks(trackID).childrenTracks(i)).endTime <= time)
remove = 1;
break
end
hash = time - CellTracks(CellTracks(trackID).childrenTracks(i)).startTime + 1;
if(0<hash)
children(i).startTime = CellTracks(CellTracks(trackID).childrenTracks(i)).startTime;
children(i).hulls = CellTracks(CellTracks(trackID).childrenTracks(i)).hulls(1:hash);
end
end
if(remove)
RemoveChildren(trackID);
else
for i=1:length(children)
familyID = NewCellFamily(children(i).hulls(1),children(i).startTime);
newTrackID = CellFamilies(familyID).rootTrackID;
for j=2:length(children(i).hulls)
AddHullToTrack(children(i).hulls(j),newTrackID,[]);
end
end
end
end
...@@ -17,7 +17,7 @@ function ChangeLabel(time,oldTrackID,newTrackID) ...@@ -17,7 +17,7 @@ function ChangeLabel(time,oldTrackID,newTrackID)
%--Eric Wait %--Eric Wait
global CellTracks CellFamilies CellHulls global CellTracks CellHulls
bothHaveChildren = 0;%flag to deal with conflicting children bothHaveChildren = 0;%flag to deal with conflicting children
%flags to deal with position of tracks relitive to one another %flags to deal with position of tracks relitive to one another
...@@ -58,7 +58,7 @@ if(oldEmptied) ...@@ -58,7 +58,7 @@ if(oldEmptied)
if(oldBeforeNew) if(oldBeforeNew)
%deal with any children %deal with any children
if(~isempty(CellTracks(oldTrackID).childrenTracks)) if(~isempty(CellTracks(oldTrackID).childrenTracks))
dropChildren(oldTrackID); RemoveChildren(oldTrackID);
end end
if(~isempty(CellTracks(newTrackID).siblingTrack) && ... if(~isempty(CellTracks(newTrackID).siblingTrack) && ...
isempty(find(CellTracks(oldTrackID).childrenTracks==CellTracks(newTrackID).siblingTrack, 1))) isempty(find(CellTracks(oldTrackID).childrenTracks==CellTracks(newTrackID).siblingTrack, 1)))
...@@ -79,7 +79,7 @@ if(oldEmptied) ...@@ -79,7 +79,7 @@ if(oldEmptied)
CellTracks(newTrackID).childrenTracks = []; CellTracks(newTrackID).childrenTracks = [];
CellTracks(oldTrackID).siblingTrack = []; CellTracks(oldTrackID).siblingTrack = [];
else else
dropChildren(newTrackID); RemoveChildren(newTrackID);
end end
moveChildren(oldTrackID,newTrackID); moveChildren(oldTrackID,newTrackID);
elseif(~isempty(CellTracks(newTrackID).childrenTracks)) elseif(~isempty(CellTracks(newTrackID).childrenTracks))
...@@ -90,7 +90,7 @@ if(oldEmptied) ...@@ -90,7 +90,7 @@ if(oldEmptied)
CellTracks(newTrackID).childrenTracks = []; CellTracks(newTrackID).childrenTracks = [];
CellTracks(oldTrackID).siblingTrack = []; CellTracks(oldTrackID).siblingTrack = [];
else else
dropChildren(newTrackID); RemoveChildren(newTrackID);
end end
elseif(~isempty(CellTracks(oldTrackID).childrenTracks)) elseif(~isempty(CellTracks(oldTrackID).childrenTracks))
moveChildren(oldTrackID,newTrackID); moveChildren(oldTrackID,newTrackID);
...@@ -103,8 +103,10 @@ if(oldEmptied) ...@@ -103,8 +103,10 @@ if(oldEmptied)
%clean up other fields %clean up other fields
RemoveTrackFromFamily(oldTrackID); RemoveTrackFromFamily(oldTrackID);
CellTracks(oldTrackID).familyID = [];
CellTracks(oldTrackID).parentTrack = []; CellTracks(oldTrackID).parentTrack = [];
CellTracks(oldTrackID).siblingTrack = []; CellTracks(oldTrackID).siblingTrack = [];
CellTracks(oldTrackID).hulls = [];
CellTracks(oldTrackID).startTime = []; CellTracks(oldTrackID).startTime = [];
CellTracks(oldTrackID).endTime = []; CellTracks(oldTrackID).endTime = [];
CellTracks(oldTrackID).color = []; CellTracks(oldTrackID).color = [];
...@@ -114,41 +116,31 @@ else %the old track still exists in some fasion ...@@ -114,41 +116,31 @@ else %the old track still exists in some fasion
%the last hull from the old track has been moved over and had %the last hull from the old track has been moved over and had
%children %children
if(CellHulls(lastOldHull).time<CellTracks(newTrackID).endTime) if(CellHulls(lastOldHull).time<CellTracks(newTrackID).endTime)
dropChildren(oldTrackID); RemoveChildren(oldTrackID);
elseif(CellHulls(lastOldHull).time>=CellTracks(newTrackID).endTime) elseif(CellHulls(lastOldHull).time>=CellTracks(newTrackID).endTime)
if(~isempty(CellTracks(newTrackID).childrenTracks)) if(~isempty(CellTracks(newTrackID).childrenTracks))
dropChildren(newTrackID); RemoveChildren(newTrackID);
end end
moveChildren(oldTrackID,newTrackID); moveChildren(oldTrackID,newTrackID);
end end
elseif(isempty(find(CellTracks(oldTrackID).hulls==lastOldHull, 1)) &&... elseif(isempty(find(CellTracks(oldTrackID).hulls==lastOldHull, 1)) &&...
CellHulls(lastOldHull).time>CellTracks(newTrackID).endTime &&... CellHulls(lastOldHull).time>CellTracks(newTrackID).endTime &&...
~isempty(CellTracks(newTrackID).childrenTracks)) ~isempty(CellTracks(newTrackID).childrenTracks))
dropChildren(newTrackID); RemoveChildren(newTrackID);
end end
end end
end end
function dropChildren(trackID)
%remove children from tree
global CellTracks
familyIDs = [];
while ~isempty(CellTracks(trackID).childrenTracks)
familyIDs = [familyIDs RemoveFromTree(CellTracks(CellTracks(trackID).childrenTracks(1)).startTime,CellTracks(trackID).childrenTracks(1),'no')];
end
CellTracks(trackID).childrenTracks = [];
%run processNewborns on them
ProcessNewborns(familyIDs);
end
function moveChildren(oldTrackID,newTrackID) function moveChildren(oldTrackID,newTrackID)
global CellTracks global CellTracks
if(isempty(CellTracks(oldTrackID).childrenTracks)) if(isempty(CellTracks(oldTrackID).childrenTracks))
%no children %no children
elseif(isempty(CellTracks(newTrackID).childrenTracks)) elseif(isempty(CellTracks(newTrackID).childrenTracks))
CellTracks(newTrackID).childrenTracks = CellTracks(oldTrackID).childrenTracks; CellTracks(newTrackID).childrenTracks = CellTracks(oldTrackID).childrenTracks;
for i=1:length(CellTracks(newTrackID).childrenTracks)
CellTracks(CellTracks(newTrackID).childrenTracks(i)).parentTrack = newTrackID;
end
if(CellTracks(oldTrackID).familyID ~= CellTracks(newTrackID).familyID) if(CellTracks(oldTrackID).familyID ~= CellTracks(newTrackID).familyID)
for i=1:length(CellTracks(oldTrackID).childrenTracks) for i=1:length(CellTracks(oldTrackID).childrenTracks)
ChangeTrackAndChildrensFamily(CellTracks(oldTrackID).familyID,CellTracks(newTrackID).familyID,CellTracks(oldTrackID).childrenTracks(i)); ChangeTrackAndChildrensFamily(CellTracks(oldTrackID).familyID,CellTracks(newTrackID).familyID,CellTracks(oldTrackID).childrenTracks(i));
......
...@@ -33,6 +33,7 @@ function trackList = traverseTree(newFamilyID,trackID) ...@@ -33,6 +33,7 @@ function trackList = traverseTree(newFamilyID,trackID)
%will add the tracks to the new family along the way %will add the tracks to the new family along the way
global CellFamilies CellTracks global CellFamilies CellTracks
RemoveTrackFromFamily(trackID);
%add track %add track
CellFamilies(newFamilyID).tracks(end+1) = trackID; CellFamilies(newFamilyID).tracks(end+1) = trackID;
...@@ -50,6 +51,4 @@ if(~isempty(CellTracks(trackID).childrenTracks)) ...@@ -50,6 +51,4 @@ if(~isempty(CellTracks(trackID).childrenTracks))
trackList = [trackList traverseTree(newFamilyID, CellTracks(trackID).childrenTracks(i))]; trackList = [trackList traverseTree(newFamilyID, CellTracks(trackID).childrenTracks(i))];
end end
end end
RemoveTrackFromFamily(trackID);
end end
...@@ -45,7 +45,7 @@ CellTracks(childTrackID).parentTrack = parentTrackID; ...@@ -45,7 +45,7 @@ CellTracks(childTrackID).parentTrack = parentTrackID;
oldFamilyID = CellTracks(childTrackID).familyID; oldFamilyID = CellTracks(childTrackID).familyID;
newFamilyID = CellTracks(siblingTrackID).familyID; newFamilyID = CellTracks(siblingTrackID).familyID;
CellTracks(childTrackID).familyID = newFamilyID; % CellTracks(childTrackID).familyID = newFamilyID;
ChangeTrackAndChildrensFamily(oldFamilyID,newFamilyID,childTrackID); ChangeTrackAndChildrensFamily(oldFamilyID,newFamilyID,childTrackID);
......
...@@ -50,6 +50,11 @@ elseif(~isempty(find([HashedCells{time}.trackID]==newTrackID,1))) ...@@ -50,6 +50,11 @@ elseif(~isempty(find([HashedCells{time}.trackID]==newTrackID,1)))
case 'Cancel' case 'Cancel'
return return
end end
elseif(isempty(CellTracks(trackID).parentTrack) && isempty(CellTracks(trackID).childrenTracks) && 1==length(CellTracks(trackID).hulls))
hullID = CellTracks(trackID).hulls(1);
AddSingleHullToTrack(trackID,newTrackID);
History('Push');
LogAction('Added hull to track',hullID,newTrackID);
else else
ChangeLabel(time,trackID,newTrackID); ChangeLabel(time,trackID,newTrackID);
History('Push'); History('Push');
......
...@@ -36,24 +36,25 @@ end ...@@ -36,24 +36,25 @@ end
%loop through the data %loop through the data
for i=2:length(objHulls) for i=2:length(objHulls)
if(i<=length(CellHulls)+1 || ~isempty(CellHulls(i).time)) % if(i<=length(CellHulls)+1 || ~isempty(CellHulls(i).time))
addHull(i); % addHull(i);
end
% CellHulls(i).time = objHulls(i).t;
% CellHulls(i).points = objHulls(i).pts;
% CellHulls(i).centerOfMass = objHulls(i).COM;
% CellHulls(i).indexPixels = objHulls(i).indPixels;
% CellHulls(i).deleted = 0;
%
% if objHulls(i).inID == 0
% NewCellFamily(i,objHulls(i).t);
% else
% AddHullToTrack(i,[],objHulls(i).inID);
% end % end
CellHulls(i).time = objHulls(i).t;
CellHulls(i).points = objHulls(i).pts;
CellHulls(i).centerOfMass = objHulls(i).COM;
CellHulls(i).indexPixels = objHulls(i).indPixels;
CellHulls(i).deleted = 0;
if objHulls(i).inID == 0
NewCellFamily(i,objHulls(i).t);
else
AddHullToTrack(i,[],objHulls(i).inID);
end
end end
%create the family trees %create the family trees
ProcessNewborns(1:length(CellFamilies)); ProcessNewborns(1:length(CellFamilies));
end
function addHull(num) function addHull(num)
CellHulls(num).time = objHulls(num).t; CellHulls(num).time = objHulls(num).t;
...@@ -62,22 +63,21 @@ ProcessNewborns(1:length(CellFamilies)); ...@@ -62,22 +63,21 @@ ProcessNewborns(1:length(CellFamilies));
CellHulls(num).indexPixels = objHulls(num).indPixels; CellHulls(num).indexPixels = objHulls(num).indPixels;
CellHulls(num).deleted = 0; CellHulls(num).deleted = 0;
if objHulls(num).inID > length(CellHulls)+1 if(objHulls(num).inID > length(CellHulls)+1)
if objHulls(objHulls(num).inID).inID == 0 if(objHulls(objHulls(num).inID).inID == 0)
NewCellFamily(num,objHulls(objHulls(num).inID).t); NewCellFamily(num,objHulls(objHulls(num).inID).t);
else else
addHull(objHulls(num).inID); addHull(objHulls(num).inID);
end end
end end
if objHulls(num).inID == 0 if(objHulls(num).inID == 0)
NewCellFamily(num,objHulls(num).t); NewCellFamily(num,objHulls(num).t);
else else
AddHullToTrack(num,[],objHulls(num).inID); AddHullToTrack(num,[],objHulls(num).inID);
end end
if objHulls(num).outID > length(CellHulls)+1 if(objHulls(num).outID > length(CellHulls)+1)
addHull(objHulls(num).outID); addHull(objHulls(num).outID);
end end
end end
end
...@@ -145,7 +145,11 @@ end ...@@ -145,7 +145,11 @@ end
oldParent = CellTracks(siblingTrack).parentTrack; oldParent = CellTracks(siblingTrack).parentTrack;
if(CellTracks(trackID).startTime==time)
ChangeTrackParent(siblingTrack,time,trackID);
else
ChangeTrackParent(trackID,time,siblingTrack); ChangeTrackParent(trackID,time,siblingTrack);
end
History('Push'); History('Push');
LogAction(['Changed parent of ' num2str(siblingTrack)],oldParent,trackID); LogAction(['Changed parent of ' num2str(siblingTrack)],oldParent,trackID);
......
...@@ -5,7 +5,7 @@ function DrawTree(familyID) ...@@ -5,7 +5,7 @@ function DrawTree(familyID)
global CellFamilies HashedCells Figures global CellFamilies HashedCells Figures
if(isempty(CellFamilies(familyID).tracks) || (isvarname('Figures.tree.familyID') && familyID==Figures.tree.familyID)),return,end if(isempty(CellFamilies(familyID).tracks)),return,end
%let the user know that this might take a while %let the user know that this might take a while
set(Figures.tree.handle,'Pointer','watch'); set(Figures.tree.handle,'Pointer','watch');
......
...@@ -137,8 +137,10 @@ if(Figures.cells.currentHullID == -1) ...@@ -137,8 +137,10 @@ if(Figures.cells.currentHullID == -1)
end end
trackID = [HashedCells{Figures.time}(:).hullID]==Figures.cells.currentHullID; trackID = [HashedCells{Figures.time}(:).hullID]==Figures.cells.currentHullID;
trackID = HashedCells{Figures.time}(trackID).trackID; trackID = HashedCells{Figures.time}(trackID).trackID;
if(CellTracks(trackID).familyID~=Figures.tree.familyID)
DrawTree(CellTracks(trackID).familyID); DrawTree(CellTracks(trackID).familyID);
DrawCells(); DrawCells();
end
set(Figures.cells.handle,'WindowButtonUpFcn',''); set(Figures.cells.handle,'WindowButtonUpFcn','');
end end
......
...@@ -40,4 +40,5 @@ file = fopen([settings.matFilePath CONSTANTS.datasetName '_log.csv'],'a'); ...@@ -40,4 +40,5 @@ file = fopen([settings.matFilePath CONSTANTS.datasetName '_log.csv'],'a');
fprintf(file,row); fprintf(file,row);
fclose(file); fclose(file);
% TestDataIntegrity(0)
end end
...@@ -7,7 +7,7 @@ function opened = OpenData() ...@@ -7,7 +7,7 @@ function opened = OpenData()
global Figures Colors CONSTANTS CellFamilies CellHulls HashedCells Costs CellTracks global Figures Colors CONSTANTS CellFamilies CellHulls HashedCells Costs CellTracks
if(isempty(Figures)) if(isempty(Figures))
fprintf('LEVer ver 3.1\n***DO NOT DISTRIBUTE***\n\n'); fprintf('LEVer ver 3.4\n***DO NOT DISTRIBUTE***\n\n');
end end
if(exist('ColorScheme.mat','file')) if(exist('ColorScheme.mat','file'))
......
function RemoveChildren(trackID)
% RemoveChildren(trackID) removes the children of the given track and moves
% them to thier own trees. Those new trees are attempted to be added to
% other trees. eg ProcessNewborns
%--Eric Wait
global CellTracks
familyIDs = [];
while ~isempty(CellTracks(trackID).childrenTracks)
familyIDs = [familyIDs RemoveFromTree(CellTracks(CellTracks(trackID).childrenTracks(1)).startTime,CellTracks(trackID).childrenTracks(1),'no')];
end
CellTracks(trackID).childrenTracks = [];
%run processNewborns on them
ProcessNewborns(familyIDs);
end
...@@ -4,7 +4,7 @@ function newTrackIDs = SplitHull(hullID, k) ...@@ -4,7 +4,7 @@ function newTrackIDs = SplitHull(hullID, k)
%--Mark Winter %--Mark Winter
global CellHulls global CellHulls CellFamilies
newHulls = ResegmentHull(CellHulls(hullID), k); newHulls = ResegmentHull(CellHulls(hullID), k);
...@@ -15,11 +15,11 @@ end ...@@ -15,11 +15,11 @@ end
% Just arbitrarily assign clone's hull for now % Just arbitrarily assign clone's hull for now
CellHulls(hullID) = newHulls(1); CellHulls(hullID) = newHulls(1);
newTrackIDs = [length(CellHulls)+1 length(CellHulls)+length(newHulls)];
% Other hulls are just added off the clone % Other hulls are just added off the clone
newFamilyIDs = [];
for i=2:length(newHulls) for i=2:length(newHulls)
CellHulls(end+i-1) = newHulls(i); CellHulls(end+1) = newHulls(i);
NewCellFamily(length(CellHulls), newHulls(i).time); newFamilyIDs = [newFamilyIDs NewCellFamily(length(CellHulls), newHulls(i).time)];
end end
newTrackIDs = [CellFamilies(newFamilyIDs).rootTrackID];
end end
...@@ -38,7 +38,7 @@ CellTracks(newTrackID).color = CellTracks(trackID).color; ...@@ -38,7 +38,7 @@ CellTracks(newTrackID).color = CellTracks(trackID).color;
%attach the parents children to the newTrack %attach the parents children to the newTrack
CellTracks(newTrackID).childrenTracks = CellTracks(trackID).childrenTracks; CellTracks(newTrackID).childrenTracks = CellTracks(trackID).childrenTracks;
for i=1:length(CellTracks(newTrackID).childrenTracks) for i=1:length(CellTracks(newTrackID).childrenTracks)
CellTracks(CellTracks(newTrackID).childrenTracks(i)).parent = newTrackID; CellTracks(CellTracks(newTrackID).childrenTracks(i)).parentTrack = newTrackID;
end end
CellTracks(trackID).childrenTracks = newTrackID; CellTracks(trackID).childrenTracks = newTrackID;
......
...@@ -15,9 +15,15 @@ track2Hulls = CellTracks(trackID2).hulls(track2Hash:end); ...@@ -15,9 +15,15 @@ track2Hulls = CellTracks(trackID2).hulls(track2Hash:end);
%clear out the hulls copied %clear out the hulls copied
CellTracks(trackID1).hulls(track1Hash:end) = []; CellTracks(trackID1).hulls(track1Hash:end) = [];
CellTracks(trackID2).hulls(track1Hash:end) = []; CellTracks(trackID2).hulls(track2Hash:end) = [];
%copy the hulls to the other track %copy the hulls to the other track
if(CellTracks(trackID1).startTime + length(CellTracks(trackID1).hulls) - 1 ~= time)
error('');
end
if(CellTracks(trackID2).startTime + length(CellTracks(trackID2).hulls) - 1 ~= time)
error('');
end
CellTracks(trackID1).hulls = [CellTracks(trackID1).hulls track2Hulls]; CellTracks(trackID1).hulls = [CellTracks(trackID1).hulls track2Hulls];
CellTracks(trackID2).hulls = [CellTracks(trackID2).hulls track1Hulls]; CellTracks(trackID2).hulls = [CellTracks(trackID2).hulls track1Hulls];
...@@ -54,7 +60,7 @@ end ...@@ -54,7 +60,7 @@ end
%check to see if the children have moved to a new family %check to see if the children have moved to a new family
if(CellTracks(trackID1).familyID ~= CellTracks(trackID2).familyID) if(CellTracks(trackID1).familyID ~= CellTracks(trackID2).familyID)
for i=1:length(CellTracks(trackID1).childrenTracks) for i=1:length(CellTracks(trackID1).childrenTracks)
ChangeTrackAndChildrensFamily(CellTracks(trackID2).familyID,CellTracks(trackID1).familyID,CellTracks(trackID1).childrenTracks(1)); ChangeTrackAndChildrensFamily(CellTracks(trackID2).familyID,CellTracks(trackID1).familyID,CellTracks(trackID1).childrenTracks(i));
end end
for i=1:length(CellTracks(trackID2).childrenTracks) for i=1:length(CellTracks(trackID2).childrenTracks)
ChangeTrackAndChildrensFamily(CellTracks(trackID1).familyID,CellTracks(trackID2).familyID,CellTracks(trackID2).childrenTracks(i)); ChangeTrackAndChildrensFamily(CellTracks(trackID1).familyID,CellTracks(trackID2).familyID,CellTracks(trackID2).childrenTracks(i));
......
function TestDataIntegrity(correct)
%TestDataIntegrity(correct) tests to make sure that the database is consistant.
%Takes the CellTracks as the most accurate. If correct=='yes', this
%function will attempt to correct the error using the data from CellTracks
%***USE SPARINGLY, TAKES A LOT OF TIME***
%--Eric Wait
global CellTracks CellHulls CellFamilies HashedCells
hullsList = [];
fprintf('Checking CellTracks');
for i=1:length(CellTracks)
fprintf(', %d',i);
%% Check child/parent/sibling relationships
if(~isempty(CellTracks(i).parentTrack))
if(isempty(find(CellTracks(CellTracks(i).parentTrack).childrenTracks==i, 1)))
error(['Parent ' num2str(CellTracks(i).parentTrack) ' does not recognize track ' num2str(i) ' as a child']);
end
if(CellTracks(CellTracks(i).siblingTrack).siblingTrack~=i)
error(['Track ' num2str(CellTracks(i).siblingTrack) ' does not recognize track ' num2str(i) ' as a sibling']);
end
end
currentFamily = CellTracks(i).familyID;
if(~isempty(CellTracks(i).childrenTracks))
for j=1:length(CellTracks(i).childrenTracks)
if(CellTracks(CellTracks(i).childrenTracks(j)).parentTrack~=i)
error(['Child ' num2str(CellTracks(i).childrenTracks(j)) ' does not recognize track ' num2str(i) ' as a parent']);
end
if(CellTracks(CellTracks(i).childrenTracks(j)).familyID~=currentFamily)
error(['Track ' num2str(i) ' and child ' num2str(CellTracks(i).childrenTracks(j)) ' do not agree on family ' num2str(currentFamily)]);
end
end
end
%% check if the current track is in the correct family and not in any
%other
if(~isempty(currentFamily))
index = find(CellFamilies(currentFamily).tracks==i);
if(isempty(index))
if(correct)
CellFamilies(currentFamily).tracks(end+1) = i;
fprintf('Track %d added to family %d\n',i,currentFamily);
else
error(['Track ' num2str(i) ' not in family ' num2str(currentFamily)])
end
elseif(1<length(index))
if(correct)
for j=2:length(index)
CellFamilies(currentFamily).tracks(index(j)) = 0;
end
CellFamilies(currentFamily).tracks = find(CellFamilies(currentFamily).tracks);
fprintf('Removed additional(s) track %d from family %d\n',i,currentFamily);
else
error(['Too many of track ' num2str(i) ' in family ' num2str(currentFamily)]);
end
end
%check for parent familyIDs
if(~isempty(CellTracks(i).parentTrack))
if(CellTracks(CellTracks(i).parentTrack).familyID~=currentFamily)
error(['Track ' num2str(i) ' and its parent ' num2str(CellTracks(i).parentTrack) ' do not agree on a family ' num2str(currentFamily)]);
end
end
for j=1:length(CellFamilies)
% fprintf('CellFamilies %d ',j);
if(currentFamily==j),continue,end
index = find(CellFamilies(j).tracks==i);
if(~isempty(index))
if(correct)
CellFamilies(j).tracks(index) = [];
fprintf('Removed track %d from family %d\n',i,j);
else
error(['Track ' num2str(i) ' is in family ' num2str(j) ' as well']);
end
end
end
end
%% check hulls for a given track
for j=1:length(CellTracks(i).hulls)
% fprintf('Hulls %d ',j);
if(~CellTracks(i).hulls(j)),continue,end
if(any(ismember(hullsList,CellTracks(i).hulls(j))))
tracks = [];
for q=1:i
if(~isempty(CellTracks(q).hulls) && ~isempty(find(CellTracks(q).hulls==CellTracks(i).hulls(j), 1)))
tracks = [tracks q];
end
end
error(['Hull ' num2str(CellTracks(i).hulls(j)) ' is in track ' num2str(i) ' as well as other tracks']);
end
hullsList = [hullsList CellTracks(i).hulls(j)];
time = j + CellTracks(i).startTime - 1;
if(time ~= CellHulls(CellTracks(i).hulls(j)).time)
error(['Hull ' num2str(CellTracks(i).hulls(j)) ' is not hashed correctly in track ' num2str(i)]);
end
index = find([HashedCells{time}.hullID]==CellTracks(i).hulls(j));
if(isempty(index))
error(['Hull ' num2str(CellTracks(i).hulls(j)) ' is not found in HashedCells at ' num2str(time)]);
elseif(1<length(index))
error(['Hull ' num2str(CellTracks(i).hulls(j)) ' is in HashedCells more than once at ' num2str(time)]);
end
if(HashedCells{time}(index).trackID~=i)
error(['Hull ' num2str(CellTracks(i).hulls(j)) ' does not have the correct track ' num2str(i)]);
end
end
end
fprintf('\n');
%% check CellHulls
% if(length(hullsList)~=length(find([CellHulls.deleted]==0)))
missingHulls = find(ismember(find([CellHulls.deleted]==0),hullsList')==0);
if(~isempty(missingHulls))
if(correct)
for i=1:length(missingHulls)
if(isempty(CellHulls(missingHulls(i)).points))
CellHulls(missingHulls(i)).deleted = 1;
end
end
end
error('HullsList ~= CellHulls');
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment