Index: /trunk/src/browse_data.m
===================================================================
--- /trunk/src/browse_data.m	(revision 1067)
+++ /trunk/src/browse_data.m	(revision 1068)
@@ -1,3 +1,4 @@
-%'browse_data': function for scanning directories in a campaign 
+
+%'browse_data': function for scanning directories in a campaign
 %------------------------------------------------------------------------
 % function varargout = series(varargin)
@@ -24,15 +25,15 @@
 function varargout = browse_data(varargin)
 
-% Last Modified by GUIDE v2.5 17-Apr-2019 18:15:24
+% Last Modified by GUIDE v2.5 08-Jul-2019 23:32:39
 
 % Begin initialization code - DO NOT EDIT
 gui_Singleton = 1;
 gui_State = struct('gui_Name',       mfilename, ...
-                   'gui_Singleton',  gui_Singleton, ...
-                   'gui_OpeningFcn', @browse_data_OpeningFcn, ...
-                   'gui_OutputFcn',  @browse_data_OutputFcn, ...
-                   'gui_LayoutFcn',  [] , ...
-                   'gui_Callback',   []);
-if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once'))              
+    'gui_Singleton',  gui_Singleton, ...
+    'gui_OpeningFcn', @browse_data_OpeningFcn, ...
+    'gui_OutputFcn',  @browse_data_OutputFcn, ...
+    'gui_LayoutFcn',  [] , ...
+    'gui_Callback',   []);
+if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once'))
     gui_State.gui_Callback = str2func(varargin{1});
 end
@@ -74,9 +75,9 @@
 set(hObject, 'Position', FigPos);
 set(hObject, 'Units', OldUnits);
-if exist('MultiDevices','var') && strcmp(MultiDevices,'on')
-    set(handles.DataSeries,'Max',2)
-else
-    set(handles.DataSeries,'Max',1)
-end
+% if exist('MultiDevices','var') && strcmp(MultiDevices,'on')
+%     set(handles.DataSeries,'Max',2)
+% else
+%     set(handles.DataSeries,'Max',1)
+% end
 if exist('EnableMirror','var') && strcmp(EnableMirror,'on')
     set(handles.CreateMirror,'Visible','on')
@@ -91,45 +92,38 @@
     InputDir=pwd;% current dir is the starting data series by default
 end
-% [Experiment,DataSeries,Ext]=fileparts(DataSeries);
-% DataSeries=[DataSeries Ext];
-% [Campaign,Experiment,Ext]=fileparts(Experiment);
-% Experiment=[Experiment Ext];
+
 [ExpWithPath,DataSeries]=fileparts(InputDir);
-[Campaign,Experiment,Ext]=fileparts(ExpWithPath);
-[tild,CampaignName]=fileparts(Campaign);
-RootXml=fullfile(Campaign,[CampaignName '.xml']);
+[Experiment,Device,Ext]=fileparts(ExpWithPath);
+Device=[Device Ext];
+[SourceDir,Experiment,Ext]=fileparts(Experiment);
+Experiment=[Experiment Ext];
+% [tild,CampaignName]=fileparts(Campaign);
+% RootXml=fullfile(Campaign,[CampaignName '.xml']);
 s=[];
-if exist(RootXml,'file')
-    [s,Heading]=xml2struct(RootXml);%read the xml file
-    if isfield(s,'SourceDir')
-        set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened
-        set(handles.MirrorDir,'Visible','on');%  mirror dir display
-        set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir
-        set(handles.CreateMirror,'String','update_mirror')
-    end
-end
+% if exist(RootXml,'file')
+%     [s,Heading]=xml2struct(RootXml);%read the xml file
+%     if isfield(s,'SourceDir')
+%         set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened
+%         set(handles.MirrorDir,'Visible','on');%  mirror dir display
+%         set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir
+%         set(handles.CreateMirror,'String','update_mirror')
+%     end
+% end
 if isempty(s) %a source dir has been opened
-    set(handles.SourceDir,'String',Campaign);
+    set(handles.SourceDir,'String',SourceDir);
     set(handles.MirrorDir,'Visible','off');% no mirror dir display
     set(handles.CreateMirror,'String','create_mirror')
 end
-errormsg=scan_campaign(handles,Campaign,Experiment,ExpWithPath);
+set(handles.DataSeries,'String',{['+/' DataSeries]});
+set(handles.ListDevices,'String',{['+/' Device]});
+errormsg=scan_campaign(handles,SourceDir,['+/' Experiment]);
 if ~isempty(errormsg)
     msgbox_uvmat('ERROR',errormsg)
     return
 end
-% set(handles.OK,'Visible','on')
-% set(handles.Cancel,'Visible','on')
-
-%set(handles.browse_data,'WindowStyle','modal')% Make the GUI
-%modal%%%%%%%%%%%%%%%%%%%%%%%
+
 set(hObject,'Visible','on')
-drawnow
-% UIWAIT makes GUI wait for user response (see UIRESUME)%%%%%%%%%%%%%%%%TO
-% CHECK
-%uiwait(handles.browse_data);
-
-
-
+drawnow      
+        
 %------------------------------------------------------------------------
 % --- Outputs from this function are returned to the command line.
@@ -149,32 +143,32 @@
 [SourcePath,ProjectName]=fileparts(SourceDir);
 if strcmp(get(handles.MirrorDir,'Visible'),'on')
-    MirrorDir=get(handles.MirrorDir,'String');% name of the mirror folder
+MirrorDir=get(handles.MirrorDir,'String');% name of the mirror folder
 else% create the mirror folder if it does not exist
-    MirrorRoot=uigetfile_uvmat('select the folder which must contain the mirror directory:',SourcePath,'uigetdir');
-    if isempty(MirrorRoot)
-        return
-    elseif strcmp(MirrorRoot,SourcePath)
-        msgbox_uvmat('ERROR','The mirror folder must be different from the source')
-        return
-    else
-        MirrorDir=fullfile(MirrorRoot,ProjectName);
-    end
-    if exist(MirrorDir,'dir')
-        msgbox_uvmat('ERROR',['The folder ' MirrorDir ' chosen as new mirror campaign already exists']) 
-        return
-    else
-        [s,errormsg]=mkdir(MirrorDir)% create the mirror dir
-        if s~=1
-            msgbox_uvmat('ERROR',['error in creating ' MirrorDir ': ' errormsg]) 
-            return
-        end
-    end
-    MirrorDoc.SourceDir=SourceDir;
-    t=struct2xml(MirrorDoc);
-    set(t,1,'name','DataTree');
-    save(t,fullfile(MirrorDir,[ProjectName '.xml']))% create an xml file in the mirror folder to indicate its source folder
-    set(handles.MirrorDir,'String',MirrorDir)
-    set(handles.MirrorDir,'Visible','on')
-    set(handles.CreateMirror,'String','update_mirror')
+MirrorRoot=uigetfile_uvmat('select the folder which must contain the mirror directory:',SourcePath,'uigetdir');
+if isempty(MirrorRoot)
+return
+elseif strcmp(MirrorRoot,SourcePath)
+msgbox_uvmat('ERROR','The mirror folder must be different from the source')
+return
+else
+MirrorDir=fullfile(MirrorRoot,ProjectName);
+end
+if exist(MirrorDir,'dir')
+msgbox_uvmat('ERROR',['The folder ' MirrorDir ' chosen as new mirror campaign already exists'])
+return
+else
+[s,errormsg]=mkdir(MirrorDir)% create the mirror dir
+if s~=1
+msgbox_uvmat('ERROR',['error in creating ' MirrorDir ': ' errormsg])
+return
+end
+end
+MirrorDoc.SourceDir=SourceDir;
+t=struct2xml(MirrorDoc);
+set(t,1,'name','DataTree');
+save(t,fullfile(MirrorDir,[ProjectName '.xml']))% create an xml file in the mirror folder to indicate its source folder
+set(handles.MirrorDir,'String',MirrorDir)
+set(handles.MirrorDir,'Visible','on')
+set(handles.CreateMirror,'String','update_mirror')
 end
 ExpName={''};
@@ -182,28 +176,28 @@
 %% update the mirror from the source dir
 if exist(SourceDir,'dir')
-    hdir=dir(SourceDir); %list files and dirs
-    idir=0;
-    for ilist=1:length(hdir)
-        if hdir(ilist).isdir% scan all subfolders
-            dirname=hdir(ilist).name;%
-            if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')%skip subfolder beginning by '0'
-                idir=idir+1;
-                mirror=fullfile(MirrorDir,hdir(ilist).name);% corresponding name in the mirror
-                if ~exist(mirror,'dir')
-                   mkdir(mirror)% create the mirror folder if it does not exist
-                end
-                ExpName{idir}=['+/' hdir(ilist).name];% insert '+/' in the list to show that it is a folder
-            end
-            % look for the list of 'devices'
-        else
-            %warning for isolated files
-        end
-    end
-    set(handles.ListExperiments,'String',[{'*'};ExpName'])
-    set(handles.ListExperiments,'Value',1)
-     update_experiments(handles,[{'*'};ExpName'],SourceDir,MirrorDir)
-   % ListExperiments_Callback(hObject, eventdata, handles) % list the content of the experiment
-else
-    msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a directory'])
+hdir=dir(SourceDir); %list files and dirs
+idir=0;
+for ilist=1:length(hdir)
+if hdir(ilist).isdir% scan all subfolders
+dirname=hdir(ilist).name;%
+if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')%skip subfolder beginning by '0'
+idir=idir+1;
+mirror=fullfile(MirrorDir,hdir(ilist).name);% corresponding name in the mirror
+if ~exist(mirror,'dir')
+mkdir(mirror)% create the mirror folder if it does not exist
+end
+ExpName{idir}=['+/' hdir(ilist).name];% insert '+/' in the list to show that it is a folder
+end
+% look for the list of 'devices'
+else
+%warning for isolated files
+end
+end
+set(handles.ListExperiments,'String',[{'*'};ExpName'])
+set(handles.ListExperiments,'Value',1)
+update_experiments(handles,[{'*'};ExpName'],SourceDir,MirrorDir)
+% ListExperiments_Callback(hObject, eventdata, handles) % list the content of the experiment
+else
+msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a directory'])
 end
 set(handles.SourceDir,'BackgroundColor',[1 1 1])
@@ -212,15 +206,124 @@
 % List the experiments in a campaign, filling the menu ListExperiments
 %------------------------------------------------------------------------
-function errormsg=scan_campaign(handles,Campaign,Experiment,DataInput)
+function errormsg=scan_campaign(handles,SourceDir,Experiment)
 %------------------------------------------------------------------------
 errormsg='';
-if ~isempty(regexp(Campaign,'^http'))|| exist(Campaign,'dir')
-    ListStruct=dir_uvmat(Campaign); %list files and dirs
+if ~isempty(regexp(SourceDir,'^http'))|| exist(SourceDir,'dir')
+    ListStruct=dir_uvmat(SourceDir); %list files and dirs, extende to OpenDAP case
     if numel(ListStruct)>1000% A campaign folder must contain maily a list of 'experiment' sub-folders
-        errormsg=[Campaign ' contains too many items (>1000) to be a Project folder'];
+        errormsg=[SourceDir ' contains too many items (>1000) to be a Project folder'];
         return
     end
+    [ListFiles,index]=list_dir_1(SourceDir,Experiment);
+    set(handles.ListExperiments,'String',ListFiles)
+    set(handles.ListExperiments,'Value',index)% initialise the menu selection with the folder defined by the input
+    ListExperiments_Callback([],[], handles)
+else
+    msgbox_uvmat('ERROR',['The input ' Campaign ' is not a directory'])
+end
+
+%------------------------------------------------------------------------
+% --- Executes on selection change in ListExperiments.
+%------------------------------------------------------------------------
+function ListExperiments_Callback(hObject, eventdata, handles)
+
+if strcmp(get(handles.MirrorDir,'Visible'),'on')
+    SourceDir=get(handles.MirrorDir,'String');
+else
+    SourceDir=get(handles.SourceDir,'String');
+end
+ListExperiments=get(handles.ListExperiments,'String');
+list_val=get(handles.ListExperiments,'Value');
+ListExperiments=ListExperiments(list_val);%choose the selected experiments
+ListDevices=get(handles.ListDevices,'String');% list of devices
+list_val=get(handles.ListDevices,'Value');% currently selected devices
+Device='';
+if numel(ListDevices)>=list_val
+Device=ListDevices(list_val);%choose selected devices
+end
+[ListFiles,indices]=list_dir_2(SourceDir,ListExperiments,Device);
+set(handles.ListDevices,'String',ListFiles)
+set(handles.ListDevices,'Value',indices)% initialise the menu selection with the folder defined by the input
+ListDevices_Callback([],[], handles)
+
+%------------------------------------------------------------------------
+% --- Executes on selection change in ListExperiments.
+%------------------------------------------------------------------------
+function ListDevices_Callback(hObject, eventdata, handles)
+
+ListDevices=get(handles.ListDevices,'String');% list of devices
+list_val=get(handles.ListDevices,'Value');% currently selected devices
+ListDevices=ListDevices(list_val);%choose selected devices
+if strcmp(get(handles.MirrorDir,'Visible'),'on')
+    SourceDir=get(handles.MirrorDir,'String');
+else
+    SourceDir=get(handles.SourceDir,'String');
+end
+ListExperiments=get(handles.ListExperiments,'String');
+list_val=get(handles.ListExperiments,'Value');
+ListExperiments=ListExperiments(list_val);%choose the selected experiments
+
+DataSeries=get(handles.DataSeries,'String');
+list_val=get(handles.DataSeries,'Value');
+if numel(DataSeries)>=list_val
+    DataSeries=DataSeries(list_val);
+else
+    DataSeries=[];
+end
+[ListFiles,indices]=list_dir_3(SourceDir,ListExperiments,ListDevices,DataSeries);
+set(handles.DataSeries,'String',ListFiles)
+set(handles.DataSeries,'Value',indices)% initialise the menu selection with the folder defined by the input
+
+%------------------------------------------------------------------------
+% --- List the DataSeries when a set of experiments is selected
+%------------------------------------------------------------------------
+% function list_dataseries(handles,ListExperiments,MirrorPath)
+% 
+% DataSeries={};
+% for iexp=1:numel(ListExperiments)
+% if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory
+% ListExperiments{iexp}(1)=[];%remove the first char '+' used to mark folders
+% ListStruct=dir(fullfile(MirrorPath,ListExperiments{iexp})); %list files and dir in the source experiment directory
+% ListCells=struct2cell(ListStruct);%transform dir struct to a cell arrray
+% ListFiles=ListCells(1,:);%list of dir and file  names
+% cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
+% cell_remove_tild=regexp(ListFiles,'~$');% detect tild the end of file nqme (do not list)
+% check_keep=cellfun('isempty', cell_remove) & cellfun('isempty', cell_remove_tild);
+% check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
+% for ilist=1:numel(ListFiles)
+%     if check_keep(ilist)% loop on eligible DataSeries folders
+%         mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist});%source folder
+%         if ~exist(mirror,'file') && ~exist(mirror,'dir')% if the name is a broken link
+%             delete(mirror)% delete broken link
+%         else %update the list of dataSeries
+%             [tild,msg]=fileattrib(mirror);
+%             if check_dir(ilist)
+%                 ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list
+%             end
+%             if isempty(find(strcmp(ListFiles{ilist},DataSeries), 1))% if the item is not already in DataSeries
+%                 DataSeries=[DataSeries;ListFiles{ilist}]; %append the item to the list
+%             end
+%         end
+%     end
+% end
+% end
+% end
+% if get(handles.CheckDevices,'Value')
+% set(handles.ListDevices,'Value',1)
+% set(handles.ListDevices,'String',sort(DataSeries))
+% CheckDevices_Callback([],[], handles)
+% else
+% set(handles.DataSeries,'Value',1)
+% set(handles.DataSeries,'String',sort(DataSeries))
+% end
+
+%------------------------------------------------------------------------
+% Provide a list to display
+%------------------------------------------------------------------------
+function [ListFiles,indices]=list_dir_1(SourceDir,ListSub)
+
+    ListStruct=dir_uvmat(SourceDir); %list files and dirs, extende to OpenDAP case
     ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
-    ListFiles=ListCells(1,:);%list of dir and file  names
+    ListFiles=ListCells(1,:);
     check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
     ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
@@ -228,87 +331,87 @@
     check_keep=cellfun('isempty', cell_remove);
     ListFiles=sort((ListFiles(check_keep))');
-    index=find(strcmp(['+/' Experiment],ListFiles));
-    if isempty(index), index=1; end
-    set(handles.ListExperiments,'String',ListFiles)
-    set(handles.ListExperiments,'Value',index)% initialise the menu selection with the folder defined by the input
-    ListExperiments_Callback([],[], handles)
-    DataSeries=get(handles.DataSeries,'String');
-    index=find(strcmp(['+/' DataInput],DataSeries));
-    if isempty(index)
-        index=find(strcmp(['~/' DataInput],DataSeries));
+
+if ischar(ListSub)
+    indices=find(strcmp(ListSub,ListFiles));
+else
+    indices=[];
+    for ilist=1:numel(ListSub)
+        index=find(strcmp(ListSub{ilist},ListFiles));
+        indices=[indices index];
     end
-    if ~isempty(index)
-          set(handles.DataSeries,'Value',index)
+end
+if isempty(indices), indices=1; end
+
+%------------------------------------------------------------------------
+% Provide a list to display
+%------------------------------------------------------------------------
+function [ListFilesTot,indices]=list_dir_2(SourceDir,ListDir,ListSub)
+ListFilesTot={};
+for ilist=1:numel(ListDir)
+    if ~isempty(regexp(ListDir{ilist},'^\+/'))
+    ListDir{ilist}=regexprep(ListDir{ilist},'^\+/','');
+    ListStruct=dir_uvmat(fullfile(SourceDir,ListDir{ilist})); %list files and dirs, extende to OpenDAP case
+    ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
+    ListFiles=ListCells(1,:);
+    check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
+    ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
+    cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
+    check_keep=cellfun('isempty', cell_remove);
+    ListFilesTot=[ListFilesTot;(ListFiles(check_keep))'];
     end
-else
-    msgbox_uvmat('ERROR',['The input ' Campaign ' is not a directory'])
-end
-
-%------------------------------------------------------------------------
-% --- Executes on selection change in ListExperiments.
-%------------------------------------------------------------------------
- function ListExperiments_Callback(hObject, eventdata, handles)
-
-if strcmp(get(handles.MirrorDir,'Visible'),'on')
-    MirrorPath=get(handles.MirrorDir,'String');
-else
-    MirrorPath=get(handles.SourceDir,'String');
-end
-ListExperiments=get(handles.ListExperiments,'String');
-list_val=get(handles.ListExperiments,'Value');
-ListExperiments=ListExperiments(list_val);%choose selected experiments
-list_dataseries(handles,ListExperiments,MirrorPath)
-
-%------------------------------------------------------------------------
-% --- List the DataSeries when a set of experiments is selected
-%------------------------------------------------------------------------
- function list_dataseries(handles,ListExperiments,MirrorPath)
-
-DataSeries={};
-for iexp=1:numel(ListExperiments)
-    if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory
-        ListExperiments{iexp}(1)=[];%remove the first char '+' used to mark folders
-        ListStruct=dir(fullfile(MirrorPath,ListExperiments{iexp})); %list files and dir in the source experiment directory
-        ListCells=struct2cell(ListStruct);%transform dir struct to a cell arrray
-        ListFiles=ListCells(1,:);%list of dir and file  names
-        cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
-        cell_remove_tild=regexp(ListFiles,'~$');% detect tild the end of file nqme (do not list)
-        check_keep=cellfun('isempty', cell_remove) & cellfun('isempty', cell_remove_tild);
-        check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
-        for ilist=1:numel(ListFiles)
-            if check_keep(ilist)% loop on eligible DataSeries folders
-                mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist});%source folder
-                if ~exist(mirror,'file') && ~exist(mirror,'dir')% if the name is a broken link
-                    delete(mirror)% delete broken link
-                else %update the list of dataSeries
-                    [tild,msg]=fileattrib(mirror);
-%                     msg.Name=regexprep(msg.Name,'^/.','/');%remove the dot in /. at the beginning of the name
-%                     if ~strcmp(msg.Name,mirror)% if it is a link
-%                         ListFiles{ilist}=['~' ListFiles{ilist}];%mark link by '@' in the list
-%                     end
-                    if check_dir(ilist)
-                        ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list
-                    end
-                    if isempty(find(strcmp(ListFiles{ilist},DataSeries), 1))% if the item is not already in DataSeries
-                        DataSeries=[DataSeries;ListFiles{ilist}]; %append the item to the list
-                    end                   
-                end
+end
+ListFilesTot=unique(ListFilesTot);
+if ischar(ListSub)
+    indices=find(strcmp(ListSub,ListFilesTot));
+else
+    indices=[];
+    for ilist=1:numel(ListSub)
+        index=find(strcmp(ListSub{ilist},ListFilesTot));
+        indices=[indices index];
+    end
+end
+if isempty(indices), indices=1; end
+
+
+%------------------------------------------------------------------------
+% Provide a list to display
+%------------------------------------------------------------------------
+function [ListFilesTot,indices]=list_dir_3(SourceDir,ListDir,ListSub,ListSubSub)
+ListFilesTot={};
+for ilist=1:numel(ListDir)
+    if ~isempty(regexp(ListDir{ilist},'^\+/'))
+        ListDir{ilist}=regexprep(ListDir{ilist},'^\+/','');
+        for isub=1:numel(ListSub)
+            if ~isempty(regexp(ListSub{isub},'^\+/'))
+                ListSub{isub}=regexprep(ListSub{isub},'^\+/','');
+                ListStruct=dir_uvmat(fullfile(SourceDir,ListDir{ilist},ListSub{isub})); %list files and dirs, extende to OpenDAP case
+                ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
+                ListFiles=ListCells(1,:);
+                check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
+                ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
+                cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
+                check_keep=cellfun('isempty', cell_remove);
+                ListFilesTot=[ListFilesTot;(ListFiles(check_keep))'];
             end
         end
     end
 end
-if get(handles.CheckDevices,'Value')
-    set(handles.ListDevices,'Value',1)
-set(handles.ListDevices,'String',sort(DataSeries))
-CheckDevices_Callback([],[], handles)
-else
-set(handles.DataSeries,'Value',1)
-set(handles.DataSeries,'String',sort(DataSeries))
-end
+ListFilesTot=unique(ListFilesTot);
+if ischar(ListSubSub)
+    indices=find(strcmp(ListSubSub,ListFilesTot));
+else
+    indices=[];
+    for ilist=1:numel(ListSubSub)
+        index=find(strcmp(ListSubSub{ilist},ListFilesTot));
+        indices=[indices index];
+    end
+end
+if isempty(indices), indices=1; end
+
 
 %------------------------------------------------------------------------
 % --- Executes when the mirror is created or updated
 %------------------------------------------------------------------------
- function update_experiments(handles,ListExperiments,CampaignPath,MirrorPath)
+function update_experiments(handles,ListExperiments,CampaignPath,MirrorPath)
 
 DataSeries={};
@@ -344,10 +447,10 @@
                                 if strcmp(answer,'Yes')
                                     delete(mirror);
-                                    system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder                                  
+                                    system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder
                                 end
                             end
                         end
                     else% create mirror to the data series if needed
-                        system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder                     
+                        system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder
                     end
                     if isempty(find(strcmp(ListFiles{ilist},DataSeries), 1))% if the item is not already in DataSeries
@@ -367,5 +470,5 @@
 % --- Executes on button press in CampaignDoc.
 function CampaignDoc_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------   
+%------------------------------------------------------------------------
 answer=msgbox_uvmat('INPUT_Y-N','This function will update the global xml rpresentation of the data set and the Heading of each xml file');
 if ~isequal(answer{1},'OK')
@@ -397,10 +500,10 @@
     ExpName=List.Experiment{iexp}.name;
     t = attributes(t,'add',uid_exp,'DirName',List.Experiment{iexp}.name);
-   
+
     if isfield(List.Experiment{iexp},'Device')
         for idevice=1:length(List.Experiment{iexp}.Device)
             [t,uid_device]=add(t,uid_exp,'element','Device');
             DeviceName=List.Experiment{iexp}.Device{idevice}.name;
-            t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name);       
+            t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name);
             if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
                 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
@@ -413,8 +516,8 @@
                         [t,uid_xml]=add(t,uid_device,'element','ImaDoc');
                         t = attributes(t,'add',uid_xml,'source','file');
-                        [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml});                    
+                        [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml});
                     end
                 end
-             elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
+            elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
                 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
                     RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
@@ -447,32 +550,32 @@
 
 
-%------------------------------------------------------------------------
-% --- Executes on button press in OK.
-%------------------------------------------------------------------------
-function OK_Callback(hObject, eventdata, handles)
-
-if strcmp(get(handles.MirrorDir,'Visible'),'on')
-    Campaign=get(handles.MirrorDir,'String');
-else
-    Campaign=get(handles.SourceDir,'String');
-end
-handles.output=[];
-handles.output.Campaign=Campaign;
-Experiment=get(handles.ListExperiments,'String');
-IndicesExp=get(handles.ListExperiments,'Value');
-if ~isequal(IndicesExp,1)% if first element ('*') selected all the experiments are selected
-    Experiment=Experiment(IndicesExp);% use the selection of the list of experiments
-end
-Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir
-Device=get(handles.DataSeries,'String');
-Value=get(handles.DataSeries,'Value');
-Device=Device(Value);
-Device=regexprep(Device,'^\+/','');% remove the +/ used to mark dir
-Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link
-handles.output.Experiment=Experiment;
-handles.output.DataSeries=Device;
-guidata(hObject, handles);% Update handles structure
-uiresume(handles.browse_data);
-drawnow
+% %------------------------------------------------------------------------
+% % --- Executes on button press in OK.
+% %------------------------------------------------------------------------
+% function OK_Callback(hObject, eventdata, handles)
+% 
+% if strcmp(get(handles.MirrorDir,'Visible'),'on')
+%     Campaign=get(handles.MirrorDir,'String');
+% else
+%     Campaign=get(handles.SourceDir,'String');
+% end
+% handles.output=[];
+% handles.output.Campaign=Campaign;
+% Experiment=get(handles.ListExperiments,'String');
+% IndicesExp=get(handles.ListExperiments,'Value');
+% if ~isequal(IndicesExp,1)% if first element ('*') selected all the experiments are selected
+%     Experiment=Experiment(IndicesExp);% use the selection of the list of experiments
+% end
+% Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir
+% Device=get(handles.DataSeries,'String');
+% Value=get(handles.DataSeries,'Value');
+% Device=Device(Value);
+% Device=regexprep(Device,'^\+/','');% remove the +/ used to mark dir
+% Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link
+% handles.output.Experiment=Experiment;
+% handles.output.DataSeries=Device;
+% guidata(hObject, handles);% Update handles structure
+% uiresume(handles.browse_data);
+% drawnow
 
 %------------------------------------------------------------------------
@@ -491,13 +594,5 @@
 %------------------------------------------------------------------------
 function closefcn(gcbo, eventdata)
-% if isequal(get(handles.browse_data, 'waitstatus'), 'waiting')
-%     % The GUI is still in UIWAIT, us UIRESUME
-%     handles.output = get(hObject,'String');
-%     guidata(hObject, handles); % Update handles structure
-%     uiresume(handles.browse_data);
-% else
-%     % The GUI is no longer waiting, just close it
-%     delete(handles.browse_data);
-% end
+
 hseries=findobj(allchild(0),'Tag','series');
 if ~isempty(hseries)
@@ -511,77 +606,145 @@
 end
 
-%------------------------------------------------------------------------
-% --- Executes on key press over figure1 with no controls selected.
-%------------------------------------------------------------------------
-function browse_data_KeyPressFcn(hObject, eventdata, handles)
+% %------------------------------------------------------------------------
+% % --- Executes on key press over figure1 with no controls selected.
+% %------------------------------------------------------------------------
+% function browse_data_KeyPressFcn(hObject, eventdata, handles)
     
-% Check for "enter" or "escape"
-if isequal(get(hObject,'CurrentKey'),'escape')
-    % User said no by hitting escape
-    handles.output = 'Cancel';
-    
-    % Update handles structure
-    guidata(hObject, handles);
-    
-    uiresume(handles.browse_data);
-end
-if isequal(get(hObject,'CurrentKey'),'return')
-    uiresume(handles.browse_data);
-end 
+% % Check for "enter" or "escape"
+% if isequal(get(hObject,'CurrentKey'),'escape')
+%     % User said no by hitting escape
+%     handles.output = 'Cancel';
+%     
+%     % Update handles structure
+%     guidata(hObject, handles);
+%     
+%     uiresume(handles.browse_data);
+% end
+% if isequal(get(hObject,'CurrentKey'),'return')
+%     uiresume(handles.browse_data);
+% end 
 
 
 % --- Executes on button press in Up.
-function Up_Callback(hObject, eventdata, handles)
-SourceDir=get(handles.SourceDir,'String');
-browse_data(SourceDir)
-
-
-% --- Executes on button press in Down.
 function Down_Callback(hObject, eventdata, handles)
 SourceDir=get(handles.SourceDir,'String');
 ListExperiments=get(handles.ListExperiments,'String');
 list_val=get(handles.ListExperiments,'Value');
-SourceFolder=regexprep(ListExperiments{list_val(1)},'+','');
-set(handles.SourceDir,'String',fullfile(SourceDir,SourceFolder))
+if ischar(ListExperiments)
+    Exp=ListExperiments;
+else
+    Exp=ListExperiments{list_val(1)};
+end
+Exp=regexprep(Exp,'^\+/','');
+SourceDirNew=fullfile(SourceDir,Exp);
+set(handles.SourceDir,'String',SourceDirNew);% New SourceDir
+ListDevices=get(handles.ListDevices,'String');
+DeviceIndices=get(handles.ListDevices,'Value');
+set(handles.ListExperiments,'String',ListDevices);%replace Experiments by Devices
+set(handles.ListExperiments,'Value',DeviceIndices);%replace Experiments by Devices
 DataSeries=get(handles.DataSeries,'String');
-ValueDevice=get(handles.DataSeries,'Value');
-set(handles.ListExperiments,'String',DataSeries)
-set(handles.ListExperiments,'Value',ValueDevice)
-ListExperiments_Callback(hObject, [], handles)
-
-
-% --- Executes on selection change in DataSeries.
-function DataSeries_Callback(hObject, eventdata, handles)
-
-
-% --- Executes on button press in CheckDevices.
-function CheckDevices_Callback(hObject, eventdata, handles)
-if get(handles.CheckDevices,'Value')
-    set(handles.ListDevices,'Visible','on')
-    ListDevices=get(handles.DataSeries,'String');
-    Index=get(handles.DataSeries,'Value');
-    set(handles.ListDevices,'String',ListDevices)
-    set(handles.ListDevices,'Value',Index)
-    set(handles.DataSeries,'Value',1)
-    if strcmp(get(handles.MirrorDir,'Visible'),'on')
-    MirrorPath=get(handles.MirrorDir,'String');
-    else
-    MirrorPath=get(handles.SourceDir,'String');
-    end
-    IndexExperiment=get(handles.ListExperiments,'Value');
-    ListExperiment=get(handles.ListExperiments,'String');
-    Experiment=ListExperiment{get(handles.ListExperiments,'Value')};
-    Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir
-    Experiment=regexprep(Experiment,'^~','');% remove the ~ used to mark symbolic link
-    Device=regexprep(ListDevices{Index},'^\+/','');% remove the +/ used to mark dir
-    Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link
-    DataSeries=dir(fullfile(MirrorPath,Experiment,Device));
-    DataSeriesCell=struct2cell(DataSeries);
-    set(handles.DataSeries,'String',DataSeriesCell(1,:)')
-else
-    ListDevices=get(handles.ListDevices,'String');
-    Index=get(handles.ListDevices,'Value');
-    set(handles.ListDevices,'Visible','off')
-    set(handles.DataSeries,'String',ListDevices)
-    set(handles.DataSeries,'Value',Index)
-end
+list_val=get(handles.DataSeries,'Value');
+set(handles.ListDevices,'String',DataSeries);%replace Devices by DataSeries
+set(handles.ListDevices,'Value',list_val);%replace Devices by DataSeries
+
+[ListFiles,indices]=list_dir_3(SourceDirNew,ListDevices(DeviceIndices),DataSeries(list_val),[]);
+set(handles.DataSeries,'String',ListFiles)
+set(handles.DataSeries,'Value',indices)% initialise the menu selection with the folder defined by the input
+
+
+% --- Executes on button press in Down.
+function Up_Callback(hObject, eventdata, handles)
+SourceDir=get(handles.SourceDir,'String');
+[SourceDir,Exp]=fileparts(SourceDir);
+set(handles.SourceDir,'String',SourceDir)
+
+% set(handles.ListExperiments,'Value',indices)
+%[ListFiles,indices]=list_dir_1(SourceDir,Exp);
+% set(handles.ListExperiments,'String',ListFiles)
+% set(handles.ListExperiments,'Value',indices)
+ListDevices=get(handles.ListDevices,'String');
+DeviceIndices=get(handles.ListDevices,'Value');
+set(handles.DataSeries,'String',ListDevices);
+set(handles.DataSeries,'Value',DeviceIndices);
+
+ListExperiments=get(handles.ListExperiments,'String');
+ExpIndices=get(handles.ListExperiments,'Value');
+set(handles.ListDevices,'String',ListExperiments);
+set(handles.ListDevices,'Value',ExpIndices);
+
+set(handles.ListExperiments,'String',{['+/' Exp]})
+set(handles.ListExperiments,'Value',1)
+
+% ListExperiments=get(handles.ListExperiments,'String');
+% list_val=get(handles.ListExperiments,'Value');
+% SourceFolder=regexprep(ListExperiments{list_val(1)},'+','');
+% set(handles.SourceDir,'String',fullfile(SourceDir,SourceFolder))
+% DataSeries=get(handles.DataSeries,'String');
+% ValueDevice=get(handles.DataSeries,'Value');
+% set(handles.ListExperiments,'String',DataSeries)
+% set(handles.ListExperiments,'Value',ValueDevice)
+% ListExperiments_Callback(hObject, [], handles)
+
+
+% % --- Executes on selection change in DataSeries.
+% function DataSeries_Callback(hObject, eventdata, handles)
+% SourceDir=get(handles.SourceDir,'String');
+% ListData=get(handles.DataSeries,'String');
+% Folder=ListData{get(handles.DataSeries,'Value')};
+% if ~isempty(regexp(Folder,'^\+/'))% if a folder is selected
+%     Folder=regexprep(Folder,'\+/','');
+%     ListExperiments=get(handles.ListExperiments,'String');
+%     list_val=get(handles.ListExperiments,'Value');
+%     for iexp=1:numel(list_val)
+%         ExpName=regexprep(ListExperiments{list_val(iexp)},'\+/','');
+%         FullName=fullfile(SourceDir,ExpName,Folder);
+%         dd=dir(FullName);
+%         check_sub=1;
+%         for idir=1:numel(dd)
+%             ListData{ilist}=dd(ilist).name;
+%             if dd(ilist).isdir && ~strcmp(dd(ilist).name,'.')&& ~strcmp(dd(ilist).name,'..')&& isempty(regexp(dd(ilist).name,'^_LOG'))...
+%                     && isempty(regexp(dd(ilist).name,'^_LOG'))&& isempty(regexp(dd(ilist).name,'^_XML'))
+%                check_sub=1;
+%                ListData{ilist}=['+/' dd(ilist).name];
+%             end
+%         end
+%         if check_sub
+%         set(handles.ListDevices,'String',ListData);
+%                 set(handles.ListDevices,'Visible','on');
+%                 set(handles.DataSeries,'String',ListData)
+%                 break
+%         end
+%     end
+% end
+
+% % --- Executes on button press in CheckDevices.
+% function CheckDevices_Callback(hObject, eventdata, handles)
+% if get(handles.CheckDevices,'Value')
+%     set(handles.ListDevices,'Visible','on')
+%     ListDevices=get(handles.DataSeries,'String');
+%     Index=get(handles.DataSeries,'Value');
+%     set(handles.ListDevices,'String',ListDevices)
+%     set(handles.ListDevices,'Value',Index)
+%     set(handles.DataSeries,'Value',1)
+%     if strcmp(get(handles.MirrorDir,'Visible'),'on')
+%     MirrorPath=get(handles.MirrorDir,'String');
+%     else
+%     MirrorPath=get(handles.SourceDir,'String');
+%     end
+%     IndexExperiment=get(handles.ListExperiments,'Value');
+%     ListExperiment=get(handles.ListExperiments,'String');
+%     Experiment=ListExperiment{get(handles.ListExperiments,'Value')};
+%     Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir
+%     Experiment=regexprep(Experiment,'^~','');% remove the ~ used to mark symbolic link
+%     Device=regexprep(ListDevices{Index},'^\+/','');% remove the +/ used to mark dir
+%     Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link
+%     DataSeries=dir(fullfile(MirrorPath,Experiment,Device));
+%     DataSeriesCell=struct2cell(DataSeries);
+%     set(handles.DataSeries,'String',DataSeriesCell(1,:)')
+% else
+%     ListDevices=get(handles.ListDevices,'String');
+%     Index=get(handles.ListDevices,'Value');
+%     set(handles.ListDevices,'Visible','off')
+%     set(handles.DataSeries,'String',ListDevices)
+%     set(handles.DataSeries,'Value',Index)
+% end
Index: /trunk/src/geometry_calib.m
===================================================================
--- /trunk/src/geometry_calib.m	(revision 1067)
+++ /trunk/src/geometry_calib.m	(revision 1068)
@@ -273,26 +273,58 @@
         hbrowse=findobj(allchild(0),'Tag','browse_data');
         if ~isempty(hbrowse)% look for the GUI 'replicate'
-            BrowseHandles=guidata(hbrowse);
-            SourceDir=get(BrowseHandles.SourceDir,'String');
-            ListExperiments=get(BrowseHandles.ListExperiments,'String');
-            ListValues=get(BrowseHandles.ListExperiments,'Value');
-            ListExperiments=ListExperiments(ListValues);
-            DataSeries=get(BrowseHandles.DataSeries,'String');
-            Val=get(BrowseHandles.DataSeries,'Value');
-            DataFolder=DataSeries{Val};
-            for ilist=1:numel(ListExperiments)
-                SubDirBase=regexprep(DataFolder,'+/','');
-                ListExperiments{ilist}=regexprep(ListExperiments{ilist},'+/','');
-                XmlName=fullfile(SourceDir,ListExperiments{ilist},[SubDirBase '.xml']);
+            BrowseData=guidata(hbrowse);
+            SourceDir=get(BrowseData.SourceDir,'String');
+            ListExp=get(BrowseData.ListExperiments,'String');
+            ExpIndices=get(BrowseData.ListExperiments,'Value');
+            ListExp=ListExp(ExpIndices);
+            ListDevices=get(BrowseData.ListDevices,'String');
+            DeviceIndices=get(BrowseData.ListDevices,'Value');
+            ListDevices=ListDevices(DeviceIndices);
+            ListDataSeries=get(BrowseData.DataSeries,'String');
+            DataSeriesIndices=get(BrowseData.DataSeries,'Value');
+            ListDataSeries=ListDataSeries(DataSeriesIndices);
+            NbExp=0; % counter of the number of experiments set by the GUI browse_data
+            for iexp=1:numel(ListExp)
+                if ~isempty(regexp(ListExp{iexp},'^\+/'))% if it is a folder
+                    for idevice=1:numel(ListDevices)
+                        if ~isempty(regexp(ListDevices{idevice},'^\+/'))% if it is a folder
+                            for isubdir=1:numel(ListDataSeries)
+                                if ~isempty(regexp(ListDataSeries{isubdir},'^\+/'))% if it is a folder
+                                    lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),...
+                                        regexprep(ListDevices{idevice},'^\+/',''));
+                                    ldir= regexprep(ListDataSeries{isubdir},'^\+/','');
+                                    if exist(fullfile(lpath,ldir),'dir')
+                                        NbExp=NbExp+1;
+                                        ListPath{NbExp}=lpath;
+                                        ListSubdir{NbExp}=ldir;
+                                        ExpIndex{NbExp}=iexp;
+                                    end
+                                end
+                            end
+                        end
+                    end
+                end
+            end
+            for iexp=1:NbExp
+                XmlName=fullfile(ListPath{iexp},[ListSubdir{iexp} '.xml']);
+                if exist(XmlName,'file')
+                    check_update=1;
+                else
+                    check_update=0;
+                end
                 errormsg=update_imadoc(GeometryCalib,XmlName,'GeometryCalib');% introduce the calibration data in the xml file
                 if ~strcmp(errormsg,'')
                     msgbox_uvmat('ERROR',errormsg);
                 else
-                    display([XmlName ' updated with calibration parameters'])
+                    if check_update
+                        display([XmlName ' updated with calibration parameters'])
+                    else
+                        display([XmlName ' created with calibration parameters'])
+                    end
                     nbcalib=nbcalib+1;
                 end
             end
         end
-        msgbox_uvmat('CONFIMATION',[SubDirBase ' calibrated for ' num2str(nbcalib) ' experiments']);  
+        msgbox_uvmat('CONFIMATION',['calibration replicated for ' num2str(NbExp) ' experiments']);
     else
         %% copy the xml file from the old location if appropriate, then update with the calibration parameters
Index: /trunk/src/plot_field.m
===================================================================
--- /trunk/src/plot_field.m	(revision 1067)
+++ /trunk/src/plot_field.m	(revision 1068)
@@ -1408,5 +1408,5 @@
     yi=rangy(1):dxy(1):rangy(2);
     A=griddata(vec_X,vec_Y,vec_A,xi,yi'); 
-    A=reshape(A,length(yi),length(xi));
+    A=reshape(A,length(yi),length(xi));total
 else
     x=vec_X(1:index(1));% the set of abscissa (obtained on the first line)
Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 1067)
+++ /trunk/src/series.m	(revision 1068)
@@ -1594,26 +1594,64 @@
 end
 
-%% Look for prcessing on multiple experiments set by the GUI browse_data
-NbExp=1;
-ListExp=Param.InputTable(1,1);
-
+%% Look for processing on multiple experiments set by the GUI browse_data
+NbExp=1;% initiate the number of experiments set by the GUI browse_data, =1 otherwise
 if get(handles.Replicate,'Value')
+    set(handles.Replicate,'BackgroundColor',[1 1 0])%paint Relicate button in yellow
     hh=findobj(allchild(0),'Tag','browse_data');
     BrowseData=guidata(hh);
     SourceDir=get(BrowseData.SourceDir,'String');
     ListExp=get(BrowseData.ListExperiments,'String');
-    ListExp=ListExp(get(BrowseData.ListExperiments,'Value'));
-    NbExp=numel(ListExp) % number of experiments set possibly by the GUI browse_data, =1 otherwise
-    for ilist=1:NbExp
-        ListExp{ilist}=regexprep(ListExp{ilist},'+','');
-        ListExp{ilist}= [SourceDir ListExp{ilist}];
-    end
-end
-
+    ExpIndices=get(BrowseData.ListExperiments,'Value');
+    ListExp=ListExp(ExpIndices);
+    ListDevices=get(BrowseData.ListDevices,'String');
+    DeviceIndices=get(BrowseData.ListDevices,'Value');
+    ListDevices=ListDevices(DeviceIndices);
+    ListDataSeries=get(BrowseData.DataSeries,'String');
+    DataSeriesIndices=get(BrowseData.DataSeries,'Value');
+    ListDataSeries=ListDataSeries(DataSeriesIndices);
+    NbExp=0; % counter of the number of experiments set by the GUI browse_data
+    for iexp=1:numel(ListExp)
+        if ~isempty(regexp(ListExp{iexp},'^\+/'))% if it is a folder
+            for idevice=1:numel(ListDevices)
+                if ~isempty(regexp(ListDevices{idevice},'^\+/'))% if it is a folder
+                    for isubdir=1:numel(ListDataSeries)
+                        if ~isempty(regexp(ListDataSeries{isubdir},'^\+/'))% if it is a folder
+                            lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),...
+                                regexprep(ListDevices{idevice},'^\+/',''));
+                            ldir= regexprep(ListDataSeries{isubdir},'^\+/','');
+                            if exist(fullfile(lpath,ldir),'dir')
+                                NbExp=NbExp+1;
+                                ListPath{NbExp}=lpath;
+                                ListSubdir{NbExp}=ldir;
+                                ExpIndex{NbExp}=iexp;
+                            end
+                        end
+                    end
+                end
+            end
+        end
+    end
+    answer=msgbox_uvmat('INPUT_Y-N-Cancel',['replicate the processing on ' num2str(NbExp) ' data series']);
+    if strcmp(answer,'Cancel')||strcmp(answer,'No')
+        return
+    end
+end
+%      set(handles.OutputSubDir,'String',SubDir)
+%      Param.OutputSubDir=SubDir;
 %%%%%%%%%%%%%%%%%%% LOOP ON EXPERIMENTS POSSIBLY SET BY THE GUI browse_data, NbExp=1 otherwise %%%%%%%%%
 for iexp=1:NbExp
-    Param.InputTable{1,1}=ListExp{iexp};
-    set(handles.InputTable,'Data',Param.InputTable)
-    [xx,ExpName]=fileparts(ListExp{iexp});
+    if get(handles.Replicate,'Value')
+        if ~strcmp(get(handles.RUN,'BusyAction'),'queue')% allow for STOP action
+            disp('program stopped by user')
+            return
+        end
+        set(BrowseData.ListExperiments,'Value',ExpIndex{iexp})
+        Param.InputTable{1,1}=ListPath{iexp};
+        Param.InputTable{1,2}=ListSubdir{iexp};
+        Param.OutputSubDir=ListSubdir{iexp};
+        set(handles.InputTable,'Data',Param.InputTable)
+%         set(handles.OutputSubDir,'String',ListSubdir{iexp})
+    end
+    [xx,ExpName]=fileparts(Param.InputTable{1,1});
     Param.IndexRange.first_i=str2num(get(handles.num_first_i,'String'));%reset the firrst_i and last_i for multiple experiments, modified by the splitting into NbProcess
     Param.IndexRange.last_i=str2num(get(handles.num_last_i,'String'));
@@ -1621,5 +1659,5 @@
     OutputDir='';
     answer='';
-    if isfield(Param,'OutputSubDir')
+    if isfield(Param,'OutputSubDir')% possibly update the output dir if it already exists
         SubDirOut=[get(handles.OutputSubDir,'String') Param.OutputDirExt];
         SubDirOutNew=SubDirOut;
@@ -1659,5 +1697,5 @@
         Param.OutputRootFile=Param.InputTable{1,3}; % the first sorted RootFile taken for output
         set(handles.OutputDirExt,'String',Param.OutputDirExt)
-        OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]); % full name (with path) of output directory
+        OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]) % full name (with path) of output directory
         if check_create    % create output directory if it does not exist
             [tild,msg1]=mkdir(OutputDir);
