Index: trunk/src/series/civ_input.m
===================================================================
--- trunk/src/series/civ_input.m	(revision 1097)
+++ trunk/src/series/civ_input.m	(revision 1098)
@@ -1795,86 +1795,110 @@
 
 if get(handles.TestPatch1,'Value')% if TestPatch1 is activated
-     set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to indicate activation
-     set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is performed
-     hseries=findobj(allchild(0),'Tag','series');
-     Param=read_GUI(hseries);
-     Param.Action.RUN=1;
-     Param.ActionInput=read_GUI(handles.civ_input);
-     if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1
-         Param.ActionInput=rmfield(Param.ActionInput,'Civ2');
-     end
-     if isfield(Param.ActionInput,'Fix2')
-         Param.ActionInput=rmfield(Param.ActionInput,'Fix2');
-     end
-     if isfield(Param.ActionInput,'Patch2')
-         Param.ActionInput=rmfield(Param.ActionInput,'Patch2');
-     end
-     if isfield(Param,'OutputSubDir')
-         Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
-     end
-     ParamPatch1=Param.ActionInput.Patch1; %store the patch1 parameters
-     Param.ActionInput=rmfield(Param.ActionInput,'Patch1');% does not execute Patch
-     Param.IndexRange.first_i=str2num(get(handles.ref_i,'String'));
-     Param.IndexRange.last_i=Param.IndexRange.first_i;
-     if strcmp(get(handles.ref_j,'Visible'),'on')
-         Param.IndexRange.first_j=str2num(get(handles.ref_j,'String'));
-         Param.IndexRange.last_j=Param.IndexRange.first_j;
-     else
-         Param.IndexRange.first_j=1;
-         Param.IndexRange.last_j=1;
-     end
-     [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results
-     bckcolor=get(handles.civ_input,'Color');
-     set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished
-     
-     %% prepare Param for iterative Patch processing without input file reading
-     Param.Civ1_X=Data.Civ1_X;
-     Param.Civ1_Y=Data.Civ1_Y;
-     Param.Civ1_U=Data.Civ1_U;
-     Param.Civ1_V=Data.Civ1_V;
-     Param.Civ1_FF=Data.Civ1_FF;
-     Param=rmfield(Param,'InputTable');%desactivate input file reading
-    if isfield(Param.ActionInput,'Civ1')
-        Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant
-    end
-    if isfield(Param.ActionInput,'Fix1')
-        Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant
-    end
-    SmoothingParam=(ParamPatch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
-    NbGood=numel(find(Data.Civ1_FF==0));
-    NbExclude=zeros(1,7);% initialize the set of smoothing parameters
-    DiffVel=zeros(1,7);% initialize the rms difference between patch and civ
-    Param.ActionInput.Patch1=ParamPatch1;% retrieve Patch1 parameters
-    for irho=1:7
-        Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho);
-        [Data,errormsg]= civ_series(Param);%apply the processing fct
-        if ~isempty(errormsg)
-            msgbox_uvmat('ERROR',errormsg)
-            return
-        end
-        ind_good=find(Data.Civ1_FF==0);
-        Civ1_U_Diff=Data.Civ1_U(ind_good)-Data.Civ1_U_smooth(ind_good);
-        Civ1_V_Diff=Data.Civ1_V(ind_good)-Data.Civ1_V_smooth(ind_good);
-        DiffVel(irho)=sqrt(mean(Civ1_U_Diff.*Civ1_U_Diff+Civ1_V_Diff.*Civ1_V_Diff));
-        NbExclude(irho)=(NbGood-numel(ind_good))/NbGood;
-    end
-    figure(1)
-    semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r',SmoothingParam,0.2*ones(size(SmoothingParam)),'m')
-    grid on
-    legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)','recommended diff Patch1-Civ1')
-    xlabel('smoothing parameter')
-    ylabel('smoothing effect')
-    set(handles.TestPatch1,'BackgroundColor',[0 1 0])
-else
-    corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
-    if ~isempty(corrfig)
-        delete(corrfig)
-    end
-    hview_field=findobj(allchild(0),'tag','view_field');% look for view_field
-    if ~isempty(hview_field)
-        delete(hview_field)
-    end
-end
-
+    hseries=findobj(allchild(0),'Tag','series');
+    Param=read_GUI(hseries);
+    CivDir=fullfile(Param.OutputPath,Param.Experiment,Param.Device,[Param.OutputSubDir Param.OutputDirExt]);
+    % ListXml=dir(CivXmlDir);
+    if exist(CivDir,'dir')
+        CivFile=uigetfile_uvmat('pick .nc file with civ1-fix1 data',CivDir,'.nc');
+        [Field,VelTypeOut,errormsg]=read_civdata(CivFile)
+        for ilist=1:numel(Field.ListGlobalAttribute)
+            r=regexp(Field.ListGlobalAttribute{ilist},'Civ1_(?<field>.+)','names');% \D = not a digit, \d =digi
+            if ~isempty(r)
+                ParamTest.Civ1.(r.field)=(Field.(['Civ1_' r.field]));
+            end
+            r=regexp(Field.ListGlobalAttribute{ilist},'Fix1_(?<field>.+)','names');% \D = not a digit, \d =digi
+            if ~isempty(r)
+                ParamTest.Fix1.(r.field)=(Field.(['Fix1_' r.field]));
+            end
+        end
+        fill_GUI(ParamTest,handles.civ_input)% fill the elements of the GUI series with the input parameters
+        drawnow
+        update_CivOptions(handles,0)
+        
+        set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to indicate activation
+%         set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is performed
+        Param.Action.RUN=1;
+         Param.ActionInput=read_GUI(handles.civ_input);
+         Param.ActionInput.CheckCiv1=0;% do not repeat Civ1 computation        
+        if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1
+            Param.ActionInput=rmfield(Param.ActionInput,'Civ2');
+        end
+        if isfield(Param.ActionInput,'Fix2')
+            Param.ActionInput=rmfield(Param.ActionInput,'Fix2');
+        end
+        if isfield(Param.ActionInput,'Patch2')
+            Param.ActionInput=rmfield(Param.ActionInput,'Patch2');
+        end
+        if isfield(Param,'OutputSubDir')
+            Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
+        end
+        ParamPatch1=Param.ActionInput.Patch1; %store the patch1 parameters
+        Param.ActionInput=rmfield(Param.ActionInput,'Patch1');% does not execute Patch
+        Param.IndexRange.first_i=str2num(get(handles.ref_i,'String'));
+        Param.IndexRange.last_i=Param.IndexRange.first_i;
+        if strcmp(get(handles.ref_j,'Visible'),'on')
+            Param.IndexRange.first_j=str2num(get(handles.ref_j,'String'));
+            Param.IndexRange.last_j=Param.IndexRange.first_j;
+        else
+            Param.IndexRange.first_j=1;
+            Param.IndexRange.last_j=1;
+        end
+        [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results
+        bckcolor=get(handles.civ_input,'Color');
+        set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished
+        
+        %% prepare Param for iterative Patch processing without input file reading
+        Param.Civ1_X=Data.Civ1_X;
+        Param.Civ1_Y=Data.Civ1_Y;
+        Param.Civ1_U=Data.Civ1_U;
+        Param.Civ1_V=Data.Civ1_V;
+        Param.Civ1_FF=Data.Civ1_FF;
+        Param=rmfield(Param,'InputTable');%desactivate input file reading
+        if isfield(Param.ActionInput,'Civ1')
+            Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant
+        end
+        if isfield(Param.ActionInput,'Fix1')
+            Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant
+        end
+        SmoothingParam=(ParamPatch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
+        NbGood=numel(find(Data.Civ1_FF==0));
+        NbExclude=zeros(1,7);% initialize the set of smoothing parameters
+        DiffVel=zeros(1,7);% initialize the rms difference between patch and civ
+        Param.ActionInput.Patch1=ParamPatch1;% retrieve Patch1 parameters
+        for irho=1:7
+            Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho);
+            [Data,errormsg]= civ_series(Param);%apply the processing fct
+            if ~isempty(errormsg)
+                msgbox_uvmat('ERROR',errormsg)
+                return
+            end
+            ind_good=find(Data.Civ1_FF==0);
+            Civ1_U_Diff=Data.Civ1_U(ind_good)-Data.Civ1_U_smooth(ind_good);
+            Civ1_V_Diff=Data.Civ1_V(ind_good)-Data.Civ1_V_smooth(ind_good);
+            DiffVel(irho)=sqrt(mean(Civ1_U_Diff.*Civ1_U_Diff+Civ1_V_Diff.*Civ1_V_Diff));
+            NbExclude(irho)=(NbGood-numel(ind_good))/NbGood;
+        end
+        figure(1)
+        semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r',SmoothingParam,0.2*ones(size(SmoothingParam)),'m')
+        grid on
+        legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)','recommended diff Patch1-Civ1')
+        xlabel('smoothing parameter')
+        ylabel('smoothing effect')
+        set(handles.TestPatch1,'BackgroundColor',[0 1 0])
+    else
+        corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
+        if ~isempty(corrfig)
+            delete(corrfig)
+        end
+        hview_field=findobj(allchild(0),'tag','view_field');% look for view_field
+        if ~isempty(hview_field)
+            delete(hview_field)
+        end
+    end
+else
+    msgbox_uvmat('ERROR','no output file: first perform a civ1-fix1 computation')
+    return
+end
+  
 %------------------------------------------------------------------------
 % --- Executes on button press in TestCiv2.
