Home > functions > tool_box > mri_toolbox > mri_point_select_dir > vb_mri_point_select_display_layer.m

vb_mri_point_select_display_layer

PURPOSE ^

plots element data on vb_mri_point_select slice.

SYNOPSIS ^

function [AVWVIEW] = vb_mri_point_select_display_layer(AVWVIEW, cut,slice, space_name)

DESCRIPTION ^

 plots element data on vb_mri_point_select slice.
 This function is called from mri_point_select.
 If you want to show the data, please reffer to Example.

 [USAGE]
    [AVWVIEW] = vb_mri_point_select_display_layer(<AVWVIEW>, <cut>, <slice>);
 [IN]
       AVWVIEW : <<struct>> vb_mri_point_select data
           cut : update axes.
                 'x' : plot sagittal axes
                 'y' : plot coronal axes
                 'z' : plot axial_axes
         slice : slice number to plot
    space_name : element will be plotted to this space.
                 'VOXEL' : voxel coordinate space
                 'MM'    : mm coordinate space
                 'M'     : m coordinate space
 [OUT]
    AVWVIEW : <<struct>> updated vb_mri_point_select data.


 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [AVWVIEW] = vb_mri_point_select_display_layer(AVWVIEW, cut, ...
0002                                                     slice, space_name)
0003 % plots element data on vb_mri_point_select slice.
0004 % This function is called from mri_point_select.
0005 % If you want to show the data, please reffer to Example.
0006 %
0007 % [USAGE]
0008 %    [AVWVIEW] = vb_mri_point_select_display_layer(<AVWVIEW>, <cut>, <slice>);
0009 % [IN]
0010 %       AVWVIEW : <<struct>> vb_mri_point_select data
0011 %           cut : update axes.
0012 %                 'x' : plot sagittal axes
0013 %                 'y' : plot coronal axes
0014 %                 'z' : plot axial_axes
0015 %         slice : slice number to plot
0016 %    space_name : element will be plotted to this space.
0017 %                 'VOXEL' : voxel coordinate space
0018 %                 'MM'    : mm coordinate space
0019 %                 'M'     : m coordinate space
0020 % [OUT]
0021 %    AVWVIEW : <<struct>> updated vb_mri_point_select data.
0022 %
0023 %
0024 % Copyright (C) 2011, ATR All Rights Reserved.
0025 % License : New BSD License(see VBMEG_LICENSE.txt)
0026 
0027 %
0028 % --- Previous check
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 % --- Main Procedure
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 % Get current Axes
0051 previous_focus = get(fig, 'CurrentAxes');
0052 
0053 % Change current Axes
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 % Previous display delete
0064 AVWVIEW = delete_previous_display(AVWVIEW, cut);
0065 
0066 % Display layer
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     % --- Marker setting
0073     %
0074     Mark = Mtype{k};
0075     color = [];
0076     % separate Color from Marker type
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             % --- Plot surface data
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             % get points on specified slice to plot
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             % plot points
0104             if strcmp(space_name, 'MM') || strcmp(space_name, 'M')
0105                 if cut == 'x'
0106                     % Sagittal(plotX == sliceY, plotY == sliceZ)
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                     % Coronal(plotX == sliceX, plotY == sliceZ)
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                     % Axial(plotX == sliceX, plotY == sliceY);
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             % --- Plot mask image data
0150             %
0151 
0152             % get points on specified slice to plot
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                     % Sagittal(plotX == sliceY, plotY == sliceZ)
0159                     X = X * Vsize(2);
0160                     Y = Y * Vsize(3);
0161                 elseif cut == 'y'
0162                     % Coronal(plotX == sliceX, plotY == sliceZ)
0163                     X = X * Vsize(1);
0164                     Y = Y * Vsize(3);
0165                 elseif cut == 'z'
0166                     % Axial(plotX == sliceX, plotY == sliceY);
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             % plot points
0176             h = plot(X, Y, [color, '.'], 'Markersize',5);
0177     end
0178 
0179     % save plot component handles
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 % delete plotted components
0191 % [IN]
0192 %    AVWVIEW : <<struct>> AVWVIEW
0193 %        cut : specify which component on axes
0194 %              'x' : plot sagittal axes
0195 %              'y' : plot coronal axes
0196 %              'z' : plot axial_axes
0197 % [OUT]
0198 %    AVWVIEW : updated AVWVIEW
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 % add plotted components to AVWVIEW
0235 % [IN]
0236 %    AVWVIEW : <<struct>> AVWVIEW
0237 %        cut : specify which component on axes
0238 %              'x' : plot sagittal axes
0239 %              'y' : plot coronal axes
0240 %              'z' : plot axial_axes
0241 %          h : added component handles
0242 % [OUT]
0243 %    AVWVIEW : updated AVWVIEW
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

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005