@@ -1677,4 +1715,8 @@
             errormsg=['cannot create ' DirXml ': ' msg1]; % error message for directory creation
             return
+        end
+        [success,msg] = fileattrib(DirXml,'+w','g','s'); % allow writing access for the group of users, recursively in the folder
+        if success==0
+            msgbox_uvmat('WARNING',{['unable to set group write access to ' DirXml ':']; msg}); % error message for directory creation
         end
     end
@@ -1861,4 +1903,8 @@
                 return
             end
+            [success,msg] = fileattrib(DirExe,'+w','g','s'); % allow writing access for the group of users, recursively in the folder
+            if success==0
+                msgbox_uvmat('WARNING',{['unable to set group write access to ' DirExe ':']; msg}); % error message for directory creation
+            end
         end
         %create subdirectory for log files
@@ -1869,4 +1915,8 @@
                 errormsg=['cannot create ' DirLog ': ' msg1]; % error message for directory creation
                 return
+            end
+            [success,msg] = fileattrib(DirLog,'+w','g','s'); % allow writing access for the group of users, recursively in the folder
+            if success==0
+                msgbox_uvmat('WARNING',{['unable to set group write access to ' DirLog ':']; msg}); % error message for directory creation
             end
         end
@@ -2024,7 +2074,7 @@
             fclose(fid);
             if status==0
-            msgbox_uvmat('CONFIRMATION',[ActionFullName ' launched for ' ExpName ' as ' num2str(NbProcess) ' processes in cluster: press STATUS to see results'])
+                msgbox_uvmat('CONFIRMATION',[ActionFullName ' launched for ' ExpName ' as ' num2str(NbProcess) ' processes in cluster: press STATUS to see results'])
             else
-               msgbox_uvmat('ERROR',result) 
+                msgbox_uvmat('ERROR',result)
             end
             %     case 'cluster_pbs' % for LMFA Kepler machine:  trqnsferred to fct
@@ -2144,4 +2194,8 @@
     end
 end
+set(handles.Replicate,'BackgroundColor',[0 1 0])
+if NbExp>1
+    set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta (input file features need to be updated)
+end
 %------------------------------------------------------------------------
 function STOP_Callback(hObject, eventdata, handles)
@@ -2160,5 +2214,5 @@
 Param=read_GUI(handles.series);
 
-%% clean the output structure by removing unused information 
+%% clean the output structure by removing unused information
 if isfield(Param,'Pairs')
     Param=rmfield(Param,'Pairs'); % info Pairs not needed for output
@@ -2203,5 +2257,5 @@
 ActionList=get(handles.ActionName,'String'); % list menu fields
 ActionIndex=get(handles.ActionName,'Value');
