...
 
Commits (2)
function mitosisNode=findFamily(conn,CONSTANTS,d1CellID,minAreaRatio)
function [mitosisNode,imCache]=findFamily(conn,CONSTANTS,d1CellID,imCache,minAreaRatio)
if ~exist('minAreaRatio','var')
minAreaRatio=1;
......@@ -48,37 +48,7 @@ centroids=reshape(cell2mat(centroids),3,[])';
parentCandidates=[cell2mat(q(:,1:2)) centroids];
d1=Read.getCell(conn,d1CellID);
d2Candidates=[];
costs=[];
for i=1:size(parentCandidates,1)
% % target sibling 2 is the cell parent candidate tracked 2
% parentCandidates are [cellID,trackID,centroid]
[d2TrackID,d2CellID,d2Centroid]=getDaughter2(conn,parentCandidates(i,:),time,d1);
if isempty(d2TrackID)
continue
end
if d2CellID==d1CellID
% need to come in via the other sibling!
return
end
pCentroid=parentCandidates(i,3:5);
d2Candidates(i,:)=[d2CellID d2Centroid];
% midpoint of line between daughters -- this is where we'd like to see
% the parent
pmid=(d2Centroid+d1Centroid)/2;
nc=[];
nc.parentDaughterCID=[parentCandidates(i,1),d2CellID,];
nc.parentToDaughterMidpoint=norm(pCentroid-pmid);
nc.dParentD1=Mitosis.cellDistance(conn,d1CellID,parentCandidates(i,1));
nc.dParentD2=Mitosis.cellDistance(conn,d2CellID,parentCandidates(i,1));
nc.parentDaughterTID=[parentCandidates(i,2),d2TrackID];
nc.ratioD1D2=nc.dParentD1/nc.dParentD2;
costs=[costs nc];
end
costs=findD2Candidates(conn,parentCandidates,time,d1);
if isempty(costs)
return
end
......@@ -129,6 +99,71 @@ end
mitosisNode.sibAreaRatio=max([d1.area,d2.area])/min([d1.area,d2.area]);
if isempty(imCache)
imCache=getImageCache(conn,CONSTANTS,time);
end
if isempty(imCache)
return;
end
d1br=brightShape(d1,imCache.im);
d2br=brightShape(d2,imCache.im);
d1t1=getNextDaughter(conn,d1);
if ~isempty(d1t1)
d1br=max([d1br,brightShape(d1t1,imCache.imP1)]);
end
d2t1=getNextDaughter(conn,d2);
if ~isempty(d2t1)
d2br=max([d2br,brightShape(d2t1,imCache.imP1)]);
end
pbr=getParentBR(conn,CONSTANTS,p,imCache);
mitosisNode.brightRatio=[d1br,d2br,pbr];
eccParent=getEcc(size(imCache.im),p);
mitosisNode.eccParent=eccParent;
4;
% end of find family
% for each parent candidate, find d1's sibling (d2) and cost
function costs=findD2Candidates(conn,parentCandidates,time,d1)
costs=[];
for i=1:size(parentCandidates,1)
% % target sibling 2 is the cell parent candidate tracked 2
% parentCandidates are [cellID,trackID,centroid]
[d2TrackID,d2CellID,d2Centroid]=getDaughter2(conn,parentCandidates(i,:),time,d1);
if isempty(d2TrackID)
continue
end
if d2CellID==d1.cellID
% need to come in via the other sibling!
return
end
pCentroid=parentCandidates(i,3:5);
% midpoint of line between daughters -- this is where we'd like to see
% the parent
pmid=(d2Centroid+d1.centroid)/2;
nc=[];
nc.parentDaughterCID=[parentCandidates(i,1),d2CellID,];
nc.parentToDaughterMidpoint=norm(pCentroid-pmid);
nc.dParentD1=Mitosis.cellDistance(conn,d1.cellID,parentCandidates(i,1));
nc.dParentD2=Mitosis.cellDistance(conn,d2CellID,parentCandidates(i,1));
nc.parentDaughterTID=[parentCandidates(i,2),d2TrackID];
nc.ratioD1D2=nc.dParentD1/nc.dParentD2;
costs=[costs nc];
end
% don't reread the images every time!!! we denoise on the image read!
function imCache=getImageCache(conn,CONSTANTS,time)
imCache=[];
if time<2
return
end
algorithms=Read.getAlgorithms(conn,'segment');
if length(algorithms)>1
algorithms=algorithms(1);
......@@ -143,33 +178,22 @@ end
resolution_um=CONSTANTS.imageData.PixelPhysicalSize; % um per pixel
min_radius_pixels = segParams.minimumRadius_um ./ resolution_um;
[im]=Segment.getImages(CONSTANTS,time,segParams.channels(1),min_radius_pixels,segParams.denoise);
[im2]=Segment.getImages(CONSTANTS,time+1,segParams.channels(1),min_radius_pixels,segParams.denoise);
d1br=brightShape(d1,im);
d2br=brightShape(d2,im);
d1t1=getNextDaughter(conn,d1);
if ~isempty(d1t1)
d1br=max([d1br,brightShape(d1t1,im2)]);
imCache.im =Segment.getImages(CONSTANTS,time, segParams.channels(1),min_radius_pixels,segParams.denoise);
imCache.imM1=Segment.getImages(CONSTANTS,time-1,segParams.channels(1),min_radius_pixels,segParams.denoise);
if time>2
imCache.imM2=Segment.getImages(CONSTANTS,time-2,segParams.channels(1),min_radius_pixels,segParams.denoise);
else
imCache.imM2=[];
end
d2t1=getNextDaughter(conn,d2);
if ~isempty(d2t1)
d2br=max([d2br,brightShape(d2t1,im2)]);
if time<CONSTANTS.imageData.NumberOfFrames
imCache.imP1=Segment.getImages(CONSTANTS,time+1,segParams.channels(1),min_radius_pixels,segParams.denoise);
else
imCache.imP1=[];
end
function pbr=getParentBR(conn,CONSTANTS,p,imCache)
pbr=getParentBR(conn,CONSTANTS,p,segParams.channels(1),min_radius_pixels,...
segParams.denoise);
mitosisNode.brightRatio=[d1br,d2br,pbr];
eccParent=getEcc(size(im),p);
mitosisNode.eccParent=eccParent;
function pbr=getParentBR(conn,CONSTANTS,p,channel,min_radius_pixels,bDenoise)
[im]=Segment.getImages(CONSTANTS,p.time,channel,min_radius_pixels,bDenoise);
pbr=brightShape(p,im);
% parent needs to be in frame t-1
pbr=brightShape(p,imCache.imM1);
cmd=['select cellID from tblCells where time=' num2str(p.time-1) ' and '...
' trackID= ' num2str(p.trackID)];
q=fetch(conn,cmd);
......@@ -177,11 +201,9 @@ if isempty(q)
return
end
p1=Read.getCell(conn,q{1});
im1=Segment.getImages(CONSTANTS,p1.time,channel,min_radius_pixels);
pbr1=brightShape(p1,im1);
pbr1=brightShape(p1,imCache.imM2);
pbr=max([pbr,pbr1]);
function d=getNextDaughter(conn,cell)
cmd=['select cellID from tblCells where trackID=' num2str(cell.trackID) ' and time=' num2str(cell.time)];
......@@ -196,6 +218,10 @@ d=Read.getCell(conn,nextID);
% mse between distance transform and intensity profile
function br=brightShape(cell,im)
if isempty(im)
br=0;
return;
end
imx=0*im;
if (size(im,3))>1
idx=sub2ind(size(im),cell.pts(:,2),cell.pts(:,1),cell.pts(:,3));
......
......@@ -27,13 +27,13 @@ else
lineageNodes=[];
end
imCache=[];
for i=1:length(newCells)
if ~isempty(intersect(lineageNodes,newCells(i)))
continue
end
mnode=Mitosis.findFamily(conn,CONSTANTS,newCells(i),mParams.parentDaughterAreaRatio);
[mnode,imCache]=Mitosis.findFamily(conn,CONSTANTS,newCells(i),imCache,mParams.parentDaughterAreaRatio);
if mnode.parentCellID<0
continue
end
......
No preview for this file type