Index: trunk/src/series.m
===================================================================
--- trunk/src/series.m	(revision 935)
+++ trunk/src/series.m	(revision 937)
@@ -467,8 +467,7 @@
 %% look for the previously opened file 'oldfile'
 InputTable=get(handles.InputTable,'Data');
-RootPathCell=InputTable(:,1);
-SubDirCell=InputTable(:,2);
+if ~isempty(InputTable)
 oldfile=fullfile(InputTable{1,1},InputTable{1,2});
-if isempty(oldfile)
+else
     % use a file name stored in prefdir
     dir_perso=prefdir;
@@ -476,6 +475,6 @@
     if exist(profil_perso,'file')
         h=load (profil_perso);
-        if isfield(h,'RootPath') && ischar(h.RootPath)
-            oldfile=h.RootPath;
+        if isfield(h,'MenuCampaign') && ~isempty(h.MenuCampaign)&& ischar(h.MenuCampaign{1})
+            oldfile=h.MenuCampaign{1};
         end
     end
@@ -519,81 +518,8 @@
 REFRESH_Callback(hObject, eventdata, handles)
 
-
-% %------------------------------------------------------------------------
-% % --- fct activated by the browser under 'Open campaign/Browse...'
-% %------------------------------------------------------------------------ 
-% function MenuBrowseCampaignAppend_Callback(hObject, eventdata, handles)
-% append='append';
-% browse_campaign(handles,append);
-
-% %------------------------------------------------------------------------
-% function browse_campaign(handles,append);
-% 
-% %% look for the previously opened file 'oldfile'
-% 
-% % 
-% % 
-% % InputTable=get(handles.InputTable,'Data');
-% % RootPath=InputTable{1,1};
-% % CampaignPath=fileparts(fileparts(RootPath));
-% % DirFull=uigetfile_uvmat('define this path as the Campaign folder:',CampaignPath,'uigetdir');
-% % if ~ischar(DirFull)|| ~exist(DirFull,'dir')
-% %     return
-% % end
-% OutPut=browse_data(oldfile);% open the GUI browse_data to get select a campaign dir, experiment and device
-% if ~isfield(OutPut,'Campaign')
-%     return
-% end
-% DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
-% ListStruct=dir(DirName); %list files and the dir DataSeries
-% % select the first appropriate file in the dir
-% FileName='';
-% for ilist=1:numel(ListStruct)
-%     if ~isequal(ListStruct(ilist).isdir,1)%look for files, not dir
-%         FileName=ListStruct(ilist).name;
-%         FileInfo=get_file_info(fullfile(DirName,FileName));
-%         switch FileInfo.FileType
-%             case {'image','multimage','civx','civdata','netcdf'}
-%                 break
-%         end
-%     end
-% end
-% if isempty(FileName)
-%     msgbox_uvmat('ERROR',['no appropriate input file in the DataSeries folder ' fullfile(DirName)])
-%     return
-% end
-% 
-% %% update the list of campaigns in the menubar
-% MenuCampaign=[{get(handles.MenuCampaign_1,'Label')};{get(handles.MenuCampaign_2,'Label')};...
-%     {get(handles.MenuCampaign_3,'Label')};{get(handles.MenuCampaign_4,'Label')};{get(handles.MenuCampaign_5,'Label')}];
-% check_dir=isempty(find(strcmp(DirName,MenuCampaign)));
-% if check_dir %insert the new campaign in the list if it is not found
-%     MenuCampaign(end)=[]; %suppress the last item
-%     MenuCampaign=[{DirName};MenuCampaign];%insert the new campaign
-%     for ilist=1:numel(MenuCampaign)
-%         set(handles.(['MenuCampaign_' num2str(ilist)]),'Label',MenuCampaign{ilist})
-%     end
-%     % save the list for future opening:
-%     dir_perso=prefdir;
-%     profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
-%     if exist(profil_perso,'file')
-%         save (profil_perso,'MenuCampaign','-append'); %store the file names for future opening of uvmat
-%     else
-%         save (profil_perso,'MenuCampaign','-V6'); %store the file names for future opening of uvmat
-%     end
-% end
-% 
-% %% display the selected field and related information
-% if get(handles.CheckAppend,'Value')
-%     display_file_name(handles,fullfile(DirName,FileName),'append')
-% else
-%     display_file_name(handles,fullfile(DirName,FileName),'one')
-% end
-% set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
-
 % --------------------------------------------------------------------
 function MenuCampaign_Callback(hObject, eventdata, handles)
 % -------------------------------------------------------------------- 
-set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])
+
 OutPut=browse_data(get(hObject,'Label'),'on','on');% open the GUI browse_data to get select a campaign dir, experiment and device
 if ~isfield(OutPut,'Campaign')
@@ -636,24 +562,4 @@
 set(handles.InputTable,'Data',InputTable)
 REFRESH_Callback(hObject, eventdata, handles)
-
-
-% DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
-% hdir=dir(DirName); %list files and dirs
-% for ilist=1:numel(hdir)
-%     if ~isequal(hdir(ilist).isdir,1)%look for files, not dir
-%         FileName=hdir(ilist).name;
-%         FileInfo=get_file_info(fullfile(DirName,FileName));
-%         switch FileInfo.FileType
-%             case {'image','multimage','civx','civdata','netcdf'}
-%             break
-%         end
-%     end
-% end
-% if get(handles.CheckAppend,'Value')
-%     display_file_name(handles,fullfile(DirName,FileName),'append')
-% else
-%     display_file_name(handles,fullfile(DirName,FileName),'one')
-% end
-% set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
 
 
@@ -816,5 +722,5 @@
 
 %% enable other menus and uicontrols
