Index: /trunk/src/check_files.m
===================================================================
--- /trunk/src/check_files.m	(revision 511)
+++ /trunk/src/check_files.m	(revision 512)
@@ -54,5 +54,5 @@
     'fill_GUI';...%  fill a GUI with a set of parameters from a Matlab structure 
     'filter_tps';...% find the thin plate spline coefficients for interpolation-smoothing
-    'find_field_indices';...% group the variables of a 'field object' into 'field cells' and specify their structure
+    'find_field_cells';...% group the variables of a 'field object' into 'field cells' and specify their structure
     'find_file_series';...%check the content of an input file and find the corresponding file series
     'find_imadoc';...% find the ImaDoc xml file associated with a given input file
Index: /trunk/src/civ.m
===================================================================
--- /trunk/src/civ.m	(revision 511)
+++ /trunk/src/civ.m	(revision 512)
@@ -533,5 +533,5 @@
 else
     set(handles.ImaDoc,'String',''); %xml file not used for timing
-    time=(i1_series(:,1)+0:size(i1_series,1)-1);% time=index i
+    time=(i1_series(:,1)+0:size(i1_series,3)-1);% time=index i
     time=time'*ones(1,size(i1_series,2),1); %makes a time matrix with the same time for all j indices
     TimeUnit='frame';
@@ -2533,7 +2533,5 @@
 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
 [RootPath,SubDir,RootFile_1,i1_series,i2_series,j1_series,j2_series,nom_type_1,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName Ext]);
-        
-       % [tild,tild,RootFile_1,tild,tild,tild,tild,tild,nom_type_1]=fileparts_uvmat(fileinput);
-        %[RootFile_1,i1_series,tild,j1_series,tild,nom_type_1,FileType,Object]=find_file_series(PathName,FileName);
+
         %check image nom type 
         if ~strcmp(nom_type_1,get(handles.NomType,'String'))
Index: /trunk/src/find_file_series.m
===================================================================
--- /trunk/src/find_file_series.m	(revision 511)
+++ /trunk/src/find_file_series.m	(revision 512)
@@ -290,4 +290,6 @@
     end
 end
-
-
+i1_series=permute(i1_series,[3 2 1]);% permute dimensions 
+i2_series=permute(i2_series,[3 2 1]);% permute dimensions
+j1_series=permute(j1_series,[3 2 1]);% permute dimensions 
+j2_series=permute(j2_series,[3 2 1]);% permute dimensions
Index: /trunk/src/get_field.m
===================================================================
--- /trunk/src/get_field.m	(revision 511)
+++ /trunk/src/get_field.m	(revision 512)
@@ -218,7 +218,7 @@
 
 set(handles.scalar,'String', Txt )
-[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Field);
+[CellVarIndex,NbDim,VarType,errormsg]=find_field_cells(Field);
 if ~isempty(errormsg)  
-    msgbox_uvmat('ERROR',['error in get_field/Field_input/find_field_indices: ' errormsg])
+    msgbox_uvmat('ERROR',['error in get_field/Field_input/find_field_cells: ' errormsg])
     return
 end  
@@ -301,5 +301,5 @@
     variables_Callback(hObject, eventdata, handles)
 end
-[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Field);
+[CellVarIndex,NbDim,VarType,errormsg]=find_field_cells(Field);
 for icell=1:numel(CellVarIndex)
     VarIndex=CellVarIndex{icell};
Index: /trunk/src/mouse_down.m
===================================================================
--- /trunk/src/mouse_down.m	(revision 511)
+++ /trunk/src/mouse_down.m	(revision 512)
@@ -110,6 +110,6 @@
                         tagaxes=get(hchild,'tag');
                         if isfield(FigData,tagaxes)
-                            eval(['Field=FigData.' tagaxes ';'])
-                            [CellVarIndex,NbDim,VarType]=find_field_indices(Field);%analyse the physical fields contained in Field
+                            Field=FigData.(tagaxes);
+                            [CellVarIndex,NbDim,VarType]=find_field_cells(Field);%analyse the physical fields contained in Field
                             for icell=1:numel(CellVarIndex)%look for all physical fields
                                 if NbDim(icell)==2 % select 2D field
