Commit 5110c884 authored by Andrew Cohen's avatar Andrew Cohen

updated importExport with new label scheme, exportAll

parent 919ad5aa
*.tif
*.txt
*.mat
*.asv
% exportAll.m
ROOT='g:\leverjs\ctc2018_finalResults\';
outfolder='g:\leverjs\ctc2018_finalResuls\results';
flist=dir(fullfile(ROOT,'**\*.LEVER'));
% ROOT='g:\leverjs\ctc2018_finalResults\';
ROOT='\\bioimage32.coe.drexel.edu\f\leverjs\ctc2020rc';
gtPath='\\bioimage32.coe.drexel.edu\g\gRaw\ctc2020\';
outfolder='g:\leverjs\ctc2020_finalResults\results';
flist=dir(fullfile(ROOT,'*\*challenge*.LEVER'));
for ff=1:length(flist)
importExport(fullfile(flist(ff).folder,flist(ff).name),outfolder);
strDB=fullfile(flist(ff).folder,flist(ff).name);
gtFile=findGT(strDB,gtPath);
fprintf(1,'%s (%s) \n',strDB,gtFile)
importExport(strDB,outfolder);
end
\ No newline at end of file
function gtFile=findGT(strDB,gtPath)
[folderPath,fullname,~]=fileparts(strDB);
dsName=fullname;
dsID=fullname(end-1:end);
fullname=fullname(1:end-3);
dsName=strrep(dsName,'_challenge','');
dsName=dsName(1:end-3);
folderTree=split(folderPath,filesep);
xd=folderTree{end};
gtFile=fullfile(gtPath,[xd '_' fullname],dsName,[dsID '_GT']);
if ~exist(gtFile,'file')
gtFile=[];
end
% generate processing table
leverRoot='.\leverData';
flist=dir(fullfile(leverRoot,'*.LEVER'));
imageRoot='..\';
rgProcess=[];
rgp=[];
batOutFolder='./';
if ~exist(batOutFolder,'dir')
mkdir(batOutFolder);
end
for ff=1:length(flist)
leverFile=fullfile(flist(ff).folder,flist(ff).name);
expname=flist(ff).name(1:end-length('_01.LEVER'));
expnumber=flist(ff).name(end-length('01.LEVER')+1:end-length('.LEVER'));
gtPath='';
imagePath=fullfile(imageRoot,expname,expnumber);
if ~exist(imagePath)
imagePath=fullfile(imageRoot,expname,expname,expnumber);
if ~exist(imagePath)
fprintf(2,'image data not found! imagePath=%s\n',imagePath);
end
end
if exist([imagePath '_GT'],'dir')
gtPath=[imagePath '_GT'];
gtPath=fullfile(gtPath,'TRA','man_track000.tif');
if ~exist(gtPath,'file')
fprintf(2,'ERROR - bad gtPath file does not exist\n');
end
end
rp.leverFile=leverFile;
rp.imagePath=imagePath;
rp.gtPath=gtPath;
rgProcess=[rgProcess,rp];
rgp=[ rgp; {leverFile,imagePath,gtPath}];
outfile=fullfile(batOutFolder,[expname '_' expnumber '.bat']);
fid=fopen(outfile,'w');
if strcmp(gtPath,'')
fprintf(fid,'processBatch.bat "%s", "%s"\n',imagePath,leverFile);
else
fprintf(fid,'processBatch.bat "%s", "%s", "%s"\n',imagePath,leverFile,gtPath);
end
fclose(fid);
end
\ No newline at end of file
......@@ -74,6 +74,7 @@ function export(filename,outpath,gtFile)
exp=strrep(exp,'_training','');
tokens=regexp(exp,'(.+)_(\d\d)','tokens');
dsName=tokens{1}{1};
dsName=strrep(dsName,'_challenge','');
dsID=tokens{1}{2};
% strip off the _01 or _02 of the exp
if strcmp(dsID,'01')
......@@ -112,7 +113,7 @@ end
% lbgep=[label, begin, end, parent]
lbep=[];
for i=1:length(tids)
label=tids(i);
label=i; %tids(i);
cmd=['select min(time),max(time) from tblCells where trackID=' num2str(tids(i))];
q=ljsFetch(conn,cmd);
if isempty(q) || 0==size(q,1)
......@@ -176,6 +177,15 @@ if 0==size(lbep,1)
return;
end
% reset parent trackID to label
for i=1:size(lbep,1)
if 0==lbep(i,4)
continue
end
idxParentLabel=find([lbep(:,5)]==lbep(i,4));
lbep(i,4)=lbep(idxParentLabel,1);
end
if any(lbep(:,2)>lbep(:,3))
fprintf(2,'bad begin end timing detected ACK\n');
end
......@@ -210,7 +220,9 @@ for t=1:CONSTANTS.imageData.NumberOfFrames
else
idx=sub2ind(szImage,iCell.pts(:,2),iCell.pts(:,1));
end
im(idx)=iCell.trackID;
idxLabel=find(tids(:,1)==iCell.trackID);
im(idx)=tids(idxLabel,2);
% im(idx)=iCell.trackID;
end
im=setMissingTrackLabels(conn,im,tids,t);
......@@ -250,7 +262,7 @@ 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! guessing...\n');
fprintf(2,'neither t-1 nor t+1 available for interp! long range interp...\n');
tt=trackTime-t;
tt(tt<0)=[];
tt1=min(tt);
......@@ -274,15 +286,17 @@ for i=1:length(idsMissing)
w1=1-(trackTime(idx1)-t)/(trackTime(idx1)-trackTime(idx0));
cxInterp=cx{idx0}.*w0 + cx{idx1} .* w1 ;
cxInterp=round(cxInterp);
idxLabel=find(tids(:,1)==idsMissing(i));
if length(size(im))<3
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);
im(cxInterp(2),cxInterp(1))=tids(idxLabel,2);
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);
im(cxInterp(2),cxInterp(1),cxInterp(3))=tids(idxLabel,2);
end
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