Commit ef47bf36 authored by Andrew Cohen's avatar Andrew Cohen

new Segmentation.batchSegmentation with spmd

parent db0ac7d4
% batch segmentation
tic
strDB='\path\to\file.LEVER';
conn = database(strDB, '','', 'org.sqlite.JDBC', 'jdbc:sqlite:');
CONSTANTS=Read.getConstants(conn);
algs=Read.getAlgorithms(conn,'segment');
params=algs.params;
Cells=[];
% p=parpool(16);
p=gcp();
for idp=0:ceil(CONSTANTS.imageData.NumberOfFrames/p.NumWorkers)-1
nc=Composite();
strTmin=num2str(idp*p.NumWorkers);
strTmax=num2str((idp+1)*p.NumWorkers);
cmd=['select time from tblCells where time>=' strTmin ' and time<=' strTmax ...
' group by time'];
q=fetch(conn,cmd);
tSeg=cell2mat(q);
spmd
t=idp*numlabs+labindex;
if isempty(intersect(t,tSeg)) && t<=CONSTANTS.imageData.NumberOfFrames
nc=Segment.FrameSegment_texture('',t,CONSTANTS,params);
else
if ~isempty(intersect(t,tSeg))
fprintf(1,' found existing seg, t=%d\n',t);
end
nc=[];
end
end
fprintf(1,'completed IDP=%d\n',idp);
Cells=[nc{:}];
Write.CreateCells_3D(conn,Cells);
end
for t=1:CONSTANTS.imageData.NumberOfFrames
Segment.CellDistance(conn,CONSTANTS,t,[t-2:t-1]);
end
tElapsed=toc;
fprintf(1,'batch segmentation -- elapsed time = %.1f seconds\n',tElapsed);
close(conn);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment