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

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


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

beatVecr = beatVec;
ChunkStack = [];
if(size(beatVec,2)<=SC)
    return
%     tid = 1;
%     for fill_id = size(beatVec,2)+1:SC+1
%         beatVecr(:,fill_id) = beatVec(:,tid);
%         tid = tid+1;
%         if(tid > size(beatVec,2))
%             tid = 1;
%         end
%     end
end

for ind = 1:size(beatVec,2)-SC
    ChunkStack(:,:,ind) = beatVecr(:,ind:ind+SC)';
end

% 
% idrand = randperm(size(beatVecr,2));
% beatVecr1 = beatVecr(:,idrand);
% 
% 
% if(size(ChunkStack,3)>30);
%     
%     idr = randperm(size(ChunkStack,3));
%      ChunkStack = ChunkStack(:,:,idr(1:30));
% end
end