Home > data-vis > vis_cstreams.m

vis_cstreams

PURPOSE ^

SYNOPSIS ^

function vis_cstreams(allcst, timebase, labels, colors, axh)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function vis_cstreams(allcst, timebase, labels, colors, axh)
0002 
0003 if ~exist('colors', 'var') || isempty(colors)
0004     colors = set_colors;
0005 end
0006 
0007 if ~iscell(allcst)
0008     allcst = {allcst};
0009 end
0010 if exist('labels', 'var') && ~isempty(labels)
0011     labels = labels(end:-1:1);
0012 else
0013     labels = cell(1, numel(allcst));
0014     for l = 1:numel(allcst)
0015         labels{1,l} = num2str(l);
0016     end
0017 end
0018 allcst = allcst(end:-1:1);
0019 
0020 bottom = 0;
0021 space = 0.03;
0022 earliesttime = Inf;
0023 latesttime = -Inf;
0024 if ~exist('axh', 'var') || isempty(axh)
0025     h = figure('visible' ,'on');
0026     axh = axes;
0027     set(h, 'position', [100 100 1440 360]);
0028     set(axh, 'position', [.05 .25 .9 .5]);
0029 end
0030 for c = 1:numel(allcst)
0031     cst = allcst{c};
0032     if ~isempty(cst)
0033         if size(cst, 2) == 1
0034             if exist('timebase', 'var') && ~isempty(timebase)
0035                 cst = cat(2, timebase(:,1), cst);
0036             else
0037                 cst = cat(2, (1:length(cst))', cst);
0038             end
0039         end
0040         
0041         if size(cst,2) == 2
0042             cev = cstream2cevent(cst);
0043         else
0044             cev = cst;
0045         end
0046         
0047         if ~isempty(cev)
0048             for i = 1:size(cev, 1)
0049                 tmp = cev(i,:);
0050                 width = tmp(2) - tmp(1);
0051                 if width > 0
0052                     rectangle('Position', [tmp(1), bottom, width, 1], 'facecolor', colors(tmp(3),:), 'edgecolor', 'black', 'linewidth', 0.5);
0053                 end
0054             end
0055             
0056             earliesttime = min([earliesttime, cev(1,1)]);
0057             latesttime = max([latesttime, cev(end,2)]);
0058         end
0059     end
0060     bottom = bottom + 1 + space;
0061 end
0062 bottom = bottom - space;
0063 ylim([0 bottom]);
0064 xlim([earliesttime latesttime]);
0065 
0066 if exist('labels', 'var')
0067     labels = cellfun(@(a) strrep(a, '_', '\_'), labels, 'un', 0);
0068     set(axh, 'ytick', .5:1:numel(allcst));
0069     set(axh, 'yticklabel', labels);
0070 end
0071 end

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