Home > vbmeg > functions > brain > vb_extract_cortex.m

vb_extract_cortex

PURPOSE ^

Extract cortex area index of original FreeSurfer surface

SYNOPSIS ^

function [Vindex] = vb_extract_cortex(V0L,F0L,V0R,F0R,brain_parm,plot_mode)

DESCRIPTION ^

 Extract cortex area index of original FreeSurfer surface
 1. Load cortex area index from original FreeSurfer surface label file
 2. Extract connected area of non-cortex region: corpus region
 3. Get cortex area index (complement of non-cortex region)
   [Vindex] = vb_extract_cortex(V0L,F0L,V0R,F0R,brain_parm)
 Vindex.cortexL = Left  cortex area index of original FreeSurfer surface
 Vindex.cortexR = Right cortex area index of original FreeSurfer surface

 2015-12-27 M. 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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function    [Vindex] = vb_extract_cortex(V0L,F0L,V0R,F0R,brain_parm,plot_mode)
0002 % Extract cortex area index of original FreeSurfer surface
0003 % 1. Load cortex area index from original FreeSurfer surface label file
0004 % 2. Extract connected area of non-cortex region: corpus region
0005 % 3. Get cortex area index (complement of non-cortex region)
0006 %   [Vindex] = vb_extract_cortex(V0L,F0L,V0R,F0R,brain_parm)
0007 % Vindex.cortexL = Left  cortex area index of original FreeSurfer surface
0008 % Vindex.cortexR = Right cortex area index of original FreeSurfer surface
0009 %
0010 % 2015-12-27 M. Sato
0011 %
0012 % Copyright (C) 2011, ATR All Rights Reserved.
0013 % License : New BSD License(see VBMEG_LICENSE.txt)
0014 
0015 % FreeSurfer file
0016 % brain_parm.FS_left_label_file
0017 % brain_parm.FS_right_label_file
0018 
0019 %brain_parm = vb_set_icbm152;
0020 %[V0L,F0L,n0L,V0R,F0R,n0R] = vb_load_orig_brain_surf(brain_parm);
0021 
0022 if ~exist('plot_mode', 'var')
0023     plot_mode = 0;
0024 end
0025 
0026 NL = size(V0L,1);
0027 NR = size(V0R,1);
0028 NV = NL + NR;
0029 
0030 % Load cortex index
0031 [VL,VLix] = load_cortex_label(brain_parm.FS_left_label_file);
0032 [VR,VRix] = load_cortex_label(brain_parm.FS_right_label_file);
0033 
0034 % get non-cortex index
0035 flgL = zeros(NL,1);
0036 flgR = zeros(NR,1);
0037 
0038 flgL(VLix) = 1;
0039 flgR(VRix) = 1;
0040 
0041 izL = find(flgL == 0);
0042 izR = find(flgR == 0);
0043 
0044 % extract connected area of non-cortex region
0045 [IZL] = vb_connected_vertex(izL,F0L);
0046 [IZR] = vb_connected_vertex(izR,F0R);
0047 
0048 izL = IZL{1};
0049 izR = IZR{1};
0050 
0051 % get cortex index
0052 flgL = zeros(NL,1);
0053 flgR = zeros(NR,1);
0054 
0055 flgL(izL) = 1;
0056 flgR(izR) = 1;
0057 
0058 icL = find(flgL == 0);
0059 icR = find(flgR == 0);
0060 
0061 Vindex.cortexL = icL;
0062 Vindex.cortexR = icR;
0063 Vindex.corpusL = izL;
0064 Vindex.corpusR = izR;
0065 
0066 NCL = length(icL);
0067 NCR = length(icR);
0068 NZL = length(izL);
0069 NZR = length(izR);
0070 
0071 %NL = size(V0L,1);
0072 %NR = size(V0R,1);
0073 
0074 fprintf('N_original   = %d (left) %d (right)\n', NL,NR)
0075 fprintf('N_cortex     = %d (left) %d (right)\n', NCL,NCR)
0076 fprintf('N_non_cortex = %d (left) %d (right)\n', NZL,NZR)
0077 
0078 if plot_mode == 0, return; end;
0079 
0080 % plot
0081 FLz = vb_patch_select(izL,F0L,NL);
0082 FRz = vb_patch_select(izR,F0R,NR);
0083 
0084 figure;
0085 subplot(1,2,1)
0086 vb_plot_surf(V0L,F0L,'','b')
0087 hold on
0088 vb_plot_surf(V0L,FLz,'r','r')
0089 
0090 subplot(1,2,2)
0091 vb_plot_surf(V0R,F0R,'','b')
0092 hold on
0093 vb_plot_surf(V0R,FRz,'r','r')
0094 
0095 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0096 %     load_cortex_label
0097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0098 function [V,Vix,Vlabel] = load_cortex_label(ascfile)
0099 
0100 % Open file
0101 fid = fopen(ascfile,'r');
0102 fgetl(fid); % comment line
0103 
0104 Num = fscanf(fid,'%d',1); 
0105 
0106 % # of vertices
0107 NV = Num(1);
0108 
0109 % data list
0110 data = fscanf(fid,'%d %e %e %e %e',inf);
0111 
0112 fclose(fid);
0113 
0114 %size(data)
0115 
0116 V = reshape(data(1:NV*5),[5 NV])';
0117 
0118 Vix = V(:,1) + 1; 
0119 Vlabel = V(:,5); 
0120 V = V(:,2:4);

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