-set(handles.MenuOpenCampaign,'Enable','on')
+% set(handles.MenuOpenCampaign,'Enable','on')
 set(handles.MenuCampaign_1,'Enable','on')
 set(handles.MenuCampaign_2,'Enable','on')
@@ -1006,5 +912,5 @@
 ref_i=1;
 if isfield(SeriesData,'ref_i')
-ref_i=SeriesData.ref_i;
+    ref_i=SeriesData.ref_i;
 end
 if isempty(first_i)
@@ -1019,5 +925,5 @@
 ref_j=1;
 if isfield(SeriesData,'ref_j')
-ref_j=SeriesData.ref_j;
+    ref_j=SeriesData.ref_j;
 end
 if isempty(first_j)
@@ -1046,14 +952,14 @@
     last_j=first_j;
 end
-set(handles.num_first_i,'String',num2str(first_i)); 
+set(handles.num_first_i,'String',num2str(first_i));
 set(handles.num_first_j,'String',num2str(first_j));
-set(handles.num_last_i,'String',num2str(last_i)); 
+set(handles.num_last_i,'String',num2str(last_i));
 set(handles.num_last_j,'String',num2str(last_j));
 
 %% number of slices set by default
-NbSlice=1;%default
+NbSlice=[];%default
 % read  value set by the first series for the append mode (iwiew >1)
 if iview>1 && strcmp(get(handles.num_NbSlice,'Visible'),'on')
-    NbSlice=str2num(get(handles.num_NbSlice,'String'));
+    NbSlice=str2double(get(handles.num_NbSlice,'String'));
 end
 
@@ -1061,5 +967,5 @@
 TimeUnit='';
 % read  value set by the first series for the append mode (iwiew >1)
-if iview>1 
+if iview>1
     TimeUnit=get(handles.TimeUnit,'String');
 end
@@ -1078,18 +984,18 @@
     [XmlData,errormsg]=imadoc2struct(XmlFileName);
     if ~isempty(errormsg)
-         msgbox_uvmat('WARNING',['error in reading ' XmlFileName ': ' errormsg]);
+        msgbox_uvmat('WARNING',['error in reading ' XmlFileName ': ' errormsg]);
     end
     % read time if available
     if isfield(XmlData,'Time')
-         Time=XmlData.Time;
+        Time=XmlData.Time;
         TimeName='xml';
     end
     if isfield(XmlData,'Camera')
-        if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
-            if iview>1 && ~isempty(NbSlice) && ~strcmp(NbSlice,XmlData.Camera.NbSlice)
-                msgbox_uvmat('WARNING','inconsistent number of slices with the first field series');
-            end
-            NbSlice=XmlData.Camera.NbSlice;% Nbre of slices from camera
-        end
+        %         if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
+        %             if iview>1 && ~isempty(NbSlice) && ~strcmp(NbSlice,XmlData.Camera.NbSlice)
+        %                 msgbox_uvmat('WARNING','inconsistent number of slices with the first field series');
+        %             end
+        %             NbSlice=XmlData.Camera.NbSlice;% Nbre of slices from camera
+        %         end
         if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
             if iview>1 && ~isempty(TimeUnit) && ~strcmp(TimeUnit,XmlData.Camera.TimeUnit)
@@ -1100,17 +1006,28 @@
     end
     % number of slices
+    if isfield(XmlData,'TranslationMotor')&& isfield(XmlData.TranslationMotor,'NbSlice')
+        NbSlice_motor=XmlData.TranslationMotor.NbSlice;
+        if ~isempty(NbSlice) && ~isequal(NbSlice_motor,NbSlice)
+                msgbox_uvmat('WARNING','inconsistent Z numbers of Z indices');
+        else
+            NbSlice=NbSlice_motor;
+        end
+    end
+   
     if isfield(XmlData,'GeometryCalib')
         check_calib=1;
         if isfield(XmlData.GeometryCalib,'SliceCoord')
             siz=size(XmlData.GeometryCalib.SliceCoord);
-            if siz(1)>1
-                if iview>1 && ~isempty(NbSlice) && ~strcmp(NbSlice,siz(1))
-                    msgbox_uvmat('WARNING','inconsistent number of Z indices with the first field series');
-                end
+            if ~isempty(NbSlice)&& ~isequal(size(1),NbSlice)
+                msgbox_uvmat('WARNING','inconsistent numbers of Z indices between motor and calibration');
+            else
                 NbSlice=siz(1);
             end
         end
     end
-    set(handles.num_NbSlice,'String',num2str(NbSlice))
+end
+if ~isempty(NbSlice)
+set(handles.num_NbSlice,'String',num2str(NbSlice))
+set(handles.num_NbSlice,'Visible','on')
 end
 
@@ -2013,4 +1930,5 @@
                     '#!/bin/bash \n'...
                     '. /etc/sysprofile \n'...
+                    'module load matlab/8.6 \n'...% CHOICE OF MATLAB VERSION
                     'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog{iprocess} ''' <<END_MATLAB \n'...
                     'addpath(''' path_series '''); \n'...
