Skip to content
Snippets Groups Projects
Commit 54db9165 authored by Mark Winter's avatar Mark Winter
Browse files

Some graph-edit related fixes.

parent 6aed22f4
No related branches found
No related tags found
No related merge requests found
...@@ -25,22 +25,12 @@ ...@@ -25,22 +25,12 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function GraphEditAddMitosis(trackID, siblingTrackID, time) function GraphEditAddMitosis(trackID, siblingTrackID, time)
global CellTracks GraphEdits Costs CachedCostMatrix global GraphEdits Costs CachedCostMatrix
parentHash = time - CellTracks(trackID).startTime; parentHull = Helper.GetNearestTrackHull(trackID, time-1, 0);
siblingHash = time - CellTracks(siblingTrackID).startTime + 1;
if ( parentHash < 1 || parentHash+1 > length(CellTracks(trackID).hulls) ) childHull = Helper.GetNearestTrackHull(trackID, time, 0);
return; siblingHull = Helper.GetNearestTrackHull(siblingTrackID, time, 0);
end
if ( siblingHash < 1 || siblingHash > length(CellTracks(trackID).hulls) )
return;
end
parentHull = CellTracks(trackID).hulls(parentHash);
childHull = CellTracks(trackID).hulls(parentHash+1);
siblingHull = CellTracks(siblingTrackID).hulls(siblingHash);
if ( parentHull == 0 || childHull == 0 || siblingHull == 0 ) if ( parentHull == 0 || childHull == 0 || siblingHull == 0 )
return; return;
......
...@@ -30,6 +30,9 @@ function GraphEditRemoveEdge(trackID, time) ...@@ -30,6 +30,9 @@ function GraphEditRemoveEdge(trackID, time)
global CellTracks CellFamilies GraphEdits CachedCostMatrix global CellTracks CellFamilies GraphEdits CachedCostMatrix
nextHull = Helper.GetNearestTrackHull(trackID, time, 1); nextHull = Helper.GetNearestTrackHull(trackID, time, 1);
if ( nextHull == 0 )
return;
end
possibleFamilyParents = []; possibleFamilyParents = [];
familyID = CellTracks(trackID).familyID; familyID = CellTracks(trackID).familyID;
...@@ -38,10 +41,6 @@ function GraphEditRemoveEdge(trackID, time) ...@@ -38,10 +41,6 @@ function GraphEditRemoveEdge(trackID, time)
possibleFamilyParents = [possibleFamilyParents Helper.GetNearestTrackHull(checkTrack, time-1, -1)]; possibleFamilyParents = [possibleFamilyParents Helper.GetNearestTrackHull(checkTrack, time-1, -1)];
end end
if ( nextHull == 0 )
return;
end
nzParentHulls = possibleFamilyParents(possibleFamilyParents > 0); nzParentHulls = possibleFamilyParents(possibleFamilyParents > 0);
for i=1:length(nzParentHulls) for i=1:length(nzParentHulls)
GraphEdits(nzParentHulls(i),nextHull) = -1; GraphEdits(nzParentHulls(i),nextHull) = -1;
......
% GraphEditSetEdge(trackID, nextTrackID, time) % GraphEditSetEdge(trackID, nextTrackID, time)
%
% Set an edge edit in GraphEdits structure. % Set an edge edit in GraphEdits structure.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
...@@ -31,22 +32,29 @@ function GraphEditSetEdge(trackID, nextTrackID, time, bLongDistance) ...@@ -31,22 +32,29 @@ function GraphEditSetEdge(trackID, nextTrackID, time, bLongDistance)
bLongDistance = 0; bLongDistance = 0;
end end
if(bLongDistance) [trackHull hullTime] = Helper.GetNearestTrackHull(trackID, time-1, -1);
track = CellTracks(trackID); if ( trackHull == 0 )
if(isempty(track.hulls)) %check for valid track return;
trackHull = 0;
else
for i=length(track.hulls):-1:1 %search backward through hulls for last edit or first hull
trackHull = track.hulls(i);
if(trackHull)
if(any(GraphEdits(trackHull,:)) || any(GraphEdits(:,trackHull)))
break
end
end end
if(bLongDistance)
hash = hullTime - CellTracks(trackID).startTime + 1;
if ( hash < 1 )
return;
end end
trackHulls = CellTracks(trackID).hulls(1:hash);
nzHulls = trackHulls(trackHulls > 0);
if ( isempty(nzHulls) )
return;
end end
trackHullIdx = find(any(GraphEdits(:,nzHulls),1),1,'last');
if ( isempty(trackHullIdx) )
trackHull = CellTracks(trackID).hulls(1);
else else
trackHull = Helper.GetNearestTrackHull(trackID, time-1, -1); trackHull = nzHulls(trackHullIdx);
end
end end
nextHull = Helper.GetNearestTrackHull(nextTrackID, time, 1); nextHull = Helper.GetNearestTrackHull(nextTrackID, time, 1);
......
% GraphEditsResetHulls(hulls) % GraphEditsResetHulls(hulls, bResetForward, bResetBack)
% Resets (zeros) all user edits into (bResetBack) and out of (bResetForward) %
% Clears all user edits into (bResetBack) and/or out of (bResetForward)
% a hull, updates associated cached costs. % a hull, updates associated cached costs.
function GraphEditsResetHulls(hulls, bResetForward, bResetBack) function GraphEditsResetHulls(hulls, bResetForward, bResetBack)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment