-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdisp_sagittal_movie.m
More file actions
157 lines (140 loc) · 6.28 KB
/
disp_sagittal_movie.m
File metadata and controls
157 lines (140 loc) · 6.28 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
%**************************************************************************
%
% PROGRAM TITLE disp_sagittal_movie.m
%
% WRITTEN BY David G. Politte
% DATE WRITTEN MAY 12, 2011
% WRITTEN FOR Pediatric head modeling project
%
% CALLING SYNTAX
% Use the following syntax:
% disp_sagittal_movie(g_3d, s_3d, b_3d_with_patch, pause_before, ...
% pause_between) ;
%
% where
% g_3d is an image volume containing the grayscale image
% from the CT scan. (double)
% s_3d is a binary-valued image volume containing the
% segmented head from the CT scan. s_3d is equal to
% 0 outside the head and equal to 1 inside the head.
% (double)
% b_3d_with_patch is a ternary-valued image volume equal to 0 for
% voxels not on the border of the segmented volume,
% equal to 1 for voxels on the border, and equal to
% 2 for voxels on the border which are also within
% the patch of voxels to which the model sphere will
% be fitted. (double)
% pause_before is the number of seconds of delay between the time
% the blank figure is created and when the display
% of the movie begins. The purpose of this parameter
% is to allow the user to move the figure window and
% resize it during demonstrations of the software.
% Set this parameter to 0 for maximal speed.
% (double)
% pause_between is the number of seconds of delay between frames
% of the movie. Set this parameter to 0 for maximal
% speed. (double)
%
% PROGRAM DESCRIPTION
% disp_sagittal_movie displays a three-panel movie of the sagittal
% slices derived from the CT images. The left-hand panel is the
% gray-scale image, the middle panel is the segmentation of the head,
% and the right-hand penel shows the border voxels in white and the
% patch voxels in red.
% A custom colormap is needed to properly display the red voxels
% of the patch shown in the right-hand panel.
% By default, Matlab displays row 1 of the image at the top and
% column 1 of the image at the left. Both of these defaults are
% overridden so that the image is displayed "correct side up" and so
% that the displayed head is facing the left, which is the standard for
% sagittal images.
%
% FILES
% standard input - not used
% standard output - not used
%
% DEPENDENCIES
% MATLAB (win64) Version 7.12.0.635 (R2011a)
% Image Processing Toolbox Version 7.2 (R2011a)
% Signal Processing Toolbox Version 6.15 (R2011a)
% Statistics Toolbox Version 7.5
%
% REVISION HISTORY
% Version Date Comment
% ------- ----------- ---------------------------------------------
% 1.0 12 May 2011 Initial release.
%
% COPYRIGHT
%
% Copyright (c) 2011 Washington University in St. Louis
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and
% limitations under the License.
%**************************************************************************
function [] = disp_sagittal_movie(g_3d, s_3d, b_3d_with_patch, ...
pause_before, pause_between)
temp = size(g_3d) ;
num_col = temp(2) ;
% Create a custom colormap. This is necessary because we're using a
% gray-scale colormap but want to display the patch voxels in red.
gray_custom = gray(64) ;
gray_custom(end,:) = [1 0 0] ;
% Create a figure and pause to allow it to be moved and/or resized.
figure(2) ;
pause(pause_before) ;
% Play a movie of successive sagittal planes.
for i = 1:num_col
% Display the grayscale image on the left.
subplot(1, 3, 1) ;
imagesc(min(squeeze(g_3d(:, i, :))', 1500)) ;
lct = length(gray_custom) ;
caxis_min = -1025 ;
m = max(max(min(squeeze(g_3d(:, i, :))', 1500))) ;
caxis_max = ceil((1 / (lct - 1)) * ((m * lct) - caxis_min)) ;
caxis([caxis_min caxis_max]) ;
colormap(gray_custom) ;
h1 = gca ;
set(h1, 'XDir', 'reverse') ;
set(h1, 'YDir', 'normal') ;
axis equal ; axis tight
xlabel('y (row)') ; ylabel('z (plane)') ;
title(['Sagittal plane ' num2str(i) ' of ' num2str(num_col)]) ;
% Display the binary segmentation image in the middle.
subplot(1, 3, 2) ;
imagesc(squeeze(s_3d(:, i, :))') ;
caxis([0 1.02]) ;
colormap(gray_custom) ;
h2 = gca ;
set(h2, 'XDir', 'reverse') ;
set(h2, 'YDir', 'normal') ;
axis equal ; axis tight ;
xlabel('y (row)') ; ylabel('z (plane)') ;
title(['Sagittal plane ' num2str(i) ' of ' num2str(num_col)]) ;
% Display the border voxels in white and the patch voxels in red on
% the right.
subplot(1, 3, 3) ;
imagesc(squeeze(b_3d_with_patch(:, i, :))') ;
caxis([0 1.02]) ;
colormap(gray_custom) ;
h3 = gca ;
set(h3, 'XDir', 'reverse') ;
set(h3, 'YDir', 'normal') ;
axis equal ; axis tight ;
xlabel('y (row)') ; ylabel('z (plane)') ;
title(['Sagittal plane ' num2str(i) ' of ' num2str(num_col)]) ;
% Pause between frames of the movie (if pause_between is not equal
% to 0).
drawnow ;
pause(pause_between) ;
end
%
end