source: trunk/src/series.m @ 36

Last change on this file since 36 was 36, checked in by sommeria, 14 years ago

-get_field: functions called by ACTION in the GUI get_field put in the subdirectory get_field (like for series)
-help put in the subdir uvmat_doc, help call in uvmat, civ, geometry calib modified accordingly

File size: 83.4 KB
Line 
1%'series': master function associated to the GUI series.m for analysis field series 
2%------------------------------------------------------------------------
3% function varargout = series(varargin)
4% associated with the GUI series.fig
5%
6%INPUT
7% param: structure with input parameters (link with the GUI uvmat)
8%      .menu_coord_str: string for the CoordType (menu for coordinate transforms)
9%      .menu_coord_val: value for CoordType (menu for coordinate transforms)
10%      .FileName: input file name
11%      .FileName_1: second input file name
12%      .list_field: menu of input fields
13%      .index_fields: chosen index
14%      .civ1=0 or 1, .interp1,  ... : input civ field type
15%
16%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
17%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
18%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
19%     This file is part of the toolbox UVMAT.
20%
21%     UVMAT is free software; you can redistribute it and/or modify
22%     it under the terms of the GNU General Public License as published by
23%     the Free Software Foundation; either version 2 of the License, or
24%     (at your option) any later version.
25%
26%     UVMAT is distributed in the hope that it will be useful,
27%     but WITHOUT ANY WARRANTY; without even the implied warranty of
28%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
30%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
31
32function varargout = series(varargin)
33
34% Begin initialization code - DO NOT EDIT
35gui_Singleton = 1;
36gui_State = struct('gui_Name',       mfilename, ...
37                   'gui_Singleton',  gui_Singleton, ...
38                   'gui_OpeningFcn', @series_OpeningFcn, ...
39                   'gui_OutputFcn',  @series_OutputFcn, ...
40                   'gui_LayoutFcn',  [] , ...
41                   'gui_Callback',   []);
42if nargin && ischar(varargin{1})
43    gui_State.gui_Callback = str2func(varargin{1});
44end
45
46if nargout
47    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
48else
49    gui_mainfcn(gui_State, varargin{:});
50end
51% End initialization code - DO NOT EDIT
52
53%--------------------------------------------------------------------------
54% --- Executes just before series is made visible.
55%--------------------------------------------------------------------------
56function series_OpeningFcn(hObject, eventdata, handles,param)
57global nb_builtin
58% Choose default command line output for series
59handles.output = hObject;
60% Update handles structure
61guidata(hObject, handles);
62%default initial parameters
63
64%load the list of previously browsed files in menus Open and Open_1
65dir_perso=prefdir;
66profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
67if exist(profil_perso,'file')
68     h=load (profil_perso);
69     if isfield(h,'MenuFile_1')
70          set(handles.MenuFile_1,'Label',h.MenuFile_1);
71          set(handles.MenuFile_insert_1,'Label',h.MenuFile_1);
72     end
73     if isfield(h,'MenuFile_1')
74          set(handles.MenuFile_2,'Label',h.MenuFile_2);
75          set(handles.MenuFile_insert_2,'Label',h.MenuFile_2);
76     end
77     if isfield(h,'MenuFile_1')
78          set(handles.MenuFile_3,'Label',h.MenuFile_3);
79          set(handles.MenuFile_insert_3,'Label',h.MenuFile_3);
80     end
81     if isfield(h,'MenuFile_1')
82          set(handles.MenuFile_4,'Label',h.MenuFile_4);
83          set(handles.MenuFile_insert_4,'Label',h.MenuFile_4);
84     end
85     if isfield(h,'MenuFile_1')
86          set(handles.MenuFile_5,'Label',h.MenuFile_5);
87          set(handles.MenuFile_insert_5,'Label',h.MenuFile_5);
88     end
89end
90
91%check default input data
92if ~exist('param','var')
93    param=[]; %default
94end
95
96%file name and browser initialisation
97if isfield(param,'menu_coord_str')
98    set(handles.CoordType,'String',param.menu_coord_str)
99end
100if isfield(param,'menu_coord_val')
101    set(handles.CoordType,'Value',param.menu_coord_val);
102else
103     set(handles.CoordType,'Value',1);%default
104end
105
106if isfield(param,'FileName')
107    if isfield(param,'FileName_1')
108        update_file(hObject, eventdata, handles,param.FileName_1,0)
109        update_file(hObject, eventdata, handles,param.FileName,1)
110    else
111        update_file(hObject, eventdata, handles,param.FileName,0)
112    end
113end 
114
115%fields input initialisation
116if isfield(param,'list_fields')&& isfield(param,'index_fields') &&~isempty(param.list_fields) &&~isempty(param.index_fields)
117    set(handles.FieldMenu,'String',param.list_fields);% list menu fields
118    set(handles.FieldMenu,'Value',param.index_fields);% selected string index
119    FieldCell{1}=param.list_fields{param.index_fields};
120end
121if isfield(param,'civ1')&& islogical(param.civ1) && isfield(param,'civ2')&& islogical(param.civ2)&...
122        isfield(param,'interp1')&& islogical(param.interp1)&&isfield(param,'interp2')&& islogical(param.interp2)&...
123        isfield(param,'filter1')&& islogical(param.filter1)&&isfield(param,'filter2')&& islogical(param.filter2)
124    set(handles.civ1,'Value',param.civ1);
125    set(handles.civ2,'Value',param.civ1);
126    set(handles.interp1,'Value',param.interp1);
127    set(handles.interp2,'Value',param.interp2);
128    set(handles.filter1,'Value',param.filter1);
129    set(handles.filter2,'Value',param.filter2);
130end
131set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles})
132NomType_Callback(hObject, eventdata, handles)
133
134%loads the information stored in prefdir to initiate the browser and the list of functions
135menu_str={'check_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'};
136nb_builtin=numel(menu_str); %number of functions
137[path_series,name,ext]=fileparts(which('series'));
138path_series=fullfile(path_series,'series');%path of the function 'series'
139
140for ilist=1:length(menu_str)
141    fct_path{ilist,1}=path_series;%paths of the fuctions buil-in in 'series.m'
142end
143% read the list of functions stored in the personal file 'uvmat_perso.mat' in prefdir
144dir_perso=prefdir;
145profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
146if exist(profil_perso,'file')
147    h=load (profil_perso);
148    if isfield(h,'series_fct') && iscell(h.series_fct)
149         for ilist=1:length(h.series_fct)
150             [path,file]=fileparts(h.series_fct{ilist});
151             fct_path=[fct_path; {path}];%concatene the list of paths
152             menu_str=[menu_str; {file}];
153         end
154    end
155end
156
157menu_str=[menu_str;{'more...'}];
158set(handles.ACTION,'String',menu_str)
159set(handles.ACTION,'UserData',fct_path)% store the list of path in UserData of ACTION
160
161% display the GUI for the default action 'check_files'
162ACTION_Callback(hObject, eventdata, handles)
163
164%--------------------------------------------------------------
165% --- Outputs from this function are returned to the command line.
166%-----------------------------------------------------------------
167function varargout = series_OutputFcn(hObject, eventdata, handles)
168% varargout  cell array for returning output args (see VARARGOUT);
169% hObject    handle to figure
170% eventdata  reserved - to be defined in a future version of MATLAB
171% handles    structure with handles and user data (see GUIDATA)
172% Get default command line output from handles structure
173varargout{1} = handles.output;
174
175
176% --------------------------------------------------------------------
177function MenuBrowse_Callback(hObject, eventdata, handles)
178
179RootPathCell=get(handles.RootPath,'String');
180SubDirCell=get(handles.SubDir,'String'); 
181RootFileCell=get(handles.RootFile,'String');
182oldfile=''; %default
183if isempty(RootPathCell)|isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box
184     dir_perso=prefdir;
185     profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
186     if exist(profil_perso,'file')
187          h=load (profil_perso);
188         if isfield(h,'filebase')&ischar(h.filebase)
189                 oldfile=h.filebase;
190         end
191         if isfield(h,'RootPath')&ischar(h.RootPath)
192                 oldfile=h.RootPath;
193         end
194     end
195 else
196     oldfile=fullfile(RootPathCell{1},SubDirCell{1},RootFileCell{1});
197 end
198[FileName, PathName, filterindex] = uigetfile( ...
199       {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)';
200       '*.xml',  '.xml files '; ...
201        '*.xls',  '.xls files '; ...
202        '*.png','.png image files'; ...
203        '*.tif','.tif image files'; ...
204        '*.avi;*.AVI','.avi movie files'; ...
205        '*.nc','.netcdf files'; ...
206        '*.*',  'All Files (*.*)'}, ...
207        'Pick a file',oldfile);
208fileinput=[PathName FileName];%complete file name
209testblank=findstr(fileinput,' ');%look for blanks
210if ~isempty(testblank)
211    errordlg('forbidden input file name: contain blanks')
212    return
213end
214sizf=size(fileinput);
215if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
216[path,name,ext]=fileparts(fileinput);
217SeriesData=[];%dfault
218if isequal(ext,'.xml')
219    errordlg('input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
220elseif isequal(ext,'.xls')
221    errordlg('input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
222else
223    update_file(hObject, eventdata, handles,fileinput,0)
224     %update list of recent files in the menubar
225    MenuFile_1=fileinput;
226    MenuFile_2=get(handles.MenuFile_1,'Label');
227    MenuFile_3=get(handles.MenuFile_2,'Label');
228    MenuFile_4=get(handles.MenuFile_3,'Label');
229    MenuFile_5=get(handles.MenuFile_4,'Label');
230    set(handles.MenuFile_1,'Label',MenuFile_1)
231    set(handles.MenuFile_2,'Label',MenuFile_2)
232    set(handles.MenuFile_3,'Label',MenuFile_3)
233    set(handles.MenuFile_4,'Label',MenuFile_4)
234    set(handles.MenuFile_5,'Label',MenuFile_5)
235    set(handles.MenuFile_insert_1,'Label',MenuFile_1)
236    set(handles.MenuFile_insert_2,'Label',MenuFile_2)
237    set(handles.MenuFile_insert_3,'Label',MenuFile_3)
238    set(handles.MenuFile_insert_4,'Label',MenuFile_4)
239    set(handles.MenuFile_insert_5,'Label',MenuFile_5)
240    dir_perso=prefdir;
241    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
242    if exist(profil_perso,'file')
243        save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
244    else
245        txt=ver;
246        Release=txt(1).Release;
247        relnumb=str2num(Release(3:4));
248        if relnumb >= 14
249            save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
250        else
251            save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
252        end
253    end
254end
255% set(hseries,'UserData',SeriesData);
256% RootFile_Callback(hObject, eventdata, handles);
257% FileExt_Callback(hObject, eventdata, handles);
258% NomType_Callback(hObject, eventdata, handles)
259% mode_Callback(hObject, eventdata, handles)
260
261
262% --------------------------------------------------------------------
263function MenuFile_1_Callback(hObject, eventdata, handles)
264fileinput=get(handles.MenuFile_1,'Label');
265update_file(hObject, eventdata, handles,fileinput,0)
266
267% --------------------------------------------------------------------
268function MenuFile_2_Callback(hObject, eventdata, handles)
269fileinput=get(handles.MenuFile_2,'Label');
270update_file(hObject, eventdata, handles,fileinput,0)
271
272% --------------------------------------------------------------------
273function MenuFile_3_Callback(hObject, eventdata, handles)
274fileinput=get(handles.MenuFile_3,'Label');
275update_file(hObject, eventdata, handles,fileinput,0)
276
277% --------------------------------------------------------------------
278function MenuFile_4_Callback(hObject, eventdata, handles)
279fileinput=get(handles.MenuFile_4,'Label');
280update_file(hObject, eventdata, handles,fileinput,0)
281
282% --------------------------------------------------------------------
283function MenuFile_5_Callback(hObject, eventdata, handles)
284fileinput=get(handles.MenuFile_5,'Label');
285update_file(hObject, eventdata, handles,fileinput,0)
286
287% --------------------------------------------------------------------
288function MenuBrowse_insert_Callback(hObject, eventdata, handles)
289
290RootPathCell=get(handles.RootPath,'String');
291RootFileCell=get(handles.RootFile,'String');
292oldfile=''; %default
293if isempty(RootPathCell)|isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box
294     dir_perso=prefdir;
295     profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
296     if exist(profil_perso,'file')
297          h=load (profil_perso);
298         if isfield(h,'filebase')&ischar(h.filebase)
299                 oldfile=h.filebase;
300         end
301         if isfield(h,'RootPath')&ischar(h.RootPath)
302                 oldfile=h.RootPath;
303         end
304     end
305 else
306     oldfile=fullfile(RootPathCell{1},RootFileCell{1});
307 end
308[FileName, PathName, filterindex] = uigetfile( ...
309       {'*.xml;*.xls;*.png;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png, *.avi,*.nc)';
310       '*.xml',  '.xml files '; ...
311        '*.xls',  '.xls files '; ...
312        '*.png','.png image files'; ...
313        '*.avi;*.AVI','.avi movie files'; ...
314        '*.nc','.netcdf files'; ...
315        '*.*',  'All Files (*.*)'}, ...
316        'Pick a file',oldfile);
317fileinput=[PathName FileName];%complete file name
318testblank=findstr(fileinput,' ');%look for blanks
319if ~isempty(testblank)
320    errordlg('forbidden input file name: contain blanks')
321    return
322end
323sizf=size(fileinput);
324if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
325[path,name,ext]=fileparts(fileinput);
326SeriesData=[];%dfault
327if isequal(ext,'.xml')
328    errordlg('input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
329elseif isequal(ext,'.xls')
330    errordlg('input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
331else
332    update_file(hObject, eventdata, handles,fileinput,1)
333    %update list of recent files in the menubar
334    MenuFile_1=fileinput;
335    MenuFile_2=get(handles.MenuFile_1,'Label');
336    MenuFile_3=get(handles.MenuFile_2,'Label');
337    MenuFile_4=get(handles.MenuFile_3,'Label');
338    MenuFile_5=get(handles.MenuFile_4,'Label');
339    set(handles.MenuFile_1,'Label',MenuFile_1)
340    set(handles.MenuFile_2,'Label',MenuFile_2)
341    set(handles.MenuFile_3,'Label',MenuFile_3)
342    set(handles.MenuFile_4,'Label',MenuFile_4)
343    set(handles.MenuFile_5,'Label',MenuFile_5)
344    set(handles.MenuFile_insert_1,'Label',MenuFile_1)
345    set(handles.MenuFile_insert_2,'Label',MenuFile_2)
346    set(handles.MenuFile_insert_3,'Label',MenuFile_3)
347    set(handles.MenuFile_insert_4,'Label',MenuFile_4)
348    set(handles.MenuFile_insert_5,'Label',MenuFile_5)
349    dir_perso=prefdir;
350    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
351    if exist(profil_perso,'file')
352        save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
353    else
354        txt=ver;
355        Release=txt(1).Release;
356        relnumb=str2num(Release(3:4));
357        if relnumb >= 14
358            save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
359        else
360            save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
361        end
362    end
363end
364%------------------------------------------------
365
366% --------------------------------------------------------------------
367function MenuFile_insert_1_Callback(hObject, eventdata, handles)
368fileinput=get(handles.MenuFile_insert_1,'Label');
369update_file(hObject, eventdata, handles,fileinput,1)
370
371% --------------------------------------------------------------------
372function MenuFile_insert_2_Callback(hObject, eventdata, handles)
373fileinput=get(handles.MenuFile_insert_2,'Label');
374update_file(hObject, eventdata, handles,fileinput,1)
375
376% --------------------------------------------------------------------
377function MenuFile_insert_3_Callback(hObject, eventdata, handles)
378fileinput=get(handles.MenuFile_insert_3,'Label');
379update_file(hObject, eventdata, handles,fileinput,1)
380
381% --------------------------------------------------------------------
382function MenuFile_insert_4_Callback(hObject, eventdata, handles)
383fileinput=get(handles.MenuFile_insert_4,'Label');
384update_file(hObject, eventdata, handles,fileinput,1)
385
386% --------------------------------------------------------------------
387function MenuFile_insert_5_Callback(hObject, eventdata, handles)
388fileinput=get(handles.MenuFile_insert_5,'Label');
389update_file(hObject, eventdata, handles,fileinput,1)
390
391% --------------------------------------------------------------------
392% refresh the GUI data after introduction of a new file series
393function update_file(hObject, eventdata, handles,fileinput,addtest)
394%hseries=get(handles.RootPath,'parent'); 
395if ~exist(fileinput,'file')
396    msgbox_uvmat('ERROR',['input file ' fileinput  ' does not exist'])
397    return
398end
399hseries=handles.figure1;
400% refresh input root name, indices, file extension and nomenclature
401[RootPath,RootFile,field_count,str2,str_a,str_b,FileExt,NomType,SubDir]=name2display(fileinput);
402%check for movie image files
403if ~isempty(FileExt)
404if ~isempty(imformats(FileExt(2:end)))
405    imainfo=imfinfo(fileinput);     
406    if length(imainfo) >1 %case of image with multiple frames
407        NomType='*';
408        [RootPath,RootFile]=fileparts(fileinput);
409    end
410end
411end
412NcType='none';%default
413if isequal(FileExt,'.nc')
414   Data=nc2struct(fileinput,[]);
415   if isfield(Data,'absolut_time_T0')
416       NcType='civx'; % test for civx velocity fields
417   end
418end
419
420set(handles.RootPath,'Value',1)
421set(handles.SubDir,'Value',1)
422set(handles.RootFile,'Value',1)
423set(handles.NomType,'Value',1)
424set(handles.FileExt,'Value',1)
425set(handles.nb_field,'Value',1)
426set(handles.nb_field2,'Value',1)
427if addtest
428    SeriesData=get(hseries,'UserData');
429    SeriesData.displ_num=[0 0 0 0;SeriesData.displ_num];
430    SeriesData.CurrentInputFile_1=SeriesData.CurrentInputFile;
431    RootPathCell=[{RootPath}; get(handles.RootPath,'String')] ;
432    SubDirCell=[{SubDir}; get(handles.SubDir,'String')];
433    RootFileCell=[{RootFile}; get(handles.RootFile,'String')];
434    NomTypeCell=[{NomType}; SeriesData.NomType];
435    FileExtCell=[{FileExt}; get(handles.FileExt,'String')];
436    NcTypeCell=[{NcType};SeriesData.NcType];
437    set(handles.NomType,'String',[{};get(handles.NomType,'String')])
438else
439    SeriesData=[];%re-initialisation
440    SeriesData.displ_num=[0 0 0 0];
441    RootPathCell={RootPath};
442    SubDirCell={SubDir};
443    RootFileCell={RootFile};   
444    NomTypeCell={NomType};
445    FileExtCell={FileExt};   
446    NcTypeCell={NcType};
447end
448
449SeriesData.NomType=NomTypeCell;
450SeriesData.NcType=NcTypeCell;
451SeriesData.CurrentInputFile=fileinput;
452set(handles.RootPath,'String',RootPathCell);
453set(handles.SubDir,'String',SubDirCell);
454set(handles.RootFile,'String',RootFileCell);
455set(handles.NomType,'String',NomTypeCell);
456set(handles.FileExt,'String',FileExtCell); 
457
458%determine field indices
459ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV
460if ~isempty(str2num(field_count))
461    ref_i=str2num(field_count);
462    if ~isempty(str2num(str2))
463        ref_i=floor((ref_i+str2num(str2))/2);% reference image number corresponding to the file
464        SeriesData.browse_Di=str2num(str2)-str2num(field_count);
465    end
466end
467set(handles.ref_i,'String',num2str(ref_i));
468set(handles.first_i,'String',num2str(ref_i));
469set(handles.last_i,'String',num2str(ref_i));
470ref_j=1; %default  ref_j is a reference frame index used to find existing pairs from PIV
471if ~isempty(str2num(str_a))
472    ref_j=str2num(str_a);
473    if ~isempty(str2num(str_b))
474        ref_j=floor((str2num(str_a)+str2num(str_b))/2);
475        SeriesData.browse_Dj=str2num(str_b)-str2num(str_a);
476    end         
477end
478set(handles.ref_j,'String',num2str(ref_j));
479set(handles.first_j,'String',num2str(ref_j))
480set(handles.last_j,'String',num2str(ref_j));
481%set(hseries,'UserData',SeriesData);
482
483%enable other menus and uicontrols
484set(handles.MenuOpen_insert,'Enable','on')
485set(handles.MenuFile_insert_1,'Enable','on')
486set(handles.MenuFile_insert_2,'Enable','on')
487set(handles.MenuFile_insert_3,'Enable','on')
488set(handles.MenuFile_insert_4,'Enable','on')
489set(handles.MenuFile_insert_5,'Enable','on')
490set(handles.RUN, 'Enable','On')
491set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red
492set(handles.RootPath,'BackgroundColor',[1 1 0]) % set RootPath edit box  to yellow
493drawnow
494
495TimeUnit=''; %default
496time=[];%default
497GeometryCalib=[];%default
498nb_field=[];%default
499nb_field2=[];%default
500SeriesData.PathCampaign=get(handles.PathCampaign,'String');
501
502% read timing and total frame number from the current file (movie files) !! may be overrid by xml file
503FileBase=fullfile(RootPath,RootFile);
504
505% nb_field{icell,1}='?';%default
506% nb_field2{icell,1}='?';%default
507testima=0; %test for image input
508if isequal(lower(FileExt),'.avi') %.avi file
509    testima=1;
510    info=aviinfo([FileBase FileExt]);
511    time=[0:1/info.FramesPerSecond:(info.NumFrames-1)/info.FramesPerSecond]';
512    nb_field=info.NumFrames;
513    nb_field2=1;
514elseif ~isempty(imformats(FileExt(2:end)))
515    testima=1;
516    if isequal(NomType,'*')% multi-frame image
517        imainfo=imfinfo([FileBase FileExt]);     
518        if length(imainfo) >1 %case of image with multiple frames
519            nb_field=length(imainfo);
520            nb_field2=1;
521        end
522    end
523elseif isequal(FileExt,'.vol')
524     testima=1;
525end
526
527% enable field and veltype menus
528testfield=isequal(get(handles.FieldMenu,'enable'),'on');
529testfield_1=isequal(get(handles.FieldMenu_1,'enable'),'on');
530testveltype=isequal(get(handles.VelTypeMenu,'enable'),'on');
531testveltype_1=isequal(get(handles.VelTypeMenu_1,'enable'),'on');
532testtransform=isequal(get(handles.CoordType,'Enable'),'on');
533testnc=0;
534testnc_1=0;
535testcivx=0;
536testcivx_1=0;
537if length(FileExtCell)==1 || length(FileExtCell)>2
538    for iview=1:length(FileExtCell)
539        if isequal(FileExtCell{iview},'.nc')
540            testnc=1;
541        end
542        if isequal(NcTypeCell{iview},'civx')
543            testcivx=1;
544        end
545    end
546elseif length(FileExtCell)==2
547    testnc=isequal(FileExtCell{1},'.nc');
548    testnc_1=isequal(FileExtCell{2},'.nc');
549    testcivx=isequal(NcTypeCell{1},'civx');
550    testcivx_1=isequal(NcTypeCell{2},'civx');
551end
552if testfield && testnc
553    view_FieldMenu(handles,'on')
554    if testcivx
555        menustr=get(handles.FieldMenu,'String');
556        if isequal(menustr,{'get_field...'})
557            set(handles.FieldMenu,'String',{'get_field...';'velocity';'vort';'div';'more...'})
558        end
559    else
560        set(handles.FieldMenu,'Value',1)
561        set(handles.FieldMenu,'String',{'get_field...'})
562    end
563else
564    view_FieldMenu(handles,'off')
565end
566if testfield_1 && testnc_1
567    view_FieldMenu_1(handles,'on')
568    if testcivx_1
569        menustr=get(handles.FieldMenu_1,'String');
570        if isequal(menustr,{'get_field...'})
571            set(handles.FieldMenu_1,'String',{'get_field...';'velocity';'vort';'div';'more...'})
572        end
573    else
574        set(handles.FieldMenu_1,'Value',1)
575        set(handles.FieldMenu_1,'String',{'get_field...'})
576    end
577else
578    view_FieldMenu_1(handles,'off')
579end
580if testveltype && testcivx
581    set(handles.VelTypeMenu,'Visible','on')
582    set(handles.VelType_text,'Visible','on');
583else
584    set(handles.VelTypeMenu,'Visible','off')
585    set(handles.VelType_text,'Visible','off');
586end
587if testveltype_1 && testcivx_1
588    set(handles.VelTypeMenu_1,'Visible','on')
589    set(handles.VelType_text_1,'Visible','on');
590else
591    set(handles.VelTypeMenu_1,'Visible','off')
592    set(handles.VelType_text_1,'Visible','off');
593end
594if testtransform && (testcivx || testima)
595     view_TRANSFORM(handles,'on')
596else
597    view_TRANSFORM(handles,'off')
598end
599if ~isequal(FileExt,'.nc') && ~isequal(FileExt,'.cdf') && ~testima
600    msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
601    return
602end 
603
604%%%%%%%%   read image documentation file  if found%%%%%%%%%%%%%%%%%%%%%%%%%%%
605      %look for the file existence
606ext_imadoc='';
607if isequal(FileExt,'.xml')||isequal(FileExt,'.civ')
608    ext_imadoc=FileExt;
609elseif exist([FileBase '.xml'],'file')
610    ext_imadoc='.xml';
611elseif exist([FileBase '.civ'],'file')
612    ext_imadoc='.civ';
613end
614      %read the ImaDoc file
615XmlData=[];
616NbSlice_calib={};
617if isequal(ext_imadoc,'.xml')
618        [XmlData,warntext]=imadoc2struct([FileBase '.xml']);
619        if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName')
620            [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName);
621        end
622        if isfield(XmlData,'Time')
623            time=XmlData.Time;
624        end
625        if isfield(XmlData,'Camera')
626            if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
627                NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform
628                if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})
629                    msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series');
630                end
631            end
632            if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
633                TimeUnit=XmlData.Camera.TimeUnit;
634            end
635        end
636        if ~isempty(warntext)
637            msgbox_uvmat('WARNING',warntext)
638        end 
639elseif isequal(ext_imadoc,'.civ')
640    [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
641    time=XmlData.Time;
642    size(time)
643    GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
644    GeometryCalib.Tx=0;
645    GeometryCalib.Ty=0;
646    GeometryCalib.Tz=1;
647    GeometryCalib.dpx=1;
648    GeometryCalib.dpy=1;
649    GeometryCalib.sx=1;
650    GeometryCalib.Cx=0;
651    GeometryCalib.Cy=0;
652    GeometryCalib.f=1;
653    GeometryCalib.kappa1=0;
654    GeometryCalib.CoordUnit='cm';
655    XmlData.GeometryCalib=GeometryCalib;
656    if error==2, warntext=['no file ' FileBase '.civ'];
657    elseif error==1, warntext='inconsistent number of fields in the .civ file';
658    end 
659end 
660if addtest
661    SeriesData.Time=[{time} SeriesData.Time];
662else
663   SeriesData.Time={time};
664end
665
666if ~isempty(time)
667    siztime=size(time);
668    nb_field=siztime(1);
669    nb_field2=siztime(2);
670end   
671set(handles.TimeUnit,'String',TimeUnit)
672if isempty(nb_field)
673    nb_field_str='?';
674    nb_field_str2='?';
675else
676    nb_field_str=num2str(nb_field);
677    nb_field_str2=num2str(nb_field2);
678end
679if addtest
680    nb_field_cell=[{nb_field_str} ;get(handles.nb_field,'String')];
681    nb_field2_cell=[{nb_field_str2} ;get(handles.nb_field2,'String')];
682else
683    nb_field_cell={nb_field_str};
684    nb_field2_cell={nb_field_str2};
685end
686set(handles.nb_field,'String',nb_field_cell);
687set(handles.nb_field2,'String',nb_field2_cell);
688set(hseries,'UserData',SeriesData);
689
690%number of slices
691if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord')
692       siz=size(XmlData.GeometryCalib.SliceCoord);
693       if siz(1)>1
694           NbSlice=siz(1);
695       else
696           NbSlice=1;
697       end
698       set(handles.NbSlice,'String',num2str(NbSlice))
699end
700
701% set menus of index pairs
702NomType_Callback(hObject, eventdata, handles)
703
704dir_perso=prefdir;
705profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
706% save(profil_perso, 'FileBase'); %store the root name for future opening of uvmat
707if exist(profil_perso,'file')
708    save (profil_perso,'RootPath','SubDir','RootFile','NomType', '-append'); %store the root name for future opening of uvmat
709else
710    txt=ver;
711    Release=txt(1).Release;
712    relnumb=str2num(Release(3:4));
713    if relnumb >= 14
714        save (profil_perso,'RootPath','SubDir','RootFile','NomType','-V6') %store the root name for future opening of uvmat
715    else
716        save(profil_perso,'RootPath','SubDir','RootFile','NomType')
717    end         
718end
719set(handles.RootPath,'BackgroundColor',[1 1 1])
720set(handles.PathCampaign,'String',SeriesData.PathCampaign)
721last_j_Callback(hObject, eventdata, handles)
722last_i_Callback(hObject, eventdata, handles)
723
724%------------------------------------------------------------
725function RootPath_Callback(hObject, eventdata, handles)
726Val=get(handles.RootPath,'Value');
727synchronise_view(handles,Val)
728NomType_Callback(hObject, eventdata, handles)
729%------------------------------------------------------------
730
731function synchronise_view(handles,Val)
732set(handles.RootPath,'Value',Val)
733set(handles.SubDir,'Value',Val)
734set(handles.RootFile,'Value',Val)
735set(handles.NomType,'Value',Val)
736set(handles.FileExt,'Value',Val)
737set(handles.nb_field,'Value',Val)
738set(handles.nb_field2,'Value',Val)
739set(handles.time_first,'Value',Val)
740set(handles.time_last,'Value',Val)
741
742
743%---------------------------------------------------------
744% Executes on carriage return on the subdir civ1 edit window
745%--------------------------------------------------------
746function SubDir_Callback(hObject, eventdata, handles)
747
748Val=get(handles.SubDir,'Value');
749synchronise_view(handles,Val)
750NomType_Callback(hObject, eventdata, handles)
751
752%--------------------------------------------------------------
753%function activated when a new filebase (image series) is introduced
754%------------------------------------------------------------
755function RootFile_Callback(hObject, eventdata, handles)
756Val=get(handles.RootFile,'Value');
757synchronise_view(handles,Val)
758NomType_Callback(hObject, eventdata, handles)
759
760%--------------------------------------------------------------
761%function activated when a new filebase (image series) is introduced
762%------------------------------------------------------------
763function FileExt_Callback(hObject, eventdata, handles)
764Val=get(handles.FileExt,'Value');
765synchronise_view(handles,Val)
766
767%--------------------------------------------------------------
768%function activated when a new filebase (image series) is introduced
769%------------------------------------------------------------
770function nb_field_Callback(hObject, eventdata, handles)
771Val=get(handles.nb_field,'Value');
772synchronise_view(handles,Val)
773
774%--------------------------------------------------------------
775%function activated when a new filebase (image series) is introduced
776%------------------------------------------------------------
777function nb_field2_Callback(hObject, eventdata, handles)
778Val=get(handles.nb_field2,'Value');
779synchronise_view(handles,Val)
780
781%--------------------------------------------------------------
782%function activated when a new filebase (image series) is introduced
783%------------------------------------------------------------
784function time_first_Callback(hObject, eventdata, handles)
785Val=get(handles.time_first,'Value');
786synchronise_view(handles,Val)
787
788%--------------------------------------------------------------
789%function activated when a new filebase (image series) is introduced
790%------------------------------------------------------------
791function time_last_Callback(hObject, eventdata, handles)
792Val=get(handles.time_last,'Value');
793synchronise_view(handles,Val)
794
795%--------------------------------------------------------------
796%function activated by NomType
797%------------------------------------------------------------
798NomType_Callback(hObject, eventdata, handles)
799
800function NomType_Callback(hObject, eventdata, handles)
801hseries=get(handles.ProjObject,'Parent');
802SeriesData=get(hseries,'UserData');
803if isfield(SeriesData,'NomType')
804    NomTypeCell=SeriesData.NomType;
805else
806    NomTypeCell={};
807end
808nbfield2_cell=get(handles.nb_field2,'String');
809val=get(handles.nb_field2,'Value');
810if iscell(nbfield2_cell)
811    nbfield2=str2num(nbfield2_cell{val});
812else
813    nbfield2=str2num(nbfield2_cell);
814end
815nbfield_cell=get(handles.nb_field,'String');
816if iscell(nbfield_cell)
817    nbfield=str2num(nbfield_cell{val});
818else
819   nbfield=str2num(nbfield_cell);
820end
821
822set(handles.mode,'Visible','off') % do not show index pairs by default
823set(handles.list_pair_civ,'Visible','off')
824set(handles.ref_i,'Visible','off')
825set(handles.ref_i_text,'Visible','off')
826testpair=0;
827state_j='off';
828%set the menus of image pairs and default selection for series
829%list pairs if relevant
830Val=get(handles.NomType,'Value');
831synchronise_view(handles,Val)
832if ~isempty(NomTypeCell)
833    NomType=NomTypeCell{Val};
834    switch NomType 
835            case {'_i1-i2_j', '_i1-i2'}
836                set(handles.mode,'String',{'series(Di)'})
837                set(handles.mode,'Value',1);
838                set(handles.mode,'Visible','on')
839                testpair=1;
840            case {'#_ab'}
841                set(handles.mode,'String',{'bursts'})
842                set(handles.mode,'Value',1);
843                testpair=1;
844            case '_i_j1-j2'
845                set(handles.mode,'String',{'bursts';'series(Dj)'})%multiple choice
846                if ~isempty(nbfield) && ~isempty(nbfield2) && ((nbfield2>10) || (nbfield==1))
847                    set(handles.mode,'Value',2);
848                else
849                    set(handles.mode,'Value',1);% advice 'bursts' for small bursts
850                end
851                set(handles.mode,'Visible','on')
852                testpair=1;
853    end
854    switch NomType   
855            case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
856                state_j='on';
857    end
858end   
859if testpair
860    mode_Callback(hObject, eventdata, handles) 
861else
862    set(handles.NomType,'String',NomTypeCell)
863end
864set(handles.first_j,'Visible',state_j)
865set(handles.incr_j,'Visible',state_j)
866set(handles.last_j,'Visible',state_j)
867set(handles.nb_field2,'Visible',state_j)
868
869%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%????????????
870% --- Executes on button press in mode.
871%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
872function mode_Callback(hObject, eventdata, handles)
873%hseries=get(handles.mode,'parent');
874hseries=handles.figure1;
875SeriesData=get(hseries,'UserData');
876mode_list=get(handles.mode,'String');
877mode_value=get(handles.mode,'Value');
878mode=mode_list{mode_value};
879NomType=[];
880test_find_pair=0;
881if isfield(SeriesData,'NomType')
882    NomTypeCell=SeriesData.NomType;
883    Val=get(handles.NomType,'Value');
884    NomType=NomTypeCell{Val};
885    test_find_pair=isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')|| isequal(NomType,'_i1-i2')|| isequal(NomType,'#_ab');
886end
887% displ_num=[];%default
888% first_i=str2num(get(handles.first_i,'String'));
889% last_i=str2num(get(handles.last_i,'String'));
890time=[];
891if isfield(SeriesData,'Time')
892time=SeriesData.Time{1}; %get the set of times
893end
894siztime=size(time);
895nbfield=siztime(1);
896nbfield2=siztime(2);
897indchosen=1;  %%first pair selected by default
898if isequal(mode,'bursts')
899    enable_i(handles,'On')
900    enable_j(handles,'Off')   
901elseif  isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')
902    enable_i(handles,'On')
903    enable_j(handles,'On')
904else
905    enable_i(handles,'On')
906    enable_j(handles,'Off')
907end   
908set(handles.list_pair_civ,'Value',indchosen);%set the default choice of image pairs for civ1
909set(hseries,'UserData',SeriesData)
910
911%list pairs if relevant
912if test_find_pair
913     find_netcpair_civ(hObject, eventdata, handles,Val)
914end
915
916%-------------------------------------
917function enable_i(handles,state)
918set(handles.i_txt,'Visible',state)
919set(handles.first_i,'Visible',state)
920set(handles.last_i,'Visible',state)
921set(handles.incr_i,'Visible',state)
922set(handles.nb_field,'Visible',state)
923set(handles.ref_i,'Visible',state)
924set(handles.ref_i_text,'Visible',state)
925
926%-----------------------------------
927function enable_j(handles,state)
928set(handles.j_txt,'Visible',state)
929set(handles.first_j,'Visible',state)
930set(handles.last_j,'Visible',state)
931set(handles.incr_j,'Visible',state)
932set(handles.nb_field2,'Visible',state)
933set(handles.ref_j,'Visible',state)
934set(handles.ref_j_text,'Visible',state)
935
936%-----------------------------------
937function view_FieldMenu(handles,state)
938set(handles.FieldMenu,'Visible',state)
939set(handles.Field_text,'Visible',state)
940set(handles.Field_frame,'Visible',state)
941
942%-----------------------------------
943function view_FieldMenu_1(handles,state)
944set(handles.FieldMenu_1,'Visible',state)
945set(handles.Field_text_1,'Visible',state)
946
947%-----------------------------------
948function view_TRANSFORM(handles,state)
949set(handles.TRANSFORM_frame,'Visible',state)
950set(handles.CoordType,'Visible',state);
951set(handles.TRANSFORM_title,'Visible',state)
952
953%--------------------------------------------------------------
954% determine the menu for civ1 pairs depending on existing netcdf file at the middle of
955% the field series set by first_i, incr, last_i
956%----------------------------------------------------------------
957function find_netcpair_civ(hObject, eventdata, handles,Val)
958%hseries=get(handles.list_pair_civ,'parent');
959SeriesData=get(handles.figure1,'UserData');
960% NomTypeCell=get(handles.NomType,'String');
961NomTypeCell=SeriesData.NomType;
962NomType=NomTypeCell{Val};
963  set(handles.list_pair_civ,'Visible','on')
964%nomenclature types
965RootPathCell=get(handles.RootPath,'String');
966filepath=RootPathCell{Val};
967RootFileCell=get(handles.RootFile,'String');
968filename=RootFileCell{Val};
969filebase=fullfile(filepath,filename);
970SubDirCell=get(handles.SubDir,'String');
971subdir=SubDirCell{Val};
972if ~exist(fullfile(filepath,subdir),'dir')
973         msgbox_uvmat('ERROR',['no civ file available: subdirectory ' subdir ' does not exist'])
974         set(handles.list_pair_civ,'String',{''});
975         return
976end
977mode_list=get(handles.mode,'String');
978mode_value=get(handles.mode,'Value');
979mode=mode_list{mode_value};
980
981%reads image numbers from the interface
982ref_i=str2num(get(handles.ref_i,'String'));
983ref_j=str2num(get(handles.ref_j,'String'));
984% time=[];
985% ref_time=[];
986 ref_time=0;
987if isfield(SeriesData,'Time')&~isempty(SeriesData.Time{Val})&~isequal(SeriesData.Time{Val},0)
988    time=SeriesData.Time{Val}; %get the set of times
989    siztime=size(time);
990    nbfield=siztime(1);
991    nbfield2=siztime(2);
992%     test_imadoc=1;
993else
994%     test_imadoc=0;%no image documentation file
995    nbfield=50;
996    nbfield2=50;%default max number of pairs
997end
998%look for existing processed pairs involving the field at the middle of the series if civ1 will not
999% be performed, while the result is needed for next steps.
1000displ_pair={''};
1001displ_num=[];
1002ind_exist=0;
1003TimeUnit=get(handles.TimeUnit,'String');
1004if length(TimeUnit)>=1
1005    dtunit=['m' TimeUnit];
1006else
1007    dtunit='e-03';
1008end
1009if isequal(mode,'series(Di)')
1010     for index=1:min(nbfield-1,50)
1011         filename=name_generator(filebase,ref_i-floor(index/2),ref_j,'.nc',NomType,1,ref_i+ceil(index/2),ref_j,subdir);
1012         select=(exist(filename,'file')==2);
1013         if select==1
1014               ind_exist=ind_exist+1;
1015                displ_num(1,ind_exist)=0;
1016                displ_num(2,ind_exist)=0;
1017                displ_num(3,ind_exist)=-floor(index/2);
1018                displ_num(4,ind_exist)=ceil(index/2);
1019                %[cte_detect,vdt,cte_read]=read_netcdf(filename,{'dt','dt2','absolut_time_T0','absolute_time_TO_2'});
1020                [Cte,var_detect,ichoice]=nc2struct(filename,{});
1021                if isfield(Cte,'dt2')
1022                    dt=Cte.dt2;
1023                elseif isfield(Cte,'dt')
1024                    dt=Cte.dt;
1025                end
1026                if isfield(Cte,'absolut_time_TO_2')
1027                    ref_time(ind_exist)=Cte.absolut_time_TO_2;%civ2 data used in priority
1028                elseif isfield(Cte,'absolut_time_TO')
1029                    ref_time(ind_exist)=Cte.absolut_time_TO;%civ2 data used in priorit
1030                elseif isfield(Cte,'Time')
1031                    ref_time(ind_exist)=Cte.Time;
1032                end
1033                displ_pair{ind_exist}=['Di= ' num2str(-floor(index/2)) '|' num2str(ceil(index/2)) ' :dt= ' num2str(dt*1000) dtunit];
1034         end
1035     end
1036     set(handles.list_pair_civ,'String',[displ_pair';{'Di=*|*'}]);   
1037elseif isequal(mode,'series(Dj)')% series on the j index
1038       for index=1:min(nbfield2-1,50)
1039           filename=name_generator(filebase,ref_i,ref_j-floor(index/2),'.nc',NomType,1,ref_i,ref_j+ceil(index/2),subdir);
1040           select=(exist(filename,'file')==2);
1041           if select==1
1042               ind_exist=ind_exist+1;
1043                displ_num(1,ind_exist)=-floor(index/2);
1044                displ_num(2,ind_exist)=ceil(index/2);
1045                displ_num(3,ind_exist)=0;
1046                displ_num(4,ind_exist)=0;
1047                %[cte_detect,vdt,cte_read]=read_netcdf(filename,{'dt','dt2','absolut_time_T0','absolute_time_TO_2'});
1048                [Cte,var_detect,ichoice]=nc2struct(nc,{});
1049                if isfield(Cte,'dt2')
1050                    dt=Cte.dt2;
1051                elseif isfield(Cte,'dt')
1052                    dt=Cte.dt;
1053                end
1054                if isfield(Cte,'absolut_time_TO_2')
1055                    ref_time(ind_exist)=Cte.absolut_time_TO_2;%civ2 data used in priority
1056                elseif isfield(Cte,'absolut_time_TO')
1057                    ref_time(ind_exist)=Cte.absolut_time_TO;%civ2 data used in priorit
1058                elseif isfield(Cte,'Time')
1059                    ref_time(ind_exist)=Cte.Time;
1060                end
1061%                 if cte_detect(2)==1;
1062%                     dt=cte_read(2);
1063%                     ref_time(ind_exist)=cte_read(4);%civ2 data used in priority
1064%                 else
1065%                     dt=cte_read(1);
1066%                     ref_time(ind_exist)=cte_read(3);
1067%                 end
1068                displ_pair{ind_exist}=['Dj= ' num2str(-floor(index/2)) '|' num2str(ceil(index/2)) ' :dt= ' num2str(dt*1000) dtunit];
1069           end
1070       end
1071       set(handles.list_pair_civ,'String',[displ_pair';{'Dj=*|*'}]);
1072elseif isequal(mode,'bursts') %case of bursts
1073    for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'bursts' mode
1074        for numod_b=(numod_a+1):nbfield2
1075            [filename]=name_generator(filebase,ref_i,numod_a,'.nc',NomType,1,ref_i,numod_b,subdir);
1076            select=(exist(filename,'file')==2);
1077            if select==1
1078                ind_exist=ind_exist+1;
1079                numlist_a(ind_exist)=numod_a;
1080                numlist_b(ind_exist)=numod_b;
1081                Attr=nc2struct(filename,[]);
1082                isfield(Attr,'absolut_time_T0_2')
1083                if isfield(Attr,'dt2')
1084                   dt(ind_exist)=Attr.dt2;
1085                   ref_time(ind_exist)=Attr.absolut_time_T0_2;
1086                elseif isfield(Attr,'dt')& isfield(Attr,'absolut_time_T0')
1087                   dt(ind_exist)=Attr.dt;
1088                   ref_time(ind_exist)=Attr.absolut_time_T0;
1089                else
1090                   dt(ind_exist)=NaN;%no information on dt
1091                end
1092                %determine nom_type_ima for pair display (used in num2stra.m)
1093                switch NomType
1094                    case {'#ab'}
1095                        nom_type_ima='#a';
1096                    case {'#AB'}
1097                        nom_type_ima='#A';
1098                    otherwise
1099                         nom_type_ima='_i_j';
1100                end
1101               displ_pair{ind_exist}=['j= ' num2stra(numod_a,nom_type_ima,2) '-' num2stra(numod_b,nom_type_ima,2) ...
1102                        ' :dt= ' num2str(dt(ind_exist)*1000)];
1103            end
1104         end
1105         set(handles.list_pair_civ,'String',[displ_pair';{'j=*-*'}]);
1106     end
1107     if exist('dt','var') & ~isempty(dt)
1108         [dtsort,indsort]=sort(dt);
1109         displ_num(1,:)=numlist_a(indsort);
1110         displ_num(2,:)=numlist_b(indsort);
1111         displ_num(3,:)=0;
1112         displ_num(4,:)=0;
1113         displ_pair=displ_pair(indsort);
1114         ref_time=ref_time(indsort);
1115     end
1116end
1117if ind_exist==0
1118         if  isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)')
1119            msgbox_uvmat('ERROR',['no .nc file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir])
1120        else
1121            msgbox_uvmat('ERROR',['no .nc file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir])
1122        end
1123        if isequal(mode,'bursts') %case of bursts
1124            set(handles.list_pair_civ,'String',{'j=*-*'});
1125        elseif isequal(mode,'series(Di)') %case of bursts
1126            set(handles.list_pair_civ,'String',{'Di=*|*'});
1127        elseif isequal(mode,'series(Dj)') %case of bursts
1128            set(handles.list_pair_civ,'String',{'Dj=*|*'});
1129        end
1130end
1131
1132val=get(handles.list_pair_civ,'Value');
1133if val > length(displ_pair)
1134    set(handles.list_pair_civ,'Value',1);% first pair proposed by default in the menu
1135    val=1;
1136end
1137iview=get(handles.NomType,'Value');
1138SeriesData.displ_num(iview,:)=(displ_num(:,val))';
1139SeriesData.ref_time=ref_time;
1140set(handles.figure1,'UserData',SeriesData)
1141list_pair_civ_Callback(hObject, eventdata, handles)
1142
1143%-------------------------------------------------------------
1144% --- Executes on selection in list_pair_civ.
1145function list_pair_civ_Callback(hObject, eventdata, handles)
1146%------------------------------------------------------------
1147
1148%update first_i and last_i according to the chosen image pairs
1149testupdate=0;
1150Val=get(handles.RootPath,'Value');
1151IndexCell=get(handles.NomType,'String');
1152%hseries=get(handles.list_pair_civ,'parent');
1153SeriesData=get(handles.figure1,'UserData');
1154NomType=SeriesData.NomType{Val};
1155list_pair=get(handles.list_pair_civ,'String');%get the menu of image pairs
1156index_pair=get(handles.list_pair_civ,'Value');
1157str_pair=list_pair{index_pair};
1158ind_equ=strfind(str_pair,'=');%find '='
1159ind_sep=strfind(str_pair,'|');%find pair separator '|'
1160ind_com=strfind(str_pair,':');%find ':'
1161test_bursts=0;
1162if isempty(ind_sep)
1163    ind_sep=strfind(str_pair,'-');%find pair separator if it is not '|'
1164    test_bursts=1;% we are in the case of bursts
1165end
1166displ_num=[0 0 0 0]; %default
1167if ~isempty(ind_sep)&& ~strcmp(str_pair(ind_sep-1),'*')% if there is a pair separator ('|' or '-')
1168    num1_str=str_pair(ind_equ(1)+1:ind_sep-1);
1169    num2_str=str_pair(ind_sep+1:ind_com-1);
1170    num1=str2double(num1_str);
1171    num2=str2double(num2_str);
1172    if isequal(num1_str(1),' ')
1173        num1_str(1)=[];
1174    end   
1175    if isequal(num2_str(end),' ')
1176        num2_str(end)=[];
1177    end
1178    switch NomType
1179       case {'_i1-i2_j'}
1180           if isequal(num1_str(1),'0')
1181               IndexCell{Val}=['_(i-(i+' num2_str ')_j'];
1182           else
1183               IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')_j'];
1184           end
1185           displ_num(3)=num1;
1186           displ_num(4)=num2;
1187       case {'_i1-i2'}
1188           if isequal(num1_str(1),'0')
1189               IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')'];
1190           else
1191               IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')'];
1192           end
1193           displ_num(3)=num1;
1194           displ_num(4)=num2;
1195       case '_i_j1-j2'
1196          if test_bursts
1197              IndexCell{Val}=['_i_' num1_str '-' num2_str ];
1198          else
1199              if isequal(num1_str(1),'0')
1200                 IndexCell{Val}=['_i_j-(j+' num2_str ')'];
1201              else
1202                 IndexCell{Val}=['_i_(j' num1_str ')-(j+' num2_str ')'];
1203              end
1204          end
1205          displ_num(1)=num1;
1206          displ_num(2)=num2;
1207       case {'#_ab'} %TO COMPLETE
1208           IndexCell{Val}=['_i_' num1_str '-' num2_str ];
1209
1210    end
1211end
1212set(handles.NomType,'String',IndexCell)
1213SeriesData.displ_num(Val,:)=displ_num;
1214set(handles.figure1,'UserData',SeriesData)
1215% set(handles.NomType,'Value',Val)
1216
1217if ~isequal(str_pair,'Dj=*|*')&~isequal(str_pair,'Di=*|*')
1218        mode_list=get(handles.mode,'String');
1219    mode_value=get(handles.mode,'Value');
1220    mode=mode_list{mode_value};
1221        if isequal(mode,'series(Di)')
1222        first_i=str2num(get(handles.first_i,'String'));
1223        last_i=str2num(get(handles.last_i,'String'));
1224        incr_i=str2num(get(handles.incr_i,'String'));
1225        num1=first_i:incr_i:last_i;
1226        lastfieldCell=get(handles.nb_field,'String');
1227        lastfield=str2num(lastfieldCell{1});
1228        if ~isempty(lastfield)
1229            ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield));
1230            num1=num1(ind);       
1231        end
1232        set(handles.first_i,'String',num2str(num1(1)));
1233        set(handles.last_i,'String',num2str(num1(end)));
1234        testupdate=1;
1235        elseif isequal(mode,'series(Dj)')
1236        first_j=str2num(get(handles.first_j,'String'));
1237        last_j=str2num(get(handles.last_j,'String'));
1238        incr_j=str2num(get(handles.incr_j,'String'));
1239        num_j=first_j:incr_j:last_j;
1240        lastfieldCell=get(handles.nb_field2,'String');
1241        if ~isempty(lastfieldCell)
1242            lastfield2=lastfieldCell{1};
1243            ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
1244                 (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2));
1245        end
1246        testupdate=1;
1247        end
1248       
1249        %update the first and last times of the series
1250        if testupdate & isfield(SeriesData,'Time')
1251        if ~isempty(SeriesData.Time{1})
1252            displ_time(handles,SeriesData.Time{1});
1253        end
1254        end
1255end
1256%---------------------------------------------------
1257% --- Executes on button press in RUN.
1258%------------------------------------------------------
1259function RUN_Callback(hObject, eventdata, handles)
1260
1261%read root name and field type
1262set(handles.RUN,'BusyAction','queue');
1263%hseries=get(handles.RUN,'parent');
1264set(0,'CurrentFigure',handles.figure1)
1265if isequal(get(handles.GetObject,'Value'),1)
1266    Series.GetObject=1;
1267    GetObject_Callback(hObject, eventdata, handles)
1268else
1269    Series.GetObject=0;
1270end
1271SeriesData=get(handles.figure1,'UserData');
1272if isfield(SeriesData,'sethandles')
1273    if iscell(SeriesData.sethandles)
1274        Series.sethandles=SeriesData.sethandles{1};
1275    else
1276        Series.sethandles=SeriesData.sethandles;%retrieve the handles of the set_object interface (to define projection objects)
1277    end
1278end
1279
1280%reinitiate waitbar position
1281Series.WaitbarPos=get(handles.waitbar_frame,'Position');%TO SUPPRESS
1282waitbarpos=Series.WaitbarPos;
1283waitbarpos(4)=0.005;%reinitialize waitbar to zero height
1284waitbarpos(2)=Series.WaitbarPos(2)+Series.WaitbarPos(4)-0.005;
1285set(handles.waitbar,'Position',waitbarpos)
1286
1287% read input file parameters and set menus
1288Series.PathProject=get(handles.PathCampaign,'String');
1289RootPath=get(handles.RootPath,'String');% path of the root name of the first field series
1290RootFile=get(handles.RootFile,'String');% root name of the first field series
1291SubDir=get(handles.SubDir,'String');% subdirectory for netcdf files
1292FileExt=get(handles.FileExt,'String');%file extension
1293if isempty(SeriesData)
1294    msgbox_uvmat('ERROR','no input file series')
1295    return
1296end
1297NomType=SeriesData.NomType;
1298if length(RootPath)==1 %string character input for user fct
1299    Series.RootPath=RootPath{1};
1300    Series.RootFile=RootFile{1};
1301    Series.SubDir=SubDir{1};
1302    Series.FileExt=FileExt{1};
1303    Series.NomType=NomType{1};
1304else %cell input for user fct
1305    Series.RootPath=RootPath;
1306    Series.RootFile=RootFile;
1307    Series.SubDir=SubDir;
1308    Series.FileExt=FileExt;
1309    Series.NomType=NomType;
1310end
1311if isequal(get(handles.FieldMenu,'Visible'),'on')
1312    FieldMenu=get(handles.FieldMenu,'String');
1313    FieldValue=get(handles.FieldMenu,'Value');
1314    Series.Field=FieldMenu(FieldValue);
1315end
1316menu_coord_state=get(handles.CoordType,'Visible');
1317Series.CoordType='';%default
1318if isequal(menu_coord_state,'on')
1319    menu_coord=get(handles.CoordType,'String');
1320    menu_index=get(handles.CoordType,'Value');
1321    Series.CoordType=menu_coord{menu_index};
1322end
1323Series.hseries=get(hObject,'Parent');
1324if isequal(get(handles.ParamVal,'Visible'),'on')
1325    ParamKey=get(handles.ParamKey,'String');
1326    if ischar(ParamKey)
1327        ParamKey{1}=ParamKey;
1328    end
1329    ParamString=get(handles.ParamVal,'String');
1330    if ischar(ParamString)
1331        for ilist=1:size(ParamString,1)
1332            ParamVal{ilist}=ParamString(ilist,:);
1333        end
1334    else
1335        ParamVal=ParamString;
1336    end   
1337end
1338
1339%read the set of field numbers
1340first_i=str2num(get(handles.first_i,'String'));
1341last_i=str2num(get(handles.last_i,'String'));
1342incr_i=str2num(get(handles.incr_i,'String'));
1343first_j=str2num(get(handles.first_j,'String'));
1344last_j=str2num(get(handles.last_j,'String'));
1345incr_j=str2num(get(handles.incr_j,'String'));
1346if ~isequal(get(handles.first_i,'Visible'),'on')
1347   first_i=1;
1348   last_i=1;
1349   incr_i=1;
1350end
1351if ~isequal(get(handles.first_j,'Visible'),'on')
1352    first_j=1;
1353    last_j=1;
1354    incr_j=1;
1355end
1356Series.NbSlice=str2num(get(handles.NbSlice,'String'));
1357if isequal(first_i,[])|isequal(first_j,[]), msgbox_uvmat('ERROR','first field number not defined'),...
1358    set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1359if isequal(last_i,[])| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),...
1360    set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1361if isequal(incr_i,[])| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),...
1362    set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1363if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
1364    set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1365num_i=[first_i:incr_i:last_i];
1366num_j=[first_j:incr_j:last_j];
1367nbfield_cell=get(handles.nb_field,'String');
1368nbfield=[]; %default
1369for iview=1:length(nbfield_cell)
1370    nb=str2num(nbfield_cell{iview});
1371    if ~isempty(nb)
1372        nbfield=[nbfield nb];
1373    end
1374end
1375nbfield=min(nbfield);
1376nbfield2_cell=get(handles.nb_field2,'String');
1377nbfield2=[]; %default
1378for iview=1:length(nbfield2_cell)
1379    nb=str2num(nbfield2_cell{iview});
1380    if ~isempty(nb)
1381        nbfield2=[nbfield2 nb];
1382    end
1383end
1384nbfield2=min(nbfield2);
1385
1386%get complementary information from the 'series' interface
1387list_action=get(handles.ACTION,'String');% list menu action
1388index_action=get(handles.ACTION,'Value');% selected string index
1389action= list_action{index_action}; % selected string
1390mode_list=get(handles.mode,'String');
1391index_mode=get(handles.mode,'Value');
1392mode=mode_list{index_mode};
1393ind_shift=0;%default
1394
1395%determine the list of input file names
1396nbmissing=0;
1397for iview=1:length(RootPath)
1398    %case of pairs (.nc files)
1399   
1400    if isequal(NomType{iview},'_i_j1-j2')| isequal(NomType{iview},'_i1-i2_j')| isequal(NomType{iview},'_i1-i2')| isequal(NomType{iview},'#_ab')
1401        ind_shift=SeriesData.displ_num(iview,:);
1402        if isequal(ind_shift,[0 0 0 0]) % undefined pairs
1403            if isequal(NomType{iview},'#_ab')
1404                mode='#_ab';
1405            end
1406            [num_i1,num_i2,num_j1,num_j2,nbmissing]=netseries_generator(fullfile(RootPath{iview},RootFile{iview}),SubDir{iview},mode,first_i,incr_i,last_i,first_j,incr_j,last_j);
1407        else   
1408            [num_i1,num_i2,num_j1,num_j2,num_i,num_j]=find_file_indices(num_i,num_j,ind_shift,NomType{iview},mode);
1409            if isempty(num_i)
1410                msgbox_uvmat('ERROR','ERROR: empty set of input files chosen')
1411                return
1412            end
1413            if num_i(1)>first_i
1414               set(handles.first_i,'String',num2str(num_i(1)))%update the display of first field
1415               last_i_Callback(hObject, eventdata, handles)
1416            end
1417            if num_i(end)<last_i
1418               set(handles.last_i,'String',num2str(num_i(end)))%update the display of last field
1419               last_i_Callback(hObject, eventdata, handles)
1420            end
1421            if num_j(1)>first_j
1422               set(handles.first_j,'String',num2str(num_j(1)))%update the display of first field
1423               last_j_Callback(hObject, eventdata, handles)
1424            end
1425            if num_j(end)<last_j
1426               set(handles.last_j,'String',num2str(num_j(end)))%update the display of last field
1427               last_j_Callback(hObject, eventdata, handles)
1428            end
1429        end
1430    else%case of images
1431        [num_i1,num_j1]=meshgrid(num_i,num_j);
1432        num_i2=num_i1;
1433        num_j2=num_j1;
1434    end
1435    if length(RootPath)>1
1436        num_i1_cell{iview}=num_i1;
1437        num_i2_cell{iview}=num_i2;
1438        num_j1_cell{iview}=num_j1;
1439        num_j2_cell{iview}=num_j2;
1440    end
1441end
1442
1443% RUN RUN'
1444path_series=which('series');
1445list_path=get(handles.ACTION,'UserData');
1446index=get(handles.ACTION,'Value');
1447fct_path=list_path{index}; %path stored for the function ACTION
1448if ~isequal(fct_path,path_series)
1449    eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION
1450    if ~isequal(spath,fct_path)& exist(fct_path,'dir')
1451        addpath(fct_path)% add the prescribed path if not the current one
1452    end
1453end
1454% fct_path
1455eval(['h_fun=@' action ';'])
1456if ~isequal(fct_path,path_series)
1457        rmpath(fct_path)% add the prescribed path if not the current one   
1458end
1459
1460Series.Action=action;%name of the processing programme
1461set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
1462drawnow
1463if length(RootPath)>1
1464%    feval(action,num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series);
1465    h_fun(num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series);
1466else
1467    h_fun(num_i1,num_i2,num_j1,num_j2,Series);
1468%     feval(action,num_i1,num_i2,num_j1,num_j2,Series);
1469end
1470set(handles.RUN,'BackgroundColor',[1 0 0])
1471
1472% %save the current interface setting as figure namefig, append .0 to the name if it already exists
1473% detect=1;
1474% while detect==1
1475%     namefigfull=[namedoc '.fig'];
1476%     hh=dir(namefigfull);
1477%     if ~isempty(hh)
1478%         detect=1;
1479%         namedoc=[namedoc '.0'];
1480%     else
1481%         detect=0;
1482%     end
1483% end
1484% saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER  .xml)
1485
1486%----------------------------------------------------
1487function STOP_Callback(hObject, eventdata, handles)
1488set(handles.RUN, 'BusyAction','cancel')
1489set(handles.RUN,'BackgroundColor',[1 0 0])
1490
1491%----------------------------------------------
1492
1493%----------------------------------------------------
1494function first_i_Callback(hObject, eventdata, handles)
1495last_i_Callback(hObject, eventdata, handles)
1496
1497%----------------------------------------------
1498function last_i_Callback(hObject, eventdata, handles)
1499%     hseries=get(handles.last_i,'parent');
1500first_i=str2num(get(handles.first_i,'String'));
1501last_i=str2num(get(handles.last_i,'String'));
1502ref_i=ceil((first_i+last_i)/2);
1503set(handles.ref_i,'String', num2str(ref_i))
1504ref_i_Callback(hObject, eventdata, handles)
1505SeriesData=get(handles.figure1,'UserData');
1506if ~isfield(SeriesData,'Time')
1507    SeriesData.Time{1}=[];
1508end
1509displ_time(handles,SeriesData.Time{1});
1510
1511%-------------------------------------------------------
1512function first_j_Callback(hObject, eventdata, handles)
1513 last_j_Callback(hObject, eventdata, handles)
1514
1515%-------------------------------------------------------
1516function last_j_Callback(hObject, eventdata, handles)
1517   % hseries=get(handles.last_i,'parent');
1518first_j=str2num(get(handles.first_j,'String'));
1519last_j=str2num(get(handles.last_j,'String'));
1520ref_j=ceil((first_j+last_j)/2);
1521set(handles.ref_j,'String', num2str(ref_j))
1522
1523ref_j_Callback(hObject, eventdata, handles)
1524SeriesData=get(handles.figure1,'UserData');
1525if ~isfield(SeriesData,'Time')
1526    SeriesData.Time{1}=[];
1527end
1528displ_time(handles,SeriesData.Time{1});
1529
1530
1531
1532
1533%-------------------------------------------------------
1534function ref_i_Callback(hObject, eventdata, handles)
1535mode_list=get(handles.mode,'String');
1536mode_value=get(handles.mode,'Value');
1537mode=mode_list{mode_value};
1538%hseries=get(handles.ref_i,'parent');
1539SeriesData=get(handles.figure1,'UserData');
1540%NomTypeCell=get(handles.NomType,'String');
1541NomTypeCell=SeriesData.NomType;
1542if ~isempty(NomTypeCell)
1543Val=get(handles.NomType,'Value');
1544NomType=NomTypeCell{Val};
1545% for ilist=1:length(NomType)
1546    if isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')|| isequal(NomType,'_i1-i2')
1547        if isequal(mode,'series(Di)')
1548            find_netcpair_civ(hObject, eventdata, handles,Val);% update the menu of pairs depending on the available netcdf files
1549%             break
1550        end
1551    end
1552end
1553
1554%----------------------------------------------------
1555function ref_j_Callback(hObject, eventdata, handles)
1556mode_list=get(handles.mode,'String');
1557mode_value=get(handles.mode,'Value');
1558mode=mode_list{mode_value};
1559%hseries=get(handles.ref_i,'parent');
1560SeriesData=get(handles.figure1,'UserData');
1561NomTypeCell=SeriesData.NomType;
1562if ~isempty(NomTypeCell)
1563    Val=get(handles.NomType,'Value');
1564    NomType=NomTypeCell{Val};
1565    if isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')|| isequal(NomType,'_i1-i2')
1566        if isequal(mode,'series(Dj)')
1567            find_netcpair_civ(hObject, eventdata, handles,Val);% update the menu of pairs depending on the available netcdf files
1568        end
1569    end
1570end
1571
1572%----------------------------------------------------
1573% --- Executes on selection change in ACTION.
1574function ACTION_Callback(hObject, eventdata, handles)
1575global nb_builtin
1576list_ACTION=get(handles.ACTION,'String');% list menu fields
1577index_ACTION=get(handles.ACTION,'Value');% selected string index
1578ACTION= list_ACTION{index_ACTION}; % selected function name
1579path_series=which('series');%path to series.m
1580list_path=get(handles.ACTION,'UserData');%list of recorded paths to functions of the list ACTION
1581
1582% add a new function to the menu if the selected item is 'more...'
1583if isequal(ACTION,'more...')
1584    pathfct=fileparts(path_series);
1585%     browse_name=fullfile(path_series,'series');%go to UVMAT/series by default
1586%     if length(list_path)>nb_builtin
1587%         browse_name=list_path{end};% initialize browser with  the path of the last introduced function
1588%      end
1589    [FileName, PathName, filterindex] = uigetfile( ...
1590       {'*.m', ' (*.m)';
1591        '*.m',  '.m files '; ...
1592        '*.*', 'All Files (*.*)'}, ...
1593        'Pick a file',list_path{end});
1594    if length(FileName)<2
1595        return
1596    end
1597    [pp,ACTION,ext_fct]=fileparts(FileName);%(end-1:end);
1598    if ~isequal(ext_fct,'.m')
1599        msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
1600        return
1601    end
1602   
1603   % insert the choice in the action menu
1604   menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed
1605   index_ACTION=get(handles.ACTION,'Value');% currently selected index in the list
1606   list_path{index_ACTION}=PathName;
1607   if length(menu_str)>nb_builtin+5; %nb_builtin=nbre of functions always remaining in the initial menu
1608       nbremove=length(menu_str)-nb_builtin-5;
1609       menu_str(nb_builtin+1:end-5)=[];
1610       list_path(nb_builtin+1:end-4)=[];
1611       index_ACTION=index_ACTION-nbremove;
1612       set(handles.ACTION,'Value',index_ACTION)
1613       set(handles.ACTION,'String',menu_str)
1614   end
1615   list_path{index_ACTION}=PathName;
1616   set(handles.ACTION,'UserData',list_path);
1617   set(handles.path,'enable','inactive')% indicate that the current path is accessible (not 'off')
1618   
1619   %record the current menu in personal file profil_perso
1620   dir_perso=prefdir;
1621   profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
1622   for ilist=nb_builtin+1:length(menu_str)-1
1623       series_fct{ilist-nb_builtin}=fullfile(list_path{ilist},[menu_str{ilist} '.m']);
1624   end
1625   if exist(profil_perso,'file')
1626        save(profil_perso,'series_fct','-append')
1627   else
1628        txt=ver;
1629        Release=txt(1).Release;
1630        relnumb=str2num(Release(3:4));
1631        if relnumb >= 14
1632            save(profil_perso,'series_fct','-V6')
1633        else
1634            save(profil_perso, 'series_fct')
1635        end
1636   end
1637end
1638
1639%check the current path to the selected function
1640PathName=list_path{index_ACTION};%current recorded path
1641set(handles.path,'String',PathName); %show the path to the senlected function
1642
1643%default setting for the visibility of the GUI elements
1644set(handles.RootPath,'UserData','many')
1645set(handles.SubDir,'Visible','on')
1646set(handles.RootFile,'Visible','on')
1647set(handles.NomType,'Visible','on')
1648set(handles.FileExt,'Visible','on')
1649set(handles.NbSlice,'Visible','off')
1650set(handles.NbSlice_title,'Visible','off')
1651set(handles.VelTypeMenu,'Visible','off');
1652set(handles.VelType_text,'Visible','off');
1653set(handles.VelTypeMenu_1,'Visible','off');
1654set(handles.VelType_text_1,'Visible','off');
1655view_FieldMenu(handles,'off')
1656view_FieldMenu_1(handles,'off')
1657view_TRANSFORM(handles,'off')
1658set(handles.ProjObject_frame,'Visible','off');
1659set(handles.GetMask,'Visible','off')
1660set(handles.Mask,'Visible','off')
1661set(handles.GetObject,'Visible','off');
1662set(handles.ProjObject,'Visible','off');
1663set(handles.OutputDir,'Visible','off');
1664set(handles.PARAMETERS_frame,'Visible','off');
1665set(handles.PARAMETERS_title,'Visible','off');
1666set(handles.ParamKey,'Visible','off')
1667set(handles.ParamVal,'Visible','off')
1668ParamKey={};
1669set(handles.FieldMenu,'Enable','off')
1670set(handles.VelTypeMenu,'Enable','off')
1671set(handles.FieldMenu_1,'Enable','off')
1672set(handles.VelTypeMenu_1,'Enable','off')
1673set(handles.CoordType,'Enable','off')
1674%set the displayed GUI item needed for input parameters
1675%list_input=feval(ACTION);% input list asked by the selected function
1676if ~isequal(path_series,PathName)
1677    addpath(PathName)
1678end
1679eval(['h_function=@' ACTION ';']);
1680if ~isequal(path_series,PathName)
1681    rmpath(PathName)
1682end
1683
1684varargout=h_function();
1685%varargout=feval(ACTION);% input list asked by the selected function
1686Param_list={};
1687% RootPath=get(handles.RootPath,'String');
1688% RootFile=get(handles.RootFile,'String');
1689
1690%nb_series=length(RootFile);
1691FileExt=get(handles.FileExt,'String');
1692nb_series=length(FileExt);
1693testima_series=1; %test for a list of images only
1694testima=1;
1695testima_1=1;
1696testciv_series=1;
1697for iview=1:nb_series
1698    ext=FileExt{iview};
1699    if length(ext)<2
1700        ext='.none';
1701    end
1702    testimaview=~isempty(imformats(ext(2:end))) || isequal(lower(ext),'.avi');
1703    if ~testimaview
1704        if iview==1
1705            testima=0;
1706        end
1707        if iview==2
1708            testima_1=0;
1709        end
1710        testima_series=0;
1711    end
1712end
1713for ilist=1:length(varargout)-1
1714    switch varargout{ilist}
1715                       %RootFile always visible
1716         case 'RootPath'   %visible by default
1717            value=lower(varargout{ilist+1});
1718            if isequal(value,'one')||isequal(value,'two')||isequal(value,'many')
1719                set(handles.RootFile,'UserData',value)% for use in menu Open_insert
1720            end
1721        case 'SubDir' %visible by default
1722            if isequal(lower(varargout{ilist+1}),'off')
1723                set(handles.SubDir,'Visible','off')
1724            end
1725        case 'RootFile'   %visible by default
1726            value=lower(varargout{ilist+1});
1727            if isequal(value,'off')
1728                set(handles.RootFile,'Visible','off')
1729            elseif isequal(value,'one')||isequal(value,'two')||isequal(value,'many')
1730                set(handles.RootFile,'Visible','on')
1731                set(handles.RootFile,'UserData',value)% for use in menu Open_insert
1732            end
1733        case 'NomType'   %visible by default
1734            if isequal(lower(varargout{ilist+1}),'off')
1735                set(handles.NomType,'Visible','off')
1736            end
1737        case 'FileExt'   %visible by default
1738            if isequal(lower(varargout{ilist+1}),'off')
1739                set(handles.FileExt,'Visible','off')
1740            end
1741        case 'NbSlice'   %hidden by default
1742            if isequal(lower(varargout{ilist+1}),'on')
1743                set(handles.NbSlice,'Visible','on')
1744                set(handles.NbSlice_title,'Visible','on')
1745            end
1746        case 'VelTypeMenu'   %hidden by default
1747            if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two')
1748                set(handles.VelTypeMenu,'Enable','on')
1749                if nb_series >=1 && ~testima_series
1750                    set(handles.VelTypeMenu,'Visible','on')
1751                    set(handles.VelType_text,'Visible','on');
1752                    set(handles.Field_frame,'Visible','on')
1753                end
1754            end
1755            if isequal(lower(varargout{ilist+1}),'two')
1756                set(handles.VelTypeMenu_1,'Enable','on')
1757                if nb_series >=2 && ~testima_series
1758                    set(handles.VelTypeMenu_1,'Visible','on')
1759                    set(handles.VelType_text_1,'Visible','on');
1760                end
1761            end
1762        case 'FieldMenu'   %hidden by default
1763            if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two')
1764                set(handles.FieldMenu,'Enable','on') % test for MenuBorser
1765                if nb_series >=1 && ~testima_series
1766                    view_FieldMenu(handles,'on')
1767                end
1768            end
1769            if isequal(lower(varargout{ilist+1}),'two')
1770                set(handles.FieldMenu_1,'Enable','on')
1771                if nb_series >=2 && ~testima_1
1772                    view_FieldMenu_1(handles,'on')
1773                end
1774            end
1775        case 'CoordType'   %hidden by default
1776            if isequal(lower(varargout{ilist+1}),'on')
1777                set(handles.CoordType,'Enable','on')
1778                view_TRANSFORM(handles,'on')
1779            end
1780        case 'GetObject'   %hidden by default
1781            if isequal(lower(varargout{ilist+1}),'on')   
1782                set(handles.ProjObject_frame,'Visible','on')
1783                set(handles.GetObject,'Visible','on');
1784            end
1785        case 'Mask'   %hidden by default
1786            if isequal(lower(varargout{ilist+1}),'on')   
1787                set(handles.ProjObject_frame,'Visible','on')
1788                set(handles.GetMask,'Visible','on');
1789            end
1790        case 'PARAMETER' 
1791            set(handles.PARAMETERS_frame,'Visible','on')
1792            set(handles.PARAMETERS_title,'Visible','on')
1793            set(handles.ParamKey,'Visible','on')
1794            %set(handles.ParamVal,'Visible','on')
1795            Param_str=varargout{ilist+1};
1796            Param_list=[Param_list; {Param_str}];         
1797    end
1798end
1799if ~isempty(Param_list)
1800    set(handles.ParamKey,'String',Param_list)
1801    set(handles.ParamVal,'Visible','on')
1802end
1803
1804%-------------------------------------------------------------------
1805% --- Executes on selection change in FieldMenu.
1806%-------------------------------------------------------------------
1807function FieldMenu_Callback(hObject, eventdata, handles)
1808
1809field_str=get(handles.FieldMenu,'String');
1810field_index=get(handles.FieldMenu,'Value');
1811field=field_str{field_index(1)};
1812if isequal(field,'get_field...')   
1813     hget_field=findobj(allchild(0),'name','get_field');
1814     if ~isempty(hget_field)
1815         delete(hget_field)%delete opened versions of get_field
1816     end
1817     %hseries=get(handles.FieldMenu,'parent');
1818     SeriesData=get(handles.figure1,'UserData');
1819     filename=SeriesData.CurrentInputFile;
1820     if exist(filename,'file')
1821        get_field(filename)
1822     end
1823elseif isequal(field,'more...')
1824    str=calc_field;
1825    [ind_answer,v] = listdlg('PromptString','Select a file:',...
1826                'SelectionMode','single',...
1827                'ListString',str);
1828       % edit the choice in the fields and action menu
1829     scalar=cell2mat(str(ind_answer));
1830     update_menu(handles.FieldMenu,scalar)
1831end
1832
1833%------------------------------------------------------
1834% --- Executes on selection change in FieldMenu_1.
1835%-----------------------------------------------------
1836function FieldMenu_1_Callback(hObject, eventdata, handles)
1837field_str=get(handles.FieldMenu_1,'String');
1838field_index=get(handles.FieldMenu_1,'Value');
1839field=field_str{field_index};
1840if isequal(field,'get_field...')   
1841     hget_field=findobj(allchild(0),'name','get_field_1');
1842     if ~isempty(hget_field)
1843         delete(hget_field)
1844     end
1845     %hseries=get(handles.FieldMenu,'parent');
1846     SeriesData=get(handles.figure1,'UserData');
1847     filename=SeriesData.CurrentInputFile_1;
1848     if exist(filename,'file')
1849        hget_field=get_field(filename);
1850        set(hget_field,'name','get_field_1')
1851     end
1852elseif isequal(field,'more...')
1853    str=calc_field;
1854    [ind_answer,v] = listdlg('PromptString','Select a file:',...
1855                'SelectionMode','single',...
1856                'ListString',str);
1857       % edit the choice in the fields and action menu
1858     scalar=cell2mat(str(ind_answer));
1859     update_menu(handles.FieldMenu_1,scalar)
1860end   
1861
1862
1863% %group the variables (fields of 'FieldData') in cells of variables with the same dimensions
1864% %%%%%%%%%%%%%%%%%%%%%%% Function independante maintenant
1865% %-----------------------------------------------------------------
1866% [CellVarIndex,NbDim,VarTypeCell]=find_field_indices(Data{1});
1867% %LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
1868% % CellVarIndex=cells of variable index arrays
1869% ivar_new=0; % index of the current variable in the projected field
1870% icoord=0;
1871% for icell=1:length(CellVarIndex)
1872%     if NbDim(icell)==1
1873%         continue
1874%     end
1875%     VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list FieldData.ListVarName
1876%     VarType=VarTypeCell{icell};
1877%     ivar_X=VarType.coord_x;
1878%     ivar_Y=VarType.coord_y;
1879%     ivar_FF=VarType.errorflag;
1880%     if isempty(ivar_X)
1881%         test_grid=1;%test for input data on regular grid (e.g. image)coordinates
1882%     else
1883%         if length(ivar_Y)~=1
1884%                 warndlg_uvmat('y coordinate missing in proj_field.m','ERROR')
1885%                 return
1886%         end
1887%         test_grid=0;
1888%     end
1889% %    DimIndices=Data{1}.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell)
1890%     %case of input fields with unstructured coordinates
1891%     if ~test_grid
1892%         for ivar=VarIndex
1893%             VarName=MergeData.ListVarName{ivar};
1894%             for iview=1:nbview
1895%                 eval(['MergeData.' VarName '=[MergeData.' VarName '; Data{iview}.' VarName ';'])
1896%             end
1897%         end
1898%     %case of fields defined on a structured  grid
1899%     else 
1900% %        DimValue=MergeData.DimValue(DimIndices);%set of dimension values
1901%         testFF=0;
1902%         for iview=2:nbview
1903% %             if ~isequal(DimValue,Data{iview}.DimValue(DimIndices))
1904% %                 MergeData.Txt='ERROR: attempt at merging structured fields with different sizes';
1905% %                 return
1906% %             end
1907%             for ivar=VarIndex
1908%                 VarName=MergeData.ListVarName{ivar};
1909%                 if isfield(MergeData,'VarAttribute')
1910%                     if length(MergeData.VarAttribute)>=ivar && isfield(MergeData.VarAttribute{ivar},'Role') && isequal(MergeData.VarAttribute{ivar}.Role,'errorflag')
1911%                         testFF=1;
1912%                     end
1913%                 end
1914%                 eval(['MergeData.' VarName '=MergeData.' VarName '+ Data{iview}.' VarName ';'])
1915%             end
1916%         end
1917%         if testFF
1918%             nbaver=nbview-MergeData.FF;
1919%             indgood=find(nbaver>0);
1920%             for ivar=VarIndex
1921%                 VarName=MergeData.ListVarName{ivar};
1922%                 eval(['MergeData.' VarName '(indgood)=double(MergeData.' VarName '(indgood))./nbaver(indgood);'])
1923%             end
1924%         else
1925%             for ivar=VarIndex
1926%                 VarName=MergeData.ListVarName{ivar};
1927%                 eval(['MergeData.' VarName '=double(MergeData.' VarName ')./nbview;'])
1928%             end   
1929%         end
1930%     end
1931% end
1932%     
1933
1934%-----------------------------
1935function mouse_up_gui(ggg,eventdata,handles)
1936if isequal(get(ggg,'SelectionType'),'alt')
1937    display('global CurData, UserData of GUI series')
1938    global CurData
1939    CurData=get(ggg,'UserData');
1940    evalin('base','global CurData');%make CurData global in the workspace
1941    evalin('base','CurData'); %display CurData in the workspace
1942    commandwindow
1943   % plot_text(CurData)
1944end
1945
1946%%%%%%%%%%%%%
1947function [ind_remove]=find_pairs(dirpair,ind_i,last_i)
1948
1949        indsel=ind_i;
1950        indiff=diff(ind_i); %test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series
1951        indiff=[1 indiff last_i-ind_i(end)+1];%for testing gaps with the imposed bounds
1952        if ~isempty(indiff)
1953            indiff2=diff(indiff);
1954            indiffp=[indiff2 1];
1955            indiffm=[1 indiff2];
1956            ind_multi_m=find((indiff==0)&(indiffm<0))-1;%indices of first members of multiplets
1957            ind_multi_p=find((indiff==0)&(indiffp>0));%indices of last members of multiplets
1958                %for each multiplet, select the most recent file
1959            ind_remove=[];
1960            for i=1:length(ind_multi_m)
1961                ind_pairs=ind_multi_m(i):ind_multi_p(i);
1962                for imulti=1:length(ind_pairs)
1963                    datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);%dates of creation
1964                end
1965                [datenew,indsort2]=sort(datepair); %sort the multiplet by creation date
1966                ind_s=indsort2(1:end-1);%
1967                ind_remove=[ind_remove ind_pairs(ind_s)];%remove these indices, leave the last one
1968            end
1969        end
1970
1971%----------------------------------------------------
1972%  determine the list of index pairs of processing file
1973%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1974function [num_i1,num_i2,num_j1,num_j2,num_i_out,num_j_out]=find_file_indices(num_i,num_j,ind_shift,NomType,mode)
1975num_i1=num_i;% set of first image numbers by default
1976num_i2=num_i;
1977num_j1=num_j;
1978num_j2=num_j;
1979num_i_out=num_i;
1980num_j_out=num_j;
1981if isequal (NomType,'_i1-i2_j') |isequal (NomType,'_i1-i2')
1982    num_i1_line=num_i+ind_shift(3);% set of first image numbers
1983    num_i2_line=num_i+ind_shift(4);
1984    % adjust the first and last field number
1985        indsel=find(num_i1_line >= 1);
1986    num_i_out=num_i(indsel);
1987    num_i1_line=num_i1_line(indsel);
1988    num_i2_line=num_i2_line(indsel);
1989    num_j1=meshgrid(num_j,ones(size(num_i1_line)));
1990    num_j2=meshgrid(num_j,ones(size(num_i1_line)));
1991    [xx,num_i1]=meshgrid(num_j,num_i1_line);
1992    [xx,num_i2]=meshgrid(num_j,num_i2_line);
1993elseif isequal (NomType,'_i_j1-j2') || isequal (NomType,'#_ab')
1994    if isequal(mode,'bursts') %case of bursts (png_old or png_2D)
1995        num_j1=ind_shift(1)*ones(size(num_i));
1996        num_j2=ind_shift(2)*ones(size(num_i));
1997    else
1998        num_j1_col=num_j+ind_shift(1);% set of first image numbers
1999        num_j2_col=num_j+ind_shift(2);
2000        % adjust the first field number
2001        indsel=find((num_j1_col >= 1));   
2002        num_j_out=num_j(indsel);
2003        num_j1_col=num_j1_col(indsel);
2004        num_j2_col=num_j2_col(indsel);
2005        [num_i1,num_j1]=meshgrid(num_i,num_j1_col);
2006        [num_i2,num_j2]=meshgrid(num_i,num_j2_col);
2007    end   
2008end
2009
2010 
2011%-----------------------------------------------------------
2012% find the times corresponding to the first and last indices of a series
2013%
2014function displ_time(handles,times)
2015hseries=get(handles.last_i,'parent');
2016SeriesData=get(hseries,'UserData');%
2017first_i=str2num(get(handles.first_i,'String'));
2018first_j=str2num(get(handles.first_j,'String'));
2019last_i=str2num(get(handles.last_i,'String'));
2020last_j=str2num(get(handles.last_j,'String'));
2021% index_civ=get(handles.list_pair_civ,'Value');
2022% NomType=get(handles.NomType,'String');
2023NomType=SeriesData.NomType;
2024mode_list=get(handles.mode,'String');
2025index_mode=get(handles.mode,'Value');
2026mode=mode_list{index_mode};
2027% ind_shift=0;%default
2028
2029time_first=[];
2030time_last=[];
2031if ~isfield(SeriesData,'Time')
2032    SeriesData.Time{1}=[];
2033end
2034for iview=1:length(NomType)
2035    time_first_cell{iview}='?';
2036    time_last_cell{iview}='?';%default
2037    time=SeriesData.Time{iview};
2038    if isequal(NomType{iview},'_i1-i2_j')|isequal(NomType{iview},'_i_j1-j2')|isequal(NomType{iview},'#_ab')|isequal(NomType{iview},'_i1-i2')
2039        if isfield(SeriesData,'displ_num')& ~isempty(SeriesData.displ_num)
2040            ind_shift=SeriesData.displ_num(iview,:);
2041            if isequal(mode,'bursts')
2042                first_j=0;
2043                last_j=0;
2044            end
2045            first_i1=first_i +ind_shift(3);
2046            first_i2 =first_i +ind_shift(4);
2047            first_j1 =first_j +ind_shift(1);
2048            first_j2 =first_j +ind_shift(2);
2049            last_i1=last_i +ind_shift(3);
2050            last_i2 =last_i +ind_shift(4);   
2051            last_j1 =last_j +ind_shift(1);
2052            last_j2 =last_j +ind_shift(2);
2053            siz=size(SeriesData.Time{1});
2054            if first_i1>=1 && first_j1>=1 && siz(1)>=last_i2 && siz(2)>=last_j2
2055                time_first=(time(first_i1,first_j1)+time(first_i2,first_j2))/2;
2056                time_last=(time(last_i1,last_j1)+time(last_i2,last_j2))/2;
2057            else%read the time in the nc files
2058                RootPath=get(handles.RootPath,'String');
2059                RootFile=get(handles.RootFile,'String');
2060                SubDir=get(handles.SubDir,'String');
2061                %VelType=get(handles.VelType,'String');
2062                VelType_str=get(handles.VelTypeMenu,'String');
2063                VelType_val=get(handles.VelTypeMenu,'Value');
2064                VelType=VelType_str{VelType_val};
2065                filebase=fullfile(RootPath{1},RootFile{1});
2066                [filefirst]=name_generator(filebase,first_i1,first_j1,'.nc',NomType{iview},1,first_i2,first_j2,SubDir{iview});
2067                if  exist(filefirst,'file')
2068                    Attrib=nc2struct(filefirst,[]);
2069                    if isfield(Attrib,'Time')
2070                        time_first=Attrib.Time;
2071                    else
2072                        if isfield(Attrib,'absolut_time_T0')
2073                            time_first=Attrib.absolut_time_T0;
2074                        end
2075                        if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1'))
2076                            time_first=Attrib.absolut_time_T0_2;
2077                        end
2078                    end
2079                end
2080                [filelast]=name_generator(filebase,last_i1,last_j1,'.nc',NomType{iview},1,last_i2,last_j2,SubDir{iview});
2081                if exist(filelast,'file')
2082                   Attrib=nc2struct(filelast,[]);
2083                    if isfield(Attrib,'Time')
2084                        time_last=Attrib.Time;
2085                    else
2086                        if isfield(Attrib,'absolut_time_T0')
2087                            time_last=Attrib.absolut_time_T0;
2088                        end
2089                        if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1'))
2090                            time_last=Attrib.absolut_time_T0_2;
2091                        end
2092                    end
2093                end
2094            end
2095        end
2096    else
2097        siz=size(times);
2098        if siz(1)>=last_i & siz(2)>=last_j
2099            time_first=times(first_i,first_j);
2100            time_last=times(last_i,last_j);
2101        end
2102    end
2103    time_first_cell{iview}=num2str(time_first,4);
2104    time_last_cell{iview}=num2str(time_last,4);
2105end
2106set(handles.time_first,'Value',1)
2107set(handles.time_last,'Value',1)
2108set(handles.time_first,'String',time_first_cell);
2109set(handles.time_last,'String',time_last_cell);
2110
2111%--------------------------------------------------------------------
2112% --- Executes on selection change in VelTypeMenu.
2113function VelTypeMenu_Callback(hObject, eventdata, handles)
2114% VelTypeList=get(handles.VelTypeMenu,'String');
2115% VelTypeIndex=get(handles.VelTypeMenu,'Value');
2116% VelTypeCell=get(handles.VelType,'String');
2117% VelTypeCell{1}=VelTypeList{VelTypeIndex};
2118% set(handles.VelType,'String',VelTypeCell)
2119
2120
2121%--------------------------------------------------------------------
2122% --- Executes on button press in GetObject.
2123function GetObject_Callback(hObject, eventdata, handles)
2124hseries=get(handles.GetObject,'parent');
2125SeriesData=get(hseries,'UserData');
2126value=get(handles.GetObject,'Value');
2127if value
2128     set(handles.GetObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow
2129     DataInit.ParentButton=handles.GetObject;
2130     hset_object=findobj(allchild(0),'Name','set_object');%find the set_object interface handle
2131     if ishandle(hset_object)
2132         [SeriesData.hset_object,SeriesData.sethandles]=set_object(DataInit); %open the set_object interface
2133     else
2134         DataInit.TITLE='POINTS';%default option
2135         [SeriesData.hset_object,SeriesData.sethandles]=set_object(DataInit); %open the set_object interface
2136     end
2137else
2138    set(handles.GetObject,'BackgroundColor',[0 1 0])%put activated buttons to green
2139    if isfield(SeriesData,'hset_object')&& ishandle(SeriesData.hset_object)
2140        close(SeriesData.hset_object)
2141    end
2142end
2143set(hseries,'UserData',SeriesData)
2144
2145%--------------------------------------------------------------
2146function GetMask_Callback(hObject, eventdata, handles)
2147value=get(handles.GetMask,'Value');
2148if value
2149    errordlg('not implemented yet')
2150end
2151%--------------------------------------------------------------
2152
2153%--------------------------------------------------------------------------
2154%'uv_ncbrowser': interactively calls the netcdf file browser 'get_field.m'
2155function ncbrowser_uvmat(hObject, eventdata)
2156     bla=get(gcbo,'String');
2157     ind=get(gcbo,'Value');
2158     filename=cell2mat(bla(ind));
2159      blank=find(filename==' ');
2160      filename=filename(1:blank-1);
2161     get_field(filename)
2162
2163% --------------------------------------------------------------------
2164function MenuHelp_Callback(hObject, eventdata, handles)
2165
2166path_to_uvmat=which ('uvmat');% check the path of uvmat
2167pathelp=fileparts(path_to_uvmat);
2168helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
2169if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
2170else
2171    addpath (fullfile(pathelp,'uvmat_doc'))
2172    web([helpfile '#series'])
2173end
2174
2175
2176
2177
2178
2179
Note: See TracBrowser for help on using the repository browser.