Index: /trunk/src/civ.m
===================================================================
--- /trunk/src/civ.m	(revision 136)
+++ /trunk/src/civ.m	(revision 137)
@@ -469,26 +469,26 @@
 
 %default first_i and j and increments
-first_i=str2num(get(handles.first_i,'String'));%value possibly set by uvmat_Opening
-if isempty(first_i)|| first_i < 1
+first_i=str2double(get(handles.first_i,'String'));%value possibly set by uvmat_Opening
+if isnan(first_i)|| first_i < 1
     first_i=1; %default first_i
 end
-last_i=str2num(get(handles.last_i,'String'));
-if isempty(last_i)|| last_i < first_i
+last_i=str2double(get(handles.last_i,'String'));
+if isnan(last_i)|| last_i < first_i
     last_i=first_i;  %default last_i
 end
-first_j=str2num(get(handles.first_j,'String'));
-if isempty(first_j)|| first_j < 1
+first_j=str2double(get(handles.first_j,'String'));
+if isnan(first_j)|| first_j < 1
     first_j=1; %default first_j
 end
-last_j=str2num(get(handles.last_j,'String'));
-if isempty(last_j)|| last_j < first_j
+last_j=str2double(get(handles.last_j,'String'));
+if isnan(last_j)|| last_j < first_j
     last_j=first_j; %default last_j
 end
-incr_i=str2num(get(handles.incr_i,'String'));
-if isempty(incr_i) || incr_i < 1;
+incr_i=str2double(get(handles.incr_i,'String'));
+if isnan(incr_i) || incr_i < 1;
     set(handles.incr_i,'String','1') %default incr_i
 end
-incr_j=str2num(get(handles.incr_j,'String'));
-if isempty(incr_j) || incr_j < 1;
+incr_j=str2double(get(handles.incr_j,'String'));
+if isnan(incr_j) || incr_j < 1;
     set(handles.incr_j,'String','1') %default incr_j
 end
@@ -696,5 +696,5 @@
  
     %determine the set of times and possible intervals for CIV
-    %   dt=(1/1000)*str2num(get(handles.dt,'String'));
+    %   dt=(1/1000)*str2double(get(handles.dt,'String'));
     time=(0:nbfield-1)';% time=file index -1  by default
     if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j
@@ -790,5 +790,5 @@
     txt=ver;
     Release=txt(1).Release;
-    relnumb=str2num(Release(3:4));
+    relnumb=str2double(Release(3:4));
     if relnumb >= 14
         save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat
@@ -816,5 +816,5 @@
 end
 displ_num=[];%default
-ref_i=str2num(get(handles.ref_i,'String'));
+ref_i=str2double(get(handles.ref_i,'String'));
 % last_i=str2num(get(handles.last_i,'String'));
 time=get(handles.RootName,'UserData'); %get the set of times
@@ -1203,9 +1203,9 @@
 %     return
 % end
-ref_i=str2num(get(handles.ref_i_civ2,'String'));
+ref_i=str2double(get(handles.ref_i_civ2,'String'));
 if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')
     ref_j=0;
 else
-    ref_j=str2num(get(handles.ref_j_civ2,'String'));
+    ref_j=str2double(get(handles.ref_j_civ2,'String'));
 end
 time=get(handles.RootName,'UserData'); %get the set of times
@@ -1304,6 +1304,6 @@
 val=get(handles.list_pair_civ2,'Value');
 ichoice=min(find(select));
-if (isempty(ichoice) | ichoice < 1); ichoice=1; end;
-if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0
+if (isempty(ichoice) || ichoice < 1); ichoice=1; end;
+if get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0
     val=ichoice;% first valid pair proposed by default in the menu
 end
@@ -1324,5 +1324,5 @@
 last_i=str2double(get(handles.last_i,'String'));%last index i
 incr=str2double(get(handles.incr_i,'String'));% increment
-num_i=[first_i:incr:last_i];% list of i indices (reference values for each pair)
+num_i=first_i:incr:last_i;% list of i indices (reference values for each pair)
 if isequal(get(handles.first_j,'Visible'),'on')
     first_j=str2double(get(handles.first_j,'String'));%first index j
@@ -1362,9 +1362,9 @@
     str_raw=str_civ1(indsel);
     indsepar=find(str_raw=='|'); %character index of the separator