Index: /trunk/src/mouse_motion.m
===================================================================
--- /trunk/src/mouse_motion.m	(revision 511)
+++ /trunk/src/mouse_motion.m	(revision 512)
@@ -97,7 +97,7 @@
             tagaxes=get(CurrentAxes,'tag');
             if isfield(FigData,tagaxes)
-                eval(['Field=FigData.' tagaxes ';'])
+                Field=FigData.(tagaxes);
                 if isfield(Field,'ListVarName')
-                    [CellVarIndex,NbDim,VarType]=find_field_indices(Field);%analyse the physical fields contained in Field
+                    [CellVarIndex,NbDim,VarType]=find_field_cells(Field);%analyse the physical fields contained in Field
                     text_displ_1='';
                     text_displ_2='';
Index: /trunk/src/plot_field.m
===================================================================
--- /trunk/src/plot_field.m	(revision 511)
+++ /trunk/src/plot_field.m	(revision 512)
@@ -6,5 +6,5 @@
 %     2D vector fields are represented by arrows, 2D scalar fields by grey scale images or contour plots, 1D fields are represented by usual plot with (abscissa, ordinate).
 %  The input field structure is first tested by check_field_structure.m,
-%  then split into blocks of related variables  by find_field_indices.m.
+%  then split into blocks of related variables  by find_field_cells.m.
 %  The dimensionality of each block is obtained  by this function
 %  considering the presence of variables with the attribute .Role='coord_x'
@@ -117,7 +117,7 @@
 end
 % check the cells of fields :
-[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data);
+[CellVarIndex,NbDim,VarType,errormsg]=find_field_cells(Data);
 if ~isempty(errormsg)
-    msgbox_uvmat('ERROR',['input of plot_field/find_field_indices: ' errormsg]);
+    msgbox_uvmat('ERROR',['input of plot_field/find_field_cells: ' errormsg]);
     return
 end
Index: /trunk/src/proj_field.m
===================================================================
--- /trunk/src/proj_field.m	(revision 511)
+++ /trunk/src/proj_field.m	(revision 512)
@@ -36,5 +36,5 @@
 %           .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName
 %        .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
-% The variables are grouped in 'fields', made of a set of variables with common dimensions (using the function find_field_indices)
+% The variables are grouped in 'fields', made of a set of variables with common dimensions (using the function find_field_cells)
 % The variable attribute 'Role' is used to define the role for plotting:
 %       Role = 'scalar':  (default) represents a scalar field
@@ -178,5 +178,5 @@
 [ProjData,errormsg]=proj_heading(FieldData,ObjectData);
 ProjData.NbDim=0;
-[CellVarIndex,NbDimCell,VarTypeCell,errormsg]=find_field_indices(FieldData);
+[CellVarIndex,NbDimCell,VarTypeCell,errormsg]=find_field_cells(FieldData);
 if ~isempty(errormsg)
     errormsg=['error in proj_field/proj_points:' errormsg];
@@ -372,5 +372,5 @@
 % DimVarIndex=0;%initilise list of indices for dimension variables
 idimvar=0;
