Index: trunk/src/civ.m
===================================================================
--- trunk/src/civ.m	(revision 11)
+++ trunk/src/civ.m	(revision 12)
@@ -22,5 +22,5 @@
 function varargout = civ(varargin)
 
-% Last Modified by GUIDE v2.5 29-Oct-2009 19:05:39
+% Last Modified by GUIDE v2.5 10-Jan-2010 22:04:45
 % Begin initialization code - DO NOT EDIT
 gui_Singleton = 1;
@@ -42,8 +42,8 @@
 % End initialization code - DO NOT EDIT
 
-%--------------------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes just before civ is made visible.
-%--------------------------------------------------------------------------
 function civ_OpeningFcn(hObject, eventdata, handles, varargin)
+%------------------------------------------------------------------------
 % This function has no output args, see OutputFcn.
 % hObject    handle to figure
@@ -106,7 +106,4 @@
 set(handles.ImaDoc,'String',ext)
 
-
-% set(handles.ImaDoc,'String',ext)
-  
 %read names of the .exe file to adjust the interface according to
 %available prog
@@ -125,5 +122,4 @@
 else
     syst='WIN';
-    %fid = fopen(fullfile(path_UVMAT,'PARAM_WIN.txt'),'r');%open the file with civ binary names
     xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml');
     if exist(xmlfile,'file')
@@ -150,19 +146,16 @@
 test_batch=1;
 if ~sge
-if isequal(todo_path,'') || isequal(todo_path,[])
-    display(['no batch distributed processing available:file path TODO.txt not defined in UVMAT/PARAM_' syst])
-    test_batch=0;
-end
-if exist(name_todo,'file')~=2 
-    msgbox_uvmat('WARNING',['no batch distributed processing available, queue file ' name_todo ' absent']);
-  %  test_batch=0;  % Problems to detect file on linux/nfs filesystems
-end
-end
-
-
+    if isequal(todo_path,'') || isequal(todo_path,[])
+        display(['no batch distributed processing available:file path TODO.txt not defined in UVMAT/PARAM_' syst])
+        test_batch=0;
+    end
+    if exist(name_todo,'file')~=2 
+        msgbox_uvmat('WARNING',['no batch distributed processing available, queue file ' name_todo ' absent']);
+      %  test_batch=0;  % Problems to detect file on linux/nfs filesystems
+    end
+end
 if test_batch==0
     set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated)
 end
-
 set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working
 set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working
@@ -215,5 +208,5 @@
 
 % set the range of fields (1:1 by default) and selected pair
-if isempty(num2)|isequal(num2,num1)
+if isempty(num2)||isequal(num2,num1)
     num_ref_i=num1;
 else
@@ -222,5 +215,5 @@
     browse.incr_pair(2)=0;
 end
-if isempty(num_b)|isequal(num_a,num_b)
+if isempty(num_b)||isequal(num_a,num_b)
     if isempty(num_a)
         num_ref_j=1;
@@ -248,9 +241,8 @@
 set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001])
 
-
-%--------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Outputs from this function are returned to the command line.
-%-----------------------------------------------------------------
 function varargout = civ_OutputFcn(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 % varargout  cell array for returning output args (see VARARGOUT);
 % hObject    handle to figure
@@ -260,7 +252,8 @@
 varargout{1} = handles.output;
 
-%------------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in browse_root.
 function browse_root_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 %get the input file properties
 filebase=get(handles.displ_filebase,'String');
@@ -321,5 +314,4 @@
    end
 end
-
 [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput);
 filebase=fullfile(RootPath,RootFile);
@@ -441,16 +433,14 @@
 displ_filebase_Callback(hObject, eventdata, handles);
 
-%------------------------------------------------
-
+%------------------------------------------------------------------------
 function ImaDoc_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 displ_filebase_Callback(hObject, eventdata, handles)
 
-%--------------------------------------------------------------
+%------------------------------------------------------------------------
 %function activated when a new filebase (image series) is introduced
-%------------------------------------------------------------
 function displ_filebase_Callback(hObject, eventdata, handles)
-
+%------------------------------------------------------------------------
 global test_batch
-%set(gcf,'Pointer','watch')
 set(handles.compare,'Visible','on')
 ext_ima=get(handles.ext_ima,'String'); 
@@ -471,8 +461,8 @@
 if ~isempty(browse) 
     if isfield(browse,'nom_type_ima')
-        nom_type_ima=browse.nom_type_ima;
+        nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name
     end
     if isfield(browse,'field_count')
-        field_count=browse.field_count;
+        field_count=browse.field_count;% get an image index type already determined by an input file
     end
 end
@@ -480,9 +470,9 @@
 %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
+if isempty(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
+if isempty(last_i)|| last_i < first_i
     last_i=first_i;  %default last_i
 end
@@ -511,5 +501,4 @@
 
  %look for an image documentation file
-ext
 if ~isequal(ext,'.xml') && ~isequal(ext,'.civ')&& ~isequal(ext,'.avi')&& ~isequal(ext,'.AVI')
     if exist([filebase '.xml'],'file')
@@ -532,10 +521,10 @@
     drawnow
     %read the image documentation file if found
-if isequal(ext,'.civxml') | isequal(ext,'.xml')| isequal(ext,'.civ')
+if isequal(ext,'.civxml') || isequal(ext,'.xml')|| isequal(ext,'.civ')
     set(handles.ref_i,'Visible','On')%use a reference index
     set(handles.ref_j,'Visible','On')
     set(handles.dt,'Visible','Off')
-    set(handles.dt_text,'String','ref. ind.')
-elseif isequal(ext,'.avi') | isequal(ext,'.AVI')
+    set(handles.dt_text,'String','')
+elseif isequal(ext,'.avi') || isequal(ext,'.AVI')
     set(handles.ref_j,'Visible','Off')
     set(handles.dt,'Visible','Off')
@@ -547,4 +536,5 @@
     set(handles.dt_text,'String','dt(ms)=')
 end
+testima_xml=0;
 if isequal(ext,'.civxml')%TO ABANDON
     [nbfield,nburst,time]=read_civxml([filebase '.civxml']);
@@ -562,7 +552,12 @@
     ext_ima_read=[];
     nom_type_read=[];
-    XmlData.Heading
-    if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')
+    if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file
         [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName);
+        fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName) %full name (including path) of the first image defined by the xmle file, 
+        if exist(fullname,'file')
+            testima_xml=1;
+        else
+            msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist'])
+        end
     end
     if isfield(XmlData,'Camera')
@@ -606,6 +601,6 @@
 elseif isequal(ext,'.civ')% case of .civ image documentation file
         [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']);
-        if error==2, warndlg(['no file ' filebase '.civ']);
-        elseif error==1, warndlg('inconsistent number of fields in the .civ file');
+        if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']);
+        elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
         end
 %         ext_ima='.png';
@@ -629,45 +624,66 @@
 set(handles.ImaDoc,'BackgroundColor',[1 1 1])
 
+%get the imabe nomenclature type if not defiend by the input file nor by the xml file
+if isempty(nom_type_ima)
+    %look for double image series '_i_j'
+    dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']);
+    if isempty(dirima)
+       % look for images series  with sub marker '_'
+       dirima=dir([filebase '_*' num2str(first_i) '.*']);
+       if isempty(dirima)
+          % look for other images series 
+          dirima=dir([filebase '*' num2str(first_i) '.*']);
+          if ~isempty(dirima)
+              [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
+          end
+       else
+           [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
+       end
+    else
+       [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
+    end
+end   
+    
 % no image documentation file found: look for a series of existing images or .nc files 
 if isempty(time) && ~isequal(ext,'.nc') 
-        subdir=get(handles.subdir_civ1,'String');
-        incr_pair=[0 0];%default
-        if isfield(browse,'incr_pair')
-                incr_pair=browse.incr_pair;
-        end
-        nbdetect=0;%test of detected images
-        field_i=field_count;
-        idetect=1;
-        while idetect==1 %look for the maximum file number in the series
-                field_i=field_i+1;
+    subdir=get(handles.subdir_civ1,'String');
+    incr_pair=[0 0];%default
+    if isfield(browse,'incr_pair')
+            incr_pair=browse.incr_pair;
+    end
+    nbdetect=0;%test of detected images
+    field_i=field_count;
+    idetect=1;
+    while idetect==1 %look for the maximum file number in the series
+            field_i=field_i+1;
+            imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima);
+            if strcmp(nom_type_ima,'none')||strcmp(nom_type_ima,'')
+               idetect=0; %stop if the same image is repeated (if nom_type='none')
+               nbdetect=1;
+            else
+                idetect=(exist(imagename,'file')==2);
+            end
+            %SEE CASE OF NETCDF FILES
+            nbdetect=nbdetect+(exist(imagename,'file')==2);
+    end
+    nb_field=field_i;% last detected field number
+    field_i=field_count;%look for the minimum file number in the series
+    idetect=1;
+    while idetect==1 
+                field_i=field_i-1;
                 imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima);
-                if strcmp(nom_type_ima,'none')||strcmp(nom_type_ima,'')
-                   idetect=0; %stop if the same image is repeated (if nom_type='none')
-                   nbdetect=1;
+                if isequal(nom_type_ima,'none')||strcmp(nom_type_ima,'')
+                    idetect=0; %stop if the same image is repeated (if nom_type='none')
+                    nbdetect=1;
                 else
                     idetect=(exist(imagename,'file')==2);
                 end
-                %SEE CASE OF NETCDF FILES
-                nbdetect=nbdetect+(exist(imagename,'file')==2);
-        end
-        nb_field=field_i;% last detected field number
-        field_i=field_count;%look for the minimum file number in the series
-        idetect=1;
-        while idetect==1 
-                    field_i=field_i-1;
-                    imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima);
-                    if isequal(nom_type_ima,'none')||strcmp(nom_type_ima,'')
-                        idetect=0; %stop if the same image is repeted (if nom_type='none')
-                        nbdetect=1;
-                    else
-                        idetect=(exist(imagename,'file')==2);
-                    end
-                    nbdetect=nbdetect+idetect;
-        end
-        first_i=max(field_i+1,1);
-            %determine the set of times and possible intervals for CIV
-        dt=(1/1000)*str2num(get(handles.dt,'String'));
-        time=(dt*[0:nb_field-1])';
-        set(handles.mode,'String',{'series(Di)'})
+                nbdetect=nbdetect+idetect;
+    end
+    first_i=max(field_i+1,1);
+        %determine the set of times and possible intervals for CIV
+    dt=(1/1000)*str2num(get(handles.dt,'String'));
+    time=(dt*[0:nb_field-1])';
+    set(handles.mode,'String',{'series(Di)'})
 end
 if isequal(nom_type_ima,'none')% no file numbering used
@@ -683,8 +699,8 @@
         set(handles.displ_filebase,'UserData',time); %store the set of times
         if isempty(TimeUnit)
-            set(handles.dt_unit,'String','e-03');
+            set(handles.dt_unit,'String','dt in e-03');
             set(handles.TimeUnit,'String','');
         else
-            set(handles.dt_unit,'String',['m' TimeUnit]);
+            set(handles.dt_unit,'String',['dt in m' TimeUnit]);
             set(handles.TimeUnit,'String',TimeUnit);
         end
@@ -780,10 +796,9 @@
 set(gcf,'Pointer','arrow')
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%????????????
+%------------------------------------------------------------------------
 % --- Executes on button press in mode.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 function mode_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 browse=get(handles.browse_root,'UserData');
-
 compare_list=get(handles.compare,'String');
 val=get(handles.compare,'Value');
@@ -813,7 +828,4 @@
     displ_dt=1;%default
     nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10
-%     if nbfield2<2
-%         nbfield2=2,
-%     end
     for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode
         for numod_b=(numod_a+1):nbfield2
@@ -938,9 +950,9 @@
 find_netcpair_civ2(hObject, eventdata, handles)
 
-%--------------------------------------------------------------
+%------------------------------------------------------------------------
 % determine the menu for civ1 pairs depending on existing netcdf file at the middle of
 % the field series set by first_i, incr, last_i
-%----------------------------------------------------------------
 function find_netcpair_civ1(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 set(gcf,'Pointer','watch')
 %nomenclature types
@@ -971,6 +983,4 @@
 end
 if isempty(nom_type_nc)
-    'TESTciv'
-    nom_type_ima
      [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)'));
 end
@@ -993,8 +1003,4 @@
 else
     ref_j=str2num(get(handles.ref_j,'String'));
-end
-if isequal(get(handles.dt_text,'String'),'dt(ms)=')%simple series(Di) with equal interval
-    ref_i=floor((first_i+last_i)/2);
-    ref_j=1;
 end
 time=get(handles.displ_filebase,'UserData');%get the set of times
@@ -1127,9 +1133,10 @@
 set(handles.list_pair_civ2,'String',displ_pair');
 set(gcf,'Pointer','arrow')
-%--------------------------------------------------------------
+
+%------------------------------------------------------------------------
 % determine the menu for civ2 pairs depending on the existing netcdf file at the 
 %middle of the series set by first_i, incr, last_i 
-%--------------------------------------------------------------
 function find_netcpair_civ2(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 set(gcf,'Pointer','watch')
 %nomenclature types
@@ -1265,13 +1272,4 @@
           end
        end
-%    else
-%        for ipair=1:nbpair
-%          if select(ipair)
-%             displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt_unit*ipair)];
-%          else 
-%             displ_pair{ipair}='...'; %pair not displayed in the menu
-%          end
-%        end
-%     end
 elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index
        for ipair=1:nbpair
@@ -1310,12 +1308,11 @@
 end
 set(handles.list_pair_civ2,'String',displ_pair');
-
-
 set(gcf,'Pointer','arrow')
-%----------------------------------------------------
+
+%------------------------------------------------------------------------
 %  determine the list of index pairs of processing file 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=...
     find_pair_indices(handles,mode)
+%------------------------------------------------------------------------
 first_i=str2num(get(handles.first_i,'String'));
 last_i=str2num(get(handles.last_i,'String'));
@@ -1459,9 +1456,8 @@
 end
 
-
-%-------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on selection change in list_pair_civ1.
 function list_pair_civ1_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------
+%------------------------------------------------------------------------
 %reproduce by default the chosen pair in the civ2 menu
 list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs
@@ -1507,8 +1503,8 @@
 end 
 
-%------------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on selection change in list_pair_civ2.
 function list_pair_civ2_Callback(hObject, eventdata, handles)
-
+%------------------------------------------------------------------------
 index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu 
 
@@ -1545,8 +1541,8 @@
 end 
 
-%---------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in RUN.
-%------------------------------------------------------
 function RUN_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 global civ1_exe civ2_exe patch_exe patch_new_exe sge
 
@@ -1583,14 +1579,26 @@
 %check mask if selecetd
 if isequal(get(handles.get_mask_civ1,'Value'),1)
-     get_mask_civ1_Callback(hObject, eventdata, handles);
+    maskname=get(handles.mask_civ1,'String');
+    if ~exist(maskname,'file')
+        get_mask_civ1_Callback(hObject, eventdata, handles);
+    end
 end
 if isequal(get(handles.get_mask_fix1,'Value'),1)
+    maskname=get(handles.mask_fix1,'String');
+    if ~exist(maskname,'file')
      get_mask_fix1_Callback(hObject, eventdata, handles);
+    end
 end
 if isequal(get(handles.get_mask_civ2,'Value'),1)
+    maskname=get(handles.mask_civ2,'String');
+    if ~exist(maskname,'file')
      get_mask_civ2_Callback(hObject, eventdata, handles);
+    end
 end
 if isequal(get(handles.get_mask_fix2,'Value'),1)
+    maskname=get(handles.mask_fix2,'String');
+    if ~exist(maskname,'file')
      get_mask_fix2_Callback(hObject, eventdata, handles);
+    end
 end
 
@@ -1651,4 +1659,11 @@
 [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
        set_civ_filenames(handles,compare,box_test);
+if isempty(filecell)
+   set(handles.RUN, 'Enable','On')
+    set(handles.RUN,'BackgroundColor',[1 0 0])
+    set(handles.BATCH, 'Enable','On')
+    set(handles.BATCH,'BackgroundColor',[1 0 0])
+   return
+end
 display('files OK, processing...')   
 nbfield=size(num1_civ1,2);
@@ -1688,7 +1703,14 @@
     end   
     h = waitbar(0,['removing velocity vectors, fix1']);% display a wait bar 
-    test_mask=get(handles.get_mask_fix1,'Value');
-    maskdispl=get(handles.mask_fix1,'String');
-    maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name
+    test_mask=get(handles.get_mask_fix1,'Value');    
+    if test_mask
+        maskdispl=get(handles.mask_fix1,'String');
+        if exist(maskdispl,'file')
+            test_mask=2;
+            maskname=maskdispl;
+        else
+            maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name
+        end
+    end
     for ifile=1:nbfield
         waitbar(ifile/nbfield); %update the waitbar
@@ -1697,5 +1719,5 @@
                 maskname='noFile use default';
                 maskflag=0;
-            else
+            elseif test_mask==1
                 nbslice_mask=str2num(maskdispl(1:end-4)); % 
                 num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1;
@@ -1838,6 +1860,13 @@
     h = waitbar(0,['removing velocity vectors, fix2']);% display a wait bar
     test_mask=get(handles.get_mask_fix2,'Value');
-    maskdispl=get(handles.mask_fix2,'String');
-    maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name
+    if test_mask
+        maskdispl=get(handles.mask_fix2,'String');
+        if exist(maskdispl,'file')
+            test_mask=2;
+            maskname=maskdispl;
+        else
+            maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name
+        end
+    end
     for ifile=1:nbfield
         waitbar(ifile/nbfield); %update the waitbar
@@ -1846,5 +1875,5 @@
                 maskname='noFile use default';
                 maskflag=0;
-           else
+           elseif test_mask==1
                 nbslice_mask=str2num(maskdispl(1:end-4)); % 
                 num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1;
@@ -1984,9 +2013,8 @@
 saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER  .xml)
 
-
-%-----------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in BATCH: remote processing
-%-----------------------------------------------------------
 function BATCH_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe
 compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3)
@@ -2024,14 +2052,26 @@
 %check mask if selecetd
 if isequal(get(handles.get_mask_civ1,'Value'),1)
-     get_mask_civ1_Callback(hObject, eventdata, handles);
+    maskname=get(handles.mask_civ1,'String');
+    if ~exist(maskname,'file')
+        get_mask_civ1_Callback(hObject, eventdata, handles);
+    end
 end
 if isequal(get(handles.get_mask_fix1,'Value'),1)
-     get_mask_fix1_Callback(hObject, eventdata, handles);
+    maskname=get(handles.mask_fix1,'String');
+    if ~exist(maskname,'file')
+        get_mask_fix1_Callback(hObject, eventdata, handles);
+    end
 end
 if isequal(get(handles.get_mask_civ2,'Value'),1)
+    maskname=get(handles.mask_civ2,'String');
+    if ~exist(maskname,'file')
      get_mask_civ2_Callback(hObject, eventdata, handles);
+    end
 end
 if isequal(get(handles.get_mask_fix2,'Value'),1)
+    maskname=get(handles.mask_fix2,'String');
+    if ~exist(maskname,'file')
      get_mask_fix2_Callback(hObject, eventdata, handles);
+    end
 end
 
@@ -2275,7 +2315,8 @@
         cmd='';
         if sge
+           %fid=fopen([filename '.cmx'],'w')
            cmd='#!/bin/bash';
-           cmd=char({cmd;'#$ -cwd'});
-           cmd=char({cmd;'hostname && date'});
+           cmd=[cmd '\n' '#$ -cwd'];
+           cmd=[cmd '\n' 'hostname && date'];
         end
         if civAll
@@ -2307,13 +2348,18 @@
             else
                 maskdispl=get(handles.mask_civ1,'String');
-                maskbase=[filebase '_' maskdispl]; % 
-                nbslice_mask=str2num(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');
-                if exist(par_civ1.maskname,'file')
-                    par_civ1.maskflag='y'; 
+                if exist(maskdispl,'file')
+                    par_civ1.maskname=maskdispl;
+                    par_civ1.maskflag='y';   
                 else
-                    par_civ1.maskname='noFile use default';
-                    par_civ1.maskflag='n'; 
+                    maskbase=[filebase '_' maskdispl]; % 
+                    nbslice_mask=str2num(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');
+                    if exist(par_civ1.maskname,'file')
+                        par_civ1.maskflag='y'; 
+                    else
+                        par_civ1.maskname='noFile use default';
+                        par_civ1.maskflag='n'; 
+                    end
                 end
             end
@@ -2346,5 +2392,5 @@
             i_cmd=i_cmd+1;
             if isequal(civAll,0)
-                cmd=char({cmd;BATCH_CIV1(filename_cmx([1:end-4]),namelog,par_civ1,handles)});
+                cmd=[cmd '\n' BATCH_CIV1(filename_cmx(1:end-4),namelog,par_civ1,handles)];
             else
                  civAllCmd=[civAllCmd ' civ1 '];
@@ -2378,5 +2424,5 @@
                    ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ...
                    ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname];
-           cmd=char({cmd ;cmd_FIX});
+           cmd=[cmd '\n' cmd_FIX];
            else
                 fix1.inputFileName=filecell.nc.civ1{ifile,j} ;
@@ -2403,5 +2449,5 @@
         if isequal(civAll,0)
             cmd_PATCH=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp);
-            cmd=char({cmd ;cmd_PATCH});
+            cmd=[cmd '\n' cmd_PATCH];
         else
             patch1.inputFileName=filecell.nc.civ1{ifile,j} ;
@@ -2471,13 +2517,18 @@
             else
                 maskdispl=get(handles.mask_civ2,'String');
-                maskbase=[filebase '_' maskdispl]; % 
-                nbslice_mask=str2num(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');
-                if exist(par_civ2.maskname,'file')
-                    par_civ2.maskflag='y'; 
+                if exist(maskdispl,'file')
+                    par_civ2.maskname=maskdispl;
+                    par_civ2.maskflag='y';
                 else
-                    par_civ2.maskname='noFile use default';
-                    par_civ2.maskflag='n'; 
+                    maskbase=[filebase '_' maskdispl]; % 
+                    nbslice_mask=str2num(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');
+                    if exist(par_civ2.maskname,'file')
+                        par_civ2.maskflag='y'; 
+                    else
+                        par_civ2.maskname='noFile use default';
+                        par_civ2.maskflag='n'; 
+                    end
                 end
             end
@@ -2510,7 +2561,7 @@
             if isequal(civAll,0)
                 if(isunix)
-                    cmd=char({cmd ; ['cp -f ' filename_cmx '2 ' filename_cmx]; cmd_CIV2});
+                    cmd=[cmd '\n' 'cp -f ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2];
                 else
-                    cmd=char({cmd ; ['copy /Y ' filename_cmx '2 ' filename_cmx]; cmd_CIV2});
+                    cmd=[cmd '\n' 'copy /Y ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2];
                 end
             else
@@ -2530,5 +2581,5 @@
      
      % FIX2
-       if box_test(5)==1
+     if box_test(5)==1
            test_mask=get(handles.get_mask_fix2,'Value');    
             if test_mask==0  
@@ -2545,5 +2596,5 @@
                    ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ...
                    ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname];
-                cmd=char({cmd ;cmd_FIX});
+                cmd=[cmd '\n' cmd_FIX];
            else                      
                 fix2.inputFileName=filecell.nc.civ2{ifile,j} ;
@@ -2567,80 +2618,81 @@
        
      %PATCH2
-    if box_test(6)==1
-        if isequal(civAll,0)
-            cmd_PATCH=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp);
-            cmd=char({cmd; cmd_PATCH});
+       if box_test(6)==1
+            if isequal(civAll,0)
+                cmd_PATCH=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp);
+                cmd=[cmd '\n' cmd_PATCH];
+            else
+                patch2.inputFileName=filecell.nc.civ1{ifile,j} ;
+                patch2.nopt=subdomain_patch1;
+                patch2.maxdiff=thresh_patch1;
+                patch2.ro=rho_patch1;
+                test_grid=get(handles.get_gridpatch2,'Value');
+                if test_grid
+                    patch2.gridflag='y';
+                    gridname=get(handles.grid_patch2,'String');
+                    if isequal(gridname(end-3:end),'grid')
+                        nbslice_grid=str2num(gridname(1:end-4)); %
+                        if ~isempty(nbslice_grid)
+                            num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1;
+                            patch2.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
+                            if ~exist(patch2.gridPatch,'file')
+                               msgbox_uvmat('ERROR','grid file absent for patch2') 
+                            end
+                        elseif exist(gridname,'file')
+                            patch2.gridPatch=gridname; 
+                        else
+                            msgbox_uvmat('ERROR','grid file absent for patch2')
+                        end
+                    end
+                else
+                      patch2.gridPatch='n';
+                      patch2.gridflag='n';
+                      patch2.m=nx_patch2;
+                      patch2.n=ny_patch2;
+                end
+                patch2.convectFlow='n';
+                fieldnames=fields(patch2);
+                [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2');
+                for ilist=1:length(fieldnames)
+                   val=eval(['patch2.' fieldnames{ilist}]);
+                   if ischar(val)
+                      [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist});
+                      [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);
+                   end
+                end             
+                civAllCmd=[civAllCmd ' patch2 '];
+            end     
+        end
+        if isequal(civAll,1)
+            save(civAllxml,[filename_cmx([1:end-4]) '.xml']);
+            cmd=char({cmd;[Civ_exe ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]});
+        end
+
+      % create the .bat file:
+        if sge
+                [Rootbat,Filebat,extbat]=fileparts(filename_cmx);
+                filename_bat=fullfile(Rootbat,['job_' Filebat extbat]);
         else
-            patch2.inputFileName=filecell.nc.civ1{ifile,j} ;
-            patch2.nopt=subdomain_patch1;
-            patch2.maxdiff=thresh_patch1;
-            patch2.ro=rho_patch1;
-            test_grid=get(handles.get_gridpatch2,'Value');
-            if test_grid
-                 patch2.gridflag='y';
-                gridname=get(handles.grid_patch2,'String');
-                if isequal(gridname(end-3:end),'grid')
-                    nbslice_grid=str2num(gridname(1:end-4)); %
-                    if ~isempty(nbslice_grid)
-                        num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1;
-                        patch2.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
-                        if ~exist(patch2.gridPatch,'file')
-                           msgbox_uvmat('ERROR','grid file absent for patch2') 
-                        end
-                    elseif exist(gridname,'file')
-                        patch2.gridPatch=gridname; 
-                    else
-                        msgbox_uvmat('ERROR','grid file absent for patch2')
-                    end
-                end
+            filename_bat=filename_cmx;
+        end
+        filename_bat(end-2:end)='bat';
+        fid=fopen(filename_bat,'w');
+        fprintf(fid,cmd)
+        fclose(fid)
+        %dlmwrite(filename_bat,cmd,'');%write commands in filename_bat
+        if sge
+            pvalue=num2str((1-ind_answer)*500);
+            namelog=[filename_bat '.patch.log'];
+            ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat];
+            eval(  ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]);
+        else
+            if(isunix)
+              cmdtodo=['. ' filename_bat ];%removed for Mathieu tests %' && rm -f ' filename_bat] ;
             else
-                  patch2.gridPatch='n';
-                  patch2.gridflag='n';
-                  patch2.m=nx_patch2;
-                  patch2.n=ny_patch2;
+               cmdtodo=[filename_bat];%removed for Mathieu tests %' && del /F /Q ' filename_bat' ;
             end
-            patch2.convectFlow='n';
-            fieldnames=fields(patch2);
-            [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2');
-            for ilist=1:length(fieldnames)
-               val=eval(['patch2.' fieldnames{ilist}]);
-               if ischar(val)
-                  [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist});
-                  [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);
-               end
-            end             
-            civAllCmd=[civAllCmd ' patch2 '];
-        end     
-    end
-    if isequal(civAll,1)
-         civAllxml
-        save(civAllxml,[filename_cmx([1:end-4]) '.xml']);
-        cmd=char({cmd;[Civ_exe ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]});
+            count= fprintf(p1,'%s\n', cmdtodo);
+        end
      end
-              
-  % create the .bat file:
-	if sge
-    		[Rootbat,Filebat,extbat]=fileparts(filename_cmx);
-    		filename_bat=fullfile(Rootbat,['job_' Filebat extbat]);
-	else
-  		filename_bat=filename_cmx;
-	end
-  filename_bat(end-2:end)='bat';
-
-    dlmwrite(filename_bat,cmd,'');%write commands in filename_bat
-    if sge
-        pvalue=num2str((1-ind_answer)*500);
-        namelog=[filename_bat '.patch.log'];
-        ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat];
-        eval(  ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]);
-    else
-        if(isunix)
-          cmdtodo=['. ' filename_bat ];%removed for Mathieu tests %' && rm -f ' filename_bat] ;
-        else
-           cmdtodo=[filename_bat];%removed for Mathieu tests %' && del /F /Q ' filename_bat' ;
-        end
-        count= fprintf(p1,'%s\n', cmdtodo);
-    end
- end
 end
 if ~sge
