Index: /trunk/src/get_field.m
===================================================================
--- /trunk/src/get_field.m	(revision 763)
+++ /trunk/src/get_field.m	(revision 764)
@@ -166,7 +166,11 @@
 set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y coordinate for 1D plots
 checkseries=0;
-if isfield(ParamIn,'SeriesInput') && ParamIn.SeriesInput
+if isfield(ParamIn,'SeriesInput') && ParamIn.SeriesInput% case of call by series
     set(handles.FieldOption,'value',1)
-    set(handles.FieldOption,'String',{'scalar'})% case of call by series, only scalar
+    if isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata')
+    set(handles.FieldOption,'String',{'pick variables';'civdata...'})
+    else
+       set(handles.FieldOption,'String',{'pick variables'}) 
+    end
     checkseries=1;
     set(handles.scalar,'Max',2)
@@ -403,5 +407,5 @@
         ordinate_Callback(hObject, eventdata, handles)
         
-    case 'scalar'
+    case {'scalar','pick variables'}
         set(handles.Coordinates,'Visible','on')
         set(handles.PanelOrdinate,'Visible','off')
@@ -954,33 +958,33 @@
     case '1D plot'
         
-    case 'scalar'
+    case {'scalar','pick variables'}
        scalar_Callback(hObject, eventdata, handles)
     case 'vectors'
 end
 
-% --- Executes on button press in CheckDimensionY.
-function CheckDimensionY_Callback(hObject, eventdata, handles)
-FieldList=get(handles.FieldOption,'String');
-FieldOption=FieldList{get(handles.FieldOption,'Value')};
-switch FieldOption
-    case '1D plot'
-        
-    case 'scalar'
-       scalar_Callback(hObject, eventdata, handles)
-    case 'vectors'
-end
-
-
-% --- Executes on button press in CheckDimensionZ.
-function CheckDimensionZ_Callback(hObject, eventdata, handles)
-FieldList=get(handles.FieldOption,'String');
-FieldOption=FieldList{get(handles.FieldOption,'Value')};
-switch FieldOption
-    case '1D plot'
-        
-    case 'scalar'
-       scalar_Callback(hObject, eventdata, handles)
-    case 'vectors'
-end
+% % --- Executes on button press in CheckDimensionY.
+% function CheckDimensionY_Callback(hObject, eventdata, handles)
+% FieldList=get(handles.FieldOption,'String');
+% FieldOption=FieldList{get(handles.FieldOption,'Value')};
+% switch FieldOption
+%     case '1D plot'
+%         
+%     case {'scalar','pick variables'}
+%        scalar_Callback(hObject, eventdata, handles)
+%     case 'vectors'
+% end
+% 
+% 
+% % --- Executes on button press in CheckDimensionZ.
+% function CheckDimensionZ_Callback(hObject, eventdata, handles)
+% FieldList=get(handles.FieldOption,'String');
+% FieldOption=FieldList{get(handles.FieldOption,'Value')};
+% switch FieldOption
+%     case '1D plot'
+%         
+%     case 'scalar'
+%        scalar_Callback(hObject, eventdata, handles)
+%     case 'vectors'
+% end
 
 % --- Executes on selection change in TimeName.
Index: /trunk/src/keyboard_callback.m
===================================================================
--- /trunk/src/keyboard_callback.m	(revision 763)
+++ /trunk/src/keyboard_callback.m	(revision 764)
@@ -51,15 +51,22 @@
         otherwise
             if ischar(get(gco,'Tag'))
-            switch get(gco,'tag')% tag of the current edit box
-                case {'RootPath', 'SubDir','RootFile','FileExt','RootPath_1', 'SubDir_1','RootFile_1','FileExt_1'}
-                    set(handleshaxes.InputFileREFRESH,'BackgroundColor',[1 0 1])%indicat that REFRESH must be activated (introduce the whole series)
-                case 'num_IndexIncrement'% no action
-                otherwise
-                    if isfield(handleshaxes,'REFRESH')
-                    set(handleshaxes.REFRESH,'BackgroundColor',[1 0 1])%indicat that run0 must be activated
-                    elseif strcmp(get(gco,'Type'),'uicontrol')
-                       set(gco,'BackgroundColor',[1 0 1])%indicate that the edition  must be validated by carriage return
-                    end
-            end
+                switch get(gco,'tag')% tag of the current edit box
+                    case {'RootPath', 'SubDir','RootFile','FileExt','RootPath_1', 'SubDir_1','RootFile_1','FileExt_1'}
+                        set(handleshaxes.InputFileREFRESH,'BackgroundColor',[1 0 1])%indicat that REFRESH must be activated (introduce the whole series)
+                    case 'num_IndexIncrement'% no action
+                    otherwise
+                        if isfield(handleshaxes,'REFRESH')
+                            set(handleshaxes.REFRESH,'BackgroundColor',[1 0 1])%indicat that run0 must be activated
+                            if isfield(handleshaxes,'movie_pair')% stop movie pair in uvmat
+                                set(handleshaxes.movie_pair,'value',0);
+                                set(handleshaxes.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
+                                set(handleshaxes.i2,'String','')% the second i index display is suppressed
+                                set(handleshaxes.j2,'String','')% the second j index display is suppressed
+                                set(handleshaxes.Dt_txt,'String','')% the time interval indication is suppressed
+                            end
+                        elseif strcmp(get(gco,'Type'),'uicontrol')
+                            set(gco,'BackgroundColor',[1 0 1])%indicate that the edition  must be validated by carriage return
+                        end
+                end
             end
     end
Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 763)
+++ /trunk/src/series.m	(revision 764)
@@ -582,5 +582,5 @@
     errormsg=['input file ' fileinput  ' does not exist'];
     msgbox_uvmat('ERROR',errormsg)
-    set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH  button to red color (end of activation)
+    set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH  button to magenta color (refresh still needed)
     return
 end
@@ -594,18 +594,18 @@
     errormsg='no input file in the series';
     msgbox_uvmat('ERROR',errormsg)
-    set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH  button to red color (end of activation)
+    set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH  button to magenta color (end of activation)
     return
 end
 if strcmp(FileType,'txt')
     edit(fileinput)
-    set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH  button to red color (end of activation)
+    set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH  button to  magenta color (end of activation)
     return
 elseif strcmp(FileType,'xml')
     editxml(fileinput)
-    set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH  button to red color (end of activation)
+    set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH  button to magenta  color (end of activation)
      return
 elseif strcmp(FileType,'figure')
     open(fileinput)
-    set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH  button to red color (end of activation)
+    set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH  button to magenta  color (end of activation)
      return
 end
@@ -624,5 +624,4 @@
 
 
-
 %% fill the list of file series
 InputTable=get(handles.InputTable,'Data');
@@ -630,10 +629,8 @@
 if strcmp(iview,'append') % display the input data as a new line in the table
     iview=size(InputTable,1)+1;% the next line in InputTable becomes the current line
-    %InputTable(iview+1,:)={'','','','',''};
     InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
 elseif strcmp(iview,'one') % refresh the list of  input  file series
     iview=1; %the first line in InputTable becomes the current line
     InputTable={'','','','',''};
-    %InputTable=[{'','','','',''};{'','','','',''}];
     InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
     set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}])
@@ -653,8 +650,9 @@
     SeriesData.Time={};
 end
-%nbview=size(InputTable,1)-1;% rmq: the last line is set blank to allow manual addition of a line
 nbview=size(InputTable,1);
 set(handles.ListView,'String',mat2cell((1:nbview)',ones(nbview,1)))
 set(handles.ListView,'Value',iview)
+SeriesData.ListViewValue=iview;
+SeriesData.ListViewMenu=mat2cell((1:nbview)',ones(nbview,1));
 set(handles.InputTable,'Data',InputTable)
 
@@ -668,5 +666,4 @@
 ref_i=floor((i1+i2)/2);% reference image number corresponding to the file
 set(handles.num_ref_i,'String',num2str(ref_i));
-% set(handles.num_ref_i,'UserData',[i1 i2])%store the indices for future opening
 if isempty(j1)
     j1=1;
@@ -981,8 +978,4 @@
 MaxIndex_i=max(MaxIndex_i);
 range_index=MaxIndex_i-MinIndex_i+1;
-% scale_y=Position(4)/nbview;
-% scale_x=Position(3)/range_index;
-%x=(0.5:range_index-0.5)*Position(3)/range_index;% set of abscissa representing the whole i index range
-% y=(0.5:nbview-0.5)*Position(4)/nbview;
 range_y=max(1,floor(Position(4)/nbview));
 npx=floor(Position(3));
@@ -1010,7 +1003,9 @@
     set(handles.Pairs,'Visible','on')
     set(handles.PairString,'Visible','on')
+    set(handles.SetPairs,'Visible','on')
 else
     set(handles.Pairs,'Visible','off')
     set(handles.PairString,'Visible','off')
+    set(handles.SetPairs,'Visible','off')
 end
 
@@ -1025,7 +1020,7 @@
 switch FileType
     case {'civx','civdata'}
-        [FieldList,ColorList]=set_field_list('U','V','C');
-        set(handles.FieldName,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
-        set(handles.FieldName,'Value',2) % set menu to 'velocity
+        FieldList=set_field_list('U','V','C');
+        set(handles.FieldName,'String',[FieldList;{'get_field...'}]);%standard menu for civx data
+        set(handles.FieldName,'Value',1) % set menu to 'velocity
         set(handles.Coord_x,'Value',1);
         set(handles.Coord_x,'String',{'X'});
@@ -1233,10 +1228,10 @@
 % check_burst=0;
 if isempty(j2_series)% no j pair
+    ModeValue=1;
     if isempty(i2_series)
-        set(handles.mode,'Value',1)
         set(handles.mode,'String',{''})% no pair menu to display
     else   
         set(handles.mode,'Value',1)
-        set(handles.mode,'String',{'series(Di)'}) % pair menu with only option Di
+        ModeMenu={'series(Di)'}; % pair menu with only option Di
     end
 else %existence of j pairs
@@ -1249,20 +1244,25 @@
     MinIndex_j=min(find(i_max))-1;% min ref index i
     if MaxIndex_j==MinIndex_j
-        set(handles.mode,'Value',1);
-        set(handles.mode,'String',{'bursts'})
-%         check_burst=1;
+        ModeValue=1;
+        ModeMenu={'bursts'};
     elseif MaxIndex_i==MinIndex_i
-        set(handles.mode,'Value',1);
-        set(handles.mode,'String',{'series(Dj)'})
+    ModeValue=1;
+    ModeMenu={'series(Dj)'};
     else
-        set(handles.mode,'String',{'bursts';'series(Dj)'})
+        ModeMenu={'bursts';'series(Dj)'};
         if (MaxIndex_j-MinIndex_j)>10
-            set(handles.mode,'Value',2);%set mode to series(Dj) if more than 10 j values
+            ModeValue=2;%set mode to series(Dj) if more than 10 j values
         else
-            set(handles.mode,'Value',1);
-%             check_burst=1;
-        end
-    end
-end
+            ModeValue=1;
+        end
+    end
+end
+
+set(handles.mode,'String',ModeMenu)
+set(handles.mode,'Value',ModeValue)
+SeriesData=get(handles.series,'UserData');
+SeriesData.ModeMenu=ModeMenu;
+SeriesData.ModeValue=ModeValue;
+set(handles.series,'UserData',SeriesData)
 fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time)
 ListPairs_Callback([],[],handles)
@@ -1369,4 +1369,5 @@
 
 %% display list of pairstring
+SeriesData=get(handles.series,'UserData');
 displ_pair_list=get(handles.ListPairs,'String');
 NewVal=[];
@@ -1377,8 +1378,12 @@
 if ~isempty(NewVal)
     set(handles.ListPairs,'Value',NewVal)
+    SeriesData.ListPairsValue=NewVal;
 else
     set(handles.ListPairs,'Value',1)
+    SeriesData.ListPairsValue=1;
 end
 set(handles.ListPairs,'String',displ_pair)
+SeriesData.ListPairsMenu=displ_pair;
+set(handles.series,'UserData',SeriesData);
 
 %-------------------------------------
@@ -1422,4 +1427,148 @@
 Param=read_GUI_series(handles);%displayed parameters
 SeriesData=get(handles.series,'UserData');%hidden parameters
+
+
+
+%% select the Action mode, 'local', 'background' or 'cluster' (if available)
+RunMode='local';%default (needed for first opening of the GUI series)
+if isfield(Param.Action,'RunMode')
+    RunMode=Param.Action.RunMode;
+end
+ActionExt='.m';%default
+if isfield(Param.Action,'ActionExt')
+    ActionExt=Param.Action.ActionExt;% '.m' or '.sh' (compiled)
+end
+ActionName=Param.Action.ActionName;
+ActionPath=Param.Action.ActionPath;
+path_series=fileparts(which('series'));
+
+%% create the Action fct handle if RunMode option = 'local'
+if strcmp(RunMode,'local')
+    if ~isequal(ActionPath,path_series)
+        eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION
+        if ~exist(ActionPath,'dir')
+            msgbox_uvmat('ERROR',['The prescribed function path ' ActionPath ' does not exist']);
+            return
+        end
+        if ~isequal(spath,ActionPath)
+            addpath(ActionPath)% add the prescribed path if not the current one
+        end
+    end
+    eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION
+    if ~isequal(ActionPath,path_series)
+        rmpath(ActionPath)% add the prescribed path if not the current one
+    end
+end
+
+%% Get RunTime code from the file PARAM.xml (needed to run compiled functions)
+errormsg='';%default error message
+xmlfile=fullfile(path_series,'PARAM.xml');
+test_batch=0;%default: ,no batch mode available
+if ~exist(xmlfile,'file')
+    [success,message]=copyfile(fullfile(path_series,'PARAM.xml.default'),xmlfile);
+end
+RunTime='';
+if strcmp(ActionExt,'.sh')
+    if exist(xmlfile,'file')
+        s=xml2struct(xmlfile);
+        if strcmp(RunMode,'cluster_oar') && isfield(s,'BatchParam')
+            if isfield(s.BatchParam,'RunTime')
+                RunTime=s.BatchParam.RunTime;
+            end
+            if isfield(s.BatchParam,'NbCore')
+                NbCore=s.BatchParam.NbCore;
+            end
+        elseif (strcmp(RunMode,'background')||strcmp(RunMode,'local')) && isfield(s,'RunParam')
+            if isfield(s.RunParam,'RunTime')
+                RunTime=s.RunParam.RunTime;
+            end
+            if isfield(s.RunParam,'NbCore')
+                NbCore=s.RunParam.NbCore;
+            end
+        end
+    end
+    if isempty(RunTime) && strcmp(RunMode,'cluster_oar')
+        msgbox_uvmat('ERROR','RunTime name not found in PARAM.xml, compiled version .sh cannot run on cluster')
+        return
+    end
+end
+
+%% If a compiled version has been selected (ext .sh) check weather it needs to be recompiled
+% ActionExtList=get(handles.ActionExt,'String');
+% ActionExt=ActionExtList{get(handles.ActionExt,'Value')};
+% ActionList=get(handles.ActionName,'String');
+% ActionName=ActionList{get(handles.ActionName,'Value')};
+% TransformPath='';
+% if ~isempty(get(handles.ActionExt,'UserData'))
+%     TransformPath=get(handles.ActionExt,'UserData');
+% end
+if strcmp(ActionExt,'.sh')
+    TransformPath='';
+    if ~isempty(get(handles.ActionExt,'UserData'))
+        TransformPath=get(handles.ActionExt,'UserData');
+    end
+    set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch'
+    set(handles.ActionExt,'BackgroundColor',[1 1 0])
+    ActionFullName=fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']);
+    if ~exist(ActionFullName,'file')
+        answer=msgbox_uvmat('INPUT_Y-N','compiled version has not been created: compile now?');
+        if strcmp(answer,'Yes')
+            set(handles.ActionExt,'BackgroundColor',[1 1 0])
+            path_uvmat=fileparts(which('series'));
+            currentdir=pwd;
+            cd(get(handles.ActionPath,'String'))% go to the directory of Action
+            %  addpath(get(handles.TransformPath,'String'))
+            addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'
+           % addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile'
+            compile(ActionName,TransformPath)
+            cd(currentdir)
+        end       
+    else
+        sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']));
+        m_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.m']));
+        if isfield(m_file_info,'datenum') && m_file_info.datenum>sh_file_info.datenum
+            set(handles.ActionExt,'BackgroundColor',[1 1 0])
+            drawnow
+            answer=msgbox_uvmat('INPUT_Y-N',[ActionName '.sh needs to be updated: recompile now?']);
+            if strcmp(answer,'Yes')
+                path_uvmat=fileparts(which('series'));
+                currentdir=pwd;
+                cd(get(handles.ActionPath,'String'))% go to the directory of Action
+                %  addpath(get(handles.TransformPath,'String'))
+                addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'
+                addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile'
+                compile(ActionName,TransformPath)
+                cd(currentdir)
+            end
+        end
+    end
+    set(handles.ActionExt,'BackgroundColor',[1 1 1])
+     set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch
+end
+
+%% set nbre of cluster cores and processes
+switch RunMode
+    case {'local','background'}
+        NbCore=1;% no need to split the calculation
+    case 'cluster_oar'
+        if strcmp(Param.Action.ActionExt,'.m')% case of Matlab function (uncompiled)
+            NbCore=1;% one core used only (limitation of Matlab licences)
+            msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing');
+            extra_oar='';
+        else
+            answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''});
+            NbCore=str2double(answer{1});
+            extra_oar=answer{2};
+        end
+end
+if ~isfield(Param.IndexRange,'NbSlice')
+    Param.IndexRange.NbSlice=[];
+end
+if isempty(Param.IndexRange.NbSlice)
+    NbProcess=NbCore;% choose one process per core
+else
+    NbProcess=Param.IndexRange.NbSlice;% the nbre of run processes is equal to the number of slices
+    NbCore=min(NbCore,NbProcess);% at least one process per core
+end
 
 %% create the output data directory if needed
@@ -1478,93 +1627,4 @@
         end
     end
-end
-
-%% select the Action mode, 'local', 'background' or 'cluster' (if available)
-RunMode='local';%default (needed for first opening of the GUI series)
-if isfield(Param.Action,'RunMode')
-    RunMode=Param.Action.RunMode;
-end
-ActionExt='.m';%default
-if isfield(Param.Action,'ActionExt')
-    ActionExt=Param.Action.ActionExt;% '.m' or '.sh' (compiled)
-end
-ActionName=Param.Action.ActionName;
-ActionPath=Param.Action.ActionPath;
-path_series=fileparts(which('series'));
-
-%% create the Action fct handle if RunMode option = 'local'
-if strcmp(RunMode,'local')
-    if ~isequal(ActionPath,path_series)
-        eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION
-        if ~exist(ActionPath,'dir')
-            msgbox_uvmat('ERROR',['The prescribed function path ' ActionPath ' does not exist']);
-            return
-        end
-        if ~isequal(spath,ActionPath)
-            addpath(ActionPath)% add the prescribed path if not the current one
-        end
-    end
-    eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION
-    if ~isequal(ActionPath,path_series)
-        rmpath(ActionPath)% add the prescribed path if not the current one
-    end
-end
-
-%% Get RunTime code from the file PARAM.xml (needed to run compiled functions)
-errormsg='';%default error message
-xmlfile=fullfile(path_series,'PARAM.xml');
-test_batch=0;%default: ,no batch mode available
-if ~exist(xmlfile,'file')
-    [success,message]=copyfile(fullfile(path_series,'PARAM.xml.default'),xmlfile);
-end
-RunTime='';
-if strcmp(ActionExt,'.sh')
-    if exist(xmlfile,'file')
-        s=xml2struct(xmlfile);
-        if strcmp(RunMode,'cluster_oar') && isfield(s,'BatchParam')
-            if isfield(s.BatchParam,'RunTime')
-                RunTime=s.BatchParam.RunTime;
-            end
-            if isfield(s.BatchParam,'NbCore')
-                NbCore=s.BatchParam.NbCore;
-            end
-        elseif (strcmp(RunMode,'background')||strcmp(RunMode,'local')) && isfield(s,'RunParam')
-            if isfield(s.RunParam,'RunTime')
-                RunTime=s.RunParam.RunTime;
-            end
-            if isfield(s.RunParam,'NbCore')
-                NbCore=s.RunParam.NbCore;
-            end
-        end
-    end
-    if isempty(RunTime) && strcmp(RunMode,'cluster_oar')
-        msgbox_uvmat('ERROR','RunTime name not found in PARAM.xml, compiled version .sh cannot run on cluster')
-        return
-    end
-end
-
-%% set nbre of cluster cores and processes
-switch RunMode
-    case {'local','background'}
-        NbCore=1;% no need to split the calculation
-    case 'cluster_oar'
-        if strcmp(Param.Action.ActionExt,'.m')% case of Matlab function (uncompiled)
-            NbCore=1;% one core used only (limitation of Matlab licences)
-            msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing');
-            extra_oar='';
-        else
-            answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''});
-            NbCore=str2double(answer{1});
-            extra_oar=answer{2};
-        end
-end
-if ~isfield(Param.IndexRange,'NbSlice')
-    Param.IndexRange.NbSlice=[];
-end
-if isempty(Param.IndexRange.NbSlice)
-    NbProcess=NbCore;% choose one process per core
-else
-    NbProcess=Param.IndexRange.NbSlice;% the nbre of run processes is equal to the number of slices
-    NbCore=min(NbCore,NbProcess);% at least one process per core
 end
         
