Newer
Older
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
47
function show_matvol(V,clim)
% SHOW_MATVOL Shows volumetric data
% show_matvol(V,clim)
% Inputs: volume, grayscale color limits (optional)
% Copyright 2018 Vedrana Andersen Dahl, vand@dtu.dk
figure('Units','Normalized','Position',[0.1 0.3 0.5 0.6],...
'KeyPressFcn',@key_press);
dim = size(V);
if nargin<2 || isempty(clim)
clim = [min(double(V(:))),max(double(V(:)))];
end
z = round(0.5*(dim(3)+1));
%update_drawing
i = imagesc(V(:,:,z),clim);
title(['slice ',num2str(z),'/',num2str(dim(3))]), axis image ij
colormap gray, drawnow
%%%%%%%%%% CALLBACK FUNCTIONS %%%%%%%%%%
function key_press(~,object)
% keyboard commands
switch object.Key
case 'uparrow'
z = min(z+1,dim(3));
case 'downarrow'
z = max(z-1,1);
case 'rightarrow'
z = min(z+10,dim(3));
case 'leftarrow'
z = max(z-10,1);
case 'pagedown'
z = min(z+50,dim(3));
case 'pageup'
z = max(z-50,1);
end
update_drawing
end
%%%%%%%%%% HELPING FUNCTIONS %%%%%%%%%%
function update_drawing
set(i,'CData',V(:,:,z))
title(['slice ',num2str(z),'/',num2str(dim(3))])
drawnow
end
end