-
Notifications
You must be signed in to change notification settings - Fork 1
/
showmsers.m
46 lines (43 loc) · 1.26 KB
/
showmsers.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
% Show 2D masks and fitted-ellipse stats on each slice of 3D image.
function showmsers(vol, bw, snum, inplanerefdiam, subset)
if nargin() > 4
bw = bw(subset);
snum = snum(subset);
end
sz = size(vol);
[cen,semi,rot,~,dm] = fitellipse(bw);
ratio = semi(:,1) ./ semi(:,2);
area = prod(2*semi/inplanerefdiam, 2); % Fraction of expected size.
diam = 2*semi(:,1) / inplanerefdiam;
format = 'Slice: %2d, ratio: %.2f, area: %.2f, dice: %.2f, semi: %.2f\n';
reset(clf());
colormap gray
phi = linspace(0, 2*pi, 50);
[cx,cy] = deal(cos(phi), sin(phi));
vol = stretchcon(vol);
for i = 1:sz(3)
figure(gcf());
im = vol(:,:,i);
imagesc(im);
axis image off
title(sprintf('%d/%d', i, sz(3)));
drawnow();
for j = find(snum==i)'
tmp = im;
tmp(bw{j}) = 1;
imagesc(tmp);
x = rot{j}(1,1)*semi(j,1)*cx + rot{j}(1,2)*semi(j,2)*cy + cen(j,1);
y = rot{j}(2,1)*semi(j,1)*cx + rot{j}(2,2)*semi(j,2)*cy + cen(j,2);
hold on
plot(y, x, 'r', 'linewidth', 2);
hold off
axis('image', 'off', [0 sz(2) 0 sz(1)]);
title(sprintf('%d/%d', i, sz(3)));
fprintf(format, i, ratio(j), area(j), dm(j), diam(j));
drawnow();
end
if ~isempty(j)
fprintf('\n');
end
pause(0.1);
end