Home > vbmeg > functions > brain > vb_inflate_to_flat_func.m

vb_inflate_to_flat_func

PURPOSE ^

Project vertex point into 2D-plane

SYNOPSIS ^

function [XY, Pindx, FLR, VLR, XYLR, IDLR] =vb_inflate_to_flat_func(V,F,Xdim,xcenter)

DESCRIPTION ^

 Project vertex point into 2D-plane
 XY    : Projected spherical coordinate 
 Pindx : Partition index (L/R & U/D) for each vertex
 Pindx(j) = [ 1 2 3 4 ]  :  { LU;  LD;  RU;  RD } (Left/Right & Up/Down)
       
 FLR   = { FLU;  FLD;  FRU;  FRD }; % Face index for each part
 VLR   = { VLU;  VLD;  VRU;  VRD }; % Vertex coordinate for each part
 XYLR  = {XYLU; XYLD; XYRU; XYRD }; % Projected coordinate for each part
 IDLR  = { ILU;  ILD;  IRU;  IRD }; % Vertex index for L/R & U/D

 V     : Inflate brain coordinate
 F3L   : Face index for left brain
 F3R   : Face index for right brain
 Nleft : Number of point in the left brain
 Xdim  : Projection direction

 Ver 1.0 written by M. Sato  2003-3-15

 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    [XY, Pindx, FLR, VLR, XYLR, IDLR] = ...
0002                     vb_inflate_to_flat_func(V,F,Xdim,xcenter)
0003 % Project vertex point into 2D-plane
0004 % XY    : Projected spherical coordinate
0005 % Pindx : Partition index (L/R & U/D) for each vertex
0006 % Pindx(j) = [ 1 2 3 4 ]  :  { LU;  LD;  RU;  RD } (Left/Right & Up/Down)
0007 %
0008 % FLR   = { FLU;  FLD;  FRU;  FRD }; % Face index for each part
0009 % VLR   = { VLU;  VLD;  VRU;  VRD }; % Vertex coordinate for each part
0010 % XYLR  = {XYLU; XYLD; XYRU; XYRD }; % Projected coordinate for each part
0011 % IDLR  = { ILU;  ILD;  IRU;  IRD }; % Vertex index for L/R & U/D
0012 %
0013 % V     : Inflate brain coordinate
0014 % F3L   : Face index for left brain
0015 % F3R   : Face index for right brain
0016 % Nleft : Number of point in the left brain
0017 % Xdim  : Projection direction
0018 %
0019 % Ver 1.0 written by M. Sato  2003-3-15
0020 %
0021 % Copyright (C) 2011, ATR All Rights Reserved.
0022 % License : New BSD License(see VBMEG_LICENSE.txt)
0023 
0024 F3R   = F.F3R;
0025 F3L   = F.F3L;
0026 Nleft = F.NdipoleL;
0027 
0028 % Where the center of sphere is set
0029 if nargin<4, xcenter = 0.1; end;
0030 
0031 Xrate   = xcenter*[ 1  -1  1 -1 ];
0032 
0033 % Set Projection direction
0034 switch    Xdim,
0035 case    1,
0036     prj_mode = { 'x' ; '-x' ;  'x' ; '-x'};
0037 case    2,
0038     prj_mode = { 'y' ; '-y' ;  'y' ; '-y'};
0039 case    3,
0040     prj_mode = { 'z' ; '-z' ;  'z' ; '-z'};
0041 end;
0042 
0043 Npoint = size(V,1);
0044 Nright = Npoint - Nleft;
0045 
0046 XY       = zeros(Npoint,3); % Projected spherical coordinate
0047 Pindx  = zeros(Npoint,1); % Partition index (L/R & U/D) for each vertex
0048 %      = [ 1 2 3 4 ]    : { LU;  LD;  RU;  RD } (Left/Right & Up/Down)
0049 
0050 VL       = V(1:Nleft,:);
0051 VR       = V((Nleft+1):Npoint,:);
0052 
0053 if Nleft==0,
0054     VLmean = zeros(1,3);
0055 else
0056     VLmean = sum(VL)/Nleft;
0057 end;
0058 
0059 if Nright==0,
0060     VRmean = zeros(1,3);
0061 else
0062     VRmean = sum(VR)/Nright;
0063 end;
0064 
0065 % Set origin to the center of gravity
0066 VL       = VL    - repmat(VLmean ,[ Nleft 1]);
0067 VR       = VR    - repmat(VRmean ,[ Nright 1]);
0068 
0069 % Select Up/Down(Front/Back) part
0070 LU     = find( VL(:,Xdim) >= 0 );
0071 LD     = find( VL(:,Xdim) <  0 );
0072 RU     = find( VR(:,Xdim) >= 0 );
0073 RD     = find( VR(:,Xdim) <  0 );
0074 
0075 VLU  = VL(LU,:);
0076 VLD  = VL(LD,:);
0077 VRU  = VR(RU,:);
0078 VRD  = VR(RD,:);
0079 
0080 RU     = RU+Nleft;
0081 RD     = RD+Nleft;
0082 
0083 IDLR = { LU;  LD;  RU;  RD }; % Index for L/R & U/D
0084 VLR  = {VLU; VLD; VRU; VRD }; % Vertex coordinate for each part
0085 XYLR = cell(4,1);             % Projected coordinate for each part
0086 
0087 % Transform coordinate into spherical coordinate in each part
0088 for j=1:4,
0089     VLRj   = VLR{j};
0090     IDj    = IDLR{j};
0091     NID    = size(VLRj,1);
0092     
0093     % Set center of sphere inside of selected part
0094     Xzero  = (max(VLRj(:,Xdim)) -min(VLRj(:,Xdim)))*Xrate(j);
0095 
0096     VLRj(:,Xdim) = VLRj(:,Xdim) - repmat(Xzero,NID,1);
0097     
0098     % Spherical coordinate projection
0099     [ Xj , Yj ]  = vb_cart2theta_phi( VLRj , prj_mode{j} );
0100 
0101     VLR{j}       = VLRj;
0102     Pindx(IDj) = j;
0103     XY(IDj,1)  = Xj;
0104     XY(IDj,2)  = Yj;
0105     XYLR{j}    = [Xj , Yj];
0106 end;
0107 
0108 % Select face inside of each projrcted part
0109 FLU = [];
0110 FLD = [];
0111 FRU = [];
0112 FRD = [];
0113 
0114 Lface=length(F3L);
0115 Rface=length(F3R);
0116 
0117 for n=1:Lface,
0118     ix=F3L(n,:);
0119     pix=Pindx(ix);
0120     
0121     if (pix(1)==1)&(pix(2)==1)&(pix(3)==1),
0122         FLU = [ FLU; ix];
0123     end;
0124     
0125     if (pix(1)==2)&(pix(2)==2)&(pix(3)==2),
0126         FLD = [ FLD; ix];
0127     end;
0128     
0129 end;
0130 
0131 for n=1:Rface,
0132     ix=F3R(n,:);
0133     pix=Pindx(ix);
0134     
0135     if (pix(1)==3)&(pix(2)==3)&(pix(3)==3),
0136         FRU = [ FRU; ix];
0137     end;
0138     
0139     if (pix(1)==4)&(pix(2)==4)&(pix(3)==4),
0140         FRD = [ FRD; ix];
0141     end;
0142     
0143 end;
0144 
0145 FLR = { FLU; FLD; FRU; FRD }; % Face index for each part

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