Home > data-analysis > manip > cstream > shuffle_cstream.m

shuffle_cstream

PURPOSE ^

SYNOPSIS ^

function out = shuffle_cstream(cstream)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function out = shuffle_cstream(cstream)
0002 
0003 cat0 = max(cstream(:,2))+1;
0004 cstream(cstream(:,2)==0,2) = cat0;
0005 cev = cstream2cevent(cstream);
0006 log = cev(:,3) == cat0;
0007 events = cev(~log,:);
0008 nonevents = cev(log,:);
0009 
0010 idxevents = randperm(size(events,1));
0011 idxnonevents = randperm(size(nonevents,1));
0012 
0013 newcev = zeros(size(cev,1),3);
0014 newcev(log,:) = nonevents(idxnonevents,:);
0015 newcev(~log,:) = events(idxevents,:);
0016 
0017 durs = newcev(:,2) - newcev(:,1);
0018 newcev(1,1) = cstream(1,1);
0019 newcev(:,2) = newcev(1,1) + cumsum(durs);
0020 newcev(2:end,1) = newcev(1:end-1,2);
0021 newcev(:,2) = newcev(:,1) + durs;
0022 newcev = newcev(~log,:);
0023 out = cevent2cstreamtb(newcev, cstream);
0024 
0025 end

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