Index: trunk/src/browse_data.m
===================================================================
--- trunk/src/browse_data.m	(revision 1069)
+++ trunk/src/browse_data.m	(revision 1070)
@@ -25,5 +25,5 @@
 function varargout = browse_data(varargin)
 
-% Last Modified by GUIDE v2.5 08-Jul-2019 23:32:39
+% Last Modified by GUIDE v2.5 11-Jul-2019 18:52:06
 
 % Begin initialization code - DO NOT EDIT
@@ -35,5 +35,5 @@
     'gui_LayoutFcn',  [] , ...
     'gui_Callback',   []);
-if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once'))
+if nargin && ischar(varargin{1}) 
     gui_State.gui_Callback = str2func(varargin{1});
 end
@@ -45,4 +45,5 @@
 end
 % End initialization code - DO NOT EDIT
+
 
 %------------------------------------------------------------------------
@@ -146,4 +147,17 @@
 varargout{1} = handles.output;
 %%%%%%%%%%%%%%%%%%delete(handles.browse_data)
+
+%------------------------------------------------------------------------
+% --- Executes on button press in SourceDir.
+function SourceDir_Callback(hObject, eventdata, handles)
+SourceDir=get(handles.SourceDir,'String');
+ListExp=get(handles.ListExperiments,'String');
+ListExp=ListExp(get(handles.ListExperiments,'Value'));
+errormsg=scan_campaign(handles,SourceDir,ListExp);
+if ~isempty(errormsg)
+    msgbox_uvmat('ERROR',errormsg)
+    return
+end
+%------------------------------------------------------------------------
 
 %------------------------------------------------------------------------
@@ -397,7 +411,12 @@
 
 %------------------------------------------------------------------------
-% Provide a list to display
+% Provide the list (ListFilesTot) to display in DataSeries with the selected indices
 %------------------------------------------------------------------------
 function [ListFilesTot,indices]=list_dir_3(SourceDir,ListDir,ListSub,ListSubSub,check_fix)
+% INPUT:
+%SourceDir: path to the displayed directories
+%ListDir: list of file and folder names under SourceDir (column 'Experiments')
+%ListSub: list of file and folder in the second column 'Devices')
+%ListSubSub: prvious list of file and folder in the third column 'DataSeries', used to mark the selected indices
 ListFilesTot={};
 for ilist=1:numel(ListDir)
@@ -410,9 +429,15 @@
                 ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
                 ListFiles=ListCells(1,:);
+                check_xml=~cellfun('isempty',regexp(ListFiles,'(\.xml|~)$'));% detect non xml files and files not marked by ~
                 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
+                nbfiles=numel(find(~check_xml & ~check_dir));% number of non xml files
+                check_dir=check_dir & cellfun('isempty', regexp(ListFiles,'^(-|\.|\+/\.)'));% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
                 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))];
+                %cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )         
+                ListFiles=ListFiles(check_dir | check_xml);           
+                ListFilesTot=[ListFilesTot ListFiles];
+                if nbfiles>0
+                    ListFilesTot=[ListFilesTot {[num2str(nbfiles) ' files']}];
+                end
             end
         end
@@ -426,4 +451,8 @@
     for ilist=1:numel(ListSubSub)
         index=find(strcmp(ListSubSub{ilist},ListFilesTot));
+        if check_fix && isempty(index)
+            ListFilesTot=[ListFilesTot {['---' ListSubSub{ilist}]}];
+            index=numel(ListFilesTot);
+        end
         indices=[indices index];
     end
@@ -676,5 +705,5 @@
 set(handles.ListDevices,'Value',list_val);%replace Devices by DataSeries
 
-[ListFiles,indices]=list_dir_3(SourceDirNew,ListDevices(DeviceIndices),DataSeries(list_val),[]);
+[ListFiles,indices]=list_dir_3(SourceDirNew,ListDevices(DeviceIndices),DataSeries(list_val),[],0);
 set(handles.DataSeries,'String',ListFiles)
 set(handles.DataSeries,'Value',indices)% initialise the menu selection with the folder defined by the input
@@ -777,2 +806,12 @@
 %     set(handles.DataSeries,'Value',Index)
 % end
+
+
+% --- Executes when user attempts to close browse_data.
+function browse_data_CloseRequestFcn(hObject, eventdata, handles)
+% hObject    handle to browse_data (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Hint: delete(hObject) closes the figure
+delete(hObject);
