function mcs(ii_load);
%
% Graphical User Interface for running MCS signal processing tool.
%
% Evan Westwood
% Applied Research Laboratories
% The University of Texas at Austin
%
% Set Bdef.size (after executing adi_global) to control size of bathymetry plot;
% Edit and run adi_global_set to customize plot sizes, contours, fonts, etc.
%
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
mcs_global
view_global
format compact
if nargin<1, ii_load=1; end
%
% Close any other MCS windows open:
figs=get(0,'Children'); names=get(figs,'Name'); ii=find(strcmp(names,'MCS')); close(figs(ii));
%
if isempty(V), view_global_set; end
format compact
MCS=[]; FFT=[];
%
bcol=[0 0 1]; fcol=[1 1 1];
box_sp=[.03 .03]; lab_h=0; lab_v=0.2;
%
mcs_init
[file_sort,nfile]=dir_sort('*_mcs.mat');
if nfile>0, 
    mcs_file=file_sort{nfile}; 
else, 
    mcs_file=[]; 
end
%
if ~isempty(mcs_file) & exist(mcs_file,'file')==2,
	MCS_cur=MCS; eval(['load ',mcs_file]);		% Save current MCS and load latest _mcs.mat file;
% Set any new fields that old MCS might not have:
    TAPE_cur=structure_copy2(MCS_cur.TAPE,MCS.TAPE,{});
    MCS_cur=structure_copy2(MCS_cur,MCS,{'swami_cal_opts','BOX','TAPE'});
% Replace MCS by MCS_cur:
	MCS=MCS_cur; MCS.TAPE=TAPE_cur; clear MCS_cur;
    lmc=length(MCS.mc_parms); if lmc<15, MCS.mc_parms=[MCS.mc_parms, zeros(1,15-lmc)]; end
end
MCS.env_options={'No Enveloping';'Env ==> Leave Complex';'Env ==> Convert to dB';'Env ==> Convert to Linear'};
%
Mdef.size=[.2,.2];
Mdef.fname='Arial'; Mdef.ptsize=14; Mdef.iibold=1;
%
figure; set(gcf,'Name','MCS');
axpos=[.5 .5 Mdef.size(1)+2 Mdef.size(2)+1.75];
set(gcf,'Units','Inches','Position',axpos);
MBOX.figno=gcf; h0=gcf;
%
MBOX.progs={'LGRAM';'SGRAM';'Matched X-Spectra';'Measured TL/SL/AN';'MC'; ...
	'CTS-to-FFT';'Make FFTs';'CGRAM';'FFT-to-CTS';'RGRAM CTS'; ...
	'Make Replicas';'RGRAM FFT';'Combine CTS Files';'View HDF File';'TS View';'n/a';'n/a';'n/a'};       % ONLY ADD TO THIS - DO NOT CHANGE ORDER
%MBOX.prog_order=[1 2 12 10 8 4 5 6 9 7 11 13 14 3];
MBOX.prog_order=[1 2 12 10 8 4 5 6 9 7 13 14 15];
MBOX.nprog=length(MBOX.progs);
MBOX.nboxtot=0;
MBOX.nbox_prog=zeros(1,MBOX.nprog);
MBOX.prog=NaN*ones(MBOX.nprog,30);
MBOX.handle=zeros(2,150);
%
hoff0=0; voff0=0;
% 
box_h=[2.1 1.7 1.3 1.3 1.4]; 
box_v=[.27 .27 .27 .27 .27 .27 .27 .27 .27];
%
fig_width=max(hoff0+sum(box_h+box_sp(1)),2.25);
MCS.box_size=[fig_width, voff0+sum(box_v+lab_v+box_sp(2))];
MBOX.hoff0=hoff0; MBOX.voff0=voff0; MBOX.box_h=box_h; MBOX.box_v=box_v;
%
set(gcf,'Position',[.75 .75 MCS.box_size]);
%
POS.out_root=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,1);
POS.gui_save=[POS.out_root(1), POS.out_root(2)+.28, .6, .2];
POS.load=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,2);
POS.geom_file=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,3); 
POS.fft_root=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,4); 
POS.fft_root2=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,3); 
POS.make_fs=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,8); %tms
POS.make_Jday=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,9); 
POS.Jday=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,7); 
POS.tape_upd=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,9); 
POS.make_mult=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,3);
POS.finit=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,9); 
%%box_v=[.34 .27 .27  0 .23 .23 .23 .4 .23];
POS.fft_parm1x=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,5); 
POS.fft_parm1=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,6); 
POS.fft_parm2=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,7); 
POS.fft_Tlims=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,[7]); 
POS.ii_cal=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,5) + [0,.265,0,0]'; 
POS.cal_file=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,5); 
POS.spec_all=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,8);
POS.isatape=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,3) + [0,.265,0,0]'; 
%
%%box_v=[.27 .27 .27 .27 .27 .27 .27 .27];
POS.rep_root=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,3); 
POS.rep_parm1=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,2); 
POS.rep_parm2=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,1); 
POS.rep_iiph=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,2); 
POS.rep_iiseq=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,1);
%
POS.make_types=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,4);
POS.hlab_fs=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,3);
POS.swami_cal=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,3);
% POS.rsp_chan1=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,6);