-if ~isequal(ActionIndex,1)% if we are not just opening series 
+if ~isequal(ActionIndex,1)% if we are not just opening series
     InputTable=get(handles.InputTable,'Data');
     if isempty(InputTable{1,4})
@@ -2301,4 +2355,5 @@
 
 set(handles.ActionInput,'BackgroundColor',[1 1 0])
+SeriesData=get(handles.series,'UserData'); % info on the input file series
 
 %% create the function handle for Action
@@ -2308,5 +2363,4 @@
 if ~exist(ActionPath,'dir')
     ActionName_Callback(handles.ActionName, ActionPath, handles)% update the function
-%     msgbox_uvmat('ERROR',['The prescribed function path ' ActionPath ' does not exist']);
     return
 end
@@ -2319,4 +2373,5 @@
 Param=read_GUI_series(handles); % read the parameters from the GUI series
 Param.Action.RUN=0;
+Param.SeriesData=SeriesData;
 ParamOut=h_fun(Param); % run the selected Action function to get the relevant input
 
@@ -2337,5 +2392,4 @@
 
 %% Detect the types of input files and set menus and default options in 'VelType'
-SeriesData=get(handles.series,'UserData'); % info on the input file series
 iview_civ=find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType));
 iview_netcdf=find(strcmp('netcdf',SeriesData.FileType)|strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType)); % all nc files, icluding civ
