Commit 98e2c454 authored by ac32's avatar ac32

importExport - interpolate on multiframe skips, use ctcEval1

parent ca6067a9
......@@ -246,8 +246,19 @@ for i=1:length(idsMissing)
idx0=find(trackTime==t-1);
idx1=find(trackTime==t+1);
if isempty(idx0) && isempty(idx1)
fprintf(2,'neither t-1 nor t+1 available for interp! failing...\n');
continue
fprintf(2,'neither t-1 nor t+1 available for interp! guessing...\n');
tt=trackTime-t;
tt(tt<0)=[];
tt1=min(tt);
idx1=find(trackTime==t+tt1);
tt=t-trackTime;
tt(tt<0)=[];
tt0=min(tt);
idx0=find(trackTime==t-tt0);
if isempty(idx0) && isempty(idx1)
fprintf(2,'guessing didnt work...failing...\n');
continue
end
end
if isempty(idx0)
idx0=idx1;
......@@ -255,12 +266,14 @@ for i=1:length(idsMissing)
if isempty(idx1)
idx1=idx0;
end
cxInterp=(cx{idx0}+cx{idx1}) ./ 2;
w0=1-(t-trackTime(idx0))/(trackTime(idx1)-trackTime(idx0));
w1=1-(trackTime(idx1)-t)/(trackTime(idx1)-trackTime(idx0));
cxInterp=cx{idx0}.*w0 + cx{idx1} .* w1 ;
cxInterp=round(cxInterp);
if length(size(im))<3
cxInterp=cxInterp(1:2);
end
cxInterp=min(cxInterp,size(im)');
cxInterp=min(cxInterp,[size(im,2);size(im,1)]);
cxInterp=max(cxInterp,ones(length(cxInterp),1));
im(cxInterp(2),cxInterp(1))=idsMissing(i);
end
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
function res=ctcEval(wrangleFolder,dsName)
gtPath='X:\gRaw\ctc2020\';
evalFolder='f:\ctcEval';
gtPath='/g/gRaw/ctc2020/';
evalFolder='/f/ctcEval';
thisFile=mfilename('fullpath');
[thisFolder,~,~]=fileparts(thisFile);
path(path,fullfile(thisFolder,'..','ctc\importExport'));
path(path,fullfile(thisFolder,'..','ctc/importExport'));
outfolder=fullfile(wrangleFolder,'eval');
flist=dir(fullfile(wrangleFolder,dsName,'*.LEVER'));
......@@ -19,58 +19,8 @@ else
end
for ff=1:length(flist)
fname=flist(ff).name;
fname=strrep(fname,'_training','');
tokens=regexp(fname,'(.*)_(\d\d)_','tokens');
dsName=tokens{1}{1};
dsID=tokens{1}{2};
[~,targetName,~]=fileparts(flist(ff).name);
importExport(fullfile(flist(ff).folder,flist(ff).name),outfolder, [])
% copy over the ground truth
gtSource=fullfile(gtPath,['2d_' dsName '_training'],dsName,[dsID '_GT\']);
if ~exist(gtSource,'dir')
gtSource=fullfile(gtPath,['3d_' dsName '_training'],dsName,[dsID '_GT\']);
end
if ~exist(gtSource,'dir')
fprintf(2,'ground truth not found, skipping : %s\n',gtSource);
continue;
end
copyfile(gtSource,fullfile(outfolder,targetName,[dsID '_GT']),'f');
exePath=fullfile(evalFolder,'EvaluationSoftware/Win');
system([fullfile(exePath,'TRAMeasure.exe') ' ' ...
fullfile(outfolder,targetName) ' ' dsID ' > score.txt']);
system([fullfile(exePath,'SEGMeasure.exe') ' ' ...
fullfile(outfolder,targetName) ' ' dsID ' >> score.txt']);
system([fullfile(exePath,'DETMeasure.exe') ' ' ...
fullfile(outfolder,targetName) ' ' dsID ' >> score.txt']);
fid=fopen('score.txt');
scoreTxt=fscanf(fid,'%s');
fclose(fid);
sx=regexp(scoreTxt,'...measure:(\d\.\d+)','tokens');
sx=cellfun(@str2double,sx);
if length(sx)<3 , sx(3)=0; end
fprintf(1,'TRAmeasure:%f, SEGmeasure:%f, DETmeasure:%f\n',sx(1),sx(2),sx(3));
pid=ff; %str2double(paramID)
% get the algorithm settings
[conn,CONSTANTS]=openDB(fullfile(flist(ff).folder,flist(ff).name));
segParams=Read.getSegmentationParams(conn);
if isempty(res)
res=table(sx,{jsonencode(segParams)},'VariableNames',{'TRA_SEG_DET','segParams'});
else
res=[res;sx,{jsonencode(segParams)}];
end
close(conn);
ctcEval1(fullfile(flist(ff).folder,flist(ff).name))
end
writetable(res,strResults);
function res=ctcEval1(strDB)
gtPath='g:\gRaw\ctc2020\';
evalFolder='f:\ctcEval';
gtPath='/g/gRaw/ctc2020/';
evalFolder='/f/ctcEval';
[~,targetName,~]=fileparts(strDB);
thisFile=mfilename('fullpath');
[thisFolder,~,~]=fileparts(thisFile);
......@@ -10,7 +10,12 @@ path(path,fullfile(thisFolder,'..','ctc/importExport'));
outfolder=fullfile(evalFolder,'eval');
% results file
strResults=fullfile(evalFolder,[targetName '_res.txt']);
if ~exist('./evalScore','dir')
mkdir('./evalScore');
end
strResults=targetName(1:strfind(targetName,'_param')-1);
strResults=fullfile('./evalScore',[strResults '_res.txt']);
if exist(strResults,'file')
res=readtable(strResults,'delimiter',',');
else
......@@ -70,9 +75,9 @@ fprintf(1,'TRAmeasure:%f, SEGmeasure:%f, DETmeasure:%f\n',sx(1),sx(2),sx(3));
segParams=Read.getSegmentationParams(conn);
if isempty(res)
res=table(sx,{jsonencode(segParams)},'VariableNames',{'TRA_SEG_DET','segParams'});
res=table(sx(1),sx(2),sx(3),{jsonencode(segParams)},'VariableNames',{'TRA','SEG','DET','segParams'});
else
res=[res;sx,{jsonencode(segParams)}];
res=[res;sx(1),sx(2),sx(3),{jsonencode(segParams)}];
end
close(conn);
......
DEST='f:\autowrangler2';
strDB='g:\leverjs\ctc2020\2d\Fluo-N2DL-HeLa_training_01.LEVER';
DEST='/g/autowrangler';
strDB='/f/leverjs/ctc2020/2d/Fluo-N2DL-HeLa_training_02.LEVER';
[~,dsName,~]=fileparts(strDB);
outfolder=fullfile(DEST,dsName);
if exist(outfolder,'dir')
......@@ -12,12 +12,13 @@ end
conn=database(strDB, '','', 'org.sqlite.JDBC', 'jdbc:sqlite:');
segParams=Read.getSegmentationParams(conn);
hTarget=[0.001,0.005,0.01,0.05,0.1];
% s=[0.5:0.025:0.7];
s=[[1.5,0.25,4];[2,0.25,4];[2,0.2,4]];
spWrangle=[];
for h=1:length(hTarget)
for h=1:length(s)
sp=segParams;
sp.alpha(1)=0.6;
sp.NLM(1)=hTarget(h);
sp.sensitivity(1)=0.55; %s(h);
sp.minimumRadius_um=s(h,:);
spWrangle=[spWrangle,sp];
buildWrangleFile(strDB,outfolder,[dsName '_param_' num2str(length(spWrangle))],sp);
end
......
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