source: trunk/src/series.m @ 32

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

-subfunction find_file_indices put back in series (it had been extracted by mistake to check_files
-aver_stat: name of output file rationalized
-read_get_field : pb with vector fields, yet to solve

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