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

Make single-frame tracks for mitoses instead of requiring end-frame hulls.

parent 8a822f73
Branches
Tags
No related merge requests found
...@@ -11,9 +11,9 @@ function historyAction = CreateMitosisAction(treeID, time, linePoints) ...@@ -11,9 +11,9 @@ function historyAction = CreateMitosisAction(treeID, time, linePoints)
end end
treeTracks = [CellFamilies(treeID).tracks]; treeTracks = [CellFamilies(treeID).tracks];
bMidTracks = (([CellTracks(treeTracks).startTime] < time) & ([CellTracks(treeTracks).endTime] > time));
checkTracks = treeTracks(bMidTracks); bInTracks = Helper.CheckInTracks(time, treeTracks);
checkTracks = treeTracks(bInTracks);
if ( isempty(checkTracks) ) if ( isempty(checkTracks) )
error('No valid tracks to add a mitosis onto'); error('No valid tracks to add a mitosis onto');
end end
...@@ -40,16 +40,25 @@ function historyAction = CreateMitosisAction(treeID, time, linePoints) ...@@ -40,16 +40,25 @@ function historyAction = CreateMitosisAction(treeID, time, linePoints)
% bLeafTrack = arrayfun(@(x)(isempty(x.childrenTracks)), CellTracks(treeTracks)); % bLeafTrack = arrayfun(@(x)(isempty(x.childrenTracks)), CellTracks(treeTracks));
% leafTracks = treeTracks(bLeafTrack); % leafTracks = treeTracks(bLeafTrack);
Helper.SetTreeLocked(treeID, 0);
% NOTE: This just makes the tree as balanced as possible, it is probably not correct % NOTE: This just makes the tree as balanced as possible, it is probably not correct
balancedTrack = checkTracks(minIdx); balancedTrack = checkTracks(minIdx);
parentTrack = Hulls.GetTrackID(parentHull); parentTrack = Hulls.GetTrackID(parentHull);
% TODO: Don't change things up if parentTrack is already complete and on
% the correct family
if ( CellTracks(parentTrack).familyID == treeID )
balancedTrack = parentTrack;
end
if ( balancedTrack ~= parentTrack ) if ( balancedTrack ~= parentTrack )
Tracks.LockedChangeLabel(parentTrack, balancedTrack, time-1); attemptLockedChangeLabel(parentTrack, balancedTrack, time-1);
end end
childTrack = Hulls.GetTrackID(childHulls(1)); childTrack = Hulls.GetTrackID(childHulls(1));
if ( balancedTrack ~= childTrack ) if ( balancedTrack ~= childTrack )
Tracks.LockedChangeLabel(childTrack, balancedTrack, time); attemptLockedChangeLabel(childTrack, balancedTrack, time);
end end
childTrack = Hulls.GetTrackID(childHulls(2)); childTrack = Hulls.GetTrackID(childHulls(2));
...@@ -61,13 +70,25 @@ function historyAction = CreateMitosisAction(treeID, time, linePoints) ...@@ -61,13 +70,25 @@ function historyAction = CreateMitosisAction(treeID, time, linePoints)
% TODO: Make this respect the endTime from start of state % TODO: Make this respect the endTime from start of state
if ( time < length(HashedCells) ) if ( time < length(HashedCells) )
childTrack = Hulls.GetTrackID(childHulls(2)); for i=1:2
Helper.PushTrackToFrame(childTrack, length(HashedCells)); childTrack = Hulls.GetTrackID(childHulls(i));
Helper.DropSubtree(childTrack);
end
end end
Helper.SetTreeLocked(treeID, 1);
historyAction = 'Push'; historyAction = 'Push';
end end
function attemptLockedChangeLabel(changeTrack, desiredTrack, time)
if ( Helper.CheckTreeLocked(changeTrack) )
Tracks.LockedChangeLabel(changeTrack, desiredTrack, time);
else
Tracks.ChangeLabel(changeTrack, desiredTrack, time);
end
end
function newPoints = clipToImage(linePoints) function newPoints = clipToImage(linePoints)
global CONSTANTS global CONSTANTS
......
...@@ -9,7 +9,7 @@ function historyAction = MitosisEditInitializeAction(treeID, endTime) ...@@ -9,7 +9,7 @@ function historyAction = MitosisEditInitializeAction(treeID, endTime)
rootTrack = CellFamilies(treeID).rootTrackID; rootTrack = CellFamilies(treeID).rootTrackID;
if ( ~CellFamilies(treeID).bLocked ) if ( ~CellFamilies(treeID).bLocked )
Helper.PushTrackToFrame(rootTrack, endTime); Helper.DropSubtree(rootTrack);
end end
CellFamilies(treeID).bLocked = 1; CellFamilies(treeID).bLocked = 1;
......
% bInTrack = CheckInTracks(tracks)
%
% Check (for reseg or mitosis editing) if time t is within tracks.
function bInTrack = CheckInTracks(time, tracks)
global CellTracks
bPastStart = ([CellTracks(tracks).startTime] < time);
bLeafTracks = arrayfun(@(x)(isempty(x.childrenTracks)), CellTracks(tracks));
bBeforeEnd = ([CellTracks(tracks).endTime] > time);
bInTrack = (bPastStart & (bBeforeEnd | bLeafTracks));
end
\ No newline at end of file
function DropSubtree(trackID)
global CellTracks
if ( isempty(CellTracks(trackID).startTime) )
error('Cannot drop subtree of an empty track!');
end
% Remove children if this is a length 1 track
if ( ~isempty(CellTracks(trackID).childrenTracks) )
Families.RemoveFromTreePrune(CellTracks(trackID).childrenTracks(1));
end
Families.RemoveFromTreePrune(trackID, CellTracks(trackID).startTime+1);
end
\ No newline at end of file
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
% with the same name copied from inStruct (all others empty) % with the same name copied from inStruct (all others empty)
function newStruct = MakeInitStruct(templateStruct, initStruct) function newStruct = MakeInitStruct(templateStruct, initStruct)
if ( isempty(templateStruct) || isempty(fieldnames(templateStruct)) ) if ( isempty(fieldnames(templateStruct)) )
error('Non-empty template structure required'); error('Template structure must have at least one field');
end end
outFields = fieldnames(templateStruct); outFields = fieldnames(templateStruct);
......
...@@ -78,9 +78,9 @@ function addMitosisEvent(treeID, time, dragCoords) ...@@ -78,9 +78,9 @@ function addMitosisEvent(treeID, time, dragCoords)
end end
treeTracks = [CellFamilies(treeID).tracks]; treeTracks = [CellFamilies(treeID).tracks];
bMidTracks = (([CellTracks(treeTracks).startTime] < time) & ([CellTracks(treeTracks).endTime] > time));
checkTracks = treeTracks(bMidTracks); bInTracks = Helper.CheckInTracks(time, treeTracks);
checkTracks = treeTracks(bInTracks);
if ( isempty(checkTracks) ) if ( isempty(checkTracks) )
msgbox('No valid tracks to add a mitosis onto','Invalid Mitosis','warn'); msgbox('No valid tracks to add a mitosis onto','Invalid Mitosis','warn');
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment