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