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

Tree inference fixes, relink back once before the inference loop.

parent 6a4bfbad
Branches
Tags
No related merge requests found
function [iterations totalTime] = LinkTrees(families)
global CellFamilies
global CellFamilies CellTracks
iterations = 0;
rootTrackIDs = [CellFamilies(families).rootTrackID];
% Use changelabel to try and extend tracks back to first frame
newRootTracks = [];
backTracks = rootTrackIDs([CellTracks(rootTrackIDs).startTime] ~= 1);
for i=1:length(backTracks)
newRootTracks = [newRootTracks linkTreeBack(backTracks(i))];
end
rootTrackIDs = unique(getRootTracks(union(rootTrackIDs,newRootTracks)));
% Try to Push/reseg
totalTime = 0;
maxPushCount = 10;
......@@ -22,3 +31,41 @@ function [iterations totalTime] = LinkTrees(families)
% LogAction('Completed Tree Inference', [i totalTime],[]);
end
function newroot = linkTreeBack(rootTrack)
global CellTracks
costMatrix = Tracker.GetCostMatrix();
curTrack = rootTrack;
while ( CellTracks(curTrack).startTime > 1 )
curHull = CellTracks(curTrack).hulls(1);
prevHulls = find(costMatrix(:,curHull) > 0);
if ( isempty(prevHulls) )
break;
end
[bestCost bestIdx] = min(costMatrix(prevHulls,curHull));
prevTrack = Hulls.GetTrackID(prevHulls(bestIdx));
Tracks.ChangeLabel(curTrack, prevTrack);
curTrack = getRootTracks(prevTrack);
end
newroot = curTrack;
end
function rootTracks = getRootTracks(tracks)
global CellTracks CellFamilies
rootTracks = [];
for i=1:length(tracks)
if ( isempty(CellTracks(tracks(i)).startTime) )
continue;
end
familyID = CellTracks(tracks(i)).familyID;
rootTracks = [rootTracks CellFamilies(familyID).rootTrackID];
end
end
\ No newline at end of file
......@@ -13,14 +13,6 @@ function [assignedExtensions findTime extTime] = LinkTreesForward(rootTracks)
costMatrix = Tracker.GetCostMatrix();
mexDijkstra('initGraph', costMatrix);
% Use changelabel to try and extend tracks back to first frame
backTracks = rootTracks([CellTracks(rootTracks).startTime] ~= 1);
for i=1:length(backTracks)
linkTreeBack(backTracks(i));
end
rootTracks = unique(getRootTracks(rootTracks));
leafHulls = getLeafHulls(rootTracks);
tStart = CellHulls(leafHulls(1)).time;
tEnd = length(HashedCells);
......@@ -129,28 +121,6 @@ function [assignedExtensions findTime extTime] = LinkTreesForward(rootTracks)
extTime = toc(chkExtendTime);
end
function linkTreeBack(rootTrack)
global CellTracks
costMatrix = Tracker.GetCostMatrix();
curTrack = rootTrack;
while ( CellTracks(curTrack).startTime > 1 )
curHull = CellTracks(curTrack).hulls(1);
prevHulls = find(costMatrix(:,curHull) > 0);
if ( isempty(prevHulls) )
break;
end
[bestCost bestIdx] = min(costMatrix(prevHulls,curHull));
prevTrack = Hulls.GetTrackID(prevHulls(bestIdx));
Tracks.ChangeLabel(curTrack, prevTrack);
curTrack = getRootTracks(prevTrack);
end
end
function cost = calcTrackCost(costMatrix, startHull, endHull, maxFrameExt)
global CellHulls CellTracks
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment