Commit 4aa2745b authored by ac 20's avatar ac 20

Merge branch 'master' of git-bioimage.coe.drexel.edu:bioimage/leverjs

parents f394a32f c82440fa
......@@ -773,6 +773,13 @@ function getExtFamilies(lDB,fnCallback)
} // getExtFamlies
function featureCompare(a,b)
{
if (a.trackID==b.trackID)
return a.time-b.time;
// else
return a.trackID-b.trackID;
}
// getCellFeatures
// called by getFamiliesDB
......@@ -798,10 +805,10 @@ function getCellFeatures(lDB,rowsTracks,fnCallback)
const LeverDB=require('./lever.js');
var leverDB=new LeverDB();
leverDB.lDB=lDB;
leverDB.getConstants(function(err,cx) {
sqlCmd='select tblCellFeatures.*,time,trackID from tblCellFeatures inner join tblCells on '+
' tblCellFeatures.cellID=tblCells.CellID order by trackID asc';
leverDB.getConstants(function(err,cx) {
sqlCmd='select tblCellFeatures.*,time,trackID from tblCellFeatures inner join tblCells on '+
' tblCellFeatures.cellID=tblCells.CellID where trackID in '+trackIDstr;
lDB.all(sqlCmd,function(err,rowFeatures){
if (err) {
// ok if there's no cellFeatures table...keep going...
......@@ -812,16 +819,18 @@ function getCellFeatures(lDB,rowsTracks,fnCallback)
fnCallback(rowsTracks);
return;
}
rowFeatures.sort(featureCompare);
var cxFeatures=cxGetCellFeatures(cx);
var jFeature=0;
for (var i=0;i<rowsTracks.length;i++) {
rowsTracks[i].features=[];
// rowFeatures is sorted by time and trackID so we don't need to iterate
// over the whole list everytime
for (var j=jFeature;j<rowFeatures.length;j++) {
if (rowFeatures[j].trackID<rowsTracks[i].trackID)
continue;
if (rowFeatures[j].trackID>rowsTracks[i].trackID)
break;
break;
jFeature=j+1;
var cellFeature=[];
......@@ -879,7 +888,7 @@ var sqlCmdTracks='select t1.trackID,min(time) as t0,max(time) as t1, jsColor FR
UpdateTime();
if (undefined!==fnCallback)
fnCallback([],[],0);
fnCallback([],[],0,[],[]);
return;
}
getExtFamilies(lDB, function(extFamilyTrackIDs) {
......
......@@ -140,7 +140,7 @@ end
CC=bwconncomp(L);
for n=1:num
idx=CC.PixelIdxList{n};
if length(idx)<area_min|| max(d(idx))<dmin
if length(idx)<area_min && max(d(idx))<dmin
continue
end
if is3D(im)
......
......@@ -25,6 +25,9 @@ for nDilate=1:nIter
% 3 things can happen: (0) CC s (1) CC disappears (2) CC splits
idxWL=vertcat(CC.PixelIdxList{:});
map=unique([workingL(idxWL),L(idxWL)],'rows');
if isempty(map)
break;
end
map(map(:,2)==0,:)=[];
mapCounts=hist(map(:,1),[1:max(map(:,1))])';
idxChange=find(mapCounts>1);
......
......@@ -12,7 +12,6 @@ else
end
if is3D(im)
nsz=2*floor(size(im)/16)+1;
T=adaptthresh(imLog,0.5,'NeighborhoodSize',nsz,'statistic','gaussian');
bwLog=imbinarize(imLog,T);
......@@ -32,37 +31,9 @@ bwLog=imbinarize(imLog,T);
bwLog=bwareaopen(bwLog,4*min_area_pixels);
if segParams.isPhase
se=strel('disk',1);
se2=strel('disk',ceil(min_radius_pixels/2));
if segParams.isPhase>0
T=adaptthresh(im,sensitivity,'foregroundpolarity','dark','statistic','gaussian');
else
T=adaptthresh(im,sensitivity,'foregroundpolarity','bright','statistic','gaussian');
end
bw=imbinarize(im,T);
if segParams.isPhase>0
bw=imcomplement(bw);
end
bw=imclose(bw,se2);
bw=imfill(bw,'holes');
if true==segParams.wellRadius
bwMask=imbinarize(medianMask,adaptthresh(medianMask,'statistic','gaussian'));
bw=bw&~bwMask;
bwh=imfill(bw,'holes');
nrep=0;
% if the mask forms a solid circle, the hole fill on bw will fill
% in the whole foreground. dilate mask until that doesn't happen...
while nrep<5 && length(find(bwh&~bw))/length(bw(:))>0.25
nrep=nrep+1;
bwMask=imdilate(bwMask,se);
bw=bw&~bwMask;
end
bw=imfill(bw,'holes');
bw=imopen(bw,se);
bwLog=bwLog&~bwMask;
bwLog=imclose(bwLog,se2);
end
bw=imfill(bw,'holes');
[bw,bwLog]=phaseThreshold(im,bwLog,min_radius_pixels,segParams,...
sensitivity,medianMask);
return;
else
% use 2x the default nhood size
T=adaptthresh(im,sensitivity,'NeighborhoodSize',4*floor(size(im)/16)+1,'statistic','gaussian');
......@@ -71,5 +42,43 @@ end
bw=bwareaopen(bw,min_area_pixels);
4;
function [bw,bwLog]=phaseThreshold(im,bwLog,min_radius_pixels,segParams,...
sensitivity,medianMask)
se=strel('disk',1);
se2=strel('disk',ceil(min_radius_pixels/2));
if segParams.isPhase>0
T=adaptthresh(im,sensitivity,'foregroundpolarity','dark','statistic','gaussian');
else
T=adaptthresh(im,sensitivity,'foregroundpolarity','bright','statistic','gaussian');
end
bw=imbinarize(im,T);
if segParams.isPhase>0
bw=imcomplement(bw);
end
bw=imclose(bw,se2);
bw=imfill(bw,'holes');
if true==segParams.wellRadius
[bw,bwLog]=thesholdMask(medianMask,bw,bwLog,se,se2);
end
function [bw,bwLog]=thesholdMask(medianMask,bw,bwLog,se,se2)
bwMask=imbinarize(medianMask,adaptthresh(medianMask,'statistic','gaussian'));
bw=bw&~bwMask;
bwh=imfill(bw,'holes');
nrep=0;
% if the mask forms a solid circle, the hole fill on bw will fill
% in the whole foreground. dilate mask until that doesn't happen...
while nrep<5 && length(find(bwh&~bw))/length(bw(:))>0.25
nrep=nrep+1;
bwMask=imdilate(bwMask,se);
bw=bw&~bwMask;
end
bw=imfill(bw,'holes');
bw=imopen(bw,se);
bwLog=bwLog&~bwMask;
bwLog=imclose(bwLog,se2);
% build matlabPollDB
[b,m]=fileparts(pwd);
[b,f]=fileparts(fileparts(pwd));
if ~strcmp('leverjs',f) || ~strcmp('matlab',m)
fprintf(1,'you need to run from the leverjs/matlab folder!\n');
% return
end
if ~exist('buildOutput','dir')
mkdir('buildOutput')
end
if exist('../../leverUtilities/src/MATLAB')
mcc -a '../../leverUtilities/src/MATLAB/+MicroscopeData/+Original/+BioFormats/bioformats_package.jar'...
-a sqlite-jdbc-3.21.0.jar -m importFolder.m -d buildOutput
elseif exist('../../utilities/src/MATLAB')
mcc -a '../../utilities/src/MATLAB/+MicroscopeData/+Original/+BioFormats/bioformats_package.jar'...
-a sqlite-jdbc-3.21.0.jar -m importFolder.m -d buildOutput
else
fprintf(2,'could not find leverUtilities in either ../../utilties or ../../leverUtilities\n');
fprintf(2,'not building leverImporter. please check path and try again\n');
end
mcc -a sqlite-jdbc-3.21.0.jar -a +Segment -a +Mitosis -a +CellFeatures ...
-m matlabPollDB.m -d buildOutput
% copy over the matlabAlgorithms.json, inserting sha hashes to match git commit
% tags
processJSON();
if ispc
copyfile(fullfile('buildOutput','matlabPollDB.exe'),fullfile('..','prebuilt'))
copyfile(fullfile('buildOutput','importFolder.exe'),fullfile('..','prebuilt'))
elseif ismac
system('cp -r buildOutput/matlabPollDB.app ../prebuilt');
copyfile(fullfile('buildOutput','run_matlabPollDB.sh'),fullfile('..','prebuilt','mac_run_matlabPollDB.sh'))
system('chmod +x ../prebuilt/mac_run_matlabPollDB.sh');
system('cp -r buildOutput/importFolder.app ../prebuilt');
copyfile(fullfile('buildOutput','run_importFolder.sh'),fullfile('..','prebuilt','mac_run_importFolder.sh'))
system('chmod +x ../prebuilt/mac_run_importFolder.sh');
elseif isunix
copyfile(fullfile('buildOutput','matlabPollDB'),fullfile('..','prebuilt'),'f');
copyfile(fullfile('buildOutput','run_matlabPollDB.sh'),fullfile('..','prebuilt','run_matlabPollDB.sh'))
system('chmod +x ../prebuilt/run_matlabPollDB.sh');
copyfile(fullfile('buildOutput','importFolder'),fullfile('..','prebuilt'),'f');
copyfile(fullfile('buildOutput','run_importFolder.sh'),fullfile('..','prebuilt','run_importFolder.sh'))
system('chmod +x ../prebuilt/run_importFolder.sh');
end
% build matlabPollDB
function buildLever()
startFolder=pwd();
thisFile=mfilename('fullpath');
[thisFolder,~,~]=fileparts(thisFile);
cd(thisFolder);
if ~exist('buildOutput','dir')
mkdir('buildOutput')
end
if exist('../../leverUtilities/src/MATLAB')
mcc -a '../../leverUtilities/src/MATLAB/+MicroscopeData/+Original/+BioFormats/bioformats_package.jar'...
-a sqlite-jdbc-3.21.0.jar -m importFolder.m -d buildOutput
elseif exist('../../utilities/src/MATLAB')
mcc -a '../../utilities/src/MATLAB/+MicroscopeData/+Original/+BioFormats/bioformats_package.jar'...
-a sqlite-jdbc-3.21.0.jar -m importFolder.m -d buildOutput
else
fprintf(2,'could not find leverUtilities in either ../../utilties or ../../leverUtilities\n');
fprintf(2,'not building leverImporter. please check path and try again\n');
end
mcc -a sqlite-jdbc-3.21.0.jar -a +Segment -a +Mitosis -a +CellFeatures ...
-m matlabPollDB.m -d buildOutput
% copy over the matlabAlgorithms.json, inserting sha hashes to match git commit
% tags
processJSON();
if ispc
copyfile(fullfile('buildOutput','matlabPollDB.exe'),fullfile('..','prebuilt'))
copyfile(fullfile('buildOutput','importFolder.exe'),fullfile('..','prebuilt'))
elseif ismac
system('cp -r buildOutput/matlabPollDB.app ../prebuilt');
copyfile(fullfile('buildOutput','run_matlabPollDB.sh'),fullfile('..','prebuilt','mac_run_matlabPollDB.sh'))
system('chmod +x ../prebuilt/mac_run_matlabPollDB.sh');
system('cp -r buildOutput/importFolder.app ../prebuilt');
copyfile(fullfile('buildOutput','run_importFolder.sh'),fullfile('..','prebuilt','mac_run_importFolder.sh'))
system('chmod +x ../prebuilt/mac_run_importFolder.sh');
elseif isunix
copyfile(fullfile('buildOutput','matlabPollDB'),fullfile('..','prebuilt'),'f');
copyfile(fullfile('buildOutput','run_matlabPollDB.sh'),fullfile('..','prebuilt','run_matlabPollDB.sh'))
system('chmod +x ../prebuilt/run_matlabPollDB.sh');
copyfile(fullfile('buildOutput','importFolder'),fullfile('..','prebuilt'),'f');
copyfile(fullfile('buildOutput','run_importFolder.sh'),fullfile('..','prebuilt','run_importFolder.sh'))
system('chmod +x ../prebuilt/run_importFolder.sh');
end
cd(startFolder)
\ No newline at end of file
No preview for this file type
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