Home > functions > plotfunc > vb_plot_brain_inflate.m

vb_plot_brain_inflate

PURPOSE ^

SYNOPSIS ^

function vb_plot_brain_inflate(plot_parm)

DESCRIPTION ^

 脳モデル上に強度分布を表示する
 2003-07-11 Taku Yoshioka

 plot_parm.brainfile: 全脳データファイル名
 plot_parm.areafile : 領域情報ファイル名
 plot_parm.J        : (電流などの)強度分布 全脳頂点数 x 1
 plot_parm.cmap     : 強度分布カラーマップ   1 hot   2 jet


 plot_parm.wmode    : 強度分布表示   1 絶対値   2 実数値
 plot_parm.wmax     : 強度分布を[0 w](または[-w w])で
                      スケーリングする w=max(abs(J))*wmax
 plot_parm.wmin     : w以上の強度を表示する w=max(abs(J))*wmin
 plot_parm.index    : 脳モデルの表示したい部分を表す頂点集合
 plot_parm.color    : 脳モデルの色を指定
 plot_parm.paint    : 1 点表示   2 面表示
 plot_parm.priority : 2ならば領域情報を強度情報の上に表示
 plot_parm.LRflag   : L/R/LR
 plot_parm.norm     : 2ならば強度情報を面積で正規化して表示
 plot_parm.sulcus   : 1ならば皺を表示する(省略可)
 plot_parm.cmax     : 強度分布絶対スケール(wmaxより優先される)

 --- 領域情報(省略可)
 plot_parm.area.key{i} : 領域ID
 plot_parm.area.clr{i} : 領域をこの色で表示
 plot_parm.area.str{i} : 表示する文字(省略可)
 plot_parm.Rlabel      : 文字と領域の距離(1で領域表面に文字表示)
 plot_parm.fs          : フォントサイズ
 plot_parm.area_number(i): 領域シーケンス中の表示する番号

 ・length(J)==0ならば強度分布を無視して脳モデルを表示
 ・length(index)==0ならば全脳モデル表示

 2003-07-24
 ・強度の実数表示に対応
 2003-07-27
 ・領域情報に基づいて表面に色をつける
 2003-07-29
 ・皺表示に対応
 2003-09-18
 ・領域を狭く表示することができるようにする
 ・領域の点表示に対応
 2003-09-19
 ・領域シーケンスの表示に対応
 2003-10-06
 ・関数を見直し、パラメータ名を少し変更
 2003-10-17
 ・領域情報と強度情報を表示する順番をplot_parm.orderで変更可能に
 2003-11-13
 ・領域半透明表示機能を追加
 2004-02-20
 ・parm構造体を使わないようにする。
 2004-03-25
 ・order->priority
 ・threshold->wmin(相対値)
 ・パラメータ`paint'の追加
 ・wmaxを相対値にする
 ・display->cmap,wmodeに分ける
 ・plot_parm.area.R->plot_parm.Rlabel
 ・plot_parm.area.fs->plot_parm.fs


 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 vb_plot_brain_inflate(plot_parm)
0002 %
0003 % 脳モデル上に強度分布を表示する
0004 % 2003-07-11 Taku Yoshioka
0005 %
0006 % plot_parm.brainfile: 全脳データファイル名
0007 % plot_parm.areafile : 領域情報ファイル名
0008 % plot_parm.J        : (電流などの)強度分布 全脳頂点数 x 1
0009 % plot_parm.cmap     : 強度分布カラーマップ   1 hot   2 jet
0010 %
0011 %
0012 % plot_parm.wmode    : 強度分布表示   1 絶対値   2 実数値
0013 % plot_parm.wmax     : 強度分布を[0 w](または[-w w])で
0014 %                      スケーリングする w=max(abs(J))*wmax
0015 % plot_parm.wmin     : w以上の強度を表示する w=max(abs(J))*wmin
0016 % plot_parm.index    : 脳モデルの表示したい部分を表す頂点集合
0017 % plot_parm.color    : 脳モデルの色を指定
0018 % plot_parm.paint    : 1 点表示   2 面表示
0019 % plot_parm.priority : 2ならば領域情報を強度情報の上に表示
0020 % plot_parm.LRflag   : L/R/LR
0021 % plot_parm.norm     : 2ならば強度情報を面積で正規化して表示
0022 % plot_parm.sulcus   : 1ならば皺を表示する(省略可)
0023 % plot_parm.cmax     : 強度分布絶対スケール(wmaxより優先される)
0024 %
0025 % --- 領域情報(省略可)
0026 % plot_parm.area.key{i} : 領域ID
0027 % plot_parm.area.clr{i} : 領域をこの色で表示
0028 % plot_parm.area.str{i} : 表示する文字(省略可)
0029 % plot_parm.Rlabel      : 文字と領域の距離(1で領域表面に文字表示)
0030 % plot_parm.fs          : フォントサイズ
0031 % plot_parm.area_number(i): 領域シーケンス中の表示する番号
0032 %
0033 % ・length(J)==0ならば強度分布を無視して脳モデルを表示
0034 % ・length(index)==0ならば全脳モデル表示
0035 %
0036 % 2003-07-24
0037 % ・強度の実数表示に対応
0038 % 2003-07-27
0039 % ・領域情報に基づいて表面に色をつける
0040 % 2003-07-29
0041 % ・皺表示に対応
0042 % 2003-09-18
0043 % ・領域を狭く表示することができるようにする
0044 % ・領域の点表示に対応
0045 % 2003-09-19
0046 % ・領域シーケンスの表示に対応
0047 % 2003-10-06
0048 % ・関数を見直し、パラメータ名を少し変更
0049 % 2003-10-17
0050 % ・領域情報と強度情報を表示する順番をplot_parm.orderで変更可能に
0051 % 2003-11-13
0052 % ・領域半透明表示機能を追加
0053 % 2004-02-20
0054 % ・parm構造体を使わないようにする。
0055 % 2004-03-25
0056 % ・order->priority
0057 % ・threshold->wmin(相対値)
0058 % ・パラメータ`paint'の追加
0059 % ・wmaxを相対値にする
0060 % ・display->cmap,wmodeに分ける
0061 % ・plot_parm.area.R->plot_parm.Rlabel
0062 % ・plot_parm.area.fs->plot_parm.fs
0063 %
0064 %
0065 % Copyright (C) 2011, ATR All Rights Reserved.
0066 % License : New BSD License(see VBMEG_LICENSE.txt)
0067 
0068 % 脳モデルの色を決めるパラメータ
0069 cscale = -0.4;
0070 c0 = 0.8;
0071 if ~isfield(plot_parm,'color') | isempty(plot_parm.color)
0072   plot_parm.color = [0.8 0.8 0.8];
0073 end
0074 
0075 % 脳モデルのロード
0076 [V,F,xx,inf_C,xxA] = vb_load_cortex(plot_parm.brainfile,'Inflate');
0077 
0078 % 脳モデルの中心
0079 V0 = mean(V);
0080 
0081 % 左脳/右脳表示切替え
0082 switch plot_parm.LRflag
0083  case 'LR',
0084   F3 = F.F3;
0085  case 'L',
0086   F3 = F.F3L;
0087  case 'R',
0088   F3 = F.F3R;
0089 end
0090 
0091 % 強度情報
0092 J = plot_parm.J;
0093 if plot_parm.norm==2
0094   J = J./xxA;
0095 end
0096 
0097 if isfield(plot_parm,'cmax')
0098   wmax = plot_parm.cmax;
0099 else
0100   wmax = plot_parm.wmax*max(abs(J(:)));
0101 end
0102 wmin = plot_parm.wmin*wmax;
0103 index = plot_parm.index;
0104 
0105 %
0106 % 脳モデルの表示
0107 %
0108 
0109 % 面を選択
0110 if length(index) == 0
0111   FF = F3;
0112 else
0113   FF = vb_patch_select2(index,F3,size(V,1));  
0114 end
0115 
0116 % 面を表示
0117 if ~isfield(plot_parm,'sulcus') | plot_parm.sulcus
0118   colors = [plot_parm.color(1)*inf_C ...
0119         plot_parm.color(2)*inf_C ...
0120         plot_parm.color(3)*inf_C] * cscale ...
0121        + repmat(plot_parm.color,[length(inf_C) 1]);
0122   patch('Faces',FF,'Vertices',V,'FaceColor','interp',...
0123     'EdgeColor','none','FaceVertexCData',colors);
0124 else
0125   patch('Faces',FF,'Vertices',V,'FaceColor',plot_parm.color,...
0126     'EdgeColor','none','FaceLighting','phong');
0127 end
0128 
0129 material dull;
0130 hold on;
0131 
0132 if isfield(plot_parm,'priority') & plot_parm.priority==2
0133   plot_value(plot_parm,V,F3,J,index,wmin,wmax);
0134   plot_area(plot_parm,V,F3,index,V0);
0135 else
0136   plot_area(plot_parm,V,F3,index,V0);
0137   plot_value(plot_parm,V,F3,J,index,wmin,wmax);
0138 end
0139 
0140 function plot_area(plot_parm,V,F3,index,V0)
0141 %
0142 % 領域の表示
0143 %
0144 if isfield(plot_parm,'area')
0145   if isempty(index)
0146     tmp = ones(size(V,1),1);
0147   else
0148     tmp = zeros(size(V,1),1);
0149     tmp(index) = 1;
0150   end
0151 
0152   % 半透明表示
0153   if isfield(plot_parm.area,'transparent') & ...
0154     plot_parm.area.transparent
0155     alpha = 0.5;
0156   else
0157     alpha = 1;
0158   end
0159   
0160   for i = 1:length(plot_parm.area.key)
0161     Area = vb_get_area(plot_parm.areafile,plot_parm.area.key{i});
0162     if isfield(plot_parm.area,'number')
0163       ix = Area.Iextract_seq{plot_parm.area.number(i)};
0164     else
0165       ix = Area.Iextract;
0166     end
0167     ix = ix(:);
0168     ix = ix(find(ix .* tmp(ix))); % 表示部分に含まれる頂点
0169 
0170     % 点表示/パッチ表示
0171     Nclr = length(plot_parm.area.clr);
0172     if plot_parm.paint==1
0173       ix2 = intersect(ix,unique(F3(:)));
0174       plot3(V(ix2,1),V(ix2,2),V(ix2,3),'.',...
0175         'MarkerFaceColor',plot_parm.area.clr{1+mod(i-1,Nclr)},...
0176         'MarkerEdgeColor',plot_parm.area.clr{1+mod(i-1,Nclr)},...
0177         'MarkerSize',plot_parm.ms);
0178     else
0179       FF = vb_patch_select2(ix,F3,size(V,1));
0180       patch('Faces',FF,'Vertices',V,...
0181         'FaceColor',plot_parm.area.clr{1+mod(i-1,Nclr)},...
0182         'EdgeColor','none','FaceLighting','none',...
0183         'FaceAlpha',alpha);
0184     end
0185 
0186     % 文字表示
0187     if isfield(plot_parm.area,'str') ...
0188       & ~isempty(plot_parm.area.str) & length(FF) > 0
0189       pos = median(V(ix,:)) - V0;
0190       [theta,phi,r] = cart2sph(pos(1),pos(2),pos(3));
0191       r = plot_parm.Rlabel * r;
0192       
0193       [x,y,z] = sph2cart(theta,phi,r);
0194       x = x + V0(1);
0195       y = y + V0(2);
0196       z = z + V0(3);
0197       pos = pos + V0;
0198       plot3([pos(1) x],[pos(2) y],[pos(3) z]);
0199       h = text(x,y,z,plot_parm.area.str{i},...
0200            'Interpreter','none','FontSize',plot_parm.fs,...
0201            'HorizontalAlignment','center');
0202     end
0203   end
0204 end
0205 
0206 function plot_value(plot_parm,V,F3,J,index,wmin,wmax)
0207 %
0208 % 強度の表示
0209 %
0210 if length(J) == 0
0211   return;
0212 end
0213 
0214 % 面を選択
0215 if length(index) == 0
0216   tmp = ones(length(J),1);
0217 else
0218   tmp = zeros(length(J),1);
0219   tmp(index) = 1;
0220 end
0221 
0222 % 左脳/右脳
0223 tmp2 = zeros(length(J),1);
0224 tmp2(unique(F3(:))) = 1;
0225 
0226 tmp = J.*tmp.*tmp2;
0227 ix = find(abs(tmp)>=wmin);
0228 if plot_parm.wmode==1
0229   J = abs(J);
0230 end
0231 
0232 % 強度を脳モデルに重ねて表示
0233 if plot_parm.paint==1
0234   h = scatter3(V(ix,1),V(ix,2),V(ix,3),1,J(ix),'.','filled');
0235   set(h,'MarkerSize',plot_parm.ms);
0236 else
0237   FF = vb_patch_select2(ix,F3,size(V,1));
0238   patch('Faces',FF,'Vertices',V,'FaceColor','interp',...
0239     'FaceVertexCData',J,'EdgeColor','none',...
0240     'FaceLighting','none');
0241   material dull;
0242 end
0243 
0244 if plot_parm.wmode==1
0245   caxis([0 wmax]);
0246 else
0247   caxis([-wmax wmax]);
0248 end
0249   
0250 if plot_parm.cmap==1
0251   colormap(hot);
0252 else
0253   colormap(jet);
0254 end
0255

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005