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

ljsNProcs, patch updates

parent 870c2667
Branches
No related tags found
No related merge requests found
......@@ -5,7 +5,11 @@ if ~exist('bTrack','var')
end
if ~exist('nProcessors','var') || isempty(nProcessors)
nProcessors=feature('numcores');
nProcessors=ljsNProcs();
% c=parcluster('local')
% c.NumWorkers=nProcessors
% saveProfile(c)
end
% batch segmentation
d0=tic();
......
......@@ -11,7 +11,8 @@ tProcess.tTrack1=toc(tx);
[conn,CONSTANTS]=openDB(strDB);
tx=tic();
Smooth.Patch.patch(conn);
Smooth.Patch.patch11(conn);
Smooth.Patch.patch12(conn);
tProcess.tPatch=toc(tx);
tx=tic();
......@@ -20,6 +21,6 @@ Smooth.extFamily(conn);
tProcess.tClassify=toc(tx);
tx=tic();
Batch.batchFeatures(conn,CONSTANTS);
tProcess.tFeatures=toc();
tProcess.tFeatures=toc(tx);
close(conn)
......@@ -14,7 +14,7 @@ updateDistance= conn.handle.prepareStatement(cmd);
conn.AutoCommit='off';
if ~exist('nProcessors','var') || isempty(nProcessors)
nProcessors=feature('numcores');
nProcessors=ljsNProcs();
end
p=gcp('nocreate');
if isempty(p) || p.NumWorkers~=nProcessors
......
function patch(conn)
cmd='select cellID_child1 as cellID from tblFamilies union select cellID_child2 as cellID from tblFamilies';
qChildren=fetch(conn,cmd);
cidChildren=qChildren.cellID;
cmd='select cellID_parent from tblFamilies';
qParents=fetch(conn,cmd);
cidParents=qParents.cellID_parent;
Smooth.Patch.patch11(conn);
Smooth.Patch.patch11(conn,cidChildren);
Smooth.Patch.patch12(conn,cidParents,cidChildren);
......@@ -2,7 +2,7 @@
% sometimes the tracker makes decisions based on longer time projections
% if those fail, we fall back on the original single frame true love
% (1st choice ccDistance <-> 1st choice ccDistance)
function patch11(conn,cidChildren)
function patch11(conn)
cmd=['select cellID,trackID,max(time) as tmax from tblCells '...
' where trackID not in (select trackID from tblCells inner join tblFamilies'...
......@@ -17,16 +17,12 @@ cmd=['select cellID_src,cellID_dst,min(cost) from tblDistCC where cellID_src in
cidList ' group by cellID_src'];
qSrcCosts=fetch(conn,cmd);
cmd=['select cellID_src,cellID_dst,trackID as trackID_dst,min(cost),time as time_dst '...
' from tblCells inner join tblDistCC on cellID=cellID_dst where cellID_src in '...
cidList ' group by cellID_dst'];
cmd=['select * from (select cellID_src,cellID_dst,trackID as trackID_dst,min(cost),time as time_dst '...
' from tblCells inner join tblDistCC on cellID=cellID_dst group by cellID_dst)'...
' where cellID_src in ' cidList];
qPatch=fetch(conn,cmd);
qPatch(qPatch.cellID_dst~=qPatch.trackID_dst,:)=[];
for i=1:length(qPatch.cellID_src)
if ~isempty(intersect(cidChildren,qPatch.cellID_dst(i)))
% can't patch to a mitotic child
continue;
end
% check src costs. true love?
idxSrcCosts=find(qSrcCosts.cellID_src==qPatch.cellID_src(i));
if qSrcCosts.cellID_dst(idxSrcCosts)~=qPatch.cellID_dst(i)
......
% the second chance patcher
% here, eligible tracks can get assigned their 1st choice, even if they
% are the corresponding 2nd choice
function patch12(conn,cidParents,cidChildren)
function patch12(conn)
cmd='select cellID_child1 as cellID from tblFamilies union select cellID_child2 as cellID from tblFamilies';
qChildren=fetch(conn,cmd);
cidChildren=qChildren.cellID;
cmd='select cellID_parent from tblFamilies';
qParents=fetch(conn,cmd);
cidParents=qParents.cellID_parent;
% patch src's are leaf nodes on the tree
% patch dst's are parent nodes on the tree
......@@ -19,6 +27,21 @@ for i=1:length(qSrc.cellID_dst)
if isempty(qTarget)
continue;
end
if qTarget.min_cost_(1)<qSrc.min_cost_(i)
% src(1:dst.tmin-1)->dst(1:end)
% reset src(dst.tmin:end)
cmd=['update tblCells set trackID=cellID' ...
' where trackID=' num2str(qTarget.trackID_src(1)) ...
' and time>=' num2str(qTarget.time_dst(1))];
exec(conn,cmd);
% set src(dst.tmin:end)->dst
cmd=['update tblCells set trackID=' num2str(qTarget.trackID_src(1))...
' where trackID=' num2str(qTarget.trackID_dst(1)) ...
' and time>=' num2str(qTarget.time_dst(1))];
exec(conn,cmd);
else
% src(1:end)->target(src.tmax)+1:end
cmd=['update tblCells set trackID=(select trackID from tblCells where '...
' cellID=' num2str(qSrc.cellID_src(i)) ') where trackID= '...
' (select trackID from tblCells where cellID=' ...
......@@ -26,7 +49,7 @@ for i=1:length(qSrc.cellID_dst)
' tblCells where trackID=(select trackID from tblCells where cellID='...
num2str(qSrc.cellID_src(i)) '))'];
exec(conn,cmd);
end
end
function qTarget=getPatchTarget(conn,qSrc)
......
function extFamily(conn)
exec(conn,'delete from uiExtFamilies');
extParams=Read.getExtFamilyParams(conn);
if extParams.firstFrame
cmd=['insert or replace into uiExtFamilies select trackID from (select trackID from tblCells where time=1)'];
......@@ -14,3 +15,10 @@ if extParams.nFrames>0
' where trackLength>' num2str(extParams.nFrames)];
exec(conn,cmd);
end
% add mitotic events
cmd=['insert or replace into uiExtFamilies(trackID) select trackID from '...
' tblCells inner join tblFamilies on cellID=cellID_parent union select '...
' trackID from tblCells inner join tblFamilies on cellID=cellID_child1 '...
' union select trackID from tblCells inner join tblFamilies on cellID=cellID_child2'];
exec(conn,cmd);
function nProcessors=ljsNProcs()
nProcessors=floor(1.5*feature('numcores'));
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment