function ChunkBeatVecST = genSTchunks(ecgSig, Rpeaks, VM)
RpeaksChunk = Rpeaks.*VM;


rind = find(RpeaksChunk == 1);

diffR = diff(rind);
%id = find(diffR<250)
rind1 = rind;

id1 = find(rind<21);
id2 = find(rind+200>length(ecgSig));
remId = unique([id1; id2]);
rind1(remId) = [];
beatVec = []; 
for ind = 1:length(rind1)  %3:length(ann_res_pruned)-1
    bv = ecgSig(rind1(ind)-20:rind1(ind)+200);
    beatVec(:,ind) = bv;%resample(bv, 200, length(bv));
end

ChunkBeatVecST = median(beatVec,2);
end