Index: trunk/src/series/civ_input.m
===================================================================
--- trunk/src/series/civ_input.m	(revision 603)
+++ trunk/src/series/civ_input.m	(revision 604)
@@ -25,5 +25,5 @@
 
 
-% Last Modified by GUIDE v2.5 04-Apr-2013 09:14:14
+% Last Modified by GUIDE v2.5 04-Apr-2013 22:08:23
 % Begin initialization code - DO NOT EDIT
 gui_Singleton = 1;
@@ -82,4 +82,5 @@
 %% input file info
 RootPath=Param.InputTable{1,1};
+set(handles.RootPath,'String',RootPath)
 RootFile=Param.InputTable{1,3};
 SubDir=Param.InputTable{1,2};
@@ -116,4 +117,12 @@
         imageinput='';
         Data=nc2struct(FileInput,'ListGlobalAttribute','Civ2_ImageA','Civ1_ImageA','Civ2_ImageB','Civ1_ImageB');
+        [PathCiv1_ImageA,Civ1_ImageA,FileExtA]=fileparts(Data.Civ1_ImageA);
+        [PathCiv1_ImageB,Civ1_ImageB,FileExtA]=fileparts(Data.Civ1_ImageB);
+        [PathCiv2_ImageA,Civ2_ImageA,FileExtA]=fileparts(Data.Civ2_ImageA);
+        [PathCiv2_ImageB,Civ2_ImageB,FileExtA]=fileparts(Data.Civ2_ImageB);
+        set(handles.Civ1_ImageA,'String',Civ1_ImageA)
+        set(handles.Civ1_ImageB,'String',Civ1_ImageB)
+        set(handles.Civ2_ImageA,'String',Civ2_ImageA)
+        set(handles.Civ2_ImageB,'String',Civ2_ImageB)
     if isfield(Data,'Txt')
         errormsg=Data.Txt;
@@ -121,32 +130,6 @@
         %TODO: introduce the image in the input table of series
     end
-        %         if  ~isempty(Data.Civ2_ImageB)%get the corresponding input image in the netcdf file
-        %             imageinput=Data.Civ2_ImageB;
-        %             [tild,ImaName,ImaExt]=fileparts(Data.Civ2_ImageA);
-        %             set(handles.RootFile_1,'String',[ImaName ImaExt])
-        %         elseif ~isempty(Data.Civ1_ImageB)
-        %             imageinput=Data.Civ1_ImageB;
-        %             [tild,ImaName,ImaExt]=fileparts(Data.Civ1_ImageA);
-        %             set(handles.RootFile_1,'String',[ImaName ImaExt])
-        %         end
-        % settings for civx data,        
-        % look for the corresponding input images
-        check_letter=~isempty(regexp(NomTypeInput,'[ab|AB]$','once'));%detect pair label by letter
-        NomTypeIma=NomTypeInput;
-        if check_letter
-            NomTypeIma=NomTypeInput(1:end-1);
-        else
-            r=regexp(NomTypeIma,'.-(?<num2>\d+)$','names');
-            if ~isempty(r)
-                NomTypeIma=regexprep(NomTypeIma,['-' r.num2],'');
-            end
-            r=regexp(NomTypeIma,'.-(?<num2>\d+)','names');
-            if ~isempty(r)
-                NomTypeIma=regexprep(NomTypeIma,['-' r.num2],'');
-            end
-        end
-%         if ~exist(imageinput,'file')
-%             imageinput=fullfile_uvmat(RootPath,regexprep(SubDir,'.civ(_?)(\d*)$',''),RootFile,'.png',NomTypeIma,i1,[],j1);
-%         end
+        [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaA]=fileparts_uvmat(Data.Civ1_ImageA);
+        [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaB]=fileparts_uvmat(Data.Civ1_ImageB);
     case 'civxdata'% case of  civx data,
         NomTypeNc=NomTypeInput;
@@ -407,5 +390,5 @@
 
 %% determine nomenclature types and extension of the input files
-% [RootPath,SubDir,RootFile,i1,i2,j1,j2,ExtInput,NomTypeInput]=fileparts_uvmat(fileinput);
+% [RootPath,SubDir,Civ2_ImageB,i1,i2,j1,j2,ExtInput,NomTypeInput]=fileparts_uvmat(fileinput);
 % NomTypeNc='';%default
 