-[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(FieldData);
+[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_cells(FieldData);
 if ~isempty(errormsg)
     errormsg=['error in proj_field/proj_patch:' errormsg];
@@ -593,5 +593,5 @@
 
 %% group the variables (fields of 'FieldData') in cells of variables with the same dimensions
-[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(FieldData);
+[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_cells(FieldData);
 if ~isempty(errormsg)
     errormsg=['error in proj_field/proj_line:' errormsg];
@@ -1008,5 +1008,5 @@
 idimvar=0;
 
-[CellVarIndex,NbDimVec,VarTypeCell,errormsg]=find_field_indices(FieldData);
+[CellVarIndex,NbDimVec,VarTypeCell,errormsg]=find_field_cells(FieldData);
 if ~isempty(errormsg)
     errormsg=['error in proj_field/proj_plane:' errormsg];
@@ -1679,5 +1679,5 @@
 %-----------------------------------------------------------------
 idimvar=0;
-[CellVarIndex,NbDimVec,VarTypeCell,errormsg]=find_field_indices(FieldData);
+[CellVarIndex,NbDimVec,VarTypeCell,errormsg]=find_field_cells(FieldData);
 if ~isempty(errormsg)
     errormsg=['error in proj_field/proj_plane:' errormsg];
Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 511)
+++ /trunk/src/series.m	(revision 512)
@@ -588,18 +588,18 @@
 
 %% display the min and max indices for all the file series
-i_sum=sum(sum(i1_series,2),3);%sum of i1_series on the last index
+i_sum=sum(sum(i1_series,2),1);%sum of i1_series on the last index
 MaxIndex_i=max(find(i_sum>0))-1;% max ref index i
 MinIndex_i=min(find(i_sum>0))-1;% min ref index i
 i2_min=[];
 if ~isempty(i2_series)
-    i2_min=i2_series(1,2);
+    i2_min=i2_series(1,2,2);
 end
 j1_min=[];
 if ~isempty(j1_series)
-    j1_min=j1_series(1,2);
+    j1_min=j1_series(1,2,2);
 end
 j2_min=[];
 if ~isempty(j2_series)
-    j2_min=j2_series(1,2);
+    j2_min=j2_series(1,2,2);
 end
 if isequal(MinIndex_i,1) &&...
@@ -607,5 +607,5 @@
     MinIndex_i=0;
 end
-j_sum=sum(sum(j1_series,1),3);
+j_sum=sum(sum(j1_series,1),1);
 MaxIndex_j=max(find(j_sum>0))-1;
 MinIndex_j=min(find(j_sum>0))-1;
@@ -793,6 +793,6 @@
 nbview=numel(SeriesData.i1_series);
 for iview=1:nbview
-    index_min(iview)=min(find(SeriesData.i1_series{iview}(2:end,2:end,1)>0));
-    index_max(iview)=max(find(SeriesData.i1_series{iview}(2:end,2:end,1)>0));
+    index_min(iview)=min(find(SeriesData.i1_series{iview}(1,2:end,2:end)>0));
+    index_max(iview)=max(find(SeriesData.i1_series{iview}(1,2:end,2:end)>0));
 end
 index_min=min(index_min);
@@ -808,5 +808,5 @@
     ind_y=1+(iview-1)*range_y:iview*range_y;
     LineData=zeros(1,range_index);
-    x_index=find(SeriesData.i1_series{iview}(2:end,2:end,1)>0)-index_min+1;
+    x_index=find(SeriesData.i1_series{iview}(1,2:end,2:end)>0)-index_min+1;
     LineData(x_index)=1;
     LineData=interp1(x,LineData,xI,'nearest');
@@ -815,27 +815,4 @@
 CData=cat(3,zeros(size(CData)),CData,zeros(size(CData)));
 set(handles.FileStatus,'CData',CData);
-
-% 
-% 
-% xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices
-% yima=0.5:pos(4)-0.5;
-% [XIma,YIma]=meshgrid(xima,yima);
-% nb_i=size(i1_series,1);
-% nb_j=size(i1_series,2);
-% ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i;
-% ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j;
-% [Ind_i,Ind_j]=meshgrid(ind_i,ind_j);
-% CData=zeros([size(XIma) 3]);%black color
-% file_ima=double((i1_series(:,:,1)>0)');
-% if numel(file_ima)>=2
-% if size(file_ima,1)==1
-%     CLine=interp1(ind_i,file_ima,xima,'nearest');
-%     CData(:,:,2)=ones(size(yima'))*CLine;
-% else
-%     CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest');
-% end
-% set(handles.FileStatus,'CData',CData)
-% end
-% set(handles.FileStatus,'Units','normalized')
 
 
@@ -1077,6 +1054,6 @@
 % end
 for iview=1:numel(SeriesData.i1_series)
-    index_min(iview)=min(find(SeriesData.i1_series{iview}(2:end,2:end,1)>0));
-    index_max(iview)=max(find(SeriesData.i1_series{iview}(2:end,2:end,1)>0));
+    index_min(iview)=min(find(SeriesData.i1_series{iview}(1,2:end,2:end)>0));
+    index_max(iview)=max(find(SeriesData.i1_series{iview}(1,2:end,2:end)>0));
 end
 [index_min,iview_min]=min(index_min);
@@ -2185,5 +2162,5 @@
 yima=0.5:pos(4)-0.5;
 [XIma,YIma]=meshgrid(xima,yima);
-nb_i=size(i1_series,1);
+nb_i=size(i1_series,3);
 nb_j=size(i1_series,2);
 ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i;
Index: /trunk/src/sub_field.m
===================================================================
--- /trunk/src/sub_field.m	(revision 511)
+++ /trunk/src/sub_field.m	(revision 512)
@@ -65,10 +65,10 @@
 
 %% check the two input fields     
-[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(Field);
+[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_cells(Field);
 if ~isempty(errormsg)
     errormsg=['invalid  first input to sub_field:' errormsg];
     return
 end
-[CellVarIndex_1,NbDim_1,VarTypeCell_1,errormsg]=find_field_indices(Field_1);
+[CellVarIndex_1,NbDim_1,VarTypeCell_1,errormsg]=find_field_cells(Field_1);
 if ~isempty(errormsg)
     errormsg=['invalid second input to sub_field:' errormsg];
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 511)
+++ /trunk/src/uvmat.m	(revision 512)
@@ -51,37 +51,36 @@
 %
 % 1) Input filenames are determined by MenuBrowse (first field), MenuBrowse_1
-% (second field), or by the stored file names under  Browse, or as an input of uvmat. 
-% 2) These functions call 'display_file_name.m' which detects the file series, and fills the file index boxes
-% 3) Then 'update_rootinfo.m' Updates information about a new field series (indices to scan, timing, calibration from an xml file)
-% 4) Then fields are opened and visualised by the main sub-function 'refresh_field.m'
-% The function first reads the name of the input file from the edit boxes  of the GUI
-% A second input file can be introduced for file comparison
-% It then reads the input file(s) with the appropriate function, read for
-% images, read_civxdata.m for CIVx PIV data, nc2struct for other netcdf
-% files.
-%               Main input open   second input open(_1)        second image (pair animation) 
-%            |                 |                             
-%            |                 |                                                
-%                     Field{1}         Field{2}               
-%                                                                         |
-% coord transform (phys.m) or other user defined  fct acting on Field{i}  |
-%                                                                   Field{i}
-%                                                                    |
-% calc_field.m: calculate scalar or other derived fields (vort, div..).
+% (second field), or by the stored file name .FileName_1, or as an input of uvmat. 
+% 2) These functions call 'uvmat/display_file_name.m' which detects the file series, and fills the file index boxes
+% 3) Then 'uvmat/update_rootinfo.m' Updates information about a new field series (indices to scan, timing, calibration from an xml file)
+% 4) Then fields are opened and visualised by the main sub-function 'uvmat/refresh_field.m'
+% The function first reads the name of the input file(s) (one or two) from the edit boxes  of the GUI
+% It then reads the input file(s) with the function read_field.m and perform the following list of operations:
 %
-% sub_field.m: combine the input Field{i} in a single set of fields (vector + scalar):
-%              Field{i=1->3}.X --> UvData.X                          |
-%                                                                    |
-%                                                                 UvData
-%                                                                    |
-% plot histograms of the whole  field
-% proj_field.m: project the set of fields on the current projection objects defined by UvData.Object
-%                                                                    |                                                                          |
-%                                                                ObjectData
-%                                                                    |
-% plot_field.m: plot the projected fields and store them as          |
-% UvData.PlotAxes                                        |
-%                                                                    |
-%                                                                AxeData
+%    %%%%%%%%  structure of uvmat/refresh_field.m %%%%%%%%
+%
+%           Main input open       second input open_1        
+%                    |                   |  
+%             read_field.m            read_field.m
+%                    |                   |
+%                 Field{1}            Field{2}               
+%                    |                   |                                  
+%                    --->transform fct<---             transform (e.g. phys.m) and combine input fields  
+%                            |                                    
+%                        (calc_tps.m)               calculate tps coefficients (for filter projection or spatial derivatives).
+%                            |
+%                       (calc_field.m)               calculate field 
+%                            |
+%                       UvData.Field-------------->histogram
+%               _____________|____________
+%              |                          |                    
+%        proj_field.m               proj_field.m       project the field on the projection objects              
+%              |                          |
+%         UvData.PlotAxes          ViewData.PlotAxes (on view_field)
+%              |                          |
+%       plot_field.m (uvmat)       plot_field.m (view_field)      plot the projected fields
+%
+% rmq: calc_field can be performed instead at the level of proj_field when needed 
+%
 %
 %%%%%%%%%%%%%%    SCALARS: %%%%%%%%%%%%??%%%
