Home > vbmeg > functions > common > morphology > vb_get_3d_mask_point.m

vb_get_3d_mask_point

PURPOSE ^

Get mask points in mask image for specified slice

SYNOPSIS ^

function [X,Y] = vb_get_3d_mask_point(B,indx,cut_dim,Vdim)

DESCRIPTION ^

 Get mask points in mask image for specified slice
---
  [X,Y] = vb_get_3d_mask_point(B,indx,cut_dim,Vdim)

 --- Input
 B : 3D mask image [NBx, NBy, NBz]. 
   Axis is the same as Analyze_right voxel coordinate except scale
 indx : slice index in cut_dim-axis 
        specified by Analyze_right voxel coordinate
 cut_dim : slice cut direction
      = 'x' : Sagittal cut : Y-Z plane
      = 'y' : Coronal cut  : X-Z plane
      = 'z' : Transverse (Axial) cut : X-Y plane
 --- Optional input
 Vdim  = [Xmax Ymax Zmax] : 3D image size of analyze_right image
 --- Output
 X : X coordinate of mask point ( B > 0)
 Y : Y coordinate of mask point ( B > 0)

 written by M. Sato  2005-8-1
 Modified by M Sato  2007-3-16
---

 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:

SOURCE CODE ^

0001 function [X,Y] = vb_get_3d_mask_point(B,indx,cut_dim,Vdim)
0002 % Get mask points in mask image for specified slice
0003 %---
0004 %  [X,Y] = vb_get_3d_mask_point(B,indx,cut_dim,Vdim)
0005 %
0006 % --- Input
0007 % B : 3D mask image [NBx, NBy, NBz].
0008 %   Axis is the same as Analyze_right voxel coordinate except scale
0009 % indx : slice index in cut_dim-axis
0010 %        specified by Analyze_right voxel coordinate
0011 % cut_dim : slice cut direction
0012 %      = 'x' : Sagittal cut : Y-Z plane
0013 %      = 'y' : Coronal cut  : X-Z plane
0014 %      = 'z' : Transverse (Axial) cut : X-Y plane
0015 % --- Optional input
0016 % Vdim  = [Xmax Ymax Zmax] : 3D image size of analyze_right image
0017 % --- Output
0018 % X : X coordinate of mask point ( B > 0)
0019 % Y : Y coordinate of mask point ( B > 0)
0020 %
0021 % written by M. Sato  2005-8-1
0022 % Modified by M Sato  2007-3-16
0023 %---
0024 %
0025 % Copyright (C) 2011, ATR All Rights Reserved.
0026 % License : New BSD License(see VBMEG_LICENSE.txt)
0027 
0028 if nargin < 3, error('Input argument error'); end;
0029 
0030 [NBx,NBy,NBz] = size(B);
0031 
0032 if ~exist('Vdim', 'var'), Vdim = [NBx,NBy,NBz]; end;
0033 if length(Vdim) ~= 3, error('Image size must be 3dim'); end;
0034 
0035 XYZ  = Vdim(:)' ./ [NBx,NBy,NBz];
0036 
0037 xdim = [1:NBx] - 0.5;
0038 ydim = [1:NBy] - 0.5;
0039 zdim = [1:NBz] - 0.5;
0040 
0041 xdim = xdim*XYZ(1);
0042 ydim = ydim*XYZ(2);
0043 zdim = zdim*XYZ(3);
0044 
0045 % Analyze-slice-cut direction
0046 switch    cut_dim,
0047 case    'x',
0048     % 'SAG' : Sagittal cut : Y-Z plane
0049     indx = round(indx/XYZ(1));
0050     B2   = reshape(B(indx,:,:),NBy,NBz);
0051     Xindx = ydim;
0052     Yindx = zdim;
0053 case    'y',
0054     % 'COR' : Coronal cut : X-Z plane
0055     indx = round(indx/XYZ(2));
0056     B2   = reshape(B(:,indx,:),NBx,NBz);
0057     Xindx = xdim;
0058     Yindx = zdim;
0059 case    'z',
0060     % 'TRN' : Transverse (Axial) cut : X-Y plane
0061     indx = round(indx/XYZ(3));
0062     B2   = B(:,:,indx);
0063     Xindx = xdim;
0064     Yindx = ydim;
0065 end;
0066 
0067 [X,Y] = ndgrid(Xindx, Yindx);
0068 
0069 ix = find( squeeze(B2) > 0 );
0070 X  = X(ix);
0071 Y  = Y(ix);
0072

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005