Home > data-utility > granger_causality > gcause_libs > visualize_gcause_matrix_group_development.m

visualize_gcause_matrix_group_development

PURPOSE ^

SYNOPSIS ^

function link_matrix = visualize_gcause_matrix_group_development(gcause_mat_groups, gcause_sig_groups, gcause_str_list, kid_list, save_name)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function link_matrix = visualize_gcause_matrix_group_development(gcause_mat_groups, gcause_sig_groups, gcause_str_list, kid_list, save_name)
0002 
0003 color_emerge = [...
0004     1    0    0; ...
0005     1 1 1; ...
0006     1 1 1];
0007 color_dissolve = [0 0 1];
0008 color_nochange = [1 1 1];
0009 
0010 num_kids = size(gcause_mat_groups, 1);
0011 num_gtypes = size(gcause_mat_groups, 2);
0012 num_exp = size(gcause_mat_groups, 3);
0013 
0014 plot_xlim = [0 num_gtypes];
0015 plot_ylim = [0 num_kids];
0016 h = figure('Position', [50 50 1200 1000]);
0017 hold on;
0018 % plot row by row
0019 gcause_mat_prev = gcause_mat_groups(:, :, 1);
0020 gcause_mat_dev = gcause_mat_groups(:, :, 2);
0021 gcause_sig_prev = gcause_sig_groups(:, :, 1);
0022 gcause_sig_dev = gcause_sig_groups(:, :, 2);
0023 
0024 link_matrix = zeros(num_kids, num_gtypes);
0025 
0026 for kidx = 1:num_kids
0027     plot_y_one = num_kids - kidx;
0028     block_y = [plot_y_one plot_y_one+1 plot_y_one+1 plot_y_one];
0029     text_y = mean(block_y);
0030     % row var text
0031     text(-0.05, text_y, sprintf('kid%d', kid_list(kidx)), 'HorizontalAlignment', 'right', 'FontSize', 8);
0032     
0033     for gtidx = 1:num_gtypes
0034         block_x = [gtidx-1 gtidx-1 gtidx gtidx];
0035 
0036         gcause_sig_one = gcause_sig_dev(kidx, gtidx);
0037         % if postive link
0038         if gcause_sig_one > 0
0039             % emergence of new positive links
0040             if gcause_sig_prev(kidx, gtidx) < 1;
0041                 block_color = color_emerge(1, :);
0042 %                 gcause_one = gcause_mat_dev(kidx, gtidx);
0043                 gcause_one = gcause_mat_dev(kidx, gtidx) - gcause_mat_prev(kidx, gtidx);
0044                 link_matrix(kidx, gtidx) = 1;
0045             else
0046                 gcause_one = gcause_mat_dev(kidx, gtidx) - gcause_mat_prev(kidx, gtidx);
0047                 % increase
0048                 if gcause_one > 0
0049                     block_color = color_emerge(2, :);
0050                 % discrease
0051                 elseif gcause_one < 0
0052                     block_color = color_emerge(3, :);
0053                 else
0054                     block_color = color_nochange;
0055                 end
0056             end
0057         else
0058 %             gcause_one = gcause_mat_dev(kidx, gtidx);
0059             gcause_one = gcause_mat_dev(kidx, gtidx) - gcause_mat_prev(kidx, gtidx);
0060             % dissolve of sig positive links
0061             if gcause_sig_prev(kidx, gtidx) > 0;
0062                 block_color = color_dissolve;
0063                 link_matrix(kidx, gtidx) = -1;
0064             else
0065                 block_color = color_nochange;
0066             end
0067         end
0068         
0069         if gcause_one > 66 && gcause_sig_one < 1
0070             kid_list(kidx)
0071             block_color = color_emerge(1, :);
0072         end
0073         
0074         fill(block_x, block_y, block_color, 'EdgeColor', 'k');
0075         text_x = mean(block_x);
0076         text(text_x, text_y, sprintf('%.2f', gcause_one), 'HorizontalAlignment', 'center', 'FontSize', 8);
0077         
0078         if kidx < 2
0079             % column var text
0080             text(text_x, (num_kids+0.1), {gcause_str_list{gtidx, 1}; gcause_str_list{gtidx, 2}}, ...
0081                 'HorizontalAlignment', 'center', 'VerticalAlignment', 'bottom', 'FontSize', 6);
0082         end
0083     end
0084 end
0085 hold off;
0086 xlim(plot_xlim);
0087 ylim(plot_ylim);
0088 set(gca,'xticklabel',{[]});
0089 set(gca,'yticklabel',{[]});
0090 
0091 if nargin > 2
0092     saveas(h, save_name);
0093     close(h);
0094 end

Generated on Wed 24-May-2017 00:00:56 by m2html © 2005