@@ -357,5 +356,6 @@
 function MenuBrowse_Callback(hObject, eventdata, handles)
 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
-oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
+%oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
+oldfile=fullfile(RootPath,SubDir);
 if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
          dir_perso=prefdir;
@@ -371,5 +371,5 @@
 fileinput=[PathName FileName];%complete file name 
 if ~exist(fileinput,'file')
-    return %abandon of the browser is cancelled
+    return %abandon if the browser is cancelled
 end
 
@@ -1014,5 +1014,5 @@
     end
 end
-[ref_i,ref_j]=find(i1_series);
+[ref_j,ref_i]=find(i1_series);
 if ~isempty(j1_series) 
         state_j='on';
@@ -1583,10 +1583,10 @@
         if get(handles.scan_i,'Value')==1% case of scanning along index i
             ref_i=ref_i+step;
-            while ref_i>=0  && size(UvData.i1_series{1},1)>=ref_i+1 && UvData.i1_series{1}(ref_i+1,ref_j+1,1)==0
+            while ref_i>=0  && size(UvData.i1_series{1},3)>=ref_i+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0
                 ref_i=ref_i+step;
             end
         else % case of scanning along index j (burst numbers)
             ref_j=ref_j+step;
-            while ref_j>=0  && size(UvData.i1_series{1},2)>=ref_j+1 && UvData.i1_series{1}(ref_i+1,ref_j+1,1)==0
+            while ref_j>=0  && size(UvData.i1_series{1},2)>=ref_j+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0
                 ref_j=ref_j+step;
             end
@@ -1597,5 +1597,5 @@
     elseif ref_j<0
         errormsg='minimum j index reached';
-    elseif ref_i+1>size(UvData.i1_series{1},1)
+    elseif ref_i+1>size(UvData.i1_series{1},3)
         errormsg='maximum i index reached (reload the input file to update the index bound)';
     elseif ref_j+1>size(UvData.i1_series{1},2)
@@ -1603,29 +1603,26 @@
     end
     if ~isempty(errormsg),return,end
-    i1_subseries=UvData.i1_series{1}(ref_i+1,ref_j+1,:);
-    i1_subseries=i1_subseries(i1_subseries>0);
-    if isempty(i1_subseries)% case of pairs
-        i1_subseries=UvData.i1_series{1}(ref_i+1,:,:);
-    end
-    if isempty(i1_subseries),errormsg='no next frame: set num_IndexIncrement =''*'' to reach the next existing file';return
-    else
-        i1=i1_subseries(end);
-    end
+    siz=size(UvData.i1_series{1});
+    ref_indices=ref_i*siz(1)*siz(2)+ref_j*siz(1)+1:ref_i*siz(1)*siz(2)+(ref_j+1)*siz(1);   
+    i1_subseries=UvData.i1_series{1}(ref_indices);
+    ref_indices=ref_indices(i1_subseries>0);
+    if isempty(ref_indices)% case of pairs (free index i)
+        ref_indices=ref_i*siz(1)*siz(2)+1:(ref_i+1)*siz(1)*siz(2); 
+        i1_subseries=UvData.i1_series{1}(ref_indices);
+        ref_indices=ref_indices(i1_subseries>0);
+    end
+    if isempty(ref_indices),errormsg='no next frame: set num_IndexIncrement =''*'' to reach the next existing file';return
+    end
+    i1=UvData.i1_series{1}(ref_indices(end));
     if ~isempty(UvData.i2_series{1})