@@ -2676,6 +2728,5 @@
 saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER  .xml)
 
-
-%----------------------------------------------------------
+%------------------------------------------------------------------------
 %OUTPUT:
 % filecell: structure of input and output files
@@ -2687,8 +2738,7 @@
 %         .ncA.civ1{i,j}, .ncA.civ2{i,j}; set of nc files for PIV results with camA (then .nc corresponds to camB)
 %         .st{i,j};   set of nc files for the combined stereo fields
-
 function [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
     set_civ_filenames(handles,compare,box_test)
-
+%------------------------------------------------------------------------
 %get the filename root, nomenclature and numbers
 filebase=get(handles.displ_filebase,'String');
@@ -2795,8 +2845,5 @@
                 if ~exist(file_ref,'file')
                     msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1'])
-                    set(handles.RUN, 'Enable','On')
-                    set(handles.RUN,'BackgroundColor',[1 0 0])
-                    set(handles.BATCH, 'Enable','On')
-                    set(handles.BATCH,'BackgroundColor',[1 0 0])
+                    filecell=[];
                     return
                 end
@@ -2849,8 +2896,5 @@
                 if ~exist(file_ref,'file')
                     msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2'])
-                    set(handles.RUN, 'Enable','On')
-                    set(handles.RUN,'BackgroundColor',[1 0 0])
-                    set(handles.BATCH, 'Enable','On')
-                    set(handles.BATCH,'BackgroundColor',[1 0 0])
+                    filecell=[];
                     return
                 end
@@ -2868,5 +2912,6 @@
 [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ)
 if ~exist(Path_ima,'dir')
-    warndlg_uvmat(['path to images ' Path_ima ' not found'],'ERROR')
+    msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found'])
+    filecell=[];
     return
 end
@@ -2877,4 +2922,5 @@
 if ~isempty(message) & ~isequal(message.UserWrite,1)
       msgbox_uvmat('ERROR',['No writting access to ' Path_ima])
+      filecell=[];
       cd(currentdir);
       return
@@ -2947,9 +2993,5 @@
           if idetectmin==0,
                 msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found'])
-                set(handles.RUN, 'Enable','On')
-                set(handles.RUN,'BackgroundColor',[1 0 0])
-                set(handles.BATCH, 'Enable','On')
-                set(handles.BATCH,'BackgroundColor',[1 0 0])
-                cd(currentdir)
+                filecell=[];
                 return
           end
@@ -2957,8 +2999,5 @@
           if idetectmin==0,
                 msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found'])
-                set(handles.RUN, 'Enable','On')
-                set(handles.RUN,'BackgroundColor',[1 0 0])
-                set(handles.BATCH, 'Enable','On')
-                set(handles.BATCH,'BackgroundColor',[1 0 0])
+                filecell=[];
                 cd(currentdir)
                 return
@@ -2978,20 +3017,14 @@
               if idetectmin==0,
                     msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found'])
-                    set(handles.RUN, 'Enable','On')
-                    set(handles.RUN,'BackgroundColor',[1 0 0])
-                    set(handles.BATCH, 'Enable','On')
-                    set(handles.BATCH,'BackgroundColor',[1 0 0])
-                      cd(currentdir)
-                      return
+                    filecell=[];
+                    cd(currentdir)
+                    return
               end
                [idetectmin,indexj]=min(idetect_1);
                if idetectmin==0,
-                    msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found'])
-                    set(handles.RUN, 'Enable','On')
-                    set(handles.RUN,'BackgroundColor',[1 0 0])
-                    set(handles.BATCH, 'Enable','On')
-                    set(handles.BATCH,'BackgroundColor',[1 0 0])
-                    cd(currentdir)
-                    return
+                   msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found'])
+                  filecell=[];
+                  cd(currentdir)
+                  return
                end
          end
@@ -3019,4 +3052,5 @@
                         set(handles.BATCH, 'Enable','On')
                     set(handles.BATCH,'BackgroundColor',[1 0 0])
+                    filecell=[];
                         cd(currentdir)
                         return
@@ -3096,8 +3130,5 @@
                 if ~exist(filename,'file')
                     msgbox_uvmat('ERROR',['input file ' filename ' not found'])
-                    set(handles.RUN, 'Enable','On')
-                    set(handles.RUN,'BackgroundColor',[1 0 0])
-                     set(handles.BATCH, 'Enable','On')
-                    set(handles.BATCH,'BackgroundColor',[1 0 0])
+                  filecell=[];
                     return
                 end
@@ -3107,8 +3138,5 @@
                         if isempty(Data.civ2)||isequal(Data.civ2,0)
                             msgbox_uvmat('ERROR',['no civ2 data in ' filename])
-                            set(handles.RUN, 'Enable','On')
-                            set(handles.RUN,'BackgroundColor',[1 0 0])
-                            set(handles.BATCH, 'Enable','On')
-                            set(handles.BATCH,'BackgroundColor',[1 0 0])
+                            filecell=[];
                             return
                         end  
@@ -3117,8 +3145,5 @@
                         if isempty(Data.patch)||isequal(Data.patch,0)
                             msgbox_uvmat('ERROR',['no patch data in ' filename])
-                            set(handles.RUN, 'Enable','On')
-                            set(handles.RUN,'BackgroundColor',[1 0 0])
-                            set(handles.BATCH, 'Enable','On')
-                            set(handles.BATCH,'BackgroundColor',[1 0 0])
+                            filecell=[];
                             return
                         end
@@ -3170,8 +3195,5 @@
             if idetectmin==0,
                     msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found'])
-                    set(handles.RUN, 'Enable','On')
-                    set(handles.RUN,'BackgroundColor',[1 0 0])
-                           set(handles.BATCH, 'Enable','On')
-                    set(handles.BATCH,'BackgroundColor',[1 0 0])
+                    filecell=[];
                     return
             end
@@ -3192,8 +3214,5 @@
             if idetectmin==0,
                     msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found'])
-                    set(handles.RUN, 'Enable','On')
-                    set(handles.RUN,'BackgroundColor',[1 0 0])
-                           set(handles.BATCH, 'Enable','On')
-                    set(handles.BATCH,'BackgroundColor',[1 0 0])
+                    filecell=[];
                     return
             end
@@ -3212,8 +3231,5 @@
                 if ~exist(filename,'file')
                     msgbox_uvmat('ERROR',['input file ' filename ' not found'])
-                    set(handles.RUN, 'Enable','On')
-                    set(handles.RUN,'BackgroundColor',[1 0 0])
-                    set(handles.BATCH, 'Enable','On')
-                    set(handles.BATCH,'BackgroundColor',[1 0 0])
+                    filecell=[];
                     return
                 else
@@ -3221,8 +3237,5 @@
                     if isempty(Data.civ2)||isequal(Data.civ2,0)         
                         msgbox_uvmat('ERROR',['no civ2 data in ' filename])
-                        set(handles.RUN, 'Enable','On')
-                        set(handles.RUN,'BackgroundColor',[1 0 0])
-                        set(handles.BATCH, 'Enable','On')
-                        set(handles.BATCH,'BackgroundColor',[1 0 0])
+                        filecell=[];
                         return
                     end
@@ -3325,8 +3338,8 @@
 end
 
-%---------------------------------------------------------
+%------------------------------------------------------------------------
 %CIV1  CIV1  CIV1 CIV1
-%----------------------------------------------------------
 function RUN_CIV1(handles,filecell,filecell_1,filecell_nc1,num1,num2,num_a,num_b,nom_type_nc)
+%------------------------------------------------------------------------
 %pixels per cm and matrix of the image times, read from the .civ file by uvmat
 global civ1_exe sge%name of the executable for civ1 calculation
@@ -3490,5 +3503,40 @@
 		'ImageUsedBefore null null'};
 		textout=char(textcmx);
-		dlmwrite(filename_cmx,textout,'');
+% 		dlmwrite(filename_cmx,textout,'');
+        
+        
+     fid=fopen([filename_cmx],'w');
+fprintf(fid, ['##############   CMX file' '\n']);
+ fprintf(fid,   ['FirstImage ' filename_ima '\n' ]);
+ fprintf(fid,   ['LastImage  ' filename_ima_1 '\n' ]);
+  fprintf(fid,  ['XX' '\n' ]);
+  fprintf(fid,  ['Mask '  maskflag '\n' ]);
+  fprintf(fid,  ['MaskName '  maskname '\n' ]);
+ fprintf(fid,   ['ImageSize '  npx ' '  npy '\n' ]);   %VERIFIER CAS GENERAL ?
+ fprintf(fid,   ['CorrelationBoxesSize '  ibx ' '  iby '\n' ]);
+ fprintf(fid,   ['SearchBoxeSize '  isx ' '  isy '\n' ]);
+ fprintf(fid,   ['RO '  rho '\n' ]);
+ fprintf(fid,   ['GridSpacing '  dx ' '  dy '\n' ]);
+ fprintf(fid,   ['XX 1.0' '\n' ]);
+ fprintf(fid,   ['Dt_TO '  Dt ' '  T0 '\n' ]);
+  fprintf(fid,  ['PixCmXY '  pxcmx ' '  pxcmy '\n' ]);
+  fprintf(fid,  ['XX 1' '\n' ]);
+ fprintf(fid,   ['ShiftXY '  shiftx ' '   shifty '\n' ]);
+  fprintf(fid,  ['Grid '  gridflag '\n' ]);
+ fprintf(fid,   ['GridName '  gridname '\n' ]);
+ fprintf(fid,   ['XX 85' '\n' ]);
+ fprintf(fid,   ['XX 1.0' '\n' ]);
+ fprintf(fid,   ['XX 1.0' '\n' ]);
+ fprintf(fid,   ['Hart 1' '\n' ]);
+ fprintf(fid,  [ 'DecimalShift 0' '\n' ]);
+ fprintf(fid,   ['Deformation 0' '\n' ]);
+  fprintf(fid,  ['CorrelationMin 0' '\n' ]);
+ fprintf(fid,   ['IntensityMin 0' '\n' ]);
+  fprintf(fid,  ['SeuilImage n' '\n' ]);
+ fprintf(fid,   ['SeuilImageValues 0 4096' '\n' ]);
+ fprintf(fid,   ['ImageToUse '  term_a ' '  term_b '\n' ]); % VERIFIER ?
+ fprintf(fid,   ['ImageUsedBefore null null' '\n' ]);
+fclose(fid);
+       
 		s=-1; 
         display(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog])
@@ -3504,8 +3552,8 @@
 end
 
-%---------------------------------------------------------------
+%------------------------------------------------------------------------
 % RUN CIV2   CIV2    CIV2   CIV2
-%-----------------------------------------------------------
 function RUN_CIV2(handles,filecell_2,filecell_3,filecell_nc1,filecell_nc2,num1,num2,num_a,num_b,nom_type_nc)
+%------------------------------------------------------------------------
 %filecell_2: names of first image
 %filecell_3: names of second images
@@ -3652,5 +3700,5 @@
 		['ImageUsedBefore ' filename_nc1]};
         textout=char(textcmx);
-        dlmwrite(filename_cmx,textout,'');     
+        dlmwrite(filename_cmx,textout,''); 
         s=-1;  
         display(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog])
@@ -3668,9 +3716,8 @@
 % close(h) 
 
-          
-%----------------------------------------
-%PATCH
-%---------------------------------------
+%------------------------------------------------------------------------
+% --- PATCH
 function cmd_PATCH=RUN_PATCH(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp)
+%------------------------------------------------------------------------
 global patch_exe patch_new_exe
         namelog=[filename_nc([1:end-3]) '_patch.log'];
@@ -3682,20 +3729,17 @@
                 ' -max ' thresh_value ' -nopt ' subdomain_patch  '  > ' namelog ' 2>&1']; % redirect standard output to the log file
         end
-              
-%----------------------------------------
-%STEREO Interp
-%---------------------------------------
+
+%------------------------------------------------------------------------
+% --- STEREO Interp
 function cmd=RUN_STINTERP(stinterp_exe,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB)
+%------------------------------------------------------------------------
 namelog=[filename_nc([1:end-3]) '_stinterp.log'];
 cmd=[stinterp_exe ' -f1 ' filename_A_nc  ' -f2 ' filename_B_nc ' -f  ' filename_nc ...
     ' -m ' nx_patch  ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ' -c1 ' xmlA ' -c2 ' xmlB '  -xy  x -Nfy 1024 > ' namelog ' 2>&1']; % redirect standard output to the log file
-  
-%----------------------------------------------------
-function first_j_Callback(hObject, eventdata, handles)
-last_j_Callback(hObject, eventdata, handles)
-
-%---------------------------------------------------------
+
+%------------------------------------------------------------------------
 % --- Executes on button press in CIV1.
 function CIV1_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 val=get(handles.CIV1,'Value');
 if isequal(val,1)
@@ -3707,24 +3751,24 @@
 find_netcpair_civ1(hObject, eventdata, handles);
 
-%------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in FIX1.
 function FIX1_Callback(hObject, eventdata, handles)
-
+%------------------------------------------------------------------------
 enable_fix1(handles,get(handles.FIX1,'Value'))
 
-
-%----------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in PATCH1.
 function PATCH1_Callback(hObject, eventdata, handles)
-
+%------------------------------------------------------------------------
 if get(handles.PATCH1,'Value')==1
-enable_patch1(handles)
-else
-desable_patch1(handles)
-end
-
-%----------------------------------------------------------
+    enable_patch1(handles)
+else
+    desable_patch1(handles)
+end
+
+%------------------------------------------------------------------------
 % --- Executes on button press in CIV2.
 function CIV2_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 state=get(handles.CIV2,'Value');
 enable_civ2(handles,state)
@@ -3734,7 +3778,8 @@
 end
 
-%---------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in FIX2.
 function FIX2_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 if get(handles.FIX2,'Value')==1
     enable_fix2(handles)
@@ -3746,9 +3791,8 @@
 end
 
-
-%-------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in PATCH2.
 function PATCH2_Callback(hObject, eventdata, handles)
-%--------------------------------------------------------
+%------------------------------------------------------------------------
 if get(handles.PATCH2,'Value')==1
     enable_patch2(handles)
@@ -3760,16 +3804,25 @@
 end
 
-
-
-%-----------------------------------------------------------
+%------------------------------------------------------------------------
 function first_i_Callback(hObject, eventdata, handles)
-%------------------------------------------------------
-last_i_Callback(hObject, eventdata, handles)
-
-%-----------------------------------------------------------
+%------------------------------------------------------------------------
+% last_i_Callback(hObject, eventdata, handles)
+first_i=str2num(get(handles.first_i,'String'));
+% last_i=str2num(get(handles.last_i,'String'));
+% ref_i=ceil((first_i+last_i)/2);
+set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index
+ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt)
+
+%------------------------------------------------------------------------
+function first_j_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
+first_j=str2num(get(handles.first_j,'String'));
+set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index
+ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt)
+
+%------------------------------------------------------------------------
 % --- Executes on button press in calcul_search: determine the search range isx,isy
-%--------------------------------------------------------
 function calcul_search_Callback(hObject, eventdata, handles)
-
+%------------------------------------------------------------------------
 %determine pair numbers
 list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs
@@ -3820,9 +3873,8 @@
 set(handles.isy,'String',num2str(isy));
 
-
-%---------------------------------------------------------
-% Executes on carriage return on the subdir civ1 edit window
-%--------------------------------------------------------
+%------------------------------------------------------------------------
+% --- Executes on carriage return on the subdir civ1 edit window
 function subdir_civ1_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 subdir=get(handles.subdir_civ1,'String');
 set(handles.subdir_civ2,'String',subdir);
@@ -3831,8 +3883,8 @@
 end
 
-%---------------------------------------------------------
-% Executes on carriage return on the subdir civ1 edit window
-%---------------------------------------------------------
+%------------------------------------------------------------------------
+% --- Executes on carriage return on the subdir civ1 edit window
 function subdir_civ2_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 %update the list of available pairs from netcdf files in the new directory
 if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0
@@ -3840,8 +3892,8 @@
 end
 
-%------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in get_mask_civ1.
-%------------------------------------------------------
 function get_mask_civ1_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 maskval=get(handles.get_mask_civ1,'Value');
 if isequal(maskval,0)
@@ -3857,7 +3909,18 @@
             filebase_a=fullfile(common_path,get(handles.displ_filebase2,'String'));
             [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
-            if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice_mask)
+            if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask)
                 mask_displ='no mask';
             end
+    end
+    if isequal(mask_displ,'no mask')
+        [FileName, PathName, filterindex] = uigetfile( ...
+               {'*.png', ' (*.png)';
+                '*.png',  '.png files '; ...
+                '*.*', 'All Files (*.*)'}, ...
+                'Pick a mask file *.png',filebase);
+        mask_displ=fullfile(PathName,FileName);  
+        if ~exist(mask_displ,'file')
+            mask_displ='no mask';
+        end
     end
     if isequal(mask_displ,'no mask')
@@ -3876,7 +3939,8 @@
 end
 
-%--------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in get_mask_fix1.
 function get_mask_fix1_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 maskval=get(handles.get_mask_fix1,'Value');
 if isequal(maskval,0)
@@ -3896,4 +3960,15 @@
 end
 if isequal(mask_displ,'no mask')
+    [FileName, PathName, filterindex] = uigetfile( ...
+           {'*.png', ' (*.png)';
+            '*.png',  '.png files '; ...
+            '*.*', 'All Files (*.*)'}, ...
+            'Pick a mask file *.png',filebase);
+    mask_displ=fullfile(PathName,FileName);  
+    if ~exist(mask_displ,'file')
+        mask_displ='no mask';
+    end
+end
+if isequal(mask_displ,'no mask')
     set(handles.get_mask_fix1,'Value',0)
     set(handles.get_mask_civ2,'Value',0)
@@ -3907,7 +3982,9 @@
 set(handles.mask_fix2,'String',mask_displ)
 end
-%-----------------------------------------
+
+%------------------------------------------------------------------------
 % --- Executes on button press in get_mask_civ2.
 function get_mask_civ2_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 maskval=get(handles.get_mask_civ2,'Value');
 if isequal(maskval,0)
@@ -3927,4 +4004,15 @@
 end
 if isequal(mask_displ,'no mask')
+    [FileName, PathName, filterindex] = uigetfile( ...
+           {'*.png', ' (*.png)';
+            '*.png',  '.png files '; ...
+            '*.*', 'All Files (*.*)'}, ...
+            'Pick a mask file *.png',filebase);
+    mask_displ=fullfile(PathName,FileName);
+    if ~exist(mask_displ,'file')
+        mask_displ='no mask';
+    end
+end
+if isequal(mask_displ,'no mask')
     set(handles.get_mask_civ2,'Value',0)
     set(handles.get_mask_fix2,'Value',0)
@@ -3935,31 +4023,46 @@
 set(handles.mask_fix2,'String',mask_displ)
 end
-%-------------------------------------
+
+%------------------------------------------------------------------------
 % --- Executes on button press in get_mask_fix2.
 function get_mask_fix2_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 maskval=get(handles.get_mask_fix2,'Value');
 if isequal(maskval,0)
     set(handles.mask_fix2,'String','')
 else
-mask_displ='no mask'; %default
-filebase=get(handles.displ_filebase,'String');
-[nbslice, flag_mask]=get_mask(filebase,handles);
-if isequal(flag_mask,1)
-      mask_displ=[num2str(nbslice) 'mask'];
-elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series
-        filebase_a=get(handles.displ_filebase2,'String');
-        [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
-        if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
+    mask_displ='no mask'; %default
+    filebase=get(handles.displ_filebase,'String');
+    [nbslice, flag_mask]=get_mask(filebase,handles);
+    if isequal(flag_mask,1)
+          mask_displ=[num2str(nbslice) 'mask'];
+    elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series
+            filebase_a=get(handles.displ_filebase2,'String');
+            [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
+            if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
+                mask_displ='no mask';
+            end
+    end
+    if isequal(mask_displ,'no mask')
+        [FileName, PathName, filterindex] = uigetfile( ...
+               {'*.png', ' (*.png)';
+                '*.png',  '.png files '; ...
+                '*.*', 'All Files (*.*)'}, ...
+                'Pick a mask file *.png',filebase);
+        mask_displ=fullfile(PathName,FileName);  
+        if ~exist(mask_displ,'file')
             mask_displ='no mask';
         end
-end
-if isequal(mask_displ,'no mask')
-    set(handles.get_mask_fix2,'Value',0)
-end 
-set(handles.mask_fix2,'String',mask_displ)
-end
-
-%---------------------------------------
+    end
+    if isequal(mask_displ,'no mask')
+        set(handles.get_mask_fix2,'Value',0)
+    end 
+    set(handles.mask_fix2,'String',mask_displ)
+end
+
+%------------------------------------------------------------------------
+% --- function called to look for mask files
 function [nbslice, flag_mask]=get_mask(filebase,handles)
+%------------------------------------------------------------------------
 %detect mask files, images with appropriate file base 
 %[filebase '_' xx 'mask'], xx=nbslice
@@ -3971,11 +4074,15 @@
 % subdir=get(handles.subdir_civ1,'String');
 [Path,Name]=fileparts(filebase);
+if ~isdir(Path)
+    msgbox_uvmat('ERROR','no path for input files')
+    return
+end
 currentdir=pwd;
 cd(Path);%move in the dir of the root name filebase
 maskfiles=dir([Name '_*mask_*.png']);%look for mask files
 cd(currentdir);%come back to the current working directory
-if isempty(maskfiles)
-    msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat')
-else
+if ~isempty(maskfiles)
+%     msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat')
+% else
     flag_mask=1;
     maskname=maskfiles(1).name;% take the first mask file in the list
@@ -3998,7 +4105,8 @@
 end    
 
-%---------------------------------------
+%------------------------------------------------------------------------
+% --- function called to look for grid files
 function [nbslice, flag_mask]=get_grid(filebase,handles)
-
+%------------------------------------------------------------------------
 flag_mask=0;%default
 nbslice=1;
@@ -4027,20 +4135,10 @@
           nbslice=1;
     end
-end    
-%------------------------------
-
-function grid_civ1_Callback(hObject, eventdata, handles)
-% hObject    handle to grid_civ1 (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 grid_civ1 as text
-%        str2double(get(hObject,'String')) returns contents of grid_civ1 as a double
-
-
-%-----------------------------------------------------------
-% transform numbers to letters
-%--------------------------------------------
+end
+
+%------------------------------------------------------------------------
+% --- transform numbers to letters
 function str=num2stra(num,nom_type);
+%------------------------------------------------------------------------
 if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD')
     str=char(96+num);
@@ -4051,24 +4149,33 @@
     str=num2str(num);
 end
-%---------------------------------------------------
+
+%------------------------------------------------------------------------
 function mask_civ1_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 set(handles.mask_civ1,'UserData',[])
 set(handles.mask_civ1,'String','')
-%----------------------------------------------------
+
+%------------------------------------------------------------------------
 function mask_civ2_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 set(handles.mask_civ2,'UserData',[])
 set(handles.mask_civ2,'String','')
-%----------------------------------------------------
+
+%------------------------------------------------------------------------
 function mask_fix1_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 set(handles.mask_fix1,'UserData',[])
 set(handles.mask_fix1,'String','')
-%----------------------------------------------------
+
+%------------------------------------------------------------------------
 function mask_fix2_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 set(handles.mask_fix2,'UserData',[])
 set(handles.mask_fix2,'String','')
 
-%--------------------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in list_subdir_civ1.
 function list_subdir_civ1_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 list_subdir_civ1=get(handles.list_subdir_civ1,'String');
 val=get(handles.list_subdir_civ1,'Value');
@@ -4079,8 +4186,8 @@
 end
 
-
-%--------------------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in list_subdir_civ2.
 function list_subdir_civ2_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 list_subdir_civ2=get(handles.list_subdir_civ2,'String');
 val=get(handles.list_subdir_civ2,'Value');
@@ -4091,26 +4198,8 @@
 end
 
-
-%----------------------------------------------
-function last_i_Callback(hObject, eventdata, handles)
-first_i=str2num(get(handles.first_i,'String'));
-last_i=str2num(get(handles.last_i,'String'));
-ref_i=ceil((first_i+last_i)/2);
-set(handles.ref_i,'String', num2str(ref_i))
-ref_i_Callback(hObject, eventdata, handles)
-
-%-------------------------------------------------------
-function last_j_Callback(hObject, eventdata, handles)
-first_j=str2num(get(handles.first_j,'String'));
-last_j=str2num(get(handles.last_j,'String'));
-ref_j=ceil((first_j+last_j)/2);
-set(handles.ref_j,'String', num2str(ref_j))
-ref_j_Callback(hObject, eventdata, handles)
-
-
-%-----------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in browse_gridciv1.
 function browse_gridciv1_Callback(hObject, eventdata, handles)
-%-----------------------------------------------------------
+%------------------------------------------------------------------------
 value=get(handles.browse_gridciv1,'Value');
 testgrid=0;
@@ -4160,8 +4249,8 @@
 end
 
-%-----------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in browse_gridciv1.
 function browse_gridciv2_Callback(hObject, eventdata, handles)
-%-----------------------------------------------------------
+%------------------------------------------------------------------------
 value=get(handles.browse_gridciv2,'Value');
 if value
@@ -4231,11 +4320,12 @@
 % set(handles.grid_patch2,'string',filegrid
 
-%-----------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in get_gridpatch2.
 function get_gridpatch2_Callback(hObject, eventdata, handles)
-
-
-%----------------------------------------------------------
+%------------------------------------------------------------------------
+
+%------------------------------------------------------------------------
 function enable_civ1(handles,state)
+%------------------------------------------------------------------------
 if isequal(state,0)
     state='off';
@@ -4293,6 +4383,7 @@
 set(handles.rho_title,'Visible',state)
 
-%----------------------------------------------------------
+%------------------------------------------------------------------------
 function enable_fix1(handles,state)
+%------------------------------------------------------------------------
 if isequal(state,0)
     state='off';
@@ -4321,7 +4412,7 @@
 set(handles.field_ref1,'Visible',state)
 
-
-%--------------------------------------------------------------
+%------------------------------------------------------------------------
 function enable_patch1(handles)
+%------------------------------------------------------------------------
 global patch_new_exe
 set(handles.frame_patch1,'BackgroundColor',[1 1 0])
@@ -4343,6 +4434,7 @@
 set(handles.grid_patch1,'Visible','on')
 
-%--------------------------------------------------------------
+%------------------------------------------------------------------------
 function desable_patch1(handles)
+%------------------------------------------------------------------------
 set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784])
 set(handles.rho_patch1,'Visible','off')
@@ -4360,6 +4452,7 @@
 set(handles.grid_patch1,'Visible','off')
 
-%----------------------------------------------------------
+%------------------------------------------------------------------------
 function enable_civ2(handles,state)
+%------------------------------------------------------------------------
 if isequal(state,0)
     state='off';
@@ -4415,7 +4508,7 @@
 end
 
-
-%----------------------------------------------------------
+%------------------------------------------------------------------------
 function enable_fix2(handles)
+%------------------------------------------------------------------------
 set(handles.frame_fix2,'BackgroundColor',[1 1 0])
 set(handles.REMOVE2,'Visible','on')
@@ -4437,6 +4530,7 @@
 set(handles.field_ref2,'Visible','on')
 
-%----------------------------------------------------------
+%------------------------------------------------------------------------
 function desable_fix2(handles)
+%------------------------------------------------------------------------
 set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784])
 set(handles.REMOVE2,'Visible','off')
@@ -4460,6 +4554,7 @@
 end
 
-%--------------------------------------------------------------
+%------------------------------------------------------------------------
 function enable_patch2(handles)
+%------------------------------------------------------------------------
 set(handles.frame_patch2,'BackgroundColor',[1 1 0])
 %set(handles.rho_patch2,'Visible','on')
@@ -4479,6 +4574,7 @@
 set(handles.subdir_civ2_text,'Visible','on')
 
-%--------------------------------------------------------------
+%------------------------------------------------------------------------
 function desable_patch2(handles)
+%------------------------------------------------------------------------
 set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784])
 set(handles.rho_patch2,'Visible','off')
@@ -4500,6 +4596,7 @@
 end
 
-%--------------------------------------------------------------
+%------------------------------------------------------------------------
 function enable_pair1(handles,state)
+%------------------------------------------------------------------------
 set(handles.subdir_civ1,'Visible',state)
 set(handles.list_subdir_civ1,'Visible',state)
@@ -4508,26 +4605,12 @@
 set(handles.list_pair_civ1,'Visible',state)
 set(handles.PAIR_txt,'Visible',state)
-set(handles.dt_display_txt,'Visible',state)
+%set(handles.dt_display_txt,'Visible',state)
 set(handles.dt_unit,'Visible',state)
 set(handles.PAIR_frame,'Visible',state)
 
-% --- Executes on button press in test_interp.
-function test_interp_Callback(hObject, eventdata, handles)
-% hObject    handle to test_interp (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hint: get(hObject,'Value') returns toggle state of test_interp
-
-
-
-
-
-
-%------------------------------------------------
-%Read the parameters for civ1 on the interface
-%--------------------------------------------------
+%------------------------------------------------------------------------
+% --- Read the parameters for civ1 on the interface
 function par=read_param_civ1(handles,file_ima)
-
+%------------------------------------------------------------------------
 ibx_val=str2num(get(handles.ibx,'String'));
 par.ibx=num2str(ibx_val);
@@ -4551,91 +4634,91 @@
          par.isy='41'; %default
          set(handles.isy,'String','41');
-end;
+end
 if isempty(str2num(par.shiftx))
          par.shiftx='0';%default
          set(handles.shiftx,'String','0');
-end; 
+end 
 if isempty(str2num(par.shifty))
          par.shifty='0'; %default
          set(handles.shifty,'String','0');
-end;
-     par.rho=get(handles.rho,'String');
-     par.dx=get(handles.dx_civ1,'String');
-     par.dy=get(handles.dy_civ1,'String');
-     if isequal(str2num(par.dx),[]) 
-         if isempty(get(handles.grid_civ1,'String'));
-             par.dx='0'; %just read by civ program, not used
-         else
-            par.dx='20';%default
-            set(handles.dx_civ1,'String','20');
-         end
+end
+ par.rho=get(handles.rho,'String');
+ par.dx=get(handles.dx_civ1,'String');
+ par.dy=get(handles.dy_civ1,'String');
+ if isequal(str2num(par.dx),[]) 
+     if isempty(get(handles.grid_civ1,'String'));
+         par.dx='0'; %just read by civ program, not used
+     else
+        par.dx='20';%default
+        set(handles.dx_civ1,'String','20');
      end
-     if isequal(str2num(par.dy),[])
-         if isempty(get(handles.grid_civ1,'String'));
-             par.dy='0';%just read by civ program, not used
-         else
-            par.dy='20';%default
-            set(handles.dy_civ1_title,'String','20');
-         end
+ end
+ if isequal(str2num(par.dy),[])
+     if isempty(get(handles.grid_civ1,'String'));
+         par.dy='0';%just read by civ program, not used
+     else
+        par.dy='20';%default
+        set(handles.dy_civ1_title,'String','20');
      end
-        par.pxcmx='1'; %velocities are expressed in pixel dispalcement
-         par.pxcmy='1';
+ end
+    par.pxcmx='1'; %velocities are expressed in pixel dispalcement
+     par.pxcmy='1';
 %      end
-     A=imread(file_ima);%read the first image to get the size
-     sizim=size(A);
-     par.npx=num2str(sizim(2));
-     par.npy=num2str(sizim(1));
-     time=get(handles.displ_filebase,'UserData'); %get the set of times
-     par.gridname=get(handles.grid_civ1,'String');
-     par.gridflag='y';
-     if isequal(par.gridname,'')| isempty(par.gridname)
-         par.gridname='nogrid';
-         par.gridflag='n';
+ A=imread(file_ima);%read the first image to get the size
+ sizim=size(A);
+ par.npx=num2str(sizim(2));
+ par.npy=num2str(sizim(1));
+ time=get(handles.displ_filebase,'UserData'); %get the set of times
+ par.gridname=get(handles.grid_civ1,'String');
+ par.gridflag='y';
+ if isequal(par.gridname,'')| isempty(par.gridname)
+     par.gridname='nogrid';
+     par.gridflag='n';
+ end
+
+%------------------------------------------------------------------------
+function par=read_param_civ2(handles,file_ima)
+%------------------------------------------------------------------------
+par.ibx=get(handles.ibx_civ2,'String');
+par.iby=get(handles.iby_civ2,'String');
+par.rho=get(handles.rho_civ2,'String');
+par.decimal=int2str(get(handles.decimal,'Value'));
+par.deformation=int2str(get(handles.deformation,'Value'));
+par.dx=get(handles.dx_civ2,'String');
+par.dy=get(handles.dy_civ2,'String');
+if isequal(str2num(par.dx),[]) 
+     if isempty(get(handles.grid_civ2,'String'));
+         par.dx='0'; %just read by civ program, not used
+     else
+        par.dx='20';%default
+        set(handles.dx_civ2,'String','20');
      end
-     
-%----------------------------------------------------------------
-function par=read_param_civ2(handles,file_ima)
-    par.ibx=get(handles.ibx_civ2,'String');
-    par.iby=get(handles.iby_civ2,'String');
-    par.rho=get(handles.rho_civ2,'String');
-    par.decimal=int2str(get(handles.decimal,'Value'));
-    par.deformation=int2str(get(handles.deformation,'Value'));
-    par.dx=get(handles.dx_civ2,'String');
-    par.dy=get(handles.dy_civ2,'String');
-    if isequal(str2num(par.dx),[]) 
-         if isempty(get(handles.grid_civ2,'String'));
-             par.dx='0'; %just read by civ program, not used
-         else
-            par.dx='20';%default
-            set(handles.dx_civ2,'String','20');
-         end
+ end
+ if isequal(str2num(par.dy),[])
+     if isempty(get(handles.grid_civ2,'String'));
+         par.dy='0';%just read by civ program, not used
+     else
+        par.dy='20';%default
+        set(handles.dy_civ2,'String','20');
      end
-     if isequal(str2num(par.dy),[])
-         if isempty(get(handles.grid_civ2,'String'));
-             par.dy='0';%just read by civ program, not used
-         else
-            par.dy='20';%default
-            set(handles.dy_civ2,'String','20');
-         end
-     end
-     par.pxcmx='1';
-     par.pxcmy='1';
-    A=imread(file_ima);%read the first image to get the size
-    sizim=size(A);
-    par.npx=num2str(sizim(2));
-    par.npy=num2str(sizim(1));
-    time=get(handles.displ_filebase,'UserData'); %get the set of times
-    par.gridname=get(handles.grid_civ2,'String');
-    par.gridflag='y';
-    if isequal(par.gridname,'')| isempty(par.gridname)
-        par.gridname='nogrid';
-        par.gridflag='n';
-    end
-
-
-%---------------------------------------------------------
-%CIV1  CIV1  CIV1 CIV1
-%----------------------------------------------------------
+ end
+ par.pxcmx='1';
+ par.pxcmy='1';
+A=imread(file_ima);%read the first image to get the size
+sizim=size(A);
+par.npx=num2str(sizim(2));
+par.npy=num2str(sizim(1));
+time=get(handles.displ_filebase,'UserData'); %get the set of times
+par.gridname=get(handles.grid_civ2,'String');
+par.gridflag='y';
+if isequal(par.gridname,'')| isempty(par.gridname)
+    par.gridname='nogrid';
+    par.gridflag='n';
+end
+
+%------------------------------------------------------------------------
+% --- CIV1  CIV1  CIV1 CIV1
 function cmd_CIV1=BATCH_CIV1(filename,namelog,par,handles)
+%------------------------------------------------------------------------
 %pixels per cm and matrix of the image times, read from the .civ file by uvmat
 global civ1_exe Civ_exe sge%name of the executable for civ1 calculation
@@ -4646,58 +4729,88 @@
                 par.Dt='1' ;%case of 'displacement' mode
             end         
- 
-    textcmx={'##############   CMX file';...
-    ['FirstImage ' par.filename_ima_a];...
-    ['LastImage  ' par.filename_ima_b];...
-    'XX' ;...
-    ['Mask ' par.maskflag] ;...
-    ['MaskName ' par.maskname];...
-    ['ImageSize ' par.npx ' ' par.npy];...   %VERIFIER CAS GENERAL ?
-    ['CorrelationBoxesSize ' par.ibx ' ' par.iby];...
-    ['SearchBoxeSize ' par.isx ' ' par.isy];...
-    ['RO ' par.rho];...
-    ['GridSpacing ' par.dx ' ' par.dy];...
-    'XX 1.0';...
-    ['Dt_TO ' par.Dt ' ' par.T0];...
-    ['PixCmXY ' par.pxcmx ' ' par.pxcmy];...
-    'XX 1';...
-    ['ShiftXY ' par.shiftx ' '  par.shifty];...
-    ['Grid ' par.gridflag];...
-    ['GridName ' par.gridname] ;...
-    'XX 85';...
-    'XX 1.0';...
-    'XX 1.0';...
-    'Hart 1';...
-    'DecimalShift 0';...
-    'Deformation 0';...
-    'CorrelationMin 0';...
-    'IntensityMin 0';...
-    'SeuilImage n';...
-    'SeuilImageValues 0 4096';...
-    ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ?
-    'ImageUsedBefore null null'};
-
-            textout=char(textcmx);
-    %         timeL1=clock;
-            dlmwrite([filename '.cmx'],textout,'');
-    %             timeL2=clock;
-    %     timciv1=etime(timeL2,timeL1)
-          if sge  
-          cmd_CIV1=[civ1_exe ' -f ' filename '.cmx' ]; % redirect standard output to the log file
-          else
-              cmd_CIV1=[civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file
-          end
-    if(isunix)
-    	[Rootbat,Filebat,extbat]=fileparts(namelog);
-    	ncName=fullfile(Rootbat,[ Filebat '.nc']);
-	    cmd_CIV1=char({cmd_CIV1 ; ['mv ' namelog  ' ' namelog '.civ1.log'];['chmod g+w ' ncName]});
-    else
-        cmd_CIV1=char({cmd_CIV1 ; ['copy /Y ' namelog ' ' namelog '.civ1.log']});
-    end
-
-%---------------------------------------------------------
-%CIV1  Unified
-%----------------------------------------------------------
+%  
+%     textcmx={'##############   CMX file';...
+%     ['FirstImage ' par.filename_ima_a];...
+%     ['LastImage  ' par.filename_ima_b];...
+%     'XX' ;...
+%     ['Mask ' par.maskflag] ;...
+%     ['MaskName ' par.maskname];...
+%     ['ImageSize ' par.npx ' ' par.npy];...   %VERIFIER CAS GENERAL ?
+%     ['CorrelationBoxesSize ' par.ibx ' ' par.iby];...
+%     ['SearchBoxeSize ' par.isx ' ' par.isy];...
+%     ['RO ' par.rho];...
+%     ['GridSpacing ' par.dx ' ' par.dy];...
+%     'XX 1.0';...
+%     ['Dt_TO ' par.Dt ' ' par.T0];...
+%     ['PixCmXY ' par.pxcmx ' ' par.pxcmy];...
+%     'XX 1';...
+%     ['ShiftXY ' par.shiftx ' '  par.shifty];...
+%     ['Grid ' par.gridflag];...
+%     ['GridName ' par.gridname] ;...
+%     'XX 85';...
+%     'XX 1.0';...
+%     'XX 1.0';...
+%     'Hart 1';...
+%     'DecimalShift 0';...
+%     'Deformation 0';...
+%     'CorrelationMin 0';...
+%     'IntensityMin 0';...
+%     'SeuilImage n';...
+%     'SeuilImageValues 0 4096';...
+%     ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ?
+%     'ImageUsedBefore null null'};
+% 
+%             textout=char(textcmx);
+
+   fid=fopen([filename '.cmx'],'w');
+fprintf(fid,['##############   CMX file' '\n' ]);
+ fprintf(fid,   ['FirstImage ' par.filename_ima_a '\n' ]);
+ fprintf(fid,   ['LastImage  ' par.filename_ima_b '\n' ]);
+  fprintf(fid,  ['XX' '\n' ]);
+  fprintf(fid,  ['Mask ' par.maskflag '\n' ]);
+  fprintf(fid,  ['MaskName ' par.maskname '\n' ]);
+ fprintf(fid,   ['ImageSize ' par.npx ' ' par.npy '\n' ]);   %VERIFIER CAS GENERAL ?
+ fprintf(fid,   ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]);
+ fprintf(fid,   ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]);
+ fprintf(fid,   ['RO ' par.rho '\n' ]);
+ fprintf(fid,   ['GridSpacing ' par.dx ' ' par.dy '\n' ]);
+ fprintf(fid,   ['XX 1.0' '\n' ]);
+ fprintf(fid,   ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]);
+  fprintf(fid,  ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]);
+  fprintf(fid,  ['XX 1' '\n' ]);
+ fprintf(fid,   ['ShiftXY ' par.shiftx ' '  par.shifty '\n' ]);
+  fprintf(fid,  ['Grid ' par.gridflag '\n' ]);
+ fprintf(fid,   ['GridName ' par.gridname '\n' ]);
+ fprintf(fid,   ['XX 85' '\n' ]);
+ fprintf(fid,   ['XX 1.0' '\n' ]);
+ fprintf(fid,   ['XX 1.0' '\n' ]);
+ fprintf(fid,   ['Hart 1' '\n' ]);
+ fprintf(fid,  [ 'DecimalShift 0' '\n' ]);
+ fprintf(fid,   ['Deformation 0' '\n' ]);
+  fprintf(fid,  ['CorrelationMin 0' '\n' ]);
+ fprintf(fid,   ['IntensityMin 0' '\n' ]);
+  fprintf(fid,  ['SeuilImage n' '\n' ]);
+ fprintf(fid,   ['SeuilImageValues 0 4096' '\n' ]);
+ fprintf(fid,   ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ?
+ fprintf(fid,   ['ImageUsedBefore null null' '\n' ]);
+fclose(fid);
+  
+if sge  
+    cmd_CIV1=[civ1_exe ' -f ' filename '.cmx' ]; % redirect standard output to the log file
+else
+    cmd_CIV1=[civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file
+end
+if(isunix)
+    [Rootbat,Filebat,extbat]=fileparts(namelog);
+    ncName=fullfile(Rootbat,[ Filebat '.nc']);
+    cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog  ' ' namelog '.civ1.log' '\n' 'chmod g+w ' ncName];
+else
+    cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y ' namelog ' ' namelog '.civ1.log'];
+end
+
+%------------------------------------------------------------------------
+% --- CIV1  Unified
 function xml_civ1_parameters=BATCH_CIV1_Unified(filename,namelog,par)
+%------------------------------------------------------------------------
 %pixels per cm and matrix of the image times, read from the .civ file by uvmat
 global civ1_exe Civ_exe%name of the executable for civ1 calculation
@@ -4734,9 +4847,9 @@
   
     xml_civ1_parameters=civ1;
-    
-%---------------------------------------------------------
-%CIV2  Unified
-%----------------------------------------------------------
+
+%------------------------------------------------------------------------
+% --- CIV2  Unified
 function civ2=BATCH_CIV2_Unified(filename,namelog,par)
+%------------------------------------------------------------------------
 %pixels per cm and matrix of the image times, read from the .civ file by uvmat
 global civ2_exe Civ_exe%name of the executable for civ1 calculation
@@ -4787,8 +4900,8 @@
 civ2.convectFlow='n';
 
-%---------------------------------------------------------
-%CIV2  CIV2  CIV2 CIV2
-%----------------------------------------------------------
+%------------------------------------------------------------------------
+% --- CIV2  CIV2  CIV2 CIV2
 function cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par)
