-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdisp_coronal_normal.m
More file actions
156 lines (146 loc) · 6.89 KB
/
disp_coronal_normal.m
File metadata and controls
156 lines (146 loc) · 6.89 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
%**************************************************************************
%
% PROGRAM TITLE disp_coronal_normal.m
%
% WRITTEN BY David G. Politte
% DATE WRITTEN May 12, 2011
% WRITTEN FOR Pediatric head modeling project
%
% CALLING SYNTAX
% Use the following syntax:
% disp_coronal_normal(g_3d, b_3d, p_3d, ref_point_rcp, ...
% center_est_rcp, pause_before) ;
%
% where
% g_3d is an image volume containing the grayscale image
% from the CT scan. (double)
% b_3d is a binary-valued image volume equal to 0 for
% voxels not on the border of the segmented volume,
% and equal to 1 for voxels on the border. (double)
% p_3d is a binary-valued image volume equal to 0 for
% voxels not in the patch of voxels to which the
% model sphere was fitted, and equal to 1 for voxels
% in the patch. (double)
% ref_point_rcp is a 1x3 row vector which is the reference point in
% rcp (row, column, plane) format. The reference
% point should be on the surface of the scalp and is
% the point at which the surface normal was
% calculated. (double)
% center_est_rcp is a 1x3 row vector which is the center in rcp
% (row, column, plane) format of the best-fit sphere
% to the patch of voxels on the border. (double)
% pause_before is the number of seconds of delay between the time
% the blank figure is created and its display 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)
%
% PROGRAM DESCRIPTION
% disp_coronal_normal displays a three-panel figure of the
% coronal slice that contains the current reference point. The
% left-hand panel is the gray-scale image, the middle panel shows the
% border voxels of the segmentation of the left-hand panel, and the
% right-hand panel shows the patch voxels. The patch voxels are a
% subset of the border voxels which are used in the least-squares fit
% of a sphere to find the surface normal at the reference point.
% The reference point is shown as a red square and the estimated
% center of the best-fit sphere is shown as a red circle in all three
% panels. The circle and square are connected by a radial vector. This
% radial vector should be perpendicular to the locus of patch voxels
% shown in the right-hand panel.
% By default, Matlab displays row 1 of the image at the top. This
% default has been overridden so that the image is displayed "correct
% side up." The origin of the coordinate system is at the lower-left.
%
% 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.
%
% PLANNED REVISIONS
% None as of 12 May 2011.
%
% 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_coronal_normal(g_3d, b_3d, p_3d, ref_point_rcp, ...
center_est_rcp, pause_before)
% Create a figure and pause to allow it to be moved and/or resized.
figure(6) ;
pause(pause_before) ;
% Display the grayscale image on the left. Plot the reference point as
% a red square, the projection into this plane of the center of the
% best-fit sphere as a red circle, and draw a red line between them.
subplot(1, 3, 1) ;
hold off ;
imagesc(squeeze(g_3d(ref_point_rcp(1), :, :))') ;
colormap('gray') ;
h1 = gca ;
set(h1, 'YDir', 'normal') ;
axis equal ; axis tight ;
xlabel('x (column)') ; ylabel('z (plane)') ;
title(['Coronal plane ' num2str(ref_point_rcp(1))]) ;
hold on ;
plot([center_est_rcp(2) ref_point_rcp(2)], ...
[center_est_rcp(3) ref_point_rcp(3)], 'red') ;
plot(ref_point_rcp(2), ref_point_rcp(3), 'rs') ;
plot(center_est_rcp(2), center_est_rcp(3), 'ro') ;
% Display the border voxels in white. Plot the reference point as a red
% square, the projection into this plane of the center of the best-fit
% sphere as a red circle, and draw a red line between them.
subplot(1, 3, 2) ;
hold off ;
imagesc(squeeze(b_3d(ref_point_rcp(1), :, :))') ;
colormap('gray') ;
h2 = gca ;
set(h2, 'YDir', 'normal') ;
axis equal ; axis tight ;
xlabel('x (column)') ; ylabel('z (plane)') ;
title(['Coronal plane ' num2str(ref_point_rcp(1))]) ;
hold on ;
plot([center_est_rcp(2) ref_point_rcp(2)], ...
[center_est_rcp(3) ref_point_rcp(3)], 'red') ;
plot(ref_point_rcp(2), ref_point_rcp(3), 'rs') ;
plot(center_est_rcp(2), center_est_rcp(3), 'ro') ;
% Display the patch voxels in white. Plot the reference point as a red
% square, the projection into this plane of the center of the best-fit
% sphere as a red circle, and draw a red line between them.
subplot(1, 3, 3) ;
hold off ;
imagesc(squeeze(p_3d(ref_point_rcp(1), :, :))') ;
colormap('gray') ;
h3 = gca ;
set(h3, 'YDir', 'normal') ;
axis equal ; axis tight ;
xlabel('x (column)') ; ylabel('z (plane)') ;
title(['Coronal plane ' num2str(ref_point_rcp(1))]) ;
hold on ;
plot([center_est_rcp(2) ref_point_rcp(2)], ...
[center_est_rcp(3) ref_point_rcp(3)], 'red') ;
plot(ref_point_rcp(2), ref_point_rcp(3), 'rs') ;
plot(center_est_rcp(2), center_est_rcp(3), 'ro') ;
end