-        i2_subseries=UvData.i2_series{1}(ref_i+1,ref_j+1,:);
-        i2_subseries=i2_subseries(i2_subseries>0);
-        i2=i2_subseries(end);
+        i2=UvData.i2_series{1}(ref_indices(end));
     end
     if ~isempty(UvData.j1_series{1})
-        j1_subseries=UvData.j1_series{1}(ref_i+1,ref_j+1,:);
-        j1_subseries=j1_subseries(j1_subseries>0);
-        j1=j1_subseries(end);
+        j1=UvData.j1_series{1}(ref_indices(end));
     end
     if ~isempty(UvData.j2_series{1})
-        j2_subseries=UvData.j2_series{1}(ref_i+1,ref_j+1,:);
-        j2_subseries=j2_subseries(j2_subseries>0);
-        j2=j2_subseries(end);
+        j2=UvData.j2_series{1}(ref_indices(end));
     end  
-    % case of a second file series
+    % case of a second file series (TODO:revise)
     if numel(UvData.i1_series)>=2
         i1_subseries=UvData.i1_series{2}(ref_i+1,ref_j+1,:);
@@ -1705,5 +1702,5 @@
 UvData=get(handles.uvmat,'UserData');
 if isequal(FieldName,'image')
-    test_1=0;
+    index=1;
     [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles);
     NomType=get(handles.NomType,'String');
@@ -1713,5 +1710,5 @@
     FieldName=list_fields{index_fields}; % selected field
     if isequal(FieldName,'image')
-        test_1=1;
+        index=2;
         [RootPath,tild,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles);
     else
@@ -1739,6 +1736,10 @@
     num_i2=num_i1;%repeat the index i1 by default
 end
-% imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
 imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i2,[],num_j2);
+if strcmp(NomType,'*')
+    num_frame=num_i2;
+else
+    num_frame=num_j2;
+end
 if ~exist(imaname_1,'file')
       msgbox_uvmat('ERROR',['second input open (-)  ' imaname_1 ' not found']);
@@ -1748,70 +1749,77 @@
 end
 
+%% get the first image
+%Field.AName='image';
+if index==1
+    Field_a=UvData.Field;% movie on the second field
+else
+    Field_a=UvData.Field_1;% movie on the first field
+end
+
 %% read the second image
