...
 
Commits (2)
......@@ -71,7 +71,8 @@ MicroscopeData.WriterH5(im,'imageData',imd,'path',outfolder);
function export(filename,outpath,gtFile)
[~,exp,~]=fileparts(filename);
tokens=regexp(exp,'(\D+)_(\d+)','tokens');
exp=strrep(exp,'_training','');
tokens=regexp(exp,'(.+)_(\d\d)','tokens');
dsName=tokens{1}{1};
dsID=tokens{1}{2};
% strip off the _01 or _02 of the exp
......@@ -81,11 +82,11 @@ else
subdir='02_RES';
end
% exp=exp(1:end-3);
outpath=fullfile(outpath,exp,subdir);
if ~exist(outpath,'dir')
mkdir(outpath);
outpath=fullfile(outpath,dsName,subdir);
if exist(outpath,'dir')
rmdir(outpath,'s');
end
mkdir(outpath);
fprintf(1,'exporting to folder %s\n',outpath);
conn = database(filename, '','', 'org.sqlite.JDBC', 'jdbc:sqlite:');
......@@ -189,6 +190,9 @@ if size(tids,1)>1
else
tidString=['(' jsonencode(tids(1)) ')'];
end
tDigits=ceil(log10(CONSTANTS.imageData.NumberOfFrames));
tDigits=max(tDigits,3);
digitFormat=['%0' num2str(tDigits) 'd'];
for t=1:CONSTANTS.imageData.NumberOfFrames
tImageLabels=[0]; % make sure no one gets over written
% NOTE -- add segCC asc as there is an issue with segCC's of -1 (from
......@@ -210,7 +214,7 @@ for t=1:CONSTANTS.imageData.NumberOfFrames
end
im=setMissingTrackLabels(conn,im,tids,t);
fname=['mask' num2str(t-1,'%03d') '.tif'];
fname=['mask' num2str(t-1,digitFormat) '.tif'];
im=uint16(im);
if size(im,3)>1
imwrite(im(:,:,1),fullfile(outpath,fname));
......@@ -271,11 +275,15 @@ for i=1:length(idsMissing)
cxInterp=cx{idx0}.*w0 + cx{idx1} .* w1 ;
cxInterp=round(cxInterp);
if length(size(im))<3
cxInterp=cxInterp(1:2);
cxInterp=cxInterp(1:2);
cxInterp=min(cxInterp,[size(im,2);size(im,1)]);
cxInterp=max(cxInterp,ones(length(cxInterp),1));
im(cxInterp(2),cxInterp(1))=idsMissing(i);
else
cxInterp=min(cxInterp,[size(im,2);size(im,1);size(im,3)]);
cxInterp=max(cxInterp,ones(length(cxInterp),1));
im(cxInterp(2),cxInterp(1),cxInterp(3))=idsMissing(i);
end
cxInterp=min(cxInterp,[size(im,2);size(im,1)]);
cxInterp=max(cxInterp,ones(length(cxInterp),1));
im(cxInterp(2),cxInterp(1))=idsMissing(i);
end
......
......@@ -9,43 +9,32 @@ path(path,fullfile(thisFolder,'..','ctc/importExport'));
outfolder=fullfile(evalFolder,'eval');
% results file
if ~exist('./evalScore','dir')
mkdir('./evalScore');
end
idxParam=strfind(targetName,'_param');
if ~isempty(idxParam)
strResults=targetName(1:idxParam-1);
else
strResults=targetName;
end
strResults=fullfile('./evalScore',[strResults '_res.txt']);
if exist(strResults,'file')
res=readtable(strResults,'delimiter',',');
else
res=[];
end
fname=strDB;
fname=strrep(fname,'_training','');
tokens=regexp(targetName,'(.*)_training_(\d\d)','tokens');
if isempty(tokens)
fprintf(2,'file %s training info not found - skipping \n',strDB);
return
end
dsName=tokens{1}{1};
dsID=tokens{1}{2};
importExport(strDB,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);
end
copyfile(gtSource,fullfile(outfolder,targetName,[dsID '_GT']),'f');
gtTarget=fullfile(outfolder,dsName,[dsID '_GT']);
if ~exist(gtTarget,'dir')
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);
return
end
copyfile(gtSource,gtTarget);
end
if ispc
TRA='TRAMeasure.exe';
......@@ -60,13 +49,13 @@ else
end
system([fullfile(exePath,TRA) ' ' ...
fullfile(outfolder,targetName) ' ' dsID ' > score.txt']);
fullfile(outfolder,dsName) ' ' dsID ' > score.txt']);
system([fullfile(exePath,SEG) ' ' ...
fullfile(outfolder,targetName) ' ' dsID ' >> score.txt']);
fullfile(outfolder,dsName) ' ' dsID ' >> score.txt']);
system([fullfile(exePath,DET) ' ' ...
fullfile(outfolder,targetName) ' ' dsID ' >> score.txt']);
fullfile(outfolder,dsName) ' ' dsID ' >> score.txt']);
fid=fopen('score.txt');
scoreTxt=fscanf(fid,'%s');
......@@ -80,14 +69,9 @@ fprintf(1,'TRAmeasure:%f, SEGmeasure:%f, DETmeasure:%f\n',sx(1),sx(2),sx(3));
[conn,CONSTANTS]=openDB(strDB);
segParams=Read.getSegmentationParams(conn);
if isempty(res)
res=table(sx(1),sx(2),sx(3),{jsonencode(segParams)},'VariableNames',{'TRA','SEG','DET','segParams'});
else
res=[res;sx(1),sx(2),sx(3),{jsonencode(segParams)}];
end
res=table(sx(1),sx(2),sx(3),{jsonencode(segParams)},'VariableNames',{'TRA','SEG','DET','segParams'});
close(conn);
writetable(res,strResults);
% eval all the datasets in the release folder
ROOT='/f/leverjs/ctc2020rc'
flist=dir(fullfile(ROOT,'**/*training*.LEVER'));
results=[];
for ff=1:length(flist)
if strcmp(flist(ff).name(1:2),'BF')
continue
end
strDB=fullfile(flist(ff).folder,flist(ff).name);
res=ctcEval1(strDB);
% drop the segparams
res=res(1,1:3);
res=[{datetime},{strDB},res];
res.Properties.VariableNames{1}='date-time';
res.Properties.VariableNames{2}='strDB';
results=[results;res]
end
writetable(results,'/f/leverjs/ctc2020rc/results.txt')
\ No newline at end of file