function [ChunkStack] = genChunksTest(ecgSig, RpeaksVM, SC)

RpeaksChunk = RpeaksVM;
totalBeats = sum(RpeaksChunk);
rind = find(RpeaksChunk == 1);


si = find(rind>500);
ei = find(rind+500<length(ecgSig));
tk = 1;
for ind = si(1):ei(end)
    bv = ecgSig(rind(ind)-500:rind(ind)+500);
    
    beatVec(:,tk) = bv;%resample(bv, 200, length(bv));
    tk = tk+1;
end

% idrand = randperm(size(beatVec,2));
% beatVecr = beatVec(:,idrand);
% 
% if(length(idrand)<SC)
%     for filid = length(idrand)+1:SC
%         tid = randperm(length(idrand))
%         beatVecr(:,filid) = beatVec(:,tid(1));
%     end
% end
beatVecr = beatVec;

ChunkStack = [];

for ind = 1:size(beatVecr,2)-8 
%    idr = randperm(size(beatVecr,2));
    ChunkStack(:,:,ind) = beatVecr(:,ind:ind+7)';
end

end