function [TSd] = setTSd(y,t0,dt,ch_id,sta,SysTF,scale,dataZero);
%   Usage: [TSd] = setTSd(y,t0,dt,ch_id,SysTF);
%   sets up Structure TSd    (Time series data description)
%    nch        # of channels in TS data array
%    npts      length of TS data array
%    ch_id     channel names for labeling each channel
%    range(nch,2)  [minch0,maxch0]
%    t0        time for first point in data array
%    dt        sampling interval
%    SysTF     System response TF table structure 
%    scale     gain*1000 considwers gain & convert to V
if nargin < 8
    dataZero = '';
end
%ch_id=ch; % remove
[nch,npts] = size(y);
scales = mean(log10(abs(SysTF.TF)),2);
scales = 10.^scales;
for ich=1:nch
 ii=find(isnan(y(ich,:))==0);
 ybar(ich) = mean(y(ich,ii));
 ySD(ich) = std(y(ich,ii));
 if ySD(ich)==0,ySD(ich)=1;end
end
MX = ybar+2*ySD; %dim 12
MN = ybar-2*ySD; %dim 12
range  = [MN',MX',scales]; % dim 12x3
TSd = struct('nch',nch,'npts',npts,'ch_id',ch_id,'sta',sta,'range',range,...
             't0',t0,'dt',dt,'SysTF',SysTF,'scale',scale,'dataZero',dataZero);
return