@@ -416,5 +399,5 @@
 % detect the file type, get the movie object if relevant, and look for the corresponding file series:
 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
-%[RootPath,ImageACiv1,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject]=find_file_series(FilePath,[FileName ImaExt]);
+%[RootPath,Civ1_ImageA,Civ2_ImageB,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject]=find_file_series(FilePath,[FileName ImaExt]);
 switch Param.FileType{1}
     case {'image','multimage','video','mmreader'}
@@ -424,6 +407,6 @@
 end
 set(handles.RootPath,'String',RootPath)
-set(handles.ImageACiv1,'String',SubDirImages)
-set(handles.RootFile,'String',RootFile)
+set(handles.Civ1_ImageA,'String',SubDirImages)
+set(handles.Civ2_ImageB,'String',RootFile)
 if strcmp(ExtInput,'.nc')
     SubDirCiv=regexprep(SubDir,['^' SubDirImages],'');%suppress the root  SuddirImages;
@@ -431,6 +414,6 @@
     SubDirCiv= '.civ';
 end
-set(handles.ImageBCiv1,'String',SubDirCiv)
-set(handles.ImageACiv2,'String',SubDirCiv)
+set(handles.Civ1_ImageB,'String',SubDirCiv)
+set(handles.Civ2_ImageA,'String',SubDirCiv)
 browse=get(handles.RootPath,'UserData');
 browse.incr_pair=[0 0];%default
@@ -511,7 +494,7 @@
 %------------------------------------------------------------------------
 % --- Executes on carriage return on the subdir checkciv1 edit window
-function ImageBCiv1_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
-SubDir=get(handles.ImageBCiv1,'String');
+function Civ1_ImageB_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
+SubDir=get(handles.Civ1_ImageB,'String');
 menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update
 ichoice=find(strcmp(SubDir,menu_str),1);
@@ -523,5 +506,5 @@
 set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu
 if get(handles.CheckCiv1,'Value')% if Civ1 is performed
-    set(handles.ImageACiv2,'String',SubDir);% set by default civ2 directory the same as civ1 
+    set(handles.Civ2_ImageA,'String',SubDir);% set by default civ2 directory the same as civ1 
 %     set(handles.ListSubdirCiv2,'Value',ilist)
 else % if Civ1 data already exist
@@ -534,7 +517,7 @@
 %------------------------------------------------------------------------
 % --- Executes on carriage return on the SubDir checkciv1 edit window
-function ImageACiv2_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
-SubDir=get(handles.ImageBCiv1,'String');
+function Civ2_ImageA_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
+SubDir=get(handles.Civ1_ImageB,'String');
 menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update
 ichoice=find(strcmp(SubDir,menu_str),1);
@@ -609,5 +592,5 @@
 % end
 set(handles.PairIndices,'Visible','on')
-set(handles.ImageBCiv1,'Visible','on')
+set(handles.Civ1_ImageB,'Visible','on')
 set(handles.TitleSubdirCiv1,'Visible','on')
 if opening==0
@@ -620,5 +603,5 @@
     set(handles.TitlePairCiv2,'Visible','on')
     set(handles.TitleSubdirCiv2,'Visible','on')
-    set(handles.ImageACiv2,'Visible','on')
+    set(handles.Civ2_ImageA,'Visible','on')
     %set(handles.ListSubdirCiv2,'Visible','on')
     set(handles.ListPairCiv2,'Visible','on')
@@ -631,5 +614,5 @@
 else
     set(handles.TitleSubdirCiv2,'Visible','off')
-    set(handles.ImageACiv2,'Visible','off')
+    set(handles.Civ2_ImageA,'Visible','off')
     set(handles.ListPairCiv2,'Visible','off')
 end
@@ -1130,7 +1113,7 @@
 
 %% reads .nc subdirectoy and image numbers from the interface
-SubDirImages=get(handles.ImageACiv1,'String');
-subdir_civ1=[SubDirImages get(handles.ImageBCiv1,'String')];%subdirectory subdir_civ1 for the netcdf data
-subdir_civ2=[SubDirImages get(handles.ImageACiv2,'String')];%subdirectory subdir_civ2 for the netcdf data
+SubDirImages=get(handles.Civ1_ImageA,'String');
+subdir_civ1=[SubDirImages get(handles.Civ1_ImageB,'String')];%subdirectory subdir_civ1 for the netcdf data
+subdir_civ2=[SubDirImages get(handles.Civ2_ImageA,'String')];%subdirectory subdir_civ2 for the netcdf data
 ref_i=str2double(get(handles.ref_i,'String'));
 ref_j=[];
@@ -1166,5 +1149,5 @@
 testpair=0;
 RootPath=get(handles.RootPath,'String');
-RootFile=get(handles.RootFile,'String');
+RootFile=get(handles.Civ2_ImageB,'String');
 if index==1 % case civ1
     if ~get(handles.CheckCiv1,'Value') %
@@ -1592,5 +1575,5 @@
 nbslice=1;
 
-% subdir=get(handles.ImageBCiv1,'String');
+% subdir=get(handles.Civ1_ImageB,'String');
 [Path,Name]=fileparts(filebase);
 if ~isdir(Path)
@@ -1688,5 +1671,5 @@
 %     end    
 % end
-% set(handles.ImageBCiv1,'String',SubDir);
+% set(handles.Civ1_ImageB,'String',SubDir);
 % errormsg=find_netcpair_civ(handles,1);
 % if ~isempty(errormsg)
@@ -1709,5 +1692,5 @@
 %     end
 % end
-% set(handles.ImageACiv2,'String',SubDir);
+% set(handles.Civ2_ImageA,'String',SubDir);
 
 %------------------------------------------------------------------------
@@ -2202,32 +2185,2 @@
 
 
-function NcFileCiv2_Callback(hObject, eventdata, handles)
-% hObject    handle to NcFileCiv2 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hints: get(hObject,'String') returns contents of NcFileCiv2 as text
-%        str2double(get(hObject,'String')) returns contents of NcFileCiv2 as a double
-
-
-% --- Executes during object creation, after setting all properties.
-function NcFileCiv2_CreateFcn(hObject, eventdata, handles)
-% hObject    handle to NcFileCiv2 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    empty - handles not created until after all CreateFcns called
-
-% Hint: edit controls usually have a white background on Windows.
-%       See ISPC and COMPUTER.
-if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
-    set(hObject,'BackgroundColor','white');
-end
-
-
-
-function ImageACiv1_Callback(hObject, eventdata, handles)
-% hObject    handle to ImageACiv1 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hints: get(hObject,'String') returns contents of ImageACiv1 as text
-%        str2double(get(hObject,'String')) returns contents of ImageACiv1 as a double
Index: trunk/src/series/civ_series.m
===================================================================
--- trunk/src/series/civ_series.m	(revision 603)
+++ trunk/src/series/civ_series.m	(revision 604)
@@ -192,10 +192,10 @@
         Civ1_param=list_param;%default
         
-        %set the values of all the global attributes in list_param
-        Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param];
+        %set the values of all the global attributes in list_param  
         for ilist=1:length(list_param)
             Civ1_param{ilist}=['Civ1_' list_param{ilist}];
             Data.(['Civ1_' list_param{ilist}])=Param.ActionInput.Civ1.(list_param{ilist});
         end
+        Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param];
         Data.CivStage=1;
         
Index: trunk/src/series/ima_levels.m
===================================================================
--- trunk/src/series/ima_levels.m	(revision 603)
+++ trunk/src/series/ima_levels.m	(revision 604)
@@ -4,37 +4,38 @@
 % function GUI_input=ima_levels(Param)
 %
+%------------------------------------------------------------------------
 %%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-% This function is used in four modes by the GUI series:
-%           1) config GUI: with no input argument, the function determine the suitable GUI configuration
-%           2) interactive input: the function is used to interactively introduce input parameters, and then stops
-%           3) RUN: the function itself runs, when an appropriate input  structure Param has been introduced. 
-%           4) BATCH: the function itself proceeds in BATCH mode, using an xml file 'Param' as input.
-%
 %OUTPUT