+%------------------------------------------------------------------------
 %pixels per cm and matrix of the image times, read from the .civ file by uvmat
 global civ2_exe sge%name of the executable for civ1 calculation
@@ -4796,45 +4909,48 @@
                 par.Dt='1' ;%case of 'displacement' mode
   end 
-textcmx={'##############   CMX file';...
-['FirstImage ' par.filename_ima_a];...
-['LastImage  ' par.filename_ima_b];...
-'XX' ;...
-['Mask ' par.maskflag];...
-['MaskName ' par.maskname];...
-['ImageSize ' par.npx ' ' par.npy];...   
-['CorrelationBoxesSize ' par.ibx ' ' par.iby];...
-['SearchBoxeSize ' par.ibx ' ' par.iby];...
-['RO ' par.rho];...
-['GridSpacing ' par.dx ' ' par.dy];...
-'XX 1.0';...
-['Dt_TO ' par.Dt ' ' par.T0];...
-['PixCmXY ' par.pxcmx ' ' par.pxcmy];...
-'XX 1';...
-['ShiftXY 0 0'];...
-['Grid ' par.gridflag];...
-['GridName ' par.gridname];...
-'XX 85';...
-'XX 1.0';...
-'XX 1.0';...
-'Hart 1';...
-['DecimalShift ' par.decimal];...
-['Deformation ' par.deformation];...
-'CorrelationMin 0';...
-'IntensityMin 0';...
-'SeuilImage n';...
-'SeuilImageValues 0 4096';...
-['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ?
-['ImageUsedBefore ' par.filename_nc1]};
-        textout=char(textcmx);
-        dlmwrite([filename_cmx '2'] ,textout,'');
-        if sge
-        cmd_CIV2=[civ2_exe ' -f ' filename_cmx ]; % redirect standard output to the log file
-        else
-          cmd_CIV2=[civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file
-      end
-
-
+textcmx=['##############   CMX file'  '\n'...
+['FirstImage ' par.filename_ima_a]  '\n'...
+['LastImage  ' par.filename_ima_b]  '\n'...
+'XX'   '\n'...
+['Mask ' par.maskflag]  '\n'...
+['MaskName ' par.maskname]  '\n'...
+['ImageSize ' par.npx ' ' par.npy]  '\n'...   
+['CorrelationBoxesSize ' par.ibx ' ' par.iby]  '\n'...
+['SearchBoxeSize ' par.ibx ' ' par.iby]  '\n'...
+['RO ' par.rho]  '\n'...
+['GridSpacing ' par.dx ' ' par.dy]  '\n'...
+'XX 1.0'  '\n'...
+['Dt_TO ' par.Dt ' ' par.T0]  '\n'...
+['PixCmXY ' par.pxcmx ' ' par.pxcmy]  '\n'...
+'XX 1'  '\n'...
+['ShiftXY 0 0']  '\n'...
+['Grid ' par.gridflag]  '\n'...
+['GridName ' par.gridname]  '\n'...
+'XX 85'  '\n'...
+'XX 1.0'  '\n'...
+'XX 1.0'  '\n'...
+'Hart 1'  '\n'...
+['DecimalShift ' par.decimal]  '\n'...
+['Deformation ' par.deformation]  '\n'...
+'CorrelationMin 0'  '\n'...
+'IntensityMin 0'  '\n'...
+'SeuilImage n'  '\n'...
+'SeuilImageValues 0 4096'  '\n'...
+['ImageToUse ' par.term_a ' ' par.term_b]  '\n'... % VERIFIER ?
+['ImageUsedBefore ' par.filename_nc1]];
+textout=char(textcmx);
+fid=fopen([filename_cmx '2'],'w');
+fprintf(fid,textout); 
+fclose(fid)
+if sge
+    cmd_CIV2=[civ2_exe ' -f ' filename_cmx ]; % redirect standard output to the log file
+else
+    cmd_CIV2=[civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file
+end
+
+%------------------------------------------------------------------------
 % --- Executes on button press in HELP.
 function HELP_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 path_to_uvmat=which ('uvmat');% check the path of uvmat
 pathelp=fileparts(path_to_uvmat);
@@ -4845,8 +4961,8 @@
 end
 
-
-%----------------------------------------------------------
+%------------------------------------------------------------------------
 %--read images and convert them to the uint16 format used for PIV
 function A=read_image(filename,nom_type,npx,npy,num);
+%------------------------------------------------------------------------
 %npx, npy are the dimensions needed for the raw SMD images
 %num is the view number needed for an avi movie
@@ -4870,44 +4986,46 @@
     A=uint16(A);
 end
-        
-%----------------------------------------------------------------
-%Executes on carriage return on the time interval dt
-%----------------------------------------------------------------
-function dt_Callback(hObject, eventdata, handles)
-%determine the set of times and possible intervals for CIV
-%                 answer=inputdlg('time interval between images?');
-                dt=(1/1000)*str2num(get(handles.dt,'String'));
-                nbfield=str2num(get(handles.nb_field,'String')); %last image number selected in the processing series
-                time=(dt*[0:nbfield-1])';
-%                 set(handles.incr_i,'UserData',dt);%store the time interval between successive images
-                set(handles.displ_filebase,'UserData',time); %store the set of times
-                for index=1:min(nbfield-1,200)
-                    displ_num(1,index)=1;
-                    displ_num(2,index)=1;
-                    displ_num(3,index)=-floor(index/2);
-                    displ_num(4,index)=ceil(index/2);
-                end
-set(handles.list_pair_civ1,'Value',1);
-set(handles.list_pair_civ1,'UserData',displ_num);
-set(handles.list_pair_civ2,'Value',1);
-%update the list of time intervals
-find_netcpair_civ1(hObject, eventdata, handles)
-find_netcpair_civ2(hObject, eventdata, handles)
-
-%-------------------------------------------------------
+
+% %----------------------------------------------------------------
+% %Executes on carriage return on the time interval dt
+% %----------------------------------------------------------------
+% function dt_Callback(hObject, eventdata, handles)
+% %determine the set of times and possible intervals for CIV
+% %                 answer=inputdlg('time interval between images?');
+%                 dt=(1/1000)*str2num(get(handles.dt,'String'));
+%                 nbfield=str2num(get(handles.nb_field,'String')); %last image number selected in the processing series
+%                 time=(dt*[0:nbfield-1])';
+% %                 set(handles.incr_i,'UserData',dt);%store the time interval between successive images
+%                 set(handles.displ_filebase,'UserData',time); %store the set of times
+%                 for index=1:min(nbfield-1,200)
+%                     displ_num(1,index)=1;
+%                     displ_num(2,index)=1;
+%                     displ_num(3,index)=-floor(index/2);
+%                     displ_num(4,index)=ceil(index/2);
+%                 end
+% set(handles.list_pair_civ1,'Value',1);
+% set(handles.list_pair_civ1,'UserData',displ_num);
+% set(handles.list_pair_civ2,'Value',1);
+% %update the list of time intervals
+% find_netcpair_civ1(hObject, eventdata, handles)
+% find_netcpair_civ2(hObject, eventdata, handles)
+
+%------------------------------------------------------------------------
 function ref_i_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 mode_list=get(handles.mode,'String');
 mode_value=get(handles.mode,'Value');
 mode=mode_list{mode_value};
-if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Di)') 
+%if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Di)') 
     find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files
-end
-if isequal(mode,'series(Di)') | ...% we do patch2 only
+%end
+if isequal(mode,'series(Di)') || ...% we do patch2 only
    (get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0)
     find_netcpair_civ2(hObject, eventdata, handles);
 end
 
-%----------------------------------------------------
+%------------------------------------------------------------------------
 function ref_j_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 mode_list=get(handles.mode,'String');
 mode_value=get(handles.mode,'Value');
@@ -4920,7 +5038,9 @@
     find_netcpair_civ2(hObject, eventdata, handles);
 end
-%----------------------------------------------------
+
+%------------------------------------------------------------------------
 % --- Executes on button press in compare.
 function compare_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 test=get(handles.compare,'Value');
 if test==2 || test==3    
@@ -4988,7 +5108,8 @@
 mode_Callback(hObject, eventdata, handles)
 
-%-----------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in get_ref_fix1.
 function get_ref_fix1_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 filebase=get(handles.displ_filebase,'String');
 [FileName, PathName, filterindex] = uigetfile( ...
@@ -5001,9 +5122,5 @@
 sizf=size(fileinput);
 if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
-%[filebasesub,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
 [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
-%filebase=fullfile(RootPath,RootFile);
-% [Pth,FileN]=fileparts(filebasesub);
-% Pth=fileparts(Pth);
 ref.filebase=fullfile(Path,File);
 ref.num_a=stra2num(str_a);
@@ -5016,5 +5133,4 @@
     return
 end
-% [path,name]=fileparts(ref.filebase);
 set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']);
 set(handles.ref_fix1,'UserData',ref)
@@ -5030,14 +5146,4 @@
     menu_field{4}='filter2';
 end
-% [cte_detect,vdt,cte_read]=read_netcdf(fileinput,{'patch','civ2','patch2'});
-% if isequal(cte_detect(1),1) & isequal(cte_read(1),1)
-%          menu_field{2}='filter1';
-% end
-% if isequal(cte_detect(2),1) & isequal(cte_read(2),1)
-%          menu_field{3}='civ2';
-% end
-% if isequal(cte_detect(3),1) & isequal(cte_read(3),1)
-%          menu_field{4}='filter2';
-% end
 set(handles.field_ref1,'String',menu_field);
 set(handles.field_ref1,'Value',length(menu_field));
@@ -5045,8 +5151,9 @@
 set(handles.thresh_vel,'String','1');%default threshold
 set(handles.ref_fix1,'Enable','on')
- 
-%---------------------------------------------------------------
+
+%------------------------------------------------------------------------
 % --- Executes on button press in get_ref_fix2.
 function get_ref_fix2_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 if isequal(get(handles.get_ref_fix2,'Value'),1)
     filebase=get(handles.displ_filebase,'String');
@@ -5059,8 +5166,5 @@
     sizf=size(fileinput);
     if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
-    %[filebasesub,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
     [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
-%     [Pth,FileN]=fileparts(filebasesub);
-%     Pth=fileparts(Pth);
     ref.filebase=fullfile(Path,File);
     ref.num_a=stra2num(str_a);
@@ -5073,9 +5177,7 @@
         return
     end
-%     [path,name]=fileparts(ref.filebase);
     set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']);
     set(handles.ref_fix2,'UserData',ref)    
     menu_field{1}='civ1';
-%     [cte_detect,vdt,cte_read]=read_netcdf(fileinput,{'patch','civ2','patch2'});
     Data=nc2struct(fileinput,[]);
     if isfield(Data,'patch') & isequal(Data.patch,1)
@@ -5088,14 +5190,4 @@
         menu_field{4}='filter2';
     end
-
-%     if isequal(cte_detect(1),1) & isequal(cte_read(1),1)
-%              menu_field{2}='filter1';
-%     end
-%     if isequal(cte_detect(2),1) & isequal(cte_read(2),1)
-%              menu_field{3}='civ2';
-%     end
-%     if isequal(cte_detect(3),1) & isequal(cte_read(3),1)
-%              menu_field{4}='filter2';
-%     end
     set(handles.field_ref2,'String',menu_field);
     set(handles.field_ref2,'Value',length(menu_field));
@@ -5109,44 +5201,29 @@
     set(handles.field_ref2,'Visible','off')
 end
-%-------------------------------------------------------
-
+
+%------------------------------------------------------------------------
 function ref_fix1_Callback(hObject, eventdata, handles)
-    set(handles.inf_sup1,'Value',1);
-    set(handles.field_ref1,'Value',1)
-    set(handles.field_ref1,'String',{' '})
-    set(handles.ref_fix1,'UserData',[]);
-    set(handles.ref_fix1,'String','');
-    set(handles.thresh_vel1,'String','0');
+%------------------------------------------------------------------------
+set(handles.inf_sup1,'Value',1);
+set(handles.field_ref1,'Value',1)
+set(handles.field_ref1,'String',{' '})
+set(handles.ref_fix1,'UserData',[]);
+set(handles.ref_fix1,'String','');
+set(handles.thresh_vel1,'String','0');
  
-
-%------------------------------------------------------
-
+%------------------------------------------------------------------------
 function ref_fix2_Callback(hObject, eventdata, handles)
-    set(handles.inf_sup2,'Value',1);
-    set(handles.field_ref2,'Value',1)
-    set(handles.field_ref2,'String',{' '})
-    set(handles.ref_fix2,'UserData',[]);
-    set(handles.ref_fix2,'String','');
-    set(handles.thresh_vel2,'String','0');
-
-%--------------------------------------------------------
-% --- Executes on selection change in inf_sup1.
-function inf_sup1_Callback(hObject, eventdata, handles)
-
-%--------------------------------------------------------------------------
-
-
-% --- Executes on selection change in field_ref.
-function field_ref_Callback(hObject, eventdata, handles)
-
-%-------------------------------------------------------------------------
-
-% --- Executes on selection change in field_ref2.
-function field_ref2_Callback(hObject, eventdata, handles)
-
-% -----------------------------------------------------------
+%------------------------------------------------------------------------
+set(handles.inf_sup2,'Value',1);
+set(handles.field_ref2,'Value',1)
+set(handles.field_ref2,'String',{' '})
+set(handles.ref_fix2,'UserData',[]);
+set(handles.ref_fix2,'String','');
+set(handles.thresh_vel2,'String','0');
+
+%------------------------------------------------------------------------
 % transform letters to numbers
-%--------------------------------------------
 function numres=stra2num(str)
+%------------------------------------------------------------------------
 numres=double(str)-96;
 if double(str) >= 48 & double(str) <= 57 % = 1 for numbers
@@ -5154,7 +5231,8 @@
 end
 
-
+%------------------------------------------------------------------------
 % --- Executes on button press in test_stereo1.
 function test_stereo1_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 if isequal(get(handles.test_stereo1,'Value'),0)
     set(handles.subdomain_patch1,'Visible','on')
@@ -5165,6 +5243,8 @@
 end
 
+%------------------------------------------------------------------------
 % --- Executes on button press in test_stereo2.
 function test_stereo2_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 if isequal(get(handles.test_stereo2,'Value'),0)
     set(handles.subdomain_patch2,'Visible','on')
@@ -5175,6 +5255,8 @@
 end
 
+%------------------------------------------------------------------------
 % --- Executes on button press in ImaThreshold.
 function ImaThreshold_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 if isequal(get(handles.ImaThreshold,'Value'),1)
     set(handles.MinIma,'Visible','on')
@@ -5185,7 +5267,8 @@
 end
 
-
+%------------------------------------------------------------------------
 % --- Executes on button press in ImaThreshold2.
 function ImaThreshold2_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 if isequal(get(handles.ImaThreshold2,'Value'),1)
     set(handles.MinIma2,'Visible','on')
@@ -5196,53 +5279,2 @@
 end
 
-
-% --- Executes on button press in Experimental.
-function Experimental_Callback(hObject, eventdata, handles)
-
-
-
-function ext_ima_1_Callback(hObject, eventdata, handles)
-% hObject    handle to ext_ima_1 (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 ext_ima_1 as text
-%        str2double(get(hObject,'String')) returns contents of ext_ima_1 as a double
-
-
-% --- Executes during object creation, after setting all properties.
-function ext_ima_1_CreateFcn(hObject, eventdata, handles)
-% hObject    handle to ext_ima_1 (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 ext_ima_Callback(hObject, eventdata, handles)
-% hObject    handle to ext_ima (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 ext_ima as text
-%        str2double(get(hObject,'String')) returns contents of ext_ima as a double
-
-
-% --- Executes during object creation, after setting all properties.
-function ext_ima_CreateFcn(hObject, eventdata, handles)
-% hObject    handle to ext_ima (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
-
-
Index: trunk/src/dataview.m
===================================================================
--- trunk/src/dataview.m	(revision 11)
+++ trunk/src/dataview.m	(revision 12)
@@ -1,3 +1,3 @@
-%TEST 'dataview': function for scanning directories in a campaign (TEST)
+%'dataview': function for scanning directories in a campaign 
 %------------------------------------------------------------------------
 % function varargout = series(varargin)
@@ -22,5 +22,5 @@
 function varargout = dataview(varargin)
 
-% Last Modified by GUIDE v2.5 28-Apr-2009 00:12:36
+% Last Modified by GUIDE v2.5 13-Jan-2010 07:28:19
 
 % Begin initialization code - DO NOT EDIT
@@ -32,5 +32,5 @@
                    'gui_LayoutFcn',  [] , ...
                    'gui_Callback',   []);
-if nargin & isstr(varargin{1})
+if nargin & ischar(varargin{1})
     gui_State.gui_Callback = str2func(varargin{1});
 end
@@ -45,28 +45,82 @@
 
 % --- Executes just before dataview is made visible.
-function dataview_OpeningFcn(hObject, eventdata, handles, varargin)
+function dataview_OpeningFcn(hObject, eventdata, handles, RootDir, SubCampaignTst,GeometryCalib)
 
 % Choose default command line output for dataview
-handles.output = hObject;
+handles.output = 'Cancel';
 
 % Update handles structure
 guidata(hObject, handles);
-
-%----------------------------------------------------------------
+testCancel=1;
+testinputstring=0;
+icontype='quest';%default question icon (text input asked)
+
+% Determine the position of the dialog - centered on the screen
+FigPos=get(0,'DefaultFigurePosition');
+OldUnits = get(hObject, 'Units');
+set(hObject, 'Units', 'pixels');
+OldPos = get(hObject,'Position');
+FigWidth = OldPos(3);
+FigHeight = OldPos(4);
+ScreenUnits=get(0,'Units');
+set(0,'Units','pixels');
+ScreenSize=get(0,'ScreenSize');
+set(0,'Units',ScreenUnits);
+
+FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
+FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
+FigPos(3:4)=[FigWidth FigHeight];
+set(hObject, 'Position', FigPos);
+set(hObject, 'Units', OldUnits);
+
+% % Show a question icon from dialogicons.mat - variables questIconData and questIconMap
+% load dialogicons.mat
+% eval(['IconData=' icontype 'IconData;'])
+% eval(['IconCMap=' icontype 'IconMap;'])
+% questIconMap(256,:) = get(handles.figure1, 'Color');
+% Img=image(IconData, 'Parent', handles.axes1);
+% set(handles.figure1, 'Colormap', IconCMap);
+% set(handles.axes1, ...
+%     'Visible', 'off', ...
+%     'YDir'   , 'reverse'       , ...
+%     'XLim'   , get(Img,'XData'), ...
+%     'YLim'   , get(Img,'YData')  ...
+%     );
+if exist('GeometryCalib','var')
+    DataviewData.GeometryCalib=GeometryCalib;
+    set(hObject,'UserData',DataviewData)
+end
+if exist('SubCampaignTst','var') && isequal(SubCampaignTst,'y')
+   set(handles.SubCampaignTest,'Value',1);
+end
+if exist('RootDir','var') 
+   set(handles.RootDirectory,'String',RootDir);
+   set(handles.clean_civ_cmx,'Visible','off')
+   set(handles.edit_xml,'Visible','off')
+   set(handles.HELP,'Visible','off')
+   set(handles.OK,'Visible','on')
+   set(handles.Cancel,'Visible','on')
+   set(handles.figure,'WindowStyle','modal')% Make% Make the GUI modal 
+   RootDirectory_Callback(hObject, eventdata, handles)
+   % UIWAIT makes translate_points wait for user response (see UIRESUME)
+   uiwait(handles.figure);
+end
+
+
+
+%------------------------------------------------------------------------
 % --- Outputs from this function are returned to the command line.
 function varargout = dataview_OutputFcn(hObject, eventdata, handles)
-
+%------------------------------------------------------------------------
 % Get default command line output from handles structure
 varargout{1} = handles.output;
-
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%------------------------------------------------------
+delete(handles.figure)
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%------------------------------------------------------------------------
 % --- Executes on button press in browser.
 function browser_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------   
-
-CurrentFile='/coriolis/bigone/PROJETS';%get(handles.RootDirectory,'String');
+%------------------------------------------------------------------------
+CurrentFile='/raid/PROJETS';%get(handles.RootDirectory,'String');
 set(handles.SubCampaignTest,'Value',0)
 CampaignDir=uigetdir(CurrentFile,'Open the Campaign directory'); %file browser
@@ -74,6 +128,8 @@
 RootDirectory_Callback(hObject, eventdata, handles)
 
+%------------------------------------------------------------------------
 % --- Executes on button press in open_SubCampaign.
 function OpenSubCampaign_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 CurrentFile='/coriolis/bigone/PROJETS';%get(handles.RootDirectory,'String');
 set(handles.SubCampaignTest,'Value',1)
@@ -84,7 +140,8 @@
 
 %------------------------------------------------------------------------
-
 function RootDirectory_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 CampaignDir=get(handles.RootDirectory,'String');
+ExpName={''};
 if exist(CampaignDir,'dir')
     hdir=dir(CampaignDir); %list files and dirs
@@ -106,5 +163,5 @@
     ListExperiments_Callback(hObject, eventdata, handles)
 else
-    warndlg_uvmat(['The input ' CampaignDir ' is not a directory'],'ERROR')
+    msgbox_uvmat('ERROR',['The input ' CampaignDir ' is not a directory'])
 end
 
@@ -112,4 +169,5 @@
 % --- Executes on selection change in ListExperiments.
  function ListExperiments_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 CurrentPath=get(handles.RootDirectory,'String');
 ListExperiments=get(handles.ListExperiments,'String');
@@ -131,9 +189,10 @@
 set(handles.ListXml,'String',[{'*'};ListXml'])
 if testList
-    hh=get(handles.ListExperiments,'parent');
-    set(hh,'UserData',List)
+    DataviewData=get(handles.figure,'UserData');
+    DataView.List=List;
+    set(handles.figure,'UserData',DataviewData)
 end
 set(handles.CampaignDoc,'Visible','on')
-set(handles.edit_xml,'Visible','on')
+% set(handles.edit_xml,'Visible','on')
 
 %------------------------------------------------------------------------
@@ -184,6 +243,6 @@
 set(handles.ListExperiments,'Value',1)
 ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories
-hh=get(handles.CampaignDoc,'parent');
-List=get(hh,'UserData');
+DataviewData=get(handles.figure,'UserData');
+List=DataviewData.List;
 Currentpath=get(handles.RootDirectory,'String');
 [Currentpath,Campaign,DirExt]=fileparts(Currentpath);
@@ -422,4 +481,5 @@
 end
 
+%------------------------------------------------------------------------
 % --- Executes on button press in HELP.
 function HELP_Callback(hObject, eventdata, handles)
@@ -427,14 +487,9 @@
 pathelp=fileparts(path_to_uvmat);
 helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
-if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
+if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
 else
 web([helpfile '#dataview'])    
 end
 
-
-
-
-% --- Executes on button press in SubCampaignTest.
-function SubCampaignTest_Callback(hObject, eventdata, handles)
 
 
@@ -456,6 +511,6 @@
 set(handles.ListExperiments,'Value',1)
 ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories
-hh=get(handles.CampaignDoc,'parent');
-List=get(hh,'UserData');
+DataviewData=get(handles.figure,'UserData');
+List=DataviewData.List;
 Currentpath=get(handles.RootDirectory,'String');
 [Currentpath,Campaign,DirExt]=fileparts(Currentpath);
@@ -510,4 +565,164 @@
 
 
-
-
+% --- Executes on button press in OK.
+function OK_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
+CurrentPath=get(handles.RootDirectory,'String');
+ListExperiments=get(handles.ListExperiments,'String');
+IndicesExp=get(handles.ListExperiments,'Value');
+if ~isequal(IndicesExp,1)
+    ListExperiments=ListExperiments(IndicesExp);
+end
+ListDevices=get(handles.ListDevices,'String');
+Value=get(handles.ListDevices,'Value');
+if isequal(Value,1)
+    msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated')
+    return
+else 
+    ListDevices=ListDevices(Value);
+end
+ListRecords=get(handles.ListRecords,'String');
+Value=get(handles.ListRecords,'Value');
+if ~isequal(Value,1)
+    ListRecords=ListRecords(Value);
+end
+[ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords);
+ListXml=get(handles.ListXml,'String');
+Value=get(handles.ListXml,'Value');
+if isequal(Value,1)
+    msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit')
+    return
+else
+    ListXml=ListXml(Value);
+end
+
+%update all the selected xml files
+DataviewData=get(handles.figure,'UserData');
+% answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' ...
+%     DataviewData.GeometryCalib.CalibrationType ' calibration data'])
+% if ~isequal(answer,'Yes')
+%     return
+% end
+%List.Experiment{1}.Device{1}
+%List.Experiment{2}.Device{1}
+for iexp=1:length(List.Experiment)
+    ExpName=List.Experiment{iexp}.name;
+    set(handles.ListExperiments,'Value',IndicesExp(iexp));
+    if isfield(List.Experiment{iexp},'Device')
+        for idevice=1:length(List.Experiment{iexp}.Device)
+            DeviceName=List.Experiment{iexp}.Device{idevice}.name;      
+            if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
+                for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
+                    FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml};
+                    for ilistxml=1:length(ListXml)
+                        if isequal(FileName,ListXml{ilistxml})
+                            set(handles.ListXml,'Value',Value(ilistxml))
+                            drawnow
+                            xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName);
+                            update_imadoc(DataviewData.GeometryCalib,xmlfullname)
+                            display([xmlfullname ' updated'])
+                            break
+                        end
+                    end
+                end
+             elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
+                for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
+                    RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
+                    if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile')
+                        for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile)
+                            FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml};
+                            for ilistxml=1:length(ListXml)
+                                if isequal(FileName,ListXml{ilistxml})
+                                    set(handles.ListXml,'Value',Value(ilistxml))
+                                    drawnow
+                                    xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName);
+                                    update_imadoc(DataviewData.GeometryCalib,xmlfullname)
+                                    display([xmlfullname ' updated'])
+                                    break
+                                end
+                            end
+                        end
+                    end
+                end
+            end
+        end
+    end
+end
+set(handles.ListXml,'Value',Value)   
+%     
+%     
+%     
+%     
+%     
+%     
+%     
+% CurrentPath=get(handles.RootDirectory,'String');%= get(hObject,'String');
+% ListExperiments=get(handles.ListExperiments,'String');
+% Value=get(handles.ListExperiments,'Value');
+% if ~isequal(Value,1)
+%     ListExperiments=ListExperiments(Value);
+% end
+% ListDevices=get(handles.ListDevices,'String');
+% Value=get(handles.ListDevices,'Value');
+% if isequal(Value,1)
+%     msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated')
+%     return
+% else 
+%     ListDevices=ListDevices(Value);
+% end
+% ListRecords=get(handles.ListRecords,'String');
+% Value=get(handles.ListRecords,'Value');
+% if ~isequal(Value,1)
+%     ListRecords=ListRecords(Value);
+% end
+% [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords);
+% ListXml=get(handles.ListXml,'String');
+% Value=get(handles.ListXml,'Value');
+% if isequal(Value,1)
+%     msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit')
+%     return
+% else
+%     ListXml=ListXml(Value);
+% end
+% handles.output.CurrentPath=CurrentPath;
+% handles.output.ListExperiments=ListExperiments;
+% handles.output.ListDevices=ListDevices;
+% handles.output.ListRecords=ListRecords;
+% handles.output.ListXml=ListXml;
+% handles.output.List=List;
+handles.output ='OK, Calibration replicated';
+guidata(hObject, handles);% Update handles structure
+uiresume(handles.figure);
+
+% --- Executes on button press in Cancel.
+function Cancel_Callback(hObject, eventdata, handles)
+handles.output = get(hObject,'String');
+guidata(hObject, handles); % Update handles structure
+% Use UIRESUME instead of delete because the OutputFcn needs
+uiresume(handles.figure);
+
+% --- Executes when user attempts to close figure.
+function figure_CloseRequestFcn(hObject, eventdata, handles)
+if isequal(get(handles.figure, 'waitstatus'), 'waiting')
+    % The GUI is still in UIWAIT, us UIRESUME
+    uiresume(handles.figure);
+else
+    % The GUI is no longer waiting, just close it
+    delete(handles.figure);
+end
+
+% --- Executes on key press over figure1 with no controls selected.
+function figure_KeyPressFcn(hObject, eventdata, handles)
+% Check for "enter" or "escape"
+if isequal(get(hObject,'CurrentKey'),'escape')
+    % User said no by hitting escape
+    handles.output = 'Cancel';
+    
+    % Update handles structure
+    guidata(hObject, handles);
+    
+    uiresume(handles.figure);
+end
+if isequal(get(hObject,'CurrentKey'),'return')
+    uiresume(handles.figure);
+end 
Index: trunk/src/geometry_calib.m
===================================================================
--- trunk/src/geometry_calib.m	(revision 11)
+++ trunk/src/geometry_calib.m	(revision 12)
@@ -43,5 +43,5 @@
 % Edit the above text to modify the response to help geometry_calib
 
-% Last Modified by GUIDE v2.5 28-Dec-2009 23:41:18
+% Last Modified by GUIDE v2.5 05-Jan-2010 23:22:04
 
 % Begin initialization code - DO NOT edit
@@ -71,5 +71,5 @@
 % parameters on the uvmat interface (obtained by 'get_plot_handle.m')
 function geometry_calib_OpeningFcn(hObject, eventdata, handles, handles_uvmat,pos,inputfile)
-set(handles.Phi,'TooltipString','Phi: rotation angle of the physical point coordiantes (in degrees)')% TO PUT IN GUIDE
+
 % Choose default command line output for geometry_calib
 handles.output = hObject;
@@ -312,5 +312,5 @@
             uid_child=children(t,uid_calib);
             t=delete(t,uid_child);
-            testappend=1;
+%             testappend=1;
         end
     end
@@ -371,171 +371,167 @@
 GeometryCalib.SourceCalib.PointCoord=Object.Coord;
 
+
+%root PROJETS
+
 %open and read the dataview GUI
 h_dataview=findobj(allchild(0),'name','dataview');
-Device=[];%default
-if isempty(h_dataview)
-    h_dataview=dataview;
-    hhdataview=guidata(h_dataview);
-    drawnow
-    hGUI=get(handles.REPLICATE,'parent');%read the calibration image source on the interface userdata
-    CalibData=get(hGUI,'UserData');
+if ~isempty(h_dataview)
+    delete(h_dataview)
+end
+CalibData=get(handles.figure1,'UserData');%read the calibration image source on the interface userdata
+% filename='PROJETS';%default
+% if isfield(CalibData,'XmlInput')
+%      [pp,filename]=fileparts(CalibData.XmlInput);
+% end
+% while ~isequal(filename,'PROJETS') && numel(filename)>1
+%     filename_1=filename;
+%     pp_1=pp;
+%     [pp,filename]=fileparts(pp)
+% end
+% projinput=fullfile(pp_1,filename_1)
+% dd=dataview(projinput)
+
+% 
+% Device=[];%default
+% 
+% h_dataview=dataview;
+% hhdataview=guidata(h_dataview);
+% drawnow
+
+if isfield(CalibData,'XmlInput')
+    XmlInput=fileparts(CalibData.XmlInput);
+    [XmlInput,filename,ext]=fileparts(XmlInput);
+end
+SubCampaignTest='n'; %default
+testinput=0;
+if isfield(CalibData,'Heading')
+    Heading=CalibData.Heading;
+    if isfield(Heading,'Record') && isequal([filename ext],Heading.Record)
+        [XmlInput,filename,ext]=fileparts(XmlInput);
+    end
+    if isfield(Heading,'Device') && isequal([filename ext],Heading.Device)
+        [XmlInput,filename,ext]=fileparts(XmlInput);
+        Device=Heading.Device;
+    end
+    if isfield(Heading,'Experiment') && isequal([filename ext],Heading.Experiment)
+        [PP,filename,ext]=fileparts(XmlInput);
+    end
+    testinput=0;
+    if isfield(Heading,'SubCampaign') && isequal([filename ext],Heading.SubCampaign)
+%         set(hhdataview.RootDirectory,'String',XmlInput)
+%         set(hhdataview.SubCampaignTest,'Value',1)
+        SubCampaignTest='y';
+        testinput=1;
+    elseif isfield(Heading,'Campaign') && isequal([filename ext],Heading.Campaign)
+%         set(hhdataview.RootDirectory,'String',XmlInput)
+%         set(hhdataview.SubCampaignTest,'Value',0)
+        testinput=1;
+    end 
+end
+if ~testinput
+    filename='PROJETS';%default
     if isfield(CalibData,'XmlInput')
-        XmlInput=fileparts(CalibData.XmlInput);
-        [XmlInput,filename,ext]=fileparts(XmlInput);
-    end
-    if isfield(CalibData,'Heading')
-        Heading=CalibData.Heading;
-        if isfield(Heading,'Record') && isequal([filename ext],Heading.Record)
-            [XmlInput,filename,ext]=fileparts(XmlInput);
-        end
-        if isfield(Heading,'Device') && isequal([filename ext],Heading.Device)
-            [XmlInput,filename,ext]=fileparts(XmlInput);
-            Device=Heading.Device;
-        end
-        if isfield(Heading,'Experiment') && isequal([filename ext],Heading.Experiment)
-            [PP,filename,ext]=fileparts(XmlInput);
-        end
-        testinput=0;
-        if isfield(Heading,'SubCampaign') && isequal([filename ext],Heading.SubCampaign)
-            set(hhdataview.RootDirectory,'String',XmlInput)
-            set(hhdataview.SubCampaignTest,'Value',1)
-            testinput=1;
-        elseif isfield(Heading,'Campaign') && isequal([filename ext],Heading.Campaign)
-            set(hhdataview.RootDirectory,'String',XmlInput)
-            set(hhdataview.SubCampaignTest,'Value',0)
-            testinput=1;
-        end 
-    end
-    if testinput
-        dataview('RootDirectory_Callback',hObject,eventdata,hhdataview)
-        ListDevices=get(hhdataview.ListDevices,'String');
-        for ilist=1:length(ListDevices)
-            if isequal(ListDevices{ilist},Device)
-                set(hhdataview.ListDevices,'Value',ilist)
-                dataview('ListDevices_Callback',hObject,eventdata,hhdataview)
-                break
-            end
-        end
-    end
-    return
-end
-
-hhdataview=guidata(h_dataview);
-CurrentPath=get(hhdataview.RootDirectory,'String');
-ListExperiments=get(hhdataview.ListExperiments,'String');
-Value=get(hhdataview.ListExperiments,'Value');
-if ~isequal(Value,1)
-    ListExperiments=ListExperiments(Value);
-end
-ListDevices=get(hhdataview.ListDevices,'String');
-Value=get(hhdataview.ListDevices,'Value');
-if isequal(Value,1)
-    warndlg_uvmat('manually select in the GUI dataview the device being calibrated','ERROR')
-    return
-else 
-    ListDevices=ListDevices(Value);
-end
-ListRecords=get(hhdataview.ListRecords,'String');
-Value=get(hhdataview.ListRecords,'Value');
-if ~isequal(Value,1)
-    ListRecords=ListRecords(Value);
-end
-[ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords);
-ListXml=get(hhdataview.ListXml,'String');
-Value=get(hhdataview.ListXml,'Value');
-if isequal(Value,1)
-    warndlg_uvmat('you need to select in the GUI dataview the xml files to edit','ERROR')
-    return
-else
-    ListXml=ListXml(Value);
-end
-
-%update all the selected xml files
-answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' calib_type ' calibration data']);
-if ~isequal(answer{1},'OK')
-    return
-end
-% 'TEST'
-% List
-% return
-for iexp=1:length(List.Experiment)
-    ExpName=List.Experiment{iexp}.name;
-    if isfield(List.Experiment{iexp},'Device')
-        for idevice=1:length(List.Experiment{iexp}.Device)
-            DeviceName=List.Experiment{iexp}.Device{idevice}.name;       
-            if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
-                for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
-                    FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml};
-                    for ilistxml=1:length(ListXml)
-                        if isequal(FileName,ListXml{ilistxml})
-                            set(hhdataview.ListXml,'Value',Value(ilistxml))
-                            drawnow
-                            xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName);
-                            update_imadoc(GeometryCalib,xmlfullname)
-                            break
-                        end
-                    end
-                end
-             elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
-                for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
-                    RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
-                    if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile')
-                        for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile)
-                            FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml};
-                            for ilistxml=1:length(ListXml)
-                                if isequal(FileName,ListXml{ilistxml})
-                                    set(hhdataview.ListXml,'Value',Value(ilistxml))
-                                    drawnow
-                                    xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName);
-                                    update_imadoc(GeometryCalib,xmlfullname)
-                                    break
-                                end
-                            end
-                        end
-                    end
-                end
-            end
-        end
-    end
-end
-set(hhdataview.ListXml,'Value',Value)
-
-
-%-------------------------------------------------------------
-function update_imadoc(GeometryCalib,outputfile)
-testappend=0;
-if exist(outputfile,'file');%=1 if the output file already exists, 0 else  
-    t=xmltree(outputfile); %read the file
-    uid=find(t,'ImaDoc');
-    if isequal(uid,1)%if the xml file is  ImaDoc
-        uid_calib=find(t,'ImaDoc/GeometryCalib');
-        if ~isempty(uid) %if GeometryCalib already exists, delete its content
-            backupfile=outputfile;
-            testexist=2;
-            while testexist==2
-               backupfile=[backupfile '~'];
-               testexist=exist(backupfile,'file');
-            end
-            [success,message]=copyfile(outputfile,backupfile);%make backup
-            if isequal(success,1)
-                delete(outputfile)
-            else
-                return
-            end
-            uid_child=children(t,uid_calib);
-            t=delete(t,uid_child);
-            testappend=1;
-        end
-    end
-end
-if ~testappend
-    t=xmltree;
-    t=set(t,1,'name','ImaDoc');
-    [t,uid_calib]=add(t,1,'element','GeometryCalib');
-%     t=struct2xml(GeometryCalib,t,uid_calib);
-end
-
-t=struct2xml(GeometryCalib,t,uid_calib); 
-save(t,outputfile);
+         [pp,filename]=fileparts(CalibData.XmlInput);
+    end
+    while ~isequal(filename,'PROJETS') && numel(filename)>1
+        filename_1=filename;
+        pp_1=pp;
+        [pp,filename]=fileparts(pp);
+    end
+    XmlInput=fullfile(pp_1,filename_1);
+    testinput=1;
+end
+if testinput
+    outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib)%,SubCampaignTest)
+end
+%     %A COMPLETER
+%     dataview('RootDirectory_Callback',hObject,eventdata,hhdataview)
+%     ListDevices=get(hhdataview.ListDevices,'String');
+%     for ilist=1:length(ListDevices)
+%         if isequal(ListDevices{ilist},Device)
+%             set(hhdataview.ListDevices,'Value',ilist)
+%             dataview('ListDevices_Callback',hObject,eventdata,hhdataview)
+%             break
+%         end
+%     end
+
+% % hhdataview=guidata(h_dataview);
+% CurrentPath=get(hhdataview.RootDirectory,'String');
+% ListExperiments=get(hhdataview.ListExperiments,'String');
+% Value=get(hhdataview.ListExperiments,'Value');
+% if ~isequal(Value,1)
+%     ListExperiments=ListExperiments(Value);
+% end
+% ListDevices=get(hhdataview.ListDevices,'String');
+% Value=get(hhdataview.ListDevices,'Value');
+% if isequal(Value,1)
+%     msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated')
+%     return
+% else 
+%     ListDevices=ListDevices(Value);
+% end
+% ListRecords=get(hhdataview.ListRecords,'String');
+% Value=get(hhdataview.ListRecords,'Value');
+% if ~isequal(Value,1)
+%     ListRecords=ListRecords(Value);
+% end
+% [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords);
+% ListXml=get(hhdataview.ListXml,'String');
+% Value=get(hhdataview.ListXml,'Value');
+% if isequal(Value,1)
+%     msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit')
+%     return
+% else
+%     ListXml=ListXml(Value);
+% end
+% 
+% %update all the selected xml files
+% answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' calib_type ' calibration data'])
+% if ~isequal(answer,'Yes')
+%     return
+% end
+% 'TESTcalib'
+% List=DataFiles.List
+% for iexp=1:length(List.Experiment)
+%     ExpName=List.Experiment{iexp}.name;
+%     if isfield(List.Experiment{iexp},'Device')
+%         for idevice=1:length(List.Experiment{iexp}.Device)
+%             DeviceName=List.Experiment{iexp}.Device{idevice}.name;       
+%             if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
+%                 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
+%                     FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml};
+%                     for ilistxml=1:length(ListXml)
+%                         if isequal(FileName,ListXml{ilistxml})
+%                             set(hhdataview.ListXml,'Value',Value(ilistxml))
+%                             drawnow
+%                             xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName);
+%                             update_imadoc(GeometryCalib,xmlfullname)
+%                             break
+%                         end
+%                     end
+%                 end
+%              elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
+%                 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
+%                     RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
+%                     if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile')
+%                         for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile)
+%                             FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml};
+%                             for ilistxml=1:length(ListXml)
+%                                 if isequal(FileName,ListXml{ilistxml})
+%                                     set(hhdataview.ListXml,'Value',Value(ilistxml))
+%                                     drawnow
+%                                     xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName);
+%                                     update_imadoc(GeometryCalib,xmlfullname)
+%                                     break
+%                                 end
+%                             end
+%                         end
+%                     end
+%                 end
+%             end
+%         end
+%     end
+% end
+% set(hhdataview.ListXml,'Value',Value)
 
 
@@ -841,35 +837,4 @@
 rotation(handles,Phi)
 
-%-----------------------------------------------------
-%rotation
-function rotation(handles,Phi)
-O_x=str2num(get(handles.O_x,'String'));
-O_y=str2num(get(handles.O_y,'String'));
-if isempty(O_x)
-    O_x=0;%default
-end
-if isempty(O_y)
-    O_y=0;%default
-end
-Coord_cell=get(handles.ListCoord,'String');
-data=read_geometry_calib(Coord_cell);
-%data=read_geometry_calib(handles);
-r1=cos(pi*Phi/180);
-r2=-sin(pi*Phi/180);
-r3=sin(pi*Phi/180);
-r4=cos(pi*Phi/180);
-x=data.Coord(:,1);
-y=data.Coord(:,2);
-data.Coord(:,1)=r1*x+r2*y;
-data.Coord(:,2)=r3*x+r4*y;
-% data.Coord(:,[4 5])=data.Coord(:,[4 5]);
-for i=1:size(data.Coord,1)
-    for j=1:5
-          Coord{i,j}=num2str(data.Coord(i,j),4);%phys x,y,z
-   end
-end
-Tabchar=cell2tab(Coord,'    |    ');
-set(handles.ListCoord,'Value',1)
-set(handles.ListCoord,'String',Tabchar)
 
 
@@ -1090,23 +1055,17 @@
 % --------------------------------------------------------------------
 function MenuCreateGrid_Callback(hObject, eventdata, handles)
