Home > vbmeg > functions > common > coordinate > vb_distance_brain_face.m

vb_distance_brain_face

PURPOSE ^

Distance between face and brain surface

SYNOPSIS ^

function [dmax,dmin] = vb_distance_brain_face(Vbrain,Vface)

DESCRIPTION ^

 Distance between face and brain surface
  [dmax,dmin] = vb_distance_brain_face(Vbrain,Vface)

 2008-10-10 Masa-aki Sato
 2008-11-4  Masa-aki Sato

 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 [dmax,dmin] = vb_distance_brain_face(Vbrain,Vface)
0002 % Distance between face and brain surface
0003 %  [dmax,dmin] = vb_distance_brain_face(Vbrain,Vface)
0004 %
0005 % 2008-10-10 Masa-aki Sato
0006 % 2008-11-4  Masa-aki Sato
0007 %
0008 % Copyright (C) 2011, ATR All Rights Reserved.
0009 % License : New BSD License(see VBMEG_LICENSE.txt)
0010 
0011 % change to mm
0012 Vface  = Vface  * 1000;
0013 Vbrain = Vbrain * 1000;
0014 
0015 Rmax  = 20; % Max radius in minimum distance search at 1st stage [mm]
0016 Nstep = 30; % number of division in Z-axis for minimum distance search
0017 Nskip = 10; % skip number for face vertex
0018 
0019 %Zwid = 20;  % Z-length for search [mm]
0020 %Ztop = 40;  % Z-length of upper face [mm]
0021 %Zmax = 150; % Z-length of search area of face [mm]
0022 %Zface = max(Vface(:,3));
0023 %Zmax  = max(Vbrain(:,3));
0024 
0025 Zmin  = min(Vbrain(:,3));
0026 
0027 % Z-coordinate for max of brain Y-axis (front)
0028 [Ymax, imax] = max(Vbrain(:,2));
0029 Z1 = Vbrain(imax,3);
0030 % Z-coordinate for min of brain Y-axis (back)
0031 [Ymin, imin] = min(Vbrain(:,2));
0032 Z2 = Vbrain(imin,3);
0033 
0034 % Middel of Z-axis to separate up/low brain
0035 Zmid = min(Z1,Z2);
0036 
0037 % Select upper face
0038 jx = find( Vface(:,3)  >= Zmid);
0039 jx = jx(1:Nskip:end);
0040 
0041 %fprintf('# of selected upper face vertex = %d\n',length(jx))
0042 
0043 % Distance from upper face to brain surface
0044 [indx ,dup] = vb_find_nearest_point(Vbrain,Vface(jx,:),Rmax,Nstep);
0045 
0046 % Select lower face
0047 jx = find( Vface(:,3)  < Zmid & Vface(:,3) >= Zmin);
0048 jx = jx(1:Nskip:end);
0049 
0050 %fprintf('# of selected lower face vertex = %d\n',length(jx))
0051 
0052 % Distance from lower face to brain surface
0053 [indx ,dlow] = vb_find_nearest_point(Vbrain,Vface(jx,:),Rmax,Nstep);
0054 
0055 dmax = max(dup);
0056 dmin = min( [dup ; dlow] );
0057 
0058 return
0059 
0060 
0061 %Zmid = min( Vbrain([ix1; ix2; ix3; ix4], 3))
0062 %Zmid = min(Zmid, (Zup - Ztop)) - Zwid;
0063 %
0064 %Zstp = 1;
0065 %
0066 %Nz = ceil((Zup-Zmin)/Zstp);
0067 %z  = fix((Vbrain(:,3) - Zmin)/Zstp);
0068 %w  = zeros(Nz,1);
0069 %
0070 %% area in axial brain slice
0071 %for n=1:Nz
0072 %    ix = find( z==n );
0073 %    if isempty(ix), continue; end;
0074 %
0075 %    Xmax = max(Vbrain(ix,1));
0076 %    Xmin = min(Vbrain(ix,1));
0077 %    Ymax = max(Vbrain(ix,2));
0078 %    Ymin = min(Vbrain(ix,2));
0079 %
0080 %    w(n) = (Xmax - Xmin) * (Ymax - Ymin);
0081 %end
0082 %
0083 %[wmax, imax] = max(w);
0084 %Zmid = z(imax) * Zstp + Zmin

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