0001 function [AVWVIEW] = vb_mri_point_select_display_layer(AVWVIEW, cut, ...
0002 slice, space_name)
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 if ~exist('AVWVIEW', 'var'), error('AVWVIEW is a required parameter.'); end
0031 if ~exist('cut', 'var'), error('cut is a required parameter.'); end
0032 if ~exist('slice', 'var'), error('slice is a required parameter.'); end
0033
0034 if ~isfield(AVWVIEW, 'display_factor'), return; end
0035
0036
0037
0038
0039 global vbmeg_inst;
0040 const = vbmeg_inst.const;
0041
0042 display_factor = AVWVIEW.display_factor;
0043 Mtype = vb_display_factor_get_element_color(display_factor);
0044
0045 Vdim = size(AVWVIEW.avw.img);
0046 Vsize = AVWVIEW.pixdim;
0047
0048 fig = figure(AVWVIEW.gui);
0049
0050
0051 previous_focus = get(fig, 'CurrentAxes');
0052
0053
0054 switch(cut)
0055 case 'x'
0056 set(fig, 'CurrentAxes', AVWVIEW.handles.sagittal_axes);
0057 case 'y'
0058 set(fig, 'CurrentAxes', AVWVIEW.handles.coronal_axes);
0059 case 'z'
0060 set(fig, 'CurrentAxes', AVWVIEW.handles.axial_axes);
0061 end
0062
0063
0064 AVWVIEW = delete_previous_display(AVWVIEW, cut);
0065
0066
0067 Nelements = vb_display_factor_get_length(display_factor);
0068 for k=1:Nelements
0069 element = vb_display_factor_get_element(display_factor, k);
0070
0071
0072
0073
0074 Mark = Mtype{k};
0075 color = [];
0076
0077 for k=1:length(Mark)
0078 if isletter(Mark(k)), color = strcat(color, Mark(k)); end
0079 end
0080
0081 switch(element.class_name)
0082 case 'surf_element'
0083
0084
0085
0086 coord_type = vb_display_element_get_coord_type(element);
0087 if strcmp(coord_type, const.COORDINATE_ANALYZE_RIGHT_MM)
0088 Vana = vb_analyze_mm_to_analyze(...
0089 vb_surf_element_get_vertex(element), Vdim, Vsize);
0090 else
0091 error('unknown coordinate data');
0092 end
0093 hold on;
0094
0095
0096 LineWidth = 1;
0097 Msize = LineWidth;
0098
0099 [X, Y, X1, Y1, X2, Y2, X3, Y3] = vb_get_cross_section(...
0100 Vana, ...
0101 vb_surf_element_get_face(element), ...
0102 slice, cut, 15);
0103
0104 if strcmp(space_name, 'MM') || strcmp(space_name, 'M')
0105 if cut == 'x'
0106
0107 X = X * Vsize(2);
0108 Y = Y * Vsize(3);
0109 X1 = X1 * Vsize(2);
0110 Y1 = Y1 * Vsize(3);
0111 X2 = X2 * Vsize(2);
0112 Y2 = Y2 * Vsize(3);
0113 X3 = X3 * Vsize(2);
0114 Y3 = Y3 * Vsize(3);
0115 elseif cut == 'y'
0116
0117 X = X * Vsize(1);
0118 Y = Y * Vsize(3);
0119 X1 = X1 * Vsize(1);
0120 Y1 = Y1 * Vsize(3);
0121 X2 = X2 * Vsize(1);
0122 Y2 = Y2 * Vsize(3);
0123 X3 = X3 * Vsize(1);
0124 Y3 = Y3 * Vsize(3);
0125 elseif cut == 'z'
0126
0127 X = X * Vsize(1);
0128 Y = Y * Vsize(2);
0129 X1 = X1 * Vsize(1);
0130 Y1 = Y1 * Vsize(2);
0131 X2 = X2 * Vsize(1);
0132 Y2 = Y2 * Vsize(2);
0133 X3 = X3 * Vsize(1);
0134 Y3 = Y3 * Vsize(2);
0135 end
0136 if strcmp(space_name, 'M')
0137 X = X / 1000;
0138 Y = Y / 1000;
0139 end
0140 end
0141 h = plot(X, Y, Mark, 'Markersize', Msize, 'LineWidth', LineWidth);
0142 if ~isempty(X1), h = [h; plot(X1, Y1, [color, '.'], 'Markersize', Msize)]; end
0143 if ~isempty(X2), h = [h; plot(X2, Y2, [color, '.'], 'Markersize', Msize)]; end
0144 if ~isempty(X3), h = [h; plot(X3, Y3, [color, '.'], 'Markersize', Msize)]; end
0145
0146 case 'mask_image_element'
0147 hold on;
0148
0149
0150
0151
0152
0153 [X,Y] = vb_get_3d_mask_point(...
0154 vb_mask_image_element_get_voxel_data(element), ...
0155 slice, cut, Vdim);
0156 if strcmp(space_name, 'MM') || strcmp(space_name, 'M')
0157 if cut == 'x'
0158
0159 X = X * Vsize(2);
0160 Y = Y * Vsize(3);
0161 elseif cut == 'y'
0162
0163 X = X * Vsize(1);
0164 Y = Y * Vsize(3);
0165 elseif cut == 'z'
0166
0167 X = X * Vsize(1);
0168 Y = Y * Vsize(2);
0169 end
0170 if strcmp(space_name, 'M')
0171 X = X / 1000;
0172 Y = Y / 1000;
0173 end
0174 end
0175
0176 h = plot(X, Y, [color, '.'], 'Markersize',5);
0177 end
0178
0179
0180 AVWVIEW = add_current_display(AVWVIEW, cut, h);
0181 end
0182
0183 set(fig, 'CurrentAxes', previous_focus);
0184
0185 if nargout ~= 1
0186 error('function caller should receive AVWVIEW');
0187 end
0188
0189 function AVWVIEW = delete_previous_display(AVWVIEW, cut)
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200 switch(cut)
0201 case 'x'
0202 if ~isfield(AVWVIEW, 'sagittal_layer')
0203 return;
0204 else
0205 layer_cell = AVWVIEW.sagittal_layer;
0206 AVWVIEW = rmfield(AVWVIEW, 'sagittal_layer');
0207 end
0208 case 'y'
0209 if ~isfield(AVWVIEW, 'coronal_layer')
0210 return;
0211 else
0212 layer_cell = AVWVIEW.coronal_layer;
0213 AVWVIEW = rmfield(AVWVIEW, 'coronal_layer');
0214 end
0215 case 'z'
0216 if ~isfield(AVWVIEW, 'axial_layer')
0217 return;
0218 else
0219 layer_cell = AVWVIEW.axial_layer;
0220 AVWVIEW = rmfield(AVWVIEW, 'axial_layer');
0221 end
0222 end
0223
0224 Nlayer = length(layer_cell);
0225 for k=1:Nlayer
0226 delete(layer_cell{k});
0227 end
0228
0229 if nargout ~= 1
0230 error('function caller should receive AVWVIEW.');
0231 end
0232
0233 function AVWVIEW = add_current_display(AVWVIEW, cut, h)
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245 switch(cut)
0246 case 'x'
0247 if ~isfield(AVWVIEW, 'sagittal_layer')
0248 AVWVIEW.sagittal_layer = cell(0);
0249 end
0250 Nlayer = length(AVWVIEW.sagittal_layer);
0251 AVWVIEW.sagittal_layer{Nlayer+1} = h;
0252 case 'y'
0253 if ~isfield(AVWVIEW, 'coronal_layer')
0254 AVWVIEW.coronal_layer = cell(0);
0255 end
0256 Nlayer = length(AVWVIEW.coronal_layer);
0257 AVWVIEW.coronal_layer{Nlayer+1} = h;
0258 case 'z'
0259 if ~isfield(AVWVIEW, 'axial_layer')
0260 AVWVIEW.axial_layer = cell(0);
0261 end
0262 Nlayer = length(AVWVIEW.axial_layer);
0263 AVWVIEW.axial_layer{Nlayer+1} = h;
0264 end
0265
0266 if nargout ~= 1
0267 error('function caller should receive AVWVIEW.');
0268 end