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

ChangeTrackAndChildrensFamily.m

Blame
  • ChangeTrackAndChildrensFamily.m 1.81 KiB
    function ChangeTrackAndChildrensFamily(oldFamilyID,newFamilyID,trackID)
    %This will remove the tree rooted at the given trackID from the given
    %oldFamily and put them in the newFamily
    %This DOES NOT make the parent child relationship, it is just updates the
    %CellFamilies data structure.
    
    %--Eric Wait
    
    global CellFamilies CellTracks
    
    %get the full list of tracks to be updateded
    trackList = traverseTree(newFamilyID,trackID);
    
    %remove tracks from family
    for i=1:length(trackList)
        CellTracks(trackList(i)).familyID = newFamilyID;
    %     RemoveTrackFromFamily(trackList(i));
    end
    
    if(isempty(CellFamilies(oldFamilyID).tracks))
        CellFamilies(oldFamilyID).rootTrackID = [];
        CellFamilies(oldFamilyID).startTime = [];
        CellFamilies(oldFamilyID).endTime = [];
    else    
        %update times
        CellFamilies(oldFamilyID).startTime = min([CellTracks(CellFamilies(oldFamilyID).tracks).startTime]);
        CellFamilies(oldFamilyID).endTime = max([CellTracks(CellFamilies(oldFamilyID).tracks).endTime]);
    end
    end
    
    function trackList = traverseTree(newFamilyID,trackID)
    %recursive helper function to traverse tree and gather track IDs
    %will add the tracks to the new family along the way
    global CellFamilies CellTracks
    
    RemoveTrackFromFamily(trackID);
    %add track
    CellFamilies(newFamilyID).tracks(end+1) = trackID;
    
    %update times
    if(CellTracks(trackID).startTime < CellFamilies(newFamilyID).startTime)
        CellFamilies(newFamilyID).startTime = CellTracks(trackID).startTime;
    end
    if(CellTracks(trackID).endTime > CellFamilies(newFamilyID).endTime)
        CellFamilies(newFamilyID).endTime = CellTracks(trackID).endTime;
    end
    
    trackList = trackID;
    if(~isempty(CellTracks(trackID).childrenTracks))    
        for i=1:length(CellTracks(trackID).childrenTracks)
            trackList = [trackList traverseTree(newFamilyID, CellTracks(trackID).childrenTracks(i))];
        end
    end
    end