-    d1=str2double(str_civ1([indsel(indsepar-1)+1:indsel(indsepar)-1]));
+    d1=str2double(str_civ1(indsel(indsepar-1)+1:indsel(indsepar)-1));
     if indsepar==length(str_raw)
-        d2=str2double(str_civ1([indsel(indsepar)+1:end]));
+        d2=str2double(str_civ1(indsel(indsepar)+1:end));
     else
-        d2=str2double(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1]));
+        d2=str2double(str_civ1(indsel(indsepar)+1:indsel(indsepar+1)-1));
     end
     num1_civ1=num_i-d1;% set of first image numbers
@@ -1377,16 +1377,16 @@
     str_raw=str_civ2(indsel);
     indsepar=find(str_raw=='|'); %character index of the separator
-    d1=str2num(str_civ2([indsel(indsepar-1)+1:indsel(indsepar)-1]));
+    d1=str2double(str_civ2(indsel(indsepar-1)+1:indsel(indsepar)-1));
     if indsepar==length(str_raw)
-        d2=str2num(str_civ2([indsel(indsepar)+1:end]));
+        d2=str2double(str_civ2(indsel(indsepar)+1:end));
     else
-        d2=str2num(str_civ2([indsel(indsepar)+1:indsel(indsepar+1)-1]));
-    end
-    if isempty(d1)
+        d2=str2double(str_civ2(indsel(indsepar)+1:indsel(indsepar+1)-1));
+    end
+    if isnan(d1)
         num1_civ2=num_i;
     else
         num1_civ2=num_i-d1;% set of first image numbers
     end
-    if isempty(d2)
+    if isnan(d2)
         num2_civ2=num_i;
     else
@@ -1397,5 +1397,5 @@
     
     % adjust the first and last field number
-    lastfield=str2num(get(handles.nb_field,'String'));
+    lastfield=str2double(get(handles.nb_field,'String'));
     if isequal(lastfield,[])
         indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1));
@@ -1415,5 +1415,5 @@
     end
 elseif isequal (mode,'series(Dj)')
-    lastfield_j=str2num(get(handles.nb_field2,'String'));
+    lastfield_j=str2double(get(handles.nb_field2,'String'));
     num1_civ1=num_i;% set of first image numbers
     num2_civ1=num_i;
@@ -1425,5 +1425,5 @@
     num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j));
     % adjust the first and last field number
-    if isequal(lastfield_j,[])
+    if isnan(lastfield_j)
         indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1));
     else
@@ -1471,6 +1471,6 @@
 index_pair=get(handles.list_pair_civ1,'Value');
 displ_num=get(handles.list_pair_civ1,'UserData');
-num_a=displ_num(1,index_pair);
-num_b=displ_num(2,index_pair);
+% num_a=displ_num(1,index_pair);
+% num_b=displ_num(2,index_pair);
 list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs
 if index_pair<=length(list_pair2)
@@ -1483,10 +1483,10 @@
 mode=mode_list{mode_value};
 if isequal(mode,'series(Di)')
-    first_i=str2num(get(handles.first_i,'String'));
-    last_i=str2num(get(handles.last_i,'String'));
-    incr_i=str2num(get(handles.incr_i,'String'));
+    first_i=str2double(get(handles.first_i,'String'));
+    last_i=str2double(get(handles.last_i,'String'));
+    incr_i=str2double(get(handles.incr_i,'String'));
     num1=first_i:incr_i:last_i;
-    lastfield=str2num(get(handles.nb_field,'String'));
-    if ~isequal(lastfield,[])
+    lastfield=str2double(get(handles.nb_field,'String'));
+    if ~isnan(lastfield)
         ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ...
             (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield));
@@ -1496,10 +1496,10 @@
     set(handles.last_i,'String',num2str(num1(end)));
 elseif isequal(mode,'series(Dj)')
-    first_j=str2num(get(handles.first_j,'String'));
-    last_j=str2num(get(handles.last_j,'String'));
-    incr_j=str2num(get(handles.incr_j,'String'));
+    first_j=str2double(get(handles.first_j,'String'));
+    last_j=str2double(get(handles.last_j,'String'));
+    incr_j=str2double(get(handles.incr_j,'String'));
     num_j=first_j:incr_j:last_j;
-    lastfield2=str2num(get(handles.nb_field2,'String'));
-    if ~isequal(lastfield2,[])
+    lastfield2=str2double(get(handles.nb_field2,'String'));
+    if ~isnan(lastfield2)
         ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
             (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2));
@@ -1521,10 +1521,10 @@
 mode=mode_list{mode_value};
 if isequal(mode,'series(Di)')
-    first_i=str2num(get(handles.first_i,'String'));
-    last_i=str2num(get(handles.last_i,'String'));
-    incr_i=str2num(get(handles.incr_i,'String'));
+    first_i=str2double(get(handles.first_i,'String'));
+    last_i=str2double(get(handles.last_i,'String'));
+    incr_i=str2double(get(handles.incr_i,'String'));
     num1=first_i:incr_i:last_i;
-    lastfield=str2num(get(handles.nb_field,'String'));
-    if ~isequal(lastfield,[])
+    lastfield=str2double(get(handles.nb_field,'String'));
+    if ~isnan(lastfield)
         ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ...
             (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield));
@@ -1534,10 +1534,10 @@
     set(handles.last_i,'String',num2str(num1(end)));
 elseif isequal(mode,'series(Dj)')
-    first_j=str2num(get(handles.first_j,'String'));
-    last_j=str2num(get(handles.last_j,'String'));
-    incr_j=str2num(get(handles.incr_j,'String'));
+    first_j=str2double(get(handles.first_j,'String'));
+    last_j=str2double(get(handles.last_j,'String'));
+    incr_j=str2double(get(handles.incr_j,'String'));
     num_j=first_j:incr_j:last_j;
-    lastfield2=str2num(get(handles.nb_field2,'String'));
-    if ~isequal(lastfield2,[])
+    lastfield2=str2double(get(handles.nb_field2,'String'));
+    if ~isnan(lastfield2)
         ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
             (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2));
@@ -1596,6 +1596,4 @@
 end
 
-
-
 %check mask if selecetd
 if isequal(get(handles.get_mask_civ1,'Value'),1)
@@ -1624,5 +1622,5 @@
 end
 
-%% initialize the waitbars
+%% initialize the waitbars: TO suppress, waitbar not used
 set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001])
 set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001])
