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

add droplets checks to traceGUI

parent fc2c79d1
......@@ -7,8 +7,6 @@ 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');
......
......@@ -68,12 +68,12 @@ ch1i = plot( Ixl, size(im, 1) - fluo(drop, 2:3:end)*iscale, ...
ch2i = plot( Ixr, size(im, 1) - fluo(drop, 3:3:end)*iscale, ...
'g', 'linewidth', 0.5);
% intensities current frame
ch0ic = plot( Ixr(frame), size(bf, 1) - fluo(drop, 1+3*(frame-1))*iscale, 'g.', ...
'markersize', 15);
ch1ic = plot( Ixl(frame), size(im, 1) - fluo(drop, 2+3*(frame-1))*iscale, 'g.', ...
'markersize', 15);
ch2ic = plot( Ixr(frame), size(im, 1) - fluo(drop, 3+3*(frame-1))*iscale, 'g.', ...
'markersize', 15);
ch0ic = plot( Ixr(frame), size(bf, 1) - fluo(drop, 1+3*(frame-1))* ...
iscale, 'g.', 'markersize', 15);
ch1ic = plot( Ixl(frame), size(im, 1) - fluo(drop, 2+3*(frame-1))* ...
iscale, 'g.', 'markersize', 15);
ch2ic = plot( Ixr(frame), size(im, 1) - fluo(drop, 3+3*(frame-1))* ...
iscale, 'g.', 'markersize', 15);
% minI-threshhold
plot([size(bf, 2)+1 2*size(bf, 2)], ...
size(bf, 1)-mean(param.cellminI)*iscale*[1 1], 'g--')
......@@ -89,16 +89,17 @@ curcirch = viscircles(gca, [0 0], 1);
text(20, 40, 'BF', 'fontsize', 20, 'color', [1 1 1]);
text(size(bf, 2)+20, 40, 'ch00', 'fontsize', 20, 'color', [1 0 0]);
text(20, size(bf, 1)+40, 'ch01', 'fontsize', 20, 'color', [1 1 0]);
text(size(bf, 2)+20, size(bf, 1)+40, 'ch02', 'fontsize', 20, 'color', [0 1 0]);
text(size(bf, 2)+20, size(bf, 1)+40, 'ch02', 'fontsize', 20, 'color', ...
[0 1 0]);
figno = fh.Number;
%%% GUI elements
ssz = get(0, 'ScreenSize');
figure('units', 'pixel', 'position', [ssz(3)-625 600 600 500], 'Visible', ...
'on', 'Name', sprintf('Droplet tracing in %s', param.dir), ...
'NumberTitle', 'off');
figure('units', 'pixel', 'position', [ssz(3)-625 600 600 500], ...
'Visible', 'on', 'Name', ...
sprintf('Droplet tracing in %s', param.dir), 'NumberTitle', 'off');
% guino = guih.Number;
panelpos = [10 370 580 100];
......@@ -109,19 +110,20 @@ buttonpos = [70 45 150 25;
% set FoV control
FoVpanel = uipanel( ...
'Title', sprintf('FoV %i of %i: %s', fov, size(list, 1), list(fov).name), ...
'BackgroundColor', 'white', 'units', 'pixel', 'Position', panelpos);
'Title', sprintf('FoV %i of %i: %s', fov, size(list, 1), ...
list(fov).name), 'BackgroundColor', 'white', 'units', 'pixel', ...
'Position', panelpos);
% FoV number text
FoVnum = uicontrol('Parent', FoVpanel, 'Style', 'edit', 'Position', ...
numpos, 'BackgroundColor', [0.7 0.7 0.7]', ...
'String', num2str(fov), 'Callback', @updateFoVnum);
% previous FoV
FoVback = uicontrol('Parent', FoVpanel, 'Style', 'pushbutton', 'Position', ...
buttonpos(1, :), 'BackgroundColor', [1 0 0]', ...
FoVback = uicontrol('Parent', FoVpanel, 'Style', 'pushbutton', ...
'Position', buttonpos(1, :), 'BackgroundColor', [1 0 0]', ...
'String', 'previous FoV', 'Callback', @FoVbackbutton);
% next FoV
FoVnext = uicontrol('Parent', FoVpanel, 'Style', 'pushbutton', 'Position', ...
buttonpos(2, :), 'BackgroundColor', [1 1 0]', ...
FoVnext = uicontrol('Parent', FoVpanel, 'Style', 'pushbutton', ...
'Position', buttonpos(2, :), 'BackgroundColor', [1 1 0]', ...
'String', 'next FoV', 'Callback', @FoVnextbutton);
% random FoV
uicontrol('Parent', FoVpanel, 'Style', 'pushbutton', 'Position', ...
......@@ -129,9 +131,10 @@ uicontrol('Parent', FoVpanel, 'Style', 'pushbutton', 'Position', ...
'String', 'random FoV', 'Callback', @FoVrandbutton);
%%% second row
% select FoV
FoVselect = uicontrol('Parent', FoVpanel, 'Style', 'popupmenu', 'Position', ...
[numpos(1) 10 buttonpos(3, 3)+buttonpos(3, 1) numpos(end)], 'BackgroundColor', [0.7 0.7 0.7], ...
'String', {list(:).name}, 'Value', fov, 'Callback', @updateFoVselect);
FoVselect = uicontrol('Parent', FoVpanel, 'Style', 'popupmenu', ...
'Position', [numpos(1) 10 buttonpos(3, 3)+buttonpos(3, 1), ...
numpos(end)], 'BackgroundColor', [0.7 0.7 0.7], 'String', ...
{list(:).name}, 'Value', fov, 'Callback', @updateFoVselect);
% set droplet control
panelpos(2) = panelpos(2) - panelpos(4) - 2*panelpos(1);
......@@ -143,12 +146,12 @@ dropnum = uicontrol('Parent', droppanel, 'Style', 'edit', 'Position', ...
numpos, 'BackgroundColor', [0.7 0.7 0.7]', ...
'String', num2str(drop), 'Callback', @updatedropnum);
% previous droplet
dropback = uicontrol('Parent', droppanel, 'Style', 'pushbutton', 'Position', ...
buttonpos(1, :), 'BackgroundColor', [1 0 0]', ...
dropback = uicontrol('Parent', droppanel, 'Style', 'pushbutton', ...
'Position', buttonpos(1, :), 'BackgroundColor', [1 0 0]', ...
'String', 'previous droplet', 'Callback', @dropbackbutton);
% next droplet
dropnext = uicontrol('Parent', droppanel, 'Style', 'pushbutton', 'Position', ...
buttonpos(2, :), 'BackgroundColor', [1 1 0]', ...
dropnext = uicontrol('Parent', droppanel, 'Style', 'pushbutton', ...
'Position', buttonpos(2, :), 'BackgroundColor', [1 1 0]', ...
'String', 'next droplet', 'Callback', @dropnextbutton);
% random droplet
uicontrol('Parent', droppanel, 'Style', 'pushbutton', 'Position', ...
......@@ -156,10 +159,11 @@ uicontrol('Parent', droppanel, 'Style', 'pushbutton', 'Position', ...
'String', 'random droplet', 'Callback', @droprandbutton);
%%% second row
% interactive select
bg = imresize( imread(fullfile(DMA_labpath, 'pics/Flag_of_Jamaica.png')), [25 50]);
bg = imresize( imread(fullfile(DMA_labpath, ...
'pics/Flag_of_Jamaica.png')), [25 50]);
uicontrol('Parent', droppanel, 'Style', 'pushbutton', 'Position', ...
numpos-[0 35 0 0], 'Cdata', bg, ...
'String', 'pick', 'Foregroundcolor', [1 1 1], 'Callback', @droppickbutton);
numpos-[0 35 0 0], 'Cdata', bg, 'String', 'pick', ...
'Foregroundcolor', [1 1 1], 'Callback', @droppickbutton);
% set frame control
panelpos(2) = panelpos(2) - panelpos(4) - 2*panelpos(1);
......@@ -167,16 +171,16 @@ framepanel = uipanel( ...
'Title', sprintf('frame %i of %i', frame, nframe), ...
'BackgroundColor', 'white', 'units', 'pixel', 'Position', panelpos);
% framelet number text
framenum = uicontrol('Parent', framepanel, 'Style', 'edit', 'Position', ...
numpos, 'BackgroundColor', [0.7 0.7 0.7]', ...
framenum = uicontrol('Parent', framepanel, 'Style', 'edit', ...
'Position', numpos, 'BackgroundColor', [0.7 0.7 0.7]', ...
'String', num2str(frame), 'Callback', @updateframenum);
% previous framelet
frameback = uicontrol('Parent', framepanel, 'Style', 'pushbutton', 'Position', ...
buttonpos(1, :), 'BackgroundColor', [1 0 0]', ...
frameback = uicontrol('Parent', framepanel, 'Style', 'pushbutton', ...
'Position', buttonpos(1, :), 'BackgroundColor', [1 0 0]', ...
'String', 'previous frame', 'Callback', @framebackbutton);
% next framelet
framenext = uicontrol('Parent', framepanel, 'Style', 'pushbutton', 'Position', ...
buttonpos(2, :), 'BackgroundColor', [1 1 0]', ...
framenext = uicontrol('Parent', framepanel, 'Style', 'pushbutton', ...
'Position', buttonpos(2, :), 'BackgroundColor', [1 1 0]', ...
'String', 'next frame', 'Callback', @framenextbutton);
% random framelet
uicontrol('Parent', framepanel, 'Style', 'pushbutton', 'Position', ...
......@@ -185,21 +189,21 @@ uicontrol('Parent', framepanel, 'Style', 'pushbutton', 'Position', ...
% set fluo control
panelpos(2) = panelpos(2) - panelpos(4) - 2*panelpos(1);
fluopanel = uipanel( ...
'Title', sprintf(['fluorescence display, param.cellminI(ch) = %1.3f', ...
fluopanel = uipanel( 'Title', ...
sprintf(['fluorescence display, param.cellminI(ch) = %1.3f', ...
' (dashed green line)'], mean(param.cellminI)), 'BackgroundColor', ...
'white', 'units', 'pixel', 'Position', panelpos);
% fluorescence display raw/processed
fluostyle = uibuttongroup('Parent', fluopanel, 'Position', [.01 .1 .6 .8], ...
'SelectionChangeFcn', @update_fluostyle);
fluostyle = uibuttongroup('Parent', fluopanel, 'Position', ...
[.01 .1 .6 .8], 'SelectionChangeFcn', @update_fluostyle);
% fluorescence: intensity raw/scaled
fl1 = uicontrol(fluostyle, 'Style', 'radiobutton', 'String', 'raw intensity', ...
'Position', [10 35 150 30]);
fl1 = uicontrol(fluostyle, 'Style', 'radiobutton', 'String', ...
'raw intensity', 'Position', [10 35 150 30]);
fl2 = uicontrol(fluostyle, 'Style', 'radiobutton', 'String', ...
'scaled intensity', 'Position', [10 5 150 30]);
% fluorescence processed all/cells
fl3 = uicontrol(fluostyle, 'Style', 'radiobutton', 'String', 'data post-process', ...
'Position', [180 35 150 30]);
fl3 = uicontrol(fluostyle, 'Style', 'radiobutton', 'String', ...
'data post-process', 'Position', [180 35 150 30]);
fl4 = uicontrol(fluostyle, 'Style', 'radiobutton', 'String', ...
'identified cells', 'Position', [180 5 150 30]);
% set proper selction
......@@ -213,10 +217,12 @@ elseif style == 4
set(fl4, 'value', 1);
end
% go to parameter settings button
bg = imresize( imread(fullfile(DMA_labpath, 'pics/Flag_of_Ethiopia.png')), [50 100]);
bg = imresize( imread(fullfile(DMA_labpath, ...
'pics/Flag_of_Ethiopia.png')), [50 100]);
uicontrol('Parent', fluopanel, 'Style', 'pushbutton', 'Position', ...
[buttonpos(3, 1)+50 10 100 50], 'Cdata', bg, ...
'String', 'go to settings', 'Foregroundcolor', [0 0 0], 'Callback', @gosetbutton);
'String', 'go to settings', 'Foregroundcolor', [0 0 0], ...
'Callback', @gosetbutton);
% update plot
update_plot
......@@ -238,46 +244,55 @@ update_plot
% update fluorescence analysis
function update_plot
% load fluorescence
for c = 1:numel(param.fluo)
% get fluorescence image from stack
F = DMA_tifread(fullfile(param.dir, list(fov).name), ...
param.fluo(c) + (frame-1)*param.nchan, param);
if bfd(drop, 1+5*(frame-1)) > 0 % check if droplet still exists
% get mask & bounding box
[mask, bb] = DMA_dropletmask(x, y, ...
bfd(drop, 2+5*(frame-1):4+5*(frame-1)) );
if style == 2
% scaled raw data
f = imcrop(F, bb);
f = f/max(f(:));
elseif style == 3
% pre-processed data
[~, f] = DMA_preprocessfluo(F, mask, c, param);
elseif style == 4
% identified cells
if param.cellminIraw > 0
[raw, ~, bw] = DMA_preprocessfluo(F, mask, c, param);
% load fluorescence
for c = 1:numel(param.fluo)
% get fluorescence image from stack
F = DMA_tifread(fullfile(param.dir, list(fov).name), ...
param.fluo(c) + (frame-1)*param.nchan, param);
% get mask & bounding box
[mask, bb] = DMA_dropletmask(x, y, ...
bfd(drop, 2+5*(frame-1):4+5*(frame-1)) );
if style == 2
% scaled raw data
f = imcrop(F, bb);
f = f/max(f(:));
elseif style == 3
% pre-processed data
[~, f] = DMA_preprocessfluo(F, mask, c, param);
elseif style == 4
% identified cells
if param.cellminIraw > 0
[raw, ~, bw] = DMA_preprocessfluo(F, mask, c, ...
param);
else
[~, raw, bw] = DMA_preprocessfluo(F, mask, c, ...
param);
end
[~, ~, f] = DMA_countfluo(raw, bw, c, param);
else
[~, raw, bw] = DMA_preprocessfluo(F, mask, c, param);
% unscaled raw data
f = imcrop(F, bb);
end
% resize fluo mage to fit overview
f = imresize(f, size(bf));
% and put in place
if c == 1
im(1:size(bf, 1), size(bf, 2)+1:end) = f;
elseif c == 2
im(size(bf, 1)+1:end, 1:size(bf, 2)) = f;
else
im(size(bf, 1)+1:end, size(bf, 2)+1:end) = f;
end
[~, ~, f] = DMA_countfluo(raw, bw, c, param);
else
% unscaled raw data
f = imcrop(F, bb);
end
% resize fluo mage to fit overview
f = imresize(f, size(bf));
% and put in place
if c == 1
im(1:size(bf, 1), size(bf, 2)+1:end) = f;
elseif c == 2
im(size(bf, 1)+1:end, 1:size(bf, 2)) = f;
else
im(size(bf, 1)+1:end, size(bf, 2)+1:end) = f;
end
else
% no droplet, fill with zeros
im(1:size(bf, 1), size(bf, 2)+1:end) = 0;
im(size(bf, 1)+1:end, :) = 0;
end
% update figure data
set(ih, 'CData', im);
......@@ -288,23 +303,39 @@ update_plot
function update_circ
figure(figno)
% update all circles
delete(allcirch)
allcirch = viscircles(gca, bfd(:, 2+5*(frame-1):3+5*(frame-1)), ...
bfd(:, 4+5*(frame-1)), ...
'EdgeColor', 'r', 'LineWidth', 0.5);
delete(precirch)
if frame > 1
precirch = viscircles(gca, bfd(drop, 2+5*(frame-2):3+5*(frame-2)), ...
bfd(drop, 4+5*(frame-2)), ...
'EdgeColor', 'y', 'LineWidth', 1);
if bfd(drop, 1+5*(frame-2)) > 0 % check if droplet still exists
precirch = viscircles(gca, bfd(drop, 2+5*(frame-2):3+...
5*(frame-2)), bfd(drop, 4+5*(frame-2)), ...
'EdgeColor', 'y', 'LineWidth', 1);
else
precirch = viscircles(gca, [1 1], 1);
end
else
% no previous circle
precirch = viscircles(gca, bfd(drop, 2:3), bfd(drop, 4), ...
'EdgeColor', 'y', 'LineWidth', 1);
end
delete(curcirch)
curcirch = viscircles(gca, bfd(drop, 2+5*(frame-1):3+5*(frame-1)), ...
bfd(drop, 4+5*(frame-1)), ...
'EdgeColor', 'g', 'LineWidth', 2);
if bfd(drop, 1+5*(frame-1)) > 0 % check if droplet still exists
curcirch = viscircles(gca, bfd(drop, 2+5*(frame-1):3+ ...
5*(frame-1)), bfd(drop, 4+5*(frame-1)), ...
'EdgeColor', 'g', 'LineWidth', 2);
else
% no current circle
curcirch = viscircles(gca, [1 1], 1);
end
end
% update intensity graphs
......@@ -516,7 +547,7 @@ update_plot
if frame <= 0, frame = 1; end
% update GUI settings
set(framepanel, 'Title', sprintf('frame %i of %i', frame,...
set(framepanel, 'Title', sprintf('frame %i of %i', frame, ...
nframe))
set(framenum, 'String', num2str(frame));
if frame == 1
......
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