Commit fc2c79d1 authored by Turnhout, M.C. van's avatar Turnhout, M.C. van
Browse files

add disappearing droplet checks to BF and fluo analysis (many thanks to Ayla...

add disappearing droplet checks to BF and fluo analysis (many thanks to Ayla for her keen debugging), requires similar checks in tracing scripts etc.
parent 3d5f0c88
......@@ -69,10 +69,19 @@ for t = 1:nframe/param.nchan
for n = 1:size(BF, 1)
idx = find(D(n, :) == min(D(n, :)));
if ~isempty(idx)
BF(n, 1+5*(t-1)) = idx;
BF(n, 2+5*(t-1):3+5*(t-1)) = C(idx, :);
BF(n, 4+5*(t-1)) = R(idx);
BF(n, 5+5*(t-1)) = D(n, idx);
% check distance
if D(n, idx) <= BF(n, 4+5*(t-2))*param.maxmove && ...
isempty( find( BF(n, 4:5:4+5*(t-2)) == 0, 1) ) % check disappearance
% add detected droplet
BF(n, 1+5*(t-1)) = idx;
BF(n, 2+5*(t-1):3+5*(t-1)) = C(idx, :);
BF(n, 4+5*(t-1)) = R(idx);
BF(n, 5+5*(t-1)) = D(n, idx);
else
fprintf('\t\t\tdroplet %3i disappeared\n', n)
end
end
end
......
......@@ -74,48 +74,50 @@ for t = 1:nframe/param.nchan
% analyse fluorescence
for n = 1:size(BF, 1)
% get mask
mask = DMA_dropletmask(x, y, BF(n, 2+5*(t-1):4+5*(t-1)) );
% loop over fluorescence channels
for c = 1:numel(param.fluo)
% read image
F = DMA_tifread(fullfile(param.dir, imname), ...
param.fluo(c) + (t-1)*param.nchan, param);
if BF(n, 1+5*(t-1)) > 0
% perform fluorescence analysis
if param.cellminIraw > 0
[raw, ~, BW] = DMA_preprocessfluo(F, mask, c, param);
else
[~, raw, BW] = DMA_preprocessfluo(F, mask, c, param);
end
[count, mi] = DMA_countfluo(raw, BW, c, param);
% get mask
mask = DMA_dropletmask(x, y, BF(n, 2+5*(t-1):4+5*(t-1)) );
% store data
ncel(n, c+numel(param.fluo)*(t-1)) = count(1); % number of detected cells
bgi(n, c+numel(param.fluo)*(t-1)) = count(2); % background intensity
if sum(mi(:, 1)) > 0
% mean object / cell intensity
fluo(n, c+numel(param.fluo)*(t-1)) = ...
mean(nonzeros(mi(:, 1)));
end
if param.cellminIrel > 0
fluo(n, c+numel(param.fluo)*(t-1)) = ...
fluo(n, c+numel(param.fluo)*(t-1))/...
bgi(n, c+numel(param.fluo)*(t-1));
% loop over fluorescence channels
for c = 1:numel(param.fluo)
% read image
F = DMA_tifread(fullfile(param.dir, imname), ...
param.fluo(c) + (t-1)*param.nchan, param);
% perform fluorescence analysis
if param.cellminIraw > 0
[raw, ~, BW] = DMA_preprocessfluo(F, mask, c, param);
else
[~, raw, BW] = DMA_preprocessfluo(F, mask, c, param);
end
[count, mi] = DMA_countfluo(raw, BW, c, param);
% store data
ncel(n, c+numel(param.fluo)*(t-1)) = count(1); % number of detected cells
bgi(n, c+numel(param.fluo)*(t-1)) = count(2); % background intensity
if sum(mi(:, 1)) > 0
% mean object / cell intensity
fluo(n, c+numel(param.fluo)*(t-1)) = ...
mean(nonzeros(mi(:, 1)));
end
if param.cellminIrel > 0
fluo(n, c+numel(param.fluo)*(t-1)) = ...
fluo(n, c+numel(param.fluo)*(t-1))/...
bgi(n, c+numel(param.fluo)*(t-1));
end
% individual object properties
obI((n-1)*param.maxcells+1:n*param.maxcells, ...
c+numel(param.fluo)*(t-1)) = mi(:, 1);
obx((n-1)*param.maxcells+1:n*param.maxcells, ...
c+numel(param.fluo)*(t-1)) = mi(:, 2);
oby((n-1)*param.maxcells+1:n*param.maxcells, ...
c+numel(param.fluo)*(t-1)) = mi(:, 3);
obA((n-1)*param.maxcells+1:n*param.maxcells, ...
c+numel(param.fluo)*(t-1)) = mi(:, 4);
end
% individual object properties
obI((n-1)*param.maxcells+1:n*param.maxcells, ...
c+numel(param.fluo)*(t-1)) = mi(:, 1);
obx((n-1)*param.maxcells+1:n*param.maxcells, ...
c+numel(param.fluo)*(t-1)) = mi(:, 2);
oby((n-1)*param.maxcells+1:n*param.maxcells, ...
c+numel(param.fluo)*(t-1)) = mi(:, 3);
obA((n-1)*param.maxcells+1:n*param.maxcells, ...
c+numel(param.fluo)*(t-1)) = mi(:, 4);
end
end
end
......@@ -146,4 +148,4 @@ DMA_writecsv(fullfile(param.dir, imname), ncel, param);
fprintf('\tanalysis done for %s -->\n\n', fullfile(param.dir, imname));
% part of DMAlab: https://gitlab.tue.nl/STEM/DMAlab
end
\ No newline at end of file
end
......@@ -7,6 +7,8 @@ r = sqrt( (x-c(1)).^2 + (y-c(2)).^2 );
r(r > c(3)) = 0; % zeros outside droplet
r(r > 0) = 1; % ones inside droplet
nargout
if nargout > 1
% get bounding box
q = regionprops(r, 'BoundingBox');
......
......@@ -256,7 +256,7 @@ update_plot
% pre-processed data
[~, f] = DMA_preprocessfluo(F, mask, c, param);
elseif style == 4
% idenified cells
% identified cells
if param.cellminIraw > 0
[raw, ~, bw] = DMA_preprocessfluo(F, mask, c, param);
else
......
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