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

vb_get_3d_mask_slice

PURPOSE ^

Get single slice of 3D mask image

SYNOPSIS ^

function [B2,Xindx, Yindx] = vb_get_3d_mask_slice(B,indx,cut_dim,Vdim)

DESCRIPTION ^

 Get single slice of 3D mask image
---
  [B2,Xindx, Yindx] = vb_get_3d_mask_slice(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
 B2    : 2D-image matrix
 Xindx : X coordinate value
 Yindx : Y coordinate value

 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 [B2,Xindx, Yindx] = vb_get_3d_mask_slice(B,indx,cut_dim,Vdim)
0002 % Get single slice of 3D mask image
0003 %---
0004 %  [B2,Xindx, Yindx] = vb_get_3d_mask_slice(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 % B2    : 2D-image matrix
0019 % Xindx : X coordinate value
0020 % Yindx : Y coordinate value
0021 %
0022 % written by M. Sato  2005-8-1
0023 % Modified by M Sato  2007-3-16
0024 %---
0025 %
0026 % Copyright (C) 2011, ATR All Rights Reserved.
0027 % License : New BSD License(see VBMEG_LICENSE.txt)
0028 
0029 if nargin < 3, error('Input argument error'); end;
0030 
0031 [NBx,NBy,NBz] = size(B);
0032 
0033 if ~exist('Vdim', 'var'), Vdim = [NBx,NBy,NBz]; end;
0034 if length(Vdim) ~= 3, error('Image size must be 3dim'); end;
0035 
0036 XYZ  = Vdim(:)' ./ [NBx,NBy,NBz];
0037 
0038 xdim = [1:NBx] - 0.5;
0039 ydim = [1:NBy] - 0.5;
0040 zdim = [1:NBz] - 0.5;
0041 
0042 xdim = xdim*XYZ(1);
0043 ydim = ydim*XYZ(2);
0044 zdim = zdim*XYZ(3);
0045 
0046 % Analyze-slice-cut direction
0047 switch    cut_dim,
0048 case    'x',
0049     % 'SAG' : Sagittal cut : Y-Z plane
0050     indx = round(indx/XYZ(1));
0051     B2   = reshape(B(indx,:,:),NBy,NBz);
0052     Xindx = ydim;
0053     Yindx = zdim;
0054 case    'y',
0055     % 'COR' : Coronal cut : X-Z plane
0056     indx = round(indx/XYZ(2));
0057     B2   = reshape(B(:,indx,:),NBx,NBz);
0058     Xindx = xdim;
0059     Yindx = zdim;
0060 case    'z',
0061     % 'TRN' : Transverse (Axial) cut : X-Y plane
0062     indx = round(indx/XYZ(3));
0063     B2   = B(:,:,indx);
0064     Xindx = xdim;
0065     Yindx = ydim;
0066 end;
0067 
0068 % Reduction of dimension of voxel matrix
0069 B2 = squeeze(B2); 
0070

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