-% GUI_input=list of options in the GUI series.fig needed for the function
+% ParamOut: sets options in the GUI series.fig needed for the function
 %
 %INPUT:
 % In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series.
 % In batch mode, Param is the name of the corresponding xml file containing the same information
-% In the absence of input (as activated when the current Action is selected
-% in series), the function ouput GUI_input set the activation of the needed GUI elements
-%
-% Param contains the elements:(use the menu bar command 'export/GUI config' in series to see the current structure Param)
+% when Param.Action.RUN=0 (as activated when the current Action is selected
+% in series), the function ouput paramOut set the activation of the needed GUI elements
+%
+% Param contains the elements:(use the menu bar command 'export/GUI config' in series to 
+% see the current structure Param)
 %    .InputTable: cell of input file names, (several lines for multiple input)
 %                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
 %    .OutputSubDir: name of the subdirectory for data outputs
-%    .OutputDir: directory for data outputs, including path
+%    .OutputDirExt: directory extension for data outputs
 %    .Action: .ActionName: name of the current activated function
 %             .ActionPath:   path of the current activated function
+%             .ActionExt: fct extension ('.m', Matlab fct, '.sh', compiled   Matlab fct
+%             .RUN =0 for GUI input, =1 for function activation
+%             .RunMode='local','background', 'cluster': type of function  use
+%             
 %    .IndexRange: set the file or frame indices on which the action must be performed
 %    .FieldTransform: .TransformName: name of the selected transform function
 %                     .TransformPath:   path  of the selected transform function
-%                     .TransformHandle: corresponding function handle
 %    .InputFields: sub structure describing the input fields withfields
-%              .FieldName: name of the field
+%              .FieldName: name(s) of the field
 %              .VelType: velocity type
 %              .FieldName_1: name of the second field in case of two input series
 %              .VelType_1: velocity type of the second field in case of two input series
+%              .Coord_y: name of y coordinate variable
+%              .Coord_x: name of x coordinate variable
 %    .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -44,5 +45,5 @@
 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName
 if isstruct(Param) && isequal(Param.Action.RUN,0)
-    ParamOut.NbViewMax=1;% max nbre of input file series (default='' , no limitation)
+    ParamOut.NbViewMax=1;% max nbre of input file series (default , no limitation)
     ParamOut.AllowInputSort='off';% 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)
@@ -54,5 +55,17 @@
     ParamOut.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
     ParamOut.OutputDirExt='.lev';%set the output dir extension
-    ParamOut.OutputFileMode='NbInput';%NbInput= 1 output file per input file index, NbInput_i=1 fileper input file index i,NbSlice= 1 file per slice
+    ParamOut.OutputFileMode='NbInput';% ='=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
+    %check the type of the existence and type of the first input file:
+    Param.IndexRange.last_i=Param.IndexRange.first_i;%keep only the first index in the series
+    Param.IndexRange.last_j=Param.IndexRange.first_j;
+    filecell=get_file_series(Param);
+    if ~exist(filecell{1,1},'file')
+        msgbox_uvmat('WARNING','the first input file does not exist')
+    else
+        FileType=get_file_type(filecell{1,1});
+        if isempty(find(strcmp(FileType,{'image','multimage','mmreader','video'})));% =1 for images
+            msgbox_uvmat('ERROR',['bad input file type for ' mfilename ': an image is needed'])
+        end
+    end
 return
 end
@@ -66,11 +79,5 @@
 end
 
-ParamOut=Param; %default output
-if ~isfield(Param,'InputFields')
-    Param.InputFields.FieldName='';
-end
-OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
-
-%% root input file(s) and type
+%% root input file names and nomenclature type (cell arrays with one element)
 RootPath=Param.InputTable(:,1);
 RootFile=Param.InputTable(:,3);
@@ -78,8 +85,9 @@
 NomType=Param.InputTable(:,4);
 FileExt=Param.InputTable(:,5);
-OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
-
-% get the set of input file names (cell array filecell), and the lists of
-% input file or frame indices i1_series,i2_series,j1_series,j2_series
+
+%% subdirectory for output files
+SubdirOut=[Param.OutputSubDir Param.OutputDirExt];
+
+%% get the set of input file names (cell array filecell), and file indices
 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
 % filecell{iview,fileindex}: cell array representing the list of file names
