function allwindows = windowize(data,wsize,winshift)

if nargin == 2
  winshift = 1;
end

[r,c] = size(data);
allwindows = cell(r,c);
for ri = 1:r
  for ci = 1:c
    oneTrial = data{ri,ci};
    nwin = 0;
    for wi = 1:winshift:size(oneTrial,2)-wsize+1
      nwin = nwin + 1;
    end
    for w = 1:nwin
      start = (w-1)*winshift+1;
      windows{w} = oneTrial(:,start:start+wsize-1);
    end
    allwindows{ri,ci} = windows;
  end
end
