diff --git a/matlab/+Read/getAlgorithms.m b/matlab/+Read/getAlgorithms.m index 28bf59ba16b242200fa169c3052fbad25879250c..37ca48beea1a4be7a129682e37adf1d08105632a 100644 --- a/matlab/+Read/getAlgorithms.m +++ b/matlab/+Read/getAlgorithms.m @@ -6,9 +6,11 @@ if isempty(Q) algorithms=[]; return end -algorithms=cellfun(@jsondecode,Q); +algorithms=cellfun(@jsondecode,Q,'UniformOutput',false); for i=1:length(algorithms) - if isfield(algorithms(i),'function') - algorithms(i).function=str2func(algorithms(i).function(2:end-2)); + if isfield(algorithms{i},'function') + algorithms{i}.function=str2func(algorithms{i}.function(2:end-2)); end -end \ No newline at end of file +end + +algorithms=[algorithms{:}]; \ No newline at end of file diff --git a/matlab/+Read/getSegmentationParams.m b/matlab/+Read/getSegmentationParams.m index 86540b24b87465709a1af172f4441a859d549129..90d02e0e95153618df5514bcc74cfc0aa282e3cd 100644 --- a/matlab/+Read/getSegmentationParams.m +++ b/matlab/+Read/getSegmentationParams.m @@ -2,6 +2,10 @@ function segParams=getSegmentationParams(conn) algs=Read.getAlgorithms(conn,'segment'); if ~isempty(algs) + if length(algs)>1 + fprintf(2,'WARNING %s found multiple segmentations -- picking first',conn.DataSource); + algs=algs(1); + end segParams=algs.params; % settings from db else segParams=[]; diff --git a/matlab/+Write/setChannelLoGfolder.m b/matlab/+Write/setChannelLoGfolder.m new file mode 100644 index 0000000000000000000000000000000000000000..0f3ec46bed3716adfff04a8603db8b7cac5766e8 --- /dev/null +++ b/matlab/+Write/setChannelLoGfolder.m @@ -0,0 +1,41 @@ +% add channel log to folder +% ROOT = '/g/leverjs/mcf10a_3d_final' +function setChannelLoGfolder(ROOT,featureParams) +% +if ~exist('featureParams','var') + featureParams.name='erkLoG'; + featureParams.radius_um=4; + featureParams.channel=2; + featureParams.color='#ff00ff'; +end +flist = dir(fullfile(ROOT,'/**/*.LEVER')); + +% extracted via processJSON.m +logjs = ['{"name":"signalLoG","type":"feature","description":"dark nucleus detector",' ... + '"function":"+CellFeatures.channelLoG.m","commandHost":"matlab"}']; +logAlg = jsondecode(logjs); +logAlg.params=featureParams; +logjs = jsonencode(logAlg); % with params +targetChannel=2; +for ff=1:length(flist) + strDB=fullfile(flist(ff).folder,flist(ff).name); + [conn,CONSTANTS,segParams]=openDB(strDB); + nameCheck=strfind(lower({CONSTANTS.renderParams.name}),'erk'); + if nameCheck{targetChannel}~=1 + fprintf(2,'%s: erk name not set (%s)\n',strDB,CONSTANTS.renderParams(2).name); + continue + end + algs=Read.getAlgorithms(conn,'feature'); + % already there? + parx={algs.params}; + algCheck = cellfun(@(x) strcmp(x.name,'erkLoG'),parx); + if any(algCheck) + fprintf(1,'%s: found erkLoG algorithm, skipping insert\n',strDB); + else + cmd=['insert into tblAlgorithms(fqn,type,jsAlgorithmInfo) values (' ... + '''' logAlg.name ''', ''' logAlg.type ''', ''' logjs ''')']; + exec(conn,cmd); + end + Batch.batchFeatures(conn,CONSTANTS,28); + close(conn) +end \ No newline at end of file diff --git a/matlab/logStudy.m b/matlab/logStudy.m index 3e9127ec29cdf6d965a5fc84adff3da1b7ee621a..d99c5dd5269cd17a8f03dc5114cc1c3c50b971f9 100644 --- a/matlab/logStudy.m +++ b/matlab/logStudy.m @@ -10,7 +10,7 @@ % if you're at the bottom of a bowl, 2nd derivative is + sz=200; center=round(sz/2); -radius=10; +radius=20; im=zeros([sz,sz]); for y=1:size(im,1) @@ -18,24 +18,23 @@ for y=1:size(im,1) d = sqrt((y-center)^2 + (x-center)^2); if d<radius im(y,x)=1; -% elseif d<radius+2 -% im(y,x)=1; end end end +im=imcomplement(im); -% clf; -strDB = '/f/leverjs/Olivier/Yannick/20210924/20210924_pos1.LEVER'; -t=187;channelERK=2; -im=leversc.loadImage(strDB,t,channelERK); -im=mat2gray(im); -radius=3; -% imagesc(im) - -rx = 1/sqrt(2) .* [radius,radius,0]; +rx = 1/2 .* [radius,radius,0]; imf = HIP.LoG(im,rx,[]); -imc = Segment.separateLoG(imf); -figure;imagesc(imc); -[conn,CONSTANTS,segParams]=openDB(strDB); -cellList=Read.getCellsTime(conn,1,1,CONSTANTS); -hold on;for i=1:length(cellList),plot(cellList(i).surface(:,1),cellList(i).surface(:,2),'color','m'),end \ No newline at end of file + +clf; +plot(imf(center,:)); +hold on +plot(im(center,:)) + + +% +% imc = Segment.separateLoG(imf); +% figure;imagesc(imc); +% [conn,CONSTANTS,segParams]=openDB(strDB); +% cellList=Read.getCellsTime(conn,1,1,CONSTANTS); +% hold on;for i=1:length(cellList),plot(cellList(i).surface(:,1),cellList(i).surface(:,2),'color','m'),end \ No newline at end of file