@@ -1636,9 +1634,7 @@
 [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=...
     set_civ_filenames(handles,compare,box_test);
-if isempty(filecell)
+if isempty(filecell)% (error message displayed in fct set_civ_filenames)
     return
 end
-filecell
-
 nbfield=numel(num1_civ1);
 nbslice=numel(num_a_civ1);
@@ -1887,5 +1883,5 @@
                 else
                     maskbase=[filecell.filebase '_' maskdispl]; %
-                    nbslice_mask=str2num(maskdispl(1:end-4)); %
+                    nbslice_mask=str2double(maskdispl(1:end-4)); %
                     num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1;
                     par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i');
@@ -1904,6 +1900,6 @@
                 gridname=get(handles.grid_civ1,'String');
                 if isequal(gridname(end-3:end),'grid')
-                    nbslice_grid=str2num(gridname(1:end-4)); %
-                    if ~isempty(nbslice_grid)
+                    nbslice_grid=str2double(gridname(1:end-4)); %
+                    if ~isnan(nbslice_grid)
                         num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1;
                         par_civ1.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
@@ -1947,5 +1943,5 @@
             else
                 maskdispl=get(handles.mask_fix1,'String');
-                nbslice_mask=str2num(maskdispl(1:end-4)); %
+                nbslice_mask=str2double(maskdispl(1:end-4)); %
                 num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1;
                 maskbase=[filecell.filebase '_' maskdispl];
@@ -1994,6 +1990,6 @@
                     gridname=get(handles.grid_patch1,'String');
                     if isequal(gridname(end-3:end),'grid')
-                        nbslice_grid=str2num(gridname(1:end-4)); %
-                        if ~isempty(nbslice_grid)
+                        nbslice_grid=str2double(gridname(1:end-4)); %
+                        if ~isnan(nbslice_grid)
                             num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1;
                             patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
@@ -2056,5 +2052,5 @@
                 else
                     maskbase=[filecell.filebase '_' maskdispl]; %
-                    nbslice_mask=str2num(maskdispl(1:end-4)); %
+                    nbslice_mask=str2double(maskdispl(1:end-4)); %
                     num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1;
                     par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i');
@@ -2068,10 +2064,10 @@
             end
             %TESTgrid
-            test_grid=get(handles.browse_gridciv2,'Value');
+            %test_grid=get(handles.browse_gridciv2,'Value');
             gridname=get(handles.grid_civ2,'String');
-            gridflag='y';
+            %gridflag='y';
             if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid')
-                nbslice_grid=str2num(gridname(1:end-4)); %
-                if ~isempty(nbslice_grid)
+                nbslice_grid=str2double(gridname(1:end-4)); %
+                if ~isnan(nbslice_grid)
                     par_civ2.gridflag='y';
                     num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1;
@@ -2123,5 +2119,5 @@
                 maskdispl=get(handles.mask_fix2,'String');
                 maskbase=[filecell.filebase '_' maskdispl]; %
-                nbslice_mask=str2num(maskdispl(1:end-4)); %
+                nbslice_mask=str2double(maskdispl(1:end-4)); %
                 num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1;
                 maskname =name_generator(maskbase,num1_mask,1,'.png','_i');
@@ -2169,6 +2165,6 @@
                     gridname=get(handles.grid_patch2,'String');
                     if isequal(gridname(end-3:end),'grid')
-                        nbslice_grid=str2num(gridname(1:end-4)); %
-                        if ~isempty(nbslice_grid)
+                        nbslice_grid=str2double(gridname(1:end-4)); %
+                        if ~isnan(nbslice_grid)
                             num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1;
                             patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
@@ -2241,6 +2237,5 @@
 end
 
-
-if ~batch%TODO: a revoir, cas 'run as background task'
+if ~batch
     [Rootbat,Filebat,extbat]=fileparts(filename_cmx);
     filename_superbat=fullfile(Rootbat,['job_list.bat']);
@@ -2255,6 +2250,5 @@
 end
 
-
-%save interface state
+%% save interface state
 if isfield(filecell,'nc')
     if isfield(filecell.nc,'civ2')
@@ -2294,5 +2288,5 @@
 end
 
-filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis
+%filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis
 filecell.filebase=filebase;
 
@@ -2308,5 +2302,5 @@
     mode=mode_list{mode_value};
 end
-time=get(handles.RootName,'UserData'); %get the set of times
+%time=get(handles.RootName,'UserData'); %get the set of times
 ext_ima=get(handles.ImaExt,'String');
 nom_type_nc=browse.nom_type_nc;
@@ -2358,10 +2352,10 @@
     ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback
     if ~isempty(ref)
-        first_i=str2num(get(handles.first_i,'String'));
-        last_i=str2num(get(handles.last_i,'String'));
-        incr_i=str2num(get(handles.incr_i,'String'));
-        first_j=str2num(get(handles.first_j,'String'));
-        last_j=str2num(get(handles.last_j,'String'));
-        incr_j=str2num(get(handles.incr_j,'String'));
+        first_i=str2double(get(handles.first_i,'String'));
+        last_i=str2double(get(handles.last_i,'String'));
+        incr_i=str2double(get(handles.incr_i,'String'));
+        first_j=str2double(get(handles.first_j,'String'));
+        last_j=str2double(get(handles.last_j,'String'));
+        incr_j=str2double(get(handles.incr_j,'String'));
         num_i_ref=first_i:incr_i:last_i;
         num_j_ref=first_j:incr_j:last_j;
@@ -2485,5 +2479,6 @@
     vers=0;
     subdir_civ1_new=subdir_civ1;
-    while detect==1 %create a new subdir if the netcdf files already exist
+    ind_test=0;
+    while detect==1 && ind_test<10%create a new subdir if the netcdf files already exist
         for ifile=1:nbfield
             for j=1:nbslice
@@ -2491,13 +2486,13 @@
                 detect=exist(filename,'file')==2;
                 if detect% if a netcdf file already exists
-                    indstr=regexp(subdir_civ1,'\D');
-                    if indstr(end)<length(subdir_civ1) %subdir_civ1 ends by a number
-                        vers=str2double(subdir_civ1(indstr(end)+1:end))+1;
-                        subdir_civ1_new=[subdir_civ1(1:indstr(end)) num2str(vers)];
+                    indstr=regexp(subdir_civ1_new,'\D');
+                    if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number
+                        vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1;
+                        subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)];
                     else
                         vers=vers+1;
-                        subdir_civ1_new=[subdir_civ1(1:indstr(end)) '_' num2str(vers)];       
+                        subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)];       
                     end
-                    subdir_civ2=subdir_civ1;
+                    subdir_civ2=subdir_civ1_new;
                     break
                 end
@@ -2529,6 +2524,4 @@
         end
         if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series
-%             vers=0;
-%             subdir_civ1_new=subdir_civ1;
             for ifile=1:nbfield
                 for j=1:nbslice
