Skip to content
Snippets Groups Projects
Commit 4304e8c6 authored by ac 20's avatar ac 20
Browse files

cellDistance and resegComplete fixes

cellDistance - cull in and out edges separately

resegComplete - check for multiple splits on a hull before undoing
   (also ljsFetch->fetch)

thresholdImages - 2 levels for log on sensitivity>1
parent 569f0f7a
No related branches found
No related tags found
No related merge requests found
......@@ -3,20 +3,37 @@
function cellDistance(conn,CONSTANTS,t0,t1Range,newCellIDs)
srcCells=Distance.getRangeCells(conn,[],t0,CONSTANTS);
t1Range=setdiff(t1Range,t0);
dstCells=Distance.getRangeCells(conn,[],t1Range,CONSTANTS);
if isempty(srcCells) || isempty(dstCells)
% first, do from t1->t0
t1_before=t1Range(t1Range<t0);
beforeCells=Distance.getRangeCells(conn,[],t1_before,CONSTANTS);
if isempty(srcCells) || isempty(beforeCells)
return;
end
srcCells=[srcCells.rgCells];
dstCells=[dstCells.rgCells];
if isempty(srcCells) || isempty(dstCells)
beforeCells=[beforeCells.rgCells];
if isempty(srcCells) || isempty(beforeCells)
return;
end
if ~exist('newCellIDs','var')
newCellIDs=[];
end
dx=Distance.ccDistance(CONSTANTS,srcCells,dstCells,newCellIDs);
dx=Distance.ccDistance(CONSTANTS,srcCells,beforeCells,newCellIDs);
% now do from t0->t1
t1_after=t1Range(t1Range>t0);
afterCells=Distance.getRangeCells(conn,[],t1_after,CONSTANTS);
if isempty(afterCells)
return;
end
afterCells=[afterCells.rgCells];
if isempty(afterCells)
return;
end
if ~exist('newCellIDs','var')
newCellIDs=[];
end
dx=[dx;Distance.ccDistance(CONSTANTS,srcCells,afterCells,newCellIDs)];
cmd = ['INSERT OR REPLACE INTO tblDistCC(cellID_src,cellID_dst,cost) values (?, ?, ?)'];
updateDistance= conn.handle.prepareStatement(cmd);
......
......@@ -11,23 +11,30 @@ function reSegmentComplete(conn,t,CONSTANTS)
% ACK ACK note this also selects previous reseg edits...
cmd=['SELECT * from tblEditList WHERE userID=0 AND imageFrame=' num2str(t)];
editQ=ljsFetch(conn,cmd);
editQ=fetch(conn,cmd);
if ~isempty(editQ)
idxUndo = cellfun(@(x) strcmp(x,'undo'),editQ(:,5));
idxUndone = [editQ{idxUndo,1}]';
idxUndo = cellfun(@(x) strcmp(x,'undo'),editQ.operation);
if any(idxUndo)
idxUndone = cellfun(@str2double,editQ.arguments(idxUndo),'UniformOutput',false);
idxUndone=[idxUndone{:}];
else
idxUndone=[];
end
for i=1:size(editQ,1)
if idxUndo(i)
continue;
end
if intersect(editQ{i,1},idxUndone)
if intersect(editQ.editID(i),idxUndone)
continue
end
cellIDs = editQ{i,6};
if ~ischar(cellIDs) || isempty(jsondecode(cellIDs))
if ~iscell(editQ.arguments) || ~ischar(editQ.arguments{i}) || isempty(jsondecode(editQ.arguments{i}))
fprintf('found bad entry in edit list, check database integrity. continuing\n');
continue;
end
cellIDs = editQ.arguments{i};
% any cells that were the result of a split where cellID=trackID
% mean those cells weren't tracked.
......@@ -36,14 +43,27 @@ if ~isempty(editQ)
% then we can't undo the split
cmd=['SELECT cellID,trackID FROM tblCells where cellID IN ('...
cellIDs(2:end-1) ') AND cellID=trackID'];
mergeQ=ljsFetch(conn,cmd);
mergeQ=fetch(conn,cmd);
if ~isempty(mergeQ)
% make sure this is the last split for mergeQ
splitList=editQ.arguments;
splitList=cellfun(@jsondecode,splitList,'UniformOutput',false);
splitList(idxUndo)={0};
idSplit=cellfun(@(x) intersect(x,mergeQ.cellID),splitList,'UniformOutput',false);
idSplit=find(cellfun(@length,idSplit));
if max(idSplit)>i
% this cell was split once (at operation i) and then again
% at max(idSplit). Don't undo this split...need to undo the
% last one...
continue;
end
% we have untracked cells in the split (cellID==trackID)
% before undoing, check for any of the split cells are in a mitosis
idSplitStr=['(' cellIDs(2:end-1) ')'];
cmd=['select * from tblFamilies where cellID_parent in ' idSplitStr...
' or cellID_child1 in ' idSplitStr ' or cellID_child2 in ' idSplitStr];
q=ljsFetch(conn,cmd);
q=fetch(conn,cmd);
if ~isempty(q)
% can't undo this split -- one of the splittees is a child
continue
......@@ -51,7 +71,7 @@ if ~isempty(editQ)
% ok -- we have untracked cells in the split, and none of the
% splittees are involved in a mitosis. undo it.
fprintf(1,'found untracked cells from reseg split -- merging\n');
Write.undoEdit(conn,editQ{i,1},0);
Write.undoEdit(conn,editQ.editID(i),0);
end
end
......
......@@ -12,7 +12,7 @@ else
end
if sensitivity>1 && round(sensitivity)==sensitivity
lm=multithresh(imLog,sensitivity);
lm=multithresh(imLog,1);
bwLog=logical(imLog>lm(end));
bwLog=Segment.aiAreaOpen(bwLog,min_radius_pixels);
lm=multithresh(im,sensitivity);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment