Changeset 309


Ignore:
Timestamp:
Nov 30, 2011, 11:09:12 PM (13 years ago)
Author:
sommeria
Message:

many bugs corrected, cleaning of civ.m, resize of the GUI civ

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r308 r309  
    11%'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch)
    22%------------------------------------------------------------------------
    3 %  provides an interface for the software CIVx
     3%  provides an interface for the software menucivx
    44% function varargout = civ(varargin)
    5 % provides an interface for the software CIVx
     5% provides an interface for the software menucivx
    66%
    77%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
     
    2323%TODO: search range
    2424
    25 % Last Modified by GUIDE v2.5 21-Nov-2011 10:58:28
     25% Last Modified by GUIDE v2.5 30-Nov-2011 21:52:52
    2626% Begin initialization code - DO NOT EDIT
    2727gui_Singleton = 1;
     
    5252handles.output = hObject;
    5353guidata(hObject, handles); % Update handles structure
    54 set(hObject,'WindowButtonDownFcn',{'mouse_down',handles}) % allows mouse action with right button (zoom for uicontrol display)
     54set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
    5555
    5656%% Adjust the GUI according to the binaries available in PARAM.xml
     
    100100end
    101101
    102 %% input parameters:
    103 % param
    104 % filebase=''; % root file name ('filebase'.civ)
    105 % ext=[];
    106 % num_i1=1; % set of field i numbers
    107 % num_i2=1; % set of field i numbers
    108 % num_j1=1; % set of field j numbers (fields a)
    109 % num_j2=1; % second set of field j numbers (fields b)
    110 % %subdir='A'; % subdir for the netcdf result files
    111 % ind_opening=0; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2)
    112 % %load the initial parameters if the interface is started from uvmat
    113 % if exist('param','var')&&isstruct(param)% the interface is opened from uvmat
    114 %     filebase=param.RootName;
    115 %     nom_type_read=param.NomType;
    116 %     num_i1=param.num1;
    117 %     if isnan(num_i1),num_i1=1;end
    118 %     num_i2=param.num2;
    119 %     if isnan(num_i2),num_i2=num_i1;end
    120 %     num_j1=param.num_a;
    121 %     if isnan(num_j1),num_j1=1;end
    122 %     num_j2=param.num_b;
    123 %     if isnan(num_j2),num_j2=num_j1;end
    124 %     subdir=param.SubDir;
    125 %     ind_opening=param.IndOpening;
    126 %     ext=param.ImaExt;
    127 % end
    128 % browse.num_i1=num_i1;
    129 % browse.num_i2=num_i2;
    130 % browse.num_j1=num_j1;
    131 % browse.num_j2=num_j2;
    132 % if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat
    133 %     set(handles.ImaExt,'String',ext)
    134 % %     browse.ext_ima=ext;
    135 % %     if exist('nom_type_read','var')
    136 % %         browse.nom_type_ima=nom_type_read; % the image nomenclature is stored
    137 % %     end
    138 % % elseif isequal(ext,'.nc')
    139 % %     if exist('nom_type_read','var')
    140 % %         browse.nom_type_nc=nom_type_read;% the netcdf  nomenclature is stored
    141 % %     end
    142 % end
    143 % set(handles.RootName,'String',filebase);
    144 % set(handles.ImaDoc,'String',ext)
    145 
    146 
    147102%% prepare the GUI with parameters from the input file if opened from uvmat
    148103if exist('fileinput','var')% && isfield(param,'RootName') && ~isempty(param.RootName)
     
    153108end
    154109
    155 % %initiate advised operations
    156 % enable_civ1(handles,0)
    157 % enable_civ2(handles,0)
    158 % %enable_pair1(handles,'on')
    159 % enable_fix1(handles,0)
    160 % enable_patch1(handles,0)
    161 % enable_fix2(handles,0)
    162 % enable_patch2(handles,0)
    163 % set(handles.CheckCiv1,'Value',0)
    164 % set(handles.CheckFix1,'Value',0)
    165 % set(handles.CheckPatch1,'Value',0)
    166 % set(handles.CheckCiv2,'Value',0)
    167 % set(handles.CheckFix2,'Value',0)
    168 % set(handles.CheckPatch2,'Value',0)
    169 %
    170 % if isequal(ind_opening,1)
    171 %     set(handles.CheckCiv1,'Value',1)
    172 %     enable_civ1(handles,1)
    173 % elseif isequal(ind_opening,2)
    174 %     set(handles.CheckFix1,'Value',1)
    175 %     enable_fix1(handles,1)
    176 % elseif isequal(ind_opening,3)
    177 %     set(handles.CheckPatch1,'Value',1)
    178 %     enable_patch1(handles,1)
    179 % elseif isequal(ind_opening,4)
    180 %     set(handles.CheckCiv2,'Value',1)
    181 %     enable_civ2(handles,1)
    182 % elseif isequal(ind_opening,5)
    183 %     set(handles.CheckFix2,'Value',1)
    184 %     enable_fix2(handles,1)
    185 %     set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])
    186 %     set(handles.ListPairCiv2,'Enable','On')
    187 %     set(handles.ListPairCiv2,'Enable','On')
    188 %     enable_pair1(handles,'off')
    189 % elseif isequal(ind_opening,6)
    190 %     set(handles.CheckPatch2,'Value',1)
    191 %     enable_patch2(handles,1)
    192 %     set(handles.ListPairCiv2,'Enable','On')
    193 %     enable_pair1(handles,'off')
    194 % end
    195 %
    196 % % set the range of fields (1:1 by default) and selected pair
    197 % if isequal(num_i2,num_i1)
    198 %     num_ref_i=num_i1;
    199 % else
    200 %     num_ref_i=floor((num_i1+num_i2)/2);
    201 %     browse.incr_pair(1)=num_i2-num_i1;
    202 %     browse.incr_pair(2)=0;
    203 % end
    204 % if isequal(num_j1,num_j2)
    205 %     if isnan(num_j1)
    206 %         num_ref_j=1;
    207 %     else
    208 %         num_ref_j=num_j1;
    209 %     end
    210 % else
    211 %     num_ref_j=floor((num_j1+num_j2)/2);
    212 %     browse.incr_pair(2)=num_j2-num_j1;
    213 % end
    214 % set(handles.first_i,'String',num2str(num_ref_i));
    215 % set(handles.last_i,'String',num2str(num_ref_i));
    216 % set(handles.first_j,'String',num2str(num_ref_j));
    217 % set(handles.last_j,'String',num2str(num_ref_j));
    218 % set(handles.ref_i,'String',num2str(num_ref_i));
    219 % set(handles.ref_j,'String',num2str(num_ref_j));
    220 % set(handles.RootName,'UserData',browse);
    221 
    222110%------------------------------------------------------------------------
    223111% --- Outputs from this function are returned to the command line.
     
    228116
    229117%------------------------------------------------------------------------
    230 % --- function activated by the Open/Browse... option in the upper menu bar.
     118% --- Function activated by the Open/Browse... option in the upper menu bar.
    231119function MenuBrowse_Callback(hObject, eventdata, handles)
    232120%------------------------------------------------------------------------
     
    234122filebase=get(handles.RootName,'String');
    235123oldfile=''; %default
    236 if isempty(filebase)|| isequal(filebase,'')%loads the previously stored root file name 
     124if isempty(filebase)|| isequal(filebase,'')%loads the previously stored root file name
    237125    dir_perso=prefdir;
    238126    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     
    252140browse.incr_pair=[0 0]; %default
    253141menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)';
    254        '*.xml',  '.xml files '; ...
    255         '*.civ',  '.civ files '; ...
    256         '*.png','.png image files'; ...
    257         '*.jpg',' jpeg image files'; ...
    258         '*.tif','.tif image files'; ...
    259         '*.avi;*.AVI','.avi movie files'; ...
    260         '*.nc','.netcdf files'; ...
    261         '*.*',  'All Files (*.*)'};
     142    '*.xml',  '.xml files '; ...
     143    '*.civ',  '.civ files '; ...
     144    '*.png','.png image files'; ...
     145    '*.jpg',' jpeg image files'; ...
     146    '*.tif','.tif image files'; ...
     147    '*.avi;*.AVI','.avi movie files'; ...
     148    '*.nc','.netcdf files'; ...
     149    '*.*',  'All Files (*.*)'};
    262150[FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile);
    263151fileinput=[PathName FileName];%complete file name
     
    267155%% prepare the GUI with parameters from the input file if opened from uvmat
    268156errormsg=display_file_name(handles,fileinput);
    269     if ~isempty(errormsg)
    270         msgbox_uvmat('ERROR',erromsg)
    271     end
    272 
     157if ~isempty(errormsg)
     158    msgbox_uvmat('ERROR',erromsg)
     159end
    273160
    274161[path,name,ext]=fileparts(fileinput);
     
    297184end
    298185[RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput);
    299 filebase=fullfile(RootPath,RootFile);
     186% filebase=fullfile(RootPath,RootFile);
    300187num_i1=str2double(str1);
    301188if isnan(num_i1),num_i1=1;end
     
    323210
    324211set(handles.RootName,'UserData',browse);% store information from browser
    325 RootName_Callback(hObject, eventdata, handles);
    326 
    327 % -----------------------------------------------------------------------
     212
     213%------------------------------------------------------------------------
    328214% --- Open again the file whose name has been recorded in MenuFile_1
    329215function MenuFile_1_Callback(hObject, eventdata, handles)
     
    344230    msgbox_uvmat('ERROR',erromsg)
    345231end
     232
    346233% -----------------------------------------------------------------------
    347234% --- Open again the file whose name has been recorded in MenuFile_3
     
    353240    msgbox_uvmat('ERROR',erromsg)
    354241end
     242
    355243% -----------------------------------------------------------------------
    356244% --- Open again the file whose name has been recorded in MenuFile_4
     
    362250    msgbox_uvmat('ERROR',erromsg)
    363251end
     252
    364253% -----------------------------------------------------------------------
    365254% --- Open again the file whose name has been recorded in MenuFile_5
     
    371260    msgbox_uvmat('ERROR',erromsg)
    372261end
    373 % %------------------------------------------------------------------------
    374 % function ImaDoc_Callback(hObject, eventdata, handles)
    375 % %------------------------------------------------------------------------
    376 % RootName_Callback(hObject, eventdata, handles)
    377 
    378 %------------------------------------------------------------------------
    379 % --- function activated when a new filebase (image series) is introduced
     262
     263% -----------------------------------------------------------------------
     264% --- Prepare the GUI for the compiled CivX program
     265function MenuCivX_Callback(hObject, eventdata, handles)
     266set(handles.MenuMatlab,'checked','off')
     267set(handles.MenuCivX,'checked','on')
     268%set(handles.thresh_patch1,'Visible','off')
     269% set(handles.thresh_text1,'Visible','off')
     270% set(handles.num_MaxDiff,'Visible','off')
     271% set(handles.thresh_text2,'Visible','off')
     272set(handles.num_Rho,'Style','edit')
     273set(handles.num_Rho,'String','1')
     274set(handles.BATCH,'Enable','on')
     275% -----------------------------------------------------------------------
     276
     277% -----------------------------------------------------------------------
     278% --- Prepare the GUI for the Matlab PIV program
     279function MenuMatlab_Callback(hObject, eventdata, handles)
     280% -----------------------------------------------------------------------
     281set(handles.MenuMatlab,'checked','on')
     282set(handles.MenuCivX,'checked','off')
     283if get(handles.CheckPatch1,'Value')
     284    set(handles.thresh_patch1,'Visible','on')
     285    set(handles.thresh_text1,'Visible','on')
     286end
     287if get(handles.CheckPatch2,'Value')
     288    set(handles.num_MaxDiff,'Visible','on')
     289    set(handles.thresh_text2,'Visible','on')
     290end
     291set(handles.num_Rho,'Style','popupmenu')
     292set(handles.num_Rho,'Value',1)
     293set(handles.num_Rho,'String',{'1';'2'})
     294set(handles.BATCH,'Enable','off')
     295
     296% -----------------------------------------------------------------------
     297% --- Open the help html file
     298function MenuHelp_Callback(hObject, eventdata, handles)
     299% -----------------------------------------------------------------------
     300path_civ=fileparts(which ('civ'));
     301helpfile=fullfile(path_civ,'uvmat_doc','uvmat_doc.html');
     302if isempty(dir(helpfile))
     303    msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
     304else
     305    addpath (fullfile(path_civ,'uvmat_doc'))
     306    web([helpfile '#civ'])
     307end
     308
     309%------------------------------------------------------------------------
     310% --- Function activated when a new filebase (image series) is introduced
    380311function RootName_Callback(hObject, eventdata, handles)
    381312%------------------------------------------------------------------------
     
    385316    msgbox_uvmat('ERROR',erromsg)
    386317end
    387 %------------------------------------------------------------------------
     318
     319%------------------------------------------------------------------------
     320% --- general function activated for an input file series
    388321function errormsg=display_file_name(handles,fileinput)
    389322%------------------------------------------------------------------------
     
    408341RootName=fullfile(RootPath,FileName);
    409342set(handles.RootName,'String',RootName)
     343set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    410344num_i1=str2double(i1_str);
    411345num_i2=str2double(i2_str);
     
    477411end
    478412
    479 % ext_imadoc=get(handles.ImaDoc,'String');
    480 % browse=get(handles.RootName,'UserData');%default
    481 % if isfield(browse,'nom_type_ima')
    482 %     nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name
    483 % end
    484 % if isfield(browse,'ext_ima')
    485 %     ext_ima=browse.ext_ima;
    486 % end
    487 % if isfield(browse,'nom_type_nc')
    488 %     nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name
    489 % end
    490 % if isfield(browse,'num_i1')
    491 %     field_count=browse.num_i1;% get an image index type already determined by an input file
    492 % end
    493 %set(handles.civ,'UserData',[]); %refresh list of previous civ files (for STATUS)
    494 
    495 
    496413%% look for an image documentation file
    497414ext_imadoc='';%default
     
    517434pxcmx_search=[];%default
    518435pxcmy_search=[];%default
    519 % first_i=1;%default
    520 % last_i=1;%default   
    521436if isequal(ext_imadoc,'.civxml')%TO ABANDON
    522437    [nbfield,nbfield2,time]=read_civxml([RootName '.civxml']);
     
    592507%% timing display
    593508%show the reference image edit box if relevant (not needed for movies or in the absence of time information
    594 % if isempty(time)|| strcmp(nom_type_ima,'*')||strcmp(nom_type_ima,'')
    595 % %     set(handles.ref_i,'Visible','Off')% do not use a reference index to display time intervals
    596 % %     set(handles.ref_j,'Visible','Off')
    597 %     first_i=1;
    598 %     last_i=1;
    599 % else
    600 % %     set(handles.ref_i,'Visible','On')%use a reference index
    601 % %     set(handles.ref_j,'Visible','On')
    602 %     set(handles.ref_i,'String',i1_str)
    603 %     set(handles.ref_j,'String',j1_str)
    604 % end
    605509if ~isempty(time)
    606510    if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt
     
    723627    end
    724628end
    725 
    726 %------------------------------------------------------------------------
    727 % --- Executes on button press in ListPairMode.
    728 function ListPairMode_Callback(hObject, eventdata, handles)
    729 %------------------------------------------------------------------------
    730 % browse=get(handles.RootName,'UserData');
    731 compare_list=get(handles.ListCompareMode,'String');
    732 val=get(handles.ListCompareMode,'Value');
    733 compare=compare_list{val};
    734 if strcmp(compare,'displacement')
    735     mode='displacement';
    736 else
    737     mode_list=get(handles.ListPairMode,'String');
    738     if ischar(mode_list)
    739         mode_list={mode_list};
    740     end
    741     mode_value=get(handles.ListPairMode,'Value');
    742     mode=mode_list{mode_value};
    743 end
    744 displ_num=[];%default
    745 ref_i=str2double(get(handles.ref_i,'String'));
    746 % last_i=str2num(get(handles.last_i,'String'));
    747 time=get(handles.ImaDoc,'UserData'); %get the set of times
    748 siztime=size(time);
    749 nbfield=siztime(1);
    750 nbfield2=siztime(2);
    751 indchosen=1;  %%first pair selected by default
    752 %displ_num used to define the indices of the civ pairs
    753 % displ_num(1,:)=indices j1
    754 % displ_num(2,:)=indices j2
    755 % displ_num(3,:)=indices i1
    756 % displ_num(4,:)=indices i2
    757 % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices
    758 % are relative to the reference indices ref_i and ref_j respectively.
    759 if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2')
    760     dt=1;
    761     displ='';
    762     index=0;
    763     numlist_a=[];
    764     numlist_B=[];
    765     %get all the time intervals in bursts
    766     displ_dt=1;%default
    767     nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10
    768     for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode
    769         for numod_b=(numod_a+1):nbfield2
    770             index=index+1;
    771             numlist_a(index)=numod_a;
    772             numlist_b(index)=numod_b;
    773             if ~isempty(time)
    774                 dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt
    775                 displ_dt(index)=dt(numod_a,numod_b);
    776             else
    777                 displ_dt(index)=1;
    778             end
    779         end
    780     end
    781     [dtsort,indsort]=sort(displ_dt);
    782     if ~isempty(numlist_a)
    783         displ_num(1,:)=numlist_a(indsort);
    784         displ_num(2,:)=numlist_b(indsort);
    785     end
    786     displ_num(3,:)=0;
    787     displ_num(4,:)=0;
    788     set(handles.jtext,'Visible','Off')
    789     set(handles.first_j,'Visible','Off')
    790     set(handles.last_j,'Visible','Off')
    791     set(handles.incr_j,'Visible','Off')
    792     set(handles.nb_field2,'Visible','Off')
    793     set(handles.ref_j,'Visible','Off')
    794 elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)')
    795     index=1:200;
    796     displ_num(1,index)=-floor(index/2);
    797     displ_num(2,index)=ceil(index/2);
    798     displ_num(3:4,index)=zeros(2,200);
    799 %     for index=1:min(nbfield2-1,200)
    800 %         displ_num(1,index)=-floor(index/2);
    801 %         displ_num(2,index)=ceil(index/2);
    802 %         displ_num(3,index)=0;
    803 %         displ_num(4,index)=0;
    804 %     end
    805     set(handles.jtext,'Visible','On')
    806     set(handles.first_j,'Visible','On')
    807     set(handles.last_j,'Visible','On')
    808     set(handles.incr_j,'Visible','On')
    809     set(handles.nb_field2,'Visible','On')
    810     set(handles.ref_j,'Visible','On')
    811     if nbfield > 1
    812         set(handles.itext,'Visible','On')
    813         set(handles.first_i,'Visible','On')
    814         set(handles.last_i,'Visible','On')
    815         set(handles.incr_i,'Visible','On')
    816         set(handles.nb_field,'Visible','On')
    817         set(handles.ref_i,'Visible','On')
     629set(handles.RootName,'BackgroundColor',[1 1 1])
     630
     631%------------------------------------------------------------------------
     632% --- Executes on carriage return on the subdir checkciv1 edit window
     633function txt_SubdirCiv1_Callback(hObject, eventdata, handles)
     634%------------------------------------------------------------------------
     635subdir=get(handles.txt_SubdirCiv1,'String');
     636menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update
     637ichoice=find(strcmp(subdir,menu_str),1);
     638if isempty(ichoice)
     639    ilist=numel(menu_str); %select 'new...' in the menu
     640else
     641    ilist=ichoice;
     642end
     643set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu
     644if get(handles.CheckCiv1,'Value')% if Civ1 is performed
     645    set(handles.txt_SubdirCiv2,'String',subdir);% set by default civ2 directory the same as civ1
     646    set(handles.ListSubdirCiv2,'Value',ilist)
     647else % if Civ1 data already exist
     648    find_netcpair_civ1(handles); %update the list of available pairs from netcdf files in the new directory
     649end
     650
     651%------------------------------------------------------------------------
     652% --- Executes on carriage return on the subdir checkciv1 edit window
     653function txt_SubdirCiv2_Callback(hObject, eventdata, handles)
     654%------------------------------------------------------------------------
     655subdir=get(handles.txt_SubdirCiv1,'String');
     656menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update
     657ichoice=find(strcmp(subdir,menu_str),1);
     658if isempty(ichoice)
     659    ilist=numel(menu_str); %select 'new...' in the menu
     660else
     661    ilist=ichoice;
     662end
     663set(handles.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu
     664%update the list of available pairs from netcdf files in the new directory
     665if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value')
     666    find_netcpair_civ2(handles);
     667end
     668
     669%------------------------------------------------------------------------
     670% --- Executes on button press in CheckCiv1.
     671function CheckCiv1_Callback(hObject, eventdata, handles)
     672%------------------------------------------------------------------------
     673update_CivOptions(handles)
     674
     675%------------------------------------------------------------------------
     676% --- Executes on button press in CheckFix1.
     677function CheckFix1_Callback(hObject, eventdata, handles)
     678%------------------------------------------------------------------------
     679update_CivOptions(handles)
     680
     681%------------------------------------------------------------------------
     682% --- Executes on button press in CheckPatch1.
     683function CheckPatch1_Callback(hObject, eventdata, handles)
     684%------------------------------------------------------------------------
     685update_CivOptions(handles)
     686
     687%------------------------------------------------------------------------
     688% --- Executes on button press in CheckCiv2.
     689function CheckCiv2_Callback(hObject, eventdata, handles)
     690%------------------------------------------------------------------------
     691update_CivOptions(handles)
     692
     693%------------------------------------------------------------------------
     694% --- Executes on button press in CheckFix2.
     695function CheckFix2_Callback(hObject, eventdata, handles)
     696%------------------------------------------------------------------------
     697update_CivOptions(handles)
     698
     699%------------------------------------------------------------------------
     700% --- Executes on button press in CheckPatch2.
     701function CheckPatch2_Callback(hObject, eventdata, handles)
     702%------------------------------------------------------------------------
     703update_CivOptions(handles)
     704
     705%------------------------------------------------------------------------
     706% --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2
     707function update_CivOptions(handles)
     708%------------------------------------------------------------------------
     709checkbox=zeros(1,6);
     710checkbox(1)=get(handles.CheckCiv1,'Value');
     711checkbox(2)=get(handles.CheckFix1,'Value');
     712checkbox(3)=get(handles.CheckPatch1,'Value');
     713checkbox(4)=get(handles.CheckCiv2,'Value');
     714checkbox(5)=get(handles.CheckFix2,'Value');
     715checkbox(6)=get(handles.CheckPatch2,'Value');
     716ind_selected=find(checkbox,1);
     717if ~isempty(ind_selected)
     718  RootName=get(handles.RootName,'String');
     719    if isempty(RootName)
     720         msgbox_uvmat('ERROR','Please open an image or PIV .nc file with the upper bar menu Open/Browse...')
     721        return
     722    end
     723end
     724set(handles.PairIndices,'Visible','on')
     725set(handles.txt_SubdirCiv1,'Visible','on')
     726set(handles.ListSubdirCiv1,'Visible','on')
     727find_netcpair_civ1(handles) % select the available netcdf files
     728if max(checkbox(4:6))% case of civ2 pair choice needed
     729    set(handles.TitlePairCiv2,'Visible','on')
     730    set(handles.TitleSubdirCiv2,'Visible','on')
     731    set(handles.txt_SubdirCiv2,'Visible','on')
     732    set(handles.ListSubdirCiv2,'Visible','on')
     733    set(handles.ListPairCiv2,'Visible','on')
     734    find_netcpair_civ2(handles) % select the available netcdf files
     735else
     736    set(handles.TitleSubdirCiv2,'Visible','off')
     737    set(handles.txt_SubdirCiv2,'Visible','off')
     738    set(handles.ListSubdirCiv2,'Visible','off')
     739    set(handles.ListPairCiv2,'Visible','off')
     740end
     741options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'};
     742for ilist=1:length(options)
     743    if checkbox(ilist)
     744        set(handles.(options{ilist}),'Visible','on')
    818745    else
    819         set(handles.itext,'Visible','Off')
    820         set(handles.first_i,'Visible','Off')
    821         set(handles.last_i,'Visible','Off')
    822         set(handles.incr_i,'Visible','Off')
    823         set(handles.nb_field,'Visible','Off')
    824         set(handles.ref_i,'Visible','Off')
    825     end
    826 elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)')
    827     index=1:200;
    828     displ_num(1:2,index)=zeros(2,200);
    829     displ_num(3,index)=-floor(index/2);
    830     displ_num(4,index)=ceil(index/2);
    831 %     for index=1:200%min(nbfield-1,200)
    832 %         displ_num(1,index)=0;
    833 %         displ_num(2,index)=0;
    834 %         displ_num(3,index)=-floor(index/2);
    835 %         displ_num(4,index)=ceil(index/2);
    836 %     end
    837     set(handles.itext,'Visible','On')
    838     set(handles.first_i,'Visible','On')
    839     set(handles.last_i,'Visible','On')
    840     set(handles.incr_i,'Visible','On')
    841     set(handles.nb_field,'Visible','On')
    842     set(handles.ref_i,'Visible','On')
    843     if nbfield2 > 1
    844         set(handles.jtext,'Visible','On')
    845         set(handles.first_j,'Visible','On')
    846         set(handles.last_j,'Visible','On')
    847         set(handles.incr_j,'Visible','On')
    848         set(handles.nb_field2,'Visible','On')
    849         set(handles.ref_j,'Visible','On')
    850     else
    851         set(handles.jtext,'Visible','Off')
    852         set(handles.first_j,'Visible','Off')
    853         set(handles.last_j,'Visible','Off')
    854         set(handles.incr_j,'Visible','Off')
    855         set(handles.nb_field2,'Visible','Off')
    856         set(handles.ref_j,'Visible','Off')
    857     end
    858 elseif isequal(mode,'displacement')%the pairs have the same indices
    859     displ_num(1,1)=0;
    860     displ_num(2,1)=0;
    861     displ_num(3,1)=0;
    862     displ_num(4,1)=0;
    863     if nbfield > 1
    864         set(handles.itext,'Visible','On')
    865         set(handles.first_i,'Visible','On')
    866         set(handles.last_i,'Visible','On')
    867         set(handles.incr_i,'Visible','On')
    868         set(handles.nb_field,'Visible','On')
    869         set(handles.ref_i,'Visible','On')
    870     else
    871         set(handles.itext,'Visible','Off')
    872         set(handles.first_i,'Visible','Off')
    873         set(handles.last_i,'Visible','Off')
    874         set(handles.incr_i,'Visible','Off')
    875         set(handles.nb_field,'Visible','Off')
    876         set(handles.ref_i,'Visible','Off')
    877     end
    878     if nbfield2 > 1
    879         set(handles.jtext,'Visible','On')
    880         set(handles.first_j,'Visible','On')
    881         set(handles.last_j,'Visible','On')
    882         set(handles.incr_j,'Visible','On')
    883         set(handles.nb_field2,'Visible','On')
    884         set(handles.ref_j,'Visible','On')
    885     else
    886         set(handles.jtext,'Visible','Off')
    887         set(handles.first_j,'Visible','Off')
    888         set(handles.last_j,'Visible','Off')
    889         set(handles.incr_j,'Visible','Off')
    890         set(handles.nb_field2,'Visible','Off')
    891         set(handles.ref_j,'Visible','Off')
    892     end
    893 end
    894 set(handles.ListPairCiv1,'UserData',displ_num);
    895 find_netcpair_civ1( handles)
    896 find_netcpair_civ2(handles)
    897 
    898 %------------------------------------------------------------------------
    899 % determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of
    900 % the field series set by first_i, incr, last_i
    901 function find_netcpair_civ1(handles)
    902 %------------------------------------------------------------------------
    903 set(gcf,'Pointer','watch')
    904 %nomenclature types
    905 filebase=get(handles.RootName,'String');
    906 [filepath,Nme,ext_dir]=fileparts(filebase);
    907 browse=get(handles.RootName,'UserData');
    908 compare_list=get(handles.ListCompareMode,'String');
    909 val=get(handles.ListCompareMode,'Value');
    910 compare=compare_list{val};
    911 if strcmp(compare,'displacement')
    912     mode='displacement';
    913 else
    914     mode_list=get(handles.ListPairMode,'String');
    915     mode_value=get(handles.ListPairMode,'Value');
    916     if isempty(mode_list)
    917         return
    918     end
    919     mode=mode_list{mode_value};
    920 end
    921 
    922 % nomenclature type of the .nc files
    923 nom_type_ima=[];%default
    924 if isfield(browse,'nom_type_ima')
    925     nom_type_ima=browse.nom_type_ima;
    926 end
    927 
    928 %determine nom_type_nc:
    929 nom_type_nc=[];%default
    930 if isfield(browse,'nom_type_nc')
    931     nom_type_nc=browse.nom_type_nc;
    932 end
    933 if isempty(nom_type_nc)
    934     [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)'));
    935 end
    936 browse.nom_type_nc=nom_type_nc;
    937 set(handles.RootName,'UserData',browse)
    938 
    939 %reads .nc subdirectoy and image numbers from the interface
    940 subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data
    941 ref_i=str2double(get(handles.ref_i,'String'));
    942 if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')
    943     ref_j=0;
    944 else
    945     ref_j=str2double(get(handles.ref_j,'String'));
    946 end
    947 time=get(handles.ImaDoc,'UserData');%get the set of times
    948 if isempty(time)
    949     time=[0 1];
    950 end
    951 dt_unit=1000;%default
    952 displ_num=get(handles.ListPairCiv1,'UserData');
    953 
    954 %eliminate the first pairs inconsistent with the position
    955 if isempty(displ_num)
    956     nbpair=0;
    957 else
    958     nbpair=length(displ_num(1,:));%nbre of displayed pairs
    959     if  isequal(mode,'series(Di)')  %| isequal(mode,'st_series(Di)')
    960         nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index
    961     elseif  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
    962         nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index
    963     end
    964 end
    965 nbpair=min(200,nbpair);%limit the number of displayed pairs to 200
    966 
    967 %look for existing processed pairs involving the field at the middle of the series if checkciv1 will not
    968 % be performed, while the result is needed for next steps.
    969 displ_pair={''};
    970 select=ones(size(1:nbpair));%flag for displayed pairs =1 for display
    971 testpair=0;
    972 
    973 %% case with no Civ1 operation, netcdf files need to exist for reading
    974 if ~get(handles.CheckCiv1,'Value') %
    975     if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir')
    976         msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']);
    977         set(handles.ListPairCiv1,'String',{});
    978         return
    979     end
    980     for ipair=1:nbpair
    981         filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
    982             ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
    983         select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist
    984     end   
    985     % case of no displayed pair
    986     if isequal(select,zeros(size(1:nbpair)))
    987         if isfield(browse,'incr_pair') && ~isequal(browse.incr_pair,[0 0])
    988             num_i1=ref_i-floor(browse.incr_pair(1)/2);
    989             num_i2=ref_i+ceil(browse.incr_pair(1)/2);
    990             num_j1=ref_j-floor(browse.incr_pair(2)/2);
    991             num_j2=ref_j+ceil(browse.incr_pair(2)/2);
    992             filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1);
    993             select(1)=exist(filename,'file')==2;
    994             testpair=1;
    995         else
    996             if  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
    997                 msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]);
    998             else
    999                 msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]);
    1000             end
    1001             set(handles.ListPairCiv1,'String',{''});
    1002             %COMPLETER CAS STEREO
    1003             return
    1004         end
    1005     end
    1006 end
    1007 
    1008 %% determine the menu display in .ListPairCiv1
    1009 % the menu depends on the mode defined in ListPairMode_callback through the array displ_num:
    1010 % displ_num(1,:)=indices j1
    1011 % displ_num(2,:)=indices j2
    1012 % displ_num(3,:)=indices i1
    1013 % displ_num(4,:)=indices i2
    1014 % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices
    1015 % are relative to the reference indices ref_i and ref_j respectively.
    1016 if isequal(mode,'series(Di)')
    1017     if testpair
    1018         displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))];
    1019     else
    1020         for ipair=1:nbpair
    1021             if select(ipair)
    1022                 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))];
    1023                 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
    1024                     dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
    1025                     displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    1026                 end
    1027             else
    1028                 displ_pair{ipair}='...'; %pair not displayed in the menu
    1029             end
    1030         end
    1031     end
    1032 elseif isequal(mode,'series(Dj)')
    1033     if testpair
    1034         displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))];
    1035     else
    1036         for ipair=1:nbpair
    1037             if select(ipair)
    1038                 displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))];
    1039                 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
    1040                     dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
    1041                     displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    1042                 end
    1043             else
    1044                 displ_pair{ipair}='...'; %pair not displayed in the menu
    1045             end
    1046         end
    1047     end
    1048 elseif isequal(mode,'pair j1-j2')%case of pairs
    1049     for ipair=1:nbpair
    1050         if select(ipair)
    1051             dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt
    1052             displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ...
    1053                 ' :dt= ' num2str(dt*1000)];
    1054         else
    1055             displ_pair{ipair}='...'; %pair not displayed in the menu
    1056         end
    1057     end
    1058 elseif isequal(mode,'displacement')
    1059     displ_pair={'Di=Dj=0'};
    1060 end
    1061 set(handles.ListPairCiv1,'String',displ_pair');
    1062 
    1063 %% determine the default selection in the pair menu
    1064 ichoice=find(select,1);% index of selected pair
    1065 if (isempty(ichoice) || ichoice < 1); ichoice=1; end;
    1066 initial=get(handles.ListPairCiv1,'Value');%initial choice of pair
    1067 if initial>nbpair || (numel(select)>=initial && ~isequal(select(initial),1))
    1068     set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu
    1069 end
    1070 initial=get(handles.ListPairCiv2,'Value');
    1071 if initial>length(displ_pair')%|~isequal(select(initial),1)
    1072     if ichoice <= length(displ_pair')
    1073         set(handles.ListPairCiv2,'Value',ichoice);% same pair proposed by default for civ2
    1074     else
    1075         set(handles.ListPairCiv2,'Value',1);% same pair proposed by default for civ2
    1076     end
    1077 end
    1078 set(handles.ListPairCiv2,'String',displ_pair');
    1079 set(gcf,'Pointer','arrow')
    1080 
    1081 %------------------------------------------------------------------------
    1082 % determine the menu for checkciv2 pairs depending on the existing netcdf file at the
    1083 %middle of the series set by first_i, incr, last_i
    1084 function find_netcpair_civ2(handles)
    1085 %------------------------------------------------------------------------
    1086 set(gcf,'Pointer','watch')
    1087 %nomenclature types
    1088 filebase=get(handles.RootName,'String');
    1089 [filepath,Nme,ext_dir]=fileparts(filebase);
    1090 browse=get(handles.RootName,'UserData');
    1091 compare_list=get(handles.ListCompareMode,'String');
    1092 val=get(handles.ListCompareMode,'Value');
    1093 compare=compare_list{val};
    1094 if strcmp(compare,'displacement')
    1095     mode='displacement';
    1096 else
    1097     mode_list=get(handles.ListPairMode,'String');
    1098     if isempty(mode_list)
    1099         msgbox_uvmat('ERROR','please enter an input image or netcdf file')
    1100         return
    1101     end
    1102     mode_value=get(handles.ListPairMode,'Value');
    1103     mode=mode_list{mode_value};
    1104 end
    1105 
    1106 % nomenclature type of the .nc files
    1107 nom_type_ima='ima_num';%default
    1108 if isfield(browse,'nom_type_ima')
    1109     nom_type_ima=browse.nom_type_ima;
    1110 end
    1111 nom_type_nc='_i1-i2';%default
    1112 if isfield(browse,'nom_type_nc')
    1113     nom_type_nc=browse.nom_type_nc;
    1114 end
    1115 if isequal(nom_type_ima,'png_old') || isequal(nom_type_ima,'netc_old')|| isequal(nom_type_ima,'raw_SMD')|| isequal(nom_type_nc,'netc_old')
    1116     nom_type_nc='netc_old';%nom_type for the netcdf files
    1117 elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none')
    1118     nom_type_nc='none';
    1119 elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2')
    1120     nom_type_nc='_i1-i2';
    1121 else
    1122     if  isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)')
    1123         nom_type_nc='_i1-i2_j'; % PIV in volume
    1124     else
    1125         nom_type_nc='_i_j1-j2';
    1126     end
    1127 end
    1128 browse.nom_type_nc=nom_type_nc;
    1129 set(handles.RootName,'UserData',browse)
    1130 
    1131 %reads .nc subdirectory and image numbers from the interface
    1132 subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data
    1133 subdir_civ2=get(handles.txt_SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data
    1134 ref_i=str2double(get(handles.ref_i,'String'));
    1135 if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')
    1136     ref_j=0;
    1137 else
    1138     ref_j=str2double(get(handles.ref_j,'String'));
    1139 end
    1140 time=get(handles.ImaDoc,'UserData'); %get the set of times
    1141 if isempty(time)
    1142     time=[0 1];%default
    1143 end
    1144 displ_num=get(handles.ListPairCiv1,'UserData');
    1145 
    1146 %eliminate the first pairs inconsistent with the position
    1147 if isempty(displ_num)
    1148     nbpair=0;
    1149 else
    1150     nbpair=length(displ_num(1,:));%nbre of displayed pairs
    1151     if  isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)')
    1152         nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index
    1153     elseif  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
    1154         nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index
    1155     end
    1156 end
    1157 nbpair=min(200,nbpair);%limit the number of displayed pairs to 200
    1158 
    1159 %% look for existing processed pairs at the reference indices if Civ1 will not
    1160 % be performed, while the result is needed for next steps.
    1161 displ_pair={''}; %default
    1162 select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs
    1163 if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value')
    1164     if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir')
    1165         errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist'])
    1166         set(handles.ListPairCiv2,'Value',1);
    1167         set(handles.ListPairCiv2,'String',{''});
    1168         return
    1169     end
    1170     for ipair=1:nbpair
    1171         filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
    1172             ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
    1173         select(ipair)=exist(filename,'file')==2;
    1174     end
    1175     if  isequal(select,zeros(size(1:nbpair)))
    1176         if isfield(browse,'incr_pair')
    1177             num_i1=ref_i-floor(browse.incr_pair(1)/2);
    1178             num_i2=ref_i+floor((browse.incr_pair(1)+1)/2);
    1179             num_j1=ref_j-floor(browse.incr_pair(2)/2);
    1180             num_j2=ref_j+floor((browse.incr_pair(2)+1)/2);
    1181             filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2);
    1182             select(1)=exist(filename,'file')==2;
    1183         else
    1184             if  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
    1185                 errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2])
    1186             else
    1187                 errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2])
    1188             end
    1189             set(handles.ListPairCiv2,'Value',1);
    1190             set(handles.ListPairCiv2,'String',{''});
    1191             return
    1192         end
    1193     end
    1194 end
    1195 if isequal(mode,'series(Di)')
    1196     for ipair=1:nbpair
    1197         if select(ipair)
    1198             displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
    1199             if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
    1200                 dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
    1201                 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    1202             end
    1203         else
    1204             displ_pair{ipair}='...'; %pair not displayed in the menu
    1205         end
    1206     end
    1207 elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index
    1208     for ipair=1:nbpair
    1209         if select(ipair)
    1210             displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
    1211             if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
    1212                 dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
    1213                 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    1214             end
    1215         else
    1216             displ_pair{ipair}='...'; %pair not displayed in the menu
    1217         end
    1218     end
    1219 elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs
    1220     for ipair=1:nbpair
    1221         if select(ipair)
    1222             dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt
    1223             displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ...
    1224                 ' :dt= ' num2str(dt*1000)];
    1225         else
    1226             displ_pair{ipair}='...'; %pair not displayed in the menu
    1227         end
    1228     end
    1229 elseif isequal(mode,'displacement')
    1230     displ_pair={'Di=Dj=0'};
    1231 end
    1232 val=get(handles.ListPairCiv2,'Value');
    1233 ichoice=find(select,1);
    1234 if (isempty(ichoice) || ichoice < 1); ichoice=1; end;
    1235 if get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0
    1236     val=ichoice;% first valid pair proposed by default in the menu
    1237 end
    1238 if val>length(displ_pair')
    1239     set(handles.ListPairCiv2,'Value',1);% first valid pair proposed by default in the menu
    1240 else
    1241     set(handles.ListPairCiv2,'Value',val);
    1242 end
    1243 set(handles.ListPairCiv2,'String',displ_pair');
    1244 set(gcf,'Pointer','arrow')
    1245 
    1246 
    1247 
    1248 
    1249 %------------------------------------------------------------------------
    1250 % --- Executes on selection change in ListPairCiv1.
    1251 function ListPairCiv1_Callback(hObject, eventdata, handles)
    1252 %------------------------------------------------------------------------
    1253 %reproduce by default the chosen pair in the checkciv2 menu
    1254 list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs
    1255 index_pair=get(handles.ListPairCiv1,'Value');
    1256 displ_num=get(handles.ListPairCiv1,'UserData');
    1257 % num_a=displ_num(1,index_pair);
    1258 % num_b=displ_num(2,index_pair);
    1259 list_pair2=get(handles.ListPairCiv2,'String');%get the menu of image pairs
    1260 if index_pair<=length(list_pair2)
    1261     set(handles.ListPairCiv2,'Value',index_pair);
    1262 end
    1263 
    1264 %update first_i and last_i according to the chosen image pairs
    1265 mode_list=get(handles.ListPairMode,'String');
    1266 mode_value=get(handles.ListPairMode,'Value');
    1267 mode=mode_list{mode_value};
    1268 if isequal(mode,'series(Di)')
    1269     first_i=str2double(get(handles.first_i,'String'));
    1270     last_i=str2double(get(handles.last_i,'String'));
    1271     incr_i=str2double(get(handles.incr_i,'String'));
    1272     num1=first_i:incr_i:last_i;
    1273     lastfield=str2double(get(handles.nb_field,'String'));
    1274     if ~isnan(lastfield)
    1275         test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ...
    1276             (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield);
    1277         num1=num1(test_find);
    1278     end
    1279     set(handles.first_i,'String',num2str(num1(1)));
    1280     set(handles.last_i,'String',num2str(num1(end)));
    1281 elseif isequal(mode,'series(Dj)')
    1282     first_j=str2double(get(handles.first_j,'String'));
    1283     last_j=str2double(get(handles.last_j,'String'));
    1284     incr_j=str2double(get(handles.incr_j,'String'));
    1285     num_j=first_j:incr_j:last_j;
    1286     lastfield2=str2double(get(handles.nb_field2,'String'));
    1287     if ~isnan(lastfield2)
    1288         test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
    1289             (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2);
    1290         num1=num_j(test_find);
    1291     end
    1292     set(handles.first_j,'String',num2str(num1(1)));
    1293     set(handles.last_j,'String',num2str(num1(end)));
    1294 end
    1295 
    1296 %------------------------------------------------------------------------
    1297 % --- Executes on selection change in ListPairCiv2.
    1298 function ListPairCiv2_Callback(hObject, eventdata, handles)
    1299 %------------------------------------------------------------------------
    1300 index_pair=get(handles.ListPairCiv2,'Value');%get the selected position index in the menu
    1301 
    1302 %update first_i and last_i according to the chosen image pairs
    1303 mode_list=get(handles.ListPairMode,'String');
    1304 mode_value=get(handles.ListPairMode,'Value');
    1305 mode=mode_list{mode_value};
    1306 if isequal(mode,'series(Di)')
    1307     first_i=str2double(get(handles.first_i,'String'));
    1308     last_i=str2double(get(handles.last_i,'String'));
    1309     incr_i=str2double(get(handles.incr_i,'String'));
    1310     num1=first_i:incr_i:last_i;
    1311     lastfield=str2double(get(handles.nb_field,'String'));
    1312     if ~isnan(lastfield)
    1313         test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ...
    1314             (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield);
    1315         num1=num1(test_find);
    1316     end
    1317     set(handles.first_i,'String',num2str(num1(1)));
    1318     set(handles.last_i,'String',num2str(num1(end)));
    1319 elseif isequal(mode,'series(Dj)')
    1320     first_j=str2double(get(handles.first_j,'String'));
    1321     last_j=str2double(get(handles.last_j,'String'));
    1322     incr_j=str2double(get(handles.incr_j,'String'));
    1323     num_j=first_j:incr_j:last_j;
    1324     lastfield2=str2double(get(handles.nb_field2,'String'));
    1325     if ~isnan(lastfield2)
    1326         test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
    1327             (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2);
    1328         num1=num_j(test_find);
    1329     end
    1330     set(handles.first_j,'String',num2str(num1(1)));
    1331     set(handles.last_j,'String',num2str(num1(end)));
     746        set(handles.(options{ilist}),'Visible','off')
     747    end
    1332748end
    1333749
     
    1372788end
    1373789
    1374 %------------------------------------------------------------------------
    1375 % --- Lauch command called by RUN and BATCH: remote processing
     790%-------------------------------------------------------------------
     791% --- Executes on button press in status.
     792function status_Callback(hObject, eventdata, handles)
     793%-------------------------------------------------------------------
     794val=get(handles.status,'Value');
     795if val==0
     796    set(handles.status,'BackgroundColor',[0 1 0])
     797    hfig=findobj(allchild(0),'name','civ_status');
     798    if ~isempty(hfig)
     799        delete(hfig)
     800    end
     801    return
     802end
     803set(handles.status,'BackgroundColor',[1 1 0])
     804drawnow
     805listtype={'civ1','fix1','patch1','civ2','fix2','patch2'};
     806Param.CheckCiv1=get(handles.CheckCiv1,'Value');
     807Param.CheckFix1=get(handles.CheckFix1,'Value');
     808Param.CheckPatch1=get(handles.CheckPatch1,'Value');
     809Param.CheckCiv2=get(handles.CheckCiv2,'Value');
     810Param.CheckFix2=get(handles.CheckFix2,'Value');
     811Param.CheckPatch2=get(handles.CheckPatch2,'Value');
     812box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2];
     813
     814option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test)
     815filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV
     816test_new=0;
     817if ~isfield(filecell,'nc')
     818    test_new=1;
     819    [ref_i,ref_j,errormsg]=find_ref_indices(handles);
     820    if ~isempty(errormsg)
     821        msgbox_uvmat('ERROR',errormsg)
     822        return
     823    end
     824    filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status
     825end
     826if ~isequal(box_test(4:6),[0 0 0])
     827    civ_files=filecell.nc.civ2;%case of civ2 operations
     828else
     829    civ_files=filecell.nc.civ1;
     830end
     831[root,filename,ext]=fileparts(civ_files{1});
     832[rootroot,subdir,extdir]=fileparts(root);
     833hfig=findobj(allchild(0),'name','civ_status');
     834if isempty(hfig)
     835    hfig=figure('DeleteFcn',@stop_status);
     836    set(hfig,'name','civ_status')
     837    hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list');
     838    uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...');
     839    uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
     840    uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','OK','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI);
     841    BarPosition=[0.05 0.81 0.01 0.05];
     842    hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');
     843    drawnow
     844end
     845% datnum=[];
     846Tabchar={};
     847nbfiles=numel(civ_files);
     848count=0;
     849testrecent=0;
     850while count<nbfiles
     851    count=0;
     852    datnum=zeros(1,nbfiles);
     853    for ifile=1:nbfiles
     854        detect=exist(civ_files{ifile},'file'); % check the existence of the file
     855        option=0;
     856        if detect==0
     857            option_str='not created';
     858        else
     859            datfile=dir(civ_files{ifile});
     860            if isfield(datfile,'datenum')
     861                datnum(ifile)=datfile.datenum;%only available in recent matlab versions
     862                testrecent=1;
     863            end
     864            filefound(ifile)={datfile.name};
     865            lastfield='';
     866            % check the content  netcdf file
     867            Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix');
     868            if ~isempty(Data.patch2) && isequal(Data.patch2,1)
     869                option=6;
     870                option_str='patch2';
     871            elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
     872                option=5;
     873                option_str='fix2';
     874            elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
     875                option=4;
     876                option_str='civ2';
     877            elseif ~isempty(Data.patch) && isequal(Data.patch,1);
     878                option=3;
     879                option_str='patch1';
     880            elseif ~isempty(Data.fix) && isequal(Data.fix,1);
     881                option=2;
     882                option_str='fix1';
     883            else
     884                option=1;
     885                option_str='civ1';
     886            end
     887        end
     888        if option >= option_civ
     889            count=count+1;
     890        end
     891        [rr,filename,ext]=fileparts(civ_files{ifile});
     892        Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext  '...' option_str];
     893    end
     894    datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
     895    if isempty(datnum)
     896        if testrecent
     897            message='no civ result created yet';
     898        else
     899            message='';
     900        end
     901    else
     902        datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
     903        [first,ind]=min(datnum);
     904        [last,indlast]=max(datnum);
     905        if test_new
     906            message='existing file status, no processing launched yet';
     907        else
     908        message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
     909            ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
     910        end
     911    end
     912    hfig=findobj(allchild(0),'name','civ_status');
     913    if isempty(hfig)% the status list has been deleted
     914        return
     915    else
     916        hlist=findobj(hfig,'tag','list');
     917        hmsgbox=findobj(hfig,'tag','msgbox');
     918        hwaitbar=findobj(hfig,'tag','waitbar');
     919        set(hlist,'String',Tabchar)
     920        set(hmsgbox,'String', message)
     921        if count>0 && ~test_new
     922            BarPosition(3)=0.9*count/nbfiles;
     923            set(hwaitbar,'Position',BarPosition)
     924        end
     925    end
     926    set(hlist,'UserData',rootroot)
     927    pause(10)% wait 10 seconds for next check
     928end
     929
     930%------------------------------------------------------------------------
     931% --- Main lauch command, called by RUN and BATCH
    1376932function errormsg=launch_jobs(hObject, eventdata, handles, batch)
    1377933%-----------------------------------------------------------------------
    1378934errormsg='';%default
    1379 
    1380 %%read the civ GUI
     935%% read the civ GUI
    1381936Param=read_GUI(handles.civ);
     937
    1382938%% check the selected list of operations:
    1383939operations={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'};
     
    14581014    return
    14591015end
    1460 
    14611016test_interp=0; %eviter les variables test_ (LG)
    1462 
    14631017if batch
    14641018    if isfield(s,'BatchParam')
     
    15001054
    15011055%% check if the binaries exist
    1502 if isequal(get(handles.Matlab,'checked'),'on')
     1056if isequal(get(handles.MenuMatlab,'checked'),'on')
    15031057    CivMode='Matlab';
    15041058else
     
    15131067    case 'Matlab'
    15141068        if batch
    1515             % vérifier Matlab installé sur le cluster
     1069            % vérifier MenuMatlab installé sur le cluster
    15161070            % difficile a faire a priori
    15171071        end         
    15181072end
    1519 for bin_name=binary_list
    1520     if isfield(Param.xml,bin_name{1})
     1073for bin_name=binary_list %loop on the list of binaries
     1074    if isfield(Param.xml,bin_name{1})% bin_name{1} =current name in the list
    15211075        if ~exist(Param.xml.(bin_name{1}),'file')%look for the full path if the file name has been defined with a relative path in PARAM.xml
    15221076            fullname=fullfile(path_civ,Param.xml.(bin_name{1}));
     
    15331087            binpath=pwd;%path of the binary
    15341088            Param.xml.(bin_name{1})=fullfile(binpath,[name ext]);
    1535             %                      display(Param.xml.(bin_name{1}));
    15361089            cd(currentdir);
    15371090        end
     
    15391092    end
    15401093end
    1541 
    15421094display('files OK, processing...')
    15431095
     
    15451097%% MAIN LOOP
    15461098time=get(handles.ImaDoc,'UserData'); %get the set of times
    1547 
    15481099super_cmd=[];
    15491100batch_file_list=[];
    1550     
     1101 
    15511102for ifile=1:nbfield
    15521103    for j=1:nbslice
     
    15771128        end
    15781129        OutputFile=regexprep(OutputFile,'.nc','');
    1579 
     1130       
    15801131        if Param.CheckCiv1
    15811132            % read image-dependent parameters
    15821133            Param.Civ1.filename_ima_a=filecell.ima1.civ1{ifile,j};
    15831134            Param.Civ1.filename_ima_b=filecell.ima2.civ1{ifile,j};
    1584             if size(time,1)>=num2_civ1(ifile) && size(time,1)>=num_b_civ1(ifile)
     1135            if size(time,1)>=num2_civ1(ifile) && size(time,2)>=num_b_civ1(ifile)
    15851136                Param.Civ1.Dt=(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j)));
    15861137                Param.Civ1.T0=((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2);
     
    15921143            Param.Civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);%
    15931144            Param.Civ1.pxcmx=1; %velocities are expressed in pixel dispalcement
    1594             Param.Civ1.pxcmy=1;
    1595 
    1596             A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size
    1597             sizim=size(A);
    1598             Param.Civ1.npx=(sizim(2));
    1599             Param.Civ1.npy=(sizim(1));
     1145            Param.Civ1.pxcmy=1;     
     1146            Param.Civ1.ImageInfo=imfinfo(filecell.ima1.civ1{1,1});%read the first image to get the size
     1147           
    16001148            %TODO : civ should not need npx and npy
    1601 
     1149           
    16021150            % read mask parameters
    16031151            if Param.Civ1.CheckMask % the lines below should be changed with the new gui
     
    16631211       
    16641212        if Param.CheckFix1
    1665            switch CivMode
     1213            switch CivMode
    16661214                case 'CivX'
    16671215                    cmd=[cmd...
     
    17371285        if Param.CheckCiv2==1
    17381286            Param.Civ2.filename_ima_a=filecell.ima1.civ2{ifile,j};
    1739             Param.Civ2.filename_ima_b=filecell.ima2.civ2{ifile,j};   
    1740             if size(time,1)>=num2_civ1(ifile) && size(time,1)>=num_b_civ1(ifile)
     1287            Param.Civ2.filename_ima_b=filecell.ima2.civ2{ifile,j};
     1288            if size(time,1)>=num2_civ2(ifile) && size(time,2)>=num_b_civ2(ifile)
    17411289                Param.Civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j)));
    1742                 Param.Civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2);
     1290                Param.Civ2.T0=num2str((time(num2_civ2(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2);
    17431291            else
    17441292                Param.Civ2.Dt=1;
    17451293                Param.Civ2.T0=0;
    1746             end         
     1294            end
    17471295            Param.Civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc);
    17481296            Param.Civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc);
     
    17951343                Param.Civ2.GridFlag='n';
    17961344            end
    1797             A=imread(filecell.ima1.civ2{1,1});%read the first image to get the size
    1798             sizim=size(A);
    1799             Param.Civ2.npx=(sizim(2));
    1800             Param.Civ2.npy=(sizim(1));
    1801                 
     1345%             A=imread(filecell.ima1.civ2{1,1});%read the first image to get the size
     1346%             sizim=size(A);
     1347            Param.Civ2.ImageInfo=imfinfo(filecell.ima1.civ1{1,1});%read the first image to get the size
     1348%             Param.Civ2.npx=(sizim(2));
     1349%             Param.Civ2.npy=(sizim(1));     
    18021350            switch CivMode
    18031351                case 'CivX'
    1804                      cmd=[cmd...
     1352                    cmd=[cmd...
    18051353                        cmd_civ2(filecell.nc.civ2{ifile,j},Param) '\n'];
    18061354                case 'CivAll'
     
    18931441            end
    18941442        end
    1895  
     1443        
    18961444        switch CivMode
    18971445            case {'CivX','CivAll'}
     
    19171465                batch_file_list{length(batch_file_list)+1}=filename_bat;
    19181466               
    1919 %                 if batch
    1920 %                     switch batch_mode
    1921 %                         case 'sge'                           
    1922 %                             display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]);
    1923 %                             eval(  ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]);
    1924 %                         case 'oar'
    1925 % %                             eval(  ['!chmod +x ' filename_bat]);
    1926 % %                             %eval(  ['!oarsub -n CIVX -l /core=1,walltime=00:10:00  ' filename_bat]);                   
    1927 % %                             eval(  ['!oarsub -n CIVX -l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:10:00"   ' filename_bat]);
    1928 %
    1929 %                     cmd_str=['sh ' filename_bat];
    1930 %                     super_cmd{length(super_cmd)+1}=cmd_str;
    1931 %                           
    1932 %                     end
    1933 %                 else
    1934 %                     %% to lauch the jobs locally :
    1935 %                     if(isunix)
    1936 %                         cmd_str=['. ' filename_bat];
    1937 %                     else %case of Windows
    1938 %                         cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"'];
    1939 %                     end
    1940 %                     super_cmd=[super_cmd cmd_str '\n'];
    1941 %                     disp(cmd_str);
    1942 %                 end
    19431467            case 'Matlab'
    19441468                drawnow
    1945                 if Param.CheckCiv1==1
    1946                     Param.Civ1=Param.Civ1;
    1947                 end
    1948                 if Param.CheckFix1==1
    1949                     fix1.WarnFlags=[];
    1950                     if get(handles.CheckFmin2,'Value')
    1951                         fix1.WarnFlags=[fix1.WarnFlags -2];
    1952                     end
    1953                     if get(handles.CheckF3,'Value')
    1954                         fix1.WarnFlags=[fix1.WarnFlags 3];
    1955                     end
    1956                     fix1.LowerBoundCorr=thresh_vecC1;
    1957                     if get(handles.num_MinVel,'Value')
    1958                         fix1.UppperBoundVel=thresh_vel1;
    1959                     else
    1960                         fix1.LowerBoundVel=thresh_vel1;
    1961                     end
    1962                     if get(handles.CheckMask,'Value')
    1963                         fix1.MaskName=maskname;
    1964                     end
    1965                     Param.Fix1=fix1;
    1966                 end
    1967                 if Param.CheckPatch1==1
    1968                     if strcmp(compare,'stereo PIV')
    1969                         filebase_A=filecell.filebase;
    1970                         [pp,ff]=fileparts(filebase_A);
    1971                         filebase_B=fullfile(pp,get(handles.RootName_1,'String'));
    1972                         RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},...
    1973                             str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml'])
    1974                     else
    1975                         Param.Patch1.Rho=rho_patch1;
    1976                         Param.Patch1.Threshold=thresh_patch1;
    1977                         Param.Patch1.SubDomain=subdomain_patch1;
    1978                     end
    1979                 end
    1980                 if Param.CheckCiv2==1
    1981                     Param.Civ2=Param.Civ2;
    1982                 end
    1983                 if Param.CheckFix2==1
    1984                     fix2.WarnFlags=[];
    1985                     if get(handles.CheckFmin2,'Value')
    1986                         fix2.WarnFlags=[fix2.WarnFlags -2];
    1987                     end
    1988                     if get(handles.CheckF4,'Value')
    1989                         fix2.WarnFlags=[fix2.WarnFlags 4];
    1990                     end
    1991                     if get(handles.CheckF3,'Value')
    1992                         fix2.WarnFlags=[fix2.WarnFlags 3];
    1993                     end
    1994                     fix2.LowerBoundCorr=thresh_vec2C;
    1995                     if get(handles.num_MinVel,'Value')
    1996                         fix2.UppperBoundVel=thresh_vel2;
    1997                     else
    1998                         fix2.LowerBoundVel=thresh_vel2;
    1999                     end
    2000                     if get(handles.CheckMask,'Value')
    2001                         fix2.MaskName=maskname;
    2002                     end
    2003                     Param.Fix2=fix2;
    2004                 end
    2005                 if Param.CheckPatch2==1
    2006                     if strcmp(compare,'stereo PIV')
    2007                         filebase_A=filecell.filebase;
    2008                         [pp,ff]=fileparts(filebase_A);
    2009                         filebase_B=fullfile(pp,get(handles.RootName_1,'String'));
    2010                         RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},...
    2011                             str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml'])
    2012                     else
    2013                         Param.Patch2.Rho=rho_patch2;
    2014                         Param.Patch2.Threshold=thresh_patch2;
    2015                         Param.Patch2.SubDomain=subdomain_patch2;
    2016                     end
    2017                 end
    20181469                if ~strcmp(compare,'stereo PIV')
    2019                     [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j});
     1470                    [Data,erromsg]=civ_matlab(Param,filecell.nc.civ1{ifile,j});
    20201471                    if isempty(errormsg)
    20211472                        display([filecell.nc.civ1{ifile,j} ' written'])
    20221473                    else
    20231474                        msgbox_uvmat('ERROR',errormsg)
    2024                     end
    2025 
     1475                    end                 
    20261476                end
    20271477        end
     
    21131563                eval(['!chmod +x  ' filename_oarscript]);
    21141564                eval(['!oarsub -S ' filename_oarscript]);
    2115 
    2116                
    2117                
    2118 
    2119                
    21201565        case 'oar_new' % to be develloped with Patrick Begou
    21211566                filename_joblist=fullfile(Rootbat,'job_list.txt');
     
    21991644    save (profil_perso,'MenuFile')
    22001645end
    2201 
    22021646
    22031647%------------------------------------------------------------------------
     
    30622506end
    30632507
    3064 
    3065 %------------------------------------------------------------------------
    3066 % --- STEREO Interp
    3067 function cmd=RUN_STINTERP(stinterpBin,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB)
    3068 %------------------------------------------------------------------------
    3069 namelog=[filename_nc(1:end-3) '_stinterp.log'];
    3070 cmd=[stinterpBin ' -f1 ' filename_A_nc  ' -f2 ' filename_B_nc ' -f  ' filename_nc ...
    3071     ' -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
    3072 
    3073 %------------------------------------------------------------------------
    3074 % --- Executes on button press in CheckCiv1.
    3075 function CheckCiv1_Callback(hObject, eventdata, handles)
    3076 %------------------------------------------------------------------------
    3077 update_CivOptions(handles)
    3078 
    3079 %------------------------------------------------------------------------
    3080 % --- Executes on button press in CheckFix1.
    3081 function CheckFix1_Callback(hObject, eventdata, handles)
    3082 %------------------------------------------------------------------------
    3083 update_CivOptions(handles)
    3084 
    3085 %------------------------------------------------------------------------
    3086 % --- Executes on button press in CheckPatch1.
    3087 function CheckPatch1_Callback(hObject, eventdata, handles)
    3088 %------------------------------------------------------------------------
    3089 update_CivOptions(handles)
    3090 
    3091 %------------------------------------------------------------------------
    3092 % --- Executes on button press in CheckCiv2.
    3093 function CheckCiv2_Callback(hObject, eventdata, handles)
    3094 %------------------------------------------------------------------------
    3095 update_CivOptions(handles)
    3096 
    3097 %------------------------------------------------------------------------
    3098 % --- Executes on button press in CheckFix2.
    3099 function CheckFix2_Callback(hObject, eventdata, handles)
    3100 %------------------------------------------------------------------------
    3101 update_CivOptions(handles)
    3102 
    3103 %------------------------------------------------------------------------
    3104 % --- Executes on button press in CheckPatch2.
    3105 function CheckPatch2_Callback(hObject, eventdata, handles)
    3106 %------------------------------------------------------------------------
    3107 update_CivOptions(handles)
    3108 
    3109 %------------------------------------------------------------------------
    3110 % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2
    3111 function update_CivOptions(handles)
    3112 %------------------------------------------------------------------------
    3113 checkbox=zeros(1,6);
    3114 checkbox(1)=get(handles.CheckCiv1,'Value');
    3115 checkbox(2)=get(handles.CheckFix1,'Value');
    3116 checkbox(3)=get(handles.CheckPatch1,'Value');
    3117 checkbox(4)=get(handles.CheckCiv2,'Value');
    3118 checkbox(5)=get(handles.CheckFix2,'Value');
    3119 checkbox(6)=get(handles.CheckPatch2,'Value');
    3120 ind_selected=find(checkbox,1);
    3121 if ~isempty(ind_selected)
    3122   RootName=get(handles.RootName,'String');
    3123     if isempty(RootName)
    3124          msgbox_uvmat('ERROR','No input file')
     2508%------------------------------------------------------------------------
     2509% --- Executes on button press in ListCompareMode.
     2510function ListCompareMode_Callback(hObject, eventdata, handles)
     2511%------------------------------------------------------------------------
     2512test=get(handles.ListCompareMode,'Value');
     2513if test==2 || test==3 % case 'dispalcemen' or 'stereo PIV'
     2514    filebase=get(handles.RootName,'String');
     2515    browse=get(handlesRootName,'Userdata');
     2516    browse.nom_type_ima1=browse.nom_type_ima;
     2517    set(handlesRootName,'UserData',browse);
     2518    set(handles.sub_txt,'Visible','on')
     2519    set(handles.RootName_1,'Visible','On');%mkes the second file input window visible
     2520    mode_store=get(handles.ListPairMode,'String');%get the present 'mode'
     2521    set(handles.ListCompareMode,'UserData',mode_store);%store the mode display
     2522    set(handles.ListPairMode,'Visible','off')
     2523    if test==2
     2524        set(handles.ListPairMode,'Visible','off')
     2525        set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default
     2526    else
     2527        set(handles.ListPairMode,'Visible','on')
     2528        set(handles.ListPairMode,'Value',3) % mode 'Matlab' selected for stereo
     2529    end
     2530   
     2531    %% menuopen an image file with the browser
     2532    ind_opening=1;%default
     2533    browse.incr_pair=[0 0]; %default
     2534    oldfile=get(handles.RootName,'String');
     2535     menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)';
     2536       '*.xml',  '.xml files '; ...
     2537        '*.civ',  '.civ files '; ...
     2538        '*.png','.png image files'; ...
     2539        '*.jpg',' jpeg image files'; ...
     2540        '*.tif','.tif image files'; ...
     2541        '*.avi;*.AVI','.avi movie files'; ...
     2542        '*.nc','.netcdf files'; ...
     2543        '*.*',  'All Files (*.*)'};
     2544    [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile);
     2545    fileinput=[PathName FileName];%complete file name
     2546    sizf=size(fileinput);
     2547    if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
     2548    [path,name,ext]=fileparts(fileinput);
     2549    [path1]=fileparts(filebase);
     2550    if isunix
     2551        [status,path]=system(['readlink ' path]);
     2552        [status,path1]=system(['readlink ' path1]);% look for the true path in case of symbolic paths
     2553    end
     2554    if ~strcmp(path1,path)
     2555        msgbox_uvmat('ERROR','The second image series must be in the same directory as the first one')
    31252556        return
    3126     end
    3127 end
    3128 set(handles.PairIndices,'Visible','on')
    3129 set(handles.txt_SubdirCiv1,'Visible','on')
    3130 set(handles.ListSubdirCiv1,'Visible','on')
    3131 find_netcpair_civ1(handles) % select the available netcdf files
    3132 if max(checkbox(4:6))% case of civ2 pair choice needed
    3133     set(handles.TitlePairCiv2,'Visible','on')
    3134     set(handles.TitleSubdirCiv2,'Visible','on')
    3135     set(handles.txt_SubdirCiv2,'Visible','on')
    3136     set(handles.ListSubdirCiv2,'Visible','on')
    3137     set(handles.ListPairCiv2,'Visible','on')
    3138     find_netcpair_civ2(handles) % select the available netcdf files
    3139 else
    3140     set(handles.TitleSubdirCiv2,'Visible','off')
    3141     set(handles.txt_SubdirCiv2,'Visible','off')
    3142     set(handles.ListSubdirCiv2,'Visible','off')
    3143     set(handles.ListPairCiv2,'Visible','off')
    3144 end
    3145 options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'};
    3146 for ilist=1:length(options)
    3147     if checkbox(ilist)
    3148         set(handles.(options{ilist}),'Visible','on')
     2557     end
     2558%     set(handles.RootName_1,'String',name);
     2559    [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name);
     2560    set(handles.RootName_1,'String',RootFile);
     2561    browse=get(handlesRootName,'UserData');
     2562    browse.nom_type_ima_1=nom_type;
     2563    set(handlesRootName,'UserData',browse)
     2564   
     2565    %check image extension
     2566    if ~strcmp(ext,get(handles.ImaExt,'String'))
     2567        msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one')
     2568        return
     2569    end
     2570   
     2571    %% check coincidence of image sizes
     2572%     ref_i=get(handles.ref_i,'string');
     2573%     ref_j=get(handles.ref_j,'string');
     2574%     [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]);
     2575%     A=imread(filecell.ima1.checkciv1{1});
     2576%     A_1=imread(fileinput);
     2577%     npxy=size(A);
     2578%     npxy_1=size(A_1);
     2579%     if ~isequal(size(A),size(A_1))
     2580%         msgbox_uvmat('ERROR','The two input image series do not have the same size')
     2581%         return
     2582%     end
     2583else
     2584    set(handles.ListPairMode,'Visible','on')
     2585    set(handles.RootName_1,'Visible','Off');
     2586    set(handles.sub_txt,'Visible','off')
     2587    set(handles.RootName_1,'String',[]);
     2588    mode_store=get(handles.ListCompareMode,'UserData');
     2589    set(handles.ListPairMode,'Value',1)
     2590    set(handles.ListPairMode,'String',mode_store)
     2591    set(handles.test_stereo1,'Value',0)
     2592    set(handles.CheckStereo,'Value',0)
     2593    set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default
     2594end
     2595if test==3 && get(handles.CheckPatch1,'Value')
     2596    set(handles.test_stereo1,'Visible','on')
     2597else
     2598    set(handles.test_stereo1,'Visible','off')
     2599end
     2600if test==3 && get(handles.CheckPatch2,'Value')
     2601    set(handles.CheckStereo,'Visible','on')
     2602else
     2603    set(handles.CheckStereo,'Visible','off')
     2604end
     2605mode_Callback(hObject, eventdata, handles)
     2606
     2607
     2608%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     2609% Callbacks in the uipanel Pair Indices
     2610%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     2611%------------------------------------------------------------------------
     2612% --- Executes on button press in ListPairMode.
     2613function ListPairMode_Callback(hObject, eventdata, handles)
     2614%------------------------------------------------------------------------
     2615compare_list=get(handles.ListCompareMode,'String');
     2616val=get(handles.ListCompareMode,'Value');
     2617compare=compare_list{val};
     2618if strcmp(compare,'displacement')
     2619    mode='displacement';
     2620else
     2621    mode_list=get(handles.ListPairMode,'String');
     2622    if ischar(mode_list)
     2623        mode_list={mode_list};
     2624    end
     2625    mode_value=get(handles.ListPairMode,'Value');
     2626    mode=mode_list{mode_value};
     2627end
     2628displ_num=[];%default
     2629ref_i=str2double(get(handles.ref_i,'String'));
     2630% last_i=str2num(get(handles.last_i,'String'));
     2631time=get(handles.ImaDoc,'UserData'); %get the set of times
     2632siztime=size(time);
     2633nbfield=siztime(1);
     2634nbfield2=siztime(2);
     2635indchosen=1;  %%first pair selected by default
     2636%displ_num used to define the indices of the civ pairs
     2637% in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices
     2638% are relative to the reference indices ref_i and ref_j respectively.
     2639if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2')
     2640    dt=1;
     2641    displ='';
     2642    index=0;
     2643    numlist_a=[];
     2644    numlist_B=[];
     2645    %get all the time intervals in bursts
     2646    displ_dt=1;%default
     2647    nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10
     2648    for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode
     2649        for numod_b=(numod_a+1):nbfield2
     2650            index=index+1;
     2651            numlist_a(index)=numod_a;
     2652            numlist_b(index)=numod_b;
     2653            if ~isempty(time)
     2654                dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt
     2655                displ_dt(index)=dt(numod_a,numod_b);
     2656            else
     2657                displ_dt(index)=1;
     2658            end
     2659        end
     2660    end
     2661    [dtsort,indsort]=sort(displ_dt);
     2662    if ~isempty(numlist_a)
     2663        displ_num(1,:)=numlist_a(indsort);
     2664        displ_num(2,:)=numlist_b(indsort);
     2665    end
     2666    displ_num(3,:)=0;
     2667    displ_num(4,:)=0;
     2668    set(handles.jtext,'Visible','Off')
     2669    set(handles.first_j,'Visible','Off')
     2670    set(handles.last_j,'Visible','Off')
     2671    set(handles.incr_j,'Visible','Off')
     2672    set(handles.nb_field2,'Visible','Off')
     2673    set(handles.ref_j,'Visible','Off')
     2674elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)')
     2675    index=1:200;
     2676    displ_num(1,index)=-floor(index/2);
     2677    displ_num(2,index)=ceil(index/2);
     2678    displ_num(3:4,index)=zeros(2,200);
     2679%     for index=1:min(nbfield2-1,200)
     2680%         displ_num(1,index)=-floor(index/2);
     2681%         displ_num(2,index)=ceil(index/2);
     2682%         displ_num(3,index)=0;
     2683%         displ_num(4,index)=0;
     2684%     end
     2685    set(handles.jtext,'Visible','On')
     2686    set(handles.first_j,'Visible','On')
     2687    set(handles.last_j,'Visible','On')
     2688    set(handles.incr_j,'Visible','On')
     2689    set(handles.nb_field2,'Visible','On')
     2690    set(handles.ref_j,'Visible','On')
     2691    if nbfield > 1
     2692        set(handles.itext,'Visible','On')
     2693        set(handles.first_i,'Visible','On')
     2694        set(handles.last_i,'Visible','On')
     2695        set(handles.incr_i,'Visible','On')
     2696        set(handles.nb_field,'Visible','On')
     2697        set(handles.ref_i,'Visible','On')
    31492698    else
    3150         set(handles.(options{ilist}),'Visible','off')
    3151     end
    3152 end
    3153 
     2699        set(handles.itext,'Visible','Off')
     2700        set(handles.first_i,'Visible','Off')
     2701        set(handles.last_i,'Visible','Off')
     2702        set(handles.incr_i,'Visible','Off')
     2703        set(handles.nb_field,'Visible','Off')
     2704        set(handles.ref_i,'Visible','Off')
     2705    end
     2706elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)')
     2707    index=1:200;
     2708    displ_num(1:2,index)=zeros(2,200);
     2709    displ_num(3,index)=-floor(index/2);
     2710    displ_num(4,index)=ceil(index/2);
     2711%     for index=1:200%min(nbfield-1,200)
     2712%         displ_num(1,index)=0;
     2713%         displ_num(2,index)=0;
     2714%         displ_num(3,index)=-floor(index/2);
     2715%         displ_num(4,index)=ceil(index/2);
     2716%     end
     2717    set(handles.itext,'Visible','On')
     2718    set(handles.first_i,'Visible','On')
     2719    set(handles.last_i,'Visible','On')
     2720    set(handles.incr_i,'Visible','On')
     2721    set(handles.nb_field,'Visible','On')
     2722    set(handles.ref_i,'Visible','On')
     2723    if nbfield2 > 1
     2724        set(handles.jtext,'Visible','On')
     2725        set(handles.first_j,'Visible','On')
     2726        set(handles.last_j,'Visible','On')
     2727        set(handles.incr_j,'Visible','On')
     2728        set(handles.nb_field2,'Visible','On')
     2729        set(handles.ref_j,'Visible','On')
     2730    else
     2731        set(handles.jtext,'Visible','Off')
     2732        set(handles.first_j,'Visible','Off')
     2733        set(handles.last_j,'Visible','Off')
     2734        set(handles.incr_j,'Visible','Off')
     2735        set(handles.nb_field2,'Visible','Off')
     2736        set(handles.ref_j,'Visible','Off')
     2737    end
     2738elseif isequal(mode,'displacement')%the pairs have the same indices
     2739    displ_num(1,1)=0;
     2740    displ_num(2,1)=0;
     2741    displ_num(3,1)=0;
     2742    displ_num(4,1)=0;
     2743    if nbfield > 1
     2744        set(handles.itext,'Visible','On')
     2745        set(handles.first_i,'Visible','On')
     2746        set(handles.last_i,'Visible','On')
     2747        set(handles.incr_i,'Visible','On')
     2748        set(handles.nb_field,'Visible','On')
     2749        set(handles.ref_i,'Visible','On')
     2750    else
     2751        set(handles.itext,'Visible','Off')
     2752        set(handles.first_i,'Visible','Off')
     2753        set(handles.last_i,'Visible','Off')
     2754        set(handles.incr_i,'Visible','Off')
     2755        set(handles.nb_field,'Visible','Off')
     2756        set(handles.ref_i,'Visible','Off')
     2757    end
     2758    if nbfield2 > 1
     2759        set(handles.jtext,'Visible','On')
     2760        set(handles.first_j,'Visible','On')
     2761        set(handles.last_j,'Visible','On')
     2762        set(handles.incr_j,'Visible','On')
     2763        set(handles.nb_field2,'Visible','On')
     2764        set(handles.ref_j,'Visible','On')
     2765    else
     2766        set(handles.jtext,'Visible','Off')
     2767        set(handles.first_j,'Visible','Off')
     2768        set(handles.last_j,'Visible','Off')
     2769        set(handles.incr_j,'Visible','Off')
     2770        set(handles.nb_field2,'Visible','Off')
     2771        set(handles.ref_j,'Visible','Off')
     2772    end
     2773end
     2774set(handles.ListPairCiv1,'UserData',displ_num);
     2775find_netcpair_civ1( handles)
     2776find_netcpair_civ2(handles)
     2777
     2778%------------------------------------------------------------------------
     2779% --- Executes on selection change in ListPairCiv1.
     2780function ListPairCiv1_Callback(hObject, eventdata, handles)
     2781%------------------------------------------------------------------------
     2782%reproduce by default the chosen pair in the checkciv2 menu
     2783list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs
     2784index_pair=get(handles.ListPairCiv1,'Value');
     2785displ_num=get(handles.ListPairCiv1,'UserData');
     2786% num_a=displ_num(1,index_pair);
     2787% num_b=displ_num(2,index_pair);
     2788list_pair2=get(handles.ListPairCiv2,'String');%get the menu of image pairs
     2789if index_pair<=length(list_pair2)
     2790    set(handles.ListPairCiv2,'Value',index_pair);
     2791end
     2792
     2793%update first_i and last_i according to the chosen image pairs
     2794mode_list=get(handles.ListPairMode,'String');
     2795mode_value=get(handles.ListPairMode,'Value');
     2796mode=mode_list{mode_value};
     2797if isequal(mode,'series(Di)')
     2798    first_i=str2double(get(handles.first_i,'String'));
     2799    last_i=str2double(get(handles.last_i,'String'));
     2800    incr_i=str2double(get(handles.incr_i,'String'));
     2801    num1=first_i:incr_i:last_i;
     2802    lastfield=str2double(get(handles.nb_field,'String'));
     2803    if ~isnan(lastfield)
     2804        test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ...
     2805            (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield);
     2806        num1=num1(test_find);
     2807    end
     2808    set(handles.first_i,'String',num2str(num1(1)));
     2809    set(handles.last_i,'String',num2str(num1(end)));
     2810elseif isequal(mode,'series(Dj)')
     2811    first_j=str2double(get(handles.first_j,'String'));
     2812    last_j=str2double(get(handles.last_j,'String'));
     2813    incr_j=str2double(get(handles.incr_j,'String'));
     2814    num_j=first_j:incr_j:last_j;
     2815    lastfield2=str2double(get(handles.nb_field2,'String'));
     2816    if ~isnan(lastfield2)
     2817        test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
     2818            (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2);
     2819        num1=num_j(test_find);
     2820    end
     2821    set(handles.first_j,'String',num2str(num1(1)));
     2822    set(handles.last_j,'String',num2str(num1(end)));
     2823end
     2824
     2825%------------------------------------------------------------------------
     2826% --- Executes on selection change in ListPairCiv2.
     2827function ListPairCiv2_Callback(hObject, eventdata, handles)
     2828%------------------------------------------------------------------------
     2829index_pair=get(handles.ListPairCiv2,'Value');%get the selected position index in the menu
     2830
     2831%update first_i and last_i according to the chosen image pairs
     2832mode_list=get(handles.ListPairMode,'String');
     2833mode_value=get(handles.ListPairMode,'Value');
     2834mode=mode_list{mode_value};
     2835if isequal(mode,'series(Di)')
     2836    first_i=str2double(get(handles.first_i,'String'));
     2837    last_i=str2double(get(handles.last_i,'String'));
     2838    incr_i=str2double(get(handles.incr_i,'String'));
     2839    num1=first_i:incr_i:last_i;
     2840    lastfield=str2double(get(handles.nb_field,'String'));
     2841    if ~isnan(lastfield)
     2842        test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ...
     2843            (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield);
     2844        num1=num1(test_find);
     2845    end
     2846    set(handles.first_i,'String',num2str(num1(1)));
     2847    set(handles.last_i,'String',num2str(num1(end)));
     2848elseif isequal(mode,'series(Dj)')
     2849    first_j=str2double(get(handles.first_j,'String'));
     2850    last_j=str2double(get(handles.last_j,'String'));
     2851    incr_j=str2double(get(handles.incr_j,'String'));
     2852    num_j=first_j:incr_j:last_j;
     2853    lastfield2=str2double(get(handles.nb_field2,'String'));
     2854    if ~isnan(lastfield2)
     2855        test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
     2856            (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2);
     2857        num1=num_j(test_find);
     2858    end
     2859    set(handles.first_j,'String',num2str(num1(1)));
     2860    set(handles.last_j,'String',num2str(num1(end)));
     2861end
     2862
     2863%------------------------------------------------------------------------
     2864function ref_i_Callback(hObject, eventdata, handles)
     2865%------------------------------------------------------------------------
     2866mode_list=get(handles.ListPairMode,'String');
     2867mode_value=get(handles.ListPairMode,'Value');
     2868mode=mode_list{mode_value};
     2869find_netcpair_civ1(handles);% update the menu of pairs depending on the available netcdf files
     2870if isequal(mode,'series(Di)') || ...% we do patch2 only
     2871        (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0)
     2872    find_netcpair_civ2( handles);
     2873end
     2874
     2875%------------------------------------------------------------------------
     2876function ref_j_Callback(hObject, eventdata, handles)
     2877%------------------------------------------------------------------------
     2878mode_list=get(handles.ListPairMode,'String');
     2879mode_value=get(handles.ListPairMode,'Value');
     2880mode=mode_list{mode_value};
     2881if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)')
     2882    find_netcpair_civ1(handles);% update the menu of pairs depending on the available netcdf files
     2883end
     2884if isequal(mode,'series(Dj)') || ...
     2885        (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0)
     2886    find_netcpair_civ2(handles);
     2887end
     2888%
     2889%------------------------------------------------------------------------
     2890% determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of
     2891% the field series set by first_i, incr, last_i
     2892function find_netcpair_civ1(handles)
     2893%------------------------------------------------------------------------
     2894set(gcf,'Pointer','watch')
     2895%nomenclature types
     2896filebase=get(handles.RootName,'String');
     2897[filepath,Nme,ext_dir]=fileparts(filebase);
     2898browse=get(handles.RootName,'UserData');
     2899compare_list=get(handles.ListCompareMode,'String');
     2900val=get(handles.ListCompareMode,'Value');
     2901compare=compare_list{val};
     2902if strcmp(compare,'displacement')
     2903    mode='displacement';
     2904else
     2905    mode_list=get(handles.ListPairMode,'String');
     2906    mode_value=get(handles.ListPairMode,'Value');
     2907    if isempty(mode_list)
     2908        return
     2909    end
     2910    mode=mode_list{mode_value};
     2911end
     2912
     2913% nomenclature type of the .nc files
     2914nom_type_ima=[];%default
     2915if isfield(browse,'nom_type_ima')
     2916    nom_type_ima=browse.nom_type_ima;
     2917end
     2918
     2919%determine nom_type_nc:
     2920nom_type_nc=[];%default
     2921if isfield(browse,'nom_type_nc')
     2922    nom_type_nc=browse.nom_type_nc;
     2923end
     2924if isempty(nom_type_nc)
     2925    [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)'));
     2926end
     2927browse.nom_type_nc=nom_type_nc;
     2928set(handles.RootName,'UserData',browse)
     2929
     2930%reads .nc subdirectoy and image numbers from the interface
     2931subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data
     2932ref_i=str2double(get(handles.ref_i,'String'));
     2933if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')
     2934    ref_j=0;
     2935else
     2936    ref_j=str2double(get(handles.ref_j,'String'));
     2937end
     2938time=get(handles.ImaDoc,'UserData');%get the set of times
     2939if isempty(time)
     2940    time=[0 1];
     2941end
     2942dt_unit=1000;%default
     2943displ_num=get(handles.ListPairCiv1,'UserData');
     2944
     2945%eliminate the first pairs inconsistent with the position
     2946if isempty(displ_num)
     2947    nbpair=0;
     2948else
     2949    nbpair=length(displ_num(1,:));%nbre of displayed pairs
     2950    if  isequal(mode,'series(Di)')  %| isequal(mode,'st_series(Di)')
     2951        nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index
     2952    elseif  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
     2953        nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index
     2954    end
     2955end
     2956nbpair=min(200,nbpair);%limit the number of displayed pairs to 200
     2957
     2958%look for existing processed pairs involving the field at the middle of the series if checkciv1 will not
     2959% be performed, while the result is needed for next steps.
     2960displ_pair={''};
     2961select=ones(size(1:nbpair));%flag for displayed pairs =1 for display
     2962testpair=0;
     2963
     2964%% case with no Civ1 operation, netcdf files need to exist for reading
     2965if ~get(handles.CheckCiv1,'Value') %
     2966    if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir')
     2967        msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']);
     2968        set(handles.ListPairCiv1,'String',{});
     2969        return
     2970    end
     2971    for ipair=1:nbpair
     2972        filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
     2973            ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
     2974        select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist
     2975    end   
     2976    % case of no displayed pair
     2977    if isequal(select,zeros(size(1:nbpair)))
     2978        if isfield(browse,'incr_pair') && ~isequal(browse.incr_pair,[0 0])
     2979            num_i1=ref_i-floor(browse.incr_pair(1)/2);
     2980            num_i2=ref_i+ceil(browse.incr_pair(1)/2);
     2981            num_j1=ref_j-floor(browse.incr_pair(2)/2);
     2982            num_j2=ref_j+ceil(browse.incr_pair(2)/2);
     2983            filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1);
     2984            select(1)=exist(filename,'file')==2;
     2985            testpair=1;
     2986        else
     2987            if  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
     2988                msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]);
     2989            else
     2990                msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]);
     2991            end
     2992            set(handles.ListPairCiv1,'String',{''});
     2993            %COMPLETER CAS STEREO
     2994            return
     2995        end
     2996    end
     2997end
     2998
     2999%% determine the menu display in .ListPairCiv1
     3000% the menu depends on the mode defined in ListPairMode_callback through the array displ_num:
     3001% displ_num(1,:)=indices j1
     3002% displ_num(2,:)=indices j2
     3003% displ_num(3,:)=indices i1
     3004% displ_num(4,:)=indices i2
     3005% in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices
     3006% are relative to the reference indices ref_i and ref_j respectively.
     3007if isequal(mode,'series(Di)')
     3008    if testpair
     3009        displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))];
     3010    else
     3011        for ipair=1:nbpair
     3012            if select(ipair)
     3013                displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))];
     3014                if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
     3015                    dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
     3016                    displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
     3017                end
     3018            else
     3019                displ_pair{ipair}='...'; %pair not displayed in the menu
     3020            end
     3021        end
     3022    end
     3023elseif isequal(mode,'series(Dj)')
     3024    if testpair
     3025        displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))];
     3026    else
     3027        for ipair=1:nbpair
     3028            if select(ipair)
     3029                displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))];
     3030                if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
     3031                    dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
     3032                    displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
     3033                end
     3034            else
     3035                displ_pair{ipair}='...'; %pair not displayed in the menu
     3036            end
     3037        end
     3038    end
     3039elseif isequal(mode,'pair j1-j2')%case of pairs
     3040    for ipair=1:nbpair
     3041        if select(ipair)
     3042            dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt
     3043            displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ...
     3044                ' :dt= ' num2str(dt*1000)];
     3045        else
     3046            displ_pair{ipair}='...'; %pair not displayed in the menu
     3047        end
     3048    end
     3049elseif isequal(mode,'displacement')
     3050    displ_pair={'Di=Dj=0'};
     3051end
     3052set(handles.ListPairCiv1,'String',displ_pair');
     3053
     3054%% determine the default selection in the pair menu
     3055ichoice=find(select,1);% index of selected pair
     3056if (isempty(ichoice) || ichoice < 1); ichoice=1; end;
     3057initial=get(handles.ListPairCiv1,'Value');%initial choice of pair
     3058if initial>nbpair || (numel(select)>=initial && ~isequal(select(initial),1))
     3059    set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu
     3060end
     3061initial=get(handles.ListPairCiv2,'Value');
     3062if initial>length(displ_pair')%|~isequal(select(initial),1)
     3063    if ichoice <= length(displ_pair')
     3064        set(handles.ListPairCiv2,'Value',ichoice);% same pair proposed by default for civ2
     3065    else
     3066        set(handles.ListPairCiv2,'Value',1);% same pair proposed by default for civ2
     3067    end
     3068end
     3069set(handles.ListPairCiv2,'String',displ_pair');
     3070set(gcf,'Pointer','arrow')
     3071
     3072%------------------------------------------------------------------------
     3073% determine the menu for checkciv2 pairs depending on the existing netcdf file at the
     3074%middle of the series set by first_i, incr, last_i
     3075function find_netcpair_civ2(handles)
     3076%------------------------------------------------------------------------
     3077set(gcf,'Pointer','watch')
     3078%nomenclature types
     3079filebase=get(handles.RootName,'String');
     3080[filepath,Nme,ext_dir]=fileparts(filebase);
     3081browse=get(handles.RootName,'UserData');
     3082compare_list=get(handles.ListCompareMode,'String');
     3083val=get(handles.ListCompareMode,'Value');
     3084compare=compare_list{val};
     3085if strcmp(compare,'displacement')
     3086    mode='displacement';
     3087else
     3088    mode_list=get(handles.ListPairMode,'String');
     3089    if isempty(mode_list)
     3090        msgbox_uvmat('ERROR','please enter an input image or netcdf file')
     3091        return
     3092    end
     3093    mode_value=get(handles.ListPairMode,'Value');
     3094    mode=mode_list{mode_value};
     3095end
     3096
     3097% nomenclature type of the .nc files
     3098nom_type_ima='ima_num';%default
     3099if isfield(browse,'nom_type_ima')
     3100    nom_type_ima=browse.nom_type_ima;
     3101end
     3102nom_type_nc='_i1-i2';%default
     3103if isfield(browse,'nom_type_nc')
     3104    nom_type_nc=browse.nom_type_nc;
     3105end
     3106if isequal(nom_type_ima,'png_old') || isequal(nom_type_ima,'netc_old')|| isequal(nom_type_ima,'raw_SMD')|| isequal(nom_type_nc,'netc_old')
     3107    nom_type_nc='netc_old';%nom_type for the netcdf files
     3108elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none')
     3109    nom_type_nc='none';
     3110elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2')
     3111    nom_type_nc='_i1-i2';
     3112else
     3113    if  isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)')
     3114        nom_type_nc='_i1-i2_j'; % PIV in volume
     3115    else
     3116        nom_type_nc='_i_j1-j2';
     3117    end
     3118end
     3119browse.nom_type_nc=nom_type_nc;
     3120set(handles.RootName,'UserData',browse)
     3121
     3122%reads .nc subdirectory and image numbers from the interface
     3123subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data
     3124subdir_civ2=get(handles.txt_SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data
     3125ref_i=str2double(get(handles.ref_i,'String'));
     3126if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')
     3127    ref_j=0;
     3128else
     3129    ref_j=str2double(get(handles.ref_j,'String'));
     3130end
     3131time=get(handles.ImaDoc,'UserData'); %get the set of times
     3132if isempty(time)
     3133    time=[0 1];%default
     3134end
     3135displ_num=get(handles.ListPairCiv1,'UserData');
     3136
     3137%eliminate the first pairs inconsistent with the position
     3138if isempty(displ_num)
     3139    nbpair=0;
     3140else
     3141    nbpair=length(displ_num(1,:));%nbre of displayed pairs
     3142    if  isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)')
     3143        nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index
     3144    elseif  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
     3145        nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index
     3146    end
     3147end
     3148nbpair=min(200,nbpair);%limit the number of displayed pairs to 200
     3149
     3150%% look for existing processed pairs at the reference indices if Civ1 will not
     3151% be performed, while the result is needed for next steps.
     3152displ_pair={''}; %default
     3153select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs
     3154if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value')
     3155    if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir')
     3156        errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist'])
     3157        set(handles.ListPairCiv2,'Value',1);
     3158        set(handles.ListPairCiv2,'String',{''});
     3159        return
     3160    end
     3161    for ipair=1:nbpair
     3162        filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
     3163            ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
     3164        select(ipair)=exist(filename,'file')==2;
     3165    end
     3166    if  isequal(select,zeros(size(1:nbpair)))
     3167        if isfield(browse,'incr_pair')
     3168            num_i1=ref_i-floor(browse.incr_pair(1)/2);
     3169            num_i2=ref_i+floor((browse.incr_pair(1)+1)/2);
     3170            num_j1=ref_j-floor(browse.incr_pair(2)/2);
     3171            num_j2=ref_j+floor((browse.incr_pair(2)+1)/2);
     3172            filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2);
     3173            select(1)=exist(filename,'file')==2;
     3174        else
     3175            if  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
     3176                errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2])
     3177            else
     3178                errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2])
     3179            end
     3180            set(handles.ListPairCiv2,'Value',1);
     3181            set(handles.ListPairCiv2,'String',{''});
     3182            return
     3183        end
     3184    end
     3185end
     3186if isequal(mode,'series(Di)')
     3187    for ipair=1:nbpair
     3188        if select(ipair)
     3189            displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
     3190            if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
     3191                dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
     3192                displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
     3193            end
     3194        else
     3195            displ_pair{ipair}='...'; %pair not displayed in the menu
     3196        end
     3197    end
     3198elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index
     3199    for ipair=1:nbpair
     3200        if select(ipair)
     3201            displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
     3202            if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
     3203                dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
     3204                displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
     3205            end
     3206        else
     3207            displ_pair{ipair}='...'; %pair not displayed in the menu
     3208        end
     3209    end
     3210elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs
     3211    for ipair=1:nbpair
     3212        if select(ipair)
     3213            dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt
     3214            displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ...
     3215                ' :dt= ' num2str(dt*1000)];
     3216        else
     3217            displ_pair{ipair}='...'; %pair not displayed in the menu
     3218        end
     3219    end
     3220elseif isequal(mode,'displacement')
     3221    displ_pair={'Di=Dj=0'};
     3222end
     3223val=get(handles.ListPairCiv2,'Value');
     3224ichoice=find(select,1);
     3225if (isempty(ichoice) || ichoice < 1); ichoice=1; end;
     3226if get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0
     3227    val=ichoice;% first valid pair proposed by default in the menu
     3228end
     3229if val>length(displ_pair')
     3230    set(handles.ListPairCiv2,'Value',1);% first valid pair proposed by default in the menu
     3231else
     3232    set(handles.ListPairCiv2,'Value',val);
     3233end
     3234set(handles.ListPairCiv2,'String',displ_pair');
     3235set(gcf,'Pointer','arrow')
     3236
     3237
     3238
     3239
     3240%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     3241% Callbacks in the uipanel Reference Indices
     3242%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    31543243%------------------------------------------------------------------------
    31553244function first_i_Callback(hObject, eventdata, handles)
     
    31663255ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt)
    31673256
     3257%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     3258% Callbacks in the uipanel Civ1
     3259%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    31683260%------------------------------------------------------------------------
    31693261% --- Executes on button press in SearchRange: determine the search range num_Searchx,num_Searchy
     
    32593351end
    32603352
    3261 %------------------------------------------------------------------------
    3262 % --- Executes on carriage return on the subdir checkciv1 edit window
    3263 function txt_SubdirCiv1_Callback(hObject, eventdata, handles)
    3264 %------------------------------------------------------------------------
    3265 subdir=get(handles.txt_SubdirCiv1,'String');
    3266 menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update
    3267 ichoice=find(strcmp(subdir,menu_str),1);
    3268 if isempty(ichoice)
    3269     ilist=numel(menu_str); %select 'new...' in the menu
    3270 else
    3271     ilist=ichoice;
    3272 end
    3273 set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu
    3274 if get(handles.CheckCiv1,'Value')% if Civ1 is performed
    3275     set(handles.txt_SubdirCiv2,'String',subdir);% set by default civ2 directory the same as civ1
    3276     set(handles.ListSubdirCiv2,'Value',ilist)
    3277 else % if Civ1 data already exist
    3278     find_netcpair_civ1(handles); %update the list of available pairs from netcdf files in the new directory
    3279 end
    3280 
    3281 %------------------------------------------------------------------------
    3282 % --- Executes on carriage return on the subdir checkciv1 edit window
    3283 function txt_SubdirCiv2_Callback(hObject, eventdata, handles)
    3284 %------------------------------------------------------------------------
    3285 subdir=get(handles.txt_SubdirCiv1,'String');
    3286 menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update
    3287 ichoice=find(strcmp(subdir,menu_str),1);
    3288 if isempty(ichoice)
    3289     ilist=numel(menu_str); %select 'new...' in the menu
    3290 else
    3291     ilist=ichoice;
    3292 end
    3293 set(handles.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu
    3294 %update the list of available pairs from netcdf files in the new directory
    3295 if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value')
    3296     find_netcpair_civ2(handles);
    3297 end
    3298 
    3299 % %------------------------------------------------------------------------
    3300 % % --- Executes on button press in CheckMask: select box for mask option
    3301 % function check_Mask_Callback(hObject, eventdata, handles)
    3302 % %------------------------------------------------------------------------
    3303 % maskval=get(handles.CheckMask,'Value');
    3304 % if isequal(maskval,0)
    3305 %     set(handles.txt_MaskName,'Visible','off')
    3306 % %     set(handles.txt_MaskName,'String','')
    3307 % else
    3308 %     mask_displ='no mask'; %default
    3309 %     filebase=get(handles.RootName,'String');
    3310 %     [ nbslice_mask, flag_mask]=get_mask(filebase,handles);
    3311 %     if isequal(flag_mask,1)
    3312 %         mask_displ=[num2str(nbslice_mask) 'mask'];
    3313 %     elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series
    3314 %         common_path=fileparts(filebase);
    3315 %         filebase_a=fullfile(common_path,get(handles.RootName_1,'String'));
    3316 %         [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    3317 %         if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask)
    3318 %             mask_displ='no mask';
    3319 %         end
    3320 %     end
    3321 %     if isequal(mask_displ,'no mask')
    3322 %         [FileName, PathName, filterindex] = uigetfile( ...
    3323 %             {'*.png', ' (*.png)';
    3324 %             '*.png',  '.png files '; ...
    3325 %             '*.*', 'All Files (*.*)'}, ...
    3326 %             'Pick a mask file *.png',filebase);
    3327 %         mask_displ=fullfile(PathName,FileName);
    3328 %         if exist(mask_displ,'file')
    3329 %             set(handles.txt_MaskName,'Visible','on')
    3330 %             set(handles.txt_MaskName,'String',mask_displ)
    3331 % %             mask_displ='no mask';
    3332 %         end
    3333 %     end
    3334 %     if isequal(mask_displ,'no mask')
    3335 %         set(handles.CheckMask,'Value',0)
    3336 %         set(handles.CheckMask,'Value',0)
    3337 %         set(handles.CheckMask,'Value',0)
    3338 %         set(handles.CheckMask,'Value',0)
    3339 %     else
    3340 %         set(handles.CheckMask,'Value',1)
    3341 %         set(handles.CheckMask,'Value',1)
    3342 %     end
    3343 %     set(handles.txt_MaskName,'String',mask_displ)
    3344 %     set(handles.txt_MaskName,'String',mask_displ)
    3345 %     set(handles.txt_Mask,'String',mask_displ)
    3346 %     set(handles.txt_MaskName,'String',mask_displ)
    3347 % end
    3348 % set(handles.CheckMask,'Value',maskval)%update the checkciv2 mask with the same option as checkciv1
    33493353
    33503354%------------------------------------------------------------------------
     
    37133717end
    37143718
    3715 %------------------------------------------------------------------------
    3716 % --- Executes on button press in CheckGrid.
    3717 function browse_gridciv2_Callback(hObject, eventdata, handles)
    3718 %------------------------------------------------------------------------
    3719 value=get(handles.CheckGrid,'Value');
    3720 if value
    3721     filebase=get(handles.RootName,'String');
    3722     [nbslice, flag_grid]=get_grid(filebase,handles);
    3723     if isequal(flag_grid,1)
    3724         mask_displ=[num2str(nbslice) 'grid'];
    3725         set(handles.txt_GridName,'String',mask_displ)
    3726         set(handles.num_Dx,'Visible','off');
    3727         set(handles.num_Dy,'Visible','off');
    3728     else
    3729         [FileName, PathName, filterindex] = uigetfile( ...
    3730             {'*.grid', ' (*.grid)';
    3731             '*.grid',  '.grid files '; ...
    3732             '*.*', 'All Files (*.*)'}, ...
    3733             'Pick a file',filebase);
    3734         filegrid=fullfile(PathName,FileName);
    3735         if isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')
    3736             set(handles.CheckGrid,'Value',0);
    3737             set(handles.txt_GridName,'string','');
    3738             set(handles.num_Dx,'Visible','on');
    3739             set(handles.num_Dy,'Visible','on');
    3740             set(handles.txt_GridName,'string','');
    3741         else
    3742             set(handles.txt_GridName,'string',filegrid);
    3743             set(handles.num_Dx,'Visible','off');
    3744             set(handles.num_Dy,'Visible','off');
    3745             set(handles.txt_GridName,'string',filegrid);
    3746         end
    3747     end
    3748 else
    3749     set(handles.txt_GridName,'string','');
    3750     set(handles.num_Dx,'Visible','on');
    3751     set(handles.num_Dy,'Visible','on');
    3752     set(handles.txt_GridName,'string','');
    3753 end
    3754 
    3755 % % --- Executes on button press in CheckGrid.
    3756 % function browse_gridciv2_Callback(hObject, eventdata, handles)
    3757 %
    3758 % filebase=get(handles.RootName,'String');
    3759 % [FileName, PathName, filterindex] = uigetfile( ...
    3760 %        {'*.grid', ' (*.grid)';
    3761 %         '*.grid',  '.grid files '; ...
    3762 %         '*.*', 'All Files (*.*)'}, ...
    3763 %         'Pick a file',filebase);
    3764 % filegrid=fullfile(PathName,FileName);
    3765 % set(handles.txt_GridName,'string',filegrid);
    3766 % set(handles.num_Dx,'String',' ');
    3767 % set(handles.num_Dy,'String',' ');
    3768 % % set(handles.grid_patch2,'string',filegrid);
    37693719
    37703720% --- Executes on button press in get_gridpatch1.
    37713721function get_gridpatch1_Callback(hObject, eventdata, handles)
    37723722% hObject    handle to get_gridpatch1 (see GCBO)
    3773 % eventdata  reserved - to be defined in a future version of MATLAB
     3723% eventdata  reserved - to be defined in a future version of MENUMATLAB
    37743724% handles    structure with handles and user data (see GUIDATA)
    37753725
     
    37893739%------------------------------------------------------------------------
    37903740
    3791 %------------------------------------------------------------------------
    3792 function enable_civ1(handles,state)
    3793 %------------------------------------------------------------------------
    3794 if state
    3795     RootName=get(handles.RootName,'String');
    3796     if isempty(RootName)
    3797          msgbox_uvmat('ERROR','No input file')
    3798         return
    3799     end
    3800     set(handles.Civ1,'Visible','on')   
    3801     set(handles.PairIndices,'Visible','on')
    3802 %     set(handles.frame_civ1,'BackgroundColor',[1 1 0])
    3803 %     set(handles.frame_para_civ1,'BackgroundColor',[1 1 0])
    3804 %     set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0])
    3805 else
    3806     set(handles.Civ1,'Visible','off') 
    3807 %     set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784])
    3808 %     set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784])
    3809 %     set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784])
    3810 end
    3811 
    3812 % set(handles.num_Bx,'Visible',state)
    3813 % set(handles.num_By,'Visible',state)
    3814 % set(handles.num_Searchx,'Visible',state)
    3815 % set(handles.num_Searchy,'Visible',state)
    3816 % set(handles.num_Shiftx,'Visible',state)
    3817 % set(handles.num_Shifty,'Visible',state)
    3818 % set(handles.num_Rho,'Visible',state)
    3819 % set(handles.num_Dx,'Visible',state)
    3820 % set(handles.num_Dy,'Visible',state)
    3821 % set(handles.SearchRange,'Visible',state)
    3822 % set(handles.u_title,'Visible',state)
    3823 % set(handles.v_title,'Visible',state)
    3824 % set(handles.min_title,'Visible',state)
    3825 % set(handles.max_title,'Visible',state)
    3826 % set(handles.umin,'Visible',state)
    3827 % set(handles.umax,'Visible',state)
    3828 % set(handles.vmin,'Visible',state)
    3829 % set(handles.vmax,'Visible',state)
    3830 % set(handles.txt_GridName,'Visible',state)
    3831 % set(handles.txt_MaskName,'Visible',state)
    3832 % set(handles.CheckGrid,'Visible',state)
    3833 % set(handles.CheckMask,'Visible',state)
    3834 % set(handles.parameters,'Visible',state)
    3835 % set(handles.grid,'Visible',state)
    3836 % set(handles.num_Dx,'Visible',state)
    3837 % set(handles.num_Dy,'Visible',state)
    3838 % set(handles.check_Threshold,'Visible',state)
    3839 % if isequal(state,'off')
    3840 %     set(handles.num_MinIma,'Visible','off')
    3841 %     set(handles.num_MaxIma,'Visible','off')
    3842 %     set(handles.check_Threshold,'Value',0)
    3843 % end
    3844 % set(handles.dx_civ1_title,'Visible',state)
    3845 % set(handles.dy_civ1_title,'Visible',state)
    3846 % set(handles.ImaThreshold_title,'Visible',state)
    3847 % set(handles.ib_title,'Visible',state)
    3848 % set(handles.is_title,'Visible',state)
    3849 % set(handles.shift_title,'Visible',state)
    3850 % set(handles.rho_title,'Visible',state)
    3851 % set(handles.TestCiv1,'Visible',state)
    3852 %set(handles.ListPairMode,'Visible',state)
    3853 
    3854 %------------------------------------------------------------------------
    3855 function enable_fix1(handles,state)
    3856 %------------------------------------------------------------------------
    3857 
    3858 if isequal(state,0)
    3859     state='off';
    3860 end
    3861 if isequal(state,1)
    3862     state='on';
    3863     RootName=get(handles.RootName,'String');
    3864     if isempty(RootName)
    3865          msgbox_uvmat('ERROR','No input file')
    3866         return
    3867     end
    3868 end
    3869 if isequal(state,'on')
    3870     set(handles.Fix1,'Visible','on')
    3871 %     set(handles.frame_fix1,'BackgroundColor',[1 1 0])
    3872 else
    3873     set(handles.Fix1,'Visible','off')
    3874     %set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7])
    3875 end
    3876 % % set(handles.REMOVE,'Visible',state)
    3877 % set(handles.CheckFmin2,'Visible',state)
    3878 % set(handles.CheckF2,'Visible',state)
    3879 % set(handles.CheckF3,'Visible',state)
    3880 % set(handles.num_MinCorr,'Visible',state)
    3881 % set(handles.thresh_vecC_title,'Visible',state)
    3882 % set(handles.num_MinVel,'Visible',state)
    3883 % set(handles.TitleMinVel,'Visible',state)
    3884 % set(handles.txt_MaskName,'Visible',state)
    3885 % set(handles.CheckMask,'Visible',state)
    3886 % set(handles.get_ref_fix1,'Visible',state)
    3887 % set(handles.ref_fix1,'Visible',state)
    3888 % set(handles.num_MinVel,'Visible',state)
    3889 % set(handles.field_ref1,'Visible',state)
    3890 
    3891 %------------------------------------------------------------------------
    3892 function enable_patch1(handles,state)
    3893 %------------------------------------------------------------------------
    3894 if state
    3895     RootName=get(handles.RootName,'String');
    3896     if isempty(RootName)
    3897         msgbox_uvmat('ERROR','No input file')
    3898         return
    3899     end
    3900     set(handles.Patch1,'Visible','on')
    3901 else
    3902     set(handles.Patch1,'Visible','off')
    3903 end
    3904 return
    3905 set(handles.frame_patch1,'BackgroundColor',[1 1 0])
    3906 set(handles.rho_patch1,'Visible','on')
    3907 set(handles.rho_text1,'Visible','on')
    3908 if get(handles.ListPairMode,'Value')==2
    3909     set(handles.thresh_patch1,'Visible','on')
    3910     set(handles.thresh_text1,'Visible','on')
    3911 end
    3912 set(handles.subdomain_patch1,'Visible','on')
    3913 set(handles.subdomain_text1,'Visible','on')
    3914 set(handles.nx_patch1,'Visible','on')
    3915 set(handles.num_Ny,'Visible','on')
    3916 set(handles.nx_patch1_title,'Visible','on')
    3917 set(handles.ny_patch1_title,'Visible','on')
    3918 % if ~isempty(patch_newBin)
    3919 set(handles.test_interp,'Visible','off');
    3920 stereo_test=get(handles.ListCompareMode,'Value');
    3921 if stereo_test==3
    3922     set(handles.test_stereo1,'Visible','on')
    3923 end
    3924 % end
    3925 %set(handles.get_gridpatch1,'Visible','on')
    3926 %set(handles.grid_patch1,'string','none');
    3927 %set(handles.grid_patch1,'Visible','on')
    3928 
    3929 % %------------------------------------------------------------------------
    3930 % function desable_patch1(handles)
    3931 % %------------------------------------------------------------------------
    3932 % return
    3933 % set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784])
    3934 % set(handles.rho_patch1,'Visible','off')
    3935 % set(handles.rho_text1,'Visible','off')
    3936 % set(handles.thresh_patch1,'Visible','off')
    3937 % set(handles.thresh_text1,'Visible','off')
    3938 % set(handles.subdomain_patch1,'Visible','off')
    3939 % set(handles.subdomain_text1,'Visible','off')
    3940 % set(handles.nx_patch1,'Visible','off')
    3941 % set(handles.num_Ny,'Visible','off')
    3942 % set(handles.nx_patch1_title,'Visible','off')
    3943 % set(handles.ny_patch1_title,'Visible','off')
    3944 % set(handles.test_stereo1,'Visible','off')
    3945 % %set(handles.test_interp,'Visible','off')
    3946 % %set(handles.get_gridpatch1,'Visible','off')
    3947 % %set(handles.grid_patch1,'Visible','off')
    3948 %
    3949 % %------------------------------------------------------------------------
    3950 % function enable_civ2(handles,state)
    3951 % %------------------------------------------------------------------------
    3952 % if state
    3953 %     RootName=get(handles.RootName,'String');
    3954 %     if isempty(RootName)
    3955 %          msgbox_uvmat('ERROR','No input file')
    3956 %         return
    3957 %     end
    3958 %     set(handles.Civ2,'Visible','on')
    3959 %     set(handles.ListSubdirCiv2,'Visible','on')
    3960 %     set(handles.SubdirCiv2,'Visible','on')
    3961 %     set(handles.TitleSubdirCiv2,'Visible','on')
    3962 % else
    3963 %     set(handles.Civ2,'Visible','off')
    3964 % end
    3965 
    3966 %
    3967 % set(handles.num_Bx,'Visible',state)
    3968 % set(handles.num_By,'Visible',state)
    3969 % set(handles.CheckDecimal,'Visible',state)
    3970 % set(handles.CheckDeformation,'Visible',state)
    3971 % set(handles.num_Rho,'Visible',state)
    3972 % set(handles.num_Dx,'Visible',state)
    3973 % set(handles.num_Dy,'Visible',state)
    3974 % set(handles.CheckGrid,'Visible',state)
    3975 % set(handles.CheckMask,'Visible',state)
    3976 % set(handles.parameters,'Visible',state)
    3977 % set(handles.grid,'Visible',state)
    3978 % set(handles.parameters_text,'Visible',state)
    3979 % set(handles.grid_text,'Visible',state)
    3980 % set(handles.txt_GridName,'Visible',state)
    3981 % set(handles.txt_Mask,'Visible',state)
    3982 % set(handles.dx_civ2_title,'Visible',state)
    3983 % set(handles.dy_civ2_title,'Visible',state)
    3984 % set(handles.ibx_civ2_text,'Visible',state)
    3985 % set(handles.rho_civ2_title,'Visible',state)
    3986 % set(handles.ImaThreshold2,'Visible',state)
    3987 % set(handles.ImaThreshold_title2,'Visible',state)
    3988 % if isequal(state,'off')
    3989 %     set(handles.num_MinIma,'Visible','off')
    3990 %     set(handles.num_MaxIma,'Visible','off')
    3991 %     set(handles.ImaThreshold2,'Value',0)
    3992 %     if isequal(get(handles.CheckFix2,'Value'),0) & isequal(get(handles.CheckPatch2,'Value'),0)
    3993 %         set(handles.ListPairCiv2,'Visible','off')
    3994 %         set(handles.txt_SubdirCiv2,'Visible','off')
    3995 %         set(handles.TitleSubdirCiv2,'Visible','off')
    3996 %         set(handles.dt_unit_civ2,'Visible','off')
    3997 %         %set(handles.ref_i_civ2,'Visible','off')
    3998 %         set(handles.i_ref_civ2_title,'Visible','off')
    3999 %         set(handles.j_ref_civ2_title,'Visible','off')
    4000 %         set(handles.ref_j_civ2,'Visible','off')
    4001 %     end
    4002 % else
    4003 %     set(handles.ListPairCiv2,'Visible','on')
    4004 %     set(handles.txt_SubdirCiv2,'Visible','on')
    4005 %     set(handles.TitleSubdirCiv2,'Visible','on')
    4006 %     set(handles.dt_unit_civ2,'Visible','on')
    4007 %   %  set(handles.ref_i_civ2,'Visible','on')
    4008 %     set(handles.i_ref_civ2_title,'Visible','on')
    4009 %     set(handles.j_ref_civ2_title,'Visible','on')
    4010 %     set(handles.ref_j_civ2,'Visible','on')
    4011 % end
    4012 % set(handles.rho_civ2_title,'Visible',state)
    4013 
    4014 %------------------------------------------------------------------------
    4015 function enable_fix2(handles,state)
    4016 %------------------------------------------------------------------------
    4017 % if isequal(state,'on')
    4018 %     set(handles.Fix2,'Visible','on') 
    4019 %     
    4020 % %     set(handles.frame_civ2,'BackgroundColor',[1 1 0])
    4021 % %     set(handles.frame_para_civ2,'BackgroundColor',[1 1 0])
    4022 % %     set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0])
    4023 % %     set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])
    4024 % else
    4025 if state
    4026     RootName=get(handles.RootName,'String');
    4027     if isempty(RootName)
    4028          msgbox_uvmat('ERROR','No input file')
    4029         return
    4030     end
    4031     set(handles.Fix2,'Visible','on')
    4032 else
    4033     set(handles.Fix2,'Visible','off')
    4034 end
    4035 
    4036 % set(handles.frame_fix2,'BackgroundColor',[1 1 0])
    4037 % set(handles.REMOVE2,'Visible','on')
    4038 % set(handles.CheckFmin2,'Visible','on')
    4039 % set(handles.CheckF4,'Visible','on')
    4040 % set(handles.CheckF3,'Visible','on')
    4041 % set(handles.num_MinCorr,'Visible','on')
    4042 % set(handles.thresh_vec2C_text,'Visible','on')
    4043 % set(handles.num_MinVel,'Visible','on')
    4044 % set(handles.TitleMinVel,'Visible','on')
    4045 % set(handles.txt_MaskName,'Visible','on')
    4046 % set(handles.CheckMask,'Visible','on')
    4047 % set(handles.ListPairCiv2,'Visible','on')
    4048 % set(handles.txt_SubdirCiv2,'Visible','on')
    4049 % set(handles.TitleSubdirCiv2,'Visible','on')
    4050 % set(handles.get_ref_fix2,'Visible','on')
    4051 % set(handles.ref_fix2,'Visible','on')
    4052 % set(handles.num_MinVel,'Visible','on')
    4053 % set(handles.field_ref2,'Visible','on')
    4054 
    4055 % %------------------------------------------------------------------------
    4056 % function desable_fix2(handles)
    4057 % %------------------------------------------------------------------------
    4058 % set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784])
    4059 % set(handles.REMOVE2,'Visible','off')
    4060 % set(handles.CheckFmin2,'Visible','off')
    4061 % set(handles.CheckF4,'Visible','off')
    4062 % set(handles.CheckF3,'Visible','off')
    4063 % set(handles.num_MinCorr,'Visible','off')
    4064 % set(handles.thresh_vec2C_text,'Visible','off')
    4065 % set(handles.num_MinVel,'Visible','off')
    4066 % set(handles.TitleMinVel,'Visible','off')
    4067 % set(handles.txt_MaskName,'Visible','off')
    4068 % set(handles.CheckMask,'Visible','off')
    4069 % set(handles.get_ref_fix2,'Visible','off')
    4070 % set(handles.ref_fix2,'Visible','off')
    4071 % set(handles.num_MinVel,'Visible','off')
    4072 % set(handles.field_ref2,'Visible','off')
    4073 % if isequal(get(handles.CheckCiv2,'Value'),0) & isequal(get(handles.CheckPatch2,'Value'),0)
    4074 %     set(handles.ListPairCiv2,'Visible','off')
    4075 %     set(handles.txt_SubdirCiv2,'Visible','off')
    4076 %     set(handles.TitleSubdirCiv2,'Visible','off')
    4077 % end
    4078 
    4079 %------------------------------------------------------------------------
    4080 function enable_patch2(handles,state)
    4081 %------------------------------------------------------------------------
    4082 if state
    4083 RootName=get(handles.RootName,'String');
    4084     if isempty(RootName)
    4085          msgbox_uvmat('ERROR','No input file')
    4086         return
    4087     end
    4088     set(handles.Patch2,'Visible','on')
    4089 else
    4090 set(handles.Patch2,'Visible','off')
    4091 end
    4092 % set(handles.frame_patch2,'BackgroundColor',[1 1 0])
    4093 % set(handles.num_SmoothingParam,'Visible','on')
    4094 % set(handles.num_SmoothingParam,'Visible','on')
    4095 % set(handles.num_MaxDiff,'Visible','on')
    4096 % set(handles.thresh_text2,'Visible','on')
    4097 % set(handles.num_SubdomainSize,'Visible','on')
    4098 % set(handles.subdomain_text2,'Visible','on')
    4099 % set(handles.num_Nx,'Visible','on')
    4100 % set(handles.num_Ny,'Visible','on')
    4101 % set(handles.nx_patch2_title,'Visible','on')
    4102 % set(handles.ny_patch2_title,'Visible','on')
    4103 % % set(handles.get_gridpatch2,'Visible','on')
    4104 % % set(handles.grid_patch2,'Visible','on')
    4105 % set(handles.ListPairCiv2,'Visible','on')
    4106 % set(handles.txt_SubdirCiv2,'Visible','on')
    4107 % set(handles.TitleSubdirCiv2,'Visible','on')
    4108 % stereo_test=get(handles.ListCompareMode,'Value');
    4109 % if stereo_test==3
    4110 %     set(handles.CheckStereo,'Visible','on')
    4111 % end
    4112 
    4113 % %------------------------------------------------------------------------
    4114 % function desable_patch2(handles)
    4115 % %------------------------------------------------------------------------
    4116 % %set(handles.checkpatch2,'Visible','off')
    4117 % return
    4118 % set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784])
    4119 % set(handles.num_SmoothingParam,'Visible','off')
    4120 % set(handles.num_SmoothingParam,'Visible','off')
    4121 % set(handles.num_MaxDiff,'Visible','off')
    4122 % set(handles.thresh_text2,'Visible','off')
    4123 % set(handles.num_SubdomainSize,'Visible','off')
    4124 % set(handles.subdomain_text2,'Visible','off')
    4125 % set(handles.num_Nx,'Visible','off')
    4126 % set(handles.num_Ny,'Visible','off')
    4127 % set(handles.nx_patch2_title,'Visible','off')
    4128 % set(handles.ny_patch2_title,'Visible','off')
    4129 % % set(handles.get_gridpatch2,'Visible','off')
    4130 % % set(handles.grid_patch2,'Visible','off')
    4131 % if isequal(get(handles.CheckCiv2,'Value'),0) & isequal(get(handles.CheckFix2,'Value'),0)
    4132 %     set(handles.ListPairCiv2,'Visible','off')
    4133 %     set(handles.txt_SubdirCiv2,'Visible','off')
    4134 %     set(handles.TitleSubdirCiv2,'Visible','off')
    4135 % end
    4136 % set(handles.CheckStereo,'Visible','off')
    4137 % %------------------------------------------------------------------------
    4138 % function enable_pair1(handles,state)
    4139 % %------------------------------------------------------------------------
    4140 % set(handles.txt_SubdirCiv1,'Visible',state)
    4141 % set(handles.ListSubdirCiv1,'Visible',state)
    4142 % set(handles.TitleSubdirCiv1,'Visible',state)
    4143 % %set(handles.frame_subdirciv1,'Visible',state)
    4144 % set(handles.ListPairCiv1,'Visible',state)
    4145 % set(handles.TitlePairCiv1,'Visible',state)
    4146 % %set(handles.dt_unit,'Visible',state)
    4147 % %set(handles.PAIR_frame,'Visible',state)
    4148 
    4149 %------------------------------------------------------------------------
    4150 % --- Read the parameters for checkciv1 on the interface
    4151 % function par=read_param_civ1(handles,filecell)
    4152 % % not deeden anymore
    4153 % %------------------------------------------------------------------------
    4154 % ibx_val=str2double(get(handles.num_Bx,'String'));
    4155 % par.ibx=num2str(ibx_val);
    4156 % iby_val=str2double(get(handles.num_By,'String'));
    4157 % par.iby=num2str(iby_val);
    4158 % isx=get(handles.num_Searchx,'String');
    4159 % if isnan(str2double(isx)), isx='41'; set(handles.num_Searchx,'String','41'), end; %default
    4160 % if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.num_Searchx,'String',num2str(ibx_val+8)); end
    4161 % isy=get(handles.num_Searchy,'String');
    4162 % if isnan(str2double(isy)), isy='41'; set(handles.num_Searchy,'String','41'), end;%default
    4163 % if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.num_Searchy,'String',num2str(iby_val+8)); end
    4164 % par.isx=get(handles.num_Searchx,'String');
    4165 % par.isy=get(handles.num_Searchy,'String');
    4166 % par.shiftx=get(handles.num_Shiftx,'String');
    4167 % par.shifty=get(handles.num_Shifty,'String');
    4168 % if isnan(str2double(par.isx))
    4169 %     par.isx='41';%default
    4170 %     set(handles.num_Searchx,'String','41');
    4171 % end
    4172 % if isnan(str2double(par.isy))
    4173 %     par.isy='41'; %default
    4174 %     set(handles.num_Searchy,'String','41');
    4175 % end
    4176 % if isnan(str2double(par.shiftx))
    4177 %     par.shiftx='0';%default
    4178 %     set(handles.num_Shiftx,'String','0');
    4179 % end
    4180 % if isnan(str2double(par.shifty))
    4181 %     par.shifty='0'; %default
    4182 %     set(handles.num_Shifty,'String','0');
    4183 % end
    4184 % par.rho=get(handles.num_Rho,'String');
    4185 % if isequal(get(handles.num_Rho,'Style'),'popupmenu')
    4186 %     index=get(handles.num_Rho,'Value');
    4187 %     par.rho=par.rho{index};
    4188 % end
    4189 % dummy=get(handles.num_Dx,'String');
    4190 % par.dx=dummy{1};
    4191 % dummy=get(handles.num_Dy,'String');
    4192 % par.dy=dummy{1};
    4193 % if isnan(str2double(par.dx))
    4194 %     if isempty(get(handles.txt_GridName,'String'));
    4195 %         par.dx='0'; %just read by civ program, not used
    4196 %     else
    4197 %         par.dx='20';%default
    4198 %         set(handles.num_Dx,'String','20');
    4199 %     end
    4200 % end
    4201 % if isnan(str2double(par.dy))
    4202 %     if isempty(get(handles.txt_GridName,'String'));
    4203 %         par.dy='0';%just read by civ program, not used
    4204 %     else
    4205 %         par.dy='20';%default
    4206 %         set(handles.dy_civ1_title,'String','20');
    4207 %     end
    4208 % end
    4209 % par.pxcmx='1'; %velocities are expressed in pixel dispalcement
    4210 % par.pxcmy='1';
    4211 % % if exist('file_ima','var')
    4212 % A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size
    4213 % sizim=size(A);
    4214 % par.npx=num2str(sizim(2));
    4215 % par.npy=num2str(sizim(1));
    4216 % %TODO : civ should not need npx and npy
    4217 %
    4218 %
    4219 % % end
    4220 % %time=get(handles.RootName,'UserData'); %get the set of times
    4221 % dummy=get(handles.txt_GridName,'String');
    4222 % par.gridname=dummy{1};
    4223 % par.gridflag='y';
    4224 % if strcmp(par.gridname,'')|| isempty(par.gridname)
    4225 %     par.gridname='nogrid';
    4226 %     par.gridflag='n';
    4227 % end
    4228 %
    4229  
    4230            
    4231 %------------------------------------------------------------------------
    4232 function par=read_param_civ2(handles,file_ima)
    4233 %------------------------------------------------------------------------
    4234 par.ibx=get(handles.num_Bx,'String');
    4235 par.iby=get(handles.num_By,'String');
    4236 par.rho=get(handles.num_Rho,'String');
    4237 par.decimal=int2str(get(handles.CheckDecimal,'Value'));
    4238 par.deformation=int2str(get(handles.CheckDeformation,'Value'));
    4239 par.dx=get(handles.num_Dx,'String');
    4240 par.dy=get(handles.num_Dy,'String');
    4241 if isnan(str2double(par.dx))
    4242     if isempty(get(handles.txt_GridName,'String'));
    4243         par.dx='0'; %just read by civ program, not used
    4244     else
    4245         par.dx='20';%default
    4246         set(handles.num_Dx,'String','20');
    4247     end
    4248 end
    4249 if isnan(str2double(par.dy))
    4250     if isempty(get(handles.txt_GridName,'String'));
    4251         par.dy='0';%just read by civ program, not used
    4252     else
    4253         par.dy='20';%default
    4254         set(handles.num_Dy,'String','20');
    4255     end
    4256 end
    4257 par.pxcmx='1';
    4258 par.pxcmy='1';
    4259 A=imread(file_ima);%read the first image to get the size
    4260 sizim=size(A);
    4261 par.npx=num2str(sizim(2));
    4262 par.npy=num2str(sizim(1));
    4263 %time=get(handles.RootName,'UserData'); %get the set of times
    4264 par.gridname=get(handles.txt_GridName,'String');
    4265 par.gridflag='y';
    4266 if strcmp(par.gridname,'')|| isempty(par.gridname)
    4267     par.gridname='nogrid';
    4268     par.gridflag='n';
    4269 end
    4270 
    4271 % function cmd_CIV1=CIV1_CMD(filename,param)
    4272 % %TODO : include filename in par_civ1
    4273 % %------------------------------------------------------------------------
    4274 % %pixels per cm and matrix of the image times, read from the .civ file by uvmat
    4275 %
    4276 % %changes : filename_cmx -> filename ( no extension )
    4277 %
    4278 % filename=regexprep(filename,'.nc','');
    4279 %
    4280 % if isequal(Param.Civ1.Dt,'0')
    4281 %     Param.Civ1.Dt='1' ;%case of 'displacement' mode
    4282 % end
    4283 % Param.Civ1.filename_ima_a=regexprep(Param.Civ1.filename_ima_a,'.png','');
    4284 % Param.Civ1.filename_ima_b=regexprep(Param.Civ1.filename_ima_b,'.png','');
    4285 % fid=fopen([filename '.civ1.cmx'],'w');
    4286 % fprintf(fid,['##############   CMX file' '\n' ]);
    4287 % fprintf(fid,   ['FirstImage ' regexprep(Param.Civ1.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility
    4288 % fprintf(fid,   ['LastImage  ' regexprep(Param.Civ1.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility
    4289 % fprintf(fid,  ['XX' '\n' ]);
    4290 % fprintf(fid,  ['Mask ' Param.Civ1.maskflag '\n' ]);
    4291 % fprintf(fid,  ['MaskName ' regexprep(Param.Civ1.maskname,'\\','\\\\') '\n' ]);
    4292 % fprintf(fid,   ['ImageSize ' Param.Civ1.npx ' ' Param.Civ1.npy '\n' ]);   %VERIFIER CAS GENERAL ?
    4293 % fprintf(fid,   ['CorrelationBoxesSize ' Param.Civ1.ibx ' ' Param.Civ1.iby '\n' ]);
    4294 % fprintf(fid,   ['SearchBoxeSize ' Param.Civ1.isx ' ' Param.Civ1.isy '\n' ]);
    4295 % fprintf(fid,   ['RO ' Param.Civ1.rho '\n' ]);
    4296 % fprintf(fid,   ['GridSpacing ' Param.Civ1.dx ' ' Param.Civ1.dy '\n' ]);
    4297 % fprintf(fid,   ['XX 1.0' '\n' ]);
    4298 % fprintf(fid,   ['Dt_TO ' Param.Civ1.Dt ' ' Param.Civ1.T0 '\n' ]);
    4299 % fprintf(fid,  ['PixCmXY ' Param.Civ1.pxcmx ' ' Param.Civ1.pxcmy '\n' ]);
    4300 % fprintf(fid,  ['XX 1' '\n' ]);
    4301 % fprintf(fid,   ['ShiftXY ' Param.Civ1.shiftx ' '  Param.Civ1.shifty '\n' ]);
    4302 % fprintf(fid,  ['Grid ' Param.Civ1.gridflag '\n' ]);
    4303 % fprintf(fid,   ['GridName ' regexprep(Param.Civ1.gridname,'\\','\\\\') '\n' ]);
    4304 % fprintf(fid,   ['XX 85' '\n' ]);
    4305 % fprintf(fid,   ['XX 1.0' '\n' ]);
    4306 % fprintf(fid,   ['XX 1.0' '\n' ]);
    4307 % fprintf(fid,   ['Hart 1' '\n' ]);
    4308 % fprintf(fid,  [ 'DecimalShift 0' '\n' ]);
    4309 % fprintf(fid,   ['Deformation 0' '\n' ]);
    4310 % fprintf(fid,  ['CorrelationMin 0' '\n' ]);
    4311 % fprintf(fid,   ['IntensityMin 0' '\n' ]);
    4312 % fprintf(fid,  ['SeuilImage n' '\n' ]);
    4313 % fprintf(fid,   ['SeuilImageValues 0 4096' '\n' ]);
    4314 % fprintf(fid,   ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ?
    4315 % fprintf(fid,   ['ImageUsedBefore null null' '\n' ]);
    4316 % fclose(fid);
    4317 %
    4318 % % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file
    4319 % % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\');
    4320 % % namelog=regexprep(namelog,'\\','\\\\');
    4321 % if(isunix)
    4322 %     cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx'];
    4323 %     cmd_CIV1=[cmd_CIV1 '\n'...
    4324 %         Param.xml.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx
    4325 %     cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting
    4326 %    % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.checkciv1.cmx' '\n'];%rename .cmx as .checkciv1.cmx
    4327 % else %Windows system
    4328 % %                     flname=regexprep(flname,'\\','\\\\');
    4329 % %                     cmd=[cmd 'copy /Y "' flname '.checkciv1.cmx" "' flname '.cmx"\n'];
    4330 % %     filename=regexprep(filename,'\\','\\\\');
    4331 %     cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"'];% copy the .civ1.cmx parameter file to .cmx
    4332 %     cmd_CIV1=[cmd_CIV1 '\n "' regexprep(Param.xml.Civ1Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file
    4333 % %     namelog=regexprep(namelog,'\\','\\\\');
    4334 %     cmd_CIV1=[cmd_CIV1 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log
    4335 %
    4336 %     %  cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.checkciv1.cmx"'];
    4337 % end
    4338 
    4339 %------------------------------------------------------------------------
    4340 % --- CheckCiv1  Unified
    4341 function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par)
    4342 %------------------------------------------------------------------------
    4343 %pixels per cm and matrix of the image times, read from the .civ file by uvmat
    4344 %global CivBin%name of the executable for checkciv1 calculation
    4345 
    4346 civ1.image1=par.filename_ima_a;
    4347 civ1.image2=par.filename_ima_b;
    4348 civ1.imageSize_X=par.npx;
    4349 civ1.imageSize_Y=par.npy;
    4350 civ1.outputFileName=[filename '.nc'];
    4351 civ1.correlationBoxesSize_X=par.ibx;
    4352 civ1.correlationBoxesSize_Y=par.iby;
    4353 civ1.searchBoxesSize_X=par.isx;
    4354 civ1.searchBoxesSize_Y=par.isy;
    4355 civ1.globalShift_X=par.shiftx;
    4356 civ1.globalShift_Y=par.shifty;
    4357 civ1.ro=par.rho;
    4358 civ1.hart='y';
    4359 if isequal(par.gridflag,'y')
    4360     civ1.grid=par.gridname;
    4361 else
    4362     civ1.grid='n';
    4363     civ1.gridSpacing_X=par.dx;
    4364     civ1.gridSpacing_Y=par.dy;
    4365 end
    4366 if isequal(par.maskflag,'y')
    4367     civ1.mask=par.maskname;
    4368 end
    4369 civ1.dt=par.Dt;
    4370 civ1.unit='pixel';
    4371 civ1.absolut_time_T0=par.T0;
    4372 civ1.pixcmx=par.pxcmx;
    4373 civ1.pixcmy=par.pxcmy;
    4374 civ1.convectFlow='n';
    4375 
    4376 xml_civ1_parameters=civ1;
    4377 
    4378 %------------------------------------------------------------------------
    4379 % --- CheckCiv2  Unified
    4380 function civ2=CIV2_CMD_Unified(filename,namelog,par)
    4381 %------------------------------------------------------------------------
    4382 %pixels per cm and matrix of the image times, read from the .civ file by uvmat
    4383 %global CivBin%name of the executable for checkciv1 calculation
    4384 
    4385 filename=regexprep(filename,'.nc','');
    4386 
    4387 civ2.image1=par.filename_ima_a;
    4388 civ2.image2=par.filename_ima_b;
    4389 civ2.imageSize_X=par.npx;
    4390 civ2.imageSize_Y=par.npy;
    4391 civ2.inputFileName=[par.filename_nc1 '.nc'];
    4392 civ2.outputFileName=[filename '.nc'];
    4393 civ2.correlationBoxesSize_X=par.ibx;
    4394 civ2.correlationBoxesSize_Y=par.iby;
    4395 civ2.ro=par.rho;
    4396 %checkciv2.decimalShift=par.CheckDecimal;
    4397 %checkciv2.CheckDeformation=par.CheckDeformation;
    4398 if isequal(par.decimal,'1')
    4399     civ2.decimalShift='y';
    4400 else
    4401     civ2.decimalShift='n';
    4402 end
    4403 if isequal(par.deformation,'1')
    4404     civ2.deformation='y';
    4405 else
    4406     civ2.deformation='n';
    4407 end
    4408 if isequal(par.gridflag,'y')
    4409     civ2.grid=par.gridname;
    4410 else
    4411     civ2.grid='n';
    4412     civ2.gridSpacing_X=par.dx;
    4413     civ2.gridSpacing_Y=par.dy;
    4414 end
    4415 civ2.gridSpacing_X='10';
    4416 civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee
    4417 if isequal(par.maskflag,'y')
    4418     civ2.mask=par.maskname;
    4419 else
    4420     civ2.mask='n';
    4421 end
    4422 civ2.dt=par.Dt;
    4423 civ2.unit='pixel';
    4424 civ2.absolut_time_T0=par.T0;
    4425 civ2.pixcmx=par.pxcmx;
    4426 civ2.pixcmy=par.pxcmy;
    4427 civ2.convectFlow='n';
    4428 civ2.pixcmx=par.pxcmx;
    4429 civ2.pixcmy=par.pxcmy;
    4430 civ2.convectFlow='n';
    4431 
    4432 % %------------------------------------------------------------------------
    4433 % % --- CheckCiv2  CheckCiv2  CheckCiv2 CheckCiv2
    4434 % function cmd_CIV2=CIV2_CMD(filename,param)
    4435 % %------------------------------------------------------------------------
    4436 % %pixels per cm and matrix of the image times, read from the .civ file by uvmat
    4437 % % global civ2Bin sge%name of the executable for checkciv1 calculation
    4438 % filename=regexprep(filename,'.nc','');
    4439 % if isequal(Param.Civ2.Dt,'0')
    4440 %     Param.Civ2.Dt='1' ;%case of 'displacement' mode
    4441 % end
    4442 % Param.Civ2.filename_ima_a=regexprep(Param.Civ2.filename_ima_a,'.png','');
    4443 % Param.Civ2.filename_ima_b=regexprep(Param.Civ2.filename_ima_b,'.png','');% bug : .png appears two times ?
    4444 % [fid,errormsg]=fopen([filename '.civ2.cmx'],'w');
    4445 % if isequal(fid,-1)
    4446 %     msgbox_uvmat('ERROR',errormsg)
    4447 %     cmd_CIV2='';
    4448 %     return
    4449 % end
    4450 % fprintf(fid,['##############   CMX file' '\n' ]);
    4451 % fprintf(fid,   ['FirstImage ' regexprep(Param.Civ2.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility
    4452 % fprintf(fid,   ['LastImage  ' regexprep(Param.Civ2.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility
    4453 % fprintf(fid,  ['XX' '\n' ]);
    4454 % fprintf(fid, ['Mask ' Param.Civ2.MaskFlag '\n' ]);
    4455 % fprintf(fid, ['MaskName ' regexprep(Param.Civ2.MaskName,'\\','\\\\') '\n' ]);% for windows compatibility
    4456 % fprintf(fid, ['ImageSize ' Param.Civ2.npx ' ' Param.Civ2.npy '\n' ]);   %VERIFIER CAS GENERAL ?
    4457 % fprintf(fid, ['CorrelationBoxesSize ' Param.Civ2.ibx ' ' Param.Civ2.iby '\n' ]);
    4458 % fprintf(fid, ['SearchBoxeSize ' Param.Civ2.ibx ' ' Param.Civ2.iby '\n']);
    4459 % fprintf(fid, ['RO ' Param.Civ2.rho '\n']);
    4460 % fprintf(fid, ['GridSpacing ' Param.Civ2.dx ' ' Param.Civ2.dy '\n']);
    4461 % fprintf(fid, ['XX 1.0' '\n' ]);
    4462 % fprintf(fid, ['Dt_TO ' Param.Civ2.Dt ' ' Param.Civ2.T0 '\n' ]);
    4463 % fprintf(fid, ['PixCmXY ' Param.Civ2.pxcmx ' ' Param.Civ2.pxcmy '\n' ]);
    4464 % fprintf(fid, ['XX 1' '\n' ]);
    4465 % fprintf(fid, 'ShiftXY 0 0\n');
    4466 % fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]);
    4467 % fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']);
    4468 % fprintf(fid, ['XX 85' '\n' ]);
    4469 % fprintf(fid, ['XX 1.0' '\n' ]);
    4470 % fprintf(fid, ['XX 1.0' '\n' ]);
    4471 % fprintf(fid, ['Hart 1' '\n' ]);
    4472 % fprintf(fid, ['DecimalShift ' Param.Civ2.decimal '\n']);
    4473 % fprintf(fid, ['Deformation ' Param.Civ2.deformation '\n']);
    4474 % fprintf(fid,  ['CorrelationMin 0' '\n' ]);
    4475 % fprintf(fid,   ['IntensityMin 0' '\n' ]);
    4476 % fprintf(fid,  ['SeuilImage n' '\n' ]);
    4477 % fprintf(fid,   ['SeuilImageValues 0 4096' '\n' ]);
    4478 % fprintf(fid,   ['ImageToUse ' Param.Civ2.term_a ' ' Param.Civ2.term_b '\n' ]); % VERIFIER ?
    4479 % fprintf(fid, ['ImageUsedBefore ' regexprep(Param.Civ2.filename_nc1,'\\','\\\\') '\n']);
    4480 % fclose(fid);
    4481 %
    4482 % if(isunix)
    4483 %     cmd_CIV2=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n'];
    4484 %     cmd_CIV2=[cmd_CIV2 Param.xml.Civ2Bin ' -f ' filename  '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx
    4485 %     cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc'];%preserve the log file as .civ2.log
    4486 % %    cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.cmx' ' ' filename '.checkciv2.cmx' '\n'];%rename .cmx as .checkciv2.cmx, the result file is named [filename '.nc'] by CIVx
    4487 %
    4488 % else
    4489 %     filename=regexprep(filename,'\\','\\\\');
    4490 %     cmd_CIV2=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx"'];
    4491 %     cmd_CIV2=[cmd_CIV2 '\n "' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f "' filename  '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file
    4492 %     cmd_CIV2=[cmd_CIV2 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"'];
    4493 %  %    cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.checkciv2.cmx"'];
    4494 % end
    4495 
     3741
     3742%------------------------------------------------------------------------
     3743% --- STEREO Interp
     3744function cmd=RUN_STINTERP(stinterpBin,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB)
     3745%------------------------------------------------------------------------
     3746namelog=[filename_nc(1:end-3) '_stinterp.log'];
     3747cmd=[stinterpBin ' -f1 ' filename_A_nc  ' -f2 ' filename_B_nc ' -f  ' filename_nc ...
     3748    ' -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
    44963749
    44973750%------------------------------------------------------------------------
     
    45173770end
    45183771
    4519 %------------------------------------------------------------------------
    4520 function ref_i_Callback(hObject, eventdata, handles)
    4521 %------------------------------------------------------------------------
    4522 mode_list=get(handles.ListPairMode,'String');
    4523 mode_value=get(handles.ListPairMode,'Value');
    4524 mode=mode_list{mode_value};
    4525 find_netcpair_civ1(handles);% update the menu of pairs depending on the available netcdf files
    4526 if isequal(mode,'series(Di)') || ...% we do patch2 only
    4527         (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0)
    4528     find_netcpair_civ2( handles);
    4529 end
    4530 
    4531 %------------------------------------------------------------------------
    4532 function ref_j_Callback(hObject, eventdata, handles)
    4533 %------------------------------------------------------------------------
    4534 mode_list=get(handles.ListPairMode,'String');
    4535 mode_value=get(handles.ListPairMode,'Value');
    4536 mode=mode_list{mode_value};
    4537 if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)')
    4538     find_netcpair_civ1(handles);% update the menu of pairs depending on the available netcdf files
    4539 end
    4540 if isequal(mode,'series(Dj)') || ...
    4541         (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0)
    4542     find_netcpair_civ2(handles);
    4543 end
    4544 %
    4545 % %------------------------------------------------------------------------
    4546 % function ref_i_civ2_Callback(hObject, eventdata, handles)
    4547 % %------------------------------------------------------------------------
    4548 % % mode_list=get(handles.ListPairMode,'String');
    4549 % % mode_value=get(handles.ListPairMode,'Value');
    4550 % % mode=mode_list{mode_value};
    4551 % find_netcpair_civ2(handles);% update the menu of pairs depending on the available netcdf files
    4552 %
    4553 % %------------------------------------------------------------------------
    4554 % function ref_j_civ2_Callback(hObject, eventdata, handles)
    4555 % %------------------------------------------------------------------------
    4556 % % mode_list=get(handles.ListPairMode,'String');
    4557 % % mode_value=get(handles.ListPairMode,'Value');
    4558 % % mode=mode_list{mode_value};
    4559 % if  isequal(mode,'series(Dj)')
    4560 %     find_netcpair_civ2(handles);% update the menu of pairs depending on the available netcdf files
    4561 % end
    4562 
    4563 %------------------------------------------------------------------------
    4564 % --- Executes on button press in ListCompareMode.
    4565 function ListCompareMode_Callback(hObject, eventdata, handles)
    4566 %------------------------------------------------------------------------
    4567 test=get(handles.ListCompareMode,'Value');
    4568 if test==2 || test==3 % case 'dispalcemen' or 'stereo PIV'
    4569     filebase=get(handles.RootName,'String');
    4570     browse=get(handlesRootName,'Userdata');
    4571     browse.nom_type_ima1=browse.nom_type_ima;
    4572     set(handlesRootName,'UserData',browse);
    4573     set(handles.sub_txt,'Visible','on')
    4574     set(handles.RootName_1,'Visible','On');%mkes the second file input window visible
    4575     mode_store=get(handles.ListPairMode,'String');%get the present 'mode'
    4576     set(handles.ListCompareMode,'UserData',mode_store);%store the mode display
    4577     set(handles.ListPairMode,'Visible','off')
    4578     if test==2
    4579         set(handles.ListPairMode,'Visible','off')
    4580         set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default
    4581     else
    4582         set(handles.ListPairMode,'Visible','on')
    4583         set(handles.ListPairMode,'Value',3) % mode 'Matlab' selected for stereo
    4584     end
    4585    
    4586     %% menuopen an image file with the browser
    4587     ind_opening=1;%default
    4588     browse.incr_pair=[0 0]; %default
    4589     oldfile=get(handles.RootName,'String');
    4590      menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)';
    4591        '*.xml',  '.xml files '; ...
    4592         '*.civ',  '.civ files '; ...
    4593         '*.png','.png image files'; ...
    4594         '*.jpg',' jpeg image files'; ...
    4595         '*.tif','.tif image files'; ...
    4596         '*.avi;*.AVI','.avi movie files'; ...
    4597         '*.nc','.netcdf files'; ...
    4598         '*.*',  'All Files (*.*)'};
    4599     [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile);
    4600     fileinput=[PathName FileName];%complete file name
    4601     sizf=size(fileinput);
    4602     if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
    4603     [path,name,ext]=fileparts(fileinput);
    4604     [path1]=fileparts(filebase);
    4605     if isunix
    4606         [status,path]=system(['readlink ' path]);
    4607         [status,path1]=system(['readlink ' path1]);% look for the true path in case of symbolic paths
    4608     end
    4609     if ~strcmp(path1,path)
    4610         msgbox_uvmat('ERROR','The second image series must be in the same directory as the first one')
    4611         return
    4612      end
    4613 %     set(handles.RootName_1,'String',name);
    4614     [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name);
    4615     set(handles.RootName_1,'String',RootFile);
    4616     browse=get(handlesRootName,'UserData');
    4617     browse.nom_type_ima_1=nom_type;
    4618     set(handlesRootName,'UserData',browse)
    4619    
    4620     %check image extension
    4621     if ~strcmp(ext,get(handles.ImaExt,'String'))
    4622         msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one')
    4623         return
    4624     end
    4625    
    4626     %% check coincidence of image sizes
    4627 %     ref_i=get(handles.ref_i,'string');
    4628 %     ref_j=get(handles.ref_j,'string');
    4629 %     [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]);
    4630 %     A=imread(filecell.ima1.checkciv1{1});
    4631 %     A_1=imread(fileinput);
    4632 %     npxy=size(A);
    4633 %     npxy_1=size(A_1);
    4634 %     if ~isequal(size(A),size(A_1))
    4635 %         msgbox_uvmat('ERROR','The two input image series do not have the same size')
    4636 %         return
    4637 %     end
    4638 else
    4639     set(handles.ListPairMode,'Visible','on')
    4640     set(handles.RootName_1,'Visible','Off');
    4641     set(handles.sub_txt,'Visible','off')
    4642     set(handles.RootName_1,'String',[]);
    4643     mode_store=get(handles.ListCompareMode,'UserData');
    4644     set(handles.ListPairMode,'Value',1)
    4645     set(handles.ListPairMode,'String',mode_store)
    4646     set(handles.test_stereo1,'Value',0)
    4647     set(handles.CheckStereo,'Value',0)
    4648     set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default
    4649 end
    4650 if test==3 && get(handles.CheckPatch1,'Value')
    4651     set(handles.test_stereo1,'Visible','on')
    4652 else
    4653     set(handles.test_stereo1,'Visible','off')
    4654 end
    4655 if test==3 && get(handles.CheckPatch2,'Value')
    4656     set(handles.CheckStereo,'Visible','on')
    4657 else
    4658     set(handles.CheckStereo,'Visible','off')
    4659 end
    4660 mode_Callback(hObject, eventdata, handles)
    46613772
    46623773%------------------------------------------------------------------------
     
    47993910
    48003911%------------------------------------------------------------------------
    4801 % --- Executes on button press in check_Threshold.
    4802 function ImaThreshold_Callback(hObject, eventdata, handles)
    4803 %------------------------------------------------------------------------
    4804 if isequal(get(handles.check_Threshold,'Value'),1)
    4805     set(handles.num_MinIma,'Visible','on')
    4806     set(handles.num_MaxIma,'Visible','on')
    4807 else
    4808     set(handles.num_MinIma,'Visible','off')
    4809     set(handles.num_MaxIma,'Visible','off')
    4810 end
    4811 
    4812 %------------------------------------------------------------------------
    4813 % --- Executes on button press in ImaThreshold2.
    4814 function ImaThreshold2_Callback(hObject, eventdata, handles)
    4815 %------------------------------------------------------------------------
    4816 if isequal(get(handles.ImaThreshold2,'Value'),1)
    4817     set(handles.num_MinIma,'Visible','on')
    4818     set(handles.num_MaxIma,'Visible','on')
    4819 else
    4820     set(handles.num_MinIma,'Visible','off')
    4821     set(handles.num_MaxIma,'Visible','off')
    4822 end
    4823 
    4824 %------------------------------------------------------------------------
    48253912% --- Executes on button press in TestCiv1: display image correlation function
    48263913function TestCiv1_Callback(hObject, eventdata, handles)
     
    48283915set(handles.TestCiv1,'BackgroundColor',[1 1 0])
    48293916drawnow
    4830 test_civ1=get(handles.TestCiv1,'Value');
    4831 if test_civ1
     3917if get(handles.TestCiv1,'Value')
    48323918    ref_i=str2double(get(handles.ref_i,'String'));
    48333919    if strcmp(get(handles.ref_j,'Visible'),'on')
     
    48433929    Data.ny=[size(Data.A,1) 1];
    48443930    Data.nx=[1 size(Data.A,2)];
    4845     par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1});
     3931    par_civ1=read_GUI(handles.Civ1);
    48463932    par_civ1.filename_ima_a=filecell.ima1.civ1{1};
    48473933    par_civ1.filename_ima_b=filecell.ima2.civ1{1};
     
    48843970end
    48853971
     3972%-------------------------------------------------------------------
     3973% ---
    48863974function closeview_field(gcbo,eventdata)
    48873975hview_field=findobj(allchild(0),'tag','view_field');% look for view_field   
     
    48893977        delete(hview_field)
    48903978    end
    4891 %-------------------------------------------------------------------
    4892 % --- Executes on button press in status.
    4893 function status_Callback(hObject, eventdata, handles)
    4894 %-------------------------------------------------------------------
    4895 val=get(handles.status,'Value');
    4896 if val==0
    4897     set(handles.status,'BackgroundColor',[0 1 0])
    4898     hfig=findobj(allchild(0),'name','civ_status');
    4899     if ~isempty(hfig)
    4900         delete(hfig)
    4901     end
    4902     return
    4903 end
    4904 set(handles.status,'BackgroundColor',[1 1 0])
    4905 drawnow
    4906 listtype={'civ1','fix1','patch1','civ2','fix2','patch2'};
    4907 Param.CheckCiv1=get(handles.CheckCiv1,'Value');
    4908 Param.CheckFix1=get(handles.CheckFix1,'Value');
    4909 Param.CheckPatch1=get(handles.CheckPatch1,'Value');
    4910 Param.CheckCiv2=get(handles.CheckCiv2,'Value');
    4911 Param.CheckFix2=get(handles.CheckFix2,'Value');
    4912 Param.CheckPatch2=get(handles.CheckPatch2,'Value');
    4913 box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2];
    4914 
    4915 option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test)
    4916 filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV
    4917 test_new=0;
    4918 if ~isfield(filecell,'nc')
    4919     test_new=1;
    4920     [ref_i,ref_j,errormsg]=find_ref_indices(handles);
    4921     if ~isempty(errormsg)
    4922         msgbox_uvmat('ERROR',errormsg)
    4923         return
    4924     end
    4925     filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status
    4926 end
    4927 if ~isequal(box_test(4:6),[0 0 0])
    4928     civ_files=filecell.nc.civ2;%case of civ2 operations
    4929 else
    4930     civ_files=filecell.nc.civ1;
    4931 end
    4932 [root,filename,ext]=fileparts(civ_files{1});
    4933 [rootroot,subdir,extdir]=fileparts(root);
    4934 hfig=findobj(allchild(0),'name','civ_status');
    4935 if isempty(hfig)
    4936     hfig=figure('DeleteFcn',@stop_status);
    4937     set(hfig,'name','civ_status')
    4938     hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list');
    4939     uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...');
    4940     uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
    4941     uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','OK','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI);
    4942     BarPosition=[0.05 0.81 0.01 0.05];
    4943     hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');
    4944     drawnow
    4945 end
    4946 % datnum=[];
    4947 Tabchar={};
    4948 nbfiles=numel(civ_files);
    4949 count=0;
    4950 testrecent=0;
    4951 while count<nbfiles
    4952     count=0;
    4953     datnum=zeros(1,nbfiles);
    4954     for ifile=1:nbfiles
    4955         detect=exist(civ_files{ifile},'file'); % check the existence of the file
    4956         option=0;
    4957         if detect==0
    4958             option_str='not created';
    4959         else
    4960             datfile=dir(civ_files{ifile});
    4961             if isfield(datfile,'datenum')
    4962                 datnum(ifile)=datfile.datenum;%only available in recent matlab versions
    4963                 testrecent=1;
    4964             end
    4965             filefound(ifile)={datfile.name};
    4966             lastfield='';
    4967             % check the content  netcdf file
    4968             Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix');
    4969             if ~isempty(Data.patch2) && isequal(Data.patch2,1)
    4970                 option=6;
    4971                 option_str='patch2';
    4972             elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
    4973                 option=5;
    4974                 option_str='fix2';
    4975             elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
    4976                 option=4;
    4977                 option_str='civ2';
    4978             elseif ~isempty(Data.patch) && isequal(Data.patch,1);
    4979                 option=3;
    4980                 option_str='patch1';
    4981             elseif ~isempty(Data.fix) && isequal(Data.fix,1);
    4982                 option=2;
    4983                 option_str='fix1';
    4984             else
    4985                 option=1;
    4986                 option_str='civ1';
    4987             end
    4988         end
    4989         if option >= option_civ
    4990             count=count+1;
    4991         end
    4992         [rr,filename,ext]=fileparts(civ_files{ifile});
    4993         Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext  '...' option_str];
    4994     end
    4995     datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
    4996     if isempty(datnum)
    4997         if testrecent
    4998             message='no civ result created yet';
    4999         else
    5000             message='';
    5001         end
    5002     else
    5003         datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
    5004         [first,ind]=min(datnum);
    5005         [last,indlast]=max(datnum);
    5006         if test_new
    5007             message='existing file status, no processing launched yet';
    5008         else
    5009         message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
    5010             ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
    5011         end
    5012     end
    5013     hfig=findobj(allchild(0),'name','civ_status');
    5014     if isempty(hfig)% the status list has been deleted
    5015         return
    5016     else
    5017         hlist=findobj(hfig,'tag','list');
    5018         hmsgbox=findobj(hfig,'tag','msgbox');
    5019         hwaitbar=findobj(hfig,'tag','waitbar');
    5020         set(hlist,'String',Tabchar)
    5021         set(hmsgbox,'String', message)
    5022         if count>0 && ~test_new
    5023             BarPosition(3)=0.9*count/nbfiles;
    5024             set(hwaitbar,'Position',BarPosition)
    5025         end
    5026     end
    5027     set(hlist,'UserData',rootroot)
    5028     pause(10)% wait 10 seconds for next check
    5029 end
    5030 
     3979   
    50313980   
    50323981%------------------------------------------------------------------------   
     
    50704019% prog=Listprog{index};
    50714020% switch prog
    5072 %     case 'CivX'
     4021%     case 'MenuCivX'
    50734022%         set(handles.thresh_patch1,'Visible','off')
    50744023%         set(handles.thresh_text1,'Visible','off')
     
    50914040
    50924041
    5093 % --------------------------------------------------------------------
    5094 function MenuHelp_Callback(hObject, eventdata, handles)
    5095 path_civ=fileparts(which ('civ'));
    5096 helpfile=fullfile(path_civ,'uvmat_doc','uvmat_doc.html');
    5097 if isempty(dir(helpfile))
    5098     msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
    5099 else
    5100     addpath (fullfile(path_civ,'uvmat_doc'))
    5101     web([helpfile '#civ'])
    5102 end
    5103 
    5104 % --------------------------------------------------------------------
    5105 function CivX_Callback(hObject, eventdata, handles)
    5106 %set(handles.thresh_patch1,'Visible','off')
    5107 set(handles.thresh_text1,'Visible','off')
    5108 set(handles.num_MaxDiff,'Visible','off')
    5109 set(handles.thresh_text2,'Visible','off')
    5110 set(handles.num_Rho,'Style','edit')
    5111 set(handles.num_Rho,'String','1')
    5112 set(handles.BATCH,'Enable','on')
    5113 
    5114 % --------------------------------------------------------------------
    5115 function Matlab_Callback(hObject, eventdata, handles)
    5116 set(handles.Matlab,'checked','on')
    5117 set(handles.CivX,'checked','off')
    5118 if get(handles.CheckPatch1,'Value')
    5119     set(handles.thresh_patch1,'Visible','on')
    5120     set(handles.thresh_text1,'Visible','on')
    5121 end
    5122 if get(handles.CheckPatch2,'Value')
    5123     set(handles.num_MaxDiff,'Visible','on')
    5124     set(handles.thresh_text2,'Visible','on')
    5125 end
    5126 set(handles.num_Rho,'Style','popupmenu')
    5127 set(handles.num_Rho,'Value',1)
    5128 set(handles.num_Rho,'String',{'1';'2'})
    5129 set(handles.BATCH,'Enable','off')
    5130 
    5131 % --------------------------------------------------------------------
    5132 % --- read a panel with handle 'handle' producing a structure 'struct'
    5133 function struct=read_panel(handle)
    5134 hchild=get(handle,'children');
    5135 for ichild=1:numel(hchild)
    5136     if strcmp(get(hchild(ichild),'Visible'),'on')
    5137         object_style=get(hchild(ichild),'Style');
    5138         tag=get(hchild(ichild),'tag');
    5139         check_input=1;%default
    5140         switch object_style
    5141             case 'edit'
    5142                 switch(tag(1:4))
    5143                     case 'num_'
    5144                         input=str2double(get(hchild(ichild),'String'));
    5145                         %deal with undefined input: retrieve the default value stored as UserData
    5146                         if isnan(input)
    5147                             input=get(hchild(ichild),'UserData');
    5148                             set(hchild(ichild),'String',num2str(input))
    5149                         end
    5150                     case 'txt_'
    5151                         input=get(hchild(ichild),'String');
    5152                 end
    5153                 key=tag(5:end);
    5154             case 'checkbox'
    5155                 input=get(hchild(ichild),'Value');
    5156                 key=tag(7:end);
    5157             otherwise
    5158                 check_input=0;
    5159         end
    5160         if check_input
    5161             eval(['struct.' key '=input;'])
    5162         end
    5163     end
    5164 end
    5165 
    5166 
    5167 
     4042
     4043
     4044%------------------------------------------------------------------------
    51684045function cmd=cmd_civ1(filename,Param)
    5169 %TODO : include filename in par_civ1
    51704046%------------------------------------------------------------------------
    51714047%pixels per cm and matrix of the image times, read from the .civ file by uvmat
    5172 
    51734048%changes : filename_cmx -> filename ( no extension )
    5174 
    5175 filename=regexprep(filename,'.nc','');
    5176 
     4049filename=regexprep(filename,'.nc',''); %file name for the result
     4050Param.Civ1
    51774051if isequal(Param.Civ1.Dt,'0')
    51784052    Param.Civ1.Dt='1' ;%case of 'displacement' mode
     
    51874061fprintf(fid,  ['Mask ' Param.Civ1.MaskFlag '\n' ]);
    51884062fprintf(fid,  ['MaskName ' regexprep(Param.Civ1.MaskName,'\\','\\\\') '\n' ]);
    5189 fprintf(fid,   ['ImageSize ' num2str(Param.Civ1.npx) ' ' num2str(Param.Civ1.npy) '\n' ]);   %VERIFIER CAS GENERAL ?
     4063fprintf(fid,   ['ImageSize ' num2str(Param.Civ1.ImageInfo.Width) ' ' num2str(Param.Civ1.ImageInfo.Height) '\n' ]);   %VERIFIER CAS GENERAL ?
    51904064fprintf(fid,   ['CorrelationBoxesSize ' num2str(Param.Civ1.Bx) ' ' num2str(Param.Civ1.By) '\n' ]);
    51914065fprintf(fid,   ['SearchBoxeSize ' num2str(Param.Civ1.Searchx) ' ' num2str(Param.Civ1.Searchy) '\n' ]);
     
    52074081fprintf(fid,  ['CorrelationMin 0' '\n' ]);
    52084082fprintf(fid,   ['IntensityMin 0' '\n' ]);
    5209 fprintf(fid,  ['SeuilImage n' '\n' ]);
    5210 fprintf(fid,   ['SeuilImageValues 0 4096' '\n' ]);
     4083if ~isfield(Param.Civ1,'MinIma')% Image threshold not activated
     4084    fprintf(fid,  ['SeuilImage n' '\n' ]);
     4085    fprintf(fid,   ['SeuilImageValues 0 4096' '\n' ]);%not used in principle
     4086else% Image threshold  activated
     4087    if isempty(Param.Civ1.MaxIma)||isnan(Param.Civ1.MaxIma)
     4088        Param.Civ1.MaxIma=2^Param.Civ1.ImageInfo.BitDepth;%take the max image value as upper bound by default
     4089    end
     4090    fprintf(fid,  ['SeuilImage y' '\n' ]);
     4091    fprintf(fid,   ['SeuilImageValues ' num2str(Param.Civ1.MinIma) ' ' num2str(Param.Civ1.MaxIma) '\n' ]);
     4092end
    52114093fprintf(fid,   ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ?
    52124094fprintf(fid,   ['ImageUsedBefore null null' '\n' ]);
    52134095fclose(fid);
    52144096
    5215 % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file
    5216 % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\');
    5217 % namelog=regexprep(namelog,'\\','\\\\');
    5218 if(isunix)
     4097if(isunix) %unix (or Mac) system
    52194098    cmd=['cp -f ' filename '.civ1.cmx ' filename '.cmx \n '];% the cmx file gives the name to the nc file
    52204099    cmd=[cmd Param.xml.Civ1Bin ' -f ' filename '.cmx >' filename '.civ1.log \n ' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx
    5221 %     cmd=[cmd '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting
    5222 %    cmd=[cmd '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx
    52234100    cmd=[cmd 'rm ' filename '.cmx'];
    52244101else %Windows system
     
    52274104    cmd=[cmd '"' regexprep(Param.xml.Civ1Bin,'\\','\\\\')...
    52284105        '" -f "' filename '.cmx" >"' filename '.civ1.log" \n ' ]; % redirect standard output to the log file
    5229 %     namelog=regexprep(namelog,'\\','\\\\');
    5230 %     cmd=[cmd '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log
    52314106    cmd=[cmd 'del "' filename '.cmx"'];
    52324107end
     
    52414116        fi2_value=num2str(Param.(fixname).CheckF4);%need to understand why...
    52424117end
    5243 
    5244 
    5245 
    52464118filename=regexprep(filename,'.nc','');
    52474119MaskName_string='';%default
     
    52704142%% ------------------------------------------------------------------------
    52714143filename=regexprep(filename,'.nc','');
    5272 % if test_interp==0
    52734144if isunix
    52744145    cmd=[Param.xml.PatchBin...
     
    52854156    cmd=regexprep(cmd,'\\','\\\\');
    52864157end
    5287 % else %nouveau programme patch
    5288 %     cmd=[PatchBin ' -f ' filename_nc ' -m ' nx_patch  ' -n ' ny_patch ' -ro ' rho_patch ...
    5289 %         ' -max ' thresh_value ' -nopt ' subdomain_patch  '  > ' namelog ' 2>&1']; % redirect standard output to the log file
    5290 % end
    5291 
    52924158
    52934159%------------------------------------------------------------------------
     
    53154181fprintf(fid, ['Mask ' Param.Civ2.MaskFlag '\n' ]);
    53164182fprintf(fid, ['MaskName ' regexprep(Param.Civ2.MaskName,'\\','\\\\') '\n' ]);% for windows compatibility
    5317 fprintf(fid, ['ImageSize ' num2str(Param.Civ2.npx) ' ' num2str(Param.Civ2.npy) '\n' ]);   %VERIFIER CAS GENERAL ?
     4183fprintf(fid,   ['ImageSize ' num2str(Param.Civ2.ImageInfo.Width) ' ' num2str(Param.Civ2.ImageInfo.Height) '\n' ]); 
     4184% fprintf(fid, ['ImageSize ' num2str(Param.Civ2.npx) ' ' num2str(Param.Civ2.npy) '\n' ]);   %VERIFIER CAS GENERAL ?
    53184185fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n' ]);
    53194186fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n']);
     
    53354202fprintf(fid,  ['CorrelationMin 0' '\n' ]);
    53364203fprintf(fid,   ['IntensityMin 0' '\n' ]);
    5337 fprintf(fid,  ['SeuilImage n' '\n' ]);
    5338 fprintf(fid,   ['SeuilImageValues 0 4096' '\n' ]);
     4204
     4205if ~isfield(Param.Civ2,'MinIma')% Image threshold not activated
     4206    fprintf(fid,  ['SeuilImage n' '\n' ]);
     4207    fprintf(fid,   ['SeuilImageValues 0 4096' '\n' ]);%not used in principle
     4208else% Image threshold  activated
     4209    if isempty(Param.Civ2.MaxIma)||isnan(Param.Civ2.MaxIma)
     4210        Param.Civ2.MaxIma=2^Param.Civ2.ImageInfo.BitDepth;%take the max image value as upper bound by default
     4211    end
     4212    fprintf(fid,  ['SeuilImage y' '\n' ]);
     4213    fprintf(fid,   ['SeuilImageValues ' num2str(Param.Civ2.MinIma) ' ' num2str(Param.Civ2.MaxIma) '\n' ]);
     4214end
    53394215fprintf(fid,   ['ImageToUse ' Param.Civ2.term_a ' ' Param.Civ2.term_b '\n' ]); % VERIFIER ?
    53404216fprintf(fid, ['ImageUsedBefore ' regexprep(Param.Civ2.filename_nc1,'\\','\\\\') '\n']);
     
    53514227        'del "' filename '.cmx" \n'];
    53524228end
     4229
     4230%------------------------------------------------------------------------
     4231% --- Executes on button press in CheckThreshold.
     4232function CheckThreshold_Callback(hObject, eventdata, handles)
     4233%------------------------------------------------------------------------
     4234huipanel=get(hObject,'parent');
     4235obj(1)=findobj(huipanel,'Tag','num_MinIma');
     4236obj(2)=findobj(huipanel,'Tag','num_MaxIma');
     4237obj(3)=findobj(huipanel,'Tag','title_Threshold');
     4238if get(hObject,'Value')
     4239    set(obj,'Visible','on')
     4240else
     4241    set(obj,'Visible','off')
     4242end
     4243
     4244%------------------------------------------------------------------------
     4245% --- CheckCiv1  Unified: TO ABADON
     4246function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par)
     4247%------------------------------------------------------------------------
     4248%pixels per cm and matrix of the image times, read from the .civ file by uvmat
     4249%global CivBin%name of the executable for checkciv1 calculation
     4250
     4251civ1.image1=par.filename_ima_a;
     4252civ1.image2=par.filename_ima_b;
     4253civ1.imageSize_X=par.npx;
     4254civ1.imageSize_Y=par.npy;
     4255civ1.outputFileName=[filename '.nc'];
     4256civ1.correlationBoxesSize_X=par.ibx;
     4257civ1.correlationBoxesSize_Y=par.iby;
     4258civ1.searchBoxesSize_X=par.isx;
     4259civ1.searchBoxesSize_Y=par.isy;
     4260civ1.globalShift_X=par.shiftx;
     4261civ1.globalShift_Y=par.shifty;
     4262civ1.ro=par.rho;
     4263civ1.hart='y';
     4264if isequal(par.gridflag,'y')
     4265    civ1.grid=par.gridname;
     4266else
     4267    civ1.grid='n';
     4268    civ1.gridSpacing_X=par.dx;
     4269    civ1.gridSpacing_Y=par.dy;
     4270end
     4271if isequal(par.maskflag,'y')
     4272    civ1.mask=par.maskname;
     4273end
     4274civ1.dt=par.Dt;
     4275civ1.unit='pixel';
     4276civ1.absolut_time_T0=par.T0;
     4277civ1.pixcmx=par.pxcmx;
     4278civ1.pixcmy=par.pxcmy;
     4279civ1.convectFlow='n';
     4280
     4281xml_civ1_parameters=civ1;
     4282
     4283%------------------------------------------------------------------------
     4284% --- CheckCiv2  Unified: TO ABADON
     4285function civ2=CIV2_CMD_Unified(filename,namelog,par)
     4286%------------------------------------------------------------------------
     4287%pixels per cm and matrix of the image times, read from the .civ file by uvmat
     4288%global CivBin%name of the executable for checkciv1 calculation
     4289
     4290filename=regexprep(filename,'.nc','');
     4291
     4292civ2.image1=par.filename_ima_a;
     4293civ2.image2=par.filename_ima_b;
     4294civ2.imageSize_X=par.npx;
     4295civ2.imageSize_Y=par.npy;
     4296civ2.inputFileName=[par.filename_nc1 '.nc'];
     4297civ2.outputFileName=[filename '.nc'];
     4298civ2.correlationBoxesSize_X=par.ibx;
     4299civ2.correlationBoxesSize_Y=par.iby;
     4300civ2.ro=par.rho;
     4301%checkciv2.decimalShift=par.CheckDecimal;
     4302%checkciv2.CheckDeformation=par.CheckDeformation;
     4303if isequal(par.decimal,'1')
     4304    civ2.decimalShift='y';
     4305else
     4306    civ2.decimalShift='n';
     4307end
     4308if isequal(par.deformation,'1')
     4309    civ2.deformation='y';
     4310else
     4311    civ2.deformation='n';
     4312end
     4313if isequal(par.gridflag,'y')
     4314    civ2.grid=par.gridname;
     4315else
     4316    civ2.grid='n';
     4317    civ2.gridSpacing_X=par.dx;
     4318    civ2.gridSpacing_Y=par.dy;
     4319end
     4320civ2.gridSpacing_X='10';
     4321civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee
     4322if isequal(par.maskflag,'y')
     4323    civ2.mask=par.maskname;
     4324else
     4325    civ2.mask='n';
     4326end
     4327civ2.dt=par.Dt;
     4328civ2.unit='pixel';
     4329civ2.absolut_time_T0=par.T0;
     4330civ2.pixcmx=par.pxcmx;
     4331civ2.pixcmy=par.pxcmy;
     4332civ2.convectFlow='n';
     4333civ2.pixcmx=par.pxcmx;
     4334civ2.pixcmy=par.pxcmy;
     4335civ2.convectFlow='n';
  • trunk/src/civ_uvmat.m

    r273 r309  
    1 % To develop....
    2 function [Data,errormsg]= civ_uvmat(Param,ncfile)
     1%'civ_matlab': Matlab version of the PIV programs CivX
     2% --- call the sub-functions:
     3%   civ: PIV function itself
     4%   fix: removes false vectors after detection by various criteria
     5%   patch: make interpolation-smoothing
     6%------------------------------------------------------------------------
     7% function [Data,errormsg,result_conv]= civ_uvmat(Param,ncfile)
     8%
     9%OUTPUT
     10% Data=structure containing the PIV results and information on the processing parameters
     11% errormsg=error message char string, default=''
     12% resul_conv: image inter-correlation function for the last grid point (used for tests)
     13%
     14%INPUT:
     15% Param: input images and processing parameters
     16% ncfile: name of a netcdf file to be created for the result (extension .nc)
     17%
     18%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
     19%  Copyright  2011, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr.
     20%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
     21%     This is part of the toolbox UVMAT.
     22%
     23%     UVMAT is free software; you can redistribute it and/or modify
     24%     it under the terms of the GNU General Public License as published by
     25%     the Free Software Foundation; either version 2 of the License, or
     26%     (at your option) any later version.
     27%
     28%     UVMAT is distributed in the hope that it will be useful,
     29%     but WITHOUT ANY WARRANTY; without even the implied warranty of
     30%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     31%     GNU General Public License (open UVMAT/COPYING.txt) for more details.
     32%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
     33
     34function [Data,errormsg,result_conv]= civ_uvmat(Param,ncfile)
    335errormsg='';
    436Data.ListGlobalAttribute={'Conventions','Program','CivStage'};
     
    2052    image1=imread(par_civ1.filename_ima_a);
    2153    image2=imread(par_civ1.filename_ima_b);
    22     stepx=str2num(par_civ1.dx);
    23     stepy=str2num(par_civ1.dy);
    24     ibx2=ceil(str2num(par_civ1.ibx)/2);
    25     iby2=ceil(str2num(par_civ1.iby)/2);
    26     isx2=ceil(str2num(par_civ1.isx)/2);
    27     isy2=ceil(str2num(par_civ1.isy)/2);
    28     shiftx=str2num(par_civ1.shiftx);
    29     shifty=str2num(par_civ1.shifty);
     54    ibx2=ceil(par_civ1.Bx/2);
     55    iby2=ceil(par_civ1.By/2);
     56    isx2=ceil(par_civ1.Searchx/2);
     57    isy2=ceil(par_civ1.Searchy/2);
     58    shiftx=par_civ1.Shiftx;
     59    shifty=par_civ1.Shifty;
    3060    miniy=max(1+isy2+shifty,1+iby2);
    3161    minix=max(1+isx2-shiftx,1+ibx2);
    3262    maxiy=min(size(image1,1)-isy2+shifty,size(image1,1)-iby2);
    3363    maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2);
    34     [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy);
    35     PointCoord(:,1)=reshape(GridX,[],1);
    36     PointCoord(:,2)=reshape(GridY,[],1);
    37     if isfield(par_civ1,'maskname') && ~isempty(par_civ1.maskname) && ~isequal(par_civ1.maskname,'noFile use default')
    38         maskname=par_civ1.maskname;
     64    if ~isfield(par_civ1,'PointCoord')   
     65        [GridX,GridY]=meshgrid(minix:par_civ1.Dx:maxix,miniy:par_civ1.Dy:maxiy);
     66        par_civ1.PointCoord(:,1)=reshape(GridX,[],1);
     67        par_civ1.PointCoord(:,2)=reshape(GridY,[],1);
     68    end
     69    if par_civ1.CheckMask && isfield(par_civ1,'MaskName') && ~isempty(par_civ1.MaskName)
     70        maskname=par_civ1.MaskName;
    3971        mask=imread(maskname);
    4072    end
    4173    % caluclate velocity data (y and v in indices, reverse to y component)
    42     [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,-shifty,PointCoord,str2num(par_civ1.rho), mask);
     74    [xtable ytable utable vtable ctable F result_conv errormsg] = civ (image1,image2,ibx2,iby2,isx2,isy2,shiftx,-shifty,par_civ1.PointCoord,par_civ1.Rho, mask);
    4375    list_param=(fieldnames(par_civ1))';
    4476    list_remove={'pxcmx','pxcmy','npx','npy','gridflag','maskflag','term_a','term_b','T0'};
    45     index=zeros(size(list_param));
    46     for ilist=1:length(list_remove)
    47         index=strcmp(list_remove{ilist},list_param);
    48         if ~isempty(find(index,1))
    49             list_param(index)=[];
    50         end
    51     end
     77    index_remove=zeros(size(list_param));
     78    for name=list_remove %loop on the list of names
     79        index_remove=index_remove +strcmp(name{1},list_param);%index of the current name = name{1}
     80    end
     81    list_param(find(index_remove,1))=[];
     82    Civ1_param=list_param;%initialisation
    5283    for ilist=1:length(list_param)
    5384        Civ1_param{ilist}=['Civ1_' list_param{ilist}];
    54         eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';'])
     85        Data.(['Civ1_' list_param{ilist}])=par_civ1.(list_param{ilist});
    5586    end
    5687    if isfield(Data,'Civ1_gridname') && strcmp(Data.Civ1_gridname(1:6),'noFile')
     
    96127
    97128%% Fix1
     129%                 if Param.CheckCiv1==1
     130%                     Param.Civ1=Param.Civ1;
     131%                 end
     132%                 if Param.CheckFix1==1
     133%                     Param.Fix1=Param.Fix1;
     134%                     fix1.WarnFlags=[];
     135%                     if get(handles.CheckFmin2,'Value')
     136%                         fix1.WarnFlags=[fix1.WarnFlags -2];
     137%                     end
     138%                     if get(handles.CheckF3,'Value')
     139%                         fix1.WarnFlags=[fix1.WarnFlags 3];
     140%                     end
     141%                     fix1.LowerBoundCorr=thresh_vecC1;
     142%                     if get(handles.num_MinVel,'Value')
     143%                         fix1.UppperBoundVel=thresh_vel1;
     144%                     else
     145%                         fix1.LowerBoundVel=thresh_vel1;
     146%                     end
     147%                     if get(handles.CheckMask,'Value')
     148%                         fix1.MaskName=maskname;
     149%                     end
     150%                     Param.Fix1=fix1;
     151%                 end
     152%                 if Param.CheckPatch1==1
     153%                     if strcmp(compare,'stereo PIV')
     154%                         filebase_A=filecell.filebase;
     155%                         [pp,ff]=fileparts(filebase_A);
     156%                         filebase_B=fullfile(pp,get(handles.RootName_1,'String'));
     157%                         %TO CHECK: filecell.nc.civ1{ifile,j},filecell.ncA.civ1{ifile,j} have been switched according to Matias Duran
     158%                         RUN_STLIN(filecell.nc.civ1{ifile,j},filecell.ncA.civ1{ifile,j},'civ1',filecell.st{ifile,j},...
     159%                             str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml'])
     160%                     else
     161%                         Param.Patch1.Rho=rho_patch1;
     162%                         Param.Patch1.Threshold=thresh_patch1;
     163%                         Param.Patch1.SubDomain=subdomain_patch1;
     164%                     end
     165%                 end
     166%                 if Param.CheckCiv2==1
     167%                     Param.Civ2=Param.Civ2;
     168%                 end
     169%                 if Param.CheckFix2==1
     170%                     fix2.WarnFlags=[];
     171%                     if get(handles.CheckFmin2,'Value')
     172%                         fix2.WarnFlags=[fix2.WarnFlags -2];
     173%                     end
     174%                     if get(handles.CheckF4,'Value')
     175%                         fix2.WarnFlags=[fix2.WarnFlags 4];
     176%                     end
     177%                     if get(handles.CheckF3,'Value')
     178%                         fix2.WarnFlags=[fix2.WarnFlags 3];
     179%                     end
     180%                     fix2.LowerBoundCorr=thresh_vec2C;
     181%                     if get(handles.num_MinVel,'Value')
     182%                         fix2.UppperBoundVel=thresh_vel2;
     183%                     else
     184%                         fix2.LowerBoundVel=thresh_vel2;
     185%                     end
     186%                     if get(handles.CheckMask,'Value')
     187%                         fix2.MaskName=maskname;
     188%                     end
     189%                     Param.Fix2=fix2;
     190%                 end
     191%                 if Param.CheckPatch2==1
     192%                     if strcmp(compare,'stereo PIV')
     193%                         filebase_A=filecell.filebase;
     194%                         [pp,ff]=fileparts(filebase_A);
     195%                         filebase_B=fullfile(pp,get(handles.RootName_1,'String'));
     196%                         RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},...
     197%                             str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml'])
     198%                     else
     199%                         Param.Patch2.Rho=rho_patch2;
     200%                         Param.Patch2.Threshold=thresh_patch2;
     201%                         Param.Patch2.SubDomain=subdomain_patch2;
     202%                     end
     203%                 end
     204
    98205if isfield (Param,'Fix1')
    99206    ListFixParam=fieldnames(Param.Fix1);
     
    117224            Data.VarDimName=[Data.VarDimName {'nb_vectors'}];
    118225        end
    119         Data.vec_FixFlag=fix_uvmat(Param.Fix1,Data.vec_F,Data.vec_C,Data.vec_U,Data.vec_V,Data.vec_X,Data.vec_Y);
     226        Data.vec_FixFlag=fix(Param.Fix1,Data.vec_F,Data.vec_C,Data.vec_U,Data.vec_V,Data.vec_X,Data.vec_Y);
    120227    else
    121228        Data.ListVarName=[Data.ListVarName {'Civ1_FF'}];
     
    123230        nbvar=length(Data.ListVarName);
    124231        Data.VarAttribute{nbvar}.Role='errorflag';   
    125         Data.Civ1_FF=fix_uvmat(Param.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V);
     232        Data.Civ1_FF=fix(Param.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V);
    126233        Data.CivStage=2;   
    127234    end
     
    148255    end
    149256    [Data.Civ1_X_SubRange,Data.Civ1_Y_SubRange,Data.Civ1_NbSites,FFres,Ures, Vres,Data.Civ1_X_tps,Data.Civ1_Y_tps,Data.Civ1_U_tps,Data.Civ1_V_tps]=...
    150                             patch_uvmat(Data.Civ1_X(ind_good)',Data.Civ1_Y(ind_good)',Data.Civ1_U(ind_good)',Data.Civ1_V(ind_good)',Data.Patch1_Rho,Data.Patch1_Threshold,Data.Patch1_SubDomain);
     257                            patch(Data.Civ1_X(ind_good)',Data.Civ1_Y(ind_good)',Data.Civ1_U(ind_good)',Data.Civ1_V(ind_good)',Data.Patch1_Rho,Data.Patch1_Threshold,Data.Patch1_SubDomain);
    151258      Data.Civ1_U_Diff(ind_good)=Data.Civ1_U(ind_good)-Ures;
    152259      Data.Civ1_V_Diff(ind_good)=Data.Civ1_V(ind_good)-Vres;
     
    164271            image2=imread(par_civ2.filename_ima_b);%read second image if not already done for civ1
    165272    end
    166     stepx=str2double(par_civ2.dx);
    167     stepy=str2double(par_civ2.dy);
     273%     stepx=str2double(par_civ2.dx);
     274%     stepy=str2double(par_civ2.dy);
    168275    ibx2=ceil(str2double(par_civ2.ibx)/2);
    169276    iby2=ceil(str2double(par_civ2.iby)/2);
     
    182289        end
    183290            [Data.Civ1_X_SubRange,Data.Civ1_Y_SubRange,Data.Civ1_NbSites,FFres,Ures, Vres,Data.Civ1_X_tps,Data.Civ1_Y_tps,Data.Civ1_U_tps,Data.Civ1_V_tps]=...
    184                                 patch_uvmat(Data.Civ1_X(ind_good)',Data.Civ1_Y(ind_good)',Data.Civ1_U(ind_good)',Data.Civ1_V(ind_good)',Data.Patch1_Rho,Data.Patch1_Threshold,Data.Patch1_SubDomain);
     291                                patch(Data.Civ1_X(ind_good)',Data.Civ1_Y(ind_good)',Data.Civ1_U(ind_good)',Data.Civ1_V(ind_good)',Data.Patch1_Rho,Data.Patch1_Threshold,Data.Patch1_SubDomain);
    185292        end
    186293%     shiftx=str2num(par_civ1.shiftx);
     
    192299    maxiy=min(size(image1,1)-isy2+shifty,size(image1,1)-iby2);
    193300    maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2);
    194     [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy);
     301    [GridX,GridY]=meshgrid(minix:par_civ2.Dx:maxix,miniy:par_civ2.Dy:maxiy);
    195302    PointCoord(:,1)=reshape(GridX,[],1);
    196303    PointCoord(:,2)=reshape(GridY,[],1);
     
    199306    end
    200307    % caluclate velocity data (y and v in indices, reverse to y component)
    201     [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,-shifty,PointCoord,str2num(par_civ1.rho),mask);
     308    [xtable ytable utable vtable ctable F] = civ (image1,image2,ibx2,iby2,isx2,isy2,shiftx,-shifty,PointCoord,str2num(par_civ1.rho),mask);
    202309    list_param=(fieldnames(par_civ1))';
    203310    list_remove={'pxcmx','pxcmy','npx','npy','gridflag','maskflag','term_a','term_b','T0'};
     
    254361            Data.VarDimName=[Data.VarDimName {'nb_vectors2'}];
    255362        end
    256         Data.vec_FixFlag=fix_uvmat(Param.Fix2,Data.vec2_F,Data.vec2_C,Data.vec2_U,Data.vec2_V,Data.vec2_X,Data.vec2_Y);
     363        Data.vec_FixFlag=fix(Param.Fix2,Data.vec2_F,Data.vec2_C,Data.vec2_U,Data.vec2_V,Data.vec2_X,Data.vec2_Y);
    257364    else
    258365        Data.ListVarName=[Data.ListVarName {'Civ2_FF'}];
     
    260367        nbvar=length(Data.ListVarName);
    261368        Data.VarAttribute{nbvar}.Role='errorflag';   
    262         Data.Civ2_FF=fix_uvmat(Param.Fix2,Data.Civ2_F,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V);
     369        Data.Civ2_FF=fix(Param.Fix2,Data.Civ2_F,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V);
    263370        Data.CivStage=5;   
    264371    end
     
    286393    end
    287394    [Data.Civ2_X_SubRange,Data.Civ2_Y_SubRange,Data.Civ2_NbSites,FFres,Ures, Vres,Data.Civ2_X_tps,Data.Civ2_Y_tps,Data.Civ2_U_tps,Data.Civ2_V_tps]=...
    288                             patch_uvmat(Data.Civ2_X(ind_good)',Data.Civ2_Y(ind_good)',Data.Civ2_U(ind_good)',Data.Civ2_V(ind_good)',Data.Patch2_Rho,Data.Patch2_Threshold,Data.Patch2_SubDomain);
     395                            patch(Data.Civ2_X(ind_good)',Data.Civ2_Y(ind_good)',Data.Civ2_U(ind_good)',Data.Civ2_V(ind_good)',Data.Patch2_Rho,Data.Patch2_Threshold,Data.Patch2_SubDomain);
    289396      Data.Civ2_U_Diff(ind_good)=Data.Civ2_U(ind_good)-Ures;
    290397      Data.Civ2_V_Diff(ind_good)=Data.Civ2_V(ind_good)-Vres;
     
    293400end   
    294401
    295 %% write result
    296 % 'TESTcalc'
    297 % [DataOut,errormsg]=calc_field('velocity',Data)
     402%% write result in a netcdf file if requested
    298403if exist('ncfile','var')
    299 errormsg=struct2nc(ncfile,Data);
     404    errormsg=struct2nc(ncfile,Data);
    300405end
    301406
     
    323428%fieldref: 'civ1','filter1'...feld used in fileref
    324429
    325 function FF=fix_uvmat(Param,F,C,U,V,X,Y)
     430function FF=fix(Param,F,C,U,V,X,Y)
    326431FF=zeros(size(F));%default
     432Param
    327433
    328434%criterium on warn flags
    329 if isfield (Param,'WarnFlags')
    330     for iflag=1:numel(Param.WarnFlags)
    331         FF=(FF==1| F==Param.WarnFlags(iflag));
    332     end
    333 end
    334 
     435FlagName={'CheckFmin2','CheckF2','CheckF3','CheckF4'};
     436FlagVal=[-2 2 3 4];
     437for iflag=1:numel(FlagVal)
     438    if Param.(CheckFlag(iflag))
     439        FF=(FF==1| F==FlagVal(iflag));
     440% if isfield (Param,'WarnFlags')
     441%     for iflag=1:numel(Param.WarnFlags)
     442%         FF=(FF==1| F==Param.WarnFlags(iflag));
     443%     end
     444% end
     445    end
     446end
    335447%criterium on correlation values
    336 if isfield (Param,'LowerBoundCorr')
    337     FF=FF==1 | C<Param.LowerBoundCorr;
    338 end
     448if isfield (Param,'MinCorr')
     449    FF=FF==1 | C<Param.MinCorr;
     450end
     451return
     452
    339453
    340454if isfield (Param,'LowerBoundVel')&& ~isequal(Param.LowerBoundVel,0)
     
    427541%------------------------------------------------------------------------
    428542% patch function
    429 function [SubRangx,SubRangy,nbpoints,FF,U_smooth,V_smooth,X_tps,Y_tps,U_tps,V_tps] =patch_uvmat(X,Y,U,V,Rho,Threshold,SubDomain)
     543function [SubRangx,SubRangy,nbpoints,FF,U_smooth,V_smooth,X_tps,Y_tps,U_tps,V_tps] =patch(X,Y,U,V,Rho,Threshold,SubDomain)
    430544%subdomain decomposition
    431545warning off
     
    542656
    543657
    544 
    545 
     658% 'civ': function piv.m adapted from PIVlab http://pivlab.blogspot.com/
     659%--------------------------------------------------------------------------
     660% function [xtable ytable utable vtable typevector] = civ (image1,image2,ibx,iby step, subpixfinder, mask, roi)
     661%
     662% OUTPUT:
     663% xtable: set of x coordinates
     664% ytable: set of y coordiantes
     665% utable: set of u displacements (along x)
     666% vtable: set of v displacements (along y)
     667% ctable: max image correlation for each vector
     668% typevector: set of flags, =1 for good, =0 for NaN vectors
     669%
     670%INPUT:
     671% image1:first image (matrix)
     672% image2: second image (matrix)
     673% ibx2,iby2: half size of the correlation box along x and y, in px (size=(2*iby2+1,2*ibx2+1)
     674% isx2,isy2: half size of the search box along x and y, in px (size=(2*isy2+1,2*isx2+1)
     675% shiftx, shifty: shift of the search box (in pixel index, yshift reversed)
     676% step: mesh of the measurement points (in px)
     677% subpixfinder=1 or 2 controls the curve fitting of the image correlation
     678% mask: =[] for no mask
     679% roi: 4 element vector defining a region of interest: x position, y position, width, height, (in image indices), for the whole image, roi=[];
     680function [xtable ytable utable vtable ctable F result_conv errormsg] = civ (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty, GridIndices, subpixfinder,mask)
     681%this funtion performs the DCC PIV analysis. Recent window-deformation
     682%methods perform better and will maybe be implemented in the future.
     683nbvec=size(GridIndices,1);
     684xtable=zeros(nbvec,1);
     685ytable=xtable;
     686utable=xtable;
     687vtable=xtable;
     688ctable=xtable;
     689F=xtable;
     690result_conv=[];
     691errormsg='';
     692%warning off %MATLAB:log:logOfZero
     693[npy_ima npx_ima]=size(image1);
     694if ~isequal(size(image2),[npy_ima npx_ima])
     695    errormsg='image pair with unequal size';
     696    return
     697end
     698
     699%% mask
     700testmask=0;
     701image1=double(image1);
     702image2=double(image2);
     703if exist('mask','var') && ~isempty(mask)
     704   testmask=1;
     705   if ~isequal(size(mask),[npy_ima npx_ima])
     706        errormsg='mask must be an image with the same size as the images';
     707        return
     708   end
     709    % Convention for mask
     710    % mask >200 : velocity calculated
     711    %  200 >=mask>150;velocity not calculated, interpolation allowed (bad spots)
     712    % 150>=mask >100: velocity not calculated, nor interpolated
     713    %  100>=mask> 20: velocity not calculated, impermeable (no flux through mask boundaries)
     714    %  20>=mask: velocity=0
     715    test_noflux=(mask<100) ;
     716    test_undefined=(mask<200 & mask>=100 );
     717    image1(test_undefined)=min(min(image1));% put image to zero in the undefined  area
     718    image2(test_undefined)=min(min(image2));% put image to zero in the undefined  area
     719end
     720
     721%% calculate correlations: MAINLOOP on velocity vectors
     722corrmax=0;
     723sum_square=1;% default
     724for ivec=1:nbvec
     725    iref=GridIndices(ivec,1);
     726    jref=GridIndices(ivec,2);
     727    testmask_ij=0;
     728    test0=0;
     729    if testmask
     730        if mask(jref,iref)<=20
     731           vector=[0 0];
     732           test0=1;
     733        else
     734            mask_crop1=mask(jref-iby2:jref+iby2,iref-ibx2:iref+ibx2);
     735            mask_crop2=mask(jref+shifty-isy2:jref+shifty+isy2,iref+shiftx-isx2:iref+shiftx+isx2);
     736            if ~isempty(find(mask_crop1<=200 & mask_crop1>100,1)) || ~isempty(find(mask_crop2<=200 & mask_crop2>100,1));
     737                testmask_ij=1;
     738            end
     739        end
     740    end
     741    if ~test0   
     742        image1_crop=image1(jref-iby2:jref+iby2,iref-ibx2:iref+ibx2);%extract a subimage (correlation box) from images 1 
     743        image2_crop=image2(jref+shifty-isy2:jref+shifty+isy2,iref+shiftx-isx2:iref+shiftx+isx2);%extract a larger subimage (search box) from image 2
     744        image1_crop=image1_crop-mean(mean(image1_crop));%substract the mean
     745        image2_crop=image2_crop-mean(mean(image2_crop));
     746        %reference: Oliver Pust, PIV: Direct Cross-Correlation
     747        result_conv= conv2(image2_crop,flipdim(flipdim(image1_crop,2),1),'valid');
     748        corrmax= max(max(result_conv));
     749        result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255
     750        %Find the correlation max, at 255
     751        [y,x] = find(result_conv==255,1);
     752        if ~isempty(y) && ~isempty(x)
     753            try
     754                if subpixfinder==1
     755                    [vector,F(ivec)] = SUBPIXGAUSS (result_conv,x,y);
     756                elseif subpixfinder==2
     757                    [vector,F(ivec)] = SUBPIX2DGAUSS (result_conv,x,y);
     758                end
     759                sum_square=sum(sum(image1_crop.*image1_crop));
     760                ctable(ivec)=corrmax/sum_square;% correlation value
     761%                 if vector(1)>shiftx+isx2-ibx2+subpixfinder || vector(2)>shifty+isy2-iby2+subpixfinder
     762%                     F(ivec)=-2;%vector reaches the border of the search zone
     763%                 end
     764            catch ME
     765                vector=[0 0]; %if something goes wrong with cross correlation.....
     766                F(ivec)=3;
     767            end
     768        else
     769            vector=[0 0]; %if something goes wrong with cross correlation.....
     770            F(ivec)=3;
     771        end
     772        if testmask_ij
     773            F(ivec)=3;
     774        end
     775    end
     776   
     777    %Create the vector matrix x, y, u, v
     778    xtable(ivec)=iref+vector(1)/2;% convec flow (velocity taken at the point middle from imgae1 and 2)
     779    ytable(ivec)=jref+vector(2)/2;
     780    utable(ivec)=vector(1)+shiftx;
     781    vtable(ivec)=vector(2)+shifty;
     782end
     783result_conv=result_conv*corrmax/(255*sum_square);% keep the last correlation matrix for output
     784
     785
     786function [vector,F] = SUBPIXGAUSS (result_conv,x,y)
     787vector=[0 0]; %default
     788F=0;
     789[npy,npx]=size(result_conv);
     790
     791% if (x <= (size(result_conv,1)-1)) && (y <= (size(result_conv,1)-1)) && (x >= 1) && (y >= 1)
     792    %the following 8 lines are copyright (c) 1998, Uri Shavit, Roi Gurka, Alex Liberzon, Technion – Israel Institute of Technology
     793    %http://urapiv.wordpress.com
     794    peaky = y;
     795    if y <= npy-1 && y >= 1
     796        f0 = log(result_conv(y,x));
     797        f1 = real(log(result_conv(y-1,x)));
     798        f2 = real(log(result_conv(y+1,x)));
     799        peaky = peaky+ (f1-f2)/(2*f1-4*f0+2*f2);
     800    else
     801        F=-2; % warning flag for vector truncated by the limited search box
     802    end
     803    peakx=x;
     804    if x <= npx-1 && x >= 1
     805        f0 = log(result_conv(y,x));
     806        f1 = real(log(result_conv(y,x-1)));
     807        f2 = real(log(result_conv(y,x+1)));
     808        peakx = peakx+ (f1-f2)/(2*f1-4*f0+2*f2);
     809    else
     810        F=-2; % warning flag for vector truncated by the limited search box
     811    end
     812    vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1];
     813% else
     814%     vector=[NaN NaN];
     815% end
     816
     817function [vector,F] = SUBPIX2DGAUSS (result_conv,x,y)
     818vector=[0 0]; %default
     819F=-2;
     820peaky=y;
     821peakx=x;
     822[npy,npx]=size(result_conv);
     823if (x <= npx-1) && (y <= npy-1) && (x >= 1) && (y >= 1)
     824    F=0;
     825    for i=-1:1
     826        for j=-1:1
     827            %following 15 lines based on
     828            %H. Nobach Æ M. Honkanen (2005)
     829            %Two-dimensional Gaussian regression for sub-pixel displacement
     830            %estimation in particle image velocimetry or particle position
     831            %estimation in particle tracking velocimetry
     832            %Experiments in Fluids (2005) 38: 511–515
     833            c10(j+2,i+2)=i*log(result_conv(y+j, x+i));
     834            c01(j+2,i+2)=j*log(result_conv(y+j, x+i));
     835            c11(j+2,i+2)=i*j*log(result_conv(y+j, x+i));
     836            c20(j+2,i+2)=(3*i^2-2)*log(result_conv(y+j, x+i));
     837            c02(j+2,i+2)=(3*j^2-2)*log(result_conv(y+j, x+i));
     838            %c00(j+2,i+2)=(5-3*i^2-3*j^2)*log(result_conv_norm(maxY+j, maxX+i));
     839        end
     840    end
     841    c10=(1/6)*sum(sum(c10));
     842    c01=(1/6)*sum(sum(c01));
     843    c11=(1/4)*sum(sum(c11));
     844    c20=(1/6)*sum(sum(c20));
     845    c02=(1/6)*sum(sum(c02));
     846    deltax=(c11*c01-2*c10*c02)/(4*c20*c02-c11^2);
     847    deltay=(c11*c10-2*c01*c20)/(4*c20*c02-c11^2);
     848    if abs(deltax)<1
     849        peakx=x+deltax;
     850    end
     851    if abs(deltay)<1
     852        peaky=y+deltay;
     853    end
     854end
     855vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1];
     856
     857
  • trunk/src/mouse_down.m

    r302 r309  
    4040set(hcurrentfig,'Units','normalized')
    4141hhcurrentfig=guidata(hcurrentfig);
     42if isfield(hhcurrentfig,'CheckZoom')
    4243test_zoom=get(hhcurrentfig.CheckZoom,'Value');%test for zoom action, first priority
     44else
     45    test_zoom=0;
     46end
    4347test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler  action, second priority;
    4448test_edit=get(hhuvmat.edit_object,'Value');%test for object editing, third priority
     
    6064    end
    6165end
    62 xdisplay=[];%default
    63 ydisplay=[];%default
    6466AxeData=[];%default
    6567
     
    7678%% loop on all the objects in the current figure (selected by the last mouse click)
    7779output_str='';
     80state_visible=get(hchildren,'Visible');
     81check_visible=strcmp('on',state_visible);%=1 if visible='on', =0 otherwise
     82hchildren=hchildren(find(check_visible)); %kkep only the visible children
    7883for ichild=1:length(hchildren)
    79     hchild=hchildren(ichild); %handle of the current object
     84    hchild=hchildren(ichild); %handle of the current obj
    8085    obj_pos=get(hchild,'Position');%position of the object
    8186    if xy_fig(1) >=obj_pos(1) & xy_fig(2) >= obj_pos(2)& xy_fig(1) <=obj_pos(1)+obj_pos(3) & xy_fig(2) <= obj_pos(2)+obj_pos(4);
     
    119124                if isequal(get(hObject,'SelectionType'),'alt')  && isequal(get(hchild,'Visible'),'on') && ~isequal(get(hchild,'tag'),'frame_object')&&...
    120125                        ~isequal(get(hchild,'tag'),'ListObject')
    121                     if strcmp(get(hchild,'Visible'),'on')
     126%                     if strcmp(get(hchild,'Visible'),'on')
     127                    if ~strcmp(get(hchild,'Style'),'frame')%do not visualisaze frames
    122128                        msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4);
    123129                        output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],'',get(hchild,'String'),msg_pos);
  • trunk/src/mouse_motion.m

    r292 r309  
    218218             % case of PIV correlation display
    219219                    if test_piv
    220                         par=civ('read_param_civ1',hhciv);
     220                        %par=civ('read_param_civ1',hhciv);
     221                        par=read_GUI(hhciv.Civ1);
    221222                        [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2)));
    222223                        xround=Field.X(ind_pt);
    223224                        yround=Field.Y(ind_pt);
     225                        par.PointCoord=[xround size(Field.A,1)-yround+1];
    224226                        % mark the correlation box with a rectangle
    225                         ibx2=floor((str2double(par.ibx)-1)/2);
    226                         iby2=floor((str2double(par.iby)-1)/2);
    227                         isx2=floor((str2double(par.isx)-1)/2);
    228                         isy2=floor((str2double(par.isy)-1)/2);
    229                         shiftx=str2double(par.shiftx);
    230                         shifty=str2double(par.shifty);
     227                        par.filename_ima_a=Field.A;
     228                        par.filename_ima_b=Field.B;
     229                        Param.Civ1=par;
     230                        ibx2=floor((par.Bx-1)/2);
     231                        iby2=floor((par.By-1)/2);
     232                        isx2=floor((par.Searchx-1)/2);
     233                        isy2=floor((par.Searchy-1)/2);
     234                        shiftx=par.Shiftx;
     235                        shifty=par.Shifty;     
    231236                        hhh=findobj(haxes,'Tag','PIV_box_marker');
    232237                        hhhh=findobj(haxes,'Tag','PIV_search_marker');
     
    244249                            set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2])
    245250                        end
    246                         [xtable ytable utable vtable ctable typevector result_conv] = pivlab (Field.A,Field.B,ibx2,iby2,isx2,isy2,shiftx,shifty,[xround size(Field.A,1)-yround+1], 1, []);
     251                        %[xtable, ytable, utable, vtable, ctable, typevector, result_conv] = ...
     252                         %               pivlab (Field.A,Field.B,ibx2,iby2,isx2,isy2,shiftx,shifty,[xround size(Field.A,1)-yround+1], 1, []);
     253                        [Data,errormsg,result_conv]= civ_matlab(Param)
    247254                        rangx(1)=-(isx2-ibx2)+shiftx;
    248255                        rangx(2)=isx2-ibx2+shiftx;
     
    261268                                set(0,'CurrentFigure',corrfig(1))
    262269                                AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]);
    263                                 AxeData.CurrentVector=line([0 utable],[0 vtable],'Tag','vector');
     270                                AxeData.CurrentVector=line([0 Data.Civ1_U],[0 -Data.Civ1_V],'Tag','vector');
    264271                               
    265272                                colorbar
     
    271278                            set(AxeData.CurrentCorrImage,'XData',rangx)
    272279                            set(AxeData.CurrentCorrImage,'YData',-rangy)
    273                             set(AxeData.CurrentVector,'XData',[0 utable],'YData',[0 -vtable])
     280                            set(AxeData.CurrentVector,'XData',[0 Data.Civ1_U],'YData',[0 -Data.Civ1_V])
    274281                        end
    275282                    end
  • trunk/src/read_GUI.m

    r295 r309  
    1 % --------------------------------------------------------------------
     1% -----------------------------------------------------------------------
    22% --- read a GUI with handle 'handle' producing a structure 'struct'
    33function struct=read_GUI(handle)
     4%------------------------------------------------------------------------
    45struct=[];%default
    56hchild=get(handle,'children');
     
    4344                        listinput=get(hchild(ichild),'String');
    4445                        value=get(hchild(ichild),'Value');
    45                         input=listinput(value);       
     46                        input=listinput(value);
     47                        separator=regexp(tag,'_');
     48                        if strcmp(tag(1:separator),'num_')
     49                            input=str2double(input);% transform to numerical values if the uicontrol tag begins with 'num_'
     50                            tag=tag(separator+1:end);
     51                        end
    4652                    otherwise
    4753                        check_input=0;
  • trunk/src/set_object.m

    r307 r309  
    8484end
    8585set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function (allow action on uvmat when set_object is in front)
    86 set(hObject,'WindowButtonDownFcn',{'mouse_alt_gui',handles}) % allows mouse action with right button (zoom for uicontrol display)
     86set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
    8787enable_plot=0;%default: does not allow plot of object and projection
    8888
     
    644644set(handles.XObject,'String',XObject)
    645645set(handles.YObject,'String',YObject)
     646
    646647%METTRA A JOUR ASPECT DE L'INTERFACE (COMME set_object_Opening
    647648%------------------------------------------------------------------------
     
    649650% executed when closing: set the parent interface button to value 0
    650651function closefcn(gcbo,eventdata,parent_button)
    651 
    652652huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
    653653if ~isempty(huvmat)
     
    671671UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat
    672672hhuvmat=guidata(huvmat);%handles in the uvmat GUI
    673 ObjectName=get(handles.TITLE,'String');%name of the current object
    674673ListObject=get(hhuvmat.ListObject,'String');%position in the objet list
    675 IndexObj=get(hhuvmat.ListObject,'Value');
    676 IndexObj_1=IndexObj(1);
    677 % if isequal(get(hhuvmat.list_object_2,'Visible'),'on')
    678 %     IndexObj_2=get(hhuvmat.list_object_2,'Value');
    679 %     List2=get(hhuvmat.list_object_2,'String');
    680 if numel(IndexObj)==2
    681     IndexObj_2=IndexObj(2);
    682 else
    683     IndexObj_2=[];
    684 end
    685 testnew=0;
     674IndexObj=get(hhuvmat.ListObject,'Value')
     675% name of the object
     676ObjectName=get(handles.TITLE,'String');%name of the current object defiend in set_object
    686677ObjectData=read_set_object(handles);%read the input parameters defining the object in the GUI set_object
    687 if ~isempty(ListObject) && strcmp(ListObject{IndexObj_1},ObjectName)% we are editing the object whose projection is viewed in the uvmat frame
    688     IndexObj=IndexObj_1;
    689     projview='uvmat';
    690 elseif ~isempty(IndexObj_2) && IndexObj_2<=numel(ListObject)&& strcmp(ListObject{IndexObj_2},ObjectName)% we are editing the object whose projection is viewed in view_field 
    691     IndexObj=IndexObj_2;
    692     projview='view_field';
    693 else %new object
    694     testnew=1;
    695     IndexObj=numel(ListObject)+1;
    696     projview='view_field';
    697 end
    698 if strcmp(projview,'view_field')
    699     hview_field=findobj(allchild(0),'tag','view_field');
    700     if isempty(hview_field)
    701         hview_field=view_field;
    702     end
    703     PlotHandles=guidata(hview_field);
    704     plotaxes=PlotHandles.axes3;%handle of axes3 in view_field
    705 else
    706     PlotHandles=hhuvmat;
    707     plotaxes=hhuvmat.axes3;%handle of axes3 in view_field
    708 
    709 end   
    710 
    711 %% naming the object
    712 if length(ObjectName)<1% name of object not defined in set_object
    713     ObjectName=[num2str(IndexObj) '-' ObjectData.Style];%default name
    714 elseif ~get(hhuvmat.edit_object,'Value')%not in edit mode (new object created)
     678if isempty(ObjectName)
     679    if get(hhuvmat.edit_object,'Value')% edit mode
     680        ObjectName=ListObject{IndexObj(end)};%take the name of the last (second) selected item
     681    end
     682end
     683if ~get(hhuvmat.edit_object,'Value') %new object is being created
    715684    detectname=1;
    716685    ObjectNameNew=ObjectName;
    717686    vers=0;
    718     while detectname==1 
     687    while detectname==1
    719688        detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
    720689        if detectname% if the object name already exists
     
    725694            else
    726695                vers=vers+1;
    727                 ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];     
     696                ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];
    728697            end
    729698        end
    730699    end
    731700    ObjectName=ObjectNameNew;
    732 end
    733 ListObject{IndexObj,1}=ObjectName;
     701    ObjectName=[num2str(IndexObj(end)) '-' ObjectData.Style];%default name
     702end
     703% IndexObj_1=IndexObj(1);
     704% % if isequal(get(hhuvmat.list_object_2,'Visible'),'on')
     705% %     IndexObj_2=get(hhuvmat.list_object_2,'Value');
     706% %     List2=get(hhuvmat.list_object_2,'String');
     707% if numel(IndexObj)==2
     708%     IndexObj_2=IndexObj(2);
     709% else
     710%     IndexObj_2=[];
     711% end
     712testnew=0;
     713
     714if numel(IndexObj)==1   % if only one object is selected, the projection is in uvmat
     715        PlotHandles=hhuvmat;
     716    plotaxes=hhuvmat.axes3;%handle of axes3 in view_field
     717else  % if a second object is selected, the projection is in view_field, and this second object is selected
     718    hview_field=findobj(allchild(0),'tag','view_field');
     719    if isempty(hview_field)
     720        hview_field=view_field;
     721    end
     722    PlotHandles=guidata(hview_field);
     723    plotaxes=PlotHandles.axes3;%handle of axes3 in view_field
     724end
     725
     726%% naming the object
     727ListObject{IndexObj(end),1}=ObjectName;
    734728set(hhuvmat.ListObject,'String',ListObject)
    735 % set(hhuvmat.list_object_2,'String',ListObject)
    736729
    737730%% update the object plot and projection field
    738 if testnew
    739    set(hhuvmat.ListObject,'Value',IndexObj)
    740 %     set(hhuvmat.list_object_2,'Value',IndexObj)
     731if testnew
     732    set(hhuvmat.ListObject,'Value',IndexObj)
    741733    ObjectData.DisplayHandle_uvmat=hhuvmat.axes3;
    742734    ObjectData.DisplayHandle_view_field=[];
    743735else
    744     IndexObj
    745     UvData.Object{IndexObj}
    746     if IndexObj<=length(UvData.Object) && isfield(UvData.Object{IndexObj},'DisplayHandle_uvmat')% save the previous object graph handles
    747         ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj}.DisplayHandle_uvmat;
     736    if IndexObj(end)<=length(UvData.Object) && isfield(UvData.Object{IndexObj(end)},'DisplayHandle_uvmat')% save the previous object graph handles
     737        ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj(end)}.DisplayHandle_uvmat;
    748738    else
    749739        ObjectData.DisplayHandle_uvmat=hhuvmat.axes3;%there is no object handle, than the axes handles is used as input
    750740    end
    751     if isfield(UvData.Object{IndexObj},'DisplayHandle_view_field')% save the previous object graph handles
    752         ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj}.DisplayHandle_view_field;
     741    if isfield(UvData.Object{IndexObj(end)},'DisplayHandle_view_field')% save the previous object graph handles
     742        ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj(end)}.DisplayHandle_view_field;
    753743    else
    754744        ObjectData.DisplayHandle_view_field=[];
    755745    end
    756746end
    757 UvData.Object{IndexObj}=ObjectData;%update the current object properties
    758 UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2);
     747UvData.Object{IndexObj(end)}=ObjectData;%update the current object properties
     748if numel(IndexObj)==2
     749    UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));
     750end
    759751set(huvmat,'UserData',UvData)
    760752
     
    765757    return
    766758end
    767 %PlotParam=read_plot_param(PlotHandles);
    768759fighandle=get(plotaxes,'parent');
    769760PlotParam=read_GUI(fighandle);
    770 [PlotType,Object_out{IndexObj}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot
     761[PlotType,Object_out{IndexObj(end)}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot
    771762
    772763%% update the GUI uvmat
     
    775766set(hhuvmat.edit_object,'Value',1) % set uvmat to object edit mode to allow further object update
    776767set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
    777 %UvData.MouseAction='edit_object'; % set the edit button to 'on'
    778768
    779769%------------------------------------------------------------------------
  • trunk/src/uvmat.m

    r307 r309  
    236236set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
    237237set(hObject,'DeleteFcn',{@closefcn})%
    238 %set(handles.ListObject,'ButtonDownFcn',{@list_object_1_Callback,handles})% allows activation of lis_object_1_callback with right mouse click
    239 %set(handles.list_object_2,'ButtonDownFcn',{@list_object_2_Callback,handles})
    240238
    241239%% refresh projection plane
     
    13291327set_scan_options(hObject, eventdata, handles)
    13301328
    1331 %---------------------------------------------------
    1332 % switch file index scanning options scan_i and scan_j in an exclusive way
     1329%------------------------------------------------------------------------
     1330% --- switch file index scanning options scan_i and scan_j in an exclusive way
    13331331function scan_i_Callback(hObject, eventdata, handles)
    1334 %---------------------------------------------------
     1332%------------------------------------------------------------------------
    13351333if get(handles.scan_i,'Value')==1
    13361334    set(handles.scan_i,'BackgroundColor',[1 1 0])
     
    13441342scan_j_Callback(hObject, eventdata, handles)
    13451343
    1346 %-------------------------------------------------------------------
    1347 % switch file index scanning options scan_i and scan_j in an exclusive way
     1344%------------------------------------------------------------------------
     1345% --- switch file index scanning options scan_i and scan_j in an exclusive way
    13481346function scan_j_Callback(hObject, eventdata, handles)
    1349 %-------------------------------------------------------------------
     1347%------------------------------------------------------------------------
    13501348if get(handles.scan_j,'Value')==1
    13511349    set(handles.scan_j,'BackgroundColor',[1 1 0])
     
    13661364end
    13671365
    1368 %-------------------------------------------------------------------
     1366%------------------------------------------------------------------------
    13691367function i1_Callback(hObject, eventdata, handles)
    1370 %-------------------------------------------------------------------
     1368%------------------------------------------------------------------------
    13711369set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])
    13721370NomType=get(handles.FileIndex,'UserData');
     
    13861384     set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])
    13871385end
    1388 %Run0_Callback(hObject, eventdata, handles)
    1389 
    1390 %-------------------------------------------------------------------
     1386
     1387%------------------------------------------------------------------------
    13911388function i2_Callback(hObject, eventdata, handles)
     1389%------------------------------------------------------------------------
    13921390set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])
    13931391i1_Callback(hObject, eventdata, handles)
    1394 %-------------------------------------------------------------------
    1395 
    1396 %-------------------------------------------------------------------
     1392
     1393%------------------------------------------------------------------------
    13971394function j1_Callback(hObject, eventdata, handles)
     1395%------------------------------------------------------------------------
    13981396set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])
    13991397i1_Callback(hObject, eventdata, handles)
    1400 %-------------------------------------------------------------------
    1401 
    1402 %-------------------------------------------------------------------
     1398
     1399%------------------------------------------------------------------------
    14031400function j2_Callback(hObject, eventdata, handles)
     1401%------------------------------------------------------------------------
    14041402set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])
    14051403i1_Callback(hObject, eventdata, handles)
    1406 %-------------------------------------------------------------------
    1407 
    1408 %-------------------------------------------------------------------
     1404
     1405%------------------------------------------------------------------------
    14091406function slices_Callback(hObject, eventdata, handles)
    1410 %-------------------------------------------------------------------
     1407%------------------------------------------------------------------------
    14111408if get(handles.slices,'Value')==1
    14121409    set(handles.slices,'BackgroundColor',[1 1 0])
     
    14241421end
    14251422
    1426 %-------------------------------------------------------------------
     1423%------------------------------------------------------------------------
    14271424function nb_slice_Callback(hObject, eventdata, handles)
    1428 %-------------------------------------------------------------------
     1425%------------------------------------------------------------------------
    14291426nb_slice_str=get(handles.nb_slice,'String');
    14301427if isequal(nb_slice_str,'volume')
     
    15411538    end
    15421539    set(handles.mask_test,'UserData',[])   
    1543     %huvmat=get(handles.mask_test,'parent');
    15441540    UvData=get(handles.uvmat,'UserData');
    15451541    if isfield(UvData,'MaskName')
     
    15501546end
    15511547
    1552 %-------------------------------------------------------------------
     1548%------------------------------------------------------------------------
    15531549function errormsg=update_mask(handles,num_i1,num_j1)
    1554 %-------------------------------------------------------------------
     1550%------------------------------------------------------------------------
    15551551errormsg=[];%default
    15561552MaskData=get(handles.mask_test,'UserData');
     
    16331629
    16341630
    1635 %-------------------------------------------------------------------
     1631%------------------------------------------------------------------------
    16361632function MenuExportFigure_Callback(hObject, eventdata, handles)
    1637 %-------------------------------------------------------------------
     1633%------------------------------------------------------------------------
    16381634huvmat=get(handles.MenuExport,'parent');
    1639 %UvData=get(huvmat,'UserData');
    16401635hfig=figure;
    16411636copyobj(handles.axes3,hfig);
     
    16441639colorbar
    16451640
    1646 %-------------------------------------------------------------------
    1647 %-------------------------------------------------------------------
     1641%------------------------------------------------------------------------
     1642%------------------------------------------------------------------------
    16481643% III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
    1649 %-------------------------------------------------------------------
    1650 
    1651 %-------------------------------------------------------------------
     1644%------------------------------------------------------------------------
     1645
     1646%------------------------------------------------------------------------
    16521647% --- Executes on button press in runplus: make one step forward and call
    16531648% --- run0. The step forward is along the fields series 1 or 2 depending on
    16541649% --- the scan_i and scan_j check box (exclusive each other)
    16551650function runplus_Callback(hObject, eventdata, handles)
    1656 %-------------------------------------------------------------------
     1651%------------------------------------------------------------------------
    16571652set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow
    16581653drawnow
     
    16691664set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red
    16701665
    1671 %-------------------------------------------------------------------
     1666%------------------------------------------------------------------------
    16721667% --- Executes on button press in runmin: make one step backward and call
    16731668% --- run0. The step backward is along the fields series 1 or 2 depending on
    16741669% --- the scan_i and scan_j check box (exclusive each other)
    16751670function runmin_Callback(hObject, eventdata, handles)
    1676 %-------------------------------------------------------------------
     1671%------------------------------------------------------------------------
    16771672set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
    16781673drawnow
     
    16881683set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red
    16891684
    1690 %-------------------------------------------------------------------
     1685%------------------------------------------------------------------------
    16911686% -- Executes on button press in Movie: make a series of +> steps
    16921687function Movie_Callback(hObject, eventdata, handles)
    1693 %------------------------------------------------------------------
     1688%------------------------------------------------------------------------
    16941689set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
    16951690drawnow
     
    17191714set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
    17201715
    1721 %-------------------------------------------------------------------
     1716%------------------------------------------------------------------------
    17221717% -- Executes on button press in Movie: make a series of <- steps
    17231718function MovieBackward_Callback(hObject, eventdata, handles)
    1724 %------------------------------------------------------------------
     1719%------------------------------------------------------------------------
    17251720set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
    17261721drawnow
     
    17501745set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
    17511746
    1752 %-------------------------------------------------------------------
     1747%------------------------------------------------------------------------
    17531748function STOP_Callback(hObject, eventdata, handles)
    1754 %-------------------------------------------------------------------
     1749%------------------------------------------------------------------------
    17551750set(handles.movie_pair,'BusyAction','Cancel')
    17561751set(handles.movie_pair,'value',0)
     
    17621757set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
    17631758
    1764 %------------------------------------------------------------------
     1759%------------------------------------------------------------------------
    17651760function errormsg=runpm(hObject,eventdata,handles,increment)
    1766 %------------------------------------------------------------------
    1767 %check for mï¿œovie pair status
     1761%------------------------------------------------------------------------
     1762%check for movie pair status
    17681763movie_status=get(handles.movie_pair,'Value');
    17691764if isequal(movie_status,1)
     
    17711766end
    17721767%read the data on the current input rootfile(s)
    1773 
    17741768[FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
    17751769NomType=get(handles.FileIndex,'UserData');
     
    17921786    filename_1=[];
    17931787end   
    1794 
    17951788comp_input=get(handles.fix_pair,'Value');
    17961789
     
    18431836end
    18441837
    1845 
    1846 %-------------------------------------------------------
     1838%------------------------------------------------------------------------
    18471839% --- Executes on button press in movie_pair: create an alternating movie with two view
    1848 %-------------------------------------------------------
    18491840function movie_pair_Callback(hObject, eventdata, handles)
     1841%------------------------------------------------------------------------
    18501842status=get(handles.movie_pair,'value');
    18511843if isequal(status,0)
     
    36753667       set(handles.num_MaxVec,'String','1')
    36763668       set(handles.num_ColCode1,'String','0.333')
    3677        colcode1_Callback(hObject, eventdata, handles)
     3669       num_ColCode1_Callback(hObject, eventdata, handles)
    36783670       set(handles.num_ColCode2,'String','0.666')
    3679        colcode2_Callback(hObject, eventdata, handles)
     3671       num_ColCode2_Callback(hObject, eventdata, handles)
    36803672   else
    36813673       set(handles.CheckFixVecColor,'Value',1)%auto scale between min,max by default
     
    37073699    set(handles.num_ColCode2,'String',num2str(col))
    37083700end
    3709 colcode1_Callback(hObject, eventdata, handles)
     3701num_ColCode1_Callback(hObject, eventdata, handles)
    37103702
    37113703%----------------------------------------------------------------
     
    37223714    set(handles.num_ColCode1,'String',num2str(col))
    37233715end
    3724 colcode2_Callback(hObject, eventdata, handles)
     3716num_ColCode2_Callback(hObject, eventdata, handles)
    37253717
    37263718%----------------------------------------------------------------
    3727 %execute on return carriage on the edit box corresponding to slider 1
     3719% --- Execute on return carriage on the edit box corresponding to slider 1
    37283720%----------------------------------------------------------------
    3729 function num_ColCode1_Callback(hObject, eventdata, handles)
    3730 % col=str2num(get(handles.num_ColCode1,'String'));
    3731 % set(handles.Slider1,'Value',col)
     3721function num_ColCode1_Callback(hObject, eventdata, handles)
    37323722set_vec_col_bar(handles)
    37333723update_plot(handles);
    37343724
    37353725%----------------------------------------------------------------
    3736 %execute on return carriage on the edit box corresponding to slider 2
     3726% --- Execute on return carriage on the edit box corresponding to slider 2
    37373727%----------------------------------------------------------------
    37383728function num_ColCode2_Callback(hObject, eventdata, handles)
    3739 % col=str2num(get(handles.num_ColCode2,'String'));
    3740 % set(handles.Slider2,'Value',col)
    3741 % slider2_Callback(hObject, eventdata, handles)
    37423729set_vec_col_bar(handles)
    37433730update_plot(handles);
    3744 %------------------------------------------------------------
    3745 %update the slider values after displaying vectors
    3746 %--------------------------------------------------------
    3747 % function slider_update(handles,auto,minC,num_ColCode1,num_ColCode2,maxC)
    3748 % set(handles.Slider1,'Min',minC)
    3749 % set(handles.Slider1,'Max',maxC)
    3750 % set(handles.Slider2,'Min',minC)
    3751 % set(handles.Slider2,'Max',maxC)
    3752 % set(handles.min_title_vec,'String',num2str(minC))
    3753 % set(handles.num_MaxVec,'String',num2str(maxC))
    3754 % if auto
    3755 %         set(handles.num_ColCode1,'String',num2str(num_ColCode1,3))%update display
    3756 %         set(handles.num_ColCode2,'String',num2str(num_ColCode2,3))
    3757 % end
    3758 % set(handles.Slider1,'Value',num_ColCode1)%update slider with constant display
    3759 % set(handles.Slider2,'Value',num_ColCode2)
    3760 % set_vec_col_bar(handles)
    3761 
    3762 
     3731%------------------------------------------------------------------------
    37633732%-------------------------------------------------------
    37643733% --- Executes on button press in CheckFixVecColor.
     
    37713740function transform_fct_Callback(hObject, eventdata, handles)
    37723741%-------------------------------------------------------------
    3773 
    37743742UvData=get(handles.uvmat,'UserData');
    37753743menu=get(handles.transform_fct,'String');
Note: See TracChangeset for help on using the changeset viewer.