Skip to content
Snippets Groups Projects
Select Git revision
  • e5f87633107f181fdeef6323b894ab8ac806cd4d
  • master default protected
  • archive
  • v7.14.3
  • v7.14.2
  • v7.14.1
  • v7.14
  • v7.13
  • v7.12
  • v7.11
  • v7.10
  • v7.9
  • v7.8
  • v7.7
  • v7.6
  • v7.5
  • v7.4
  • v7.3
  • v7.3_MultiCellType
  • v7.2
  • v7.2_MultiCell
  • v7.1
  • v7.1_MultiCell
23 results

ChangeTrackParent.m

Blame
  • ChangeTrackParent.m 2.18 KiB
    function ChangeTrackParent(parentTrackID,time,childTrackID)
    %This will take the childTrack and connect it to the parent track.  It also
    %takes the hulls that exist in the parent track that are come after the
    %childTrack root and makes a new track with said hulls.  When finished
    %there should be a new track and the child track that are siblings with the
    %parent track being the parent.
    
    %--Eric Wait
    
    global CellTracks CellFamilies
    
    %see if the child exists before time
    if(time > CellTracks(childTrackID).startTime)
        newFamilyID = RemoveFromTree(time,childTrackID,'yes');
        childTrackID = CellFamilies(newFamilyID).rootTrackID;
    end
    
    %find where the child should attach to the parent
    hash = time - CellTracks(parentTrackID).startTime + 1;
    if(hash <= 0)
        error('Trying to attach a parent that comes after the child');
    elseif(hash <= length(CellTracks(parentTrackID).hulls))
        parentHullID = CellTracks(parentTrackID).hulls(hash);
        siblingTrackID = SplitTrack(parentTrackID,parentHullID); % SplitTrack adds sibling to the parent already
    else
        %just rename the child to the parent
        ChangeLabel(time,childTrackID,parentTrackID);
        return
    end
    
    childIndex = length(CellTracks(parentTrackID).childrenTracks) + 1;
    CellTracks(parentTrackID).childrenTracks(childIndex) = childTrackID;
    
    %clean up old parent
    if(~isempty(CellTracks(childTrackID).siblingTrack))
        CellTracks(CellTracks(childTrackID).siblingTrack).siblingTrack = [];
        ChangeLabel(CellTracks(CellTracks(childTrackID).siblingTrack).startTime,...
            CellTracks(childTrackID).siblingTrack,CellTracks(childTrackID).parentTrack);
        index = CellTracks(CellTracks(childTrackID).parentTrack).childrenTracks == childTrackID;
        CellTracks(CellTracks(childTrackID).parentTrack).childrenTracks(index) = [];
    end
    CellTracks(childTrackID).parentTrack = parentTrackID;
    
    %Detatch childTrack and clean up child's family
    oldFamilyID = CellTracks(childTrackID).familyID;
    newFamilyID = CellTracks(siblingTrackID).familyID;
    
    % CellTracks(childTrackID).familyID = newFamilyID;
    
    ChangeTrackAndChildrensFamily(oldFamilyID,newFamilyID,childTrackID);
    
    CellTracks(childTrackID).siblingTrack = siblingTrackID;
    CellTracks(siblingTrackID).siblingTrack = childTrackID;
    
    end