@@ -2245,5 +2305,5 @@
     Param=read_GUI(handles.series);
     Param.InputTable=Param.InputTable(1,:);
-     % check the existence of the first file in the series
+    % check the existence of the first file in the series
     first_j=[];
     if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
@@ -2255,6 +2315,4 @@
     FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
         Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
-%     filecell=get_file_series(Param);
-%     
     if exist(FirstFileName,'file')
         ParamIn.SeriesInput=1;
@@ -2266,23 +2324,20 @@
                 VName=GetFieldData.PanelVectors.vector_y;
                 YName={GetFieldData.Coordinates.Coord_y};
-                CName=GetFieldData.PanelVectors.vec_color;
                 FieldList={['vec(' UName ',' VName ')'];...
                     ['norm(' UName ',' VName ')'];...
                     UName;VName};
-                VecColorList={['norm(' UName ',' VName ')'];...
-                    UName;VName};
-                if ~isempty(CName)
-                    VecColorList=[{CName};VecColorList];
-                end
-            case 'scalar'
+            case {'scalar','pick variables'}
                 FieldList=GetFieldData.PanelScalar.scalar;
                 YName={GetFieldData.Coordinates.Coord_y};
                 if ischar(FieldList)
-                FieldList={FieldList};
+                    FieldList={FieldList};
                 end
             case '1D plot'
                 YName=GetFieldData.PanelOrdinate.ordinate;
-%             case 'civdata...'%reinitiate input, return to automatic civ data reading
-%                 display_file_name(handles,FileName,1)
+            case 'civdata...'
+                FieldList=set_field_list('U','V','C');
+                set(handles.FieldName,'Value',2) % set menu to 'velocity
+                XName='X';
+                YName='y';
         end
         if ~strcmp(GetFieldData.FieldOption,'civdata...')
@@ -2307,9 +2362,9 @@
                     ParamIn.TimeDimName=GetFieldData.Time.TimeName;
             end
-            set(handles.Coord_x,'String',{XName})
-            set(handles.Coord_y,'String',YName)
-            set(handles.FieldName,'Value',1)
-            set(handles.FieldName,'String',[FieldList; {'get_field...'}]);
-        end
+        end
+        set(handles.Coord_x,'String',{XName})
+        set(handles.Coord_y,'String',YName)
+        set(handles.FieldName,'Value',1)
+        set(handles.FieldName,'String',[FieldList; {'get_field...'}]);
     end
 end
@@ -2321,24 +2376,67 @@
 field_str=get(handles.FieldName_1,'String');
 field_index=get(handles.FieldName_1,'Value');
-field=field_str{field_index};
-if isequal(field,'get_field...')    
-     hget_field=findobj(allchild(0),'name','get_field_1');
-     if ~isempty(hget_field)
-         delete(hget_field)
-     end
-     SeriesData=get(handles.series,'UserData');
-     filename=SeriesData.CurrentInputFile_1;
-     if exist(filename,'file')
-        hget_field=get_field(filename);
-        set(hget_field,'name','get_field_1')
-     end
-% elseif isequal(field,'more...')
-%     str=calc_field;
-%     [ind_answer,v] = listdlg('PromptString','Select a file:',...
-%                 'SelectionMode','single',...
-%                 'ListString',str);
-%        % edit the choice in the fields and actionname menu
-%      scalar=cell2mat(str(ind_answer));
-%      update_menu(handles.FieldName_1,scalar)
+field=field_str{field_index(1)};
+if isequal(field,'get_field...')
+    hget_field=findobj(allchild(0),'name','get_field');
+    if ~isempty(hget_field)
+        delete(hget_field)%delete opened versions of get_field
+    end
+    Param=read_GUI(handles.series);
+    Param.InputTable=Param.InputTable(1,:);
+    % check the existence of the first file in the series
+    first_j=[];
+    if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
+    if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end
+    PairString='';
+    if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
+    [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
+    FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
+        Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
+    if exist(FirstFileName,'file')
+        ParamIn.SeriesInput=1;
+        GetFieldData=get_field(FirstFileName,ParamIn);
+        FieldList={};
+        switch GetFieldData.FieldOption
+            case 'vectors'
+                UName=GetFieldData.PanelVectors.vector_x;
+                VName=GetFieldData.PanelVectors.vector_y;
+                FieldList={['vec(' UName ',' VName ')'];...
+                    ['norm(' UName ',' VName ')'];...
+                    UName;VName};
+            case {'scalar','pick variables'}
+                FieldList=GetFieldData.PanelScalar.scalar;
+                if ischar(FieldList)
+                    FieldList={FieldList};
+                end
+            case '1D plot'
+
+            case 'civdata...'
+                FieldList=set_field_list('U','V','C');
+                set(handles.FieldName,'Value',2) % set menu to 'velocity
+        end
+        if ~strcmp(GetFieldData.FieldOption,'civdata...')
+            TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
+            switch TimeNameStr
+                case 'file index'
+                    set(handles.TimeName,'String','');
+                case 'attribute'
+                    set(handles.TimeName,'String',['att:' GetFieldData.Time.TimeName]);
+                case 'variable'
+                    set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName])
+                    set(handles.NomType,'String','*')
+                    set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% A VERIFIER !!!!!!
+                    set(handles.FileIndex,'String','')
+                    ParamIn.TimeVarName=GetFieldData.Time.TimeName;
+                case 'matrix_index'
+                    set(handles.TimeName,'String',['dim:' GetFieldData.Time.TimeName]);
+                    set(handles.NomType,'String','*')
+                    set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])
+                    set(handles.FileIndex,'String','')
+                    ParamIn.TimeDimName=GetFieldData.Time.TimeName;
+            end
+        end
+        set(handles.FieldName_1,'Value',1)
+        set(handles.FieldName_1,'String',[FieldList; {'get_field...'}]);
+    end
 end   
 
@@ -2927,49 +3025,47 @@
 ActionList=get(handles.ActionName,'String');
 ActionName=ActionList{get(handles.ActionName,'Value')};
-TransformPath='';
-if ~isempty(get(handles.ActionExt,'UserData'))
-    TransformPath=get(handles.ActionExt,'UserData');
-end
-if strcmp(ActionExt,'.sh')
-    set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch'
-    set(handles.ActionExt,'BackgroundColor',[1 1 0])
-    ActionFullName=fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']);
-    if ~exist(ActionFullName,'file')
-        answer=msgbox_uvmat('INPUT_Y-N','compiled version has not been created: compile now?');
-        if strcmp(answer,'Yes')
-            set(handles.ActionExt,'BackgroundColor',[1 1 0])
-            path_uvmat=fileparts(which('series'));
-            currentdir=pwd;
-            cd(get(handles.ActionPath,'String'))% go to the directory of Action
-            %  addpath(get(handles.TransformPath,'String'))
-            addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'
-           % addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile'
-            compile(ActionName,TransformPath)
-            cd(currentdir)
-        end       
-    else
-        sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']));
-        m_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.m']));
-        if isfield(m_file_info,'datenum') && m_file_info.datenum>sh_file_info.datenum
-            set(handles.ActionExt,'BackgroundColor',[1 1 0])
-            drawnow
-            answer=msgbox_uvmat('INPUT_Y-N',[ActionName '.sh needs to be updated: recompile now?']);
-            if strcmp(answer,'Yes')
-                path_uvmat=fileparts(which('series'));
-                currentdir=pwd;
-                cd(get(handles.ActionPath,'String'))% go to the directory of Action
-                %  addpath(get(handles.TransformPath,'String'))
-                addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'
-                addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile'
-                compile(ActionName,TransformPath)
-                cd(currentdir)
-            end
-        end
-    end
-    set(handles.ActionExt,'BackgroundColor',[1 1 1])
-     set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch
-end
-
-
+% TransformPath='';
+% if ~isempty(get(handles.ActionExt,'UserData'))
+%     TransformPath=get(handles.ActionExt,'UserData');
+% end
+% if strcmp(ActionExt,'.sh')
+%     set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch'
+%     set(handles.ActionExt,'BackgroundColor',[1 1 0])
+%     ActionFullName=fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']);
+%     if ~exist(ActionFullName,'file')
+%         answer=msgbox_uvmat('INPUT_Y-N','compiled version has not been created: compile now?');
+%         if strcmp(answer,'Yes')
+%             set(handles.ActionExt,'BackgroundColor',[1 1 0])
+%             path_uvmat=fileparts(which('series'));
+%             currentdir=pwd;
+%             cd(get(handles.ActionPath,'String'))% go to the directory of Action
+%             %  addpath(get(handles.TransformPath,'String'))
+%             addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'
+%            % addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile'
+%             compile(ActionName,TransformPath)
+%             cd(currentdir)
+%         end       
+%     else
+%         sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']));
+%         m_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.m']));
+%         if isfield(m_file_info,'datenum') && m_file_info.datenum>sh_file_info.datenum
+%             set(handles.ActionExt,'BackgroundColor',[1 1 0])
+%             drawnow
+%             answer=msgbox_uvmat('INPUT_Y-N',[ActionName '.sh needs to be updated: recompile now?']);
+%             if strcmp(answer,'Yes')
+%                 path_uvmat=fileparts(which('series'));
+%                 currentdir=pwd;
+%                 cd(get(handles.ActionPath,'String'))% go to the directory of Action
+%                 %  addpath(get(handles.TransformPath,'String'))
+%                 addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'
+%                 addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile'
+%                 compile(ActionName,TransformPath)
+%                 cd(currentdir)
+%             end
+%         end
+%     end
+%     set(handles.ActionExt,'BackgroundColor',[1 1 1])
+%      set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch
+% end
 
 
@@ -3022,2 +3118,90 @@
 function series_WindowButtonMotionFcn(hObject, eventdata, handles)
 set(hObject,'Pointer','arrow');
+
+
+% --- Executes on button press in SetPairs.
+function SetPairs_Callback(hObject, eventdata, handles)
+
+%% create the GUI set_pairs
+set(0,'Unit','points')
+ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right
+Width=300;% fig width in points (1/72 inch)
+Height=min(0.8*ScreenSize(4),300);
+Left=ScreenSize(3)- Width-40; %right edge close to the right, with margin=40
+Bottom=ScreenSize(4)-Height-40; %put fig at top right
+hfig=findobj(allchild(0),'Tag','set_slice');
+if ~isempty(hfig),delete(hfig), end; %delete existing version of the GUI 
+hfig=figure('name','set_pairs','tag','set_pairs','MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height]);
+BackgroundColor=get(hfig,'Color');
+hh=0.14; % box height (relative)
+ii=0.01; % gap between uicontrols
+
+ww=0.9; % box width (relative)
+SeriesData=get(handles.series,'UserData');
+% first raw of the GUI
+uicontrol('Style','text','Units','normalized', 'Position', [0.02 0.9 0.5 0.1],'BackgroundColor',BackgroundColor,...
+    'String','row to edit #','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title
+uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.54 0.8 0.3 0.2],'tag','ListView','BackgroundColor',[1 1 1],...
+    'String',SeriesData.ListViewMenu,'Value',SeriesData.ListViewValue,'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''ListView'':choice of the file series w for pair display');
+% second raw of the GUI
+uicontrol('Style','text','Units','normalized', 'Position', [0.02 0.8 0.7 0.1],'BackgroundColor',BackgroundColor,...
+    'String','mode of index pairing:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');%title
+uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.02 0.58 ww 0.2],'tag','Mode','BackgroundColor',[1 1 1],'Callback',@(hObject,eventdata)ModeMenu_Callback(hObject,eventdata),...
+    'String',SeriesData.ModeMenu,'Value',SeriesData.ModeValue,'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''Mode'': choice of the image pair mode');
+% third raw
+uicontrol('Style','text','Units','normalized', 'Position', [0.02 0.6 0.7 0.1],'BackgroundColor',BackgroundColor,...
+    'String','pair choice:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');%title
+uicontrol('Style','listbox','Units','normalized', 'Position', [0.02 0.16 ww 0.4],'tag','ListPairs','BackgroundColor',[1 1 1],'Callback',@(hObject,eventdata)ListPairsMenu_Callback(hObject,eventdata),...
+    'String',SeriesData.ListPairsMenu,'Value',SeriesData.ListPairsValue,'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''ListPairs'': menu for selecting the image pair');
+%  last raw  of the GUI: pushbuttons
+wwp=(1-4*ii)/3; %width of the push buttons
+uicontrol('Style','pushbutton','Units','normalized', 'Position', [ii ii wwp hh],'BackgroundColor',[0 1 0],'String','OK','Callback',@(hObject,eventdata)OK_Callback(hObject,eventdata),...
+    'FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''OK'': apply the output to the current field series in uvmat');
+drawnow
+
+function ModeMenu_Callback(hObject,eventdata)
+hseries=findobj(allchild(0),'tag','series');
+hhseries=guidata(hseries);
+SeriesData=get(hseries,'UserData');
+hListView=findobj(get(hObject,'parent'),'Tag','ListView');
+iview=get(hListView,'Value');
+hMode=findobj(get(hObject,'parent'),'Tag','Mode');
+mode_list=get(hMode,'String');
+mode=mode_list{get(hMode,'Value')};
+if isequal(mode,'bursts')
+    enable_i(hhseries,'On')
+    enable_j(hhseries,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice)
+else
+    enable_i(hhseries,'On')
+    enable_j(hhseries,'Off')
+end
+fill_ListPair(hhseries,SeriesData.i1_series{iview},SeriesData.i2_series{iview},...
+    SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview})
+ListPairs_Callback([],[],hhseries)
+
+%-------------------------------------------------------------
+% --- Executes on selection in ListPairs.
+function ListPairsMenu_Callback(hObject,eventdata)
+%------------------------------------------------------------
+list_pair=get(hObject,'String');%get the menu of image pairs
+if isempty(list_pair)
+    string='';
+else
+    string=list_pair{get(hObject,'Value')};
+    string=regexprep(string,',.*','');%removes time indication (after ',')
+end
+hseries=findobj(allchild(0),'tag','series');
+hPairString=findobj(hseries,'tag','PairString');
+PairString=get(hPairString,'Data');
+hListView=findobj(get(hObject,'parent'),'Tag','ListView');
+iview=get(hListView,'Value');
+PairString{iview,1}=string;
+% report the selected pair string to the table PairString
+set(hPairString,'Data',PairString)
+
+%-------------------------------------------------------------
+% --- Executes on selection in ListPairs.
+function OK_Callback(hObject,eventdata)
+%------------------------------------------------------------
+delete(get(hObject,'parent'))
+
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 763)
+++ /trunk/src/uvmat.m	(revision 764)
@@ -610,5 +610,5 @@
 %------------------------------------------------------------------------
 [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));
-set(handles.i1,'String',num2str(i1));
+set(handles.i1,'String',num2str(i1));%update the counters
 set(handles.i2,'String',num2str(i2));
 set(handles.j1,'String',num2str(j1));
@@ -626,5 +626,5 @@
 FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2);
 set(handles.FileIndex,'String',FileIndex)
-% inputfilerefresh the current settings and inputfilerefresh the field view
+% refresh the current settings and refresh the field view
 RootPath_Callback(hObject,eventdata,handles)
 
@@ -1260,17 +1260,17 @@
     case 1
         indices=fullfile_uvmat('','','','',NomType,stra2num(get(handles.i1,'String')),i2,j1,j2);
-        set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
+%        set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
     case 2
         indices=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.i2,'String')),j1,j2);
-        set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
+%        set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
     case 3
         indices=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.j1,'String')),j2);
-        set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
+%        set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
     case 4
         indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.j2,'String')));
-        set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
+%        set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
 end
 set(handles.FileIndex,'String',indices)
-set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
+%set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
 % update the second index if relevant
 if strcmp(get(handles.FileIndex_1,'Visible'),'on')
@@ -1518,5 +1518,4 @@
     msgbox_uvmat('ERROR',errormsg);
 end
-set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red
 
 %------------------------------------------------------------------------
@@ -1537,5 +1536,4 @@
     msgbox_uvmat('ERROR',errormsg);
 end
-set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red
 
 %------------------------------------------------------------------------
@@ -1619,5 +1617,5 @@
 %% check for movie pair status
 movie_status=get(handles.movie_pair,'Value');
-if isequal(movie_status,1)
+if movie_status
     STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
 end
@@ -1635,4 +1633,10 @@
     j1=str2num(get(handles.j1,'String'));%case of indexed movie
 end
+if movie_status% we read the second index from the edit box
+    i2=str2num(get(handles.i2,'String'));%read the field indices (for movie, it is not given by the file name)
+    if strcmp(get(handles.j2,'Visible'),'on')
+    j2=str2num(get(handles.j2,'String'));%
+    end
+end
 sub_value= get(handles.SubField,'Value');
 if sub_value % a second input file has been entered
@@ -1672,5 +1676,5 @@
     end
     
-    % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used
+% the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used
 else
     UvData=get(handles.uvmat,'UserData');
@@ -1818,6 +1822,9 @@
 end
 set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0])
+set(handles.runplus,'BackgroundColor',[1 0 0])
+set(handles.runmin,'BackgroundColor',[1 0 0])
 
 %% update the index counters if the index move is successfull
+
 if isempty(errormsg) 
     set(handles.i1,'String',num2stra(i1,NomType,1));
@@ -1846,10 +1853,4 @@
         if isempty(j2), set(handles.j2,'String',''); end 
     end
-    set(handles.i1,'BackgroundColor',[1 1 1])
-    set(handles.i2,'BackgroundColor',[1 1 1])
-    set(handles.j1,'BackgroundColor',[1 1 1])
-    set(handles.j2,'BackgroundColor',[1 1 1])
-    set(handles.FileIndex,'BackgroundColor',[1 1 1])
-    set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) 
 end
 
@@ -1862,47 +1863,57 @@
 if ~get(handles.movie_pair,'value')
     set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
-    set(handles.i2,'String','')
-    set(handles.j2,'String','')
-    set(handles.Dt_txt,'String','')
+    set(handles.i2,'String','')% the second i index display is suppressed
+    set(handles.j2,'String','')% the second j index display is suppressed
+    set(handles.Dt_txt,'String','')% the time interval indication is suppressed
     return
-else
-    set(handles.movie_pair,'BusyAction','queue')
-    set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0])
-end
-
-%% initialisation
-set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
+end
+   
+%% check the input file indexing:
+[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
+NomType=get(handles.NomType,'String');
+if ~isempty(find(regexp(NomType,'-')))
+    msgbox_uvmat('ERROR','The movie pair requires file series with a single index on the first input line')
+    return
+end
+filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line)
+
+set(handles.movie_pair,'BusyAction','queue')% 
+set(handles.CheckFixPair,'Value',1)% impose fixed pair (needed for function runpm)
+set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity
+set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity
 drawnow
-list_fields=get(handles.FieldName,'String');% list menu fields
-index_fields=get(handles.FieldName,'Value');% selected string index
-FieldName=list_fields{index_fields}; % selected field
-UvData=get(handles.uvmat,'UserData');
-if isequal(FieldName,'image')
-    index=1;
-    [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles);
-    NomType=get(handles.NomType,'String');
-else
-    list_fields=get(handles.FieldName_1,'String');% list menu fields
-    index_fields=get(handles.FieldName_1,'Value');% selected string index
-    FieldName=list_fields{index_fields}; % selected field
-    if isequal(FieldName,'image')
-        index=2;
-        [RootPath,SubDir,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles);% get info from the second input line
-    else
-        msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
-        set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
-        set(handles.movie_pair,'Value',0)
-        return
-    end
-end
+% list_fields=get(handles.FieldName,'String');% list menu fields
+% index_fields=get(handles.FieldName,'Value');% selected string index
+% FieldName=list_fields{index_fields}; % selected field
+
+
+% if isequal(FieldName,'image')
+%     index=1;
+
+% else
+%     list_fields=get(handles.FieldName_1,'String');% list menu fields
+%     index_fields=get(handles.FieldName_1,'Value');% selected string index
+%     FieldName=list_fields{index_fields}; % selected field
+%     if isequal(FieldName,'image')
+%         index=2;
+%         [RootPath,SubDir,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles);% get info from the second input line
+%     else
+%         msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
+%         set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
+%         set(handles.movie_pair,'Value',0)
+%         return
+%     end
+% end
 num_i1=str2num(get(handles.i1,'String'));
 num_j1=stra2num(get(handles.j1,'String'));
 num_i2=str2num(get(handles.i2,'String'));
 num_j2=stra2num(get(handles.j2,'String'));
+
+%% determine the name 'imaname_1' of the second file in the pair
 imaname_1='';
-if isempty(num_j2)
+if isempty(num_j2)% no second j index indicated
     if isempty(num_i2)
         if strcmp(get(handles.j2,'Visible'),'on') %if the j box is visible
-            imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i1,[],num_j1+1);
+            imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1,[],num_j1+1);
         end
         if exist(imaname_1,'file')
@@ -1910,5 +1921,5 @@
             set(handles.j2,'String',num2stra(num_j2,NomType));
         else
-            imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i1+1,[],num_j1);
+            imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1+1,[],num_j1);
             if exist(imaname_1,'file')
                 num_i2=num_i1+1;
@@ -1934,5 +1945,5 @@
     num_j2=num_j1;%repeat the index i1 by default
 end
-imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i2,[],num_j2);
+imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i2,[],num_j2);
 if strcmp(NomType,'*')
     num_frame=num_i2;
@@ -1946,4 +1957,31 @@
       return
 end
+
+%% display the first field in the pair (including possibly a background field from second line input filename_1)
+filename_1='';%default
+FileIndex_1='';
+if get(handles.SubField,'Value')
+    [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
+    filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
+end
+% num_i1=stra2num(get(handles.i1,'String'));
+% num_i2=stra2num(get(handles.i2,'String'));
+% num_j1=stra2num(get(handles.j1,'String'));
+% num_j2=stra2num(get(handles.j2,'String'));
+[tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);% get the indices of the second series from the string FileIndex_1
+if isempty(j1_1)% case of movies, the index is not given by file index
+    j1_1=num_j1;
+end
+
+errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
+
+if isempty(errormsg)
+    set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull
+else
+     msgbox_uvmat('ERROR',errormsg);
+     set(handles.REFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull
+end
+UvData=get(handles.uvmat,'UserData');
+Field_a=UvData.Field;% movie on the field defined by the second input line
 
 %% display time interval for the image pair
@@ -1960,45 +1998,35 @@
 end
 
-%% get the first image
-%Field.AName='image';
-if index==1
-    Field_a=UvData.Field;% movie on the second field
-else
-    Field_a=UvData.Field_1;% movie on the first field
-end
-
-%% read the second image
-MovieObject=[];
-if numel(UvData.MovieObject)>=index
-    MovieObject=UvData.MovieObject{index};
-end
-[Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},MovieObject,num_frame);
-
-%px to phys or other transform on field
+%% read the second field
+if isempty(UvData.MovieObject)
+    [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},[],num_frame);
+else
+    [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{1},UvData.MovieObject{1},num_frame);
+end
+if ~isempty(errormsg)
+    msgbox_uvmat('ERROR',['Error in reading second image: ' errormsg])
+    return
+end
+
+%% apply phys or other transform on the two input fields
 transform=get(handles.TransformPath,'UserData');
 if  ~isempty(transform)
-    if isfield(UvData,'XmlData') && numel(UvData.XmlData)>=index %use geometry calib recorded from the ImaDoc xml file as first priority
-        if index==2
-        Field_a=transform(Field_a,UvData.XmlData{index});%the first field has been stored without transform
-        end
+    if isfield(UvData,'XmlData') && ~isempty(UvData.XmlData) %use geometry calib recorded from the ImaDoc xml file as first priority
         if nargin(transform)>=2
-        Field_b=transform(Field_b,UvData.XmlData{index});
+            Field_b=transform(Field_b,UvData.XmlData{1});
         else
-          Field_b=transform(Field_b);
-        end
-    end
-end
-
-% make movie until movie speed is set to 0 or STOP is activated
+            Field_b=transform(Field_b);
+        end
+    end
+end
+
+%% make movie until movie speed is set to 0 or STOP is activated
 hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER)
 set(handles.STOP,'Visible','on')
 set(handles.speed,'Visible','on')
 set(handles.speed_txt,'Visible','on')
-set(handles.i2,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input
-set(handles.j2,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input
-set(handles.FileIndex,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input
 while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue') % enable STOP command
     % read and plot the series of images in non erase mode
-    set(hima,'CData',Field_b.A); 
+    set(hima,'CData',Field_b.A); %TODO: generalise to other kinds of fields
     pause(1.02-get(handles.speed,'Value'));% wait for next image
     set(hima,'CData',Field_a.A);
@@ -2013,16 +2041,16 @@
 function REFRESH_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
-set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the command button in yellow
+set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the REFRESH button in yellow to indicate its activity
 drawnow
-[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
+[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);%read the features of the input file name (first line)
 [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(FileIndex);% check back the indices used
-if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used
-if isempty(j2), set(handles.j2,'String',''); end 
-filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
-filename_1='';%default
+if isempty(i2), set(handles.i2,'String',''); end % suppress the second i index display if not used
+if isempty(j2), set(handles.j2,'String',''); end % suppress the second j index display if not used
+filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line)
+filename_1='';%default second file name
 FileIndex_1='';
-if get(handles.SubField,'Value')
-    [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
-    filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
+if get(handles.SubField,'Value')% if a second file is introduced
+    [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);%read the features of the input file name (second line)
+    filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; %build the input file name (second line)
 end
 num_i1=stra2num(get(handles.i1,'String'));
@@ -2034,19 +2062,13 @@
     j1_1=num_j1;
 end
-
+% in case of movies the index is set by edit boxes i1 or j1 (case of movies indexed by index i)
 errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
 
-if ~isempty(errormsg)
-      msgbox_uvmat('ERROR',errormsg);
-      set(handles.InputFileREFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull
-else
-    set(handles.i1,'BackgroundColor',[1 1 1])
-    set(handles.i2,'BackgroundColor',[1 1 1])
-    set(handles.j1,'BackgroundColor',[1 1 1])
-    set(handles.j2,'BackgroundColor',[1 1 1])
-    set(handles.FileIndex,'BackgroundColor',[1 1 1])
-    set(handles.FileIndex_1,'BackgroundColor',[1 1 1])  
+if isempty(errormsg)
     set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull
-end    
+else
+     msgbox_uvmat('ERROR',errormsg);
+     set(handles.REFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull
+end
 
 %------------------------------------------------------------------------
@@ -3554,10 +3576,10 @@
         msgbox_uvmat('ERROR',errormsg);
     else
-        set(handles.i1,'BackgroundColor',[1 1 1])
-        set(handles.i2,'BackgroundColor',[1 1 1])
-        set(handles.j1,'BackgroundColor',[1 1 1])
-        set(handles.j2,'BackgroundColor',[1 1 1])
-        set(handles.FileIndex,'BackgroundColor',[1 1 1])
-        set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
+%         set(handles.i1,'BackgroundColor',[1 1 1])
+%         set(handles.i2,'BackgroundColor',[1 1 1])
+%         set(handles.j1,'BackgroundColor',[1 1 1])
+%         set(handles.j2,'BackgroundColor',[1 1 1])
+%         set(handles.FileIndex,'BackgroundColor',[1 1 1])
+%         set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
     end
     set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0])
@@ -4235,9 +4257,11 @@
 [tild,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam);
 errormsg=fill_GUI(PlotParamOut,handles.uvmat);
-if ~isempty(errormsg)
+if isempty(errormsg)
+    set(handles.REFRESH,'BackgroundColor',[1 0 0]);% operation finished, back to red color
+else
     msgbox_uvmat('ERROR',errormsg)
-    return
-end
-set(handles.REFRESH,'BackgroundColor',[1 0 0]);
+    set(handles.REFRESH,'BackgroundColor',[1 0 1]);% magenta color: graph still needs to be updated
+end
+
 
 %------------------------------------------------------------------------
