Home > vbmeg > functions > job > job_view_cortex_dir > job_view_cortex_plot.m

job_view_cortex_plot

PURPOSE ^

job_view_cortex_plot( key )

SYNOPSIS ^

function job_view_cortex_plot( key )

DESCRIPTION ^

 job_view_cortex_plot( key )

 脳モデル表示pインターフェイス


 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 job_view_cortex_plot( key )
0002 % job_view_cortex_plot( key )
0003 %
0004 % 脳モデル表示pインターフェイス
0005 %
0006 %
0007 % Copyright (C) 2011, ATR All Rights Reserved.
0008 % License : New BSD License(see VBMEG_LICENSE.txt)
0009 
0010 H = get( gcf, 'UserData' );
0011 
0012 brain = get( H.braindata, 'UserData' );
0013 act = get( H.actdata, 'UserData' );
0014 area = get( H.areadata, 'UserData' );
0015 selection = get( H.selectdata, 'UserData' );
0016 param = get( H.paramdata, 'UserData' );
0017 
0018 % モデルIswitch param.model_type
0019  case 'original'
0020   V = brain.V;
0021  case 'inflate'
0022   V = brain.Vinflate;
0023 end
0024 
0025 % 右脳/]/Iswitch param.LRflg
0026  case 'L'
0027   F = brain.F.F3L;
0028  case 'R'
0029   F = brain.F.F3R;
0030  case 'LR'
0031   F = brain.F.F3;
0032 end
0033 
0034 % マスク( マスク_(揩\示 )
0035 if isempty(area.masking)
0036   mask = [1:length(brain.V)];  % マスクS\示
0037 else
0038   mask = unique( [ area.source(area.masking).Vi ] );
0039 end
0040 
0041 %===  脳モデル\示  ================================================
0042 switch key
0043 
0044  case 'brain'
0045   cla;
0046   job_view_cortex_plot_brain_model( V, F, brain.S, mask, param );
0047   job_view_cortex_plot_brain_act_area( V, F, brain.Va, act, area,...
0048                        mask, param, key );
0049   job_view_cortex_plot_brain_selected( V, F, selection.Vi, mask, param );
0050   selected = get( H.activation_plotted_list, 'Value' );
0051   job_view_cortex_plot_brain_act_highlight( act, param,...
0052                         act.plotted( selected ) );
0053   selected = get( H.area_plotted_list, 'Value' );
0054   job_view_cortex_plot_brain_area_highlight( V, F, area, mask, param,...
0055                          area.plotted( selected ) );
0056   alpha(1.0);
0057   
0058  case { 'act', 'area' }
0059   job_view_cortex_plot_brain_act_area( V, F, brain.Va, act, area,...
0060                        mask, param, key );
0061   job_view_cortex_plot_brain_selected( V, F, selection.Vi, mask, param );
0062   selected = get( H.activation_plotted_list, 'Value' );
0063   job_view_cortex_plot_brain_act_highlight( act, param,...
0064                         act.plotted( selected ) );
0065   selected = get( H.area_plotted_list, 'Value' );
0066   job_view_cortex_plot_brain_area_highlight( V, F, area, mask, param,...
0067                          area.plotted( selected ) );
0068   alpha(1.0);
0069   
0070  case 'selection'
0071   job_view_cortex_plot_brain_selected( V, F, selection.Vi, mask, param );
0072   selected = get( H.activation_plotted_list, 'Value' );
0073   job_view_cortex_plot_brain_act_highlight( act, param,...
0074                         act.plotted( selected ) );
0075   selected = get( H.area_plotted_list, 'Value' );
0076   job_view_cortex_plot_brain_area_highlight( V, F, area, mask, param,...
0077                          area.plotted( selected ) );
0078   
0079  case 'highlight act'
0080   selected = get( H.activation_plotted_list, 'Value' );
0081   job_view_cortex_plot_brain_act_highlight( act,...
0082                         param, act.plotted( selected ) );
0083 
0084  case 'highlight area'
0085   selected = get( H.area_plotted_list, 'Value' );
0086   job_view_cortex_plot_brain_area_highlight( V, F, area, mask, param,...
0087                          area.plotted( selected ) );
0088 
0089 end
0090 
0091 material dull;
0092 lighting phong;
0093 
0094 % マウス@能]job_view_cortex_callback( 'mouse func' );
0095 
0096 
0097 
0098 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0099 %%%% 脳モデル`%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0100 
0101 function job_view_cortex_plot_brain_model( V, F, S, mask, param )
0102 %
0103 % V : _データ
0104 % F : fータ
0105 % S : _a_理配% mask : 表示_インデックス
0106 % param : パラメタ色々。g..
0107 %     param.brain_color : モデル`F
0108 %     param.sulcus_visibility: 溝F visible or invisible )
0109 %     param.sulcus_color     : 溝`F( true color )
0110 %     param.lighting         : ライティング on or off )
0111 %
0112 
0113 % IFF = vb_patch_select2(mask,F,length(V));
0114 
0115 switch param.model_type
0116  case 'original'
0117   Vshrink = vb_shrink_cortex_for_plot(V, FF);
0118   patch( 'Faces', FF, 'Vertices', Vshrink, 'FaceColor', param.brain_color,...
0119      'EdgeColor', 'none', 'Tag', 'brain', 'Clipping', 'off' );
0120  case 'inflate'
0121   switch param.sulcus_visibility
0122    case 'visible'
0123     colors = ( ones(length(V),1) - S' ) * param.brain_color...
0124           + S' * param.sulcus_color; 
0125     Vshrink = vb_shrink_cortex_for_plot(V, FF, true);
0126     patch( 'Faces', FF, 'Vertices', Vshrink, 'FaceColor', 'interp',...
0127        'EdgeColor', 'none', 'FaceVertexCData', colors,...
0128        'Tag', 'brain', 'Clipping', 'off' );
0129    case 'invisible'
0130     patch( 'Faces', FF, 'Vertices', V, 'FaceColor', param.brain_color,...
0131        'EdgeColor', 'none', 'Tag', 'brain', 'Clipping', 'off' );
0132   end
0133 end
0134   
0135 switch param.lighting
0136  case 'on'
0137   h  = camlight(0, 0);
0138   set(h,  'UserData', 'light1');
0139   h2 = camlight(0, 180);
0140   set(h2, 'UserData', 'light2');
0141 end
0142 
0143 
0144 
0145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0146 %%%% 脳活脳`%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0147 
0148 function job_view_cortex_plot_brain_act_area( V, F, Va, act, area, mask, param, key )
0149 %
0150 % param.act_area_priority ( 脳活]\示
0151 % U%
0152 
0153 switch param.act_area_priority
0154  case 'activation'
0155   switch key
0156    case 'act'
0157     job_view_cortex_plot_brain_activation( V, F, Va, act, mask, param );
0158    case { 'brain', 'area' }
0159     job_view_cortex_plot_brain_area( V, F, area, mask, param );
0160     job_view_cortex_plot_brain_activation( V, F, Va, act, mask, param );
0161   end
0162  case 'area'
0163   switch key
0164    case { 'brain', 'act' }
0165     job_view_cortex_plot_brain_area( V, F, area, mask, param );
0166     job_view_cortex_plot_brain_activation( V, F, Va, act, mask, param );
0167    case 'area'
0168     job_view_cortex_plot_brain_area( V, F, area, mask, param );
0169   end
0170 end
0171 
0172 
0173 
0174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0175 %%%% 脳活`%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0176 
0177 function job_view_cortex_plot_brain_activation( V, F, Va, act, mask, param )
0178 %
0179 % V    : _データ ( Nv × 3 )
0180 % F    : fータ ( Nf × 3 )
0181 % Va   : 各_( Nv × 1 )
0182 % act  : 活fータ構% mask : 表示_Cンデックス ( Nm × 1 )
0183 % param.act_normalize  : 活xK%     'no'       --- K デフォルト
0184 %     'meshsize' --- 脳モデル<bシュサイズK% param.act_relative_mode  : 活xlv法
0185 %     'all'  --- .act.matファイル中fータl
0186 %     'each' --- 表示中fータl, デフォルト
0187 % param.act_min_mode  : 描xl@
0188 %     'absolute' --- lw%     'relative' --- lыw デフォルト
0189 % param.act_min  : 描xl
0190 %     param.act_min_mode = 'absolute' l
0191 %     param.act_min_mode = 'relative' lы
0192 %     ( デフォルト.1 )
0193 % param.act_sign_mode         :
0194 % param.act_colormap_max_mode :
0195 % param.act_colormap_max      : カラー軸%     act_sing_mode = 'signed'   Aカラー軸[ -cmax, cmax ]
0196 %     act_sing_mode = 'unsigned' Aカラー軸[ 0, cmax ]
0197 %     AcmaxAact_colormap_max_mode A
0198 %         'absolute' Acmax = act_colormap_max
0199 %         'relative' Acmax = act_colormap_max × l
0200 %     デフォルトA
0201 %     act_sign_mode = 'unsigned'
0202 %     act_colormap_max_mode = 'relative'
0203 %     act_colormap_max = 1
0204 % param.act_colormap_type  : カラーマップ^イプ
0205 %     'jet' --- jet タイプ, デフォルト
0206 %     'hot' --- hot タイプ
0207 % param.paint  : 活x,  選`@
0208 %     'patch' --- patch(`%     'dot'   --- plot(点)`% param.markersize  : 点描桙}ーカー%     スカラ値 ( デフォルト1 )
0209 %
0210 
0211 delete( findobj( gca, 'Tag', 'act' ) );
0212 
0213 if isempty( act.plotted ); return; end;
0214 
0215 % lv
0216 switch param.act_relative_mode
0217  case 'each'
0218   Jabsmax = max( abs( [ act.source(act.plotted).J ] ) );
0219  case 'all'
0220   Jabsmax = max( abs( [ act.source(act.candidate).J ] ) );
0221 end
0222 
0223 % 各活xデータ`for id = act.plotted
0224 
0225   J = act.source(id).J;
0226 
0227   %%%%% 活K%%%%%
0228   switch param.act_normalize
0229    case 'meshsize'
0230     J = J ./ Va;
0231   end
0232 
0233   %%%%% 表示_I %%%%%
0234   % マスキング : mask _F _舶  ind = intersect( mask, unique(F(:)) );
0235   % `xI  switch param.act_min_mode
0236    case 'absolute'
0237     ind = intersect( ind, find( abs(J) >= param.act_min ) );
0238    case 'relative'
0239     ind = intersect( ind, find( abs(J) >= Jabsmax * param.act_min ) );
0240   end
0241 
0242   %%%%% カラーマップ%%%%%
0243   switch param.act_colormap_max_mode
0244    case 'absolute'
0245     cmax = param.act_colormap_max;
0246    case 'relative'
0247     cmax = Jabsmax * param.act_colormap_max;
0248   end
0249 
0250   switch param.act_colormap_type
0251    case 'hot'
0252     colormap(hot);
0253    case 'jet'
0254     colormap(jet);
0255   end
0256 
0257   %%%%% l表示/符号付\示*****
0258   switch param.act_sign_mode
0259    case 'signed'
0260     caxis( [ -cmax cmax ] );
0261    case 'unsigned'
0262     J = abs(J);
0263     caxis( [ 0 cmax ] );
0264   end
0265 
0266   %%%%% 描%%%%%
0267   switch param.paint
0268    case 'dot'
0269     tmp = scatter3( V(ind,1), V(ind,2), V(ind,3), 1, J(ind), '.', 'filled' );
0270     set( tmp, 'MarkerSize', param.markersize, 'Tag', 'act', 'UserData', id,...
0271           'HitTest', 'off', 'Clipping', 'off' );
0272    case 'patch'
0273     FF = vb_patch_select2(ind,F,length(V));  
0274     patch( 'Faces', FF, 'Vertices', V, 'FaceColor', 'interp',...
0275        'FaceVertexCData', J', 'EdgeColor', 'none', 'FaceAlpha', 0.99,...
0276        'Tag', 'act', 'UserData', id, 'HitTest', 'off', 'Clipping', 'off' );
0277     alpha(findobj( gca, 'Tag', 'brain' ), 0.99); % to fix display bug for MATLAB r2014b-2015b
0278   end
0279   
0280 end
0281 
0282 
0283 
0284 
0285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0286 %%%% 脳`%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0287 
0288 function job_view_cortex_plot_brain_area( V, F, area, mask, param )
0289 %
0290 % V    : _データ ( Nv × 3 )
0291 % F    : fータ ( Nf × 3 )
0292 % area : 活fータ構% mask : 表示_Cンデックス ( Nm × 1 )
0293 % param.area_alpha  : \示x
0294 %     0.01 〜 0.99 Xカラ値 ( デフォルト0.4 )
0295 % param.paint  : 活x,  選`@
0296 %     'patch' --- patch(`%     'dot'   --- plot(点)`% param.markersize  : 点描桙}ーカー%     スカラ値 ( デフォルト1 )
0297 %
0298 
0299 delete( findobj( gca, 'Tag', 'area' ) );
0300 
0301 if isempty( area.plotted ); return; end;
0302 
0303 area_colors = [ 1 0 0; 0 1 0; 0 0 1; 1 1 0; 1 0 1; 0 1 1;
0304         1 1 0.5; 0.5 0 0; 0 0.5 1; 0.5 1 0; 1 0.5 1; 0 0 0.5;
0305         1 0.5 0; 0 1 0.5; 0.5 0 1; 0 0.5 0; 0.5 1 1; 1 0 0.5;
0306         1 0.5 0.5; 0 0.5 0.5; 0.5 1 0.5;
0307         0.5 0 0.5; 0.5 0.5 1; 0.5 0.5 0 ];
0308 
0309 for id = area.plotted
0310   
0311   ind = intersect( area.source(id).Vi, mask );
0312 
0313   % F _Jットオフ
0314   ind = intersect( ind, unique(F) );
0315 
0316   if isfield(area.source(id), 'color')
0317       color = area.source(id).color;
0318   else
0319       color = area_colors(1+mod(id-1,length(area_colors)),:);
0320   end
0321 
0322   % 描  switch param.paint
0323    case 'dot'
0324     plot3( V(ind,1), V(ind,2), V(ind,3), '.',...
0325        'MarkerFaceColor', color, 'MarkerEdgeColor', color,...
0326        'MarkerSize', param.markersize, 'Tag', 'area', 'UserData', id,...
0327        'HitTest', 'off', 'Clipping', 'off' );
0328    case 'patch'
0329     FF = vb_patch_select2( ind, F, length(V) );
0330     patch( 'Faces', FF, 'Vertices', V,...
0331        'FaceColor', color, 'EdgeColor', 'none', 'FaceLighting', 'none',...
0332        'FaceAlpha', param.area_alpha, 'Tag', 'area', 'UserData', id,...
0333        'HitTest', 'off', 'Clipping', 'off' );
0334     alpha(findobj( gca, 'Tag', 'brain' ), 0.99); % to fix display bug for MATLAB r2014b-2015b
0335   end
0336 
0337   % 囎\示 ?????
0338 
0339 end
0340 
0341 
0342 
0343 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0344 %%%% ハイライト`%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0345 
0346 function job_view_cortex_plot_brain_act_highlight( act, param, selected )
0347 %
0348 % param.act_show_highlight  : 活xnイライト(Plot ListI梛
0349 %     'on'  --- ハイライト デフォルト
0350 %     'off' --- ハイライト%     ハイライトO\示% param.act_non_highlight_alpha  : ハイライトOxx
0351 %     0.01 〜 0.99 Xカラ値 ( デフォルト0.5 )
0352 %
0353 
0354 if isempty( selected ); return; end;
0355 if strcmp( param.act_show_highlight, 'off' ); return; end;
0356 
0357 for id = act.plotted
0358   if ismember( id, selected )
0359     set( findobj( gca, 'Tag', 'act', 'UserData', id ), 'FaceAlpha', 0.99 );
0360   else
0361     set( findobj( gca, 'Tag', 'act', 'UserData', id ),...
0362      'FaceAlpha', param.act_non_highlight_alpha );
0363   end
0364 end
0365 
0366 
0367 function job_view_cortex_plot_brain_area_highlight( V, F, area, mask,...
0368                             param, selected )
0369 %
0370 % param.area_show_highlight  : nイライト(Plot ListI梛
0371 %     'on'  --- ハイライト デフォルト
0372 %     'off' --- ハイライト%
0373 
0374 delete( findobj( 'Tag', 'area_highlight' ) );
0375 
0376 if isempty( area.plotted ) | isempty( selected ); return; end;
0377 if strcmp( param.area_show_highlight, 'off' ); return; end;
0378 
0379 Vx = V(:,1); Vy = V(:,2); Vz = V(:,3);
0380 
0381 for id = selected
0382   % エッジ
0383   Vi = intersect( area.source(id).Vi, mask );
0384   FF = vb_patch_select2( Vi, F, length(V) );
0385   FL = [ FF(:,1), FF(:,2); FF(:,2), FF(:,3); FF(:,3), FF(:,1) ];
0386   FL_inv = [ FL(:,2), FL(:,1) ];
0387   FL = setdiff( FL, FL_inv, 'rows' );
0388   [ FL_unq, I, J ] = unique( FL, 'rows' );
0389   edge = setdiff( FL_unq, FL( setdiff( [1:size(FL,1)], I ), : ), 'rows' );
0390   %エッジ`%
0391 %   next = sparse( edge(:,1), edge(:,2), ones(length(edge),1), length(V), length(V), length(edge) );
0392 %   [X,Y] = gplot( next, V, '-' );
0393 %   line( X, Y, 'Color', [0.3,0.3,0.3], 'Tag', 'area_highlight', 'UserData', id );
0394 %
0395 %   Se = mat2cell( edge, ones(1,length(edge)), [2] );
0396 %   for i = 1 : length(Se)
0397 %     for j = i + 1 : length(Se)
0398 %       e1 = Se{i}; e2 = Se{j};
0399 %       if e1(1) == e2(1)
0400 %     Se{j} = [ e1(length(e1):2), e2 ];
0401 %     Se{i} = [];
0402 %     break;
0403 %       elseif e1(1) == e2(length(e2))
0404 %     Se{j} = [ e2, e1(2:length(e1)) ];
0405 %     Se{i} = [];
0406 %     break;
0407 %       elseif e1(length(e1)) == e2(1)
0408 %     Se{j} = [ e1(1:length(e1)-1), e2 ];
0409 %     Se{i} = [];
0410 %     break;
0411 %       elseif e1(length(e1)) == e2(length(e2))
0412 %     Se{j} = [ e1(1:length(e1)-1), e2 ];
0413 %     Se{i} = [];
0414 %     break;
0415 %       end
0416 %     end
0417 %   end
0418 %   for i = 1 : length(Se)
0419 %     if ~isempty(Se{i})
0420 %       e = Se{i};
0421 %       line( Vx(e), Vy(e), Vz(e), 'Color', [0.3,0.3,0.3],...
0422 %         'Tag', 'area_highlight', 'UserData', id );
0423 %     end
0424 %   end
0425 %
0426   line( Vx(edge'), Vy(edge'), Vz(edge'), 'Color', [0.3,0.3,0.3],...
0427     'Tag', 'area_highlight', 'UserData', id );
0428 end
0429 
0430 
0431 
0432 
0433 
0434 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0435 %%%% 選`%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0436 
0437 function job_view_cortex_plot_brain_selected( V, F, Vi, mask, param )
0438 %
0439 % param.selection_color  : I桙F
0440 %     TrueColor ( デフォルト[ 1 1 1 ] )
0441 % param.paint  : 活x,  選`@
0442 %     'patch' --- patch(`%     'dot'   --- plot(点)`% param.markersize  : 点描桙}ーカー%     スカラ値 ( デフォルト1 )
0443 %
0444 
0445 delete( findobj( gca, 'Tag', 'selected' ) );
0446 
0447 if isempty( Vi )
0448   return;
0449 end
0450 
0451 ind = intersect( Vi, mask );
0452 
0453 % F _Jットオフ
0454 Vi = intersect( ind, unique(F) );
0455 
0456 color = param.selection_color;
0457 
0458 % 描if param.paint == 1
0459   plot3( V(Vi,1), V(Vi,2), V(Vi,3), '.',...
0460      'MarkerFaceColor', color, 'MarkerEdgeColor', color,...
0461      'MarkerSize', param.markersize, 'Tag', 'selected',...
0462      'HitTest', 'off', 'CLipping', 'off' );
0463 else
0464   FF = vb_patch_select2( ind, F, length(V) );
0465   patch( 'Faces', FF, 'Vertices', V,...
0466      'FaceColor', color, 'EdgeColor', 'none', 'FaceAlpha', 0.99,...
0467      'Tag', 'selected', 'HitTest', 'off', 'Clipping', 'off' );
0468 end
0469 
0470 
0471 
0472 
0473 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0474 % ルーチン
0475 function Fnew = vb_patch_select2(Vix,F,Nvertex)
0476 Itrans = zeros(Nvertex,1);
0477 Itrans(Vix) = 1;
0478 Fnew = Itrans(F);
0479 ix = find(sum(Fnew,2));
0480 Fnew = F(ix,:);

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