@@ -2469,7 +2523,12 @@
     set(handles.MinIndex_j,'Data',MinIndex_j(iview,:));
     set(handles.MaxIndex_i,'Data',MaxIndex_i(iview,:));
-    set(handles.MaxIndex_j,'Data',MaxIndex_j(iview,:));
+    set(handles.MaxIndex_j,'Data',MaxIndex_j(iview,:));;
     TimeTable=get(handles.TimeTable,'Data');
-    set(handles.TimeTable,'Data',TimeTable(iview,:));
+    if size(TimeTable,1)<size(Param.InputTable,1)%if the time table is not complete, copy the missing lines from the previous ones
+        for iline=size(TimeTable,1)+1:size(Param.InputTable,1)
+            TimeTable(iline,:)=TimeTable(iline-1,:);
+        end
+    end
+    set(handles.TimeTable,'Data',TimeTable(iview,:));% sort the time tables
     PairString=get(handles.PairString,'Data');
     set(handles.PairString,'Data',PairString(iview,:));
Index: /trunk/src/series/civ_series.m
===================================================================
--- /trunk/src/series/civ_series.m	(revision 1067)
+++ /trunk/src/series/civ_series.m	(revision 1068)
@@ -89,5 +89,39 @@
     end
     % estimated CPUTime
-Data.CPUTime=1; % 1 minute per field pair
+    CPUtime_unit=0.01;%estimated time for a multiplication (in microsecond)
+    if isfield(Param.SeriesData,'FileInfo')&&isfield(Param.SeriesData.FileInfo{1},'Height')&&isfield(Param.SeriesData.FileInfo{1},'Width')
+        pixnbre=Param.SeriesData.FileInfo{1}.Height*Param.SeriesData.FileInfo{1}.Width; % total number of pxels for input images  
+        CPUtime=0;
+        if isfield(Data.ActionInput,'Civ1')
+            %BoxSize=Data.ActionInput.Civ1.CorrBoxSize(1)*Data.ActionInput.Civ1.CorrBoxSize(2);
+            tic
+            testboxa=rand(Data.ActionInput.Civ1.CorrBoxSize(1),Data.ActionInput.Civ1.CorrBoxSize(2));
+            testboxb=rand(Data.ActionInput.Civ1.SearchBoxSize(1),Data.ActionInput.Civ1.SearchBoxSize(2));
+            anss=conv2(testboxa,testboxb);
+            CPUtime_unit=toc;
+            nb_box=pixnbre/(Data.ActionInput.Civ1.Dx*Data.ActionInput.Civ1.Dy);    
+            %nbpos=Data.ActionInput.Civ1.SearchBoxSize-Data.ActionInput.Civ1.CorrBoxSize;
+            CPUtime=2*CPUtime_unit*nb_box%*BoxSize*nbpos(1)*nbpos(2);% adjustement factor 2 used
+        end
+        if isfield(Data.ActionInput,'Patch1')
+            CPUtime=2*CPUtime;
+        end
+        if isfield(Data.ActionInput,'Civ2')
+            tic
+            testboxa=rand(Data.ActionInput.Civ2.CorrBoxSize(1),Data.ActionInput.Civ2.CorrBoxSize(2));
+            testboxb=rand(Data.ActionInput.Civ2.SearchBoxSize(1),Data.ActionInput.Civ2.SearchBoxSize(2));
+            anss=conv2(testboxa,testboxb);
+            CPUtime_unit=toc;
+            nb_box=pixnbre/(Data.ActionInput.Civ2.Dx*Data.ActionInput.Civ2.Dy);
+            %BoxSize=Data.ActionInput.Civ2.CorrBoxSize(1)*Data.ActionInput.Civ2.CorrBoxSize(2);
+            %nbpos=Data.ActionInput.Civ2.SearchBoxSize-Data.ActionInput.Civ2.CorrBoxSize;
+            CPUtime=CPUtime+2*CPUtime_unit*nb_box;%*BoxSize*nbpos(1)*nbpos(2);
+        end
+        if isfield(Data.ActionInput,'Patch2')
+            CPUtime=(4/3)*CPUtime;
+        end
+        Data.CPUTime=ceil(CPUtime/6); % estimated CPU time per field pair in minute
+        Data.CPUTime=Data.CPUTime/10; % displqy CPU time with 1 digit beyond dot
+    end
     return
 end
Index: /trunk/src/series/extract_multitif.m
===================================================================
--- /trunk/src/series/extract_multitif.m	(revision 1067)
+++ /trunk/src/series/extract_multitif.m	(revision 1068)
@@ -73,5 +73,6 @@
     ParamOut.OutputDirExt='.png';%set the output dir extension
     ParamOut.OutputFileMode='NbSlice';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
-      ParamOut.CheckOverwriteVisible='on'; % manage the overwrite of existing files (default=1)
+    ParamOut.CheckOverwriteVisible='on'; % manage the overwrite of existing files (default=1)
+    ParamOut.CPUTime=7;% expected time for writting one image ( in minute)
     %% root input file(s) and type
     % check the existence of the first file in the series
@@ -113,24 +114,4 @@
 end
 
-%% list of input images
-% DirImages=fullfile(Param.InputTable{1,1},Param.InputTable{1,2});
-% ListStruct=dir(DirImages);
-% ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
-% check_bad=strcmp('.',ListCells(1,:))|strcmp('..',ListCells(1,:));%detect the dir '.' to exclude it
-% check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
-% ListFile=ListCells(1,find(~check_dir & ~check_bad));
-
-%% check file names
-% RootName=regexprep(ListFile{1},'.tif$','')
-% rank(1)=1;
-% for ilist=2:numel(ListFile)
-%     rank_str=regexprep(ListFile{ilist},'.tif$','');
-%     rank(ilist)=regexprep(rank_str,['^' RootName '@'],'');
-% %     if ~isequal(str2num(rank),ilist-1)
-% %         disp(['error in the list of input file # ' num2str(ilist-1)])
-% %         return
-% %     end
-% end
-
 %% output directory
 OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]);
@@ -156,10 +137,4 @@
 end
 
-%% Main loop
-
-
-% count=0;
-%count=316;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%CORRECTION EXP08: 4684 images -> start at 316 start 67->_11_1
-%count=1934%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%CORRECTION EXP07: 3066 images
 %% loop on the files
 % include the first tiff file with no index in the first iteration
@@ -174,4 +149,5 @@
 end
 for ifile=firstindex:Param.IndexRange.last_i
+    tic
     if firstindex==0 && ifile==0% first slice of processing
         ImageName=fullfile(Param.InputTable{1,1},Param.InputTable{1,2},'im.tif')
@@ -181,5 +157,4 @@
     NbFrames=numel(imfinfo(ImageName));
     for iframe=1:NbFrames
-        iframe
         if isequal(ImagesPerLevel,1)% mode series
             OutputFile=fullfile(OutputDir,['img_' num2str(count+1) '.png']);
@@ -198,4 +173,7 @@
         count=count+1;
     end
+    tt=toc;
+    disp(['elapsed time (in min.) for the file im@' num2str(ifile,'%04d')])
+    disp(num2str(tt/60))
 end
 
Index: /trunk/src/series/extract_rdvision.m
===================================================================
--- /trunk/src/series/extract_rdvision.m	(revision 1067)
+++ /trunk/src/series/extract_rdvision.m	(revision 1068)
@@ -489,12 +489,12 @@
 
 %% correct NbDtj and NbDti (error from RDvision)
-if NbDtj==numel(Dtj)% case of bursts
-    NbDtj=1;
-    uid_motor_nbslice=find(t,'ImaDoc/TranslationMotor/Nbslice');
-    if ~isempty(uid_motor_nbslice)&& ~isempty(uid_Dtk)% case of multilevel
-        NbSlice=str2num(get(t,get(t,uid_motor_nbslice,'contents'),'value'));
-        NbDti=NbSlice-1;
-    end
-end
+% if NbDtj==numel(Dtj)% case of bursts
+%     NbDtj=1;
+%     uid_motor_nbslice=find(t,'ImaDoc/TranslationMotor/Nbslice');
+%     if ~isempty(uid_motor_nbslice)&& ~isempty(uid_Dtk)% case of multilevel
+%         NbSlice=str2num(get(t,get(t,uid_motor_nbslice,'contents'),'value'));
+%         NbDti=NbSlice-1;
+%     end
+% end
 
 if isempty(Dtj)% case of simple series