@@ -2536,11 +2529,11 @@
                     detect=exist(filename,'file')==2;
                     if detect% if a netcdf file already exists
-                       indstr=regexp(subdir_civ1,'\D');
-                       if indstr(end)<length(subdir_civ1) %subdir_civ1 ends by a number
-                           vers=str2double(subdir_civ1(indstr(end)+1:end))+1;
-                           subdir_civ1_new=[subdir_civ1(1:indstr(end)) num2str(vers)];
+                       indstr=regexp(subdir_civ1_new,'\D');
+                       if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number
+                           vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1;
+                           subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)];
                        else
                            vers=vers+1;
-                           subdir_civ1_new=[subdir_civ1 '_' num2str(vers)];
+                           subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)];
                        end
                        subdir_civ2=subdir_civ1;
@@ -2553,5 +2546,4 @@
                 end
             end
-%             subdir_civ1=subdir_civ1_new;
             %create the new subdir_civ1
             if exist(fullfile(Path_ima,subdir_civ1_new),'dir')
@@ -3093,5 +3085,5 @@
 %------------------------------------------------------------------------
 % last_i_Callback(hObject, eventdata, handles)
-first_i=str2num(get(handles.first_i,'String'));
+first_i=str2double(get(handles.first_i,'String'));
 % last_i=str2num(get(handles.last_i,'String'));
 % ref_i=ceil((first_i+last_i)/2);
@@ -3123,5 +3115,5 @@
 mode=mode_list{mode_value};
 if isequal (mode, 'series(Di)' )
-    ref_i=str2num(get(handles.ref_i,'String'));
+    ref_i=str2double(get(handles.ref_i,'String'));
     num1=ref_i-floor(index/2);%  first image numbers
     num2=ref_i+ceil(index/2);
@@ -3131,9 +3123,9 @@
     num1=1;
     num2=1;
-    ref_j=str2num(get(handles.ref_j,'String'));
+    ref_j=str2double(get(handles.ref_j,'String'));
     num_a=ref_j-floor(index/2);%  first image numbers
     num_b=ref_j+ceil(index/2);
 elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D)
-    ref_i=str2num(get(handles.ref_i,'String'));
+    ref_i=str2double(get(handles.ref_i,'String'));
     num1=ref_i;
     num2=ref_i;
@@ -3142,10 +3134,10 @@
 end
 dt=time(num2,num_b)-time(num1,num_a);
-ibx=str2num(get(handles.ibx,'String'));
-iby=str2num(get(handles.iby,'String'));
-umin=dt*pxcmx*str2num(get(handles.umin,'String'));
-umax=dt*pxcmx*str2num(get(handles.umax,'String'));
-vmin=dt*pxcmy*str2num(get(handles.vmin,'String'));
-vmax=dt*pxcmy*str2num(get(handles.vmax,'String'));
+ibx=str2double(get(handles.ibx,'String'));
+iby=str2double(get(handles.iby,'String'));
+umin=dt*pxcmx*str2double(get(handles.umin,'String'));
+umax=dt*pxcmx*str2double(get(handles.umax,'String'));
+vmin=dt*pxcmy*str2double(get(handles.vmin,'String'));
+vmax=dt*pxcmy*str2double(get(handles.vmax,'String'));
 shiftx=round((umin+umax)/2);
 shifty=round((vmin+vmax)/2);
@@ -3379,9 +3371,9 @@
     ind_mask=findstr('mask',Name);
     i=ind_mask-1;
-    while val(i)==0 & i>0
+    while val(i)==0 && i>0
         i=i-1;
     end
-    nbslice=str2num(Name(i+1:ind_mask-1));
-    if ~isequal(nbslice,[]) & Name(i)=='_'
+    nbslice=str2double(Name(i+1:ind_mask-1));
+    if ~isnan(nbslice) && Name(i)=='_'
         flag_mask=1;
     else
@@ -3411,9 +3403,9 @@
     ind_mask=findstr('grid',Name);
     i=ind_mask-1;
-    while val(i)==0 & i>0
+    while val(i)==0 && i>0
         i=i-1;
     end
-    nbslice=str2num(Name(i+1:ind_mask-1));
-    if ~isequal(nbslice,[]) & Name(i)=='_'
+    nbslice=str2double(Name(i+1:ind_mask-1));
+    if ~isnan(nbslice) && Name(i)=='_'
         flag_mask=1;
     else