-Field.AName='image';
-if test_1
-    Field_a=UvData.Field_1;
-else
-    Field_a=UvData.Field;
-end
-Field_b.AX=Field_a.AX;
-Field_b.AY=Field_a.AY;
-% z index
-nbslice=str2double(get(handles.num_NbSlice,'String'));
-if ~isempty(nbslice)
-    Field_b.ZIndex=mod(num_i2-1,nbslice)+1;
-end
-Field_b.CoordUnit='pixel';
-
-%% determine the input file type
-if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1}))
-    FileType='movie';
-elseif isequal(lower(Ext),'.avi')
-    FileType='avi';
-elseif isequal(lower(Ext),'.vol')
-    FileType='vol';
-else 
-   form=imformats(Ext(2:end));
-   if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
-       if isequal(NomType,'*');
-           FileType='multimage';
-       else
-           FileType='image';
-       end
-   end
-end
-switch FileType
-        case 'movie'
-            if test_1
-                Field_b.A=read(UvData.MovieObject{2},num_i2);
-            else
-                Field_b.A=read(UvData.MovieObject{1},num_i2);
-            end
-        case 'avi'
-            mov=aviread(imaname_1,num_i2);
-            Field_b.A=frame2im(mov(1));
-        case 'vol'
-            Field_b.A=imread(imaname_1);
-        case 'multimage'
-            Field_b.A=imread(imaname_1,num_i2);
-        case 'image'
-            Field_b.A=imread(imaname_1);
-end 
-if get(handles.slices,'Value')
-    Field.ZIndex=str2double(get(handles.z_index,'String'));
-end
+MovieObject=[];
+if numel(UvData.MovieObject)>=index
+    MovieObject=UvData.MovieObject{index};
+end
+[Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},MovieObject,num_frame)
+% Field_b.AX=Field_a.AX;
+% Field_b.AY=Field_a.AY;
+% % z index
+% nbslice=str2double(get(handles.num_NbSlice,'String'));
+% if ~isempty(nbslice)
+%     Field_b.ZIndex=mod(num_i2-1,nbslice)+1;
+% end
+% Field_b.CoordUnit='pixel';
+% 
+% %% determine the input file type
+% if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1}))
+%     FileType='movie';
+% elseif isequal(lower(Ext),'.avi')
+%     FileType='avi';
+% elseif isequal(lower(Ext),'.vol')
+%     FileType='vol';
+% else 
+%    form=imformats(Ext(2:end));
+%    if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
+%        if isequal(NomType,'*');
+%            FileType='multimage';
+%        else
+%            FileType='image';
+%        end
+%    end
+% end
+% switch FileType
+%         case 'movie'
+%             if test_1
+%                 Field_b.A=read(UvData.MovieObject{2},num_i2);
+%             else
+%                 Field_b.A=read(UvData.MovieObject{1},num_i2);
+%             end
+%         case 'avi'
+%             mov=aviread(imaname_1,num_i2);
+%             Field_b.A=frame2im(mov(1));
+%         case 'vol'
+%             Field_b.A=imread(imaname_1);
+%         case 'multimage'
+%             Field_b.A=imread(imaname_1,num_i2);
+%         case 'image'
+%             Field_b.A=imread(imaname_1);
+% end 
+% if get(handles.slices,'Value')
+%     Field.ZIndex=str2double(get(handles.z_index,'String'));
+% end
 
 %px to phys or other transform on field
-menu_transform=get(handles.transform_fct,'String');
-choice_value=get(handles.transform_fct,'Value');
-transform_name=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
-transform_list=get(handles.transform_fct,'UserData');
-transform=transform_list{choice_value};
-if  ~isequal(transform_name,'') && ~isequal(transform_name,'px')
-    if test_1 && isfield(UvData,'XmlData') && numel(UvData.XmlData)==2 && isfield(UvData.XmlData{2},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
-        Field_a=transform(Field_a,UvData.XmlData{2});%the first field has been stored without transform
-        Field_b=transform(Field_b,UvData.XmlData{2});
-    elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib
-        Field_b=transform(Field_b,UvData.XmlData{1});
+% menu_transform=get(handles.transform_fct,'String');
+% choice_value=get(handles.transform_fct,'Value');
+% transform_name=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
+% transform_list=get(handles.transform_fct,'UserData');
+transform=get(handles.path_transform,'UserData');
+if  ~isempty(transform)
+    if isfield(UvData,'XmlData') && numel(UvData.XmlData)>=index %use geometry calib recorded from the ImaDoc xml file as first priority
+        if index==2
+        Field_a=transform(Field_a,UvData.XmlData{index});%the first field has been stored without transform
+        end
+        Field_b=transform(Field_b,UvData.XmlData{index});
     end
 end
@@ -2249,4 +2257,8 @@
 %% store the current open names, fields and vel types in uvmat interface 
 UvData.FileName_1=FileName_1;
+UvData.ParamOut_1=ParamOut_1;
+if numel(Field)==2
+UvData.Field_1=Field{2}; %store the second field for possible use at next RUN
+end
 
 %% apply coordinate transform or other user fct
@@ -2262,18 +2274,21 @@
     end
     transform=get(handles.path_transform,'UserData');
-    nbre_arg=nargin(transform);
-    if length(Field)==2
-        if nbre_arg==4
-            [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
-        else
-            Field{1}=transform(Field{1},XmlData);
-            Field(2)=[];
-        end
-    else
-        if nbre_arg==1
-            Field{1}=transform(Field{1});%transform which does not need input parameter
-        else
-            Field{1}=transform(Field{1},XmlData);
-        end
+    switch nargin(transform)
+        case 4
+            if length(Field)==2
+                UvData.Field=transform(Field{1},XmlData,Field{2},XmlData_1);
+            else
+                UvData.Field=transform(Field{1},XmlData);
+            end
+        case 3
+            if length(Field)==2
+                UvData.Field=transform(Field{1},XmlData,Field{2});
+            else
+                UvData.Field=transform(Field{1},XmlData);
+            end
+        case 2
+            UvData.Field=transform(Field{1},XmlData);
+        case 1
+            UvData.Field=transform(Field{1});
     end
 end
@@ -2293,8 +2308,8 @@
        check_tps=1;%tps needed to get the requested field
 end
-if (check_tps ||check_proj_tps)&&~isfield(Field{1},'Coord_tps')
-    Field{1}=calc_tps(Field{1});
-end
-Field{1}.FieldList=[{ParamOut.FieldName} {ParamOut.ColorVar}];
+if (check_tps ||check_proj_tps)&&~isfield(UvData.Field,'Coord_tps')
+    UvData.Field=calc_tps(UvData.Field);
+end
+UvData.Field.FieldList=[{ParamOut.FieldName} {ParamOut.ColorVar}];
 
 %% calculate scalar
@@ -2302,5 +2317,5 @@
          &&~strcmp(ParamOut.FieldName,'velocity') && ~strcmp(ParamOut.FieldName,'get_field...') 
     if ~check_proj_tps
-        Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1});
+        UvData.Field=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],UvData.Field);
     end
 end