Index: trunk/src/series/sub_background_special.m
===================================================================
--- trunk/src/series/sub_background_special.m	(revision 1097)
+++ trunk/src/series/sub_background_special.m	(revision 1098)
@@ -50,5 +50,5 @@
 %     UVMAT is free software; you can redistribute it and/or modify
 %     it under the terms of the GNU General Public License as published
-%     by the Free Software Foundation; either version 2 of the license,
+%     by the Free Software Foundation; either version 2 of the license,series
 %     or (at your option) any later version.
 %
@@ -66,5 +66,5 @@
     ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
     ParamOut.WholeIndexRange='on';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
-    ParamOut.NbSlice='off'; %nbre of slices ('off' by default)
+    ParamOut.NbSlice='on'; %nbre of slices ('off' by default)
     ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
@@ -93,12 +93,18 @@
 end
 %% estimate the position of bottom and mask for each Z Index
-BottomIndex=[1900 1800 1700 1650 1650 1600 1600 1600 1600 1600 1600];
+NbSlice=Param.IndexRange.NbSlice;
+switch NbSlice
+    case 11
+        BottomIndex=[1900 1800 1700 1650 1650 1600 1600 1600 1600 1600 1600];
+    case 4
+        BottomIndex=[1950 1850 1740 1700];
+end
 MaxIndex=BottomIndex+100;
 MinIndex=BottomIndex-100;
+
 maskindex=[665 1080];% range of x index perturbed by shadows 
-NbSlice=11;
 Bfilter=ones(1,20)/20;
 %% root input file names and nomenclature type (cell arrays with one element)
-OutputDir=[Param.OutputSubDir Param.OutputDirExt];
+OutputDir=[Param.OutputSubDir Param.OutputDirExt];4
 nbj=numel(Param.IndexRange.first_i:Param.IndexRange.last_i);
 for i_ind=Param.IndexRange.first_i:Param.IndexRange.last_i