@@ -88,23 +96,10 @@
 % i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j 
 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
-% set of frame indices used for movie or multimage input 
-% numbers of slices and file indices
-
-NbSlice=1;%default
-if isfield(Param.IndexRange,'NbSlice')
-    NbSlice=Param.IndexRange.NbSlice;
-end
-nbview=numel(i1_series);%number of input file series (lines in InputTable)
-nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
+nbfield_j=size(j1_series{1},1); %nb of fields for the j index (bursts or volume slices)
 nbfield_i=size(i1_series{1},2); %nb of fields for the i index
 nbfield=nbfield_j*nbfield_i; %total number of fields
-nbfield_i=floor(nbfield/NbSlice);%total number of  indexes in a slice (adjusted to an integer number of slices) 
-nbfield=nbfield_i*NbSlice; %total number of fields after adjustement
-
-%determine the file type on each line from the first input file 
-ImageTypeOptions={'image','multimage','mmreader','video'};%allowed input file types(images)
-
-[FileType{1},FileInfo{1},MovieObject{1}]=get_file_type(filecell{1,1});
-CheckImage{1}=~isempty(find(strcmp(FileType,ImageTypeOptions)));% =1 for images
+[FileType{1},FileInfo{1},VideoObject{1}]=get_file_type(filecell{1,1});% type of input file
+
+%% frame index for movie or multimage file input  
 if ~isempty(j1_series{1})
     frame_index{1}=j1_series{1};
@@ -125,16 +120,11 @@
  % EDIT FROM HERE
 
- %% check the validity of  input file types
-if CheckImage{1}
-    FileExtOut='.png'; % write result as .png images for image inputs
-    if strcmp(lower(NomType{1}(end)),'a')
-        NomTypeOut=NomType{1};
-    else
-        NomTypeOut='_1_1';
-    end
-else 
-    msgbox_uvmat('ERROR',['invalid file type input: ' FileType{1} ' not an image'])
-    return
-end
+ %% Extension and indexing nomenclature for output file
+ FileExtOut='.png'; % write result as .png images for image inputs
+ if strcmpi(NomType{1}(end),'a')
+     NomTypeOut=NomType{1};
+ else
+     NomTypeOut='_1_1';
+ end
 
 %% Set field names and velocity types
@@ -153,25 +143,27 @@
 j1=[];%default
 for ifile=1:nbfield
-          if checkrun
-                stopstate=get(Param.RUNHandle,'BusyAction');
-                update_waitbar(Param.WaitbarHandle,ifile/nbfield)
-          else
-                stopstate='queue';
-          end
-    if isequal(stopstate,'queue') % enable STOP command
-        if ~isempty(j1_series)&&~isequal(j1_series,{[]})
-            j1=j1_series{1}(ifile);
-        end
-        filename=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomType{1},i1_series{1}(ifile),[],j1);
-        A=read_image(filename,FileType{1},MovieObject{1},frame_index{1}(ifile));
-        if ndims(A)==3;%color images
-            A=sum(double(Aread),3);% take the sum of color components
-        end
-        % operation on images
-        A=levels(A);
-        filename_new=fullfile_uvmat(RootPath{1},OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
-        imwrite(A,filename_new)
-        display([filename_new ' written'])
-    end
+    if checkrun
+        stopstate=get(Param.RUNHandle,'BusyAction');
+        update_waitbar(Param.WaitbarHandle,ifile/nbfield)
+    else
+        stopstate='queue';
+    end
+    if ~isequal(stopstate,'queue') % enable STOP command
+        break
+    end
+    if ~isempty(j1_series)&&~isequal(j1_series,{[]})
+        j1=j1_series{1}(ifile);
+    end
+    filename=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomType{1},i1_series{1}(ifile),[],j1);
+    A=read_image(filename,FileType{1},VideoObject{1},frame_index{1}(ifile));
+    if ndims(A)==3;%color images
+        A=sum(double(Aread),3);% take the sum of color components
+    end
+    % operation on images
+    A=levels(A);
+    % write output file
+    filename_new=fullfile_uvmat(RootPath{1},SubdirOut,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
+    imwrite(A,filename_new)
+    display([filename_new ' written'])
 end
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
