source: trunk/src/civ_3D.m @ 71

Last change on this file since 71 was 71, checked in by sommeria, 11 years ago

civ3D updated: introduction of image size
imadoc2struct: reding of image size from the xml file
set_object, view_field and related functions: improvement of projection object editing
mouse: possibility of adjusting the calibrations points with the mouse

File size: 120.3 KB
Line 
1%'civ_3D': function associated with the interface 'civ_3D.fig' for PIV in volume   
2%------------------------------------------------------------------------
3%  provides an interface for the software CIVx
4% function varargout = civ_3D(varargin)
5% provides an interface for the software CIVx
6%
7%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
8%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
9%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
10%     This file is part of the toolbox UVMAT.
11%
12%     UVMAT is free software; you can redistribute it and/or modify
13%     it under the terms of the GNU General Public License as published by
14%     the Free Software Foundation; either version 2 of the License, or
15%     (at your option) any later version.
16%
17%     UVMAT is distributed in the hope that it will be useful,
18%     but WITHOUT ANY WARRANTY; without even the implied warranty of
19%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
21%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
22function varargout = civ_3D(varargin)
23
24% Last Modified by GUIDE v2.5 26-Mar-2010 22:51:31
25% Begin initialization code - DO NOT EDIT
26gui_Singleton = 1;
27gui_State = struct('gui_Name',       mfilename, ...
28                   'gui_Singleton',  gui_Singleton, ...
29                   'gui_OpeningFcn', @civ_3D_OpeningFcn, ...
30                   'gui_OutputFcn',  @civ_3D_OutputFcn, ...
31                   'gui_LayoutFcn',  [] , ...
32                   'gui_Callback',   []);
33if nargin & isstr(varargin{1})
34    gui_State.gui_Callback = str2func(varargin{1});
35end
36
37if nargout
38    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
39else
40    gui_mainfcn(gui_State, varargin{:});
41end
42% End initialization code - DO NOT EDIT
43
44%--------------------------------------------------------------------------
45% --- Executes just before civ_3D is made visible.
46%--------------------------------------------------------------------------
47function civ_3D_OpeningFcn(hObject, eventdata, handles, varargin)
48% This function has no output args, see OutputFcn.
49% hObject    handle to figure
50% eventdata  reserved - to be defined in a future version of MATLAB
51% handles    structure with handles and user data (see GUIDATA)
52% varargin   command line arguments to civ_3D (see VARARGIN)
53global test_batch patch_new_exe%=1 if patch processing available
54%filebase: root name
55%nom_type: nomencalture used ('png_old','_i_j'...)
56%list of field numbers to process
57%subdir: subdirectory of the opened netcdf file
58%ind_opening: operation number advised for beginning (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2),
59%ind_a_opening ind_b_opening chosen pair from the opened netcdf file
60% Choose default command line output for civ_3D
61handles.output = hObject;
62% Update handles structure
63guidata(hObject, handles);
64
65%default initial parameters
66filebase=''; % root file name ('filebase'.civ_3D)
67nom_type=[]; % nomenclature type
68ext=[];
69testall=0;
70browse=[];
71
72%load the initial parameters if the interface is started from uvmat
73if ~isempty(varargin)% the interface is opened from uvmat
74    varcell=varargin{1};
75    filebase=varcell{1};
76    nom_type_read=varcell{2};
77    num1=varcell{3};
78    num2=varcell{4};
79    num_a=varcell{5};
80    num_b=varcell{6};
81    subdir=varcell{7};
82    ind_opening=varcell{8};
83    ind_a_opening=varcell{9};
84    ind_b_opening=varcell{10};
85    ext=varcell{11};
86else
87    num1=1; % set of field i numbers
88    num2=2; % set of field i numbers
89    num_a=1; % set of field j numbers (fields a)
90    num_b=1; % second set of field j numbers (fields b)
91    subdir='A'; % subdir for the netcdf result files
92    ind_opening=1; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2)
93    ind_a_opening=1; % proposed index in the menu of fields a
94    ind_b_opening=2; % proposed index in the menu of fields b   
95end
96
97if exist('ext','var') & length(ext)>1 & (~isempty(imformats(ext([2:end])))|...
98                       isequal(ext,'.avi')|isequal(ext,'.AVI'));%if an image file has been opened by uvmat
99        browse.ext_ima=ext;
100        if exist('nom_type_read','var')
101            browse.nom_type_ima=nom_type_read; % the image nomenclature is stored
102        end
103elseif isequal(ext,'.nc')
104    if exist('nom_type_read','var')
105        browse.nom_type_nc=nom_type_read;% the netcdf  nomenclature is stored
106    end
107end
108set(handles.displ_filebase,'String',filebase);
109set(handles.ImaDoc,'UserData',testall);
110set(handles.browse_root,'UserData',browse)
111set(handles.ImaDoc,'String',ext)
112
113
114% set(handles.ImaDoc,'String',ext)
115 
116%read names of the .exe file to adjust the interface according to
117%available prog
118%read names of the .exe file
119path_uvmat=which('uvmat');% check the path detected for source file uvmat
120path_UVMAT=fileparts(path_uvmat); %path to UVMAT
121if isunix
122    syst='LINUX'
123    %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ_3D binary names
124    xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml')
125    if exist(xmlfile,'file')
126        t=xmltree(xmlfile);
127        sparam=convert(t);
128    end
129else
130    syst='WIN'
131    %fid = fopen(fullfile(path_UVMAT,'PARAM_WIN.txt'),'r');%open the file with civ_3D binary names
132    xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml');
133    if exist(xmlfile,'file')
134        t=xmltree(xmlfile);
135        sparam=convert(t);
136    end
137end
138   
139patch_new_exe='';
140todo_patch='';
141sge=0;
142
143if isfield(sparam,'PatchNew_exe')
144    patch_new_exe=sparam.PatchNew_exe;
145end
146if isfield(sparam,'Todo_path')
147    todo_path=sparam.Todo_path
148end
149if isfield(sparam,'SGE')
150    sge=str2num(sparam.SGE);
151end   
152name_todo=fullfile(todo_path,'TODO.txt')
153test_batch=1;
154if ~sge
155if isequal(todo_path,'') |isequal(todo_path,[])
156    ['no batch distributed processing available:file path TODO.txt not defined in UVMAT/PARAM_' syst]
157    test_batch=0;
158end
159if exist(name_todo,'file')~=2
160    msgbox_uvmat('ERROR',['no batch distributed processing available, queue file ' name_todo ' absent']);
161  %  test_batch=0;  % Problems to detect file on linux/nfs filesystems
162end
163end
164
165
166if test_batch==0
167    set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated)
168end
169
170set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working
171set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working
172
173%initiate advised operations
174if isequal(ind_opening,[])
175    ind_opening=1; % default
176end
177% set default operation options
178    enable_civ1(handles,'off')
179    enable_civ2(handles,'off')
180    desable_fix1(handles)
181    desable_patch1(handles)
182    desable_fix2(handles)
183    desable_patch2(handles)
184    set(handles.CIV1,'Value',0)
185    set(handles.FIX1,'Value',0)
186    set(handles.PATCH1,'Value',0)
187    set(handles.CIV2,'Value',0)
188    set(handles.FIX2,'Value',0)
189    set(handles.PATCH2,'Value',0)
190    set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784])
191if isequal(ind_opening,1)
192    set(handles.CIV1,'Value',1)
193    enable_civ1(handles,'on')
194elseif isequal(ind_opening,2)
195    set(handles.FIX1,'Value',1)
196    enable_fix1(handles)
197elseif isequal(ind_opening,3)
198    set(handles.PATCH1,'Value',1)
199    enable_patch1(handles)
200elseif isequal(ind_opening,4)
201    set(handles.CIV2,'Value',1)
202    enable_civ2(handles,1)
203elseif isequal(ind_opening,5)
204    set(handles.FIX2,'Value',1)
205    enable_fix2(handles)
206     set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])
207     set(handles.list_pair_civ2,'Enable','On')
208     set(handles.list_pair_civ2,'Enable','On')
209elseif isequal(ind_opening,6)
210    set(handles.PATCH2,'Value',1)
211    enable_patch2(handles)
212    set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])
213    set(handles.list_pair_civ2,'Enable','On')
214end
215
216% set the range of fields (1:1 by default) and selected pair
217if isempty(num2)|isequal(num2,num1)
218    num_ref_i=num1;
219else
220    num_ref_i=floor((num1+num2)/2);
221    browse.incr_pair(1)=num2-num1;
222    browse.incr_pair(2)=0;
223end
224if isempty(num_b)|isequal(num_a,num_b)
225    if isempty(num_a)
226        num_ref_j=1;
227    else
228        num_ref_j=num_a;
229    end
230else
231    num_ref_j=floor((num_a+num_b)/2);
232    browse.incr_pair(2)=num_b-num_a;
233end
234set(handles.first_i,'String',num2str(num_ref_i));
235set(handles.last_i,'String',num2str(num_ref_i));
236set(handles.ref_i,'String',num2str(num_ref_i));
237set(handles.browse_root,'UserData',browse);
238if ~isempty(varargin)% the interface is opened from uvmat
239    displ_filebase_Callback(hObject, eventdata, handles);
240end
241
242set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001])
243set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001])
244set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001])
245set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001])
246
247
248%--------------------------------------------------------------
249% --- Outputs from this function are returned to the command line.
250%-----------------------------------------------------------------
251function varargout = civ_3D_OutputFcn(hObject, eventdata, handles)
252% varargout  cell array for returning output args (see VARARGOUT);
253% hObject    handle to figure
254% eventdata  reserved - to be defined in a future version of MATLAB
255% handles    structure with handles and user data (see GUIDATA)
256% Get default command line output from handles structure
257varargout{1} = handles.output;
258
259%------------------------------------------------------------------
260% --- Executes on button press in browse_root.
261function browse_root_Callback(hObject, eventdata, handles)
262%get the input file properties
263filebase=get(handles.displ_filebase,'String');
264oldfile=''; %default
265if isempty(filebase)|isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box
266     dir_perso=prefdir;
267     profil_perso=fullfile(dir_perso,'uvmat_perso.mat')
268     if exist(profil_perso,'file')
269          h=load (profil_perso);
270         if isfield(h,'filebase')&ischar(h.filebase)
271                 oldfile=h.filebase;
272         end
273         if isfield(h,'RootPath')&ischar(h.RootPath)
274%                 oldfile=h.filebase{1}
275                 oldfile=h.RootPath;
276         end
277     end
278 else
279     oldfile=filebase;
280 end
281testall=get(handles.ImaDoc,'UserData');
282ind_opening=1;%default
283browse.incr_pair=[0 0]; %default
284
285menu={'*.*', 'All Files (*.*)'; '*.xml;*.vol; *.avi;*.AVI','(*.xml,*.civ,*.avi,*.vol)'; ...
286        '*.xml', '.xml files';'*.civ', '.civ files';...
287         '*.avi;*.AVI', '.avi files';'*.vol', '.vol files'};
288
289[FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile);
290fileinput=[PathName FileName];%complete file name
291sizf=size(fileinput);
292if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
293[path,name,ext]=fileparts(fileinput);
294testeditxml=0;
295if isequal(ext,'.xml')
296    testeditxml=1;
297    t_browse=xmltree(fileinput);
298    head_element=get(t_browse,1);
299    if isfield(head_element,'name')& isequal(head_element.name,'ImaDoc')
300        testeditxml=0;
301    end
302end
303if testeditxml==1 | isequal(ext,'.xls')
304   heditxml=editxml({fileinput});
305   set(heditxml,'Tag','browser')
306   waitfor(heditxml,'Tag','idle')
307   if ~ishandle(heditxml)
308       return
309   end
310   attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes');
311   set(handles.browse,'UserData',fileinput)% store for future opening with browser
312   fileinput=get(attr,'UserData');
313   if ~exist(fileinput,'file')
314       return
315   end
316end
317[RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput);
318filebase=fullfile(RootPath,RootFile);
319if isequal(get(handles.compare,'Value'),1)
320    browse=get(handles.browse_root,'UserData');
321else
322    browse=[];%initialisation
323end
324if length(ext)>1 & (~isempty(imformats(ext([2:end])))||...
325                       isequal(lower(ext),'.avi')||isequal(ext,'.vol'));%if an image file has been opened by uvmat
326    browse.ext_ima=ext;
327    browse.nom_type_ima=nom_type;
328    browse.field_count=str2num(field_count);
329end
330set(handles.ImaDoc,'String',ext);
331%%%%% read the state of the selected netcdf file to advise default operation
332if isequal(ext,'.nc')
333    browse.nom_type_nc=nom_type;
334    ind_opening=2;% propose 'fix' as the default option   
335    Data=nc2struct(fileinput,[]);
336    if isfield(Data,'fix') & isequal(Data.fix,1)
337        ind_opening=3;
338    end
339    if isfield(Data,'patch') & isequal(Data.patch,1)
340        ind_opening=4;
341    end
342    if isfield(Data,'civ2') & isequal(Data.civ2,1)
343        ind_opening=5;
344    end
345    if isfield(Data,'fix2') & isequal(Data.fix2,1)
346        ind_opening=6;
347    end
348    if isfield(Data,'pixcmx') & isequal(Data,'pixcmy')
349        browse.pxcmx=Data.pixcmx;
350        browse.pxcmy=Data.pixcmy;
351    end
352    testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX
353    subdir='';%default
354    if testciv
355        [Pathbase,Namebase]=fileparts(filebase)
356        [Pathprev,subdir,extdir]=fileparts(Pathbase)
357        subdir=[subdir extdir]
358%         if isequal (subdir,subdir_obs)
359        filebase=fullfile(Pathprev,Namebase)% move upward to get the base name (corresponding to the .civ_3D file and images)
360%         end
361    end
362    set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results
363    set(handles.subdir_civ2,'String',subdir);
364    browse.testciv=testciv;
365    browse.ind_opening=ind_opening;
366end
367set(handles.displ_filebase,'String',filebase);
368set(handles.ImaDoc,'String',ext);
369if ~isempty(str2num(field_count))
370    ref_i=str2num(field_count);
371    if ~isempty(str2num(str2))
372        ref_i=floor((ref_i+str2num(str2))/2);% reference image number corresponding to the file
373        browse.incr_pair(1)=str2num(str2)-str2num(field_count);
374        browse.incr_pair(2)=0;
375    end
376    set(handles.first_i,'String',num2str(ref_i));
377    set(handles.last_i,'String',num2str(ref_i));
378    set(handles.ref_i,'String',num2str(ref_i));
379end
380if isequal(ind_opening,1)
381    set(handles.CIV1,'Value',1)
382    enable_civ1(handles,'on')
383elseif isequal(ind_opening,2)
384    set(handles.FIX1,'Value',1)
385    enable_fix1(handles)
386elseif isequal(ind_opening,3)
387    set(handles.PATCH1,'Value',1)
388    enable_patch1(handles)
389elseif isequal(ind_opening,4)
390    set(handles.CIV2,'Value',1)
391    enable_civ2(handles,1)
392elseif isequal(ind_opening,5)
393    set(handles.FIX2,'Value',1)
394    enable_fix2(handles)
395     set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])
396     set(handles.list_pair_civ2,'Enable','On')
397     set(handles.list_pair_civ2,'Enable','On')
398elseif isequal(ind_opening,6)
399    set(handles.PATCH2,'Value',1)
400    enable_patch2(handles)
401    set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])
402    set(handles.list_pair_civ2,'Enable','On')
403end
404set(handles.browse_root,'UserData',browse);% store information from browser
405testall=isequal(menu(filtindex,1),{'*.*'});
406set(handles.ImaDoc,'UserData',testall);
407
408displ_filebase_Callback(hObject, eventdata, handles);
409
410%------------------------------------------------
411
412function ImaDoc_Callback(hObject, eventdata, handles)
413displ_filebase_Callback(hObject, eventdata, handles)
414
415%--------------------------------------------------------------
416%function activated when a new filebase (image series) is introduced
417%------------------------------------------------------------
418function displ_filebase_Callback(hObject, eventdata, handles)
419
420global test_batch
421set(gcf,'Pointer','watch')
422ext_ima=[]; %default
423nom_type_ima=[];%default
424field_count=1;%default
425nom_type_nc=[];
426npx=[];%default
427npy=[];
428TimeUnit='s'; %default
429CoordUnit='cm';%default
430pxcmx_search=[];%default
431pxcmy_search=[];%default
432filebase=get(handles.displ_filebase,'String');
433
434ext=get(handles.ImaDoc,'String');
435browse=get(handles.browse_root,'UserData');%default
436if ~isempty(browse)
437    if isfield(browse,'ext_ima')
438        ext_ima=browse.ext_ima;
439    end
440    if isfield(browse,'nom_type_ima')
441        nom_type_ima=browse.nom_type_ima;
442    end
443    if isfield(browse,'field_count')
444        field_count=browse.field_count;
445    end
446end
447
448%default first_i and j and increments
449first_i=str2num(get(handles.first_i,'String'));%value possibly set by uvmat_Opening
450if isempty(first_i)| first_i < 1
451    first_i=1; %default first_i
452end
453last_i=str2num(get(handles.last_i,'String'));
454if isempty(last_i)| last_i < first_i
455    last_i=first_i;  %default last_i
456end
457
458incr_i=str2num(get(handles.incr_i,'String'));
459if isempty(incr_i) | incr_i < 1;
460    set(handles.incr_i,'String','1') %default incr_i
461end
462dt=[];%default
463testmode=0;%default
464nbfield=1; %default
465if isfield(browse,'pxcmx') & isfield(browse,'pxcmy')
466    pxcmx=num2str(browse.pxcmx);
467    pxcmy=num2str(browse.pxcmy);
468else
469    pxcmx=1;%default
470    pxcmy=1;
471end
472 %look for an image documentation file
473if ~isequal(ext,'.xml') & ~ isequal(ext,'.avi')& ~ isequal(ext,'.AVI')
474    if exist([filebase '.xml'],'file')
475         ext='.xml';
476         set(handles.ImaDoc,'String','.xml')
477    elseif exist([filebase '.civ_3D'],'file')
478         ext='.civ_3D';
479         set(handles.ImaDoc,'String','.civ_3D')
480    elseif exist([filebase '.avi'],'file')
481         ext='.avi';
482         set(handles.ImaDoc,'String','.avi')
483    elseif exist([filebase '.AVI'],'file')
484         ext='.AVI';
485         set(handles.ImaDoc,'String','.AVI')
486    end
487end
488%%%%%%%%   read image documentation file  %%%%%%%%%%%%%%%%%%%%%%%%%%%
489    mode=''; %default
490if isequal(ext,'.xml')
491    [XmlData,warntext]=imadoc2struct([filebase '.xml'])
492        if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')
493            [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName);
494        end
495        if isfield(XmlData,'TimeUnit')
496                TimeUnit=XmlData.TimeUnit;
497        end
498        if isfield(XmlData,'Npx')&&isfield(XmlData,'Npy')
499            set(handles.npx,'String',num2str(XmlData.Npx));
500            set(handles.npy,'String',num2str(XmlData.Npy));
501        end
502        if isfield(XmlData,'Time')&&~isempty(XmlData.Time)
503            time=XmlData.Time;
504            set(handles.npz,'String',num2str(size(time,2)));
505        end
506        pxcmx_search=1;
507        pxcmy_search=1;
508        if isfield(XmlData,'GeometryCalib')
509            tsai=XmlData.GeometryCalib;
510            if isfield(tsai,'f') & isfield(tsai,'Tz') & isfield(tsai,'dpx') & isfield(tsai,'dpy')& isfield(tsai,'R')
511                 rot2D=tsai.R([1:2],[1,2]);
512                 pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx);
513                 pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy);           
514            end
515            if isfield(tsai,'CoordUnit')
516                 CoordUnit=tsai.CoordUnit;
517            end
518        end               
519        if isempty(ext_ima_read)
520              ext_ima='.png';%default
521        else
522              ext_ima=ext_ima_read;
523        end
524        if isempty(nom_type_read)
525                nom_type_ima='_i_j';
526                msgbox_uvmat('WARNING','no ImageName defined in ImaDoc/Heading, take _i_j indexing by default')
527        else
528                nom_type_ima=nom_type_read;
529        end
530       
531elseif isequal(ext,'.avi')|isequal(ext,'.AVI')
532        nom_type_ima='avi';
533        ext_ima=ext;
534        set(handles.mode,'String',{'series(Di)'})
535        dt=0.04;%default
536        if exist([filebase ext],'file')==2
537            info=aviinfo([filebase ext]);%read infos on the avi movie
538            dt=1/info.FramesPerSecond;%time interval between successive frames
539            nbfield=info.NumFrames;%number of frames
540        end
541        time=(dt*[0:nbfield-1])';%list of image times   
542        set(handles.dt,'String',num2str(dt*1000));%store the time interval between successive images
543       
544     % no image documentation file found: look for a series of existing images or .nc files
545elseif ~isequal(ext,'.nc')
546        subdir=get(handles.subdir_civ1,'String');
547        incr_pair=[0 0];%default
548        if isfield(browse,'incr_pair')
549                incr_pair=browse.incr_pair;
550        end
551        nbdetect=0;%test of detected images
552        field_i=field_count;
553        idetect=1;
554%         imagename='';%default
555        while idetect==1 %look for the maximum file number in the series
556                field_i=field_i+1;
557%                 imagename_last=imagename;
558                imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima);
559                idetect=exist(imagename,'file');
560                if isequal(nom_type_ima,'none')
561                   idetect=0; %stop if the same image is repeated (if nom_type='none')
562                   nbdetect=1;
563                end
564                %SEE CASE OF NETCDF FILES
565                nbdetect=nbdetect+idetect;
566        end
567%         nb_field=field_i-1;% last detected field number
568        nb_field=field_i;% last detected field number
569        field_i=field_count;%look for the minimum file number in the series
570        idetect=1;
571        while idetect==1
572                    field_i=field_i-1;
573                    imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima);
574                    idetect=exist(imagename,'file');
575                    if isequal(nom_type_ima,'none')
576                        idetect=0; %stop if the same image is repeted (if nom_type='none')
577                        nbdetect=1;
578                    end
579                    nbdetect=nbdetect+idetect;
580        end
581        first_i=max(field_i+1,1);
582            %determine the set of times and possible intervals for CIV_3D
583        dt=(1/1000)*str2num(get(handles.dt,'String'));
584        time=(dt*[0:nb_field-1])';
585%             set(handles.incr_i,'UserData',dt);%store the time interval
586%             between successive images
587            %displ_num:list  of possible time intervals for civ_3D calculations
588        set(handles.mode,'String',{'series(Di)'})
589end
590if isequal(nom_type_ima,'none')% no file numbering used
591  first_i=1;
592  last_i=1;
593   first_j=1;
594  last_j=1;
595end
596UvData.XmlData=XmlData;
597
598if exist('time','var')
599    nbfield=size(time,1);
600    set(handles.displ_filebase,'UserData',time); %store the set of times
601    set(handles.TimeUnit,'String',TimeUnit);
602    set(handles.nb_field,'String',num2str(nbfield));
603end
604set(handles.CoordUnit,'String',[CoordUnit '/'])
605if isempty(pxcmx_search)
606   set(handles.calcul_search,'UserData',[pxcmx pxcmy]);
607else
608   set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]);
609end
610set(handles.first_i,'String',num2str(first_i));
611set(handles.last_i,'String',num2str(last_i));%
612browse.ext_ima=ext_ima;
613browse.nom_type_ima=nom_type_ima;
614set(handles.browse_root,'UserData',browse)% store the nomenclature type
615
616        %%%%%%%%%%%  set the menus of image pairs and default selection for civ_3D   %%%%%%%%%%%%%%%%%%%
617if isequal(get(handles.compare,'Value'),1)
618    if isequal(nom_type_ima,'_i')| isequal(nom_type_nc,'_i1-i2')|~exist('nbfield2','var')|(nbfield2==1)
619        set(handles.mode,'String',{'st_series(Di)';'displacement'})
620        set(handles.mode,'Value',1)
621    elseif (nbfield==1)% simple series in j
622        set(handles.mode,'String',{'st_series(Dj)';'displacement'})
623        set(handles.mode,'Value',1)
624    else
625        set(handles.mode,'String',{'st_pair j1-j2';'st_series(Dj)';'st_series(Di)';'displacement'})%multiple choice
626        if isequal(mode,'volume')
627            set(handles.mode,'Value',3)
628        elseif nbfield2 <= 5
629            set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts
630        end
631    end
632else
633    if isequal(nom_type_ima,'_i')| isequal(nom_type_nc,'_i1-i2')|~exist('nbfield2','var')|(nbfield2==1)
634        set(handles.mode,'String',{'series(Di)'})
635        set(handles.mode,'Value',1)
636    elseif isequal(nom_type_ima,'png_old')|isequal(nom_type_nc,'netc_old')
637        set(handles.mode,'String',{'pair j1-j2'})
638        set(handles.mode,'Value',1)
639    elseif (nbfield==1)% simple series in j
640        set(handles.mode,'String',{'series(Dj)'})
641        set(handles.mode,'Value',1)
642    else
643        set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice
644        if isequal(mode,'volume')
645            set(handles.mode,'Value',3)
646        elseif nbfield2 <= 5
647            set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts
648        else
649            set(handles.mode,'Value',2)% advice series Dj for long bursts, not volume
650        end
651    end
652end
653mode_Callback(hObject, eventdata, handles) 
654
655%%%%%% initialize waitbars and RUN button
656set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001])
657set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001])
658set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001])
659set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001])
660set(handles.RUN, 'Enable','On')
661set(handles.RUN,'BackgroundColor',[1 0 0])
662if isequal(test_batch,1)%if batch installation is available
663    set(handles.BATCH, 'Enable','On')
664    set(handles.BATCH,'BackgroundColor',[1 0 0])
665end
666   
667%%%%% store the root input filename for future opening
668dir_perso=prefdir;
669profil_perso=fullfile(prefdir,'uvmat_perso.mat');
670RootPath=fileparts(filebase);
671if exist(profil_perso,'file')
672    save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat
673else
674    txt=ver;
675    Release=txt(1).Release;
676    relnumb=str2num(Release(3:4));
677    if relnumb >= 14
678        save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat
679    else
680        save (profil_perso,'RootPath'); %store the root name for future opening of uvmat
681    end
682end
683% save(profil_perso, 'filebase'); %store the root name for future opening of uvmat
684set(gcf,'Pointer','arrow')
685
686%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%????????????
687% --- Executes on button press in mode.
688%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
689function mode_Callback(hObject, eventdata, handles)
690browse=get(handles.browse_root,'UserData');
691mode_list=get(handles.mode,'String');
692mode_value=get(handles.mode,'Value');
693mode=mode_list{mode_value};
694displ_num=[];%default
695first_i=str2num(get(handles.first_i,'String'));
696% last_i=str2num(get(handles.last_i,'String'));
697time=get(handles.displ_filebase,'UserData'); %get the set of times
698siztime=size(time);
699nbfield=siztime(1);
700nbfield2=siztime(2);
701indchosen=1;  %%first pair selected by default
702if isequal(mode,'pair j1-j2')| isequal(mode,'st_pair j1-j2')
703    dt=1;
704    displ='';
705    index=0;
706    %get all the time intervals in bursts
707    displ_dt=1;%default
708    nbfield2=min(nbfield2,10),%limitate the number of pairs to 10x10
709%     if nbfield2<2
710%         nbfield2=2,
711%     end
712    for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode
713        for numod_b=(numod_a+1):nbfield2
714             index=index+1;
715             numlist_a(index)=numod_a;
716             numlist_b(index)=numod_b;
717             if ~isempty(time)
718                dt(numod_a,numod_b)=time(first_i,numod_b)-time(first_i,numod_a);%first time interval dt
719                displ_dt(index)=dt(numod_a,numod_b);
720             else
721                 displ_dt(index)=1
722             end
723         end
724     end
725     [dtsort,indsort]=sort(displ_dt);
726     displ_num(1,:)=numlist_a(indsort);
727     displ_num(2,:)=numlist_b(indsort);
728     displ_num(3,:)=0;
729     displ_num(4,:)=0;
730     set(handles.jtext,'Visible','Off')
731    set(handles.first_j,'Visible','Off')
732    set(handles.last_j,'Visible','Off')
733    set(handles.incr_j,'Visible','Off')
734    set(handles.nb_field2,'Visible','Off')
735    set(handles.ref_j,'Visible','Off')
736elseif isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)')
737     for index=1:min(nbfield2-1,200)
738         displ_num(1,index)=-floor(index/2);
739         displ_num(2,index)=ceil(index/2);
740         displ_num(3,index)=0;
741         displ_num(4,index)=0;
742     end       
743     set(handles.jtext,'Visible','On')
744     set(handles.first_j,'Visible','On')
745     set(handles.last_j,'Visible','On')
746     set(handles.incr_j,'Visible','On')
747     set(handles.nb_field2,'Visible','On')
748     set(handles.ref_j,'Visible','On')
749     if nbfield > 1
750        set(handles.itext,'Visible','On')
751        set(handles.first_i,'Visible','On')
752        set(handles.last_i,'Visible','On')
753        set(handles.incr_i,'Visible','On')
754        set(handles.nb_field,'Visible','On')
755        set(handles.ref_i,'Visible','On')
756    else
757        set(handles.itext,'Visible','Off')
758        set(handles.first_i,'Visible','Off')
759        set(handles.last_i,'Visible','Off')
760        set(handles.incr_i,'Visible','Off')
761        set(handles.nb_field,'Visible','Off')
762        set(handles.ref_i,'Visible','Off')
763    end
764elseif isequal(mode,'series(Di)') | isequal(mode,'st_series(Di)')
765     for index=1:min(nbfield-1,200)
766         displ_num(1,index)=0;
767         displ_num(2,index)=0;
768         displ_num(3,index)=-floor(index/2);
769         displ_num(4,index)=ceil(index/2);
770     end
771     set(handles.itext,'Visible','On')
772     set(handles.first_i,'Visible','On')
773     set(handles.last_i,'Visible','On')
774     set(handles.incr_i,'Visible','On')
775     set(handles.nb_field,'Visible','On')
776     set(handles.ref_i,'Visible','On')
777elseif isequal(mode,'displacement')%the pairs have the same indices
778     displ_num(1,1)=0;
779     displ_num(2,1)=0;
780     displ_num(3,1)=0;
781     displ_num(4,1)=0;
782     if nbfield > 1
783        set(handles.itext,'Visible','On')
784        set(handles.first_i,'Visible','On')
785        set(handles.last_i,'Visible','On')
786        set(handles.incr_i,'Visible','On')
787        set(handles.nb_field,'Visible','On')
788        set(handles.ref_i,'Visible','On')
789    else
790        set(handles.itext,'Visible','Off')
791        set(handles.first_i,'Visible','Off')
792        set(handles.last_i,'Visible','Off')
793        set(handles.incr_i,'Visible','Off')
794        set(handles.nb_field,'Visible','Off')
795        set(handles.ref_i,'Visible','Off')
796    end
797    if nbfield2 > 1
798      set(handles.jtext,'Visible','On')
799     set(handles.first_j,'Visible','On')
800     set(handles.last_j,'Visible','On')
801     set(handles.incr_j,'Visible','On')
802     set(handles.nb_field2,'Visible','On')
803     set(handles.ref_j,'Visible','On')
804    else
805        set(handles.jtext,'Visible','Off')
806        set(handles.first_j,'Visible','Off')
807        set(handles.last_j,'Visible','Off')
808        set(handles.incr_j,'Visible','Off')
809        set(handles.nb_field2,'Visible','Off')
810        set(handles.ref_j,'Visible','Off')
811    end
812end 
813set(handles.list_pair_civ1,'UserData',displ_num);
814find_netcpair_civ1(hObject, eventdata, handles)
815find_netcpair_civ2(hObject, eventdata, handles)
816
817%--------------------------------------------------------------
818% determine the menu for civ1 pairs depending on existing netcdf file at the middle of
819% the field series set by first_i, incr, last_i
820%----------------------------------------------------------------
821function find_netcpair_civ1(hObject, eventdata, handles)
822set(gcf,'Pointer','watch')
823%nomenclature types
824filebase=get(handles.displ_filebase,'String');
825[filepath,Nme,ext_dir]=fileparts(filebase);
826browse=get(handles.browse_root,'UserData');
827mode_list=get(handles.mode,'String');
828mode_value=get(handles.mode,'Value');
829mode=mode_list{mode_value};
830% nomenclature type of the .nc files
831nom_type_ima=[];%default
832if isfield(browse,'nom_type_ima')
833    nom_type_ima=browse.nom_type_ima;
834end
835
836%determine nom_type_nc:
837nom_type_nc=[];%default
838if isfield(browse,'nom_type_nc')
839    nom_type_nc=browse.nom_type_nc;
840end
841if isequal(nom_type_ima,'png_old') | isequal(nom_type_nc,'netc_old')| isequal(nom_type_ima,'raw_SMD')
842    nom_type_nc='netc_old';%nom_type for the netcdf files
843elseif isequal(nom_type_ima,'none')|isequal(nom_type_nc,'none')
844    nom_type_nc='none';
845elseif isequal(nom_type_ima,'avi')|isequal(nom_type_ima,'_i')|isequal(nom_type_ima,'ima_num')|...
846        isequal(nom_type_nc,'_i1-i2')
847     nom_type_nc='_i1-i2';
848elseif isequal(nom_type_ima,'_i_j1-j2')||isequal(nom_type_nc,'_i1-i2_j1-j2')
849     nom_type_nc='_i1-i2_j1-j2';
850else
851    if  isequal(mode,'series(Di)')|isequal(mode,'st_series(Di)')
852        nom_type_nc='_i1-i2_j'; % PIV in volume
853    else
854        nom_type_nc='_i_j1-j2';
855    end   
856end
857browse.nom_type_nc=nom_type_nc;
858set(handles.browse_root,'UserData',browse)
859
860%reads .nc subdirectoy and image numbers from the interface
861subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data
862first_i=str2num(get(handles.first_i,'String'));
863last_i=str2num(get(handles.last_i,'String'));
864incr=str2num(get(handles.incr_i,'String'));
865num1=first_i:incr:last_i;
866if isempty(num1)
867    set(handles.list_pair_civ1,'String',{''});
868    return
869end
870ref_i=str2num(get(handles.ref_i,'String'));
871time=get(handles.displ_filebase,'UserData');%get the set of times
872if isempty(time)
873    time=[0 1];
874end
875displ_num=get(handles.list_pair_civ1,'UserData');
876
877%eliminate the first pairs inconsistent with the position
878if isempty(displ_num)
879    nbpair=0;
880else
881    nbpair=length(displ_num(1,:));%nbre of displayed pairs
882    if  isequal(mode,'series(Di)')  | isequal(mode,'st_series(Di)')
883        nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index
884    elseif  isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)')
885        nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index
886    end
887end
888nbpair=min(200,nbpair);%limit the number of displayed pairs to 200
889
890%look for existing processed pairs involving the field at the middle of the series if civ1 will not
891% be performed, while the result is needed for next steps.
892displ_pair={''};
893select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs
894testpair=0;
895if get(handles.CIV1,'Value')==0 %
896    dirname=fullfile(filepath,subdir_civ1,ext_dir);
897    if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir')
898         msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']);
899         set(handles.list_pair_civ1,'String',{});
900         return
901    end
902    for ipair=1:nbpair   
903        filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
904        ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
905        select(ipair)=exist(filename,'file');
906    end
907    if ~exist('select','var') | isequal(select,zeros(size(1:nbpair)))
908        if isfield(browse,'incr_pair')
909            num_i1=ref_i-floor(browse.incr_pair(1)/2);
910            num_i2=ref_i+ceil(browse.incr_pair(1)/2);
911            num_j1=ref_j-floor(browse.incr_pair(2)/2);
912            num_j2=ref_j+ceil(browse.incr_pair(2)/2);
913            [filename]=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1);
914            select(1)=exist(filename,'file');
915            testpair=1;
916        else
917            if  isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)')
918                msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]);
919            else
920                msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]);
921            end
922             set(handles.list_pair_civ1,'String',{''});
923             %COMPLETER CAS STEREO
924            return
925        end
926    end
927end
928if isequal(mode,'series(Di)')
929    if testpair
930              displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))];       
931    else
932       for ipair=1:nbpair
933          if select(ipair)         
934              dt=time(ref_i+displ_num(4,ipair),1)-time(ref_i+displ_num(3,ipair),1);%time interval dt
935              displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)];
936          else
937             displ_pair{ipair}='...'; %pair not displayed in the menu
938          end
939       end
940    end
941elseif isequal(mode,'pair j1-j2')%case of pairs
942    for ipair=1:nbpair
943        if select(ipair)
944           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
945           displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ...
946                        ' :dt= ' num2str(dt*1000)];
947       else
948          displ_pair{ipair}='...'; %pair not displayed in the menu
949        end   
950   end
951elseif isequal(mode,'displacement')
952    displ_pair={'Di=Dj=0'}; 
953end   
954set(handles.list_pair_civ1,'String',displ_pair');
955ichoice=min(find(select));
956if (isempty(ichoice) | ichoice < 1); ichoice=1; end;
957initial=get(handles.list_pair_civ1,'Value');
958if initial>nbpair |~isequal(select(initial),1)
959    set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu
960end
961set(handles.list_pair_civ2,'String',displ_pair');
962initial=get(handles.list_pair_civ2,'Value');
963if initial>nbpair |~isequal(select(initial),1)
964    set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2
965end
966set(gcf,'Pointer','arrow')
967%--------------------------------------------------------------
968% determine the menu for civ2 pairs depending on the existing netcdf file at the
969%middle of the series set by first_i, incr, last_i
970%--------------------------------------------------------------
971function find_netcpair_civ2(hObject, eventdata, handles)
972return %do not exist in 3D
973set(gcf,'Pointer','watch')
974%nomenclature types
975filebase=get(handles.displ_filebase,'String');
976[filepath,Nme,ext_dir]=fileparts(filebase);
977browse=get(handles.browse_root,'UserData');
978mode_list=get(handles.mode,'String');
979mode_value=get(handles.mode,'Value');
980mode=mode_list{mode_value};
981
982% nomenclature type of the .nc files
983nom_type_ima='ima_num';%default
984if isfield(browse,'nom_type_ima')
985    nom_type_ima=browse.nom_type_ima;
986end
987nom_type_nc='_i1-i2';%default
988if isfield(browse,'nom_type_nc')
989    nom_type_nc=browse.nom_type_nc;
990end
991if isequal(nom_type_ima,'png_old') | isequal(nom_type_ima,'netc_old')| isequal(nom_type_ima,'raw_SMD')| isequal(nom_type_nc,'netc_old')
992    nom_type_nc='netc_old';%nom_type for the netcdf files
993elseif isequal(nom_type_ima,'none')|isequal(nom_type_nc,'none')
994    nom_type_nc='none';
995elseif isequal(nom_type_ima,'avi')|isequal(nom_type_ima,'_i')|isequal(nom_type_ima,'ima_num')|isequal(nom_type_nc,'_i1-i2')
996     nom_type_nc='_i1-i2';
997else
998    if  isequal(mode,'series(Di)')|isequal(mode,'st_series(Di)')
999        nom_type_nc='_i1-i2_j'; % PIV in volume
1000    else
1001        nom_type_nc='_i_j1-j2';
1002    end   
1003end
1004browse.nom_type_nc=nom_type_nc;
1005set(handles.browse_root,'UserData',browse)
1006
1007%reads .nc subdirectory and image numbers from the interface
1008subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data
1009subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data
1010first_i=str2num(get(handles.first_i,'String'));
1011last_i=str2num(get(handles.last_i,'String'));
1012incr=str2num(get(handles.incr_i,'String'));
1013num1=first_i:incr:last_i;
1014if isempty(num1)
1015    set(handles.list_pair_civ2,'String',{});
1016    return
1017end
1018ref_i=str2num(get(handles.ref_i,'String'));
1019if isequal(mode,'pair j1-j2')|isequal(mode,'st_pair j1-j2')
1020    ref_j=0;
1021else
1022    ref_j=str2num(get(handles.ref_j,'String'));
1023end
1024time=get(handles.displ_filebase,'UserData'); %get the set of times
1025if isempty(time)
1026    time=[0 1];%default
1027end
1028dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file
1029displ_num=get(handles.list_pair_civ1,'UserData');
1030
1031
1032%eliminate the first pairs inconsistent with the position
1033if isempty(displ_num)
1034    nbpair=0;
1035else
1036    nbpair=length(displ_num(1,:));%nbre of displayed pairs
1037    if  isequal(mode,'series(Di)') | isequal(mode,'st_series(Di)')
1038        nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index
1039    elseif  isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)')
1040        nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index
1041    end
1042end
1043nbpair=min(200,nbpair);%limit the number of displayed pairs to 200
1044
1045%look for existing processed pairs involving the field at the middle of the series if civ1 will not
1046% be performed, while the result is needed for next steps.
1047displ_pair={''}; %default
1048select=ones(size(1:nbpair));%default =1 for nubers of displayed pairs
1049if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&...
1050    if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir')
1051         errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist'])
1052         set(handles.list_pair_civ2,'String',{});
1053         return
1054    end
1055    for ipair=1:nbpair       
1056        [filename]=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
1057        ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
1058        select(ipair)=exist(filename,'file');
1059    end
1060    if  isequal(select,zeros(size(1:nbpair)))
1061        if isfield(browse,'incr_pair')
1062            num_i1=ref_i-floor(browse.incr_pair(1)/2);
1063            num_i2=ref_i+floor((browse.incr_pair(1)+1)/2);
1064            num_j1=ref_j-floor(browse.incr_pair(2)/2);
1065            num_j2=ref_j+floor((browse.incr_pair(2)+1)/2);
1066            filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2);
1067            select(1)=exist(filename,'file');
1068        else
1069            if  isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)')
1070                msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2])
1071            else
1072                msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2])
1073            end
1074             set(handles.list_pair_civ2,'String',{});
1075            return
1076        end
1077    end
1078end
1079if isequal(mode,'series(Di)')  | isequal(mode,'st_series(Di)')
1080    if  ~isequal(get(handles.ext_txt,'String'),'dt(ms)=')
1081       for ipair=1:nbpair
1082          if select(ipair)
1083              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
1084              displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)];
1085          else
1086             displ_pair{ipair}='...'; %pair not displayed in the menu
1087          end
1088       end
1089   else
1090       for ipair=1:nbpair
1091         if select(ipair)
1092            displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt_unit*ipair)];
1093         else
1094            displ_pair{ipair}='...'; %pair not displayed in the menu
1095         end
1096       end
1097    end
1098elseif isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') % series on the j index
1099       for ipair=1:nbpair
1100          if select(ipair)
1101              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
1102              displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)];
1103          else
1104             displ_pair{ipair}='...'; %pair not displayed in the menu
1105          end
1106       end
1107elseif isequal(mode,'pair j1-j2') | isequal(mode,'st_pair j1-j2') %case of pairs
1108    for ipair=1:nbpair
1109        if select(ipair)
1110           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
1111           displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ...
1112                        ' :dt= ' num2str(dt*1000)];
1113       else
1114          displ_pair{ipair}='...'; %pair not displayed in the menu
1115       end   
1116   end
1117elseif isequal(mode,'displacement')
1118    displ_pair={'Di=Dj=0'}; 
1119end   
1120set(handles.list_pair_civ2,'String',displ_pair');
1121ichoice=min(find(select));
1122if (isempty(ichoice) | ichoice < 1); ichoice=1; end;
1123if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0
1124    set(handles.list_pair_civ2,'Value',ichoice);% first valid pair proposed by default in the menu
1125end
1126set(gcf,'Pointer','arrow')
1127%----------------------------------------------------
1128%  determine the list of index pairs of processing file
1129%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1130function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=...
1131    find_pair_indices(handles,mode)
1132first_i=str2num(get(handles.first_i,'String'));
1133last_i=str2num(get(handles.last_i,'String'));
1134incr=str2num(get(handles.incr_i,'String'));
1135list_civ1=get(handles.list_pair_civ1,'String');
1136index_civ1=get(handles.list_pair_civ1,'Value');
1137str_civ1=list_civ1{index_civ1};
1138list_civ2=get(handles.list_pair_civ2,'String');
1139index_civ2=get(handles.list_pair_civ2,'Value');
1140str_civ2=list_civ2{index_civ2};
1141if isempty(first_i), msgbox_uvmat('ERROR','first field number not defined'),...
1142    set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1143if isempty(last_i),msgbox_uvmat('ERROR','last field number not defined'),...
1144    set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1145if isempty(incr), msgbox_uvmat('ERROR','increment in field number not defined'),...
1146    set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1147if last_i < first_i , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
1148    set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1149num1=[first_i:incr:last_i];
1150if isequal (mode,'series(Di)')
1151     %recognize the pair civ1 from the display
1152        indsel=find((double(str_civ1)<48)|(double(str_civ1)>57));% character indices of non numerical characters
1153    str_raw=str_civ1(indsel);
1154    indsepar=find(str_raw=='|'); %character index of the separator
1155    d1=str2num(str_civ1([indsel(indsepar-1)+1:indsel(indsepar)-1]));
1156    if indsepar==length(str_raw)
1157        d2=str2num(str_civ1([indsel(indsepar)+1:end]));
1158    else
1159        d2=str2num(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1]));
1160    end   
1161    %recognize the pair civ2 from the display
1162    num1_civ1=num1-d1;% set of first image numbers
1163    num2_civ1=num1+d2;
1164    num_a_civ1=1;
1165    num_b_civ1=1;
1166    num1_civ2=num1-floor(index_civ2/2)*ones(size(num1));% set of first image numbers
1167    num2_civ2=num1+ceil(index_civ2/2)*ones(size(num1));
1168    num1_civ2=num1-d1;% set of first image numbers
1169    num2_civ2=num1+d2;
1170    num_a_civ2=1;
1171    num_b_civ2=1;
1172    % adjust the first and last field number
1173    lastfield=str2num(get(handles.nb_field,'String'));
1174    if isequal(lastfield,[])
1175        indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1));
1176    else
1177        indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1));
1178    end
1179    if length(indsel)>=1
1180        firstind=indsel(1);
1181        lastind=indsel(end);
1182        set(handles.first_i,'String',num2str(num1(firstind)))%update the display of first and last fields
1183        set(handles.last_i,'String',num2str(num1(lastind)))
1184        num1=num1(indsel);
1185        num1_civ1=num1_civ1(indsel);
1186        num1_civ2=num1_civ2(indsel);
1187        num2_civ1=num2_civ1(indsel);
1188        num2_civ2=num2_civ2(indsel);
1189    end
1190elseif isequal (mode,'series(Dj)')|isequal (mode,'st_series(Dj)')
1191    lastfield_j=str2num(get(handles.nb_field2,'String'));
1192    num1_civ1=num1;% set of first image numbers
1193    num2_civ1=num1;
1194    num_a_civ1=num_j-floor(index_civ1/2)*ones(size(num_j));
1195    num_b_civ1=num_j+ceil(index_civ1/2)*ones(size(num_j));
1196    num1_civ2=num1;
1197    num2_civ2=num1;
1198    num_a_civ2=num_j-floor(index_civ2/2)*ones(size(num_j));
1199    num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j));
1200    % adjust the first and last field number
1201    if isequal(lastfield_j,[])
1202        indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1));
1203    else
1204        indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1));
1205    end
1206    if length(indsel)>=1
1207        firstind=indsel(1);
1208        lastind=indsel(end);
1209        set(handles.first_j,'String',num2str(num_j(firstind)))%update the display of first and last fields
1210        set(handles.last_j,'String',num2str(num_j(lastind)))
1211        num_j=num_j(indsel);
1212        num_a_civ1=num_a_civ1(indsel);
1213        num_a_civ2=num_a_civ2(indsel);
1214        num_b_civ1=num_b_civ1(indsel);
1215        num_b_civ2=num_b_civ2(indsel);
1216    end
1217elseif isequal(mode,'pair j1-j2') | isequal(mode,'st_pair j1-j2') %case of bursts (png_old or png_2D)
1218    num1_civ1=num1;
1219    num1_civ2=num1;
1220    displ_num=get(handles.list_pair_civ1,'UserData');
1221    num2_civ1=num1;
1222    num_a_civ1=displ_num(1,index_civ1);
1223    num_b_civ1=displ_num(2,index_civ1);
1224    num2_civ2=num1;
1225    num_a_civ2=displ_num(1,index_civ2);
1226    num_b_civ2=displ_num(2,index_civ2);
1227elseif isequal(mode,'displacement')
1228    num1_civ1=num1;
1229    num2_civ1=num1;
1230    num_a_civ1=num_j;
1231    num_b_civ1=num_j;
1232    num1_civ2=num1;
1233    num2_civ2=num1;
1234    num_a_civ2=num_j;
1235    num_b_civ2=num_j;
1236end
1237
1238
1239%-------------------------------------------------------------
1240% --- Executes on selection change in list_pair_civ1.
1241function list_pair_civ1_Callback(hObject, eventdata, handles)
1242%------------------------------------------------------------
1243%reproduce by default the chosen pair in the civ2 menu
1244list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs
1245index_pair=get(handles.list_pair_civ1,'Value');
1246displ_num=get(handles.list_pair_civ1,'UserData');
1247num_a=displ_num(1,index_pair);
1248num_b=displ_num(2,index_pair);
1249set(handles.list_pair_civ2,'Value',index_pair);
1250
1251%update first_i and last_i according to the chosen image pairs
1252mode_list=get(handles.mode,'String');
1253mode_value=get(handles.mode,'Value');
1254mode=mode_list{mode_value};
1255if isequal(mode,'series(Di)')
1256    first_i=str2num(get(handles.first_i,'String'));
1257    last_i=str2num(get(handles.last_i,'String'));
1258    incr_i=str2num(get(handles.incr_i,'String'));
1259    num1=first_i:incr_i:last_i;
1260    lastfield=str2num(get(handles.nb_field,'String'));
1261    if ~isequal(lastfield,[])
1262        ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ...
1263             (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield));
1264        num1=num1(ind);
1265    end
1266    set(handles.first_i,'String',num2str(num1(1)));
1267    set(handles.last_i,'String',num2str(num1(end)));
1268elseif isequal(mode,'series(Dj)')
1269    first_j=str2num(get(handles.first_j,'String'));
1270    last_j=str2num(get(handles.last_j,'String'));
1271    incr_j=str2num(get(handles.incr_j,'String'));
1272    num_j=first_j:incr_j:last_j;
1273    lastfield2=str2num(get(handles.nb_field2,'String'));
1274    if ~isequal(lastfield2,[])
1275        ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
1276             (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2));
1277        num1=num_j(ind);
1278    end
1279    set(handles.first_j,'String',num2str(num1(1)));
1280    set(handles.last_j,'String',num2str(num1(end)));
1281end
1282
1283%------------------------------------------------------------------
1284% --- Executes on selection change in list_pair_civ2.
1285function list_pair_civ2_Callback(hObject, eventdata, handles)
1286
1287index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu
1288
1289%update first_i and last_i according to the chosen image pairs
1290mode_list=get(handles.mode,'String');
1291mode_value=get(handles.mode,'Value');
1292mode=mode_list{mode_value};
1293if isequal(mode,'series(Di)')
1294    first_i=str2num(get(handles.first_i,'String'));
1295    last_i=str2num(get(handles.last_i,'String'));
1296    incr_i=str2num(get(handles.incr_i,'String'));
1297    num1=first_i:incr_i:last_i;
1298    lastfield=str2num(get(handles.nb_field,'String'));
1299    if ~isequal(lastfield,[])
1300        ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ...
1301             (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield));
1302        num1=num1(ind);
1303    end
1304    set(handles.first_i,'String',num2str(num1(1)));
1305    set(handles.last_i,'String',num2str(num1(end)));
1306elseif isequal(mode,'series(Dj)')
1307    first_j=str2num(get(handles.first_j,'String'));
1308    last_j=str2num(get(handles.last_j,'String'));
1309    incr_j=str2num(get(handles.incr_j,'String'));
1310    num_j=first_j:incr_j:last_j;
1311    lastfield2=str2num(get(handles.nb_field2,'String'));
1312    if ~isequal(lastfield2,[])
1313        ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
1314             (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield));
1315        num1=num_j(ind);
1316    end
1317    set(handles.first_j,'String',num2str(num1(1)));
1318    set(handles.last_j,'String',num2str(num1(end)));
1319end
1320
1321
1322
1323
1324%-----------------------------------------------------------
1325% --- Executes on button press in BATCH: remote processing
1326%-----------------------------------------------------------
1327function BATCH_Callback(hObject, eventdata, handles)
1328global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe
1329
1330% pxcmx=get(handles.pxcmx,'String');
1331% pxcmy=get(handles.pxcmy,'String');
1332% npx=get(handles.pxcmx,'UserData');
1333% npy=get(handles.pxcmy,'UserData');
1334
1335%check the list of operations:
1336operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'};
1337run_flag=1;
1338box_test(1)=get(handles.CIV1,'Value');
1339box_test(2)=get(handles.FIX1,'Value');
1340box_test(3)=get(handles.PATCH1,'Value');
1341box_test(4)=get(handles.CIV2,'Value');
1342box_test(5)=get(handles.FIX2,'Value');
1343box_test(6)=get(handles.PATCH2,'Value');
1344index=find(box_test==1);
1345if isempty(index)
1346    errordlg('no selected operation')
1347    set(handles.BATCH, 'Enable','On')
1348    set(handles.BATCH,'BackgroundColor',[1 0 0])
1349    return
1350end
1351index_first=min(index);
1352index_last=max(index);
1353box_used=box_test([index_first : index_last]);
1354[box_missing,ind_missing]=min(box_used);
1355if isequal(box_missing,0)
1356    errordlg(['missing' cell2mat(operations(ind_missing))]);
1357    set(handles.BATCH, 'Enable','On')
1358    set(handles.BATCH,'BackgroundColor',[1 0 0])
1359    return
1360end
1361
1362%check mask if selecetd
1363if isequal(get(handles.get_mask_civ1,'Value'),1)
1364     get_mask_civ1_Callback(hObject, eventdata, handles);
1365end
1366if isequal(get(handles.get_mask_fix1,'Value'),1)
1367     get_mask_fix1_Callback(hObject, eventdata, handles);
1368end
1369if isequal(get(handles.get_mask_civ2,'Value'),1)
1370     get_mask_civ2_Callback(hObject, eventdata, handles);
1371end
1372if isequal(get(handles.get_mask_fix2,'Value'),1)
1373     get_mask_fix2_Callback(hObject, eventdata, handles);
1374end
1375
1376
1377%read names of the .exe file
1378path_uvmat=which('uvmat');% check the path detected for source file uvmat
1379path_UVMAT=fileparts(path_uvmat); %path to UVMAT
1380%fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ_3D binary names
1381xmlfile=fullfile(path_UVMAT,'PARAM.xml');
1382if exist(xmlfile,'file')
1383    t=xmltree(xmlfile);
1384    sparam=convert(t);
1385end
1386if isfield(sparam.BatchParam,'Civ3D3CBin')
1387    Civ3D3CBin=sparam.BatchParam.Civ3D3CBin;
1388else
1389    msgbox_uvmat('ERROR','binary for CIV3D3C not defined in PARAM.xml')
1390    return
1391end
1392 
1393%choice of batch priority
1394ind_answer=2;
1395% if sge
1396    [s,w]=unix('qstat -q civ_3D.q|grep job_| wc -l'); %check the waiting list (command unix)
1397    if isequal(s,0)
1398        w(end)=[];
1399        str_displ={[w ' jobs in the waiting list'];'Select a priority:'};
1400        str={'urgent';'normal';'low'};
1401        [ind_answer,v] = listdlg('PromptString',str_displ,...
1402                'SelectionMode','single',...
1403                'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3);
1404        if isequal(v,0) % to handle Cancel button and figure close, 
1405           return % a better way should be create
1406        end
1407    else
1408        msgbox_uvmat('ERROR','batch system not available')
1409        return
1410    end
1411% end
1412%initialize the waitbars
1413set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001])
1414set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001])
1415set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001])
1416set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001])
1417set(handles.BATCH, 'Enable','Off')
1418set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])
1419
1420%get the filename root, nomenclature and numbers
1421filebase=get(handles.displ_filebase,'String');
1422% for Windows system find the UBC path name if needed
1423if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\')
1424    cur_dir=pwd;
1425    if ~isequal(cur_dir(2:3),':\')
1426        cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M:
1427    end
1428    [ss,ww]=dos(['net use ' filebase(1:2)]);
1429    if isequal(ss,0)
1430        rankpath=findstr(ww,'\\');
1431        if ~isempty(rankpath)
1432            wwrest=ww(rankpath:end);
1433            rankend=min(find(double(wwrest)==10))-1;
1434            filebase=[wwrest(1:rankend) filebase(3:end)];
1435            set(handles.displ_filebase,'String',filebase);
1436        end
1437    else
1438         msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed');
1439         set(handles.BATCH, 'Enable','On')
1440         set(handles.BATCH,'BackgroundColor',[1 0 0])
1441         return
1442    end
1443end
1444browse=get(handles.browse_root,'UserData')
1445ext_ima=browse.ext_ima;
1446nom_type_nc='_i1-i2';
1447nom_type_ima=browse.nom_type_ima;
1448% nom_type_nc=browse.nom_type_nc;
1449% if isequal(nom_type_ima2,[]),nom_type_ima2='ima_num';end; %default
1450% if isequal(nom_type_nc,[]),nom_type_nc='_i1-i2';end; %default
1451mode_list=get(handles.mode,'String');
1452mode_value=get(handles.mode,'Value');
1453mode=mode_list{mode_value};
1454time=get(handles.displ_filebase,'UserData'); %get the set of times
1455
1456[num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=...
1457find_pair_indices(handles,mode); %determine the pairs of processing file
1458
1459%check dir
1460subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data
1461subdir_civ2=get(handles.subdir_civ2,'String');
1462if isequal(subdir_civ1,''),subdir_civ1='A'; end% put default subdir
1463if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir
1464currentdir=pwd;%store the current working directory
1465[Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ_3D)
1466if ~exist(Path_ima,'dir')
1467    msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found'])
1468    return
1469end
1470cd(Path_ima);%move to the directory of the images
1471dircur=pwd; %current working directory
1472m2='';
1473[erread,message]=fileattrib(Path_ima);
1474if ~isempty(message) & ~isequal(message.UserWrite,1)
1475      errordlg(['No writting access to ' Path_ima])
1476      cd(currentdir)
1477      return
1478end
1479
1480%test for reference file in fix
1481ref_fix1=get(handles.ref_fix1,'UserData');
1482ref_fix2=get(handles.ref_fix2,'UserData');
1483if (~isempty(ref_fix1) & box_test(2)==1)|(~isempty(ref_fix2) & box_test(5)==1)
1484    errordlg('reference file not implemented in BATCH mode, use RUN')
1485    set(handles.BATCH, 'Enable','On')
1486    set(handles.BATCH,'BackgroundColor',[1 0 0])
1487    return
1488end
1489nbfield=length(num1_civ1);
1490nbslice=length(num_a_civ1);
1491   
1492%check the existence of the netcdf and image files involved
1493% if box_test(1)==1;%CIV1 activated
1494detect=1;
1495while detect==1 %name a new subdir if one of the netcdf files already exists
1496      for ifile=1:nbfield
1497%           for j=1:nbslice
1498              filename=name_generator(filebase,num1_civ1(ifile),[],'.nc',...
1499                '_i1-i2',1,num2_civ1(ifile),[],subdir_civ1);%
1500            detect=exist(filename,'file')
1501              if detect% if a netcdf file already exists
1502                 subdir_civ1=[subdir_civ1 '.0'];
1503                 subdir_civ2=subdir_civ1;
1504                 break
1505              end
1506              filecell_nc1(ifile)={filename};
1507          if detect% if a netcdf file already exists
1508              break
1509          end
1510      end
1511       %create the new subdir_civ1 if it does not exist
1512      if ~exist(fullfile(Path_ima,subdir_civ1),'dir')
1513          [m1,m2,m3]=mkdir(subdir_civ1)
1514           if ~isequal(m2,'')
1515               msgbox(m2);%error message for directory creation
1516          end
1517     end
1518end
1519%get image names
1520for ifile=1:nbfield
1521    filecell_ima1_civ1{ifile}=name_generator(filebase, num1_civ1(ifile),[],'.vol','_i');%first image
1522    filecell_ima2_civ1{ifile}=name_generator(filebase, num2_civ1(ifile),[],'.vol','_i'); %second image
1523     if ~exist(filecell_ima1_civ1{ifile},'file')
1524            msgbox_uvmat('ERROR',[filecell_ima1_civ1{ifile} ' not found'])
1525            set(handles.BATCH, 'Enable','On')
1526            set(handles.BATCH,'BackgroundColor',[1 0 0])
1527            cd(currentdir)
1528            return
1529     end     
1530     if ~exist(filecell_ima2_civ1{ifile},'file')
1531            msgbox_uvmat('ERROR',[filecell_ima2_civ1{ifile} ' not found'])
1532            set(handles.BATCH, 'Enable','On')
1533            set(handles.BATCH,'BackgroundColor',[1 0 0])
1534            cd(currentdir)
1535            return
1536     end
1537end
1538
1539cd(currentdir);%come back to the initial working directory
1540% if ~isequal(m2,'')
1541%      msgbox(m2);%error message for directory creation
1542% end
1543set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box
1544set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box
1545browse.nom_type_nc=nom_type_nc;
1546set(handles.browse_root,'UserData',browse);%update the nomenclature type for uvmat
1547
1548for ifile=1:nbfield
1549    i_cmd=0;
1550    cmd='';
1551    if sge
1552       cmd='#!/bin/bash';
1553       cmd=char({cmd;'#$ -cwd'});
1554       cmd=char({cmd;'hostname && date'});
1555    end
1556    filename_cmx=cell2mat(filecell_nc1(ifile));%output netcdf file
1557    filename_cmx([end-1:end])='cm';%name of cmx file
1558    filename_cmx=[filename_cmx 'x'];
1559   
1560%CIV1
1561    if box_test(1)==1
1562        %GET civ_3D PARAMETERS:
1563        par_civ1=read_param_civ1(handles,cell2mat(filecell_ima1_civ1(1,1)));
1564        p1text=[];
1565        [par_civ1.path,resu_file,resu_ext]=fileparts(filecell_nc1{ifile});
1566        par_civ1.volume1=filecell_ima1_civ1{ifile};
1567        par_civ1.volume2=filecell_ima2_civ1{ifile};
1568        par_civ1.nx=str2double(get(handles.npx,'String'));
1569        par_civ1.ny=str2double(get(handles.npy,'String'));;
1570        par_civ1.nz=par_civ1.gridLimits_Zmax - par_civ1.gridLimits_Zmin;
1571        'TEST'
1572        par_civ1
1573        % civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method
1574        % if isequal(civAll,1)
1575        civAllxml=struct2xml(par_civ1);% xml contents,  all parameters
1576        civAllxml=set(civAllxml,1,'name','civ3d3c');
1577    %    save(civAllxml)
1578        par_civ1_3d_xml=fullfile(par_civ1.path,[resu_file '.xml']);%[par_civ1.path '/test_to_change.xml'];
1579         pvalue=num2str((1-ind_answer)*500)
1580        save(civAllxml,par_civ1_3d_xml);
1581   
1582%       if(isunix && sge)
1583         ['echo /CIVX/bin/MPI/lam-7.1.3_g95/bin/mpirun C  ' Civ3D3CBin ' -p ' par_civ1_3d_xml '|qsub -p ' pvalue ' -q lam.q -pe lam_loose 16 -e ' par_civ1_3d_xml '.errors -o ' par_civ1_3d_xml '.log' ]
1584         eval ( ['!echo /CIVX/bin/MPI/lam-7.1.3_g95/bin/mpirun C  ' Civ3D3CBin ' -p ' par_civ1_3d_xml '|qsub -p ' pvalue ' -q lam.q -pe lam_loose 16 -e ' par_civ1_3d_xml '.errors -o ' par_civ1_3d_xml '.log' ])
1585%       else
1586%           '3D mode is NOT supported without sge'
1587%       end
1588     return
1589        % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1590        %  fichier xml produit
1591        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1592        % A CONTINUER
1593        %civAllxml
1594        civAllCmd=[];
1595        civAllxml=set(civAllxml,1,'name','civ3d3c');
1596        namelog=[filename_cmx([1:end-3]) 'log'];
1597        %par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(1)));
1598        %par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(1)))/2);
1599       % test_mask=get(handles.get_mask_civ1,'Value');
1600        i_cmd=i_cmd+1;
1601%         if isequal(civAll,0)
1602%             cmd=char({cmd;BATCH_CIV1(filename_cmx([1:end-4]),namelog,par_civ1,handles)});
1603%         else
1604             civAllCmd=[civAllCmd ' civ1 '];
1605             str=BATCH_CIV1_Unified(filename_cmx([1:end-4]),namelog,par_civ1,handles);
1606            fieldnames=fields(str);
1607            [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1');
1608            for ilist=1:length(fieldnames)
1609              val=eval(['str.' fieldnames{ilist}]);
1610              if ischar(val)
1611                [civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist});
1612                [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);
1613               end
1614            end   
1615%         end
1616    end         
1617    if(isunix)
1618            cmd=char({cmd ; ['cp -f ' filename_cmx '2 ' filename_cmx]; cmd_CIV2});
1619    else
1620        cmd=char({cmd ; ['copy /Y ' filename_cmx '2 ' filename_cmx]; cmd_CIV2});
1621    end
1622end
1623     
1624%  if isequal(civAll,1)
1625    save(civAllxml,[filename_cmx([1:end-4]) '.xml']);
1626    cmd=char({cmd;[Civ_exe ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]});
1627
1628     %save(civAllxml,'/tmp/test.xml');
1629%  end
1630
1631
1632% create the .bat file:
1633if sge
1634        [Rootbat,Filebat,extbat]=fileparts(filename_cmx);
1635        filename_bat=fullfile(Rootbat,['job_' Filebat extbat]);
1636else
1637    filename_bat=filename_cmx;
1638end
1639filename_bat(end-2:end)='bat';
1640
1641%     pbat=fopen(filename_bat,'w'); %create the file filename_bat
1642dlmwrite(filename_bat,cmd,'');%write commands in filename_bat
1643if sge
1644    pvalue=num2str((1-ind_answer)*500);
1645    namelog=[filename_bat '.patch.log'];
1646    ['!qsub -p ' pvalue ' -q civ_3D.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat];
1647    eval(  ['!qsub -p ' pvalue ' -q civ_3D.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]);
1648else
1649    if(isunix)
1650      cmdtodo=['. ' filename_bat ];%removed for Mathieu tests %' && rm -f ' filename_bat] ;
1651    else
1652%      cmdtodo=[filename_bat ' && del /F /Q ' filename_bat];
1653       cmdtodo=[filename_bat];%removed for Mathieu tests %' && del /F /Q ' filename_bat' ;
1654    end
1655    count= fprintf(p1,'%s\n', cmdtodo);
1656end
1657if ~sge
1658    fclose(p1);
1659    fclose(p0);
1660    delete(name_lock);
1661end
1662set(handles.BATCH, 'Enable','On')
1663set(handles.BATCH,'BackgroundColor',[1 0 0])
1664%save interface state
1665[Path,Name]=fileparts(filebase);
1666namefig=fullfile(Path,subdir_civ2,Name);
1667detect=1;
1668while detect==1
1669    namefigfull=[namefig '.fig'];
1670    hh=dir(namefigfull);
1671    if ~isempty(hh)
1672        detect=1;
1673        namefig=[namefig '.0'];
1674    else
1675        detect=0;
1676    end
1677end
1678saveas(gcbf,namefigfull);%save the interface with name namefigfull
1679
1680
1681%----------------------------------------
1682%PATCH
1683%---------------------------------------
1684function cmd_PATCH=RUN_PATCH(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp)
1685global patch_exe patch_new_exe
1686        namelog=[filename_nc([1:end-3]) '_patch.log'];
1687        if test_interp==0
1688            cmd_PATCH=[patch_exe ' -f ' filename_nc ' -m ' nx_patch  ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ...
1689            '  > ' namelog ' 2>&1'] % redirect standard output to the log file
1690         else %nouveau programme patch
1691             cmd_PATCH=[patch_new_exe ' -f ' filename_nc ' -m ' nx_patch  ' -n ' ny_patch ' -ro ' rho_patch ...
1692                ' -max ' thresh_value ' -nopt ' subdomain_patch  '  > ' namelog ' 2>&1']; % redirect standard output to the log file
1693        end
1694
1695 
1696%----------------------------------------------------
1697function first_j_Callback(hObject, eventdata, handles)
1698last_j_Callback(hObject, eventdata, handles)
1699
1700%---------------------------------------------------------
1701% --- Executes on button press in CIV1.
1702function CIV1_Callback(hObject, eventdata, handles)
1703enable_civ1(handles,get(handles.CIV1,'Value'))
1704find_netcpair_civ1(hObject, eventdata, handles);
1705
1706%------------------------------------------------------
1707% --- Executes on button press in FIX1.
1708function FIX1_Callback(hObject, eventdata, handles)
1709
1710if get(handles.FIX1,'Value')==1
1711enable_fix1(handles)
1712else
1713desable_fix1(handles)
1714end
1715
1716%----------------------------------------------------------------
1717% --- Executes on button press in PATCH1.
1718function PATCH1_Callback(hObject, eventdata, handles)
1719
1720if get(handles.PATCH1,'Value')==1
1721enable_patch1(handles)
1722else
1723desable_patch1(handles)
1724end
1725
1726%----------------------------------------------------------
1727% --- Executes on button press in CIV2.
1728function CIV2_Callback(hObject, eventdata, handles)
1729state=get(handles.CIV2,'Value');
1730enable_civ2(handles,state)
1731if state
1732    find_netcpair_civ2(hObject, eventdata, handles)
1733end
1734
1735%---------------------------------------------------
1736% --- Executes on button press in FIX2.
1737function FIX2_Callback(hObject, eventdata, handles)
1738if get(handles.FIX2,'Value')==1
1739    enable_fix2(handles)
1740    if get(handles.CIV2,'Value')==0
1741        find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files
1742    end
1743else
1744    desable_fix2(handles)
1745end
1746
1747
1748%-------------------------------------------------------
1749% --- Executes on button press in PATCH2.
1750function PATCH2_Callback(hObject, eventdata, handles)
1751%--------------------------------------------------------
1752if get(handles.PATCH2,'Value')==1
1753    enable_patch2(handles)
1754    if get(handles.CIV2,'Value')==0
1755        find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files
1756    end
1757else
1758    desable_patch2(handles)
1759end
1760
1761
1762
1763%-----------------------------------------------------------
1764function first_i_Callback(hObject, eventdata, handles)
1765%------------------------------------------------------
1766last_i_Callback(hObject, eventdata, handles)
1767
1768%-----------------------------------------------------------
1769% --- Executes on button press in calcul_search: determine the search range isx,isy
1770%--------------------------------------------------------
1771function calcul_search_Callback(hObject, eventdata, handles)
1772
1773%determine pair numbers
1774list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs
1775index=get(handles.list_pair_civ1,'Value');
1776displ_num=get(handles.list_pair_civ1,'UserData');
1777time=get(handles.displ_filebase,'UserData'); %get the set of times
1778pxcm_xy=get(handles.calcul_search,'UserData')
1779pxcmx=pxcm_xy(1);
1780pxcmy=pxcm_xy(2);
1781mode_list=get(handles.mode,'String');
1782mode_value=get(handles.mode,'Value');
1783mode=mode_list{mode_value};
1784if isequal (mode, 'series(Di)' )
1785    ref_i=str2num(get(handles.ref_i,'String'));
1786    num1=ref_i-floor(index/2);%  first image numbers
1787    num2=ref_i+ceil(index/2);
1788    num_a=1;
1789    num_b=1;
1790elseif isequal (mode, 'series(Dj)')
1791    num1=1;
1792    num2=1;
1793    ref_j=str2num(get(handles.ref_j,'String'));
1794    num_a=ref_j-floor(index/2);%  first image numbers
1795    num_b=ref_j+ceil(index/2);
1796elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D)
1797    ref_i=str2num(get(handles.ref_i,'String'));
1798    num1=ref_i;
1799    num2=ref_i;
1800    num_a=displ_num(1,index);
1801    num_b=displ_num(2,index);
1802end
1803dt=time(num2,num_b)-time(num1,num_a);
1804ibx=str2num(get(handles.ibx,'String'));
1805iby=str2num(get(handles.iby,'String'));
1806umin=dt*pxcmx*str2num(get(handles.umin,'String'));
1807umax=dt*pxcmx*str2num(get(handles.umax,'String'));
1808vmin=dt*pxcmy*str2num(get(handles.vmin,'String'));
1809vmax=dt*pxcmy*str2num(get(handles.vmax,'String'));
1810shiftx=round((umin+umax)/2);
1811shifty=round((vmin+vmax)/2);
1812isx=(umax+2-shiftx)*2+ibx;
1813isx=2*ceil(isx/2)+1;
1814isy=(vmax+2-shifty)*2+iby;
1815isy=2*ceil(isy/2)+1;
1816set(handles.shiftx,'String',num2str(shiftx));
1817set(handles.shifty,'String',num2str(shifty));
1818set(handles.isx,'String',num2str(isx));
1819set(handles.isy,'String',num2str(isy));
1820
1821
1822%---------------------------------------------------------
1823% Executes on carriage return on the subdir civ1 edit window
1824%--------------------------------------------------------
1825function subdir_civ1_Callback(hObject, eventdata, handles)
1826subdir=get(handles.subdir_civ1,'String');
1827set(handles.subdir_civ2,'String',subdir);
1828if get(handles.CIV1,'Value')==0
1829    find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory
1830end
1831
1832%---------------------------------------------------------
1833% Executes on carriage return on the subdir civ1 edit window
1834%---------------------------------------------------------
1835function subdir_civ2_Callback(hObject, eventdata, handles)
1836%update the list of available pairs from netcdf files in the new directory
1837if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0
1838    find_netcpair_civ2(hObject, eventdata, handles);
1839end
1840
1841%------------------------------------------------------
1842% --- Executes on button press in get_mask_civ1.
1843%------------------------------------------------------
1844function get_mask_civ1_Callback(hObject, eventdata, handles)
1845maskval=get(handles.get_mask_civ1,'Value')
1846if isequal(maskval,0)
1847    set(handles.mask_civ1,'String','')
1848else
1849mask_displ='no mask'; %default
1850filebase=get(handles.displ_filebase,'String');
1851[ nbslice, flag_mask]=get_mask(filebase,handles)
1852if isequal(flag_mask,1)
1853      mask_displ=[num2str(nbslice) 'mask'];
1854end
1855if get(handles.compare,'Value')==1 & ~isequal(mask_displ,'no mask')% look for the second mask series
1856        filebase_a=get(handles.displ_filebase2,'String');
1857        [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles)
1858        if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
1859            mask_displ='no mask';
1860        end
1861end
1862if isequal(mask_displ,'no mask')
1863    set(handles.get_mask_civ1,'Value',0)
1864    set(handles.get_mask_fix1,'Value',0)
1865    set(handles.get_mask_civ2,'Value',0)
1866    set(handles.get_mask_fix2,'Value',0)
1867else
1868    set(handles.get_mask_fix1,'Value',1)
1869    set(handles.get_mask_civ2,'Value',1)
1870    set(handles.get_mask_fix2,'Value',1)
1871end
1872set(handles.mask_civ1,'String',mask_displ)
1873set(handles.mask_fix1,'String',mask_displ)
1874set(handles.mask_civ2,'String',mask_displ)
1875set(handles.mask_fix2,'String',mask_displ)
1876end
1877%--------------------------------------------------------------
1878% --- Executes on button press in get_mask_fix1.
1879function get_mask_fix1_Callback(hObject, eventdata, handles)
1880maskval=get(handles.get_mask_fix1,'Value')
1881if isequal(maskval,0)
1882    set(handles.mask_fix1,'String','')
1883else
1884mask_displ='no mask'; %default
1885filebase=get(handles.displ_filebase,'String');
1886[nbslice, flag_mask]=get_mask(filebase,handles)
1887if isequal(flag_mask,1)
1888      mask_displ=[num2str(nbslice) 'mask'];
1889end
1890if get(handles.compare,'Value')==1 & ~isequal(mask_displ,'no mask')% look for the second mask series
1891        filebase_a=get(handles.displ_filebase2,'String');
1892        [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles)
1893        if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
1894            mask_displ='no mask';
1895        end
1896end
1897if isequal(mask_displ,'no mask')
1898    set(handles.get_mask_fix1,'Value',0)
1899    set(handles.get_mask_civ2,'Value',0)
1900    set(handles.get_mask_fix2,'Value',0)
1901else
1902    set(handles.get_mask_civ2,'Value',1)
1903    set(handles.get_mask_fix2,'Value',1)
1904end
1905set(handles.mask_fix1,'String',mask_displ)
1906set(handles.mask_civ2,'String',mask_displ)
1907set(handles.mask_fix2,'String',mask_displ)
1908end
1909%-----------------------------------------
1910% --- Executes on button press in get_mask_civ2.
1911function get_mask_civ2_Callback(hObject, eventdata, handles)
1912maskval=get(handles.get_mask_civ2,'Value')
1913if isequal(maskval,0)
1914    set(handles.mask_civ2,'String','')
1915else
1916mask_displ='no mask'; %default
1917filebase=get(handles.displ_filebase,'String');
1918[nbslice, flag_mask]=get_mask(filebase,handles)
1919if isequal(flag_mask,1)
1920      mask_displ=[num2str(nbslice) 'mask'];
1921end
1922if get(handles.compare,'Value')==1 & ~isequal(mask_displ,'no mask')% look for the second mask series
1923        filebase_a=get(handles.displ_filebase2,'String');
1924        [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles)
1925        if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
1926            mask_displ='no mask';
1927        end
1928end
1929if isequal(mask_displ,'no mask')
1930    set(handles.get_mask_civ2,'Value',0)
1931    set(handles.get_mask_fix2,'Value',0)
1932else
1933    set(handles.get_mask_fix2,'Value',1)
1934end
1935set(handles.mask_civ2,'String',mask_displ)
1936set(handles.mask_fix2,'String',mask_displ)
1937end
1938%-------------------------------------
1939% --- Executes on button press in get_mask_fix2.
1940function get_mask_fix2_Callback(hObject, eventdata, handles)
1941maskval=get(handles.get_mask_fix2,'Value')
1942if isequal(maskval,0)
1943    set(handles.mask_fix2,'String','')
1944else
1945mask_displ='no mask'; %default
1946filebase=get(handles.displ_filebase,'String');
1947[nbslice, flag_mask]=get_mask(filebase,handles)
1948if isequal(flag_mask,1)
1949      mask_displ=[num2str(nbslice) 'mask'];
1950end
1951if get(handles.compare,'Value')==1 & ~isequal(mask_displ,'no mask')% look for the second mask series
1952        filebase_a=get(handles.displ_filebase2,'String');
1953        [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles)
1954        if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
1955            mask_displ='no mask';
1956        end
1957end
1958if isequal(mask_displ,'no mask')
1959    set(handles.get_mask_fix2,'Value',0)
1960end
1961set(handles.mask_fix2,'String',mask_displ)
1962end
1963
1964%---------------------------------------
1965function [nbslice, flag_mask]=get_mask(filebase,handles)
1966%detect mask files, images with appropriate file base
1967%[filebase '_' xx 'mask'], xx=nbslice
1968%flag_mask=1 indicates detection
1969
1970flag_mask=0;%default
1971nbslice=1;
1972
1973% subdir=get(handles.subdir_civ1,'String');
1974[Path,Name]=fileparts(filebase)
1975currentdir=pwd;
1976cd(Path);%move in the dir of the root name filebase
1977maskfiles=dir([Name '_*mask_*.png'])%look for mask files
1978cd(currentdir);%come back to the current working directory
1979if isempty(maskfiles)
1980    browse=get(handles.browse_root,'UserData');
1981     varargin{1}='';
1982    image_name=name_generator(filebase,1,1,browse.ext_ima,browse.nom_type_ima);%name of an image
1983    if exist(image_name,'file')
1984         varargin{1}=image_name;
1985    end
1986    msgbox_uvmat('ERROR','no mask available, use TOOL menu in the uvmat interface to create it')
1987%     makemask(varargin); %open the makemask interface
1988else
1989    maskname=maskfiles(1).name;% take the first mask file in the list
1990    [Path2,Name,ext]=fileparts(maskname);
1991    Namedouble=double(Name);
1992    val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
1993    ind_mask=findstr('mask',Name);
1994    i=ind_mask-1;
1995    while val(i)==0 & i>0
1996       i=i-1;
1997    end
1998    nbslice=str2num(Name(i+1:ind_mask-1));
1999    if ~isequal(nbslice,[]) & Name(i)=='_'
2000          flag_mask=1;
2001    else
2002          errordlg(['bad mask file ' Name ext ' found in ' Path2])
2003          return
2004          nbslice=1;
2005    end
2006end   
2007%------------------------------
2008
2009
2010function grid_civ1_Callback(hObject, eventdata, handles)
2011% hObject    handle to grid_civ1 (see GCBO)
2012% eventdata  reserved - to be defined in a future version of MATLAB
2013% handles    structure with handles and user data (see GUIDATA)
2014
2015% Hints: get(hObject,'String') returns contents of grid_civ1 as text
2016%        str2double(get(hObject,'String')) returns contents of grid_civ1 as a double
2017
2018
2019%-----------------------------------------------------------
2020% transform numbers to letters
2021%--------------------------------------------
2022function str=num2stra(num,nom_type);
2023if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD')
2024    str=char(96+num);
2025elseif isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')...
2026        |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none')
2027    str='';
2028else
2029    str=num2str(num);
2030end
2031%---------------------------------------------------
2032function mask_civ1_Callback(hObject, eventdata, handles)
2033set(handles.mask_civ1,'UserData',[])
2034set(handles.mask_civ1,'String','')
2035%----------------------------------------------------
2036function mask_civ2_Callback(hObject, eventdata, handles)
2037set(handles.mask_civ2,'UserData',[])
2038set(handles.mask_civ2,'String','')
2039%----------------------------------------------------
2040function mask_fix1_Callback(hObject, eventdata, handles)
2041set(handles.mask_fix1,'UserData',[])
2042set(handles.mask_fix1,'String','')
2043%----------------------------------------------------
2044function mask_fix2_Callback(hObject, eventdata, handles)
2045set(handles.mask_fix2,'UserData',[])
2046set(handles.mask_fix2,'String','')
2047
2048%--------------------------------------------------------------------------
2049% --- Executes on button press in list_subdir_civ1.
2050function list_subdir_civ1_Callback(hObject, eventdata, handles)
2051
2052filebase=get(handles.displ_filebase,'String');
2053dirinput = uigetdir(filebase)
2054    set(handles.subdir_civ1,'String',dirinput)
2055    set(handles.subdir_civ2,'String',dirinput)
2056
2057displ_filebase_Callback(hObject, eventdata, handles);
2058
2059
2060function rho_civ2_Callback(hObject, eventdata, handles)
2061% hObject    handle to rho_civ2 (see GCBO)
2062% eventdata  reserved - to be defined in a future version of MATLAB
2063% handles    structure with handles and user data (see GUIDATA)
2064
2065% Hints: get(hObject,'String') returns contents of rho_civ2 as text
2066%        str2double(get(hObject,'String')) returns contents of rho_civ2 as a double
2067
2068%----------------------------------------------
2069function last_i_Callback(hObject, eventdata, handles)
2070first_i=str2num(get(handles.first_i,'String'));
2071last_i=str2num(get(handles.last_i,'String'));
2072ref_i=ceil((first_i+last_i)/2);
2073set(handles.ref_i,'String', num2str(ref_i))
2074ref_i_Callback(hObject, eventdata, handles)
2075
2076%-------------------------------------------------------
2077function last_j_Callback(hObject, eventdata, handles)
2078first_j=str2num(get(handles.first_j,'String'));
2079last_j=str2num(get(handles.last_j,'String'));
2080ref_j=ceil((first_j+last_j)/2);
2081set(handles.ref_j,'String', num2str(ref_j))
2082ref_j_Callback(hObject, eventdata, handles)
2083
2084%--------------------------------------------------------------------------
2085% --- Executes on button press in browse_gridciv1.
2086function browse_gridciv1_Callback(hObject, eventdata, handles)
2087value=get(handles.browse_gridciv1,'Value');
2088if value
2089        filebase=get(handles.displ_filebase,'String');
2090        [FileName, PathName, filterindex] = uigetfile( ...
2091           {'*.grid', ' (*.grid)';
2092            '*.grid',  '.grid files '; ...
2093            '*.*', 'All Files (*.*)'}, ...
2094            'Pick a file',filebase);
2095        filegrid=fullfile(PathName,FileName);
2096    if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file')
2097        set(handles.browse_gridciv1,'Value',0);
2098        set(handles.grid_civ1,'string','');
2099            set(handles.dx_civ1,'Visible','on');
2100            set(handles.dy_civ1,'Visible','on');
2101            set(handles.grid_civ2,'string','');
2102        if get(handles.CIV2,'Value')
2103                set(handles.dx_civ2,'Visible','on');
2104                set(handles.dy_civ2,'Visible','on');
2105        end
2106    else
2107                set(handles.grid_civ1,'string',filegrid);
2108                set(handles.dx_civ1,'Visible','off');
2109                set(handles.dy_civ1,'Visible','off');
2110                set(handles.grid_civ2,'string',filegrid);
2111                set(handles.dx_civ2,'Visible','off');
2112                set(handles.dy_civ2,'Visible','off');
2113% set(handles.grid_patch1,'string',filegrid);
2114% set(handles.grid_patch2,'string',filegrid);
2115    end
2116else
2117    set(handles.grid_civ1,'string','');
2118        set(handles.dx_civ1,'Visible','on');
2119        set(handles.dy_civ1,'Visible','on');
2120        set(handles.grid_civ2,'string','');
2121    if get(handles.CIV2,'Value')
2122            set(handles.dx_civ2,'Visible','on');
2123            set(handles.dy_civ2,'Visible','on');
2124    end
2125end
2126
2127
2128
2129function pxcmx_Callback(hObject, eventdata, handles)
2130% hObject    handle to pxcmx (see GCBO)
2131% eventdata  reserved - to be defined in a future version of MATLAB
2132% handles    structure with handles and user data (see GUIDATA)
2133
2134% Hints: get(hObject,'String') returns contents of pxcmx as text
2135%        str2double(get(hObject,'String')) returns contents of pxcmx as a double
2136
2137
2138
2139function pxcmy_Callback(hObject, eventdata, handles)
2140% hObject    handle to pxcmy (see GCBO)
2141% eventdata  reserved - to be defined in a future version of MATLAB
2142% handles    structure with handles and user data (see GUIDATA)
2143
2144% Hints: get(hObject,'String') returns contents of pxcmy as text
2145%        str2double(get(hObject,'String')) returns contents of pxcmy as a double
2146
2147
2148% --- Executes on button press in browse_gridciv2.
2149function browse_gridciv2_Callback(hObject, eventdata, handles)
2150
2151filebase=get(handles.displ_filebase,'String');
2152[FileName, PathName, filterindex] = uigetfile( ...
2153       {'*.grid', ' (*.grid)';
2154        '*.grid',  '.grid files '; ...
2155        '*.*', 'All Files (*.*)'}, ...
2156        'Pick a file',filebase);
2157filegrid=fullfile(PathName,FileName);
2158set(handles.grid_civ2,'string',filegrid);
2159set(handles.dx_civ2,'String',' ');
2160set(handles.dy_civ2,'String',' ');
2161% set(handles.grid_patch2,'string',filegrid);
2162
2163% --- Executes on button press in get_gridpatch1.
2164function get_gridpatch1_Callback(hObject, eventdata, handles)
2165% hObject    handle to get_gridpatch1 (see GCBO)
2166% eventdata  reserved - to be defined in a future version of MATLAB
2167% handles    structure with handles and user data (see GUIDATA)
2168
2169filebase=get(handles.displ_filebase,'String');
2170[FileName, PathName, filterindex] = uigetfile( ...
2171       {'*.grid', ' (*.grid)';
2172        '*.grid',  '.grid files '; ...
2173        '*.*', 'All Files (*.*)'}, ...
2174        'Pick a file',filebase);
2175filegrid=fullfile(PathName,FileName);
2176set(handles.grid_patch1,'string',filegrid);
2177% set(handles.grid_patch2,'string',filegrid
2178
2179%-----------------------------------------------------------------
2180% --- Executes on button press in get_gridpatch2.
2181function get_gridpatch2_Callback(hObject, eventdata, handles)
2182% hObject    handle to get_gridpatch2 (see GCBO)
2183% eventdata  reserved - to be defined in a future version of MATLAB
2184% handles    structure with handles and user data (see GUIDATA)
2185
2186
2187%----------------------------------------------------------
2188function enable_civ1(handles,state)
2189if isequal(state,0)
2190    state='off';
2191end
2192if isequal(state,1)
2193    state='on';
2194end
2195if isequal(state,'on')
2196    set(handles.frame_civ1,'BackgroundColor',[1 1 0])
2197    set(handles.frame_para_civ1,'BackgroundColor',[1 1 0])
2198    set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0])
2199else
2200    set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784])
2201    set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784])
2202    set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784])
2203end
2204set(handles.ibx,'Visible',state)
2205set(handles.iby,'Visible',state)
2206set(handles.isx,'Visible',state)
2207set(handles.isy,'Visible',state)
2208set(handles.shiftx,'Visible',state)
2209set(handles.shifty,'Visible',state)
2210set(handles.rho,'Visible',state)
2211set(handles.dx_civ1,'Visible',state)
2212set(handles.dy_civ1,'Visible',state)
2213set(handles.calcul_search,'Visible',state)
2214set(handles.u_text,'Visible',state)
2215set(handles.v_text,'Visible',state)
2216set(handles.min,'Visible',state)
2217set(handles.max,'Visible',state)
2218set(handles.umin,'Visible',state)
2219set(handles.umax,'Visible',state)
2220set(handles.vmin,'Visible',state)
2221set(handles.vmax,'Visible',state)
2222set(handles.grid_civ1,'Visible',state)
2223set(handles.mask_civ1,'Visible',state)
2224set(handles.browse_gridciv1,'Visible',state)
2225set(handles.get_mask_civ1,'Visible',state)
2226set(handles.parameters,'Visible',state)
2227set(handles.grid,'Visible',state)
2228set(handles.dx_civ1,'Visible',state)
2229set(handles.dy_civ1,'Visible',state)
2230set(handles.ImaThreshold,'Visible',state)
2231if isequal(state,'off')
2232    set(handles.MinIma,'Visible','off')
2233    set(handles.MaxIma,'Visible','off')
2234    set(handles.ImaThreshold,'Value',0)
2235end
2236set(handles.dx_civ1_title,'Visible',state)
2237set(handles.dy_civ1_title,'Visible',state)
2238set(handles.ImaThreshold_title,'Visible',state)
2239set(handles.ib_title,'Visible',state)
2240set(handles.is_title,'Visible',state)
2241set(handles.shift_title,'Visible',state)
2242set(handles.rho_title,'Visible',state)
2243
2244%----------------------------------------------------------
2245function enable_fix1(handles)
2246set(handles.frame_fix1,'BackgroundColor',[1 1 0])
2247set(handles.REMOVE,'Visible','on')
2248set(handles.vec_Fmin2,'Visible','on')
2249set(handles.vec_F2,'Visible','on')
2250set(handles.vec_F3,'Visible','on')
2251set(handles.thresh_vecC,'Visible','on')
2252set(handles.thresh_vecC_title,'Visible','on')
2253set(handles.thresh_vel,'Visible','on')
2254set(handles.thresh_vel_text,'Visible','on')
2255set(handles.mask_fix1,'Visible','on')
2256set(handles.get_mask_fix1,'Visible','on')
2257set(handles.get_ref_fix1,'Visible','on')
2258set(handles.ref_fix1,'Visible','on')
2259set(handles.inf_sup1,'Visible','on')
2260set(handles.field_ref1,'Visible','on')
2261
2262%----------------------------------------------------------
2263function desable_fix1(handles)
2264set(handles.frame_fix1,'BackgroundColor',[0.831 0.816 0.784])
2265set(handles.REMOVE,'Visible','off')
2266set(handles.vec_Fmin2,'Visible','off')
2267set(handles.vec_F2,'Visible','off')
2268set(handles.vec_F3,'Visible','off')
2269set(handles.thresh_vecC,'Visible','off')
2270set(handles.thresh_vecC_title,'Visible','off')
2271set(handles.thresh_vel,'Visible','off')
2272set(handles.thresh_vel_text,'Visible','off')
2273set(handles.mask_fix1,'Visible','off')
2274set(handles.get_mask_fix1,'Visible','off')
2275set(handles.get_ref_fix1,'Visible','off')
2276set(handles.ref_fix1,'Visible','off')
2277set(handles.inf_sup1,'Visible','off')
2278set(handles.field_ref1,'Visible','off')
2279
2280%--------------------------------------------------------------
2281function enable_patch1(handles)
2282global patch_new_exe
2283set(handles.frame_patch1,'BackgroundColor',[1 1 0])
2284set(handles.rho_patch1,'Visible','on')
2285set(handles.rho_text1,'Visible','on')
2286set(handles.thresh_patch1,'Visible','on')
2287set(handles.thresh_text1,'Visible','on')
2288set(handles.subdomain_patch1,'Visible','on')
2289set(handles.subdomain_text1,'Visible','on')
2290set(handles.nx_patch1,'Visible','on')
2291set(handles.ny_patch1,'Visible','on')
2292set(handles.nx_patch1_title,'Visible','on')
2293set(handles.ny_patch1_title,'Visible','on')
2294if (~isequal(patch_new_exe,[]) & ~isequal(patch_new_exe,[]))
2295    set(handles.test_interp,'Visible','on');
2296end
2297set(handles.get_gridpatch1,'Visible','on')
2298set(handles.grid_patch1,'string','none');
2299set(handles.grid_patch1,'Visible','on')
2300
2301%--------------------------------------------------------------
2302function desable_patch1(handles)
2303set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784])
2304set(handles.rho_patch1,'Visible','off')
2305set(handles.rho_text1,'Visible','off')
2306set(handles.thresh_patch1,'Visible','off')
2307set(handles.thresh_text1,'Visible','off')
2308set(handles.subdomain_patch1,'Visible','off')
2309set(handles.subdomain_text1,'Visible','off')
2310set(handles.nx_patch1,'Visible','off')
2311set(handles.ny_patch1,'Visible','off')
2312set(handles.nx_patch1_title,'Visible','off')
2313set(handles.ny_patch1_title,'Visible','off')
2314set(handles.test_interp,'Visible','off')
2315set(handles.get_gridpatch1,'Visible','off')
2316set(handles.grid_patch1,'Visible','off')
2317
2318%----------------------------------------------------------
2319function enable_civ2(handles,state)
2320if isequal(state,0)
2321    state='off';
2322end
2323if isequal(state,1)
2324    state='on';
2325end
2326if isequal(state,'on')
2327    set(handles.frame_civ2,'BackgroundColor',[1 1 0])
2328    set(handles.frame_para_civ2,'BackgroundColor',[1 1 0])
2329    set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0])
2330    set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])
2331else
2332    set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784])
2333    set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784])
2334    set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784])
2335    set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784])
2336end
2337set(handles.ibx_civ2,'Visible',state)
2338set(handles.iby_civ2,'Visible',state)
2339set(handles.decimal,'Visible',state)
2340set(handles.deformation,'Visible',state)
2341set(handles.rho_civ2,'Visible',state)
2342set(handles.dx_civ2,'Visible',state)
2343set(handles.dy_civ2,'Visible',state)
2344set(handles.browse_gridciv2,'Visible',state)
2345set(handles.get_mask_civ2,'Visible',state)
2346set(handles.parameters,'Visible',state)
2347set(handles.grid,'Visible',state)
2348set(handles.parameters_text,'Visible',state)
2349set(handles.grid_text,'Visible',state)
2350set(handles.grid_civ2,'Visible',state)
2351set(handles.mask_civ2,'Visible',state)
2352set(handles.dx_civ2_title,'Visible',state)
2353set(handles.dy_civ2_title,'Visible',state)
2354set(handles.ibx_civ2_text,'Visible',state)
2355set(handles.rho_civ2_title,'Visible',state)
2356set(handles.ImaThreshold2,'Visible',state)
2357set(handles.ImaThreshold_title2,'Visible',state)
2358if isequal(state,'off')
2359    set(handles.MinIma2,'Visible','off')
2360    set(handles.MaxIma2,'Visible','off')
2361    set(handles.ImaThreshold2,'Value',0)
2362    if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0)
2363        set(handles.list_pair_civ2,'Visible','off')
2364        set(handles.subdir_civ2,'Visible','off')
2365        set(handles.subdir_civ2_text,'Visible','off')
2366    end
2367else
2368    set(handles.list_pair_civ2,'Visible','on')
2369    set(handles.subdir_civ2,'Visible','on')
2370    set(handles.subdir_civ2_text,'Visible','on')
2371end
2372
2373%----------------------------------------------------------
2374% function desable_civ2(handles)
2375% set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784])
2376% set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784])
2377% set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784])
2378% set(handles.ibx_civ2,'Visible','off')
2379% set(handles.iby_civ2,'Visible','off')
2380% set(handles.decimal,'Visible','off')
2381% set(handles.deformation,'Visible','off')
2382% set(handles.rho_civ2,'Visible','off')
2383% set(handles.dx_civ2,'Visible','off')
2384% set(handles.dy_civ2,'Visible','off')
2385% set(handles.browse_gridciv2,'Visible','off')
2386% set(handles.get_mask_civ2,'Visible','off')
2387% set(handles.parameters,'Visible','off')
2388% set(handles.grid,'Visible','off')
2389% set(handles.grid,'Visible','on')
2390% set(handles.parameters_text,'Visible','off')
2391% set(handles.grid_text,'Visible','off')
2392% set(handles.grid_civ2,'Visible','off')
2393% set(handles.mask_civ2,'Visible','off')
2394% set(handles.dx_civ2_title,'Visible','off')
2395% set(handles.dy_civ2_title,'Visible','off')
2396% set(handles.ibx_civ2_text,'Visible','off')
2397% set(handles.rho_civ2_title,'Visible','off')
2398% set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784])
2399% if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0)
2400%     set(handles.list_pair_civ2,'Visible','off')
2401%     set(handles.subdir_civ2,'Visible','off')
2402%     set(handles.subdir_civ2_text,'Visible','off')
2403% end
2404
2405%----------------------------------------------------------
2406function enable_fix2(handles)
2407set(handles.frame_fix2,'BackgroundColor',[1 1 0])
2408set(handles.REMOVE2,'Visible','on')
2409set(handles.vec_Fmin2_2,'Visible','on')
2410set(handles.vec_F4,'Visible','on')
2411set(handles.vec_F3_2,'Visible','on')
2412set(handles.thresh_vec2C,'Visible','on')
2413set(handles.thresh_vec2C_text,'Visible','on')
2414set(handles.thresh_vel2,'Visible','on')
2415set(handles.thresh_vel2_text,'Visible','on')
2416set(handles.mask_fix2,'Visible','on')
2417set(handles.get_mask_fix2,'Visible','on')
2418set(handles.list_pair_civ2,'Visible','on')
2419set(handles.subdir_civ2,'Visible','on')
2420set(handles.subdir_civ2_text,'Visible','on')
2421set(handles.get_ref_fix2,'Visible','on')
2422set(handles.ref_fix2,'Visible','on')
2423set(handles.inf_sup2,'Visible','on')
2424set(handles.field_ref2,'Visible','on')
2425
2426%----------------------------------------------------------
2427function desable_fix2(handles)
2428set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784])
2429set(handles.REMOVE2,'Visible','off')
2430set(handles.vec_Fmin2_2,'Visible','off')
2431set(handles.vec_F4,'Visible','off')
2432set(handles.vec_F3_2,'Visible','off')
2433set(handles.thresh_vec2C,'Visible','off')
2434set(handles.thresh_vec2C_text,'Visible','off')
2435set(handles.thresh_vel2,'Visible','off')
2436set(handles.thresh_vel2_text,'Visible','off')
2437set(handles.mask_fix2,'Visible','off')
2438set(handles.get_mask_fix2,'Visible','off')
2439set(handles.get_ref_fix2,'Visible','off')
2440set(handles.ref_fix2,'Visible','off')
2441set(handles.inf_sup2,'Visible','off')
2442set(handles.field_ref2,'Visible','off')
2443if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0)
2444    set(handles.list_pair_civ2,'Visible','off')
2445    set(handles.subdir_civ2,'Visible','off')
2446    set(handles.subdir_civ2_text,'Visible','off')
2447end
2448
2449%--------------------------------------------------------------
2450function enable_patch2(handles)
2451set(handles.frame_patch2,'BackgroundColor',[1 1 0])
2452set(handles.rho_patch2,'Visible','on')
2453set(handles.rho_text2,'Visible','on')
2454set(handles.thresh_patch2,'Visible','on')
2455set(handles.thresh_text2,'Visible','on')
2456set(handles.subdomain_patch2,'Visible','on')
2457set(handles.subdomain_text2,'Visible','on')
2458set(handles.nx_patch2,'Visible','on')
2459set(handles.ny_patch2,'Visible','on')
2460set(handles.nx_patch2_title,'Visible','on')
2461set(handles.ny_patch2_title,'Visible','on')
2462set(handles.get_gridpatch2,'Visible','on')
2463set(handles.grid_patch2,'Visible','on')
2464set(handles.list_pair_civ2,'Visible','on')
2465set(handles.subdir_civ2,'Visible','on')
2466set(handles.subdir_civ2_text,'Visible','on')
2467
2468%--------------------------------------------------------------
2469function desable_patch2(handles)
2470set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784])
2471set(handles.rho_patch2,'Visible','off')
2472set(handles.rho_text2,'Visible','off')
2473set(handles.thresh_patch2,'Visible','off')
2474set(handles.thresh_text2,'Visible','off')
2475set(handles.subdomain_patch2,'Visible','off')
2476set(handles.subdomain_text2,'Visible','off')
2477set(handles.nx_patch2,'Visible','off')
2478set(handles.ny_patch2,'Visible','off')
2479set(handles.nx_patch2_title,'Visible','off')
2480set(handles.ny_patch2_title,'Visible','off')
2481set(handles.get_gridpatch2,'Visible','off')
2482set(handles.grid_patch2,'Visible','off')
2483if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0)
2484    set(handles.list_pair_civ2,'Visible','off')
2485    set(handles.subdir_civ2,'Visible','off')
2486    set(handles.subdir_civ2_text,'Visible','off')
2487end
2488
2489% --- Executes on button press in test_interp.
2490function test_interp_Callback(hObject, eventdata, handles)
2491
2492
2493%------------------------------------------------
2494%Read the parameters for civ1 on the interface
2495%--------------------------------------------------
2496function par=read_param_civ1(handles,file_ima)
2497
2498ibx_val=str2num(get(handles.ibx,'String'));
2499par.correlationBoxesSize_X=num2str(ibx_val);
2500iby_val=str2num(get(handles.iby,'String'));
2501par.correlationBoxesSize_Y=num2str(iby_val);
2502ibz_val=str2num(get(handles.ibz,'String'));
2503par.correlationBoxesSize_Z=num2str(ibz_val);
2504isx=get(handles.isx,'String');
2505if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default
2506maxDisplacement_X=floor((str2num(isx)-ibx_val)/2);
2507par.maxDisplacement_X=num2str(maxDisplacement_X);
2508isy=get(handles.isy,'String');
2509if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end; %default
2510maxDisplacement_Y=floor((str2num(isy)-iby_val)/2);
2511par.maxDisplacement_Y=num2str(maxDisplacement_Y);
2512isz=get(handles.isz,'String');
2513if isempty(str2num(isz)), isz='41'; set(handles.isz,'String','41'), end; %default
2514maxDisplacement_Z=floor((str2num(isz)-ibz_val)/2);
2515par.maxDisplacement_Z=num2str(maxDisplacement_Z);
2516%      par.rho=get(handles.rho,'String');
2517par.gridSpacing_X=get(handles.dx_civ1,'String');
2518par.gridSpacing_Y=get(handles.dy_civ1,'String');
2519par.gridSpacing_Z=get(handles.dz_civ1,'String');
2520% Zmin=str2num(get(handles.first_j,'String'))-1;
2521Zmax=str2num(get(handles.npz,'String'));
2522par.gridLimits_Xmin=0;
2523par.gridLimits_Ymin=0;
2524par.gridLimits_Zmin=0;
2525% A=imread(file_ima);%read the first image to get the size
2526%sizim=size(A);
2527par.gridLimits_Xmax=str2double(get(handles.npx,'String'));%num2str(sizim(2));
2528par.gridLimits_Ymax=str2double(get(handles.npy,'String'));%num2str(sizim(1));
2529par.gridLimits_Zmax=Zmax;
2530par.grid='grille';
2531par.grid_division=4;
2532par.hart=0;
2533par.ratioHoverZ=1;
2534
2535%     
2536% %----------------------------------------------------------------
2537% function par=read_param_civ2(handles,file_ima)
2538%     par.ibx=get(handles.ibx_civ2,'String');
2539%     par.iby=get(handles.iby_civ2,'String');
2540%     par.rho=get(handles.rho_civ2,'String');
2541%     par.decimal=int2str(get(handles.decimal,'Value'));
2542%     par.deformation=int2str(get(handles.deformation,'Value'));
2543%     par.dx=get(handles.dx_civ2,'String');
2544%     par.dy=get(handles.dy_civ2,'String');
2545%     if isequal(str2num(par.dx),[])
2546%          if isempty(get(handles.grid_civ2,'String'));
2547%              par.dx='0'; %just read by civ_3D program, not used
2548%          else
2549%             par.dx='20';%default
2550%             set(handles.dx_civ2,'String','20');
2551%          end
2552%      end
2553%      if isequal(str2num(par.dy),[])
2554%          if isempty(get(handles.grid_civ2,'String'));
2555%              par.dy='0';%just read by civ_3D program, not used
2556%          else
2557%             par.dy='20';%default
2558%             set(handles.dy_civ2,'String','20');
2559%          end
2560%      end
2561%     par.pxcmx=get(handles.pxcmx,'String');
2562%     par.pxcmy=get(handles.pxcmy,'String');
2563%     if isempty(str2num(par.pxcmx)) |isempty(str2num(par.pxcmy))
2564%         par.pxcmx='1';
2565%          par.pxcmy='1';
2566%     end
2567% %     par.npx=get(handles.pxcmx,'UserData');
2568% %     par.npy=get(handles.pxcmy,'UserData');
2569%     A=imread(file_ima);%read the first image to get the size
2570%     sizim=size(A);
2571%     par.npx=num2str(sizim(2));
2572%     par.npy=num2str(sizim(1));
2573%     time=get(handles.displ_filebase,'UserData'); %get the set of times
2574%     par.gridname=get(handles.grid_civ2,'String');
2575%     par.gridflag='y';
2576%     if isequal(par.gridname,'')| isempty(par.gridname)
2577%         par.gridname='nogrid';
2578%         par.gridflag='n';
2579%     end
2580
2581
2582%---------------------------------------------------------
2583%CIV1  CIV1  CIV1 CIV1
2584%----------------------------------------------------------
2585function cmd_CIV1=BATCH_CIV1(filename,namelog,par,handles)
2586%pixels per cm and matrix of the image times, read from the .civ_3D file by uvmat
2587global civ1_exe Civ_exe sge%name of the executable for civ1 calculation
2588
2589%changes : filename_cmx -> filename ( no extension )
2590
2591            if isequal(par.Dt,'0')
2592                par.Dt='1' ;%case of 'displacement' mode
2593            end         
2594 
2595    textcmx={'##############   CMX file';...
2596    ['FirstImage ' par.filename_ima_a];...
2597    ['LastImage  ' par.filename_ima_b];...
2598    'XX' ;...
2599    ['Mask ' par.maskflag] ;...
2600    ['MaskName ' par.maskname];...
2601    ['ImageSize ' par.npx ' ' par.npy];...   %VERIFIER CAS GENERAL ?
2602    ['CorrelationBoxesSize ' par.ibx ' ' par.iby];...
2603    ['SearchBoxeSize ' par.isx ' ' par.isy];...
2604    ['RO ' par.rho];...
2605    ['GridSpacing ' par.dx ' ' par.dy];...
2606    'XX 1.0';...
2607    ['Dt_TO ' par.Dt ' ' par.T0];...
2608    ['PixCmXY ' par.pxcmx ' ' par.pxcmy];...
2609    'XX 1';...
2610    ['ShiftXY ' par.shiftx ' '  par.shifty];...
2611    ['Grid ' par.gridflag];...
2612    ['GridName ' par.gridname] ;...
2613    'XX 85';...
2614    'XX 1.0';...
2615    'XX 1.0';...
2616    'Hart 1';...
2617    'DecimalShift 0';...
2618    'Deformation 0';...
2619    'CorrelationMin 0';...
2620    'IntensityMin 0';...
2621    'SeuilImage n';...
2622    'SeuilImageValues 0 4096';...
2623    ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ?
2624    'ImageUsedBefore null null'};
2625
2626            textout=char(textcmx);
2627    %         timeL1=clock;
2628            dlmwrite([filename '.cmx'],textout,'');
2629    %             timeL2=clock;
2630    %     timciv1=etime(timeL2,timeL1)
2631          if sge 
2632          cmd_CIV1=[civ1_exe ' -f ' filename '.cmx' ]; % redirect standard output to the log file
2633          else
2634              cmd_CIV1=[civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file
2635          end
2636    if(isunix)
2637        [Rootbat,Filebat,extbat]=fileparts(namelog);
2638        ncName=fullfile(Rootbat,[ Filebat '.nc']);
2639            cmd_CIV1=char({cmd_CIV1 ; ['mv ' namelog  ' ' namelog '.civ1.log'];['chmod g+w ' ncName]});
2640    else
2641        cmd_CIV1=char({cmd_CIV1 ; ['copy /Y ' namelog ' ' namelog '.civ1.log']});
2642    end
2643
2644%---------------------------------------------------------
2645%CIV1  Unified
2646%----------------------------------------------------------
2647function xml_civ1_parameters=BATCH_CIV1_Unified(filename,namelog,par,handles)
2648%pixels per cm and matrix of the image times, read from the .civ_3D file by uvmat
2649global civ1_exe Civ_exe%name of the executable for civ1 calculation
2650
2651    civ1.image1=par.filename_ima_a;
2652    civ1.image2=par.filename_ima_b;
2653    civ1.imageSize_X=par.npx;
2654    civ1.imageSize_Y=par.npy;
2655    civ1.outputFileName=[filename '.nc'];
2656    civ1.correlationBoxesSize_X=par.ibx;
2657    civ1.correlationBoxesSize_Y=par.iby;
2658    civ1.searchBoxesSize_X=par.isx;
2659    civ1.searchBoxesSize_Y=par.isy;
2660    civ1.globalShift_X=par.shiftx;
2661    civ1.globalShift_Y=par.shifty;
2662    civ1.ro=par.rho;
2663    civ1.hart='y';
2664    if isequal(par.gridflag,'y')
2665        civ1.grid=par.gridname;
2666    end
2667    civ1.gridSpacing_X=par.dx;
2668    civ1.gridSpacing_Y=par.dy;
2669    if isequal(par.maskflag,'y')
2670        civ1.mask=par.maskname;
2671    end
2672    civ1.dt=par.Dt;
2673    civ1.unit='pixel';
2674    civ1.absolut_time_T0=par.T0;
2675    civ1.pixcmx=par.pxcmx;
2676    civ1.pixcmy=par.pxcmy;
2677    civ1.convectFlow='n';
2678 
2679    xml_civ1_parameters=civ1;
2680   
2681%---------------------------------------------------------
2682%CIV2  CIV2  CIV2 CIV2
2683%----------------------------------------------------------
2684function cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par)
2685%pixels per cm and matrix of the image times, read from the .civ_3D file by uvmat
2686global civ2_exe sge%name of the executable for civ1 calculation
2687   if isequal(par.Dt,'0')
2688                par.Dt='1' ;%case of 'displacement' mode
2689  end
2690textcmx={'##############   CMX file';...
2691['FirstImage ' par.filename_ima_a];...
2692['LastImage  ' par.filename_ima_b];...
2693'XX' ;...
2694['Mask ' par.maskflag];...
2695['MaskName ' par.maskname];...
2696['ImageSize ' par.npx ' ' par.npy];...   
2697['CorrelationBoxesSize ' par.ibx ' ' par.iby];...
2698['SearchBoxeSize ' par.ibx ' ' par.iby];...
2699['RO ' par.rho];...
2700['GridSpacing ' par.dx ' ' par.dy];...
2701'XX 1.0';...
2702['Dt_TO ' par.Dt ' ' par.T0];...
2703['PixCmXY ' par.pxcmx ' ' par.pxcmy];...
2704'XX 1';...
2705['ShiftXY 0 0'];...
2706['Grid ' par.gridflag];...
2707['GridName ' par.gridname];...
2708'XX 85';...
2709'XX 1.0';...
2710'XX 1.0';...
2711'Hart 1';...
2712['DecimalShift ' par.decimal];...
2713['Deformation ' par.deformation];...
2714'CorrelationMin 0';...
2715'IntensityMin 0';...
2716'SeuilImage n';...
2717'SeuilImageValues 0 4096';...
2718['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ?
2719['ImageUsedBefore ' par.filename_nc1]};
2720        textout=char(textcmx);
2721        dlmwrite([filename_cmx '2'] ,textout,'');
2722        if sge
2723        cmd_CIV2=[civ2_exe ' -f ' filename_cmx ]; % redirect standard output to the log file
2724        else
2725          cmd_CIV2=[civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file
2726      end
2727
2728
2729% --- Executes on button press in HELP.
2730function HELP_Callback(hObject, eventdata, handles)
2731path_to_uvmat=which ('uvmat');% check the path of uvmat
2732pathelp=fileparts(path_to_uvmat);
2733helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
2734if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
2735else
2736web([helpfile '#civ_3D'])   
2737end
2738
2739
2740%----------------------------------------------------------
2741%--read images and convert them to the uint16 format used for PIV
2742function A=read_image(filename,nom_type,npx,npy,num);
2743%npx, npy are the dimensions needed for the raw SMD images
2744%num is the view number needed for an avi movie
2745if isequal(nom_type,'avi')
2746    mov=aviread(filename,num);
2747    A=frame2im(mov(1));
2748    A=sum(double(A),3);
2749    A=uint16(A);
2750elseif isequal(nom_type,'raw_SMD')
2751    [fid,message]=fopen(filename,'r');   
2752    B=fread(fid,Inf,'int16',0,'ieee-le');%read 16 bit binary file
2753    A=(reshape(B,npx,npy))'; %remplissage ligne par ligne avec une matrice colonne ? transposer(uB) pour avoir une matrice ligne
2754    A=uint16(A);
2755    fclose(fid);
2756else
2757    A=imread(filename);
2758    siz=size(A);
2759    if length(siz)==3;%color images
2760        A=sum(double(A),3);
2761    end
2762    A=uint16(A);
2763end
2764       
2765%----------------------------------------------------------------
2766%Executes on carriage return on the time interval dt
2767%----------------------------------------------------------------
2768function dt_Callback(hObject, eventdata, handles)
2769%determine the set of times and possible intervals for CIV_3D
2770%                 answer=inputdlg('time interval between images?');
2771                dt=(1/1000)*str2num(get(handles.dt,'String'));
2772                nbfield=str2num(get(handles.nb_field,'String')); %last image number selected in the processing series
2773                time=(dt*[0:nbfield-1])';
2774%                 set(handles.incr_i,'UserData',dt);%store the time interval between successive images
2775                set(handles.displ_filebase,'UserData',time); %store the set of times
2776                for index=1:min(nbfield-1,200)
2777                    displ_num(1,index)=1;
2778                    displ_num(2,index)=1;
2779                    displ_num(3,index)=-floor(index/2);
2780                    displ_num(4,index)=ceil(index/2);
2781                end
2782set(handles.list_pair_civ1,'Value',1);
2783set(handles.list_pair_civ1,'UserData',displ_num);
2784set(handles.list_pair_civ2,'Value',1);
2785%update the list of time intervals
2786find_netcpair_civ1(hObject, eventdata, handles)
2787find_netcpair_civ2(hObject, eventdata, handles)
2788
2789%-------------------------------------------------------
2790function ref_i_Callback(hObject, eventdata, handles)
2791mode_list=get(handles.mode,'String');
2792mode_value=get(handles.mode,'Value');
2793mode=mode_list{mode_value};
2794if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Di)')
2795    find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files
2796end
2797if isequal(mode,'series(Di)') | ...% we do patch2 only
2798   (get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0)
2799    find_netcpair_civ2(hObject, eventdata, handles);
2800end
2801
2802%----------------------------------------------------
2803function ref_j_Callback(hObject, eventdata, handles)
2804mode_list=get(handles.mode,'String');
2805mode_value=get(handles.mode,'Value');
2806mode=mode_list{mode_value};
2807if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Dj)')
2808    find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files
2809end
2810if isequal(mode,'series(Dj)') | ...
2811   (get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0)
2812    find_netcpair_civ2(hObject, eventdata, handles);
2813end
2814%----------------------------------------------------
2815% --- Executes on button press in compare.
2816function compare_Callback(hObject, eventdata, handles)
2817test=get(handles.compare,'Value');
2818if test
2819    filebase=get(handles.displ_filebase,'String');
2820    browse=get(handles.browse_root,'Userdata');
2821    browse.nom_type_ima1=browse.nom_type_ima;
2822    set(handles.browse_root,'UserData',browse);
2823    set(handles.displ_filebase2,'Visible','On');%mkes the second file input window visible
2824    set(handles.displ_filebase2,'String',filebase);
2825    mode_store=get(handles.mode,'String');%get the present 'mode'
2826    set(handles.compare,'UserData',mode_store);%store the mode display
2827    set(handles.mode,'Value',1)
2828    set(handles.mode,'String',{'displacement';'st_pair j1-j2'})
2829else
2830    set(handles.displ_filebase2,'Visible','Off');
2831    set(handles.displ_filebase2,'String',[]);
2832    mode_store=get(handles.compare,'UserData');
2833    set(handles.mode,'String',mode_store)
2834    set(handles.test_stereo1,'Value',0)
2835    set(handles.test_stereo2,'Value',0)
2836end
2837mode_Callback(hObject, eventdata, handles)
2838
2839%-----------------------------------------------------------
2840% --- Executes on button press in get_ref_fix1.
2841function get_ref_fix1_Callback(hObject, eventdata, handles)
2842filebase=get(handles.displ_filebase,'String');
2843[FileName, PathName, filterindex] = uigetfile( ...
2844       {'*.nc', ' (*.nc)';
2845        '*.nc',  'netcdf files '; ...
2846        '*.*', 'All Files (*.*)'}, ...
2847        'Pick a file',filebase);
2848   
2849fileinput=[PathName FileName];
2850sizf=size(fileinput);
2851if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
2852%[filebasesub,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
2853[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
2854%filebase=fullfile(RootPath,RootFile);
2855% [Pth,FileN]=fileparts(filebasesub);
2856% Pth=fileparts(Pth);
2857ref.filebase=fullfile(Path,File);
2858ref.num_a=stra2num(str_a);
2859ref.num_b=stra2num(str_b);
2860ref.num1=str2num(field_count);
2861ref.num2=str2num(str2);
2862browse=[];%initialisation
2863if ~isequal(ref.ext,'.nc')
2864    errordlg('the reference file must be in netcdf format (*.nc)')
2865    return
2866end
2867% [path,name]=fileparts(ref.filebase);
2868set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']);
2869set(handles.ref_fix1,'UserData',ref)
2870menu_field{1}='civ1';
2871Data=nc2struct(fileinput,[]);
2872if isfield(Data,'patch') & isequal(Data.patch,1)
2873    menu_field{2}='filter1';
2874end
2875if isfield(Data,'civ2') & isequal(Data.civ2,1)
2876    menu_field{3}='civ2';
2877end
2878if isfield(Data,'patch2') & isequal(Data.patch2,1)
2879    menu_field{4}='filter2';
2880end
2881% [cte_detect,vdt,cte_read]=read_netcdf(fileinput,{'patch','civ2','patch2'});
2882% if isequal(cte_detect(1),1) & isequal(cte_read(1),1)
2883%          menu_field{2}='filter1';
2884% end
2885% if isequal(cte_detect(2),1) & isequal(cte_read(2),1)
2886%          menu_field{3}='civ2';
2887% end
2888% if isequal(cte_detect(3),1) & isequal(cte_read(3),1)
2889%          menu_field{4}='filter2';
2890% end
2891set(handles.field_ref1,'String',menu_field);
2892set(handles.field_ref1,'Value',length(menu_field));
2893set(handles.inf_sup1,'Value',2);
2894set(handles.thresh_vel,'String','1');%default threshold
2895set(handles.ref_fix1,'Enable','on')
2896 
2897%---------------------------------------------------------------
2898% --- Executes on button press in get_ref_fix2.
2899function get_ref_fix2_Callback(hObject, eventdata, handles)
2900if isequal(get(handles.get_ref_fix2,'Value'),1)
2901    filebase=get(handles.displ_filebase,'String');
2902    [FileName, PathName, filterindex] = uigetfile( ...
2903           {'*.nc', ' (*.nc)';
2904            '*.nc',  'netcdf files '; ...
2905            '*.*', 'All Files (*.*)'}, ...
2906            'Pick a file',filebase);
2907    fileinput=[PathName FileName];
2908    sizf=size(fileinput);
2909    if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
2910    %[filebasesub,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
2911    [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
2912%     [Pth,FileN]=fileparts(filebasesub);
2913%     Pth=fileparts(Pth);
2914    ref.filebase=fullfile(Path,File)
2915    ref.num_a=stra2num(str_a);
2916    ref.num_b=stra2num(str_b);
2917    ref.num1=str2num(field_count);
2918    ref.num2=str2num(str2);
2919    browse=[];%initialisation
2920    if ~isequal(ref.ext,'.nc')
2921        errordlg('the reference file must be in netcdf format (*.nc)')
2922        return
2923    end
2924%     [path,name]=fileparts(ref.filebase);
2925    set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']);
2926    set(handles.ref_fix2,'UserData',ref)   
2927    menu_field{1}='civ1';
2928%     [cte_detect,vdt,cte_read]=read_netcdf(fileinput,{'patch','civ2','patch2'});
2929    Data=nc2struct(fileinput,[]);
2930    if isfield(Data,'patch') & isequal(Data.patch,1)
2931        menu_field{2}='filter1';
2932    end
2933    if isfield(Data,'civ2') & isequal(Data.civ2,1)
2934        menu_field{3}='civ2';
2935    end
2936    if isfield(Data,'patch2') & isequal(Data.patch2,1)
2937        menu_field{4}='filter2';
2938    end
2939
2940%     if isequal(cte_detect(1),1) & isequal(cte_read(1),1)
2941%              menu_field{2}='filter1';
2942%     end
2943%     if isequal(cte_detect(2),1) & isequal(cte_read(2),1)
2944%              menu_field{3}='civ2';
2945%     end
2946%     if isequal(cte_detect(3),1) & isequal(cte_read(3),1)
2947%              menu_field{4}='filter2';
2948%     end
2949    set(handles.field_ref2,'String',menu_field);
2950    set(handles.field_ref2,'Value',length(menu_field));
2951    set(handles.inf_sup2,'Value',2);
2952    set(handles.thresh_vel2,'String','1');%default threshold
2953    set(handles.ref_fix2,'Enable','on')
2954    set(handles.ref_fix2,'Visible','on')
2955    set(handles.field_ref2,'Visible','on')
2956else
2957    set(handles.ref_fix2,'Visible','off')
2958    set(handles.field_ref2,'Visible','off')
2959end
2960%-------------------------------------------------------
2961
2962function ref_fix1_Callback(hObject, eventdata, handles)
2963    set(handles.inf_sup1,'Value',1);
2964    set(handles.field_ref1,'Value',1)
2965    set(handles.field_ref1,'String',{' '})
2966    set(handles.ref_fix1,'UserData',[]);
2967    set(handles.ref_fix1,'String','');
2968    set(handles.thresh_vel1,'String','0');
2969 
2970
2971%------------------------------------------------------
2972
2973function ref_fix2_Callback(hObject, eventdata, handles)
2974    set(handles.inf_sup2,'Value',1);
2975    set(handles.field_ref2,'Value',1)
2976    set(handles.field_ref2,'String',{' '})
2977    set(handles.ref_fix2,'UserData',[]);
2978    set(handles.ref_fix2,'String','');
2979    set(handles.thresh_vel2,'String','0');
2980
2981%--------------------------------------------------------
2982% --- Executes on selection change in inf_sup1.
2983function inf_sup1_Callback(hObject, eventdata, handles)
2984
2985%--------------------------------------------------------------------------
2986
2987
2988% --- Executes on selection change in field_ref.
2989function field_ref_Callback(hObject, eventdata, handles)
2990
2991%-------------------------------------------------------------------------
2992
2993% --- Executes on selection change in field_ref2.
2994function field_ref2_Callback(hObject, eventdata, handles)
2995
2996% -----------------------------------------------------------
2997% transform letters to numbers
2998%--------------------------------------------
2999function numres=stra2num(str)
3000numres=double(str)-96;
3001if double(str) >= 48 & double(str) <= 57 % = 1 for numbers
3002    numres=str2num(str);
3003end
3004
3005
3006% --- Executes on button press in test_stereo1.
3007function test_stereo1_Callback(hObject, eventdata, handles)
3008if isequal(get(handles.test_stereo1,'Value'),0)
3009    set(handles.subdomain_patch1,'Visible','on')
3010    set(handles.rho_patch1,'Visible','on')
3011else
3012    set(handles.subdomain_patch1,'Visible','off')
3013    set(handles.rho_patch1,'Visible','off')
3014end
3015
3016% --- Executes on button press in test_stereo2.
3017function test_stereo2_Callback(hObject, eventdata, handles)
3018if isequal(get(handles.test_stereo2,'Value'),0)
3019    set(handles.subdomain_patch2,'Visible','on')
3020    set(handles.rho_patch2,'Visible','on')
3021else
3022    set(handles.subdomain_patch2,'Visible','off')
3023    set(handles.rho_patch2,'Visible','off')
3024end
3025
3026% --- Executes on button press in ImaThreshold.
3027function ImaThreshold_Callback(hObject, eventdata, handles)
3028if isequal(get(handles.ImaThreshold,'Value'),1)
3029    set(handles.MinIma,'Visible','on')
3030    set(handles.MaxIma,'Visible','on')
3031else
3032    set(handles.MinIma,'Visible','off')
3033    set(handles.MaxIma,'Visible','off')
3034end
3035
3036
3037% --- Executes on button press in ImaThreshold2.
3038function ImaThreshold2_Callback(hObject, eventdata, handles)
3039if isequal(get(handles.ImaThreshold2,'Value'),1)
3040    set(handles.MinIma2,'Visible','on')
3041    set(handles.MaxIma2,'Visible','on')
3042else
3043    set(handles.MinIma2,'Visible','off')
3044    set(handles.MaxIma2,'Visible','off')
3045end
3046
3047
3048
3049% --- Executes on button press in Experimental.
3050function Experimental_Callback(hObject, eventdata, handles)
3051
3052
3053
3054function ibz_Callback(hObject, eventdata, handles)
3055% hObject    handle to ibz (see GCBO)
3056% eventdata  reserved - to be defined in a future version of MATLAB
3057% handles    structure with handles and user data (see GUIDATA)
3058
3059% Hints: get(hObject,'String') returns contents of ibz as text
3060%        str2double(get(hObject,'String')) returns contents of ibz as a double
3061
3062
3063% --- Executes during object creation, after setting all properties.
3064function ibz_CreateFcn(hObject, eventdata, handles)
3065% hObject    handle to ibz (see GCBO)
3066% eventdata  reserved - to be defined in a future version of MATLAB
3067% handles    empty - handles not created until after all CreateFcns called
3068
3069% Hint: edit controls usually have a white background on Windows.
3070%       See ISPC and COMPUTER.
3071if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3072    set(hObject,'BackgroundColor','white');
3073end
3074
3075
3076
3077function edit74_Callback(hObject, eventdata, handles)
3078% hObject    handle to edit74 (see GCBO)
3079% eventdata  reserved - to be defined in a future version of MATLAB
3080% handles    structure with handles and user data (see GUIDATA)
3081
3082% Hints: get(hObject,'String') returns contents of edit74 as text
3083%        str2double(get(hObject,'String')) returns contents of edit74 as a double
3084
3085
3086% --- Executes during object creation, after setting all properties.
3087function edit74_CreateFcn(hObject, eventdata, handles)
3088% hObject    handle to edit74 (see GCBO)
3089% eventdata  reserved - to be defined in a future version of MATLAB
3090% handles    empty - handles not created until after all CreateFcns called
3091
3092% Hint: edit controls usually have a white background on Windows.
3093%       See ISPC and COMPUTER.
3094if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3095    set(hObject,'BackgroundColor','white');
3096end
3097
3098
3099function dz_civ1_Callback(hObject, eventdata, handles)
3100% hObject    handle to dz_civ1 (see GCBO)
3101% eventdata  reserved - to be defined in a future version of MATLAB
3102% handles    structure with handles and user data (see GUIDATA)
3103
3104% Hints: get(hObject,'String') returns contents of dz_civ1 as text
3105%        str2double(get(hObject,'String')) returns contents of dz_civ1 as a double
3106
3107
3108function edit77_Callback(hObject, eventdata, handles)
3109% hObject    handle to edit77 (see GCBO)
3110% eventdata  reserved - to be defined in a future version of MATLAB
3111% handles    structure with handles and user data (see GUIDATA)
3112
3113% Hints: get(hObject,'String') returns contents of edit77 as text
3114%        str2double(get(hObject,'String')) returns contents of edit77 as a double
3115
3116
3117
3118function edit78_Callback(hObject, eventdata, handles)
3119% hObject    handle to ref_i (see GCBO)
3120% eventdata  reserved - to be defined in a future version of MATLAB
3121% handles    structure with handles and user data (see GUIDATA)
3122
3123% Hints: get(hObject,'String') returns contents of ref_i as text
3124%        str2double(get(hObject,'String')) returns contents of ref_i as a double
3125
3126
3127function edit79_Callback(hObject, eventdata, handles)
3128% hObject    handle to edit79 (see GCBO)
3129% eventdata  reserved - to be defined in a future version of MATLAB
3130% handles    structure with handles and user data (see GUIDATA)
3131
3132% Hints: get(hObject,'String') returns contents of edit79 as text
3133%        str2double(get(hObject,'String')) returns contents of edit79 as a double
3134
3135
3136
3137function npz_Callback(hObject, eventdata, handles)
3138% hObject    handle to npz (see GCBO)
3139% eventdata  reserved - to be defined in a future version of MATLAB
3140% handles    structure with handles and user data (see GUIDATA)
3141
3142% Hints: get(hObject,'String') returns contents of npz as text
3143%        str2double(get(hObject,'String')) returns contents of npz as a double
3144
3145
3146function npy_Callback(hObject, eventdata, handles)
3147% hObject    handle to npy (see GCBO)
3148% eventdata  reserved - to be defined in a future version of MATLAB
3149% handles    structure with handles and user data (see GUIDATA)
3150
3151% Hints: get(hObject,'String') returns contents of npy as text
3152%        str2double(get(hObject,'String')) returns contents of npy as a double
3153
3154
3155
3156
3157function npx_Callback(hObject, eventdata, handles)
3158% hObject    handle to npx (see GCBO)
3159% eventdata  reserved - to be defined in a future version of MATLAB
3160% handles    structure with handles and user data (see GUIDATA)
3161
3162% Hints: get(hObject,'String') returns contents of npx as text
3163%        str2double(get(hObject,'String')) returns contents of npx as a double
3164
3165
3166
3167
Note: See TracBrowser for help on using the repository browser.