Index: trunk/src/series.m
===================================================================
--- trunk/src/series.m	(revision 453)
+++ trunk/src/series.m	(revision 456)
@@ -539,8 +539,12 @@
 MinIndex=get(handles.MinIndex,'Data');%retrieve the min indices in the table MinIndex
 MaxIndex=get(handles.MaxIndex,'Data');%retrieve the max indices in the table MaxIndex
-i_sum=sum(sum(i1_series,2),3);
+i_sum=sum(sum(i1_series,2),3);%sum of i1_series on the last index
 MaxIndex_i=max(find(i_sum>0))-1;
-MinIndex_i=min(find(i_sum>0))-1;
-j_sum=sum(sum(i1_series,1),3);
+if isequal(i1_series(1),0)
+    MinIndex_i=0;
+else
+    MinIndex_i=min(find(i_sum>0))-1;
+end
+j_sum=sum(sum(j1_series,1),3);
 MaxIndex_j=max(find(j_sum>0))-1;
 MinIndex_j=min(find(j_sum>0))-1;
@@ -650,12 +654,17 @@
 
 %% update time table
+if ~isempty(time)
 TimeTable=get(handles.TimeTable,'Data');
 if isempty(MinIndex_j)
+    if MinIndex_i>0
     TimeTable{iview,1}=time(MinIndex_i);
+    end
     TimeTable{iview,2}=time(first_i);
     TimeTable{iview,3}=time(last_i);
     TimeTable{iview,4}=time(MaxIndex_i);
 elseif ~isempty(time)
+    if MinIndex_i>0
     TimeTable{iview,1}=time(MinIndex_i,MinIndex_j);
+    end
     TimeTable{iview,2}=time(first_i,first_j);
     TimeTable{iview,3}=time(last_i,last_j);
@@ -663,4 +672,5 @@
 end
 set(handles.TimeTable,'Data',TimeTable)
+end
 
 %% number of slices
@@ -1108,5 +1118,9 @@
 else
     enable_i(handles,'On')
-    enable_j(handles,'On')
+    if isempty(j1_series)
+         enable_j(handles,'Off')
+    else
+        enable_j(handles,'On')
+    end
 end
 fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time)
@@ -1259,13 +1273,15 @@
 set(handles.RUN, 'Enable','Off')
 set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
+drawnow
 [h_fun,Series,filexml,errormsg]=prepare_jobs(handles);
 if ~isempty(errormsg)
     msgbox_uvmat('ERROR',errormsg)
 else
-   Series.Specific=h_fun(Series,0);   
+  %Series.Specific=h_fun(Series);   
+   Series=h_fun(Series);  
    t=struct2xml(Series);
     t=set(t,1,'name','Series');
     save(t,filexml);
-    h_fun(Series);
+%     h_fun(Series);
 end
 set(handles.RUN, 'Enable','On')
@@ -1293,5 +1309,5 @@
 end
 % update the xml file after interactive input with the function
-Series.Specific=h_fun(Series,0);   
+Series.Specific=h_fun('input?');   
 t=struct2xml(Series);
 t=set(t,1,'name','Series');
@@ -1305,5 +1321,5 @@
     return
 end
-fctpath=get(handles.ActionPath,'String');
+path_fct=get(handles.ActionPath,'String');
 text_matlabscript=[...
     '#!/bin/bash \n'...
@@ -1311,5 +1327,5 @@
     'matlab -nodisplay -nosplash -nojvm <<END_MATLAB \n'...
     'cd(''' path_series '''); \n'...
-    'addpath(''' fctpath '''); \n'...
+    'addpath(''' path_fct '''); \n'...
     '' Series.Action  '( ''' filename_xml '''); \n'...
     'exit \n'...
@@ -1318,8 +1334,10 @@
 fclose(fid);
 if isunix
-    system(['chmod +x ' filename_bat]);
+    system(['chmod +x ' filename_bat]);% set the file to executable
+    system(['. ' filename_bat]);%execute fct
 end
 set(handles.BATCH, 'Enable','On')
 set(handles.BATCH,'BackgroundColor',[1 0 0])
+
 %------------------------------------------------------------------------
 % --- Executes on button press in BIN.
@@ -1333,7 +1351,8 @@
     
 %------------------------------------------------------------------------
-% --- Main lauch command, called by RUN and BATCH
+% --- Main launch command, called by RUN and BATCH
 function [h_fun,Series,filexml,errormsg]=prepare_jobs(handles)
 %------------------------------------------------------------------------
+filexml='';
 errormsg='';
 %% Read parameters from series
@@ -1343,5 +1362,5 @@
 end
 
-%% read root name and field type
+%% read index ranges
 first_i=1;
 last_i=1;
@@ -1463,7 +1482,7 @@
     end
     filexml=fullfile(Series.OutputDir,[Series.InputTable{1,3} '.xml']);% name of the parameter xml file set in this directory
-    t=struct2xml(Series);
-    t=set(t,1,'name','Series');
-    save(t,filexml);
+%     t=struct2xml(Series);
+%     t=set(t,1,'name','Series');
+%     save(t,filexml);
 end
 
@@ -1573,5 +1592,5 @@
     InputText=textscan(fid,'%s',1,'delimiter','\n');
     fclose(fid)
-    set(handles.ActionName,'ToolTipString',InputText{1}{1})
+    set(handles.ActionName,'ToolTipString',InputText{1}{1})% put the first line of the selected function as tooltip help
 end
 if ~isequal(path_series,PathName)
@@ -1617,5 +1636,20 @@
                 SeriesData.AllowInputSort=1;
                 set(handles.series,'UserData',SeriesData)
-            end              
+            end                      
+        case 'WholeIndexRange'
+            if isequal(lower(varargout{ilist+1}),'on')% sort the input table by alphabetical order of the SubDir
+                MinIndex=get(handles.MinIndex,'Data');
+                MaxIndex=get(handles.MaxIndex,'Data');
+                if ~isempty(MinIndex)
+                    set(handles.num_first_i,'String',num2str(MinIndex{1}))
+                    set(handles.num_last_i,'String',num2str(MaxIndex{1}))
+                    set(handles.num_incr_i,'String','1')
+                    if size(MinIndex,2)>=2
+                        set(handles.num_first_j,'String',num2str(MinIndex{1,2}))
+                        set(handles.num_last_j,'String',num2str(MaxIndex{1,2}))
+                        set(handles.num_incr_j,'String','1')
+                    end
+                end
+            end            
         case 'NbSlice'   %hidden by default
             if isequal(lower(varargout{ilist+1}),'on')