@@ -509,40 +509,40 @@
     nbfield2=NbDtj*numel(Dtj)+1;
     NbFrames_xml=nbfield1*nbfield2;
-   if NbFrames_xml<numel(timestamp)
-       disp(['ERROR: size from xml ' num2str(NbFrame_xml) ' smaller than timestamp size ' num2str(numel(timestamp))])
-       return
-   end
-   if NbFrames_xml>numel(timestamp)
-       nbfield1=floor(numel(timestamp)/nbfield2);
-       nbfieldk=floor(nbfield1/nbfieldi);
-       nbfield1=nbfieldi*nbfieldk;
-       NbDtk=nbfieldk-1;
-       t=set(t,uid_content_NbDtk,'value',num2str(NbDtk));% correct NbDtk in the xml file (in practice numel(Dtk)=1;
-       timestamp=timestamp(1:nbfield1*nbfield2);
-       disp(['image record stopped before end: max index i= ' num2str(nbfield1)]);
-       timestamp=reshape(timestamp,nbfield2,nbfield1);
-   end
-   % check Dtj with respect to timestamp
-    timestamp=(reshape(timestamp,nbfield2,[]))';
-    diff_Dtj=diff(timestamp(1,:))-Dtj;
-    if max(abs(diff_Dtj))>min(Dtj)/1000
-        disp(['Dtj from xml file differs from time stamp by ' num2str(max(abs(diff_Dtj))) ', '])%'
-    else
-        disp('Dtj OK');
-    end
+%    if NbFrames_xml<numel(timestamp)
+%        disp(['ERROR: size from xml ' num2str(NbFrame_xml) ' smaller than timestamp size ' num2str(numel(timestamp))])
+%        return
+%    end
+%    if NbFrames_xml>numel(timestamp)
+%        nbfield1=floor(numel(timestamp)/nbfield2);
+%        nbfieldk=floor(nbfield1/nbfieldi);
+%        nbfield1=nbfieldi*nbfieldk;
+%        NbDtk=nbfieldk-1;
+%        t=set(t,uid_content_NbDtk,'value',num2str(NbDtk));% correct NbDtk in the xml file (in practice numel(Dtk)=1;
+%        timestamp=timestamp(1:nbfield1*nbfield2);
+%        disp(['image record stopped before end: max index i= ' num2str(nbfield1)]);
+%        timestamp=reshape(timestamp,nbfield2,nbfield1);
+%    end
+%    % check Dtj with respect to timestamp
+%     timestamp=(reshape(timestamp,nbfield2,[]))';
+%     diff_Dtj=diff(timestamp(1,:))-Dtj;
+%     if max(abs(diff_Dtj))>min(Dtj)/1000
+%         disp(['Dtj from xml file differs from time stamp by ' num2str(max(abs(diff_Dtj))) ', '])%'
+%     else
+%         disp('Dtj OK');
+%     end
 end
 
 %% adjust Dti
-if NbDti+1>size(timestamp,1)
-    NbDti=size(timestamp,1)-1;
-end
-Dti_stamp=(timestamp(1+NbDti,1)-timestamp(1,1))/NbDti;
-Dti_stamp=(timestamp(1+NbDti,1)-timestamp(2,1))/(NbDti-1);
-t=set(t,uid_content_Dti,'value',num2str(Dti_stamp));%corret Dti
-if abs(Dti_stamp-Dti)>Dti/1000
-    disp([msg 'Dti from xml file corrected by ' num2str(Dti_stamp-Dti) ', ']);%'
-else
-    disp('Dti OK')
-end
+% if NbDti+1>size(timestamp,1)
+%     NbDti=size(timestamp,1)-1;
+% end
+% Dti_stamp=(timestamp(1+NbDti,1)-timestamp(1,1))/NbDti;
+% Dti_stamp=(timestamp(1+NbDti,1)-timestamp(2,1))/(NbDti-1);
+% t=set(t,uid_content_Dti,'value',num2str(Dti_stamp));%corret Dti
+% if abs(Dti_stamp-Dti)>Dti/1000
+%     disp([msg 'Dti from xml file corrected by ' num2str(Dti_stamp-Dti) ', ']);%'
+% else
+%     disp('Dti OK')
+% end
 
 %% adjust Dtk
Index: /trunk/src/series/merge_proj_polar.m
===================================================================
--- /trunk/src/series/merge_proj_polar.m	(revision 1067)
+++ /trunk/src/series/merge_proj_polar.m	(revision 1068)
@@ -63,5 +63,5 @@
     ParamOut.AllowInputSort='on';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
     ParamOut.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
-    ParamOut.NbSlice='on'; %nbre of slices ('off' by default)
+    ParamOut.NbSlice='off'; %nbre of slices ('off' by default)
     ParamOut.VelType='one';% 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)
@@ -268,8 +268,6 @@
     CheckOverwrite=Param.CheckOverwrite;
 end
-
+NbField 
 for index=1:NbField
-    disp(['index=' num2str(index)])
-    disp(['ellapsed time ' num2str(toc(tstart)/60,4) ' minutes'])
     update_waitbar(WaitbarHandle,index/NbField)
     if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
@@ -352,8 +350,12 @@
         %% calculate tps coefficients
         Data{iview}=tps_coeff_field(Data{iview},1);
-        
+        'tps_coeff done'
         %% projection on the polar grid
         [DataOut,VarAttribute,errormsg]=calc_field_tps(Data{iview}.Coord_tps,Data{iview}.NbCentre,Data{iview}.SubRange,...
             cat(3,Data{iview}.U_tps,Data{iview}.V_tps),FieldNames,cat(3,XI,YI));
+        if ~isempty(errormsg)
+            disp(errormsg)
+        end
+        
         % set to NaN interpolation points which are too far from any initial data (more than 2 CoordMesh)
         Coord=permute(Data{iview}.Coord_tps,[1 3 2]);
@@ -366,4 +368,5 @@
             G=TriScatteredInterp(Coord,Coord(:,2),'nearest');
         end
+        'Interp done'
         Distx=F(XI,YI)-XI;% diff of x coordinates with the nearest measurement point
         Disty=G(XI,YI)-YI;% diff of y coordinates with the nearest measurement point
@@ -390,4 +393,5 @@
     
     %% merge the NbView fields
+    ProjData
     [MergeData,errormsg]=merge_field(ProjData);
     if ~isempty(errormsg)
@@ -446,5 +450,5 @@
        TimeData.div=MergeData.div;
 
-            [error,ncid]=struct2nc(OutputFile,TimeData);%save result file
+            error=struct2nc(OutputFile,TimeData);%save result file
         if isempty(error)
             disp(['output file ' OutputFile ' written'])
@@ -453,9 +457,7 @@
         end
             ellapsed_time=toc(tstart);
-    disp(['total ellapsed time ' num2str(ellapsed_time/60,2) ' minutes'])
-end
-
-ellapsed_time=toc(tstart);
-disp(['total ellapsed time ' num2str(ellapsed_time/60,2) ' minutes'])
+    disp(['ellapsed time since start ' num2str(ellapsed_time/60,2) ' minutes'])
+end
+
 disp([ num2str(ellapsed_time/(60*NbField),3) ' minutes per iteration'])
 
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 1067)
+++ /trunk/src/uvmat.m	(revision 1068)
@@ -254,7 +254,7 @@
 
 %% case of an input argument for uvmat
-testinputfield=0;
+%testinputfield=0;
 inputfile=[];
-Field=[];
+%Field=[];
 if exist('input','var')
     if ishandle(handles.UVMAT_title)
@@ -790,5 +790,5 @@
 %aviobj=avifile(MovieName,'Compression','None','fps',fps);
 
-aviobj = VideoWriter(MovieName,'Uncompressed AVI');
+aviobj = VideoWriter(MovieName,'Motion JPEG AVI');
 open(aviobj)
 %% get info from uvmat and adjust it
@@ -812,5 +812,4 @@
             set(htitle,'String',regexprep(Title,'t=\d+.\d*',['t=' time_str]))
             mov=getframe(figure_movie);
-           % aviobj=addframe(aviobj,mov);
             writeVideo(aviobj,mov);
     end
