source: trunk/src/series.m @ 376

Last change on this file since 376 was 376, checked in by sommeria, 12 years ago

introduce get_file_type to get easily the type of file (image, multimage, civdata...)
a few bugs corrected in series

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