@@ -2314,17 +2329,4 @@
 end
 
-%% combine the two input fields (e.g. substract velocity fields)
-if numel(Field)==2
-   [UvData.Field,errormsg]=sub_field(Field{1},Field{2});  
-   UvData.Field_1=Field{2}; %store the second field for possible use at next RUN
-   UvData.ParamOut_1=ParamOut_1;
-else
-   UvData.Field=Field{1};
-end
-if ~isempty(errormsg)
-    errormsg=['error in uvmat/refresh_field/sub_field:' errormsg];
-    return
-end
-%UvData.Field.FieldList={FieldName}; % TODO: to generalise, used for proj_field with tps interpolation
 
 %% analyse input field
@@ -2336,7 +2338,7 @@
     return
 end
-[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(UvData.Field);% analyse  the input field structure
+[CellVarIndex,NbDim,VarType,errormsg]=find_field_cells(UvData.Field);% analyse  the input field structure
 if ~isempty(errormsg)
-    errormsg=['error in uvmat/refresh_field/find_field_indices: ' errormsg];% display error
+    errormsg=['error in uvmat/refresh_field/find_field_cells: ' errormsg];% display error
     return
 end
@@ -3513,4 +3515,5 @@
 
 %% create the function handle of the selected fct
+
 if isempty(list_path{ichoice})% case of no selected fct
     transform_handle=[];
@@ -3527,4 +3530,5 @@
 set(handles.path_transform,'String',list_path{ichoice})
 set(handles.path_transform,'UserData',transform_handle)
+set(handles.transform_fct,'UserData',list_path)
 
 %% update the ToolTip string of the menu transform_fct with the first line of the selected fct file
@@ -4806,2 +4810,9 @@
 ProjectDir = uigetdir(fileparts(fileparts(RootPath)), 'select the project source directory');
 datatree_browser(ProjectDir)
+
+
+% --------------------------------------------------------------------
+function MenuBrowseProject_Callback(hObject, eventdata, handles)
+RootPath=get(handles.RootPath,'String');
+ProjectDir = uigetdir(fileparts(fileparts(RootPath)), 'select the project directory');
+datatree_browser(ProjectDir)
