freesurfer_surf_separate - separate left and right hemi-surfaces [LH,RH] = freesurfer_surf_separate(FV, NfacesLH, NvertLH, NfacesRH, NvertRH) It is assumed that FV input is a struct: FV.vertices = Nx3, comprising NvertLH followed by NvertRH FV.faces = Nx3, comprising NfacesLH followed by NfacesRH If NfacesRH and NvertRH are missing, they are assumed to be the remainder of FV after extracting the LH. This assumes that the RH surface was concatenated into FV *after* the LH. After separating surfaces, try: patch('vertices',LH.vertices,'faces',LH.faces,.. 'facecolor',[1 0 0],'edgecolor','none'); light See also freesurfer_read_surf, freesurfer_surf_combine
0001 function [LH,RH] = freesurfer_surf_separate(FV, NfacesLH, NvertLH, NfacesRH, NvertRH) 0002 0003 % freesurfer_surf_separate - separate left and right hemi-surfaces 0004 % 0005 % [LH,RH] = freesurfer_surf_separate(FV, NfacesLH, NvertLH, NfacesRH, NvertRH) 0006 % 0007 % It is assumed that FV input is a struct: 0008 % FV.vertices = Nx3, comprising NvertLH followed by NvertRH 0009 % FV.faces = Nx3, comprising NfacesLH followed by NfacesRH 0010 % 0011 % If NfacesRH and NvertRH are missing, they are assumed to be the remainder 0012 % of FV after extracting the LH. This assumes that the RH surface was 0013 % concatenated into FV *after* the LH. 0014 % 0015 % After separating surfaces, try: 0016 % patch('vertices',LH.vertices,'faces',LH.faces,.. 0017 % 'facecolor',[1 0 0],'edgecolor','none'); light 0018 % 0019 % See also freesurfer_read_surf, freesurfer_surf_combine 0020 % 0021 0022 0023 % $Revision: 1.1 $ $Date: 2005/08/14 21:24:19 $ 0024 0025 % Copyright (C) 2005 Darren L. Weber 0026 % 0027 % This program is free software; you can redistribute it and/or 0028 % modify it under the terms of the GNU General Public License 0029 % as published by the Free Software Foundation; either version 2 0030 % of the License, or (at your option) any later version. 0031 % 0032 % This program is distributed in the hope that it will be useful, 0033 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0034 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0035 % GNU General Public License for more details. 0036 % 0037 % You should have received a copy of the GNU General Public License 0038 % along with this program; if not, write to the Free Software 0039 % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 0040 % USA. 0041 0042 % History: 05/2005, Darren.Weber_at_radiology.ucsf.edu 0043 % 0044 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0045 0046 ver = '$Revision: 1.1 $ $Date: 2005/08/14 21:24:19 $'; 0047 fprintf('FREESURFER_SURF_SEPARATE [v %s]\n\n',ver(11:15)); 0048 0049 if ~exist('FV','var'), 0050 error('FV undefined'); 0051 end 0052 if isempty(FV), 0053 error('FV undefined'); 0054 end 0055 0056 if ~exist('NfacesLH','var'), 0057 error('NfacesLH undefined'); 0058 end 0059 if isempty(NfacesLH), 0060 error('NfacesLH undefined'); 0061 end 0062 0063 if ~exist('NfacesRH','var'), 0064 NfacesRH = length(FV.faces) - NfacesLH 0065 end 0066 if isempty(NfacesRH), 0067 NfacesRH = length(FV.faces) - NfacesLH 0068 end 0069 0070 if ~exist('NvertLH','var'), 0071 error('NvertLH undefined'); 0072 end 0073 if isempty(NvertLH), 0074 error('NvertLH undefined'); 0075 end 0076 0077 if ~exist('NvertRH','var'), 0078 NvertRH = length(FV.vertices) - NvertLH 0079 end 0080 if isempty(NvertRH), 0081 NvertRH = length(FV.vertices) - NvertLH 0082 end 0083 0084 if (NvertLH+NvertRH) ~= length(FV.vertices), 0085 error('(NvertLH+NvertRH) ~= length(FV.vertices)'); 0086 end 0087 if (NfacesLH+NfacesRH) ~= length(FV.faces), 0088 error('(NfacesLH+NfacesRH) ~= length(FV.faces)'); 0089 end 0090 0091 % separate the vertices 0092 LvertIndex = 1:NvertLH; 0093 RvertIndex = NvertLH+1:NvertLH+NvertRH; 0094 0095 LH.vertices = FV.vertices(LvertIndex,:); 0096 RH.vertices = FV.vertices(RvertIndex,:); 0097 0098 % separate the faces 0099 LfaceIndex = 1:NfacesLH; 0100 RfaceIndex = NfacesLH+1:NfacesLH+NfacesRH; 0101 0102 LH.faces = FV.faces(LfaceIndex,:); 0103 RH.faces = FV.faces(RfaceIndex,:) - length(LH.vertices); 0104 0105 return