-% hObject    handle to MenuCreateGrid (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --------------------------------------------------------------------
-function MenuTranslatePoints_Callback(hObject, eventdata, handles)
 hcalib=get(handles.calib_type,'parent');%handles of the GUI geometry_calib
-CalibData=get(hcalib,'UserData')
+CalibData=get(hcalib,'UserData');
 Tinput=[];%default
-if isfield(CalibData,'translate')
-    Tinput=CalibData.translate;
-end
-T=translate_points(Tinput);%display translate_points GUI and get shift parameters 
-CalibData.translate=T;
+if isfield(CalibData,'grid')
+    Tinput=CalibData.grid;
+end
+T=create_grid(Tinput);%display translate_points GUI and get shift parameters 
+CalibData.grid=T;
 set(hcalib,'UserData',CalibData)
+
+%grid in phys space
 Coord_cell=get(handles.ListCoord,'String');
 data=read_geometry_calib(Coord_cell);
-% data=read_geometry_calib(handles);
 data.Coord(:,1)=T(1)+data.Coord(:,1);
 data.Coord(:,2)=T(2)+data.Coord(:,2);
@@ -1123,190 +1082,74 @@
 
 
+
+% --------------------------------------------------------------------
+function MenuTranslatePoints_Callback(hObject, eventdata, handles)
+hcalib=get(handles.calib_type,'parent');%handles of the GUI geometry_calib
+CalibData=get(hcalib,'UserData')
+Tinput=[];%default
+if isfield(CalibData,'translate')
+    Tinput=CalibData.translate;
+end
+T=translate_points(Tinput);%display translate_points GUI and get shift parameters 
+CalibData.translate=T;
+set(hcalib,'UserData',CalibData)
+%translation
+Coord_cell=get(handles.ListCoord,'String');
+data=read_geometry_calib(Coord_cell);
+data.Coord(:,1)=T(1)+data.Coord(:,1);
+data.Coord(:,2)=T(2)+data.Coord(:,2);
+data.Coord(:,3)=T(3)+data.Coord(:,3);
+data.Coord(:,[4 5])=data.Coord(:,[4 5]);
+for i=1:size(data.Coord,1)
+    for j=1:5
+          Coord{i,j}=num2str(data.Coord(i,j),4);%phys x,y,z
+   end
+end
+Tabchar=cell2tab(Coord,'    |    ');
+set(handles.ListCoord,'Value',1)
+set(handles.ListCoord,'String',Tabchar)
+
+
 % --------------------------------------------------------------------
 function MenuRotatePoints_Callback(hObject, eventdata, handles)
-% hObject    handle to MenuRotatePoints (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --------------------------------------------------------------------
-function Untitled_8_Callback(hObject, eventdata, handles)
-% hObject    handle to Untitled_8 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-
-function edit27_Callback(hObject, eventdata, handles)
-
-
-function edit28_Callback(hObject, eventdata, handles)
-% hObject    handle to O_y (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 O_y as text
-%        str2double(get(hObject,'String')) returns contents of O_y as a double
-
-
-% --- Executes on button press in rotation_plus.
-function pushbutton16_Callback(hObject, eventdata, handles)
-% hObject    handle to rotation_plus (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --- Executes on button press in rotation_minus.
-function pushbutton17_Callback(hObject, eventdata, handles)
-% hObject    handle to rotation_minus (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-
-function edit30_Callback(hObject, eventdata, handles)
-% hObject    handle to Phi (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 Phi as text
-%        str2double(get(hObject,'String')) returns contents of Phi as a double
-
-
-% --- Executes during object creation, after setting all properties.
-function O_y_CreateFcn(hObject, eventdata, handles)
-% hObject    handle to O_y (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
-
-
-% --- Executes during object creation, after setting all properties.
-function O_x_CreateFcn(hObject, eventdata, handles)
-% hObject    handle to O_x (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
-
-
-% --- Executes during object creation, after setting all properties.
-function T_x_CreateFcn(hObject, eventdata, handles)
-% hObject    handle to T_x (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
-
-
-% --- Executes during object creation, after setting all properties.
-function T_y_CreateFcn(hObject, eventdata, handles)
-% hObject    handle to T_y (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
-
-
-% --- Executes during object creation, after setting all properties.
-function T_z_CreateFcn(hObject, eventdata, handles)
-% hObject    handle to T_z (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 edit31_Callback(hObject, eventdata, handles)
-% hObject    handle to edit31 (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 edit31 as text
-%        str2double(get(hObject,'String')) returns contents of edit31 as a double
-
-
-% --- Executes during object creation, after setting all properties.
-function edit31_CreateFcn(hObject, eventdata, handles)
-% hObject    handle to edit31 (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 edit32_Callback(hObject, eventdata, handles)
-% hObject    handle to edit32 (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 edit32 as text
-%        str2double(get(hObject,'String')) returns contents of edit32 as a double
-
-
-% --- Executes during object creation, after setting all properties.
-function edit32_CreateFcn(hObject, eventdata, handles)
-% hObject    handle to edit32 (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 edit33_Callback(hObject, eventdata, handles)
-% hObject    handle to edit33 (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 edit33 as text
-%        str2double(get(hObject,'String')) returns contents of edit33 as a double
-
-
-% --- Executes on button press in pushbutton18.
-function pushbutton18_Callback(hObject, eventdata, handles)
-% hObject    handle to pushbutton18 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --- Executes on button press in pushbutton19.
-function pushbutton19_Callback(hObject, eventdata, handles)
-% hObject    handle to pushbutton19 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-
-
+hcalib=get(handles.calib_type,'parent');%handles of the GUI geometry_calib
+CalibData=get(hcalib,'UserData')
+Tinput=[];%default
+if isfield(CalibData,'rotate')
+    Tinput=CalibData.rotate;
+end
+T=rotate_points(Tinput);%display translate_points GUI and get shift parameters 
+CalibData.rotate=T;
+set(hcalib,'UserData',CalibData)
+%-----------------------------------------------------
+%rotation
+Phi=T(1);
+O_x=0;%default
+O_y=0;%default
+if numel(T)>=2
+    O_x=T(2);%default
+end
+if numel(T)>=3
+    O_y=T(3);%default
+end
+Coord_cell=get(handles.ListCoord,'String');
+data=read_geometry_calib(Coord_cell);
+r1=cos(pi*Phi/180);
+r2=-sin(pi*Phi/180);
+r3=sin(pi*Phi/180);
+r4=cos(pi*Phi/180);
+x=data.Coord(:,1)-O_x;
+y=data.Coord(:,2)-O_y;
+data.Coord(:,1)=r1*x+r2*y;
+data.Coord(:,2)=r3*x+r4*y;
+% data.Coord(:,[4 5])=data.Coord(:,[4 5]);
+for i=1:size(data.Coord,1)
+    for j=1:5
+          Coord{i,j}=num2str(data.Coord(i,j),4);%phys x,y,z
+   end
+end
+Tabchar=cell2tab(Coord,'    |    ');
+set(handles.ListCoord,'Value',1)
+set(handles.ListCoord,'String',Tabchar)
+
+
Index: trunk/src/get_field.m
===================================================================
--- trunk/src/get_field.m	(revision 11)
+++ trunk/src/get_field.m	(revision 12)
@@ -22,5 +22,5 @@
 function varargout = get_field(varargin)
 
-% Last Modified by GUIDE v2.5 08-Jan-2010 15:15:06
+% Last Modified by GUIDE v2.5 06-Feb-2010 09:58:13
 
 % Begin initialization code - DO NOT EDIT
@@ -56,5 +56,5 @@
 guidata(hObject, handles);
 pathuvmat=fileparts(which('uvmat'));
-% addpath(fullfile(pathuvmat,'FIELD_FCT'))
+addpath(fullfile(pathuvmat,'FIELD_FCT'))
 set(handles.attributes,'enable','on')% TO BE SET BY GUIDE
 set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles})%set mouse click action function
@@ -113,8 +113,4 @@
 
 
-
-
-
-
 %-----------------------------------------------------------
 % --- Outputs from this function are returned to the command line.
@@ -125,6 +121,4 @@
 % --- Executes on button press in browse.
 function browse_Callback(hObject, eventdata, handles)
-
-
 
 
@@ -768,5 +762,4 @@
 end
 haxes=findobj(hfig,'Type','axes');
-
 plot_field(SubField,haxes) 
 end
@@ -1484,13 +1477,12 @@
 list_path=get(handles.ACTION,'UserData');
 nb_builtin=0;
-list_path
 if iscell(list_path)
-for ilist=1:length(list_path)
-    if isequal(list_path{ilist},path_get_field)
-        nb_builtin=nb_builtin+1;
-    else
-        break
-    end
-end
+    for ilist=1:length(list_path)
+        if isequal(list_path{ilist},path_get_field)
+            nb_builtin=nb_builtin+1;
+        else
+            break
+        end
+    end
 end
 if nb_builtin==0% the path to get_field has been changed, reinitialize
@@ -1652,17 +1644,17 @@
 %default setting for the visibility of the GUI elements*
 if ~isequal(ACTION,'PLOT')
-    varargout=feval(ACTION);% input list asked by the selected function
+    varargout=feval(ACTION)% input list asked by the selected function
     test_1Dplot=[];
     test_scalar=[];
     test_vector=[];
-    for ilist=1:length(varargout)-1
-        switch varargout{ilist}
+    for ilist=1:length(varargout)
+        switch varargout{ilist,1}
                            %RootFile always visible
             case 'check_1Dplot'   
-                 test_1Dplot=isequal(lower(varargout{ilist+1}),'y');
+                 test_1Dplot=isequal(lower(varargout{ilist,2}),'y')
             case 'check_scalar'
-                 test_scalar=isequal(lower(varargout{ilist+1}),'y');    
+                 test_scalar=isequal(lower(varargout{ilist,2}),'y')    
             case 'check_vector'   
-                 test_vector=isequal(lower(varargout{ilist+1}),'y'); 
+                 test_vector=isequal(lower(varargout{ilist,2}),'y') 
         end
     end
@@ -1725,13 +1717,5 @@
 % end
 
-% --- Executes on selection change in menu_coord.
-function HELP_Callback(hObject, eventdata, handles)
-path_to_uvmat=which ('uvmat');% check the path of uvmat
-pathelp=fileparts(path_to_uvmat);
-helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
-if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
-else
-web([helpfile '#get_field'])    
-end
+
 
 %-----------------------------------------------------
@@ -1883,5 +1867,5 @@
 testblank=findstr(fileinput,' ');%look for blanks
 if ~isempty(testblank)
-    warndlg_uvmat(['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name'],'ERROR')
+    msgbox_uvmat('ERROR',['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name'])
     return
 end
@@ -1917,40 +1901,47 @@
 % --------------------------------------------------------------------
 function MenuFile_1_Callback(hObject, eventdata, handles)
-% hObject    handle to MenuFile_1 (see GCBO)
+fileinput=get(handles.MenuFile_1,'Label');
+set(handles.inputfile,'String',fileinput)
+inputfile_Callback(hObject, eventdata, handles)
+
+% --------------------------------------------------------------------
+function MenuFile_2_Callback(hObject, eventdata, handles)
+fileinput=get(handles.MenuFile_2,'Label');
+set(handles.inputfile,'String',fileinput)
+inputfile_Callback(hObject, eventdata, handles)
+
+% --------------------------------------------------------------------
+function MenuFile_3_Callback(hObject, eventdata, handles)
+fileinput=get(handles.MenuFile_3,'Label');
+set(handles.inputfile,'String',fileinput)
+inputfile_Callback(hObject, eventdata, handles)
+
+% --------------------------------------------------------------------
+function MenuFile_4_Callback(hObject, eventdata, handles)
+fileinput=get(handles.MenuFile_4,'Label');
+set(handles.inputfile,'String',fileinput)
+inputfile_Callback(hObject, eventdata, handles)
+
+% --------------------------------------------------------------------
+function MenuFile_5_Callback(hObject, eventdata, handles)
+fileinput=get(handles.MenuFile_5,'Label');
+set(handles.inputfile,'String',fileinput)
+inputfile_Callback(hObject, eventdata, handles)
+
+% --------------------------------------------------------------------
+function MenuExportField_Callback(hObject, eventdata, handles)
+
+
+% --------------------------------------------------------------------
+function MenuHelp_Callback(hObject, eventdata, handles)
+% hObject    handle to MenuHelp (see GCBO)
 % eventdata  reserved - to be defined in a future version of MATLAB
 % handles    structure with handles and user data (see GUIDATA)
-
-
-% --------------------------------------------------------------------
-function MenuFile_2_Callback(hObject, eventdata, handles)
-% hObject    handle to MenuFile_2 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --------------------------------------------------------------------
-function MenuFile_3_Callback(hObject, eventdata, handles)
-% hObject    handle to MenuFile_3 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --------------------------------------------------------------------
-function MenuFile_4_Callback(hObject, eventdata, handles)
-% hObject    handle to MenuFile_4 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --------------------------------------------------------------------
-function MenuFile_5_Callback(hObject, eventdata, handles)
-% hObject    handle to MenuFile_5 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --------------------------------------------------------------------
-function ExportField_Callback(hObject, eventdata, handles)
-% hObject    handle to ExportField (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
+path_to_uvmat=which ('uvmat');% check the path of uvmat
+pathelp=fileparts(path_to_uvmat);
+helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
+if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
+else
+web([helpfile '#get_field'])    
+end
+
Index: trunk/src/mouse_up.m
===================================================================
--- trunk/src/mouse_up.m	(revision 11)
+++ trunk/src/mouse_up.m	(revision 12)
@@ -194,4 +194,5 @@
                     set(hfig2,'DeleteFcn',{@close_fig,AxeData.CurrentRectZoom,'zoom'})
                     set(hfig2,'UserData',AxeData.CurrentRectZoom)% record the parent object (zoom rectangle) in the new fig
+                    %UvData.Plane2.Axes=copyobj(currentaxes,hfig2); %copy the current graph axes to the zoom figure  
                     AxeData.ZoomAxes=copyobj(currentaxes,hfig2); %copy the current graph axes to the zoom figure 
                     figure(hfig2)
Index: trunk/src/msgbox_uvmat.m
===================================================================
--- trunk/src/msgbox_uvmat.m	(revision 11)
+++ trunk/src/msgbox_uvmat.m	(revision 12)
@@ -142,5 +142,4 @@
 else
     varargout{1}=get(handles.edit_box,'String');
-    isequal(varargout{1},'')
     if isempty(varargout{1}) || isequal(varargout{1},'')
         varargout{1}='Yes';
Index: trunk/src/series.m
===================================================================
--- trunk/src/series.m	(revision 11)
+++ trunk/src/series.m	(revision 12)
@@ -1999,5 +1999,4 @@
                             % check the content  netcdf file
                             Data=nc2struct(file,'ListGlobalAttribute','patch2','fix2','civ2','patch','fix','absolut_time_T0','hart');
-                            lastfield='civ1'; %default
                             if ~isempty(Data.patch2) && isequal(Data.patch2,1) 
                                 lastfield='patch2';
@@ -2012,21 +2011,5 @@
                             elseif ~isempty(Data.absolut_time_T0) && ~isempty(Data.hart)
                                 lastfield='civ1'; 
-                            end   
-%                             Data=nc2struct(file,[]);       
-%                              lastfield='civ1'; %default
-%                             if isfield(Data,'patch2') & isequal(Data.patch2,1);
-%                                 lastfield='patch2';
-%                             elseif isfield(Data,'fix2') & isequal(Data.fix2,1);
-%                                 lastfield='fix2';
-%                             elseif isfield(Data,'civ2') & isequal(Data.civ2,1);
-%                                 lastfield='civ2';
-%                             elseif isfield(Data,'patch') & isequal(Data.patch,1);
-%                                 lastfield='patch1';
-%                             elseif isfield(Data,'fix') & isequal(Data.fix,1);
-%                                 lastfield='fix1';
-%                             elseif isfield(Data,'absolut_time_T0') & isfield(Data,'hart')
-%                                 lastfield='civ1'; 
-%                             end   
-                          
+                            end                          
                         end 
                     end
@@ -2222,6 +2205,6 @@
            return
         end
-        hhget_field=guidata(hget_field);%handles of GUI elements in get_field
-        SubField=read_var_names(hhget_field); %read the names of the variables to plot in the get_field GUI
+        %hhget_field=guidata(hget_field);%handles of GUI elements in get_field
+        SubField=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
     end
 end
@@ -2566,4 +2549,5 @@
 hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI
 delete(hget_field)
+'TEST'
 uvmat(filemean)
 
@@ -3035,11 +3019,11 @@
 if isequal(FieldName,'get_field...')
     hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI
-    hhget_field=guidata(hget_field);%handles of GUI elements in get_field
-    SubField=get_field('read_var_names',hObject,eventdata,hhget_field); %read the names of the variables to plot in the get_field GUI
-    if isequal(get(hhget_field.menu_coord,'Visible'),'on')
-        list_transform=get(hhget_field.menu_coord,'String');
-        val_list=get(hhget_field.menu_coord,'Value');
-        transform=list_transform{val_list};
-    end
+   % hhget_field=guidata(hget_field);%handles of GUI elements in get_field
+    SubField=get_field('read_get_field',hObject,eventdata,hget_field); %read the names of the variables to plot in the get_field GUI
+%     if isequal(get(hhget_field.menu_coord,'Visible'),'on')
+%         list_transform=get(hhget_field.menu_coord,'String');
+%         val_list=get(hhget_field.menu_coord,'Value');
+%         transform=list_transform{val_list};
+%     end
 end
 %detect whether all the files are 'images' or 'netcdf'
@@ -3303,10 +3287,10 @@
     else
         if length(ivar_Y)~=1
-                msgbox_uvmat('ERROR','y coordinate missing in proj_field.m')
+                warndlg_uvmat('y coordinate missing in proj_field.m','ERROR')
                 return
         end
         test_grid=0;
     end
- %   DimIndices=Data{1}.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell)
+%    DimIndices=Data{1}.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell)
     %case of input fields with unstructured coordinates
     if ~test_grid
@@ -3319,5 +3303,5 @@
     %case of fields defined on a structured  grid 
     else  
-%         DimValue=MergeData.DimValue(DimIndices);%set of dimension values
+%        DimValue=MergeData.DimValue(DimIndices);%set of dimension values
         testFF=0;
         for iview=2:nbview
@@ -3660,5 +3644,6 @@
 if test_object%isfield(Series,'sethandles')
     Series.ProjObject=read_set_object(Series.sethandles);
-    answeryes=questdlg({['field series projected on ' Series.ProjObject.Style]});
+    %answeryes=questdlg({['field series projected on ' Series.ProjObject.Style]});
+    answeryes=msgbox_uvmat('INPUT_Y-N',['field series projected on ' Series.ProjObject.Style]);
     if ~isequal(answeryes,'Yes')
         return
@@ -3698,16 +3683,18 @@
 %Number of input series: this function  accepts only a single input file series 
 nbview=length(RootPath);
-if nbview>2  
-    RootPath=RootPath(1:2);
-    set(hseries.RootPath,'String',RootPath)
-    SubDir=SubDir(1:2);
-    set(hseries.SubDir,'String',SubDir)
-    RootFile=RootFile(1:2);
-    set(hseries.RootFile,'String',RootFile)
-    NomType=NomType(1:2);
-    %set(hseries.NomType,'String',NomType)
-    FileExt=FileExt(1:2);
-    set(hseries.FileExt,'String',FileExt)
-    nbview=2;
+if nbview==2
+    %TODO: choose between difference and two series
+elseif nbview>2  % TODO: make multiple series
+%     RootPath=RootPath(1:2);
+%     set(hseries.RootPath,'String',RootPath)
+%     SubDir=SubDir(1:2);
+%     set(hseries.SubDir,'String',SubDir)
+%     RootFile=RootFile(1:2);
+%     set(hseries.RootFile,'String',RootFile)
+%     NomType=NomType(1:2);
+%     %set(hseries.NomType,'String',NomType)
+%     FileExt=FileExt(1:2);
+%     set(hseries.FileExt,'String',FileExt)
+%     nbview=2;
 end
 hhh=which('mmreader');
@@ -3722,5 +3709,4 @@
 end
 filebase{1}=fullfile(RootPath{1},RootFile{1});
-% FileDisplay=fullfile(RootPath{1},SubDir{1},RootFile{1});
 
 % number of slices
@@ -3739,20 +3725,25 @@
 if isequal(FieldName,{'get_field...'})
     hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI
-    if length(hget_field)>1
-        delete(hget_field(2:end))
+    if numel(hget_field)>1
+        delete(hget_field(2:end)) % delete multiple occurerence of the GUI get_fioeld
     elseif isempty(hget_field)
-       filename=...
-               name_generator(filebase{1},num_i1{1}(1),num_j1{1}(1),FileExt{1},NomType{1},1,num_i2{1}(1),num_j2{1}(1),SubDir{1}); 
+       filename=name_generator(filebase{1},num_i1{1}(1),num_j1{1}(1),FileExt{1},NomType{1},1,num_i2{1}(1),num_j2{1}(1),SubDir{1}); 
        idetect(iview)=exist(filename,'file');
        hget_field=get_field(filename);
        return
     end
-    hhget_field=guidata(hget_field);%handles of GUI elements in get_field
-    SubField=read_var_names(hhget_field); %read the names of the variables to plot in the get_field GUI
-    if isequal(get(hhget_field.menu_coord,'Visible'),'on')
-        list_transform=get(hhget_field.menu_coord,'String');
-        val_list=get(hhget_field.menu_coord,'Value');
-        transform=list_transform{val_list};
-    end
+    %hhget_field=guidata(hget_field);%handles of GUI elements in get_field
+    SubField=read_get_field(hget_field) %read the names of the variables to plot in the get_field GUI
+    if isempty(SubField)
+        delete(hget_field)
+       filename=name_generator(filebase{1},num_i1{1}(1),num_j1{1}(1),FileExt{1},NomType{1},1,num_i2{1}(1),num_j2{1}(1),SubDir{1});
+        hget_field=get_field(filename);
+        SubField=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
+    end
+%     if isequal(get(hhget_field.menu_coord,'Visible'),'on')
+%         list_transform=get(hhget_field.menu_coord,'String');
+%         val_list=get(hhget_field.menu_coord,'Value');
+%         transform=list_transform{val_list};
+%     end
 end
 
@@ -3794,5 +3785,5 @@
     increment=num_i1{1}(2)-num_i1{1}(1);
     if ~isequal(increment,1) % if an increment is set
-        answeryes=msgbox_uvmat('INPUT_Y-N',['will take time series in ' num2str(NbSlice) 'slices with increment = ' num2str(increment) '!']) 
+        answeryes=msgbox_uvmat('INPUT_Y-N',['will take time series in ' num2str(NbSlice) 'slices with increment = ' num2str(increment) '!']); 
     else    
         answeryes=msgbox_uvmat('INPUT_Y-N',{['will take time series in ' num2str(NbSlice) ' slices'];['results stored as files ' filebase_out ' ...']});
@@ -3930,14 +3921,6 @@
                     nbcolor=size(A,3);
                     if nbcolor==3
-%                         Data{iview}.ListDimName={'coord_y','coord_x','rgb'};
-%                         Data{iview}.DimValue=[npy npx 3];
-%                         Data{iview}.VarDimIndex={[1 2 3]};
-                           Data{iview}.VarDimName={'coord_y','coord_x',{'coord_y','coord_x','rgb'}};
+                         Data{iview}.VarDimName={'coord_y','coord_x',{'coord_y','coord_x','rgb'}};
                     else
-%                         Data{iview}.ListDimName={'coord_y','coord_x'};  
-%                         Data{iview}.DimValue=[npy npx];
-%                         Data{iview}.VarDimIndex={[1 2]};
-%                         Data{iview}.VarAttribute{1}.Coord_1=[npy-0.5 0.5];
-%                         Data{iview}.VarAttribute{1}.Coord_2=[0.5 npx-0.5];
                          Data{iview}.VarDimName={'coord_y','coord_x',{'coord_y','coord_x'}};
                     end  
@@ -3980,4 +3963,5 @@
             end
             if isfield(Series,'ProjObject')
+                Series.ProjObject
                 [Field,errormsg]=proj_field(Field,Series.ProjObject);
                 if ~isempty(errormsg)
@@ -4022,6 +4006,5 @@
                                     DimCell={DimCell};
                                 end
-                                if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell)%TODO generalise with attribute
-                               % if length(Field.ListDimName)>=index & isequal(Field.ListVarName{ivar},Field.ListDimName{index})%detect dimension variables
+                                if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables
                                    testsum(ivar)=1;
                                 end
@@ -4034,5 +4017,4 @@
                         end
                     end
-                 %   RecordData.ListDimName=[{'Time'} RecordData.ListDimName];%name of dimension 
                     RecordData.ListVarName=[{'Time'} RecordData.ListVarName];
                 end
@@ -4050,5 +4032,5 @@
                         end
                         VarVal=shiftdim(VarVal,-1); %shift dimension 
-                        eval(['RecordData.' VarName '=cat(1,RecordData.' VarName ',VarVal);']);%concanete the current field to the time series                     
+                        eval(['RecordData.' VarName '=cat(1,RecordData.' VarName ',VarVal);']);%concanete the current field to the time series    
                     elseif testsum(ivar)==1% variable representing fixed coordinates
                         eval(['VarInit=RecordData.' VarName ';']);
@@ -4117,8 +4099,4 @@
     [filemean]=...
                name_generator(filebase_out,num_i1{1}(i_slice),num_j1{1}(i_slice),'.nc','_i1-i2_j1-j2',1,num_i2{end}(ifile),num_j2{end}(ifile),SubDir{1});
-    RecordData
-     RecordData.VarDimName{1}
-     RecordData.VarDimName{2}
-      RecordData.VarDimName{3}
     errormsg=struct2nc(filemean,RecordData); %save result file
     if isempty(errormsg)
@@ -4442,5 +4420,5 @@
                             time_first=Attrib.absolut_time_T0;
                         end
-                        if isfield(Attrib,'absolut_time_T0_2')&~(isequal(VelType,'civ1')|isequal(VelType,'interp1')|isequal(VelType,'filter1'))
+                        if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1'))
                             time_first=Attrib.absolut_time_T0_2;
                         end
@@ -4456,5 +4434,5 @@
                             time_last=Attrib.absolut_time_T0;
                         end
-                        if isfield(Attrib,'absolut_time_T0_2')&~(isequal(VelType,'civ1')|isequal(VelType,'interp1')|isequal(VelType,'filter1'))
+                        if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1'))
                             time_last=Attrib.absolut_time_T0_2;
                         end
Index: trunk/src/translate_points.m
===================================================================
--- trunk/src/translate_points.m	(revision 11)
+++ trunk/src/translate_points.m	(revision 12)
@@ -16,5 +16,5 @@
 function varargout = translate_points(varargin)
 
-% Last Modified by GUIDE v2.5 05-Jan-2010 09:49:31
+% Last Modified by GUIDE v2.5 05-Jan-2010 19:31:33
 
 % Begin initialization code - DO NOT EDIT
@@ -163,4 +163,40 @@
 
 
-
-
+function edit5_Callback(hObject, eventdata, handles)
+% hObject    handle to edit5 (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 edit5 as text
+%        str2double(get(hObject,'String')) returns contents of edit5 as a double
+
+
+
+function edit6_Callback(hObject, eventdata, handles)
+% hObject    handle to edit6 (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 edit6 as text
+%        str2double(get(hObject,'String')) returns contents of edit6 as a
+%        double
+
+
+function edit7_Callback(hObject, eventdata, handles)
+% hObject    handle to edit7 (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 edit7 as text
+%        str2double(get(hObject,'String')) returns contents of edit7 as a double
+
+
+function edit8_Callback(hObject, eventdata, handles)
+% hObject    handle to edit8 (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 edit8 as text
+%        str2double(get(hObject,'String')) returns contents of edit8 as a double
+
+