POS.ii_spike=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,4);
POS.spike_dB=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,3);
%POS.make_dvla=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,5);
%POS.make_difar=POS.make_dvla + [0,.27,0,0]';
%POS.make_difar2=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,6);
%POS.make_vlad=POS.make_difar2 + [0,.27,0,0]';
%POS.make_ref=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,7);
%%POS.make_types=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,5); 
%
%%box_v=[.27 .27 .27 .27 .40 .27 .27 .23];
POS.rm_parm2=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,1); 
POS.rm_parm1=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,2); 
POS.sg_parm2=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,2); 
POS.iienv=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,2); 
POS.zpfac=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,1); 
POS.rvec_bw=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,4); 
POS.tau_lim=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,4); 
POS.freq_lim=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,5); 
POS.freq_bands=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,1); 
POS.sg_norm=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,5); 
POS.sg_hann=POS.sg_norm + [0,.265,0,0]';
POS.AN_freq=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,[3:4]); 
POS.SL_freq=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,[3:4]); 
POS.TL_freq=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,[3:4]); 
POS.ii_AN=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,5); 
POS.ii_TL=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,5); 
POS.ii_SL=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,5); 
POS.TLm_root=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,1); 
POS.TLm_run=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,2); 
POS.AN_root=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,1);
% Adjust so TLm/SL Files and AN Files have more space:
xx=1.25; POS.TLm_root=POS.TLm_root + [-xx,0,xx/2,0]'; %%POS.TLm_run=POS.TLm_run  + [-xx,0,xx/2,0]';
POS.AN_root=POS.AN_root + [-xx/2,0,xx/2,0]';
POS.AN_run=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,2); 
POS.make_cal=POS.AN_run + [0,.265,0,0]';
POS.SL_use=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,4); 
POS.iiAN_corr=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,4); 
POS.SL_root=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,3); 
POS.SL=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,2); 
POS.ii_sc2=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,6) + [0,.265,0,0]';
POS.phones=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,6); 
POS.Tlims=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,7); 
POS.iihr=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,8); 
POS.ii_phavg=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,6) + [0,.265,0,0]'; 
POS.mc_fix=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,4); 
POS.mc_mcc=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,4); 
POS.mc_dr=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,5); 
POS.mc_src_wf=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,3);
POS.wf_set=[POS.mc_src_wf(1), POS.mc_src_wf(2)+.28, .6, .2];
POS.mc_pri=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,3);
POS.mc_T_rep_int=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,2);
POS.mc_phis=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,2);
POS.mc_cts2fft=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,2);
%POS.mc_filt=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,1); 
POS.cts_p1=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,2); 
POS.cts_p2=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,1); 
%%POS.SL_jump=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,3); 
%%POS.ii_jump=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,3); 
POS.tspec=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,8); 
%
POS.th_lim=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,1); 
POS.phi_lim=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,2); 
POS.iisin=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,3); 
%%box_v=[.27 .27 .27 .27 .27 .27 .27 .27];
POS.clim=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,8);
POS.psize=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,9);
POS.xc_aper=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,1); 
POS.bf_aper=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,2); 
POS.fac_var=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,3); 
%
POS.bf_type=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,8); 
POS.alpha=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,7); 
POS.wng=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,6);
POS.D_dmr=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,5);
%
%%box_v=[.3 .3 .3 .3 .27 .27];
POS.help=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,1); 
POS.run=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,1) + [0,.265,0,0]';
POS.run2=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,3);
POS.run3=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,3) + [0,.265,0,0]';
POS.run4=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,1);
POS.run5=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,4);
POS.iiprog=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,2);
POS.cts_details=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,8) + [0,.265,0,0]';
POS.comb_off0=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,9);
%tms
% POS.hdf_root=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,8);
POS.hdf_root=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,7);
%POS.hdf_sets=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,[3:7]);
POS.hdf_sets=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,[3:6]);
POS.hdf_rank=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,7);
POS.hdf_dim_names=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,[4:6]);
POS.hdf_dims=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,[4:6]);
POS.hdf_dim_lims=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,[4:6]);
POS.newfig=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,7);
POS.iidata=POS.newfig + [0;.265;0;0];
POS.f_bb=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,4);
%%%
POS.file_times=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,9); 
%
tag=[]; nprog=MBOX.nprog;
%
iipr1=[1:nprog];
iipr2=[1:10,12,15];
iipr_fft=[1:5,8,9,10,11,12];
MCS.fft_prog=iipr_fft;
%
tip='Program'; fmt='%s'; vbl='MBOX.progs(MBOX.prog_order)';
val=find(MBOX.prog_order==MCS.iiprog); if isempty(val), val=1; end
mcs_gui_box(iipr1,POS.iiprog,fmt,vbl,'popupmenu',tag,tip,val,tip,bcol,fcol);
%
tip='RUN MCS';
mcs_gui_box([3],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
tip='Leave Complex [==>dB]'; vbl='MCS.lg_parms(1)';
mcs_gui_box([1],POS.iienv,[],vbl,'checkbox',tag,tip,MCS.lg_parms(1),[],bcol,fcol);
tip='RUN LGRAM';
mcs_gui_box([1],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
tip='RUN SGRAM';
mcs_gui_box([2],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
tip='RUN RGRAM CTS';
mcs_gui_box([10],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
tip='RUN RGRAM FFT';
mcs_gui_box([12],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
tip='RGRAM Align';
mcs_gui_box([10,12],POS.run2,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
tip='RGRAM Map';
mcs_gui_box([10,12],POS.run3,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
tip='RGRAM & Align';
mcs_gui_box([10],POS.run4,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
tip='RGal + Phase Map';
mcs_gui_box([10],POS.run5,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
tip='MAKE REPLICAS';
mcs_gui_box([11],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
tip='RUN CGRAM';
mcs_gui_box([8],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
tip='RUN TLm_calc';
mcs_gui_box([4],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
tip='RUN MC';
mcs_gui_box([5],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
tip='RUN DTAU';
mcs_gui_box([5],POS.run-[0,.265,0,0]',[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
tip='RUN CTS to FFT';
mcs_gui_box([6],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
tip='Plot CTS Time Series';
mcs_gui_box([6],POS.run-[0,.265,0,0]',[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
tip='RUN FFT to CTS';
mcs_gui_box([9],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
tip='RUN fft_make';
mcs_gui_box([7],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
tip='Combine CTS Files';
mcs_gui_box([13],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%%%
tip='re-init';  
mcs_gui_box(iipr1,POS.finit,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
tip='FFT Files'; fmt='%s'; vbl='''dummy''';
mcs_gui_box(iipr_fft,POS.fft_root,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
%
%tip='FFT File 2'; fmt='%s'; vbl='''dummy''';
%mcs_gui_box([8],POS.fft_root2,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
%
tip='FFT f1,f2,iihann'; fmt='%1.0f,%1.0f,%1i'; vbl='MCS.fft_parm([1:2,8])';
mcs_gui_box(iipr_fft,POS.fft_parm1,fmt,vbl,'text',tag,tip,1,tip,bcol,fcol);
%
tip='FFT df,Tw,Tstep'; fmt='%3.3f,%1.1f'; vbl='MCS.fft_parm(3:4)';
mcs_gui_box(iipr_fft,POS.fft_parm1x,fmt,vbl,'text',tag,tip,1,tip,bcol,fcol);
%
tip='nrec,nseq,%step'; fmt='%1i,%1i,%1i,%1i'; vbl='MCS.fft_parm(5:7)';
mcs_gui_box(iipr_fft,POS.fft_parm2,fmt,vbl,'text',tag,tip,1,tip,bcol,fcol);
%
tip='Day,Hour'; fmt='%3.3i,%2.2f\n'; vbl='MCS.fft_Tlims';
mcs_gui_box(iipr2,POS.fft_Tlims,fmt,vbl,'text',tag,tip,1,tip,bcol,fcol);
%
if ~isfield(MCS.TAPE,'ii_cal'), MCS.TAPE.ii_cal=0; end; 
tip='Use Calibration File'; vbl='MCS.TAPE.ii_cal';
mcs_gui_box([6 7],POS.ii_cal,[],vbl,'checkbox',tag,tip,MCS.TAPE.ii_cal,[],bcol,fcol);
tip='Cal Files'; fmt='%s'; vbl='''dummy''';
mcs_gui_box([6 7],POS.cal_file,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
%
tip='CTS Files'; fmt='%s'; vbl='''dummy''';
mcs_gui_box(6,POS.fft_root,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
%
tip='Use Header from CTS File'; fmt='%s'; vbl='''dummy''';
mcs_gui_box(9,POS.rep_root,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
tip='Baseband Freq (0=def)'; fmt='%1.4f'; vbl='MCS.f_bb';
mcs_gui_box(9,POS.f_bb,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='CTS nrec,fs,f_bb'; fmt='%1i,%1.1f,%1.1f\n'; vbl='[1 60 250]';
mcs_gui_box(6,POS.fft_parm2,fmt,vbl,'text',tag,tip,1,tip,bcol,fcol);
%
tip='Specify All';
mcs_gui_box(iipr2,POS.spec_all,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
tip='Array Geometry Files'; fmt='%s'; vbl='''dummy''';
mcs_gui_box([3,4],POS.geom_file,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
%
tip='Output File Root'; fmt='%s'; vbl='MCS.out_root';
mcs_gui_box(iipr1,POS.out_root,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
tip='Save MCS';
mcs_gui_box(iipr1,POS.gui_save,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
tip='Load _mcs root'; fmt='%s'; vbl='''dummy''';
mcs_gui_box(iipr1,POS.load,fmt,vbl,'popupmenu',tag,tip,1,tip,[.8,0,0],[1,1,1]);
%
%%%
tip='BW: nbin/-Hz'; fmt='%1.1f'; vbl='MCS.rvec_bw'; 
mcs_gui_box([3],POS.rvec_bw,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Frequencies'; fmt='%1.0f,%1.0f\n'; vbl='MCS.freq_lim'''; iipr_f=iipr2(find(iipr2~=4));iipr_f=iipr_f(find(iipr_f~=15));
mcs_gui_box([iipr_f],POS.freq_lim,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
tip='Frequency Band(s)'; fmt='%1.0f,%1.0f\n'; vbl='MCS.freq_bands''';
mcs_gui_box(13,POS.freq_bands,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Time Specification'; fmt='%s'; vbl='MCS.tspec_opt';
mcs_gui_box(iipr2,POS.tspec,fmt,vbl,'popupmenu',tag,tip,MCS.tspec,tip,bcol,fcol);
%
tip='Seqs or Times'; fmt='%1.0f,%1.0f'; vbl='MCS.Tlims'; 
mcs_gui_box(iipr2,POS.Tlims,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Enveloping'; fmt='%s'; vbl='MCS.env_options'; val=find(MCS.sg_parms(1)==MCS.iienv_codes);
mcs_gui_box([2,8,10,12],POS.iienv,fmt,vbl,'popupmenu',tag,tip,val,tip,bcol,fcol);
tip='Zero Pad by 2^N'; fmt='%1i'; vbl='MCS.sg_parms(2)';
mcs_gui_box([2,8,10,12],POS.zpfac,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%tip='iienv,zpfac'; fmt='%1i,%1i'; vbl='MCS.sg_parms(1:2)';
%mcs_gui_box([2,8,10,12],POS.iienv,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Hann in f-domain'; vbl='MCS.sg_parms(3)';
mcs_gui_box([2,8,10,12],POS.sg_hann,[],vbl,'checkbox',tag,tip,MCS.sg_parms(3),[],bcol,fcol);
tip='Range Normalize'; vbl='MCS.sg_parms(4)';
mcs_gui_box([2,10,12],POS.sg_norm,[],vbl,'checkbox',tag,tip,MCS.sg_parms(4),[],bcol,fcol);
tip='# Seq to Avg (def=1)'; fmt='%1i'; vbl='MCS.sg_parms(5)';
mcs_gui_box([2,8],POS.sg_parm2,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
if ~any(MCS.sg_parms(6)==[0 1]), MCS.sg_parms(6)=1; end
tip='Phase Transform'; vbl='MCS.sg_parms(6)';
mcs_gui_box([8],POS.sg_norm,[],vbl,'checkbox',tag,tip,MCS.sg_parms(6),[],bcol,fcol);
%
tip='Rep Corr FFT'; fmt='%s'; vbl='''dummy''';
mcs_gui_box([12],POS.rep_root,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
tip='REP f1,f2,Tw'; fmt='%1.0f,%1.0f,%1.1f'; vbl='MCS.rep_parm([1,2,4])';
mcs_gui_box([12],POS.rep_parm1,fmt,vbl,'text',tag,tip,1,tip,bcol,fcol);
tip='REP nrec,nseq'; fmt='%1i,%1i'; vbl='MCS.rep_parm(6:7)';
mcs_gui_box([12],POS.rep_parm2,fmt,vbl,'text',tag,tip,1,tip,bcol,fcol);
tip='Rep Corr iiph'; fmt='%1i '; vbl='MCS.rep_iiph'; 
mcs_gui_box([12],POS.rep_iiph,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
tip='Rep Corr iiseq'; fmt='%1i '; vbl='MCS.rep_iiseq'; 
mcs_gui_box([12],POS.rep_iiseq,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Tlab=HOD(seq)'; vbl='MCS.iihr';
mcs_gui_box([1:2,10,12],POS.iihr,[],vbl,'checkbox',tag,tip,MCS.iihr,[],bcol,fcol);
%
tip='Phone Numbers'; fmt='%1i '; vbl='MCS.phones'; 
mcs_gui_box([1:7,9,10,12,15],POS.phones,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='XC Pairs [nx2]'; fmt='%1i,%1i'; vbl='MCS.ph_pairs'; 
mcs_gui_box([8],POS.phones,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='[taumin,taumax]'; fmt='%2.2f,%2.2f'; vbl='MCS.tau_lim'; 
mcs_gui_box([2,10,12],POS.tau_lim,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
%%%
tip='Vertical Angles'; fmt='%1.0f %1.0f %1i'; vbl='MCS.th_lim'; 
mcs_gui_box([3],POS.th_lim,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Azimuthal Angles'; fmt='%1.0f,%1.0f,%1i'; vbl='MCS.phi_lim'; 
mcs_gui_box([3],POS.phi_lim,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Delay Time Limits'; fmt='%2.2f,%2.2f'; vbl='MCS.ctau_lim'; 
mcs_gui_box([8],POS.tau_lim,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
%%%
tip='Vertical Angles'; fmt='%1.0f %1.0f %1i'; vbl='MCS.th_lim'; 
mcs_gui_box([3],POS.th_lim,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Azimuthal Angles'; fmt='%1.0f,%1.0f,%1i'; vbl='MCS.phi_lim'; 
mcs_gui_box([3],POS.phi_lim,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Sin space [deg]'; vbl='MCS.iisin';
mcs_gui_box([3],POS.iisin,[],vbl,'checkbox',tag,tip,MCS.iisin,[],bcol,fcol);
%
tip='Cmin,Cmax'; fmt='%1.0f,%1.0f'; vbl='MCS.clim';
mcs_gui_box([1,2,4,10,12,14],POS.clim,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='XCmin,XCmax'; fmt='%1.2f,%1.2f'; vbl='MCS.xclim';
mcs_gui_box([8],POS.clim,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Plot Size [w,h]'; fmt='%1.1f,%1.1f'; vbl='MCS.psize';
mcs_gui_box([1,2,4,10,12,14,15],POS.psize,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='SL (-1=sim)'; fmt='%1.0f'; vbl='MCS.SL';
mcs_gui_box([4],POS.SL,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
tip='Correct for AN'; vbl='MCS.iiAN_corr';
mcs_gui_box([4],POS.iiAN_corr,[],vbl,'checkbox',tag,tip,MCS.iiAN_corr,[],bcol,fcol);
tip='Use SL File'; vbl='MCS.SL_use';
mcs_gui_box([4],POS.SL_use,[],vbl,'checkbox',tag,tip,MCS.SL_use,[],bcol,fcol);
tip='SL Files'; fmt='%s'; vbl='''dummy''';
mcs_gui_box([4],POS.SL_root,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
tip='Dropout dB,T_filt (min)'; fmt='%1.0f,%1.0f'; vbl='MCS.SL_parms';
mcs_gui_box([4],POS.SL_use,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Compute TL'; vbl='MCS.ii_TL';
mcs_gui_box([4],POS.ii_TL,[],vbl,'checkbox',tag,tip,MCS.ii_TL,[],bcol,fcol);
tip='Compute SL'; vbl='MCS.ii_SL';
mcs_gui_box([4],POS.ii_SL,[],vbl,'checkbox',tag,tip,MCS.ii_SL,[],bcol,fcol);
tip='Compute AN'; vbl='MCS.ii_AN';
mcs_gui_box([4],POS.ii_AN,[],vbl,'checkbox',tag,tip,MCS.ii_AN,[],bcol,fcol);
tip='TL Frequency Band(s)'; fmt='%1.1f,%1.1f\n'; vbl='MCS.TL_freq''';
mcs_gui_box([4],POS.TL_freq,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
tip='SL Frequency Band(s)'; fmt='%1.1f,%1.1f\n'; vbl='MCS.SL_freq''';
mcs_gui_box([4],POS.SL_freq,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
tip='AN Frequency Band(s)'; fmt='%1.1f,%1.1f\n'; vbl='MCS.AN_freq''';
mcs_gui_box([4],POS.AN_freq,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
tip='TLm/SL Files'; fmt='%s'; vbl='''dummy''';
mcs_gui_box([4],POS.TLm_root,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
tip='AN Files'; fmt='%s'; vbl='''dummy''';
mcs_gui_box([4],POS.AN_root,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
tip='Make Cal File';
mcs_gui_box([4],POS.make_cal,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
tip='Plot Measured TL/SL';
mcs_gui_box([4],POS.TLm_run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
tip='Plot Measured AN';
mcs_gui_box([4],POS.AN_run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
tip='Enter Phone Depths'; vbl='MCS.ii_sc2';
mcs_gui_box([4],POS.ii_sc2,[],vbl,'checkbox',tag,tip,MCS.ii_AN,[],bcol,fcol);
%
tip='Avg over phone'; vbl='MCS.ii_phavg';
mcs_gui_box([4],POS.ii_phavg,[],vbl,'checkbox',tag,tip,MCS.ii_phavg,[],bcol,fcol);
%
%%tip='Fix SL jumps'; vbl='MCS.ii_jump';
%%mcs_gui_box([4],POS.ii_jump,[],vbl,'checkbox',tag,tip,MCS.ii_jump,[],bcol,fcol);
%
%%tip='SL Jump Tolerance'; fmt='%1.0f'; vbl='MCS.SL_jump';
%%mcs_gui_box([4],POS.SL_jump,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%%% MC:
tip='nrec_avg (0=fix,1=ind)'; fmt='%1i'; vbl='MCS.mc_parms(1)';
mcs_gui_box([5],POS.mc_fix,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='RUN CTS2FFT'; vbl='MCS.mc_cts2fft';
mcs_gui_box([5,13],POS.mc_cts2fft,[],vbl,'checkbox',tag,tip,MCS.mc_cts2fft,[],bcol,fcol);
%
MCS.mc_mcc=0;
tip='FD [TD]'; vbl='MCS.mc_mcc';
mcs_gui_box([5],POS.mc_mcc,[],vbl,'checkbox',tag,tip,MCS.mc_mcc,[],bcol,fcol);
tip='Tfilt,drmax,iial'; fmt='%1.1f,%1.1f,%1i'; vbl='MCS.mc_parms(4:6)';
mcs_gui_box([5],POS.mc_dr,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
%tip='Freq lines'; fmt='%1.0f'; vbl='MCS.mc_flines';
%mcs_gui_box([5],POS.mc_flines,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
tip='SRC CTS File'; fmt='%s'; vbl='''dummy''';
mcs_gui_box([5,10,11,12],POS.mc_src_wf,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
tip='Set WF Dir';
mcs_gui_box([5,10,11,12],POS.wf_set,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
tip='PRI'; fmt='%2.2f'; vbl='MCS.PRI';
mcs_gui_box([5,10,11,12],POS.mc_pri,fmt,vbl,'text',tag,tip,1,tip,bcol,fcol);
tip='T_rep_int(0=PRI)'; fmt='%2.2f'; if length(MCS.sg_parms)<7, MCS.sg_parms(7)=0; end; vbl='MCS.sg_parms(7)';
mcs_gui_box([10],POS.mc_T_rep_int,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%tip='SRC CTS File'; fmt='%s'; vbl='GUI.cts_files';
%dop_gui_box([13,17],POS.cts_files,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
%
%%% fft_cts:
tip='T_fft,T_step'; fmt='%1.0f,%1.0f'; vbl='MCS.cts_parms(1:2)';
mcs_gui_box([5,6,7,13],POS.cts_p1,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='zpfac,ii_hann'; fmt='%1i,%1i'; vbl='MCS.cts_parms(3:4)';
mcs_gui_box([5,6,7,13],POS.cts_p2,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
%%% fft_make:
tip='Data Files'; fmt='%s'; vbl='''dummy''';
mcs_gui_box([7,15],POS.fft_root,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
tip='Tape Address'; fmt='%s'; vbl='MCS.tape_files';
mcs_gui_box([7,15],POS.fft_root,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
%
tip='Proc Mult Files'; vbl='MCS.make_parms(7)';
mcs_gui_box([7,15],POS.make_mult,[],vbl,'checkbox',tag,tip,MCS.make_parms(7),[],bcol,fcol);
%
tip='Last Data File'; fmt='%s'; vbl='''dummy''';
mcs_gui_box([7,15],POS.fft_root2,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
%
tip='Type of Data'; fmt='%s'; vbl='MCS.make_types';
mcs_gui_box([7,15],POS.make_types,fmt,vbl,'popupmenu',tag,tip,MCS.make_parms(1),tip,bcol,fcol);
tip='Set Files by Times';
mcs_gui_box([7,15],POS.file_times,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
% tip='Array to Process'; fmt='%s'; vbl='MCS.hlab_fs';
% mcs_gui_box([7],POS.hlab_fs,fmt,vbl,'popupmenu',tag,tip,MCS.rsp_parms(2),tip,bcol,fcol);
% tip='1st Channel #'; fmt='%1i'; vbl='MCS.rsp_parms(2)';
% mcs_gui_box([7],POS.rsp_chan1,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
tip='HLA-B fs'; fmt='%s'; vbl='MCS.hla_fs_opts';
mcs_gui_box([7,15],POS.hlab_fs,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
%
tip='Remove Spikes'; vbl='MCS.spike_parms(1)';
mcs_gui_box([7],POS.ii_spike,[],vbl,'checkbox',tag,tip,MCS.spike_parms(1),[],bcol,fcol);
tip='Spike Threshold (dB)'; fmt='%1i'; vbl='MCS.spike_parms(2)';
mcs_gui_box([7],POS.spike_dB,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='fs, calfac'; fmt='%2.2f,%2.2f'; vbl='MCS.make_parms(2:3)';
mcs_gui_box([7,15],POS.make_fs,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Init Jday,Jhour'; fmt='%3i,%2.2f'; vbl='MCS.make_parms(4:5)';
mcs_gui_box([7,15],POS.make_Jday,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
if length(MCS.make_parms)<8, MCS.make_parms(8:15)=0; end
tip='Julian Day'; fmt='%3i'; vbl='MCS.make_parms(8)';
mcs_gui_box([7,15],POS.Jday,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
tip='Read Tape Jday,Jhour';
mcs_gui_box([7,15],POS.tape_upd,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
tip='SWAMI calfac'; fmt='%s'; vbl='MCS.swami_cal_opts';
mcs_gui_box([7],POS.swami_cal,fmt,vbl,'popupmenu',tag,tip,MCS.swami_cal_ii,tip,bcol,fcol);
%
%%% rep_fft_make:
tip='Freq Shifts'; fmt='%2.2f,%2.2f,%1i'; vbl='MCS.rm_Df'; 
mcs_gui_box([11],POS.Tlims,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Freq Chirps'; fmt='%1.1f,%1.1f,%1i'; vbl='MCS.v_10km'; 
mcs_gui_box([11],POS.phones,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Nup,Ntap,Tstep'; fmt='%1i,%1i,%2.1f'; vbl='MCS.rm_parms([1:2,5])';
mcs_gui_box([11],POS.rm_parm1,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Tfft,fs,iiauto'; fmt='%1.1f,%1.1f,%1i'; vbl='MCS.rm_parms([3,4,6])';
mcs_gui_box([11],POS.rm_parm2,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%%%
tip='Min,Max XC aper'; fmt='%1.1f,%1.0f'; vbl='MCS.xc_aper'; 
mcs_gui_box([3],POS.xc_aper,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='Min,Max BF aper'; fmt='%1.1f,%1.0f'; vbl='MCS.bf_aper'; 
mcs_gui_box([3],POS.bf_aper,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='f-dep nphi fac (1-3)'; fmt='%1.1f'; vbl='MCS.fac_var'; 
mcs_gui_box([3],POS.fac_var,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%%%
% Beamforming and ABF Parms:
tip='Beamformer'; fmt='%s'; vbl='MCS.bf_type';
mcs_gui_box([3],POS.bf_type,fmt,vbl,'popupmenu',tag,tip,MCS.iibf_type,tip,bcol,fcol);
%
tip='Exp:+a/-T10dB'; fmt='%2.2f'; vbl='MCS.abf_parm(6)';
mcs_gui_box([3],POS.alpha,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='WN Gain(-3,-6)'; fmt='%1i'; vbl='MCS.abf_parm(3)';
mcs_gui_box([3],POS.wng,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
tip='DMR: D'; fmt='%1i'; vbl='MCS.abf_parm(2)';
mcs_gui_box([3],POS.D_dmr,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
%
% CTS Combine:
tip='# CTS Files to Combine'; fmt='%i'; vbl='MCS.comb_parms(1)'; 
mcs_gui_box([13],POS.fft_root,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
tip='Print CTS Details';
mcs_gui_box([13],POS.cts_details,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
tip='Set All to Zero';
mcs_gui_box([13],POS.comb_off0,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
for jcomb=1:MCS.comb_parms(2),
    pos=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,2,9-jcomb);
    tip=sprintf(['CTS File ',int2str(jcomb)]); fmt='%s'; vbl='''dummy''';
    mcs_gui_box([13],pos,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
    pos=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,9-jcomb);
    tip=sprintf(['CTS Level ',int2str(jcomb)]); fmt='%1.1f'; vbl='MCS.comb_levels(1,1)';
    mcs_gui_box([13],pos,fmt,vbl,'text',tag,tip,1,tip,bcol,fcol);
    pos=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,9-jcomb);
    tip=sprintf(['CTS New Level ',int2str(jcomb)]); fmt='%1.1f'; vbl='MCS.comb_levels(2,1)';
    mcs_gui_box([13],pos,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
    pos=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,9-jcomb);
    tip=sprintf(['CTS Time Offset ',int2str(jcomb)]); fmt='%1.1f'; vbl='MCS.comb_offsets(1)';
    mcs_gui_box([13],pos,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
end
%
% View HDF File:
tip='HDF File'; fmt='%s'; vbl='MCS.hdf_files';
mcs_gui_box([14],POS.hdf_root,fmt,vbl,'popupmenu',tag,tip,1,tip,bcol,fcol);
tip='HDF Set Names'; fmt='%s'; vbl='MCS.hdf_sets';
mcs_gui_box([14],POS.hdf_sets,fmt,vbl,'listbox',tag,tip,1,tip,bcol,fcol);
tip='HDF Set Rank'; fmt='%1i'; vbl='MCS.hdf_rank';
mcs_gui_box([14],POS.hdf_rank,fmt,vbl,'text',tag,tip,1,tip,bcol,fcol);
tip='Set Dim Names'; fmt='%s'; vbl='MCS.hdf_dim_names';
mcs_gui_box([14],POS.hdf_dim_names,fmt,vbl,'text',tag,tip,1,tip,bcol,fcol);
tip='Dims [min,max]'; fmt='%1i '; vbl='MCS.hdf_dims';
mcs_gui_box([14],POS.hdf_dims,fmt,vbl,'text',tag,tip,1,tip,bcol,fcol);
tip='Dim Limits'; fmt='%s'; vbl='{'' '','' ''}'; 
mcs_gui_box([14],POS.hdf_dim_lims,fmt,vbl,'edit',tag,tip,1,tip,bcol,fcol);
tip='Create New Fig'; vbl='MCS.v_opts(1)';
mcs_gui_box([14,15],POS.newfig,[],vbl,'checkbox',tag,tip,MCS.v_opts(1),[],bcol,fcol);
tip='Copy Data to Mdat.xx'; vbl='MCS.v_opts(2)';
mcs_gui_box([6,14,15],POS.iidata,[],vbl,'checkbox',tag,tip,MCS.v_opts(2),[],bcol,fcol);
tip='View HDF Set';
mcs_gui_box([14],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);
%
%tms
POS.use_fp=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,7); 
tip='Use Fast Positioning'; vbl='MCS.TAPE.use_fp';
MCS.TAPE.use_fp=1;
mcs_gui_box([7,15],POS.use_fp,[],vbl,'checkbox',tag,tip,MCS.TAPE.use_fp,[],bcol,fcol);
tip='Input From Tape'; vbl='MCS.TAPE.isatape';
if isfield(MCS.TAPE,'isatape'), MCS.TAPE.isatape=0; end
mcs_gui_box([7,15],POS.isatape,[],vbl,'checkbox',tag,tip,MCS.TAPE.isatape,[],bcol,fcol);
%tms
POS.dir=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,8);
posx=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,1,8)+[0,.29,0,0]'; % move up to label
POS.browsein = posx .* [1 1 .2 .7]';
POS.prev_dir = posx + [.8*posx(4) 0 .2*posx(4) 0]';
tip='Input Directory';fmt='%s'; vbl='MCS.dir';
mcs_gui_box([1:nprog],POS.dir,fmt,vbl,'edit',tag,tip,val,tip,bcol,fcol);
tip='Find';
mcs_gui_box([1:nprog],POS.browsein,[],tip,'pushbutton',tag,tip,val,[],bcol,fcol);
%tip='Prev';
%mcs_gui_box([1:nprog],POS.prev_dir,[],tip,'pushbutton',tag,tip,val,[],bcol,fcol);

POS.hlab_endian=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,3,4); 
tip='HLAB Endian'; fmt='%s'; vbl='MCS.TAPE.hlab_endian';
mcs_gui_box([7,15],POS.hlab_endian,fmt,vbl,'popupmenu',tag,tip,MCS.TAPE.iihlab_endian,tip,bcol,fcol);

%tms
POS.file_header_bytes=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,9); 
tip='File Header,Footer Bytes'; fmt='%5i'; vbl='[MCS.TAPE.file_header_bytes;MCS.TAPE.file_footer_bytes]';
mcs_gui_box([7,15],POS.file_header_bytes,fmt,vbl,'edit',tag,tip,[MCS.TAPE.file_header_bytes;MCS.TAPE.file_footer_bytes],tip,bcol,fcol);

POS.header_bytes=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,8); 
tip='Record Header,Footer Bytes'; fmt='%5i'; vbl='[MCS.TAPE.record_header_bytes;MCS.TAPE.record_footer_bytes]';
mcs_gui_box([7,15],POS.header_bytes,fmt,vbl,'edit',tag,tip,[MCS.TAPE.record_header_bytes;MCS.TAPE.record_footer_bytes],tip,bcol,fcol);

POS.data_formats=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,7); 
tip='Data Word Format'; fmt='%s'; vbl='MCS.TAPE.data_formats';
mcs_gui_box([7,15],POS.data_formats,fmt,vbl,'popupmenu',tag,tip,MCS.TAPE.iidata_formats,tip,bcol,fcol);

POS.nchan=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,6); 
tip='Number of Channels'; fmt='%1i'; vbl='MCS.TAPE.nchan';
mcs_gui_box([7,15],POS.nchan,fmt,vbl,'edit',tag,tip,val,tip,bcol,fcol);

POS.nsamp=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,5); 
tip='Samples per Channel'; fmt='%1i'; vbl='MCS.TAPE.nsamp';
mcs_gui_box([7,15],POS.nsamp,fmt,vbl,'edit',tag,tip,MCS.TAPE.nsamp,tip,bcol,fcol);

POS.byteswap=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,4); 
tip='Byte Swap'; fmt='%s'; vbl='MCS.TAPE.byteswap_yn';
mcs_gui_box([7,15],POS.byteswap,fmt,vbl,'popupmenu',tag,tip,MCS.TAPE.iibyteswap,tip,bcol,fcol);

POS.batch=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,5,1); 
tip='Batch Mode'; vbl='MCS.batch';
MCS.batch=0;
mcs_gui_box([7],POS.batch,[],vbl,'checkbox',tag,tip,MCS.batch,[],bcol,fcol);

POS.ts_view_sample_ith=gui_box_pos(hoff0,voff0,box_h,box_v,box_sp,lab_h,lab_v,4,7); 
tip='Sample ith'; fmt='%3i'; vbl='MCS.ts_view_sample_ith';
MCS.ts_view_sample_ith=1;
mcs_gui_box([15],POS.ts_view_sample_ith,fmt,vbl,'edit',tag,tip,MCS.ts_view_sample_ith,tip,bcol,fcol);

tip='RUN TS View';
mcs_gui_box([15],POS.run,[],tip,'pushbutton',tag,tip,1,[],bcol,fcol);

mcs_act('Program');

if ii_load & nfile>0,
	h=findobj(gcf,'Tag','Load _mcs root'); ii_val=find(strcmp(MCS.mcs_files,mcs_file(1:end-8)));
	set(h,'Value',ii_val);
	mcs_act('Load _mcs root');
end
