function [iband] = setBands(npts,Nbt,logBands,alpha,minBW);
% Usage [iband] = setBands(npts,logBands,alpha,Nbt,minBW);
%   defines logarithmically spaced non-overlapping
%   frequency bands for a time series
%      npts = length of TS
%      Nbt = # of bands (nominal)
%      logBands = 1 for logarithmically spaced bands;
%       if logBands = 0, remaining arguments are not used.
%      alpha = reduction factor for adjacent bands
%      minBW = minimum band width (number of FCs)

n2 = ceil(npts/2);
iband = zeros(2,Nbt);
if logBands
   N = n2*(1-alpha)/(1-alpha^Nbt);
   i2 = n2;
   for ib = 1:Nbt
      iband(2,ib) = i2;
      iband(1,ib) = i2-fix(N)+1;
      i2 = iband(1,ib)-1;
      N = max(N*alpha,minBW);
      if(i2 < minBW)
         iband = iband(:,1:ib);
         break;
      end
   end
else
   nW = floor(n2/Nbt);
   n2 = nW*Nbt+1;
   i2 = n2;
   for ib = 1:Nbt
      iband(2,ib) = i2;
      iband(1,ib) = i2-nW+1;
      i2 = iband(1,ib)-1;
   end
end
