function [V,C,Indx] = vb_fs_load_surface(patchfile,curvfile) Load flat patch file(lh/rh.flat.patch.3d.asc) and original indices. [Input] patchfile : Freesurfer flat patch file(lh/rh.flat.patch.3d.asc) [Output] V : Vertex coordinates F : Faces C : Curvature Indx : Vertex index in the FS original model (1-start) [History] 2018-8-02 rhayashi Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [V, F, C, Indx] = vb_fs_load_flat_patch(flatpatchfile, curvfile) 0002 % function [V,C,Indx] = vb_fs_load_surface(patchfile,curvfile) 0003 % Load flat patch file(lh/rh.flat.patch.3d.asc) and original indices. 0004 % 0005 % [Input] 0006 % patchfile : Freesurfer flat patch file(lh/rh.flat.patch.3d.asc) 0007 % 0008 % [Output] 0009 % V : Vertex coordinates 0010 % F : Faces 0011 % C : Curvature 0012 % Indx : Vertex index in the FS original model (1-start) 0013 % 0014 % [History] 0015 % 2018-8-02 rhayashi 0016 % 0017 % Copyright (C) 2011, ATR All Rights Reserved. 0018 % License : New BSD License(see VBMEG_LICENSE.txt) 0019 0020 [N0,C] = vb_fs_load_normal(curvfile); 0021 0022 0023 % Load patch data 0024 fid = fopen(flatpatchfile,'r'); 0025 fgetl(fid); % Comment line 0026 s = fgetl(fid); 0027 tmp = sscanf(s,'%d %d',2); 0028 NV = tmp(1); % Number of vertices 0029 NF = tmp(2); % Number of patches 0030 0031 % Load vertices 0032 V = zeros(size(N0, 1), 3); 0033 %V(:, :) = nan; 0034 Indx = zeros(NV, 1); 0035 0036 for k=1:NV 0037 s = fgetl(fid); 0038 ix = sscanf(s,'%d vno=%d', 2); 0039 s = fgetl(fid); 0040 tmp = sscanf(s,'%e %e %e',3); 0041 % fprintf('%d\n', k); 0042 Indx(k) = ix(2) + 1; 0043 V(Indx(k), :) = tmp'; 0044 end 0045 0046 % Load faces 0047 F = zeros(NF, 3); 0048 for k=1:NF 0049 s = fgetl(fid); % fno 0050 s = fgetl(fid); % F 0051 tmp = sscanf(s,'%e %e %e',3)+1; 0052 F(k, :) = [tmp']; 0053 end 0054 F = uint32(F); 0055 0056 fclose(fid); 0057 % toc; 0058 % % Load curvature data 0059 % n = load('-ascii',curvfile); % inner function 0060 % C = n(Indx,5); 0061 % C = (C./max(abs(C))+1)*0.5;