1 | %'uvmat': function associated with the GUI 'uvmat.fig' for images and data field visualization |
---|
2 | %------------------------------------------------------------------------ |
---|
3 | % function huvmat=uvmat(input) |
---|
4 | % |
---|
5 | %OUTPUT |
---|
6 | % huvmat=current handles of the GUI uvmat.fig |
---|
7 | %% |
---|
8 | % |
---|
9 | %INPUT: |
---|
10 | % input: input file name (if character chain), or input image matrix to |
---|
11 | % visualize, or Matlab structure representing netcdf fieldname (with fieldname |
---|
12 | % ListVarName....) |
---|
13 | % |
---|
14 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
15 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr. |
---|
16 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
17 | % This open is part of the toolbox UVMAT. |
---|
18 | % |
---|
19 | % UVMAT is free software; you can redistribute it and/or modify |
---|
20 | % it under the terms of the GNU General Public License as published by |
---|
21 | % the Free Software Foundation; either version 2 of the License, or |
---|
22 | % (at your option) any later version. |
---|
23 | % |
---|
24 | % UVMAT is distributed in the hope that it will be useful, |
---|
25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
27 | % GNU General Public License (open UVMAT/COPYING.txt) for more details. |
---|
28 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
29 | % |
---|
30 | % Information stored on the interface:(use 'Export/field in workspace' in |
---|
31 | % the menu bar of uvmat to retrieve it) |
---|
32 | % .OpenParam: structure containing parameters defined when uvmat is opened |
---|
33 | % .PosColorbar: position (1x4 vector)of the colorbar (relative to the fig uvmat) |
---|
34 | % .PosSetObject: position of set_object |
---|
35 | % .PosGeometryCalib: size of set_object |
---|
36 | % .NbBuiltin: nbre of functions always displayed in transform_fct menu |
---|
37 | % .Object: cell array of structures representing the current projection objects, as produced by 'set_object.m'={[]} by default |
---|
38 | % .NewSeries: =0/1 flag telling whether a new field series has been opened |
---|
39 | % .FileName_1: name of the current second field (used to detect a constant field during file scanning) |
---|
40 | % .FileType: current file type, as defined by the fct get_file_type.m) |
---|
41 | % .i1_series,.i2_series,.j1_series,.j1_series: series of i1,i2,j1,j2 indices detected in the input dir,set by the fct find_file_series |
---|
42 | % .MovieObject: current movie object |
---|
43 | % .TimeUnit: unit for time |
---|
44 | % .XmlData: cell array of 1 or 2 structures representing the xml files associated with the input fieldname (containing timing and geometry calibration) |
---|
45 | % .Field: cell array of 1 or 2 structures representing the current input field(s) |
---|
46 | % .PlotAxes: field structure representing the current field plotted on the main axes (used for mouse operations) |
---|
47 | % .HistoAxes: idem for histogram axes |
---|
48 | |
---|
49 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%: |
---|
50 | % |
---|
51 | % |
---|
52 | % 1) Input filenames are determined by MenuBrowse (first field), MenuBrowse_1 |
---|
53 | % (second field), or by the stored file name .FileName_1, or as an input of uvmat. |
---|
54 | % 2) These functions call 'uvmat/display_file_name.m' which detects the file series, and fills the file index boxes |
---|
55 | % 3) Then 'uvmat/update_rootinfo.m' Updates information about a new field series (indices to scan, timing, calibration from an xml file) |
---|
56 | % 4) Then fieldname are opened and visualised by the main sub-function 'uvmat/refresh_field.m' |
---|
57 | % The function first reads the name of the input file(s) (one or two) from the edit boxes of the GUI |
---|
58 | % It then reads the input file(s) with the function read_field.m and perform the following list of operations: |
---|
59 | % |
---|
60 | % %%%%%%%% structure of uvmat/refresh_field.m %%%%%%%% |
---|
61 | % |
---|
62 | % Main input open second input open_1 |
---|
63 | % | | |
---|
64 | % read_field.m read_field.m |
---|
65 | % | | |
---|
66 | % Field{1} Field{2} |
---|
67 | % | | |
---|
68 | % --->transform fct<--- transform (e.g. phys.m) and combine input fieldname |
---|
69 | % | |
---|
70 | % (calc_tps.m) calculate tps coefficients (for filter projection or spatial derivatives). |
---|
71 | % | |
---|
72 | % UvData.Field-------------->histogram |
---|
73 | % _____________|____________ |
---|
74 | % | | |
---|
75 | % proj_field.m proj_field.m project the field on the projection objects (use calc_field.m) |
---|
76 | % | | |
---|
77 | % UvData.PlotAxes ViewData.PlotAxes (on view_field) |
---|
78 | % | | |
---|
79 | % plot_field.m (uvmat) plot_field.m (view_field) plot the projected fieldname |
---|
80 | % |
---|
81 | % |
---|
82 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%% |
---|
83 | % scalars are displayed either as an image or countour plot, either as a color of |
---|
84 | % velocity vectors. The scalar values in the first case is represented by |
---|
85 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X |
---|
86 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and |
---|
87 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar |
---|
88 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the |
---|
89 | % coordinates of the four image corners. The scalar name is represented by |
---|
90 | % the strings .AName and/or .CName. |
---|
91 | % If the scalar exists in an input open (image or scalar stored under its |
---|
92 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}. |
---|
93 | % Else only its name AName is recorded in Field{i}, and its field is then calculated |
---|
94 | %by the fuction calc_scal after the coordinate transform or after projection on an edit_object |
---|
95 | |
---|
96 | % Properties attached to plotting figures (standard Matlab properties): |
---|
97 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes'); |
---|
98 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned |
---|
99 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned |
---|
100 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure |
---|
101 | % 'KeyPressFcn': function called by pressing a key on the key board |
---|
102 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure |
---|
103 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure |
---|
104 | |
---|
105 | % Properties attached to plotting axes: |
---|
106 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates. |
---|
107 | % AxeData:=get(gca,'UserData'); |
---|
108 | % AxeData.Drawing = create: create a new object |
---|
109 | % = deform: modify an existing object by moving its defining create |
---|
110 | % = off: no current drawing action |
---|
111 | % = translate: translate an existing object |
---|
112 | % = calibration: move a calibration point |
---|
113 | % = CheckZoom: isolate a subregion for CheckZoom in=1 if an object is being currently drawn, 0 else (set to 0 by releasing mouse button) |
---|
114 | % .CurrentOrigin: Origin of a curently drawn edit_object |
---|
115 | % .CurrentLine: currently drawn menuline (A REVOIR) |
---|
116 | % .CurrentObject: handle of the currently drawn edit_object |
---|
117 | % .CurrentRectZoom: current rectangle used for CheckZoom |
---|
118 | |
---|
119 | % Properties attached to projection objects (create, menuline, menuplane...): |
---|
120 | % 'Tag'='proj_object': for all projection objects |
---|
121 | % ObjectData.Type=...: style of projection object: |
---|
122 | % .ProjMode |
---|
123 | % .Coord: defines the position of the object |
---|
124 | % .XMin,YMin.... |
---|
125 | % .XMax,YMax.... |
---|
126 | % .DX,DY,DZ |
---|
127 | % .Phi, .Theta, .Psi : Euler angles |
---|
128 | % .X,.Y,.U,.V.... : field data projected on the object |
---|
129 | % .IndexObj: index in the list of UvData.Object |
---|
130 | %during plotting |
---|
131 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object |
---|
132 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes |
---|
133 | % To each projection object #iobj, corresponds an axis |
---|
134 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the |
---|
135 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field; |
---|
136 | |
---|
137 | %------------------------------------------------------------------------ |
---|
138 | %------------------------------------------------------------------------ |
---|
139 | % I - MAIN FUNCTION uvmat |
---|
140 | %------------------------------------------------------------------------ |
---|
141 | %------------------------------------------------------------------------ |
---|
142 | function varargout = uvmat(varargin) |
---|
143 | |
---|
144 | % Begin initialization code - DO NOT EDIT |
---|
145 | gui_Singleton = 1; |
---|
146 | gui_State = struct('gui_Name', mfilename, ... |
---|
147 | 'gui_Singleton', gui_Singleton, ... |
---|
148 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ... |
---|
149 | 'gui_OutputFcn', @uvmat_OutputFcn, ... |
---|
150 | 'gui_LayoutFcn', [], ... |
---|
151 | 'gui_Callback', []); |
---|
152 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
153 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
154 | end |
---|
155 | |
---|
156 | if nargout |
---|
157 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:}); |
---|
158 | else |
---|
159 | gui_mainfcn(gui_State, varargin{:}); |
---|
160 | end |
---|
161 | % End initialization code - DO NOT EDIT |
---|
162 | |
---|
163 | %------------------------------------------------------------------------ |
---|
164 | % --- Executes just before the GUI uvmat is made visible. |
---|
165 | function uvmat_OpeningFcn(hObject, eventdata, handles, input ) |
---|
166 | %------------------------------------------------------------------------ |
---|
167 | |
---|
168 | %% Choose default command menuline output for uvmat (standard GUI) |
---|
169 | handles.output = hObject; |
---|
170 | |
---|
171 | %% Update handles structure (standard GUI) |
---|
172 | guidata(hObject, handles); |
---|
173 | |
---|
174 | %% add the path to uvmat (useful if uvmat has been opened in the working directory and a working directory change occured) |
---|
175 | path_uvmat=fileparts(which('uvmat')); |
---|
176 | |
---|
177 | %% set the position of colorbar and ancillary GUIs: |
---|
178 | set(hObject,'Units','Normalized') |
---|
179 | movegui(hObject,'center') |
---|
180 | UvData.OpenParam.PosColorbar=[0.805 0.022 0.019 0.445]; |
---|
181 | UvData.OpenParam.PosSetObject=[-0.05 -0.03 0.3 0.7]; %position for set_object |
---|
182 | UvData.OpenParam.PosGeometryCalib=[0.95 -0.03 0.28 1 ];%position for geometry_calib (TO IMPROVE) |
---|
183 | % UvData.OpenParam.CalSize=[0.28 1]; |
---|
184 | % UvData.PlotAxes=[];%initiate the record of plotted field |
---|
185 | % UvData.axes2=[]; |
---|
186 | % UvData.axes1=[]; |
---|
187 | AxeData.LimEditBox=1; %initialise AxeData |
---|
188 | set(handles.PlotAxes,'UserData',AxeData) |
---|
189 | |
---|
190 | %% set functions for the mouse and keyboard |
---|
191 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function |
---|
192 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio |
---|
193 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function |
---|
194 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles}) |
---|
195 | set(hObject,'DeleteFcn',{@closefcn})% |
---|
196 | |
---|
197 | %% initialisation |
---|
198 | % set(handles.ListObject,'Value',1)% default: empty projection objectproj_field |
---|
199 | % set(handles.ListObject,'String',{''}) |
---|
200 | % set(handles.ListObject_1,'Value',1)% default: empty projection objectproj_field |
---|
201 | % set(handles.ListObject_1,'String',{''}) |
---|
202 | set(handles.FieldName,'Value',1) |
---|
203 | set(handles.FieldName,'string',{''}) |
---|
204 | UvData.Object={[]}; |
---|
205 | |
---|
206 | %% TRANSFORM menu: builtin fcts |
---|
207 | transform_menu={'';'sub_field';'phys';'phys_polar'}; |
---|
208 | UvData.OpenParam.NbBuiltin=numel(transform_menu); %number of functions |
---|
209 | transform_path=fullfile(path_uvmat,'transform_field'); |
---|
210 | path_list=cell(UvData.OpenParam.NbBuiltin,1); |
---|
211 | path_list{1}=''; |
---|
212 | for ilist=2:UvData.OpenParam.NbBuiltin |
---|
213 | path_list{ilist}=transform_path; % set transform_path to the path_list |
---|
214 | end |
---|
215 | |
---|
216 | %% load the list of previously browsed files in menus Open, Open_1 and transform_fct |
---|
217 | dir_perso=prefdir; % path to the directory .matlab for personal data |
---|
218 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab |
---|
219 | if exist(profil_perso,'file') |
---|
220 | h=load (profil_perso); |
---|
221 | if isfield(h,'MenuFile')% load the menu of previously opened files |
---|
222 | for ifile=1:min(length(h.MenuFile),5) |
---|
223 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
224 | eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});']) |
---|
225 | end |
---|
226 | end |
---|
227 | if isfield(h,'transform_fct') && iscell(h.transform_fct) % load the menu of transform fct set by user |
---|
228 | for ilist=1:length(h.transform_fct); |
---|
229 | if exist(h.transform_fct{ilist},'file') |
---|
230 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
231 | transform_menu=[transform_menu; {file}]; |
---|
232 | path_list=[path_list; {path}]; |
---|
233 | end |
---|
234 | end |
---|
235 | end |
---|
236 | end |
---|
237 | transform_menu=[transform_menu;{'more...'}];%append the option more.. to the menu |
---|
238 | set(handles.transform_fct,'String',transform_menu)% display the menu of transform fcts |
---|
239 | set(handles.transform_fct,'UserData',path_list)% store the corresponding list of path in UserData of uicontrol transform_fct |
---|
240 | set(handles.path_transform,'String','') |
---|
241 | set(handles.path_transform,'UserData',[]) |
---|
242 | |
---|
243 | %% case of an input argument for uvmat |
---|
244 | testinputfield=0; |
---|
245 | inputfile=[]; |
---|
246 | Field=[]; |
---|
247 | if exist('input','var') |
---|
248 | if ishandle(handles.UVMAT_title) |
---|
249 | delete(handles.UVMAT_title) |
---|
250 | end |
---|
251 | if isstruct(input) |
---|
252 | if isfield(input,'InputFile') |
---|
253 | inputfile=input.InputFile; |
---|
254 | end |
---|
255 | if isfield(input,'TimeIndex') |
---|
256 | set(handles.i1,num2str(input.TimeIndex)) |
---|
257 | end |
---|
258 | if isfield(input,'FieldsString') |
---|
259 | UvData.FieldsString=input.FieldsString; |
---|
260 | end |
---|
261 | elseif ischar(input)% file name introduced as input |
---|
262 | inputfile=input; |
---|
263 | elseif isnumeric(input)%simple matrix introduced as input |
---|
264 | sizinput=size(input); |
---|
265 | if sizinput(1)<=1 || sizinput(2)<=1 |
---|
266 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted') |
---|
267 | return |
---|
268 | end |
---|
269 | UvData.Field.ListVarName={'A','coord_y','coord_x'}; |
---|
270 | UvData.Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'}; |
---|
271 | UvData.Field.A=input; |
---|
272 | UvData.Field.coord_x=[0.5 size(input,2)-0.5]; |
---|
273 | UvData.Field.coord_y=[size(input,1)-0.5 0.5]; |
---|
274 | testinputfield=1; |
---|
275 | end |
---|
276 | else |
---|
277 | %% check the path and date of modification of all functions in uvmat |
---|
278 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat |
---|
279 | [infomsg,date_str,svn_info]=check_files;%check the path of the functions called by uvmat.m |
---|
280 | date_str=['last modification: ' date_str]; |
---|
281 | if ishandle(handles.UVMAT_title) |
---|
282 | set(handles.UVMAT_title,'String',... |
---|
283 | [{'Copyright LEGI UMR 5519 /CNRS-UJF-Grenoble INP, 2010'};... |
---|
284 | {'GNU General Public License'};... |
---|
285 | {path_to_uvmat};... |
---|
286 | {date_str};... |
---|
287 | infomsg]); |
---|
288 | end |
---|
289 | end |
---|
290 | set(handles.uvmat,'UserData',UvData) |
---|
291 | if ~isempty(inputfile) |
---|
292 | %%%%% display the input field %%%%%%% |
---|
293 | display_file_name(handles,inputfile) |
---|
294 | %%%%%%% |
---|
295 | testinputfield=1; |
---|
296 | end |
---|
297 | |
---|
298 | set_vec_col_bar(handles) %update the display of color code for vectors |
---|
299 | |
---|
300 | %------------------------------------------------------------------------ |
---|
301 | % --- Outputs from this function are returned to the command menuline. |
---|
302 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles) |
---|
303 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure |
---|
304 | |
---|
305 | %------------------------------------------------------------------------ |
---|
306 | % --- executed when closing uvmat: delete or desactivate the associated figures if exist |
---|
307 | function closefcn(gcbo,eventdata) |
---|
308 | %------------------------------------------------------------------------ |
---|
309 | hh=findobj(allchild(0),'tag','view_field'); |
---|
310 | if ~isempty(hh) |
---|
311 | delete(hh) |
---|
312 | end |
---|
313 | hh=findobj(allchild(0),'tag','geometry_calib'); |
---|
314 | if ~isempty(hh) |
---|
315 | delete(hh) |
---|
316 | end |
---|
317 | hh=findobj(allchild(0),'tag','set_object'); |
---|
318 | if ~isempty(hh) |
---|
319 | hhh=findobj(hh,'tag','PLOT'); |
---|
320 | set(hhh,'enable','off') |
---|
321 | end |
---|
322 | |
---|
323 | %------------------------------------------------------------------------ |
---|
324 | %------------------------------------------------------------------------ |
---|
325 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES |
---|
326 | % automatically sets the global properties when the rootfile name is introduced |
---|
327 | % then activate the view-field action if selected |
---|
328 | % it is activated either by clicking on the RootPath window or by the |
---|
329 | % browser |
---|
330 | %------------------------------------------------------------------------ |
---|
331 | %------------------------------------------------------------------------ |
---|
332 | % --- Executes on the menu Open/Browse... |
---|
333 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
334 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
335 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
336 | %oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
337 | oldfile=fullfile(RootPath,SubDir); |
---|
338 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box |
---|
339 | dir_perso=prefdir; |
---|
340 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
341 | if exist(profil_perso,'file') |
---|
342 | h=load (profil_perso); |
---|
343 | if isfield(h,'MenuFile_1') |
---|
344 | oldfile=h.MenuFile_1; |
---|
345 | end |
---|
346 | end |
---|
347 | end |
---|
348 | [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',oldfile); |
---|
349 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
350 | fileinput=[PathName FileName];%complete file name |
---|
351 | |
---|
352 | %% display the selected field and related information |
---|
353 | display_file_name( handles,fileinput) |
---|
354 | |
---|
355 | % ----------------------------------------------------------------------- |
---|
356 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
357 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
358 | %------------------------------------------------------------------------ |
---|
359 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
360 | display_file_name( handles,fileinput) |
---|
361 | |
---|
362 | % ----------------------------------------------------------------------- |
---|
363 | % --- Open again the file whose name has been recorded in MenuFile_2 |
---|
364 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
365 | %------------------------------------------------------------------------ |
---|
366 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
367 | display_file_name(handles,fileinput) |
---|
368 | |
---|
369 | % ----------------------------------------------------------------------- |
---|
370 | % --- Open again the file whose name has been recorded in MenuFile_3 |
---|
371 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
372 | %------------------------------------------------------------------------ |
---|
373 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
374 | display_file_name(handles,fileinput) |
---|
375 | |
---|
376 | % ----------------------------------------------------------------------- |
---|
377 | % --- Open again the file whose name has been recorded in MenuFile_4 |
---|
378 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
379 | %------------------------------------------------------------------------ |
---|
380 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
381 | display_file_name(handles,fileinput) |
---|
382 | |
---|
383 | % ----------------------------------------------------------------------- |
---|
384 | % --- Open again the file whose name has been recorded in MenuFile_5 |
---|
385 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
386 | %------------------------------------------------------------------------ |
---|
387 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
388 | display_file_name(handles,fileinput) |
---|
389 | |
---|
390 | %------------------------------------------------------------------------ |
---|
391 | % --- Executes on the menu Open/Browse_1 for the second input field, |
---|
392 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
393 | function MenuBrowse_1_Callback(hObject, eventdata, handles) |
---|
394 | %------------------------------------------------------------------------ |
---|
395 | RootPath=get(handles.RootPath,'String'); |
---|
396 | [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',RootPath); |
---|
397 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
398 | fileinput_1=[PathName FileName];%complete file name |
---|
399 | |
---|
400 | % refresh the current displayed field |
---|
401 | set(handles.SubField,'Value',1) |
---|
402 | display_file_name(handles,fileinput_1,2) |
---|
403 | |
---|
404 | %update list of recent files in the menubar |
---|
405 | MenuFile_1=fileinput_1; |
---|
406 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
407 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
408 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
409 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
410 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
411 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
412 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
413 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
414 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
415 | set(handles.MenuFile_1_1,'Label',MenuFile_1) |
---|
416 | set(handles.MenuFile_2_1,'Label',MenuFile_2) |
---|
417 | set(handles.MenuFile_3_1,'Label',MenuFile_3) |
---|
418 | set(handles.MenuFile_4_1,'Label',MenuFile_4) |
---|
419 | set(handles.MenuFile_5_1,'Label',MenuFile_5) |
---|
420 | dir_perso=prefdir; |
---|
421 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
422 | if exist(profil_perso,'file') |
---|
423 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
424 | else |
---|
425 | txt=ver('MATLAB'); |
---|
426 | Release=txt.Release; |
---|
427 | relnumb=str2double(Release(3:4)); |
---|
428 | if relnumb >= 14 |
---|
429 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
430 | else |
---|
431 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
432 | end |
---|
433 | end |
---|
434 | |
---|
435 | % ----------------------------------------------------------------------- |
---|
436 | % --- Open again as second field the file whose name has been recorded in MenuFile_1 |
---|
437 | function MenuFile_1_1_Callback(hObject, eventdata, handles) |
---|
438 | % ----------------------------------------------------------------------- |
---|
439 | fileinput_1=get(handles.MenuFile_1_1,'Label'); |
---|
440 | set(handles.SubField,'Value',1) |
---|
441 | display_file_name(handles,fileinput_1,2) |
---|
442 | |
---|
443 | % ----------------------------------------------------------------------- |
---|
444 | % --- Open again as second field the file whose name has been recorded in MenuFile_2 |
---|
445 | function MenuFile_2_1_Callback(hObject, eventdata, handles) |
---|
446 | % ----------------------------------------------------------------------- |
---|
447 | fileinput_1=get(handles.MenuFile_2_1,'Label'); |
---|
448 | set(handles.SubField,'Value',1) |
---|
449 | display_file_name(handles,fileinput_1,2) |
---|
450 | |
---|
451 | % ----------------------------------------------------------------------- |
---|
452 | % --- Open again as second field the file whose name has been recorded in MenuFile_3 |
---|
453 | function MenuFile_3_1_Callback(hObject, eventdata, handles) |
---|
454 | % ----------------------------------------------------------------------- |
---|
455 | fileinput_1=get(handles.MenuFile_3_1,'Label'); |
---|
456 | set(handles.SubField,'Value',1) |
---|
457 | display_file_name(handles,fileinput_1,2) |
---|
458 | |
---|
459 | % ----------------------------------------------------------------------- |
---|
460 | % --- Open again as second field the file whose name has been recorded in MenuFile_4 |
---|
461 | function MenuFile_4_1_Callback(hObject, eventdata, handles) |
---|
462 | % ----------------------------------------------------------------------- |
---|
463 | fileinput_1=get(handles.MenuFile_4_1,'Label'); |
---|
464 | set(handles.SubField,'Value',1) |
---|
465 | display_file_name(handles,fileinput_1,2) |
---|
466 | |
---|
467 | % ----------------------------------------------------------------------- |
---|
468 | % --- Open again as second field the file whose name has been recorded in MenuFile_5 |
---|
469 | function MenuFile_5_1_Callback(hObject, eventdata, handles) |
---|
470 | % ----------------------------------------------------------------------- |
---|
471 | fileinput_1=get(handles.MenuFile_5_1,'Label'); |
---|
472 | set(handles.SubField,'Value',1) |
---|
473 | display_file_name(handles,fileinput_1,2) |
---|
474 | |
---|
475 | %------------------------------------------------------------------------ |
---|
476 | % --- Called by action in RootPath edit box |
---|
477 | function RootPath_Callback(hObject,eventdata,handles) |
---|
478 | %------------------------------------------------------------------------ |
---|
479 | % read the current input file name: |
---|
480 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
481 | if ~exist(fullfile(RootPath,SubDir),'dir') |
---|
482 | msgbox_uvmat('ERROR',['directory ' fullfile(RootPath,SubDir) ' does not exist']) |
---|
483 | return |
---|
484 | end |
---|
485 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
486 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
487 | % initiate the input file series and refresh the current field view: |
---|
488 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,1); |
---|
489 | |
---|
490 | %----------------------------------------------------------------------- |
---|
491 | % --- Called by action in RootPath_1 edit box |
---|
492 | function RootPath_1_Callback(hObject,eventdata,handles) |
---|
493 | % ----------------------------------------------------------------------- |
---|
494 | % update_rootinfo_1(hObject,eventdata,handles) |
---|
495 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
496 | if ~exist(fullfile(RootPath,SubDir),'dir') |
---|
497 | msgbox_uvmat('ERROR',['directory ' fullfile(RootPath,SubDir) ' does not exist']) |
---|
498 | return |
---|
499 | end |
---|
500 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
501 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
502 | % initiate the input file series and refresh the current field view: |
---|
503 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2); |
---|
504 | |
---|
505 | %------------------------------------------------------------------------ |
---|
506 | % --- Called by action in RootFile edit box |
---|
507 | function SubDir_Callback(hObject, eventdata, handles) |
---|
508 | %------------------------------------------------------------------------ |
---|
509 | %refresh the menu of input fieldname |
---|
510 | Fields_Callback(hObject, eventdata, handles); |
---|
511 | % refresh the current field view |
---|
512 | run0_Callback(hObject, eventdata, handles); |
---|
513 | |
---|
514 | %------------------------------------------------------------------------ |
---|
515 | % --- Called by action in RootFile edit box |
---|
516 | function RootFile_Callback(hObject, eventdata, handles) |
---|
517 | %------------------------------------------------------------------------ |
---|
518 | RootPath_Callback(hObject,eventdata,handles) |
---|
519 | |
---|
520 | %----------------------------------------------------------------------- |
---|
521 | % --- Called by action in RootFile_1 edit box |
---|
522 | function RootFile_1_Callback(hObject, eventdata, handles) |
---|
523 | % ----------------------------------------------------------------------- |
---|
524 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
525 | |
---|
526 | %------------------------------------------------------------------------ |
---|
527 | % --- Called by action in FileIndex edit box |
---|
528 | function FileIndex_Callback(hObject, eventdata, handles) |
---|
529 | %------------------------------------------------------------------------ |
---|
530 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
531 | set(handles.i1,'String',num2str(i1)); |
---|
532 | set(handles.i2,'String',num2str(i2)); |
---|
533 | set(handles.j1,'String',num2str(j1)); |
---|
534 | set(handles.j2,'String',num2str(j2)); |
---|
535 | |
---|
536 | % refresh the current field view |
---|
537 | run0_Callback(hObject, eventdata, handles) |
---|
538 | |
---|
539 | %------------------------------------------------------------------------ |
---|
540 | % --- Called by action in FileIndex_1 edit box |
---|
541 | function FileIndex_1_Callback(hObject, eventdata, handles) |
---|
542 | %------------------------------------------------------------------------ |
---|
543 | run0_Callback(hObject, eventdata, handles) |
---|
544 | |
---|
545 | %------------------------------------------------------------------------ |
---|
546 | % --- Called by action in NomType edit box |
---|
547 | function NomType_Callback(hObject, eventdata, handles) |
---|
548 | %------------------------------------------------------------------------ |
---|
549 | i1=str2num(get(handles.i1,'String')); |
---|
550 | i2=str2num(get(handles.i2,'String')); |
---|
551 | j1=str2num(get(handles.j1,'String')); |
---|
552 | j2=str2num(get(handles.j2,'String')); |
---|
553 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2); |
---|
554 | set(handles.FileIndex,'String',FileIndex) |
---|
555 | % refresh the current settings and refresh the field view |
---|
556 | RootPath_Callback(hObject,eventdata,handles) |
---|
557 | |
---|
558 | %------------------------------------------------------------------------ |
---|
559 | % --- Called by action in NomType edit box |
---|
560 | function NomType_1_Callback(hObject, eventdata, handles) |
---|
561 | %------------------------------------------------------------------------ |
---|
562 | i1=str2num(get(handles.i1,'String')); |
---|
563 | i2=str2num(get(handles.i2,'String')); |
---|
564 | j1=str2num(get(handles.j1,'String')); |
---|
565 | j2=str2num(get(handles.j2,'String')); |
---|
566 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType_1,'String'),i1,i2,j1,j2); |
---|
567 | set(handles.FileIndex_1,'String',FileIndex) |
---|
568 | % refresh the current settings and refresh the field view |
---|
569 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
570 | |
---|
571 | %------------------------------------------------------------------------ |
---|
572 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput' |
---|
573 | function display_file_name(handles,fileinput,index) |
---|
574 | %------------------------------------------------------------------------ |
---|
575 | %% look for the input file existence |
---|
576 | if ~exist(fileinput,'file') |
---|
577 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
578 | return |
---|
579 | end |
---|
580 | |
---|
581 | %% set the mouse pointer to 'watch' |
---|
582 | set(handles.uvmat,'Pointer','watch') |
---|
583 | set(handles.RootPath,'BackgroundColor',[1 1 0]) |
---|
584 | drawnow |
---|
585 | |
---|
586 | %% define the relevant handles for the first field series (index=1) or the second file series (index=2) |
---|
587 | if ~exist('index','var') |
---|
588 | index=1; |
---|
589 | end |
---|
590 | if index==1 |
---|
591 | handles_RootPath=handles.RootPath; |
---|
592 | handles_SubDir=handles.SubDir; |
---|
593 | handles_RootFile=handles.RootFile; |
---|
594 | handles_FileIndex=handles.FileIndex; |
---|
595 | handles_NomType=handles.NomType; |
---|
596 | handles_FileExt=handles.FileExt; |
---|
597 | elseif index==2 |
---|
598 | handles_RootPath=handles.RootPath_1; |
---|
599 | handles_SubDir=handles.SubDir_1; |
---|
600 | handles_RootFile=handles.RootFile_1; |
---|
601 | handles_FileIndex=handles.FileIndex_1; |
---|
602 | handles_NomType=handles.NomType_1; |
---|
603 | handles_FileExt=handles.FileExt_1; |
---|
604 | set(handles.RootPath_1,'Visible','on') |
---|
605 | set(handles.RootFile_1,'Visible','on') |
---|
606 | set(handles.SubDir_1,'Visible','on'); |
---|
607 | set(handles.FileIndex_1,'Visible','on'); |
---|
608 | set(handles.FileExt_1,'Visible','on'); |
---|
609 | set(handles.NomType_1,'Visible','on'); |
---|
610 | end |
---|
611 | |
---|
612 | %% detect root name, nomenclature and indices in the input file name: |
---|
613 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
614 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
615 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
616 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
617 | |
---|
618 | %% open the file or fill the GUI uvmat according to the detected file type |
---|
619 | switch FileType |
---|
620 | case '' |
---|
621 | msgbox_uvmat('ERROR','invalid input file type') |
---|
622 | case 'txt' |
---|
623 | edit(fileinput) |
---|
624 | case 'figure' %display matlab figure |
---|
625 | hfig=open(fileinput); |
---|
626 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio |
---|
627 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function |
---|
628 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function |
---|
629 | case 'xml' % edit xml files |
---|
630 | t=xmltree(fileinput); |
---|
631 | % the xml file marks a project or project link, open datatree_browser |
---|
632 | if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir') |
---|
633 | datatree_browser(fileinput) |
---|
634 | else % other xml file, open the xml editor |
---|
635 | editxml(fileinput); |
---|
636 | end |
---|
637 | case 'xls'% Excel file opended by editxml |
---|
638 | editxml(fileinput); |
---|
639 | otherwise |
---|
640 | set(handles_RootPath,'String',RootPath); |
---|
641 | rootname=fullfile(RootPath,SubDir,RootFile); |
---|
642 | set(handles_SubDir,'String',['/' SubDir]); |
---|
643 | set(handles_RootFile,'String',['/' RootFile]); %display the separator |
---|
644 | indices=fileinput(length(rootname)+1:end); |
---|
645 | indices(end-length(FileExt)+1:end)=[]; %remove extension |
---|
646 | set(handles_FileIndex,'String',indices); |
---|
647 | set(handles_NomType,'String',NomType); |
---|
648 | set(handles_FileExt,'String',FileExt); |
---|
649 | if index==1 |
---|
650 | % fill file index counters if the first file series is opened |
---|
651 | set(handles.i1,'String',num2str(i1)); |
---|
652 | set(handles.i2,'String',num2str(i2)); |
---|
653 | set(handles.j1,'String',num2stra(j1,NomType)); |
---|
654 | set(handles.j2,'String',num2stra(j2,NomType)); |
---|
655 | else %read the current field index to synchronise with the first series |
---|
656 | i1_s=str2num(get(handles.i1,'String')); |
---|
657 | i2_0=str2num(get(handles.i2,'String')); |
---|
658 | if ~isempty(i2_0) |
---|
659 | i2_s=i2_0; |
---|
660 | else |
---|
661 | i2_s=i2; |
---|
662 | end |
---|
663 | j1_0=stra2num(get(handles.j1,'String')); |
---|
664 | if ~isempty(j1_0) |
---|
665 | j1_s=j1_0; |
---|
666 | else |
---|
667 | j1_s=j1; |
---|
668 | end |
---|
669 | j2_0=stra2num(get(handles.j2,'String')); |
---|
670 | if ~isempty(j2_0) |
---|
671 | j2_s=j2_0; |
---|
672 | else |
---|
673 | j2_s=j2; |
---|
674 | end |
---|
675 | end |
---|
676 | |
---|
677 | % synchronise indices of the second input file if it exists |
---|
678 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers |
---|
679 | Input=read_GUI(handles.InputFile); |
---|
680 | if ~isfield(Input,'RootPath_1')||strcmp(Input.RootPath_1,'"') |
---|
681 | Input.RootPath_1=Input.RootPath; |
---|
682 | end |
---|
683 | if ~isfield(Input,'SubDir_1')||strcmp(Input.SubDir_1,'"') |
---|
684 | Input.SubDir_1=Input.SubDir; |
---|
685 | end |
---|
686 | if ~isfield(Input,'RootFile_1')||strcmp(Input.RootFile_1,'"') |
---|
687 | Input.RootFile_1=Input.RootFile; |
---|
688 | end |
---|
689 | if ~isfield(Input,'FileExt_1')||strcmp(Input.FileExt_1,'"') |
---|
690 | Input.FileExt_1=Input.FileExt; |
---|
691 | end |
---|
692 | if ~isfield(Input,'NomType_1')||strcmp(Input.NomType_1,'"') |
---|
693 | Input.NomType_1=Input.NomType; |
---|
694 | end |
---|
695 | %updtate the indices of the second field series to correspond to the newly opened one |
---|
696 | FileName_1=fullfile_uvmat(Input.RootPath_1,Input.SubDir_1,Input.RootFile_1,Input.FileExt_1,Input.NomType_1,i1_s,i2_s,j1_s,j2_s); |
---|
697 | if exist(FileName_1,'file') |
---|
698 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1_s,i2_s,j1_s,j2_s); |
---|
699 | else |
---|
700 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1,i2,j1,j2); |
---|
701 | msgbox_uvmat('WARNING','unable to synchronise the indices of the two series') |
---|
702 | end |
---|
703 | set(handles.FileIndex_1,'String',FileIndex_1) |
---|
704 | end |
---|
705 | |
---|
706 | %enable other menus |
---|
707 | set(handles.MenuOpen_1,'Enable','on') |
---|
708 | set(handles.MenuFile_1_1,'Enable','on') |
---|
709 | set(handles.MenuFile_2_1,'Enable','on') |
---|
710 | set(handles.MenuFile_3_1,'Enable','on') |
---|
711 | set(handles.MenuFile_4_1,'Enable','on') |
---|
712 | set(handles.MenuFile_5_1,'Enable','on') |
---|
713 | set(handles.MenuExport,'Enable','on') |
---|
714 | set(handles.MenuExportFigure,'Enable','on') |
---|
715 | set(handles.MenuExportMovie,'Enable','on') |
---|
716 | set(handles.MenuTools,'Enable','on') |
---|
717 | |
---|
718 | % initiate input file series and refresh the current field view: |
---|
719 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,index); |
---|
720 | |
---|
721 | end |
---|
722 | |
---|
723 | %% update list of recent files in the menubar and save it for future opening |
---|
724 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
725 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
726 | str_find=strcmp(fileinput,MenuFile); |
---|
727 | if isempty(find(str_find,1)) |
---|
728 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list |
---|
729 | end |
---|
730 | for ifile=1:min(length(MenuFile),5) |
---|
731 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
732 | eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',MenuFile{ifile});']) |
---|
733 | end |
---|
734 | dir_perso=prefdir; |
---|
735 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
736 | if exist(profil_perso,'file') |
---|
737 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
738 | else |
---|
739 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat |
---|
740 | end |
---|
741 | |
---|
742 | %% set back the mouse pointer to arrow |
---|
743 | set(handles.uvmat,'Pointer','arrow') |
---|
744 | |
---|
745 | |
---|
746 | %------------------------------------------------------------------------ |
---|
747 | % --- Update information about a new field series (indices to scan, timing, |
---|
748 | % calibration from an xml file, then refresh current plots |
---|
749 | |
---|
750 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,index) |
---|
751 | %------------------------------------------------------------------------ |
---|
752 | %% define the relevant handles depending on the index (1=first file series, 2= second file series) |
---|
753 | if ~exist('index','var') |
---|
754 | index=1; |
---|
755 | end |
---|
756 | if index==1 |
---|
757 | handles_RootPath=handles.RootPath; |
---|
758 | handles_Fields=handles.FieldName; |
---|
759 | elseif index==2 |
---|
760 | handles_RootPath=handles.RootPath_1; |
---|
761 | handles_Fields=handles.FieldName_1; |
---|
762 | end |
---|
763 | |
---|
764 | set(handles_RootPath,'BackgroundColor',[1 1 0]) |
---|
765 | drawnow |
---|
766 | set(handles.FieldName,'UserData',[])% reinialize data from uvmat opening |
---|
767 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface |
---|
768 | UvData.NewSeries=1; %flag for run0: begin a new series |
---|
769 | UvData.FileName_1='';% name of the current second field (used to detect a constant field during file scanning) |
---|
770 | UvData.FileType{index}=FileType; |
---|
771 | UvData.i1_series{index}=i1_series; |
---|
772 | UvData.i2_series{index}=i2_series; |
---|
773 | UvData.j1_series{index}=j1_series; |
---|
774 | UvData.j2_series{index}=j2_series; |
---|
775 | set(handles.FixVelType,'Value',0); %desactivate fixed veltype |
---|
776 | if index==1 |
---|
777 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
778 | else |
---|
779 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
780 | end |
---|
781 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
782 | FileBase=fullfile(RootPath,RootFile); |
---|
783 | if ~exist(FileName,'file') |
---|
784 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']); |
---|
785 | return |
---|
786 | end |
---|
787 | |
---|
788 | %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file |
---|
789 | XmlData.Time=[];%default |
---|
790 | XmlData.GeometryCalib=[];%default |
---|
791 | TimeUnit='';%default |
---|
792 | Time=[]; |
---|
793 | testima=0; %test for image input |
---|
794 | imainfo=[]; |
---|
795 | ColorType='falsecolor'; %default |
---|
796 | hhh=[]; |
---|
797 | UvData.MovieObject{index}=VideoObject; |
---|
798 | if ~isempty(VideoObject) |
---|
799 | imainfo=get(VideoObject); |
---|
800 | testima=1; |
---|
801 | TimeUnit='s'; |
---|
802 | if isempty(j1_series); %frame index along i |
---|
803 | Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)'; |
---|
804 | else |
---|
805 | Time=ones(size(i1_series,1),1)*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate); |
---|
806 | end |
---|
807 | %nbfield=imainfo.NumberOfFrames; |
---|
808 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
809 | ColorType='truecolor'; |
---|
810 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image |
---|
811 | testima=1; |
---|
812 | if ~isequal(SubDir,'') |
---|
813 | RootFile=get(handles.RootFile,'String'); |
---|
814 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]); |
---|
815 | else |
---|
816 | imainfo=imfinfo([FileBase FileIndices FileExt]); |
---|
817 | end |
---|
818 | ColorType=imainfo.ColorType;%='truecolor' for color images |
---|
819 | if length(imainfo) >1 %case of image with multiple frames |
---|
820 | % nbfield=length(imainfo); |
---|
821 | % nbfield_j=1; |
---|
822 | end |
---|
823 | end |
---|
824 | if isfield(imainfo,'Width') && isfield(imainfo,'Height') |
---|
825 | if length(imainfo)>1 |
---|
826 | set(handles.num_Npx,'String',num2str(imainfo(1).Width));%fills nbre of pixels x box |
---|
827 | set(handles.num_Npy,'String',num2str(imainfo(1).Height));%fills nbre of pixels x box |
---|
828 | else |
---|
829 | set(handles.num_Npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box |
---|
830 | set(handles.num_Npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box |
---|
831 | end |
---|
832 | else |
---|
833 | set(handles.num_Npx,'String','');%fills nbre of pixels x box |
---|
834 | set(handles.num_Npy,'String','');%fills nbre of pixels x box |
---|
835 | end |
---|
836 | set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image |
---|
837 | |
---|
838 | %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) |
---|
839 | XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt); |
---|
840 | [tild,tild,DocExt]=fileparts(XmlFileName); |
---|
841 | warntext='';%default warning message |
---|
842 | NbSlice=1;%default |
---|
843 | set(handles.RootPath,'BackgroundColor',[1 1 1]) |
---|
844 | if ~isempty(XmlFileName) |
---|
845 | set(handles.view_xml,'Visible','on') |
---|
846 | set(handles.view_xml,'BackgroundColor',[1 1 0]) |
---|
847 | set(handles.view_xml,'String','view .xml') |
---|
848 | drawnow |
---|
849 | [XmlDataRead,warntext]=imadoc2struct(XmlFileName); |
---|
850 | if ~isempty(warntext) |
---|
851 | msgbox_uvmat('WARNING',warntext) |
---|
852 | end |
---|
853 | if isempty(XmlDataRead) |
---|
854 | set(handles.view_xml,'Visible','off') |
---|
855 | else |
---|
856 | set(handles.view_xml,'String',['view ' DocExt]) |
---|
857 | XmlData=XmlDataRead; |
---|
858 | if isfield(XmlData,'TimeUnit') |
---|
859 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit) |
---|
860 | TimeUnit=XmlData.TimeUnit; |
---|
861 | end |
---|
862 | end |
---|
863 | set(handles.view_xml,'BackgroundColor',[1 1 1]) |
---|
864 | drawnow |
---|
865 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib) |
---|
866 | if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y') |
---|
867 | set (handles.num_NbSlice,'String','volume') |
---|
868 | end |
---|
869 | hgeometry_calib=findobj('tag','geometry_calib'); |
---|
870 | if ~isempty(hgeometry_calib) |
---|
871 | GUserData=get(hgeometry_calib,'UserData'); |
---|
872 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,XmlFileName)) |
---|
873 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?'); |
---|
874 | if strcmp(answer,'Yes') |
---|
875 | geometry_calib(XmlFileName);%diplay the new calibration points and parameters in geometry_calib |
---|
876 | end |
---|
877 | end |
---|
878 | end |
---|
879 | end |
---|
880 | end |
---|
881 | end |
---|
882 | if ~(isfield(XmlData,'Time')&& ~isempty(XmlData.Time)) |
---|
883 | XmlData.Time=Time; %time set by video |
---|
884 | end |
---|
885 | |
---|
886 | %% store last index in handles.lat_i and .last_j |
---|
887 | nbfield=max(max(max(i2_series))); |
---|
888 | if isempty(nbfield) |
---|
889 | nbfield=max(max(max(i1_series))); |
---|
890 | end |
---|
891 | nbfield_j=max(max(max(j2_series))); |
---|
892 | if isempty(nbfield_j) |
---|
893 | nbfield_j=max(max(max(j2_series))); |
---|
894 | end |
---|
895 | if ~isempty(XmlData.Time) |
---|
896 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index |
---|
897 | if isequal(size(XmlData.Time,1),1) |
---|
898 | NomType=get(handles.NomType,'String'); |
---|
899 | XmlData.Time=(XmlData.Time)'; |
---|
900 | end |
---|
901 | end |
---|
902 | last_i_cell=get(handles.last_i,'String'); |
---|
903 | if isempty(nbfield) |
---|
904 | last_i_cell{1}=''; |
---|
905 | else |
---|
906 | last_i_cell{1}=num2str(nbfield); |
---|
907 | end |
---|
908 | set(handles.last_i,'String',last_i_cell) |
---|
909 | last_j_cell=get(handles.last_j,'String'); |
---|
910 | if isempty(nbfield_j) |
---|
911 | last_j_cell{1}=''; |
---|
912 | else |
---|
913 | last_j_cell{1}=num2str(nbfield_j); |
---|
914 | end |
---|
915 | set(handles.last_j,'String',last_j_cell); |
---|
916 | |
---|
917 | %% store geometric calibration in UvData |
---|
918 | if isfield(XmlData,'GeometryCalib') |
---|
919 | GeometryCalib=XmlData.GeometryCalib; |
---|
920 | if isempty(GeometryCalib) |
---|
921 | set(handles.pxcm,'String','') |
---|
922 | set(handles.pycm,'String','') |
---|
923 | set(handles.transform_fct,'Value',1); % no transform by default |
---|
924 | else |
---|
925 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||... |
---|
926 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0)) |
---|
927 | set(handles.pxcm,'String','var') |
---|
928 | set(handles.pycm,'String','var') |
---|
929 | elseif isfield(GeometryCalib,'fx_fy') |
---|
930 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx); |
---|
931 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy); |
---|
932 | set(handles.pxcm,'String',num2str(pixcmx)) |
---|
933 | set(handles.pycm,'String',num2str(pixcmy)) |
---|
934 | end |
---|
935 | if ~get(handles.CheckFixLimits,'Value') |
---|
936 | set(handles.transform_fct,'Value',3); % phys transform by default if fixedLimits is off |
---|
937 | end |
---|
938 | if isfield(GeometryCalib,'SliceCoord') |
---|
939 | siz=size(GeometryCalib.SliceCoord); |
---|
940 | if siz(1)>1 |
---|
941 | NbSlice=siz(1); |
---|
942 | set(handles.slices,'Visible','on') |
---|
943 | set(handles.slices,'Value',1) |
---|
944 | end |
---|
945 | if isfield(GeometryCalib,'VolumeScan') && isequal(GeometryCalib.VolumeScan,'y') |
---|
946 | set(handles.num_NbSlice,'String','volume') |
---|
947 | else |
---|
948 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
949 | end |
---|
950 | slices_Callback([],[], handles) |
---|
951 | end |
---|
952 | end |
---|
953 | end |
---|
954 | |
---|
955 | %% update the data attached to the uvmat interface |
---|
956 | if ~isempty(TimeUnit) |
---|
957 | set(handles.time_txt,'String',['time (' TimeUnit ')']) |
---|
958 | end |
---|
959 | UvData.TimeUnit=TimeUnit; |
---|
960 | UvData.XmlData{index}=XmlData; |
---|
961 | UvData.NewSeries=1; |
---|
962 | % UvData.MovieObject=MovieObject; |
---|
963 | |
---|
964 | %display warning message |
---|
965 | if ~isequal(warntext,'') |
---|
966 | msgbox_uvmat('WARNING',warntext); |
---|
967 | end |
---|
968 | |
---|
969 | %% set default options in menu 'FieldName' |
---|
970 | switch FileType |
---|
971 | case {'civx','civdata'} |
---|
972 | [FieldList,ColorList]=calc_field; |
---|
973 | set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
974 | set(handles_Fields,'Value',2) % set menu to 'velocity |
---|
975 | set(handles.ColorScalar,'Value',1) |
---|
976 | set(handles.ColorScalar,'String',ColorList) |
---|
977 | set(handles.Vectors,'Visible','on') |
---|
978 | set(handles.Coord_x,'Value',1); |
---|
979 | set(handles.Coord_x,'String',{'X'}); |
---|
980 | set(handles.Coord_y,'Value',1); |
---|
981 | set(handles.Coord_y,'String',{'Y'}); |
---|
982 | case 'netcdf' |
---|
983 | set(handles_Fields,'Value',1) |
---|
984 | set(handles_Fields,'String',{'get_field...'}) |
---|
985 | hget_field=get_field(FileName); |
---|
986 | hhget_field=guidata(hget_field); |
---|
987 | get_field('RUN_Callback',hhget_field.RUN,[],hhget_field); |
---|
988 | otherwise |
---|
989 | set(handles_Fields,'Value',1) % set menu to 'image' |
---|
990 | set(handles_Fields,'String',{'image'}) |
---|
991 | set(handles.Coord_x,'Value',1); |
---|
992 | set(handles.Coord_x,'String',{'AX'}); |
---|
993 | set(handles.Coord_y,'Value',1); |
---|
994 | set(handles.Coord_y,'String',{'AY'}); |
---|
995 | end |
---|
996 | set(handles.uvmat,'UserData',UvData) |
---|
997 | |
---|
998 | %% set index navigation options and refresh plots |
---|
999 | scan_option='i';%default |
---|
1000 | state_j='off'; %default |
---|
1001 | if index==2 |
---|
1002 | if get(handles.scan_j,'Value') |
---|
1003 | scan_option='j'; %keep the scan option for the second file series |
---|
1004 | end |
---|
1005 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
1006 | state_j='on'; |
---|
1007 | end |
---|
1008 | end |
---|
1009 | [ref_j,ref_i]=find(squeeze(i1_series(1,:,:))); |
---|
1010 | if ~isempty(j1_series) |
---|
1011 | state_j='on'; |
---|
1012 | if index==1 |
---|
1013 | if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first value |
---|
1014 | scan_option='j'; %scan j indext |
---|
1015 | end |
---|
1016 | end |
---|
1017 | end |
---|
1018 | if isequal(scan_option,'i') |
---|
1019 | diff_ref_i=diff(ref_i,1); |
---|
1020 | if isempty(diff_ref_i) |
---|
1021 | diff_ref_i=1; |
---|
1022 | end |
---|
1023 | if isequal (diff_ref_i,diff_ref_i(1)*ones(size(diff_ref_i))) |
---|
1024 | set(handles.num_IndexIncrement,'String',num2str(diff_ref_i(1))) |
---|
1025 | end |
---|
1026 | set(handles.scan_i,'Value',1) |
---|
1027 | scan_i_Callback([],[], handles); |
---|
1028 | else |
---|
1029 | diff_ref_j=diff(ref_j); |
---|
1030 | if isempty(diff_ref_j) |
---|
1031 | diff_ref_j=1; |
---|
1032 | end |
---|
1033 | if isequal (diff_ref_j,diff_ref_j(1)*ones(size(diff_ref_j))) |
---|
1034 | set(handles.num_IndexIncrement,'String',num2str(diff_ref_j(1))) |
---|
1035 | end |
---|
1036 | set(handles.scan_j,'Value',1) |
---|
1037 | scan_j_Callback([],[], handles); |
---|
1038 | end |
---|
1039 | set(handles.scan_j,'Visible',state_j) |
---|
1040 | set(handles.j1,'Visible',state_j) |
---|
1041 | set(handles.j2,'Visible',state_j) |
---|
1042 | set(handles.last_j,'Visible',state_j); |
---|
1043 | set(handles.frame_j,'Visible',state_j); |
---|
1044 | set(handles.j_text,'Visible',state_j); |
---|
1045 | if ~isempty(i2_series)||~isempty(j2_series) |
---|
1046 | set(handles.CheckFixPair,'Visible','on') |
---|
1047 | elseif index==1 |
---|
1048 | set(handles.CheckFixPair,'Visible','off') |
---|
1049 | end |
---|
1050 | |
---|
1051 | %% apply the effect of the transform fct and view the field |
---|
1052 | transform=get(handles.path_transform,'UserData'); |
---|
1053 | if index==2 && (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
1054 | set(handles.transform_fct,'value',2); % set transform to sub_field if the current fct doe not accept two input fields |
---|
1055 | end |
---|
1056 | transform_fct_Callback([],[],handles) |
---|
1057 | mask_test=get(handles.CheckMask,'value'); |
---|
1058 | if mask_test |
---|
1059 | MaskData=get(handles.CheckMask,'UserData'); |
---|
1060 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
1061 | delete(MaskData.maskhandle) %delete old mask |
---|
1062 | end |
---|
1063 | CheckMask_Callback([],[],handles) |
---|
1064 | end |
---|
1065 | |
---|
1066 | %------------------------------------------------------------------------ |
---|
1067 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
1068 | function scan_i_Callback(hObject, eventdata, handles) |
---|
1069 | %------------------------------------------------------------------------ |
---|
1070 | if get(handles.scan_i,'Value')==1 |
---|
1071 | set(handles.scan_i,'BackgroundColor',[1 1 0]) |
---|
1072 | set(handles.scan_j,'Value',0) |
---|
1073 | else |
---|
1074 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1075 | set(handles.scan_j,'Value',1) |
---|
1076 | end |
---|
1077 | scan_j_Callback(hObject, eventdata, handles) |
---|
1078 | |
---|
1079 | %------------------------------------------------------------------------ |
---|
1080 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
1081 | function scan_j_Callback(hObject, eventdata, handles) |
---|
1082 | %------------------------------------------------------------------------ |
---|
1083 | if get(handles.scan_j,'Value')==1 |
---|
1084 | set(handles.scan_j,'BackgroundColor',[1 1 0]) |
---|
1085 | set(handles.scan_i,'Value',0) |
---|
1086 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1087 | % NomType=get(handles.NomType,'String'); |
---|
1088 | % switch NomType |
---|
1089 | % case {'_1_1-2','#_ab','%3dab'},% pair with j index |
---|
1090 | % set(handles.CheckFixPair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off') |
---|
1091 | % otherwise |
---|
1092 | % set(handles.CheckFixPair,'Visible','off') |
---|
1093 | % end |
---|
1094 | else |
---|
1095 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1096 | set(handles.scan_i,'Value',1) |
---|
1097 | set(handles.scan_i,'BackgroundColor',[1 1 0]) |
---|
1098 | set(handles.CheckFixPair,'Visible','off') |
---|
1099 | end |
---|
1100 | |
---|
1101 | %------------------------------------------------------------------------ |
---|
1102 | function i1_Callback(hObject, eventdata, handles) |
---|
1103 | %------------------------------------------------------------------------ |
---|
1104 | update_ij(handles,1) |
---|
1105 | |
---|
1106 | %------------------------------------------------------------------------ |
---|
1107 | function i2_Callback(hObject, eventdata, handles) |
---|
1108 | %------------------------------------------------------------------------ |
---|
1109 | update_ij(handles,2) |
---|
1110 | |
---|
1111 | %------------------------------------------------------------------------ |
---|
1112 | function j1_Callback(hObject, eventdata, handles) |
---|
1113 | %------------------------------------------------------------------------ |
---|
1114 | update_ij(handles,3) |
---|
1115 | |
---|
1116 | %------------------------------------------------------------------------ |
---|
1117 | function j2_Callback(hObject, eventdata, handles) |
---|
1118 | %------------------------------------------------------------------------ |
---|
1119 | update_ij(handles,4) |
---|
1120 | |
---|
1121 | %------------------------------------------------------------------------ |
---|
1122 | %--- update the index display after action on edit boxes i1, i2, j1 or j2 |
---|
1123 | function update_ij(handles,index_rank) |
---|
1124 | NomType=get(handles.NomType,'String'); |
---|
1125 | indices=get(handles.FileIndex,'String'); |
---|
1126 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(indices);% the indices for the second series taken from FileIndex |
---|
1127 | switch index_rank |
---|
1128 | case 1 |
---|
1129 | indices=fullfile_uvmat('','','','',NomType,stra2num(get(handles.i1,'String')),i2,j1,j2); |
---|
1130 | set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
1131 | case 2 |
---|
1132 | indices=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.i2,'String')),j1,j2); |
---|
1133 | set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
1134 | case 3 |
---|
1135 | indices=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.j1,'String')),j2); |
---|
1136 | set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
1137 | case 4 |
---|
1138 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.j2,'String'))); |
---|
1139 | set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
1140 | end |
---|
1141 | set(handles.FileIndex,'String',indices) |
---|
1142 | set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
1143 | % update the second index if relevant |
---|
1144 | if strcmp(get(handles.FileIndex_1,'Visible'),'on') |
---|
1145 | NomType_1=get(handles.NomType_1,'String'); |
---|
1146 | indices_1=get(handles.FileIndex_1,'String'); |
---|
1147 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(indices_1);% the indices for the second series taken from FileIndex_1 |
---|
1148 | switch index_rank |
---|
1149 | case 1 |
---|
1150 | indices_1=fullfile_uvmat('','','','',NomType_1,stra2num(get(handles.i1,'String')),i2_1,j1_1,j2_1); |
---|
1151 | case 2 |
---|
1152 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,stra2num(get(handles.i2,'String')),j1_1,j2_1); |
---|
1153 | case 3 |
---|
1154 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,stra2num(get(handles.j1,'String')),j2_1); |
---|
1155 | case 4 |
---|
1156 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,stra2num(get(handles.j2,'String'))); |
---|
1157 | end |
---|
1158 | set(handles.FileIndex_1,'String',indices_1) |
---|
1159 | set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
1160 | end |
---|
1161 | |
---|
1162 | %------------------------------------------------------------------------ |
---|
1163 | |
---|
1164 | %------------------------------------------------------------------------ |
---|
1165 | function slices_Callback(hObject, eventdata, handles) |
---|
1166 | %------------------------------------------------------------------------ |
---|
1167 | if get(handles.slices,'Value')==1 |
---|
1168 | set(handles.slices,'BackgroundColor',[1 1 0]) |
---|
1169 | set(handles.num_NbSlice,'Visible','on') |
---|
1170 | set(handles.z_text,'Visible','on') |
---|
1171 | set(handles.z_index,'Visible','on') |
---|
1172 | num_NbSlice_Callback(hObject, eventdata, handles) |
---|
1173 | else |
---|
1174 | set(handles.num_NbSlice,'Visible','off') |
---|
1175 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7]) |
---|
1176 | set(handles.z_text,'Visible','off') |
---|
1177 | set(handles.z_index,'Visible','off') |
---|
1178 | set(handles.masklevel,'Value',1) |
---|
1179 | set(handles.masklevel,'String',{'1'}) |
---|
1180 | end |
---|
1181 | |
---|
1182 | %------------------------------------------------------------------------ |
---|
1183 | function num_NbSlice_Callback(hObject, eventdata, handles) |
---|
1184 | %------------------------------------------------------------------------ |
---|
1185 | nb_slice_str=get(handles.num_NbSlice,'String'); |
---|
1186 | if isequal(nb_slice_str,'volume') |
---|
1187 | num=stra2num(get(handles.j1,'String')); |
---|
1188 | last_j=get(handles.last_j,'String'); |
---|
1189 | nbslice=str2double(last_j{1}); |
---|
1190 | else |
---|
1191 | num=str2double(get(handles.i1,'String')); |
---|
1192 | nbslice=str2double(get(handles.num_NbSlice,'String')); |
---|
1193 | end |
---|
1194 | z=mod(num-1,nbslice)+1; |
---|
1195 | set(handles.z_index,'String',num2str(z)) |
---|
1196 | for ilist=1:nbslice |
---|
1197 | list_index{ilist,1}=num2str(ilist); |
---|
1198 | end |
---|
1199 | set(handles.masklevel,'String',list_index) |
---|
1200 | set(handles.masklevel,'Value',z) |
---|
1201 | |
---|
1202 | %------------------------------------------------------------------------ |
---|
1203 | % --- Executes on button press in view_xml. |
---|
1204 | function view_xml_Callback(hObject, eventdata, handles) |
---|
1205 | %------------------------------------------------------------------------ |
---|
1206 | %[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles); |
---|
1207 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
1208 | FileBase=fullfile(RootPath,RootFile); |
---|
1209 | option=get(handles.view_xml,'String'); |
---|
1210 | if isequal(option,'view .xml') |
---|
1211 | FileXml=fullfile(RootPath,[SubDir '.xml']); |
---|
1212 | if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir |
---|
1213 | FileXml=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']); |
---|
1214 | end |
---|
1215 | heditxml=editxml(FileXml); |
---|
1216 | end |
---|
1217 | |
---|
1218 | %------------------------------------------------------------------------ |
---|
1219 | % --- Executes on button press in CheckMask. |
---|
1220 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
1221 | %------------------------------------------------------------------------ |
---|
1222 | %case of view mask selection |
---|
1223 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
1224 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
1225 | FileBase=fullfile(RootPath,RootFile); |
---|
1226 | num_i1=stra2num(get(handles.i1,'String')); |
---|
1227 | num_j1=stra2num(get(handles.j1,'String')); |
---|
1228 | currentdir=pwd; |
---|
1229 | cd(RootPath); |
---|
1230 | maskfiles=dir('*_*mask_*.png');%look for a mask file |
---|
1231 | cd(currentdir);%come back to the working directory |
---|
1232 | mdetect=0; |
---|
1233 | if ~isempty(maskfiles) |
---|
1234 | for ilist=1:length(maskfiles) |
---|
1235 | maskname=maskfiles(ilist).name;% take the first mask file in the list |
---|
1236 | [tild,tild,tild,tild,tild,tild,tild,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname); |
---|
1237 | [tild,Name]=fileparts(maskname); |
---|
1238 | Namedouble=double(Name); |
---|
1239 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
1240 | ind_mask=findstr('mask',Name); |
---|
1241 | i=ind_mask-1; |
---|
1242 | while val(i)==0 && i>0 |
---|
1243 | i=i-1; |
---|
1244 | end |
---|
1245 | nbmask_str=str2num(Name(i+1:ind_mask-1)); |
---|
1246 | if ~isempty(nbmask_str) |
---|
1247 | nbslice(ilist)=nbmask_str; % number of different masks (slices) |
---|
1248 | end |
---|
1249 | end |
---|
1250 | if isequal(min(nbslice),max(nbslice)) |
---|
1251 | nbslice=nbslice(1); |
---|
1252 | else |
---|
1253 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory') |
---|
1254 | return |
---|
1255 | end |
---|
1256 | if ~isempty(nbslice) && Name(i)=='_' |
---|
1257 | Mask.Base=[FileBase Name(i:ind_mask+3)]; |
---|
1258 | Mask.NbSlice=nbslice; |
---|
1259 | num_i1=mod(num_i1-1,nbslice)+1; |
---|
1260 | Mask.NomType=regexprep(Mask_NomType{1},'0','');%remove '0' in nom type for masks |
---|
1261 | [RootPath,RootFile]=fileparts(Mask.Base); |
---|
1262 | maskname=fullfile_uvmat(RootPath,'',RootFile,'.png',Mask.NomType,num_i1,[],num_j1); |
---|
1263 | %maskname=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);% |
---|
1264 | mdetect=exist(maskname,'file'); |
---|
1265 | if mdetect |
---|
1266 | set(handles.num_NbSlice,'String',Name(i+1:ind_mask-1)); |
---|
1267 | set(handles.num_NbSlice,'BackgroundColor',[1 1 0]) |
---|
1268 | set(handles.CheckMask,'UserData',Mask); |
---|
1269 | set(handles.CheckMask,'BackgroundColor',[1 1 0]) |
---|
1270 | if nbslice > 1 |
---|
1271 | set(handles.slices,'value',1) |
---|
1272 | slices_Callback(hObject, eventdata, handles) |
---|
1273 | end |
---|
1274 | end |
---|
1275 | end |
---|
1276 | end |
---|
1277 | errormsg=[];%default |
---|
1278 | if mdetect==0 |
---|
1279 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1280 | {'*.png', ' (*.png)'; |
---|
1281 | '*.png', '.png files '; ... |
---|
1282 | '*.*', 'All Files (*.*)'}, ... |
---|
1283 | 'Pick a mask file *.png',FileBase); |
---|
1284 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
1285 | maskname=fullfile(PathName,FileName); |
---|
1286 | [RootDir,SubDir,RootFile,tild,tild,tild,tild,tild,Mask.NomType]=fileparts_uvmat(maskname); |
---|
1287 | Mask.Base=fullfile(RootDir,SubDir,RootFile); |
---|
1288 | Mask.NbSlice=1; |
---|
1289 | set(handles.CheckMask,'UserData',Mask); |
---|
1290 | set(handles.CheckMask,'BackgroundColor',[1 1 0]) |
---|
1291 | end |
---|
1292 | if isempty(errormsg) |
---|
1293 | errormsg=update_mask(handles,num_i1,num_j1); |
---|
1294 | end |
---|
1295 | if ~isempty(errormsg) |
---|
1296 | set(handles.CheckMask,'Value',0) |
---|
1297 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
1298 | end |
---|
1299 | else % desactivate mask display |
---|
1300 | MaskData=get(handles.CheckMask,'UserData'); |
---|
1301 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
1302 | delete(MaskData.maskhandle) |
---|
1303 | end |
---|
1304 | set(handles.CheckMask,'UserData',[]) |
---|
1305 | UvData=get(handles.uvmat,'UserData'); |
---|
1306 | if isfield(UvData,'MaskName') |
---|
1307 | UvData=rmfield(UvData,'MaskName'); |
---|
1308 | set(handles.uvmat,'UserData',UvData) |
---|
1309 | end |
---|
1310 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
1311 | end |
---|
1312 | |
---|
1313 | %------------------------------------------------------------------------ |
---|
1314 | function errormsg=update_mask(handles,num_i1,num_j1) |
---|
1315 | %------------------------------------------------------------------------ |
---|
1316 | errormsg=[];%default |
---|
1317 | MaskData=get(handles.CheckMask,'UserData'); |
---|
1318 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
1319 | uistack(MaskData.maskhandle,'top'); |
---|
1320 | end |
---|
1321 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1; |
---|
1322 | [RootPath,RootFile]=fileparts(MaskData.Base); |
---|
1323 | MaskName=fullfile_uvmat(RootPath,'',RootFile,'.png',MaskData.NomType,num_i1_mask,[],num_j1); |
---|
1324 | UvData=get(handles.uvmat,'UserData'); |
---|
1325 | %update mask image if the mask is new |
---|
1326 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName)) |
---|
1327 | UvData.MaskName=MaskName; %update the recorded name on UvData |
---|
1328 | set(handles.uvmat,'UserData',UvData); |
---|
1329 | if ~exist(MaskName,'file') |
---|
1330 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
1331 | delete(MaskData.maskhandle) |
---|
1332 | end |
---|
1333 | else |
---|
1334 | %read mask image |
---|
1335 | Mask.AName='image'; |
---|
1336 | Mask.A=imread(MaskName); |
---|
1337 | npxy=size(Mask.A); |
---|
1338 | test_error=0; |
---|
1339 | if length(npxy)>2 |
---|
1340 | errormsg=[MaskName ' is not a grey scale image']; |
---|
1341 | return |
---|
1342 | elseif ~isa(Mask.A,'uint8') |
---|
1343 | errormsg=[MaskName ' is not a 8 bit grey level image']; |
---|
1344 | return |
---|
1345 | end |
---|
1346 | Mask.AX=[0.5 npxy(2)-0.5]; |
---|
1347 | Mask.AY=[npxy(1)-0.5 0.5 ]; |
---|
1348 | Mask.CoordUnit='pixel'; |
---|
1349 | if isequal(get(handles.slices,'Value'),1) |
---|
1350 | NbSlice=str2num(get(handles.num_NbSlice,'String')); |
---|
1351 | num_i1=str2num(get(handles.i1,'String')); |
---|
1352 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1; |
---|
1353 | end |
---|
1354 | %px to phys or other transform on field |
---|
1355 | menu_transform=get(handles.transform_fct,'String'); |
---|
1356 | choice_value=get(handles.transform_fct,'Value'); |
---|
1357 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' |
---|
1358 | transform_list=get(handles.transform_fct,'UserData'); |
---|
1359 | transform=transform_list{choice_value}; |
---|
1360 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px') |
---|
1361 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
1362 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
1363 | Mask=transform(Mask,UvData.XmlData{1}); |
---|
1364 | end |
---|
1365 | end |
---|
1366 | flagmask=Mask.A < 200; |
---|
1367 | |
---|
1368 | %make brown color image |
---|
1369 | imflag(:,:,1)=0.9*flagmask; |
---|
1370 | imflag(:,:,2)=0.7*flagmask; |
---|
1371 | imflag(:,:,3)=zeros(size(flagmask)); |
---|
1372 | |
---|
1373 | %update mask image |
---|
1374 | hmask=[]; %default |
---|
1375 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
1376 | hmask=MaskData.maskhandle; |
---|
1377 | end |
---|
1378 | if ~isempty(hmask) |
---|
1379 | set(hmask,'CData',imflag) |
---|
1380 | set(hmask,'AlphaData',flagmask*0.6) |
---|
1381 | set(hmask,'XData',Mask.AX); |
---|
1382 | set(hmask,'YData',Mask.AY); |
---|
1383 | % uistack(hmask,'top') |
---|
1384 | else |
---|
1385 | axes(handles.PlotAxes) |
---|
1386 | hold on |
---|
1387 | size(flagmask) |
---|
1388 | % MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask); |
---|
1389 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*ones(size(flagmask))); |
---|
1390 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask) |
---|
1391 | set(handles.CheckMask,'UserData',MaskData) |
---|
1392 | end |
---|
1393 | end |
---|
1394 | end |
---|
1395 | |
---|
1396 | %------------------------------------------------------------------------ |
---|
1397 | %------------------------------------------------------------------------ |
---|
1398 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT' |
---|
1399 | %------------------------------------------------------------------------ |
---|
1400 | |
---|
1401 | %------------------------------------------------------------------------ |
---|
1402 | % --- Executes on button press in runplus: make one step forward and call |
---|
1403 | % --- run0. The step forward is along the fieldname series 1 or 2 depending on |
---|
1404 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
1405 | function runplus_Callback(hObject, eventdata, handles) |
---|
1406 | %------------------------------------------------------------------------ |
---|
1407 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1408 | drawnow |
---|
1409 | %TODO: introduce the option: increment ='*' to move to the next available view |
---|
1410 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
1411 | % if isnan(increment) |
---|
1412 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
1413 | % increment=1; |
---|
1414 | % end |
---|
1415 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
1416 | if ~isempty(errormsg) |
---|
1417 | msgbox_uvmat('ERROR',errormsg); |
---|
1418 | end |
---|
1419 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
1420 | |
---|
1421 | %------------------------------------------------------------------------ |
---|
1422 | % --- Executes on button press in runmin: make one step backward and call |
---|
1423 | % --- run0. The step backward is along the fieldname series 1 or 2 depending on |
---|
1424 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
1425 | function runmin_Callback(hObject, eventdata, handles) |
---|
1426 | %------------------------------------------------------------------------ |
---|
1427 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1428 | drawnow |
---|
1429 | increment=-str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
1430 | % if isnan(increment) |
---|
1431 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
1432 | % increment=1; |
---|
1433 | % end |
---|
1434 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
1435 | if ~isempty(errormsg) |
---|
1436 | msgbox_uvmat('ERROR',errormsg); |
---|
1437 | end |
---|
1438 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
1439 | |
---|
1440 | %------------------------------------------------------------------------ |
---|
1441 | % -- Executes on button press in Movie: make a series of +> steps |
---|
1442 | function Movie_Callback(hObject, eventdata, handles) |
---|
1443 | %------------------------------------------------------------------------ |
---|
1444 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1445 | drawnow |
---|
1446 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
1447 | % if isnan(increment) |
---|
1448 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
1449 | % increment=1; |
---|
1450 | % end |
---|
1451 | set(handles.STOP,'Visible','on') |
---|
1452 | set(handles.speed,'Visible','on') |
---|
1453 | set(handles.speed_txt,'Visible','on') |
---|
1454 | set(handles.Movie,'BusyAction','queue') |
---|
1455 | UvData=get(handles.uvmat,'UserData'); |
---|
1456 | |
---|
1457 | while get(handles.Movie,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command |
---|
1458 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
1459 | if ~isempty(errormsg) |
---|
1460 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1461 | return |
---|
1462 | end |
---|
1463 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
1464 | end |
---|
1465 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
1466 | UvData.aviobj=close(UvData.aviobj); |
---|
1467 | set(handles.uvmat,'UserData',UvData); |
---|
1468 | end |
---|
1469 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1470 | |
---|
1471 | %------------------------------------------------------------------------ |
---|
1472 | % -- Executes on button press in Movie: make a series of <- steps |
---|
1473 | function MovieBackward_Callback(hObject, eventdata, handles) |
---|
1474 | %------------------------------------------------------------------------ |
---|
1475 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1476 | drawnow |
---|
1477 | increment=-str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
1478 | set(handles.STOP,'Visible','on') |
---|
1479 | set(handles.speed,'Visible','on') |
---|
1480 | set(handles.speed_txt,'Visible','on') |
---|
1481 | set(handles.MovieBackward,'BusyAction','queue') |
---|
1482 | UvData=get(handles.uvmat,'UserData'); |
---|
1483 | |
---|
1484 | while get(handles.MovieBackward,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command |
---|
1485 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
1486 | if ~isempty(errormsg) |
---|
1487 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1488 | return |
---|
1489 | end |
---|
1490 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
1491 | end |
---|
1492 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
1493 | UvData.aviobj=close(UvData.aviobj); |
---|
1494 | set(handles.uvmat,'UserData',UvData); |
---|
1495 | end |
---|
1496 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1497 | |
---|
1498 | %------------------------------------------------------------------------ |
---|
1499 | function STOP_Callback(hObject, eventdata, handles) |
---|
1500 | %------------------------------------------------------------------------ |
---|
1501 | set(handles.movie_pair,'BusyAction','Cancel') |
---|
1502 | set(handles.movie_pair,'value',0) |
---|
1503 | set(handles.Movie,'BusyAction','Cancel') |
---|
1504 | set(handles.MovieBackward,'BusyAction','Cancel') |
---|
1505 | set(handles.MenuExportMovie,'BusyAction','Cancel') |
---|
1506 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1507 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1508 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1509 | |
---|
1510 | %------------------------------------------------------------------------ |
---|
1511 | % --- function activated by runplus and run minus |
---|
1512 | function errormsg=runpm(hObject,eventdata,handles,increment) |
---|
1513 | %------------------------------------------------------------------------ |
---|
1514 | errormsg='';%default |
---|
1515 | %% check for movie pair status |
---|
1516 | movie_status=get(handles.movie_pair,'Value'); |
---|
1517 | if isequal(movie_status,1) |
---|
1518 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active |
---|
1519 | end |
---|
1520 | |
---|
1521 | %% read the current input file name(s) and field indices |
---|
1522 | InputFile=read_GUI(handles.InputFile); |
---|
1523 | InputFile.RootFile=regexprep(InputFile.RootFile,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
1524 | InputFile.SubDir=regexprep(InputFile.SubDir,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
1525 | FileExt=InputFile.FileExt; |
---|
1526 | NomType=get(handles.NomType,'String'); |
---|
1527 | i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) |
---|
1528 | i2=[];%default |
---|
1529 | if strcmp(get(handles.i2,'Visible'),'on') |
---|
1530 | i2=str2num(get(handles.i2,'String')); |
---|
1531 | end |
---|
1532 | j1=[]; |
---|
1533 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
1534 | j1=stra2num(get(handles.j1,'String')); |
---|
1535 | end |
---|
1536 | j2=j1; |
---|
1537 | if strcmp(get(handles.j2,'Visible'),'on') |
---|
1538 | j2=stra2num(get(handles.j2,'String')); |
---|
1539 | end |
---|
1540 | sub_value= get(handles.SubField,'Value'); |
---|
1541 | if sub_value % a second input file has been entered |
---|
1542 | [InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileIndex_1,InputFile.FileExt_1,InputFile.NomType_1]=read_file_boxes_1(handles); |
---|
1543 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(InputFile.FileIndex_1);% the indices for the second series taken from FileIndex_1 |
---|
1544 | else |
---|
1545 | filename_1=[]; |
---|
1546 | end |
---|
1547 | |
---|
1548 | %% increment (or decrement) the field indices and update the input filename(s) |
---|
1549 | if isempty(increment) |
---|
1550 | set(handles.CheckFixPair,'Value',0) |
---|
1551 | end |
---|
1552 | CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2)); |
---|
1553 | |
---|
1554 | % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected) |
---|
1555 | if CheckFixPair |
---|
1556 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
1557 | i1=i1+increment; |
---|
1558 | i2=i2+increment; |
---|
1559 | if sub_value |
---|
1560 | i1_1=i1_1+increment; |
---|
1561 | i2_1=i2_1+increment; |
---|
1562 | end |
---|
1563 | |
---|
1564 | else % case of scanning along index j (burst numbers) |
---|
1565 | j1=j1+increment; |
---|
1566 | j2=j2+increment; |
---|
1567 | if sub_value |
---|
1568 | j1_1=j1_1+increment; |
---|
1569 | j2_1=j2_1+increment; |
---|
1570 | end |
---|
1571 | end |
---|
1572 | |
---|
1573 | % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used |
---|
1574 | else |
---|
1575 | UvData=get(handles.uvmat,'UserData'); |
---|
1576 | ref_i=i1; |
---|
1577 | if ~isempty(i2) |
---|
1578 | ref_i=floor((i1+i2)/2);% current reference index i |
---|
1579 | end |
---|
1580 | ref_j=1; |
---|
1581 | if ~isempty(j1) |
---|
1582 | ref_j=j1; |
---|
1583 | if ~isempty(j2) |
---|
1584 | ref_j=floor((j1+j2)/2);% current reference index j |
---|
1585 | end |
---|
1586 | end |
---|
1587 | if ~isempty(increment) |
---|
1588 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
1589 | ref_i=ref_i+increment;% increment the current reference index i |
---|
1590 | else % case of scanning along index j (burst numbers) |
---|
1591 | ref_j=ref_j+increment;% increment the current reference index j if scan_j option is used |
---|
1592 | end |
---|
1593 | else % free increment |
---|
1594 | runaction=get(gcbo,'tag'); |
---|
1595 | if strcmp(runaction,'runplus')||strcmp(runaction,'Movie')% if runplus or movie is activated |
---|
1596 | step=1; |
---|
1597 | else |
---|
1598 | step=-1; |
---|
1599 | end |
---|
1600 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
1601 | ref_i=ref_i+step; |
---|
1602 | while ref_i>=0 && size(UvData.i1_series{1},3)>=ref_i+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0 |
---|
1603 | ref_i=ref_i+step; |
---|
1604 | end |
---|
1605 | else % case of scanning along index j (burst numbers) |
---|
1606 | ref_j=ref_j+step; |
---|
1607 | while ref_j>=0 && size(UvData.i1_series{1},2)>=ref_j+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0 |
---|
1608 | ref_j=ref_j+step; |
---|
1609 | end |
---|
1610 | end |
---|
1611 | end |
---|
1612 | if ref_i<0 |
---|
1613 | errormsg='minimum i index reached'; |
---|
1614 | elseif ref_j<0 |
---|
1615 | errormsg='minimum j index reached'; |
---|
1616 | elseif ref_i+1>size(UvData.i1_series{1},3) |
---|
1617 | errormsg='maximum i index reached (reload the input file to update the index bound)'; |
---|
1618 | elseif ref_j+1>size(UvData.i1_series{1},2) |
---|
1619 | errormsg='maximum j index reached (reload the input file to update the index bound)'; |
---|
1620 | end |
---|
1621 | if ~isempty(errormsg),return,end |
---|
1622 | siz=size(UvData.i1_series{1}); |
---|
1623 | ref_indices=ref_i*siz(1)*siz(2)+ref_j*siz(1)+1:ref_i*siz(1)*siz(2)+(ref_j+1)*siz(1); |
---|
1624 | i1_subseries=UvData.i1_series{1}(ref_indices); |
---|
1625 | ref_indices=ref_indices(i1_subseries>0); |
---|
1626 | if isempty(ref_indices)% case of pairs (free index i) |
---|
1627 | ref_indices=ref_i*siz(1)*siz(2)+1:(ref_i+1)*siz(1)*siz(2); |
---|
1628 | i1_subseries=UvData.i1_series{1}(ref_indices); |
---|
1629 | ref_indices=ref_indices(i1_subseries>0); |
---|
1630 | end |
---|
1631 | if isempty(ref_indices),errormsg='no next frame: set num_IndexIncrement =''*'' to reach the next existing file';return |
---|
1632 | end |
---|
1633 | i1=UvData.i1_series{1}(ref_indices(end)); |
---|
1634 | if ~isempty(UvData.i2_series{1}) |
---|
1635 | i2=UvData.i2_series{1}(ref_indices(end)); |
---|
1636 | end |
---|
1637 | if ~isempty(UvData.j1_series{1}) |
---|
1638 | j1=UvData.j1_series{1}(ref_indices(end)); |
---|
1639 | end |
---|
1640 | if ~isempty(UvData.j2_series{1}) |
---|
1641 | j2=UvData.j2_series{1}(ref_indices(end)); |
---|
1642 | end |
---|
1643 | |
---|
1644 | % case of a second file series |
---|
1645 | if sub_value |
---|
1646 | ref_i_1=i1_1; |
---|
1647 | if ~isempty(i2_1) |
---|
1648 | ref_i_1=floor((i1_1+i2_1)/2);% current reference index i |
---|
1649 | end |
---|
1650 | ref_j_1=1; |
---|
1651 | if ~isempty(j1_1) |
---|
1652 | ref_j_1=j1_1; |
---|
1653 | if ~isempty(j2_1) |
---|
1654 | ref_j_1=floor((j1_1+j2_1)/2);% current reference index j |
---|
1655 | end |
---|
1656 | end |
---|
1657 | if ~isempty(increment) |
---|
1658 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
1659 | ref_i_1=ref_i_1+increment;% increment the current reference index i |
---|
1660 | else % case of scanning along index j (burst numbers) |
---|
1661 | ref_j_1=ref_j_1+increment;% increment the current reference index j if scan_j option is used |
---|
1662 | end |
---|
1663 | else % free increment, synchronise the ref indices with the first series |
---|
1664 | ref_i_1=ref_i; |
---|
1665 | ref_j_1=ref_j; |
---|
1666 | end |
---|
1667 | if numel(UvData.i1_series)==1 |
---|
1668 | UvData.i1_series{2}=UvData.i1_series{1}; |
---|
1669 | UvData.j1_series{2}=UvData.j1_series{1}; |
---|
1670 | UvData.i2_series{2}=UvData.i2_series{1}; |
---|
1671 | UvData.j2_series{2}=UvData.j2_series{1}; |
---|
1672 | end |
---|
1673 | if ref_i_1<0 |
---|
1674 | errormsg='minimum i index reached'; |
---|
1675 | elseif ref_j_1<0 |
---|
1676 | errormsg='minimum j index reached'; |
---|
1677 | elseif ref_i_1+1>size(UvData.i1_series{2},3) |
---|
1678 | errormsg='maximum i index reached for the second series (reload the input file to update the index bound)'; |
---|
1679 | elseif ref_j_1+1>size(UvData.i1_series{2},2) |
---|
1680 | errormsg='maximum j index reached for the second series(reload the input file to update the index bound)'; |
---|
1681 | end |
---|
1682 | if ~isempty(errormsg),return,end |
---|
1683 | siz=size(UvData.i1_series{2}); |
---|
1684 | ref_indices=ref_i_1*siz(1)*siz(2)+ref_j_1*siz(1)+1:ref_i_1*siz(1)*siz(2)+(ref_j_1+1)*siz(1); |
---|
1685 | i1_subseries=UvData.i1_series{2}(ref_indices); |
---|
1686 | ref_indices=ref_indices(i1_subseries>0); |
---|
1687 | if isempty(ref_indices)% case of pairs (free index i) |
---|
1688 | ref_indices=ref_i_1*siz(1)*siz(2)+1:(ref_i_1+1)*siz(1)*siz(2); |
---|
1689 | i1_subseries=UvData.i1_series{2}(ref_indices); |
---|
1690 | ref_indices=ref_indices(i1_subseries>0); |
---|
1691 | end |
---|
1692 | i1_1=UvData.i1_series{2}(ref_indices(end)); |
---|
1693 | if ~isempty(UvData.i2_series{2}) |
---|
1694 | i2_1=UvData.i2_series{2}(ref_indices(end)); |
---|
1695 | end |
---|
1696 | if ~isempty(UvData.j1_series{2}) |
---|
1697 | j1_1=UvData.j1_series{2}(ref_indices(end)); |
---|
1698 | end |
---|
1699 | if ~isempty(UvData.j2_series{2}) |
---|
1700 | j2_1=UvData.j2_series{1}(ref_indices(end)); |
---|
1701 | end |
---|
1702 | else% the second series (if needed) is the same file as the first |
---|
1703 | i1_1=i1; |
---|
1704 | i2_1=i2; |
---|
1705 | j1_1=j1; |
---|
1706 | j2_1=j2; |
---|
1707 | end |
---|
1708 | end |
---|
1709 | filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2); |
---|
1710 | if sub_value |
---|
1711 | filename_1=fullfile_uvmat(InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileExt_1,InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1); |
---|
1712 | end |
---|
1713 | |
---|
1714 | %% refresh plots |
---|
1715 | errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1); |
---|
1716 | |
---|
1717 | %% update the index counters if the index move is successfull |
---|
1718 | if isempty(errormsg) |
---|
1719 | set(handles.i1,'String',num2stra(i1,NomType,1)); |
---|
1720 | if isequal(i2,i1) |
---|
1721 | set(handles.i2,'String',''); |
---|
1722 | else |
---|
1723 | set(handles.i2,'String',num2stra(i2,NomType,1)); |
---|
1724 | end |
---|
1725 | set(handles.j1,'String',num2stra(j1,NomType,2)); |
---|
1726 | if isequal(j2,j1) |
---|
1727 | set(handles.j2,'String',''); |
---|
1728 | else |
---|
1729 | set(handles.j2,'String',num2stra(j2,NomType,2)); |
---|
1730 | end |
---|
1731 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
1732 | set(handles.FileIndex,'String',indices); |
---|
1733 | if ~isempty(filename_1) |
---|
1734 | indices_1=fullfile_uvmat('','','','',InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1); |
---|
1735 | set(handles.FileIndex_1,'String',indices_1); |
---|
1736 | end |
---|
1737 | if isequal(movie_status,1) |
---|
1738 | set(handles.movie_pair,'Value',1) |
---|
1739 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated |
---|
1740 | end |
---|
1741 | end |
---|
1742 | |
---|
1743 | %------------------------------------------------------------------------ |
---|
1744 | % --- Executes on button press in movie_pair: create an alternating movie with two view |
---|
1745 | function movie_pair_Callback(hObject, eventdata, handles) |
---|
1746 | %------------------------------------------------------------------------ |
---|
1747 | %% stop movie action if the movie_pair button is off |
---|
1748 | if ~get(handles.movie_pair,'value') |
---|
1749 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off' |
---|
1750 | set(handles.i2,'String','') |
---|
1751 | set(handles.j2,'String','') |
---|
1752 | return |
---|
1753 | else |
---|
1754 | set(handles.movie_pair,'BusyAction','queue') |
---|
1755 | end |
---|
1756 | |
---|
1757 | %% initialisation |
---|
1758 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1759 | drawnow |
---|
1760 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
1761 | index_fields=get(handles.FieldName,'Value');% selected string index |
---|
1762 | FieldName=list_fields{index_fields}; % selected field |
---|
1763 | UvData=get(handles.uvmat,'UserData'); |
---|
1764 | if isequal(FieldName,'image') |
---|
1765 | index=1; |
---|
1766 | [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles); |
---|
1767 | NomType=get(handles.NomType,'String'); |
---|
1768 | else |
---|
1769 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
1770 | index_fields=get(handles.FieldName_1,'Value');% selected string index |
---|
1771 | FieldName=list_fields{index_fields}; % selected field |
---|
1772 | if isequal(FieldName,'image') |
---|
1773 | index=2; |
---|
1774 | [RootPath,tild,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles); |
---|
1775 | else |
---|
1776 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input') |
---|
1777 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
1778 | set(handles.movie_pair,'Value',0) |
---|
1779 | return |
---|
1780 | end |
---|
1781 | end |
---|
1782 | num_i1=str2num(get(handles.i1,'String')); |
---|
1783 | num_j1=stra2num(get(handles.j1,'String')); |
---|
1784 | num_i2=str2num(get(handles.i2,'String')); |
---|
1785 | num_j2=stra2num(get(handles.j2,'String')); |
---|
1786 | if isempty(num_j2) |
---|
1787 | if isempty(num_i2) |
---|
1788 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie') |
---|
1789 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
1790 | set(handles.movie_pair,'Value',0) |
---|
1791 | return |
---|
1792 | else |
---|
1793 | num_j2=num_j1;%repeat the index i1 by default |
---|
1794 | end |
---|
1795 | end |
---|
1796 | if isempty(num_i2) |
---|
1797 | num_i2=num_i1;%repeat the index i1 by default |
---|
1798 | end |
---|
1799 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i2,[],num_j2); |
---|
1800 | if strcmp(NomType,'*') |
---|
1801 | num_frame=num_i2; |
---|
1802 | else |
---|
1803 | num_frame=num_j2; |
---|
1804 | end |
---|
1805 | if ~exist(imaname_1,'file') |
---|
1806 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']); |
---|
1807 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
1808 | set(handles.movie_pair,'Value',0) |
---|
1809 | return |
---|
1810 | end |
---|
1811 | |
---|
1812 | %% get the first image |
---|
1813 | %Field.AName='image'; |
---|
1814 | if index==1 |
---|
1815 | Field_a=UvData.Field;% movie on the second field |
---|
1816 | else |
---|
1817 | Field_a=UvData.Field_1;% movie on the first field |
---|
1818 | end |
---|
1819 | |
---|
1820 | %% read the second image |
---|
1821 | MovieObject=[]; |
---|
1822 | if numel(UvData.MovieObject)>=index |
---|
1823 | MovieObject=UvData.MovieObject{index}; |
---|
1824 | end |
---|
1825 | [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},MovieObject,num_frame) |
---|
1826 | % Field_b.AX=Field_a.AX; |
---|
1827 | % Field_b.AY=Field_a.AY; |
---|
1828 | % % z index |
---|
1829 | % nbslice=str2double(get(handles.num_NbSlice,'String')); |
---|
1830 | % if ~isempty(nbslice) |
---|
1831 | % Field_b.ZIndex=mod(num_i2-1,nbslice)+1; |
---|
1832 | % end |
---|
1833 | % Field_b.CoordUnit='pixel'; |
---|
1834 | % |
---|
1835 | % %% determine the input file type |
---|
1836 | % if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1})) |
---|
1837 | % FileType='movie'; |
---|
1838 | % elseif isequal(lower(Ext),'.avi') |
---|
1839 | % FileType='avi'; |
---|
1840 | % elseif isequal(lower(Ext),'.vol') |
---|
1841 | % FileType='vol'; |
---|
1842 | % else |
---|
1843 | % form=imformats(Ext(2:end)); |
---|
1844 | % if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
1845 | % if isequal(NomType,'*'); |
---|
1846 | % FileType='multimage'; |
---|
1847 | % else |
---|
1848 | % FileType='image'; |
---|
1849 | % end |
---|
1850 | % end |
---|
1851 | % end |
---|
1852 | % switch FileType |
---|
1853 | % case 'movie' |
---|
1854 | % if test_1 |
---|
1855 | % Field_b.A=read(UvData.MovieObject{2},num_i2); |
---|
1856 | % else |
---|
1857 | % Field_b.A=read(UvData.MovieObject{1},num_i2); |
---|
1858 | % end |
---|
1859 | % case 'avi' |
---|
1860 | % mov=aviread(imaname_1,num_i2); |
---|
1861 | % Field_b.A=frame2im(mov(1)); |
---|
1862 | % case 'vol' |
---|
1863 | % Field_b.A=imread(imaname_1); |
---|
1864 | % case 'multimage' |
---|
1865 | % Field_b.A=imread(imaname_1,num_i2); |
---|
1866 | % case 'image' |
---|
1867 | % Field_b.A=imread(imaname_1); |
---|
1868 | % end |
---|
1869 | % if get(handles.slices,'Value') |
---|
1870 | % Field.ZIndex=str2double(get(handles.z_index,'String')); |
---|
1871 | % end |
---|
1872 | |
---|
1873 | %px to phys or other transform on field |
---|
1874 | % menu_transform=get(handles.transform_fct,'String'); |
---|
1875 | % choice_value=get(handles.transform_fct,'Value'); |
---|
1876 | % transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' |
---|
1877 | % transform_list=get(handles.transform_fct,'UserData'); |
---|
1878 | transform=get(handles.path_transform,'UserData'); |
---|
1879 | if ~isempty(transform) |
---|
1880 | if isfield(UvData,'XmlData') && numel(UvData.XmlData)>=index %use geometry calib recorded from the ImaDoc xml file as first priority |
---|
1881 | if index==2 |
---|
1882 | Field_a=transform(Field_a,UvData.XmlData{index});%the first field has been stored without transform |
---|
1883 | end |
---|
1884 | Field_b=transform(Field_b,UvData.XmlData{index}); |
---|
1885 | end |
---|
1886 | end |
---|
1887 | |
---|
1888 | % make movie until movie speed is set to 0 or STOP is activated |
---|
1889 | hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER) |
---|
1890 | set(handles.STOP,'Visible','on') |
---|
1891 | set(handles.speed,'Visible','on') |
---|
1892 | set(handles.speed_txt,'Visible','on') |
---|
1893 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command |
---|
1894 | % read and plot the series of images in non erase mode |
---|
1895 | set(hima,'CData',Field_b.A); |
---|
1896 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
1897 | set(hima,'CData',Field_a.A); |
---|
1898 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
1899 | end |
---|
1900 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
1901 | set(handles.movie_pair,'Value',0) |
---|
1902 | |
---|
1903 | %------------------------------------------------------------------------ |
---|
1904 | % --- Executes on button press in run0. |
---|
1905 | function run0_Callback(hObject, eventdata, handles) |
---|
1906 | %------------------------------------------------------------------------ |
---|
1907 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1908 | drawnow |
---|
1909 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
1910 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
1911 | filename_1='';%default |
---|
1912 | FileIndex_1=''; |
---|
1913 | if get(handles.SubField,'Value') |
---|
1914 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
1915 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
1916 | end |
---|
1917 | num_i1=stra2num(get(handles.i1,'String')); |
---|
1918 | num_i2=stra2num(get(handles.i2,'String')); |
---|
1919 | num_j1=stra2num(get(handles.j1,'String')); |
---|
1920 | num_j2=stra2num(get(handles.j2,'String')); |
---|
1921 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1); |
---|
1922 | |
---|
1923 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
1924 | |
---|
1925 | if ~isempty(errormsg) |
---|
1926 | msgbox_uvmat('ERROR',errormsg); |
---|
1927 | else |
---|
1928 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
1929 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
1930 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
1931 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
1932 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
1933 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
1934 | end |
---|
1935 | set(handles.run0,'BackgroundColor',[1 0 0]) |
---|
1936 | |
---|
1937 | |
---|
1938 | %------------------------------------------------------------------------ |
---|
1939 | % --- read the input files and refresh all the plots, including projection. |
---|
1940 | % OUTPUT: |
---|
1941 | % errormsg: error message char string =[] by default |
---|
1942 | % INPUT: |
---|
1943 | % filename: first input file (=[] in the absence of input file) |
---|
1944 | % filename_1: second input file (=[] in the asbsenc of secodn input file) |
---|
1945 | % num_i1,num_i2,num_j1,num_j2; frame indices |
---|
1946 | % Field: structure describing an optional input field (then replace the input file) |
---|
1947 | |
---|
1948 | function errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1) |
---|
1949 | %------------------------------------------------------------------------ |
---|
1950 | |
---|
1951 | %% initialisation |
---|
1952 | abstime=[]; |
---|
1953 | abstime_1=[]; |
---|
1954 | dt=[]; |
---|
1955 | if ~exist('Field','var') |
---|
1956 | Field={}; |
---|
1957 | end |
---|
1958 | UvData=get(handles.uvmat,'UserData'); |
---|
1959 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat |
---|
1960 | delete(handles.UVMAT_title) |
---|
1961 | end |
---|
1962 | |
---|
1963 | %% determine the main input file information for action |
---|
1964 | if ~exist(FileName,'file') |
---|
1965 | errormsg=['input file ' FileName ' does not exist']; |
---|
1966 | return |
---|
1967 | end |
---|
1968 | NomType=get(handles.NomType,'String'); |
---|
1969 | NomType_1=''; |
---|
1970 | if strcmp(get(handles.NomType_1,'Visible'),'on') |
---|
1971 | NomType_1=get(handles.NomType_1,'String'); |
---|
1972 | end |
---|
1973 | %update the z position index |
---|
1974 | nbslice_str=get(handles.num_NbSlice,'String'); |
---|
1975 | if isequal(nbslice_str,'volume')%NOT USED |
---|
1976 | z_index=num_j1; |
---|
1977 | set(handles.z_index,'String',num2str(z_index)) |
---|
1978 | else |
---|
1979 | nbslice=str2num(nbslice_str); |
---|
1980 | z_index=mod(num_i1-1,nbslice)+1; |
---|
1981 | set(handles.z_index,'String',num2str(z_index)) |
---|
1982 | end |
---|
1983 | % refresh menu for save_mask if relevant |
---|
1984 | masknumber=get(handles.masklevel,'String'); |
---|
1985 | if length(masknumber)>=z_index |
---|
1986 | set(handles.masklevel,'Value',z_index) |
---|
1987 | end |
---|
1988 | |
---|
1989 | %% test for need of tps |
---|
1990 | check_proj_tps=0; |
---|
1991 | if (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx')) |
---|
1992 | for iobj=1:numel(UvData.Object) |
---|
1993 | if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'filter') |
---|
1994 | check_proj_tps=1; |
---|
1995 | break |
---|
1996 | end |
---|
1997 | end |
---|
1998 | end |
---|
1999 | |
---|
2000 | %% read the first input field |
---|
2001 | ParamIn.ColorVar='';%default variable name for vector color |
---|
2002 | frame_index=1;%default |
---|
2003 | FieldName='';%default |
---|
2004 | VelType='';%default |
---|
2005 | switch UvData.FileType{1} |
---|
2006 | case {'civx','civdata','netcdf'}; |
---|
2007 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
2008 | FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field |
---|
2009 | if ~strcmp(FieldName,'get_field...') |
---|
2010 | if get(handles.FixVelType,'Value') |
---|
2011 | VelTypeList=get(handles.VelType,'String'); |
---|
2012 | VelType=VelTypeList{get(handles.VelType,'Value')}; |
---|
2013 | end |
---|
2014 | end |
---|
2015 | if ~isempty(regexp(FieldName,'^vec(')) |
---|
2016 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
2017 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
2018 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
2019 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
2020 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
2021 | ParamIn.ColorVar= list_code{index_code}; % selected field |
---|
2022 | end |
---|
2023 | end |
---|
2024 | case {'video','mmreader'} |
---|
2025 | ParamIn=UvData.MovieObject{1}; |
---|
2026 | if ~strcmp(NomType,'*') |
---|
2027 | frame_index=num_j1;%frame index for movies or multimage |
---|
2028 | else |
---|
2029 | frame_index=num_i1; |
---|
2030 | end |
---|
2031 | case 'multimage' |
---|
2032 | if ~strcmp(NomType,'*') |
---|
2033 | frame_index=num_j1;%frame index for movies or multimage |
---|
2034 | else |
---|
2035 | frame_index=num_i1; |
---|
2036 | end |
---|
2037 | case 'vol' %TODO: update |
---|
2038 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
2039 | ParamIn.Npy=UvData.XmlData.Npy; |
---|
2040 | ParamIn.Npx=UvData.XmlData.Npx; |
---|
2041 | else |
---|
2042 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
2043 | return |
---|
2044 | end |
---|
2045 | end |
---|
2046 | if isstruct (ParamIn) |
---|
2047 | ParamIn.FieldName=FieldName; |
---|
2048 | ParamIn.VelType=VelType; |
---|
2049 | XNameMenu=get(handles.Coord_x,'String'); |
---|
2050 | ParamIn.Coord_x=XNameMenu(get(handles.Coord_x,'Value')); |
---|
2051 | YNameMenu=get(handles.Coord_y,'String'); |
---|
2052 | ParamIn.Coord_y=YNameMenu(get(handles.Coord_y,'Value')); |
---|
2053 | end |
---|
2054 | check_tps = 0; |
---|
2055 | if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamIn.FieldName,'velocity')&&~strcmp(ParamIn.FieldName,'get_field...') |
---|
2056 | check_tps=1;%tps needed to get the requested field |
---|
2057 | end |
---|
2058 | [Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index); |
---|
2059 | if ~isempty(errormsg) |
---|
2060 | errormsg=['uvmat / refresh_field / read_field( ' FileName ') / ' errormsg]; |
---|
2061 | return |
---|
2062 | end |
---|
2063 | if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy') |
---|
2064 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
2065 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
2066 | end |
---|
2067 | if isfield(ParamOut,'TimeIndex')% case of time obtained from get_field |
---|
2068 | set(handles.i1,'String',num2str(ParamOut.TimeIndex)) |
---|
2069 | end |
---|
2070 | if isfield(ParamOut,'TimeValue') |
---|
2071 | Field{1}.Time=ParamOut.TimeValue;% case of time obtained from get_field |
---|
2072 | end |
---|
2073 | Field{1}.ZIndex=z_index; %used for multiplane 3D calibration |
---|
2074 | % end |
---|
2075 | |
---|
2076 | %% choose and read a second field FileName_1 if defined |
---|
2077 | VelType_1=[];%default |
---|
2078 | FieldName_1=[]; |
---|
2079 | ParamIn_1=[]; |
---|
2080 | ParamOut_1=[]; |
---|
2081 | frame_index_1=1; |
---|
2082 | if ~isempty(FileName_1) |
---|
2083 | if ~exist(FileName_1,'file') |
---|
2084 | errormsg=['second file ' FileName_1 ' does not exist']; |
---|
2085 | return |
---|
2086 | end |
---|
2087 | Name=FileName_1; |
---|
2088 | switch UvData.FileType{2} |
---|
2089 | case {'civx','civdata','netcdf'}; |
---|
2090 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
2091 | if ischar(list_fields),list_fields={list_fields};end |
---|
2092 | FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field |
---|
2093 | if ~strcmp(FieldName,'get_field...') |
---|
2094 | if get(handles.FixVelType,'Value') |
---|
2095 | VelTypeList=get(handles.VelType_1,'String'); |
---|
2096 | VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type. |
---|
2097 | end |
---|
2098 | end |
---|
2099 | if strcmp(FieldName_1,'velocity')&& strcmp(get(handles.ColorCode,'Visible'),'on') |
---|
2100 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
2101 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
2102 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
2103 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
2104 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
2105 | ParamIn_1.ColorVar= list_code{index_code}; % selected field for vector color display |
---|
2106 | end |
---|
2107 | end |
---|
2108 | case {'video','mmreader'} |
---|
2109 | ParamIn_1=UvData.MovieObject{2}; |
---|
2110 | if ~strcmp(NomType_1,'*') |
---|
2111 | frame_index_1=j1_1;%frame index for movies or multimage |
---|
2112 | else |
---|
2113 | frame_index_1=i1_1; |
---|
2114 | end |
---|
2115 | case 'multimage' |
---|
2116 | if ~strcmp(NomType_1,'*') |
---|
2117 | frame_index_1=j1_1;%frame index for movies or multimage |
---|
2118 | else |
---|
2119 | frame_index_1=i1_1; |
---|
2120 | end |
---|
2121 | case 'vol' %TODO: update |
---|
2122 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
2123 | ParamIn_1.Npy=UvData.XmlData.Npy; |
---|
2124 | ParamIn_1.Npx=UvData.XmlData.Npx; |
---|
2125 | else |
---|
2126 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
2127 | return |
---|
2128 | end |
---|
2129 | end |
---|
2130 | if isequal(get(handles.NomType_1,'Visible'),'on') |
---|
2131 | NomType_1=get(handles.NomType_1,'String'); |
---|
2132 | else |
---|
2133 | NomType_1=get(handles.NomType,'String'); |
---|
2134 | end |
---|
2135 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged |
---|
2136 | if ~isequal(NomType_1,'*')&& isfield(UvData,'FileName_1') |
---|
2137 | test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1); |
---|
2138 | end |
---|
2139 | if test_keepdata_1 |
---|
2140 | Field{2}=UvData.Field_1;% keep the stored field |
---|
2141 | ParamOut_1=UvData.ParamOut_1; |
---|
2142 | else |
---|
2143 | if isempty(ParamIn_1) || isstruct(ParamIn_1) |
---|
2144 | ParamIn_1.FieldName=FieldName_1; |
---|
2145 | ParamIn_1.VelType=VelType_1; |
---|
2146 | ParamIn_1.GUIName='get_field_1'; |
---|
2147 | end |
---|
2148 | [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,frame_index_1); |
---|
2149 | if ~isempty(errormsg) |
---|
2150 | errormsg=['error in reading ' FieldName_1 ' in ' FileName_1 ': ' errormsg]; |
---|
2151 | return |
---|
2152 | end |
---|
2153 | if isstruct(ParamOut_1)&&~strcmp(ParamOut_1.FieldName,'get_field...')&& (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx'))... |
---|
2154 | &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...') |
---|
2155 | if ~check_proj_tps |
---|
2156 | % Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2}); |
---|
2157 | end |
---|
2158 | end |
---|
2159 | end |
---|
2160 | Field{2}.ZIndex=z_index;%used for multi-plane 3D calibration |
---|
2161 | end |
---|
2162 | |
---|
2163 | %% update uvmat interface |
---|
2164 | if isfield(ParamOut,'Npx') |
---|
2165 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
2166 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
2167 | elseif isfield(ParamOut_1,'Npx') |
---|
2168 | set(handles.num_Npx,'String',num2str(ParamOut_1.Npx));% display image size on the interface |
---|
2169 | set(handles.num_Npy,'String',num2str(ParamOut_1.Npy)); |
---|
2170 | end |
---|
2171 | |
---|
2172 | %% update the display menu for the first velocity type (first menuline) |
---|
2173 | test_veltype=0; |
---|
2174 | % if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...') |
---|
2175 | if (strcmp(UvData.FileType{1},'civx')||strcmp(UvData.FileType{1},'civdata'))&& ~strcmp(FieldName,'get_field...') |
---|
2176 | test_veltype=1; |
---|
2177 | set(handles.VelType,'Visible','on') |
---|
2178 | set(handles.VelType_1,'Visible','on') |
---|
2179 | set(handles.FixVelType,'Visible','on') |
---|
2180 | menu=set_veltype_display(ParamOut.CivStage,UvData.FileType{1}); |
---|
2181 | index_menu=strcmp(ParamOut.VelType,menu);%look for VelType in the menu |
---|
2182 | index_val=find(index_menu,1); |
---|
2183 | if isempty(index_val) |
---|
2184 | index_val=1; |
---|
2185 | end |
---|
2186 | set(handles.VelType,'Value',index_val) |
---|
2187 | if ~get(handles.SubField,'value') |
---|
2188 | set(handles.VelType,'String',menu) |
---|
2189 | set(handles.VelType_1,'Value',1) |
---|
2190 | set(handles.VelType_1,'String',[{''};menu]) |
---|
2191 | end |
---|
2192 | else |
---|
2193 | set(handles.VelType,'Visible','off') |
---|
2194 | end |
---|
2195 | % display the FieldName menu from the input file and pick the selected one: |
---|
2196 | % if isstruct(ParamOut) |
---|
2197 | % field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList); |
---|
2198 | % set(handles.FieldName,'String',ParamOut.FieldList); %update the field menu |
---|
2199 | % set(handles.FieldName,'Value',find(field_index,1)) |
---|
2200 | % end |
---|
2201 | |
---|
2202 | %% update the display menu for the second velocity type (second menuline) |
---|
2203 | test_veltype_1=0; |
---|
2204 | if isempty(FileName_1) |
---|
2205 | % set(handles.FieldName_1,'Value',1); %update the field menu |
---|
2206 | % if isstruct(ParamOut) |
---|
2207 | % set(handles.FieldName_1,'String',[{''};ParamOut.FieldList]); %update the field menu |
---|
2208 | % end |
---|
2209 | elseif ~test_keepdata_1 |
---|
2210 | if (~strcmp(UvData.FileType{2},'netcdf')&&~strcmp(UvData.FileType{2},'civdata')&&~strcmp(UvData.FileType{2},'civx'))|| isequal(FieldName_1,'get_field...') |
---|
2211 | set(handles.VelType_1,'Visible','off') |
---|
2212 | else |
---|
2213 | test_veltype_1=1; |
---|
2214 | set(handles.VelType_1,'Visible','on') |
---|
2215 | menu=set_veltype_display(ParamOut_1.CivStage,UvData.FileType{2}); |
---|
2216 | index_menu=strcmp(ParamOut_1.VelType,menu); |
---|
2217 | set(handles.VelType_1,'Value',1+find(index_menu,1)) |
---|
2218 | set(handles.VelType_1,'String',[{''};menu]) |
---|
2219 | end |
---|
2220 | % update the second field menu: the same quantity |
---|
2221 | if isstruct(ParamOut_1) |
---|
2222 | set(handles.FieldName_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu |
---|
2223 | % display the FieldName menu from the input file and pick the selected one: |
---|
2224 | field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); |
---|
2225 | set(handles.FieldName_1,'Value',find(field_index,1)+1) |
---|
2226 | end |
---|
2227 | |
---|
2228 | end |
---|
2229 | if test_veltype||test_veltype_1 |
---|
2230 | set(handles.FixVelType,'Visible','on') |
---|
2231 | else |
---|
2232 | set(handles.FixVelType,'Visible','off') |
---|
2233 | end |
---|
2234 | |
---|
2235 | % field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); |
---|
2236 | % set(handles.FieldName,'String',ParamOut.FieldList); %update the field menu |
---|
2237 | % set(handles.FieldName,'Value',find(field_index,1)) |
---|
2238 | |
---|
2239 | %% introduce w as background image by default for a new series (only for nbdim=2) |
---|
2240 | if ~isfield(UvData,'NewSeries') |
---|
2241 | UvData.NewSeries=1; |
---|
2242 | end |
---|
2243 | %put W as background image by default if NbDim=2: |
---|
2244 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3); |
---|
2245 | set(handles.SubField,'Value',1); |
---|
2246 | set(handles.RootPath_1,'String','"') |
---|
2247 | set(handles.RootFile_1,'String','"') |
---|
2248 | set(handles.SubDir_1,'String','"'); |
---|
2249 | indices=fullfile_uvmat('','','','',NomType,num_i1,num_i2,num_j1,num_j2); |
---|
2250 | set(handles.FileIndex_1,'String',indices) |
---|
2251 | set(handles.FileExt_1,'String','"'); |
---|
2252 | set(handles.FieldName_1,'Visible','on'); |
---|
2253 | set(handles.FieldName_1,'Visible','on'); |
---|
2254 | set(handles.RootPath_1,'Visible','on') |
---|
2255 | set(handles.RootFile_1,'Visible','on') |
---|
2256 | set(handles.SubDir_1,'Visible','on'); |
---|
2257 | set(handles.FileIndex_1,'Visible','on'); |
---|
2258 | set(handles.FileExt_1,'Visible','on'); |
---|
2259 | set(handles.FieldName_1,'Visible','on'); |
---|
2260 | Field{1}.AName='w'; |
---|
2261 | end |
---|
2262 | |
---|
2263 | %% display time |
---|
2264 | testimedoc=0; |
---|
2265 | TimeUnit=''; |
---|
2266 | if isfield(Field{1},'Time') |
---|
2267 | abstime=Field{1}.Time;%time read from the netcdf input file |
---|
2268 | end |
---|
2269 | if numel(Field)==2 && isfield(Field{2},'Time') |
---|
2270 | abstime_1=Field{2}.Time;%time read from the netcdf input file |
---|
2271 | end |
---|
2272 | if isfield(Field{1},'Dt') |
---|
2273 | dt=Field{1}.Dt;%dt read from the netcdf input file |
---|
2274 | if isfield(Field{1},'TimeUnit') |
---|
2275 | TimeUnit=Field{1}.TimeUnit; |
---|
2276 | end |
---|
2277 | elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first |
---|
2278 | dt=Field{2}.Dt;%dt read from the netcdf input file |
---|
2279 | if isfield(Field{2},'TimeUnit') |
---|
2280 | TimeUnit=Field{2}.TimeUnit; |
---|
2281 | end |
---|
2282 | end |
---|
2283 | % time from xml file overset previous result |
---|
2284 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time') |
---|
2285 | if isempty(num_i2)||isnan(num_i2) |
---|
2286 | num_i2=num_i1; |
---|
2287 | end |
---|
2288 | if isempty(num_j1)||isnan(num_j1) |
---|
2289 | num_j1=1; |
---|
2290 | end |
---|
2291 | if isempty(num_j2)||isnan(num_j2) |
---|
2292 | num_j2=num_j1; |
---|
2293 | end |
---|
2294 | siz=size(UvData.XmlData{1}.Time); |
---|
2295 | if ~isempty(num_i1)&& ~isempty(num_i2)&&siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2) |
---|
2296 | abstime=(UvData.XmlData{1}.Time(num_i1,num_j1)+UvData.XmlData{1}.Time(num_i2,num_j2))/2;%overset the time read from files |
---|
2297 | dt=(UvData.XmlData{1}.Time(num_i2,num_j2)-UvData.XmlData{1}.Time(num_i1,num_j1)); |
---|
2298 | Field{1}.Dt=dt; |
---|
2299 | if isfield(UvData.XmlData{1},'TimeUnit') |
---|
2300 | TimeUnit=UvData.XmlData{1}.TimeUnit; |
---|
2301 | end |
---|
2302 | end |
---|
2303 | if numel(UvData.XmlData)==2 |
---|
2304 | if isempty(i2_1) |
---|
2305 | i2_1=num_i1; |
---|
2306 | end |
---|
2307 | if isempty(j1_1) |
---|
2308 | j1_1=1; |
---|
2309 | end |
---|
2310 | if isempty(j2_1) |
---|
2311 | j2_1=j1_1; |
---|
2312 | end |
---|
2313 | siz=size(UvData.XmlData{2}.Time); |
---|
2314 | if ~isempty(i1_1) && siz(1)>=max(i1_1,i2_1) && siz(2)>=max(j1_1,j2_1) |
---|
2315 | abstime_1=(UvData.XmlData{2}.Time(i1_1,j1_1)+UvData.XmlData{2}.Time(i2_1,j2_1))/2;%overset the time read from files |
---|
2316 | Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1,j2_1)-UvData.XmlData{2}.Time(i1_1,j1_1)); |
---|
2317 | end |
---|
2318 | end |
---|
2319 | end |
---|
2320 | if ~isequal(numel(abstime),1) |
---|
2321 | abstime=[]; |
---|
2322 | end |
---|
2323 | if ~isequal(numel(abstime_1),1) |
---|
2324 | abstime_1=[]; |
---|
2325 | end |
---|
2326 | set(handles.abs_time,'String',num2str(abstime,5)) |
---|
2327 | set(handles.abs_time_1,'String',num2str(abstime_1,5)) |
---|
2328 | if isempty(dt)||isequal(dt,0) |
---|
2329 | set(handles.Dt_txt,'String','') |
---|
2330 | else |
---|
2331 | if isempty(TimeUnit) |
---|
2332 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] ) |
---|
2333 | else |
---|
2334 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' TimeUnit] ) |
---|
2335 | end |
---|
2336 | end |
---|
2337 | |
---|
2338 | |
---|
2339 | %% store the current open names, fieldname and vel types in uvmat interface |
---|
2340 | UvData.FileName_1=FileName_1; |
---|
2341 | UvData.ParamOut_1=ParamOut_1; |
---|
2342 | if numel(Field)==2 |
---|
2343 | UvData.Field_1=Field{2}; %store the second field for possible use at next RUN |
---|
2344 | end |
---|
2345 | |
---|
2346 | %% apply coordinate transform or other user fct |
---|
2347 | transform=get(handles.path_transform,'UserData'); |
---|
2348 | if isempty(transform) |
---|
2349 | UvData.Field=Field{1}; |
---|
2350 | else |
---|
2351 | XmlData=[];%default |
---|
2352 | XmlData_1=[];%default |
---|
2353 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
2354 | XmlData=UvData.XmlData{1}; |
---|
2355 | if numel(UvData.XmlData)==2 |
---|
2356 | XmlData_1=UvData.XmlData{2}; |
---|
2357 | end |
---|
2358 | end |
---|
2359 | transform=get(handles.path_transform,'UserData'); |
---|
2360 | switch nargin(transform) |
---|
2361 | case 4 |
---|
2362 | if length(Field)==2 |
---|
2363 | UvData.Field=transform(Field{1},XmlData,Field{2},XmlData_1); |
---|
2364 | else |
---|
2365 | UvData.Field=transform(Field{1},XmlData); |
---|
2366 | end |
---|
2367 | case 3 |
---|
2368 | if length(Field)==2 |
---|
2369 | UvData.Field=transform(Field{1},XmlData,Field{2}); |
---|
2370 | else |
---|
2371 | UvData.Field=transform(Field{1},XmlData); |
---|
2372 | end |
---|
2373 | case 2 |
---|
2374 | UvData.Field=transform(Field{1},XmlData); |
---|
2375 | case 1 |
---|
2376 | UvData.Field=transform(Field{1}); |
---|
2377 | end |
---|
2378 | end |
---|
2379 | |
---|
2380 | %% calculate tps coefficients if needed |
---|
2381 | UvData.Field=calc_tps(UvData.Field,check_proj_tps); |
---|
2382 | |
---|
2383 | %% analyse input field |
---|
2384 | %test_x=0; |
---|
2385 | %test_z=0;% test for unstructured z coordinate |
---|
2386 | %[errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);% check the input field structure |
---|
2387 | % if ~isempty(errormsg) |
---|
2388 | % errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];% display error |
---|
2389 | % return |
---|
2390 | % end |
---|
2391 | [CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse the input field structure |
---|
2392 | if ~isempty(errormsg) |
---|
2393 | errormsg=['uvmat /refresh_field / find_field_cells / ' errormsg];% display error |
---|
2394 | return |
---|
2395 | end |
---|
2396 | |
---|
2397 | NbDim=max(NbDimArray);% spatial dimension of the input field |
---|
2398 | imax=find(NbDimArray==NbDim);% indices of field cells to consider |
---|
2399 | if isfield(UvData.Field,'NbDim') |
---|
2400 | NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates |
---|
2401 | end |
---|
2402 | |
---|
2403 | |
---|
2404 | %% get bounds and mesh (needed to propose default options for projection objects) |
---|
2405 | if NbDim>1 |
---|
2406 | CoordMax=zeros(1,numel(imax)); |
---|
2407 | CoordMin=zeros(1,numel(imax)); |
---|
2408 | for ind=1:numel(imax) |
---|
2409 | XName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)}; |
---|
2410 | YName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)}; |
---|
2411 | CoordMax(ind,1)=max(max(UvData.Field.(XName))); |
---|
2412 | CoordMin(ind,1)=min(min(UvData.Field.(XName))); |
---|
2413 | CoordMax(ind,2)=max(max(UvData.Field.(YName))); |
---|
2414 | CoordMin(ind,2)=min(min(UvData.Field.(YName))); |
---|
2415 | % test_x=1;%test for unstructured coordinates |
---|
2416 | if NbDim==3 |
---|
2417 | ZName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)}; |
---|
2418 | CoordMax(imax(ind),3)=max(max(UvData.Field.(ZName))); |
---|
2419 | CoordMin(ind,3)=min(min(UvData.Field.(ZName))); |
---|
2420 | end |
---|
2421 | |
---|
2422 | switch CellInfo{imax(ind)}.CoordType |
---|
2423 | |
---|
2424 | case 'scattered' %unstructured coordinates |
---|
2425 | NbPoints(ind)=CellInfo{imax(ind)}.CoordSize;% nbre of points |
---|
2426 | Mesh(ind)=(prod(CoordMax(ind,:)-CoordMin(ind,:))/NbPoints)^(1/NbDim); %(volume or area per point)^(1/NbDim) |
---|
2427 | case 'grid'%structured coordinate |
---|
2428 | NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points |
---|
2429 | Mesh(ind)=min((CoordMax(ind,:)-CoordMin(ind,:))./NbPoints); |
---|
2430 | |
---|
2431 | end |
---|
2432 | end |
---|
2433 | UvData.Field.Mesh=min(Mesh); |
---|
2434 | UvData.Field.XMax=max(CoordMax(ind,1)); |
---|
2435 | UvData.Field.XMin=min(CoordMin(ind,1)); |
---|
2436 | UvData.Field.YMax=max(CoordMax(ind,2)); |
---|
2437 | UvData.Field.YMin=max(CoordMin(ind,2)); |
---|
2438 | if NbDim==3 |
---|
2439 | UvData.Field.ZMax=max(CoordMax(ind,3)); |
---|
2440 | UvData.Field.ZMin=max(CoordMin(ind,3)); |
---|
2441 | end |
---|
2442 | % adjust the mesh to a value 1, 2 , 5 *10^n |
---|
2443 | ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude |
---|
2444 | if UvData.Field.Mesh/ord>=5 |
---|
2445 | UvData.Field.Mesh=5*ord; |
---|
2446 | elseif UvData.Field.Mesh/ord>=2 |
---|
2447 | UvData.Field.Mesh=2*ord; |
---|
2448 | else |
---|
2449 | UvData.Field.Mesh=ord; |
---|
2450 | end |
---|
2451 | % default projection plane |
---|
2452 | if isempty(UvData.Object{1}) |
---|
2453 | UvData.Object{1}.Type='plane';%main plotting plane |
---|
2454 | UvData.Object{1}.ProjMode='projection';%main plotting plane |
---|
2455 | UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat |
---|
2456 | UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat |
---|
2457 | end |
---|
2458 | %% 3D case (menuvolume) |
---|
2459 | if NbDim==3% && UvData.NewSeries |
---|
2460 | test_set_object=1; |
---|
2461 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI |
---|
2462 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
2463 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
2464 | if ~isempty(hset_object) %if set_object is detected |
---|
2465 | delete(hset_object);% delete the GUI set_object if it does not fit |
---|
2466 | end |
---|
2467 | if test_set_object% reinitiate the GUI set_object |
---|
2468 | delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2 |
---|
2469 | UvData.Object{1}.NbDim=NbDim;%test for 3D objects |
---|
2470 | UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane |
---|
2471 | UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen |
---|
2472 | UvData.Object{1}.Angle=[0 0 0]; |
---|
2473 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR |
---|
2474 | UvData.Object{1}.Name='1-PLANE'; |
---|
2475 | UvData.Object{1}.enable_plot=1; |
---|
2476 | set_object(UvData.Object{1},handles,ZBounds); |
---|
2477 | set(handles.ListObject,'Value',1); |
---|
2478 | set(handles.ListObject,'String',{'1-PLANE'}); |
---|
2479 | set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor |
---|
2480 | edit_object_Callback([],[], handles) |
---|
2481 | end |
---|
2482 | %multilevel case (single menuplane in a 3D space) |
---|
2483 | elseif isfield(UvData,'Z') |
---|
2484 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData') |
---|
2485 | XmlData=UvData.XmlData{1}; |
---|
2486 | if isfield(XmlData,'PlanePos') |
---|
2487 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:); |
---|
2488 | end |
---|
2489 | if isfield(XmlData,'PlaneAngle') |
---|
2490 | siz=size(XmlData.PlaneAngle); |
---|
2491 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning) |
---|
2492 | UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:); |
---|
2493 | end |
---|
2494 | elseif isfield(UvData,'ZIndex') |
---|
2495 | UvData.Object{1}.ZObject=UvData.ZIndex; |
---|
2496 | end |
---|
2497 | end |
---|
2498 | end |
---|
2499 | |
---|
2500 | testnewseries=UvData.NewSeries; |
---|
2501 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback) |
---|
2502 | set(handles.uvmat,'UserData',UvData) |
---|
2503 | |
---|
2504 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need) |
---|
2505 | % if isfield(UvData,'Mask')&& ~isfield(UvData,'A') |
---|
2506 | % set(handles.num_MinA,'String','0') |
---|
2507 | % set(handles.num_MaxA,'String','255') |
---|
2508 | % end |
---|
2509 | |
---|
2510 | %% usual 1D (x,y) plots |
---|
2511 | if NbDim<=1 |
---|
2512 | set(handles.Objects,'Visible','off') |
---|
2513 | set(handles.ListObject_1_title,'Visible','off') |
---|
2514 | set(handles.ListObject_1,'Visible','off') |
---|
2515 | [PlotType,PlotParamOut]=plot_field(UvData.Field,handles.PlotAxes,read_GUI(handles.uvmat)); |
---|
2516 | write_plot_param(handles,PlotParamOut) %update the auto plot parameters |
---|
2517 | |
---|
2518 | %% 2D or 3D fieldname are generally projected |
---|
2519 | else |
---|
2520 | set(handles.Objects,'Visible','on') |
---|
2521 | set(handles.ListObject_1_title,'Visible','on') |
---|
2522 | set(handles.ListObject_1,'Visible','on') |
---|
2523 | |
---|
2524 | %% Plot the projections on the selected projection objects |
---|
2525 | % main projection object (uvmat display) |
---|
2526 | list_object=get(handles.ListObject_1,'String'); |
---|
2527 | if isequal(list_object,{''})%refresh list of objects if the menu is empty |
---|
2528 | set(handles.ListObject,'Value',1) |
---|
2529 | set(handles.ListObject,'String',{'plane'}) |
---|
2530 | UvData.Object{1}.Type='plane';%main plotting plane |
---|
2531 | UvData.Object{1}.ProjMode='projection';%main plotting plane |
---|
2532 | UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat |
---|
2533 | UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat |
---|
2534 | set(handles.ListObject_1,'Value',1) |
---|
2535 | set(handles.ListObject_1,'String',{'plane'}) |
---|
2536 | end |
---|
2537 | IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view |
---|
2538 | if IndexObj(1)> numel(UvData.Object) |
---|
2539 | IndexObj(1)=1;%select the first object if the selected one does not exist |
---|
2540 | set(handles.ListObject_1,'Value',1) |
---|
2541 | end |
---|
2542 | IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view |
---|
2543 | if isequal(IndexObj(2),IndexObj(1)) |
---|
2544 | IndexObj(2)=[]; |
---|
2545 | end |
---|
2546 | plot_handles{1}=handles; |
---|
2547 | if isfield(UvData,'plotaxes')%case of movies |
---|
2548 | haxes(1)=UvData.plotaxes; |
---|
2549 | else |
---|
2550 | haxes(1)=handles.PlotAxes; |
---|
2551 | end |
---|
2552 | PlotParam{1}=read_GUI(handles.uvmat); |
---|
2553 | %default settings if vectors not visible |
---|
2554 | if ~isfield(PlotParam{1},'Vectors') |
---|
2555 | PlotParam{1}.Vectors.MaxVec=1; |
---|
2556 | PlotParam{1}.Vectors.MinVec=0; |
---|
2557 | PlotParam{1}.Vectors.CheckFixVecColor=1; |
---|
2558 | PlotParam{1}.Vectors.ColCode1=0.33; |
---|
2559 | PlotParam{1}.Vectors.ColCode2=0.66; |
---|
2560 | PlotParam{1}.Vectors.ColorScalar={''}; |
---|
2561 | PlotParam{1}.Vectors.ColorCode= {'rgb'}; |
---|
2562 | end |
---|
2563 | PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface |
---|
2564 | |
---|
2565 | %% second projection object (view_field display) |
---|
2566 | if length( IndexObj)>=2 |
---|
2567 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI |
---|
2568 | if ~isempty(view_field_handle) |
---|
2569 | plot_handles{2}=guidata(view_field_handle); |
---|
2570 | haxes(2)=plot_handles{2}.PlotAxes; |
---|
2571 | PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface |
---|
2572 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field |
---|
2573 | end |
---|
2574 | end |
---|
2575 | |
---|
2576 | %% loop on the projection objects: one or two |
---|
2577 | |
---|
2578 | for imap=1:numel(IndexObj) |
---|
2579 | iobj=IndexObj(imap); |
---|
2580 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object |
---|
2581 | if ~isempty(errormsg) |
---|
2582 | return |
---|
2583 | end |
---|
2584 | if testnewseries |
---|
2585 | PlotParam{imap}.Scalar.CheckBW=[]; %B/W option depends on the input field (image or scalar) |
---|
2586 | if isfield(ObjectData,'CoordUnit') |
---|
2587 | PlotParam{imap}.Coordinates.CheckFixAspectRatio=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y) |
---|
2588 | PlotParam{imap}.Coordinates.AspectRatio=1; %set aspect ratio to 1 |
---|
2589 | end |
---|
2590 | end |
---|
2591 | %use of mask (TODO: check) |
---|
2592 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A') |
---|
2593 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions |
---|
2594 | AX=ObjectData.AX;%x coordiantes for the scalar field |
---|
2595 | AY=ObjectData.AY;%y coordinates for the scalar field |
---|
2596 | MaskX=ObjectData.MaskX;%x coordiantes for the mask |
---|
2597 | MaskY=ObjectData.MaskY;%y coordiantes for the mask |
---|
2598 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY) |
---|
2599 | nxy=size(flag_mask); |
---|
2600 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel |
---|
2601 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1); |
---|
2602 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display |
---|
2603 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display |
---|
2604 | %project on the positions of the scalar |
---|
2605 | npxy=size(ObjectData.A); |
---|
2606 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y |
---|
2607 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x |
---|
2608 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end); |
---|
2609 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end); |
---|
2610 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates |
---|
2611 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI); |
---|
2612 | end |
---|
2613 | AClass=class(ObjectData.A); |
---|
2614 | ObjectData.A=flag_mask.*double(ObjectData.A); |
---|
2615 | ObjectData.A=feval(AClass,ObjectData.A); |
---|
2616 | % ind_off=[]; |
---|
2617 | % if isfield(ObjectData,'ListVarName') |
---|
2618 | % for ilist=1:length(ObjectData.ListVarName) |
---|
2619 | % if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY') |
---|
2620 | % ind_off=[ind_off ilist]; |
---|
2621 | % end |
---|
2622 | % end |
---|
2623 | % ObjectData.ListVarName(ind_off)=[]; |
---|
2624 | % VarDimIndex(ind_off)=[]; |
---|
2625 | % ind_off=[]; |
---|
2626 | % |
---|
2627 | % end |
---|
2628 | end |
---|
2629 | if ~isempty(ObjectData) |
---|
2630 | PlotType='none'; %default |
---|
2631 | if imap==2 && isempty(view_field_handle) |
---|
2632 | view_field(ObjectData) |
---|
2633 | else |
---|
2634 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap}); |
---|
2635 | write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters |
---|
2636 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh) |
---|
2637 | ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot) |
---|
2638 | end |
---|
2639 | end |
---|
2640 | end |
---|
2641 | end |
---|
2642 | |
---|
2643 | %% update the mask |
---|
2644 | if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on |
---|
2645 | update_mask(handles,num_i1,num_i2); |
---|
2646 | end |
---|
2647 | |
---|
2648 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case) |
---|
2649 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display |
---|
2650 | ind_skip=[]; |
---|
2651 | % nb_histo=1; |
---|
2652 | Ustring=''; |
---|
2653 | Vstring=''; |
---|
2654 | % suppress coordinates from the histogram menu |
---|
2655 | for ivar=1:numel(menu_histo)%l loop on field variables: |
---|
2656 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role') |
---|
2657 | Role=UvData.Field.VarAttribute{ivar}.Role; |
---|
2658 | switch Role |
---|
2659 | case {'coord_x','coord_y','coord_z','dimvar'} |
---|
2660 | ind_skip=[ind_skip ivar]; |
---|
2661 | case {'vector_x'} |
---|
2662 | Ustring=UvData.Field.ListVarName{ivar}; |
---|
2663 | ind_skip=[ind_skip ivar]; |
---|
2664 | case {'vector_y'} |
---|
2665 | Vstring=UvData.Field.ListVarName{ivar}; |
---|
2666 | ind_skip=[ind_skip ivar]; |
---|
2667 | end |
---|
2668 | end |
---|
2669 | DimCell=UvData.Field.VarDimName{ivar}; |
---|
2670 | DimName=''; |
---|
2671 | if ischar(DimCell) |
---|
2672 | DimName=DimCell; |
---|
2673 | elseif iscell(DimCell)&& numel(DimCell)==1 |
---|
2674 | DimName=DimCell{1}; |
---|
2675 | end |
---|
2676 | if strcmp(DimName,menu_histo{ivar}) |
---|
2677 | ind_skip=[ind_skip ivar]; |
---|
2678 | end |
---|
2679 | end |
---|
2680 | menu_histo(ind_skip)=[];% remove skipped items |
---|
2681 | if ~isempty(Ustring) |
---|
2682 | menu_histo=[{[Ustring ',' Vstring]};menu_histo];% add U, V at the beginning if they exist |
---|
2683 | end |
---|
2684 | |
---|
2685 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
2686 | % display menus and plot histograms |
---|
2687 | test_v=0; |
---|
2688 | if ~isempty(menu_histo) |
---|
2689 | set(handles.histo1_menu,'Value',1) |
---|
2690 | set(handles.histo1_menu,'String',menu_histo) |
---|
2691 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram |
---|
2692 | end |
---|
2693 | end |
---|
2694 | |
---|
2695 | %------------------------------------------------------------------------ |
---|
2696 | function histo1_menu_Callback(hObject, eventdata, handles) |
---|
2697 | %-------------------------------------------- |
---|
2698 | histo_menu=get(handles.histo1_menu,'String'); |
---|
2699 | histo_value=get(handles.histo1_menu,'Value'); |
---|
2700 | FieldName=histo_menu{histo_value}; |
---|
2701 | |
---|
2702 | UvData=get(handles.uvmat,'UserData'); |
---|
2703 | Field=UvData.Field; |
---|
2704 | r=regexp(FieldName,'(?<var1>.*)(?<sep>,)(?<var2>.*)','names'); |
---|
2705 | FieldName_2=''; |
---|
2706 | if ~isempty(r) |
---|
2707 | FieldName=r.var1; |
---|
2708 | FieldName_2=r.var2; |
---|
2709 | end |
---|
2710 | if ~isfield(UvData.Field,FieldName) |
---|
2711 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram']) |
---|
2712 | return |
---|
2713 | end |
---|
2714 | FieldHisto=Field.(FieldName); |
---|
2715 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto)) |
---|
2716 | indsel=find(Field.FF==0);%find values marked as false |
---|
2717 | if ~isempty(indsel) |
---|
2718 | FieldHisto=FieldHisto(indsel); |
---|
2719 | if ~isempty(FieldName_2) |
---|
2720 | FieldHisto(:,:,2)=Field.(FieldName_2)(indsel); |
---|
2721 | end |
---|
2722 | end |
---|
2723 | end |
---|
2724 | if isempty(Field) |
---|
2725 | msgbox_uvmat('ERROR',['empty field ' FieldName]) |
---|
2726 | else |
---|
2727 | nxy=size(FieldHisto); |
---|
2728 | Amin=double(min(min(min(FieldHisto))));%min of field value |
---|
2729 | Amax=double(max(max(max(FieldHisto))));%max of field value |
---|
2730 | if isequal(Amin,Amax) |
---|
2731 | cla(handles.HistoAxes) |
---|
2732 | else |
---|
2733 | Histo.ListVarName={FieldName,'histo'}; |
---|
2734 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
2735 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
2736 | else |
---|
2737 | if numel(nxy)==2 |
---|
2738 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
2739 | else |
---|
2740 | Histo.VarDimName={FieldName,{FieldName,'component'}}; %dimensions for the histogram |
---|
2741 | end |
---|
2742 | end |
---|
2743 | %unit |
---|
2744 | units=[]; %default |
---|
2745 | for ivar=1:numel(Field.ListVarName) |
---|
2746 | if strcmp(Field.ListVarName{ivar},FieldName) |
---|
2747 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units') |
---|
2748 | units=Field.VarAttribute{ivar}.units; |
---|
2749 | break |
---|
2750 | end |
---|
2751 | end |
---|
2752 | end |
---|
2753 | if ~isempty(units) |
---|
2754 | Histo.VarAttribute{1}.units=units; |
---|
2755 | end |
---|
2756 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo |
---|
2757 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
2758 | C=reshape(double(FieldHisto),1,[]);% reshape in a vector |
---|
2759 | Histo.histo(:,1)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
2760 | else |
---|
2761 | for col=1:size(FieldHisto,3) |
---|
2762 | B=FieldHisto(:,:,col); |
---|
2763 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector |
---|
2764 | Histo.histo(:,col)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
2765 | end |
---|
2766 | end |
---|
2767 | plot_field(Histo,handles.HistoAxes); |
---|
2768 | hlegend=legend; |
---|
2769 | if isempty(FieldName_2) |
---|
2770 | set(hlegend,'String',FieldName) |
---|
2771 | else |
---|
2772 | set(hlegend,'String',{FieldName;FieldName_2}) |
---|
2773 | end |
---|
2774 | end |
---|
2775 | end |
---|
2776 | |
---|
2777 | %------------------------------------------------------------------- |
---|
2778 | % --- translate coordinate to matrix index |
---|
2779 | %------------------------------------------------------------------- |
---|
2780 | function [indx,indy]=pos2ind(x0,rangx0,nxy) |
---|
2781 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel |
---|
2782 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel |
---|
2783 | |
---|
2784 | |
---|
2785 | %------------------------------------------------------------------- |
---|
2786 | % --- Executes on button press in 'CheckZoom'. |
---|
2787 | %------------------------------------------------------------------- |
---|
2788 | function CheckZoom_Callback(hObject, eventdata, handles) |
---|
2789 | |
---|
2790 | if (get(handles.CheckZoom,'Value') == 1); |
---|
2791 | set(handles.CheckZoom,'BackgroundColor',[1 1 0]) |
---|
2792 | set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes |
---|
2793 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
2794 | else |
---|
2795 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
2796 | end |
---|
2797 | |
---|
2798 | %------------------------------------------------------------------- |
---|
2799 | % --- Executes on button press in 'CheckFixLimits'. |
---|
2800 | %------------------------------------------------------------------- |
---|
2801 | function CheckFixLimits_Callback(hObject, eventdata, handles) |
---|
2802 | test=get(handles.CheckFixLimits,'Value'); |
---|
2803 | if test |
---|
2804 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
2805 | else |
---|
2806 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
2807 | update_plot(handles); |
---|
2808 | end |
---|
2809 | |
---|
2810 | %------------------------------------------------------------------- |
---|
2811 | % --- Executes on button press in CheckFixAspectRatio. |
---|
2812 | function CheckFixAspectRatio_Callback(hObject, eventdata, handles) |
---|
2813 | %------------------------------------------------------------------- |
---|
2814 | if get(handles.CheckFixAspectRatio,'Value') |
---|
2815 | set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0]) |
---|
2816 | update_plot(handles); |
---|
2817 | else |
---|
2818 | set(handles.CheckFixAspectRatio,'BackgroundColor',[0.7 0.7 0.7]) |
---|
2819 | update_plot(handles); |
---|
2820 | end |
---|
2821 | |
---|
2822 | %------------------------------------------------------------------- |
---|
2823 | function num_AspectRatio_Callback(hObject, eventdata, handles) |
---|
2824 | %------------------------------------------------------------------- |
---|
2825 | set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button |
---|
2826 | set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0])% mark in yellow |
---|
2827 | update_plot(handles); |
---|
2828 | %------------------------------------------------------------------- |
---|
2829 | |
---|
2830 | %------------------------------------------------------------------- |
---|
2831 | |
---|
2832 | |
---|
2833 | |
---|
2834 | %------------------------------------------------------------------- |
---|
2835 | %----Executes on button press in 'record': records the current flags of manual correction. |
---|
2836 | %------------------------------------------------------------------- |
---|
2837 | function record_Callback(hObject, eventdata, handles) |
---|
2838 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles); |
---|
2839 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
2840 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
2841 | %FileName=read_file_boxes(handles); |
---|
2842 | [erread,message]=fileattrib(FileName); |
---|
2843 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
2844 | msgbox_uvmat('ERROR',['no writting access to ' FileName]) |
---|
2845 | return |
---|
2846 | end |
---|
2847 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); |
---|
2848 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]); |
---|
2849 | if ~test_civ2 && ~test_civ1 |
---|
2850 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
2851 | end |
---|
2852 | if test_civ2 |
---|
2853 | nbname='nb_vectors2'; |
---|
2854 | flagname='vec2_FixFlag'; |
---|
2855 | attrname='fix2'; |
---|
2856 | end |
---|
2857 | if test_civ1 |
---|
2858 | nbname='nb_vectors'; |
---|
2859 | flagname='vec_FixFlag'; |
---|
2860 | attrname='fix'; |
---|
2861 | end |
---|
2862 | %write fix flags in the netcdf file |
---|
2863 | UvData=get(handles.uvmat,'UserData'); |
---|
2864 | hhh=which('netcdf.open');% look for built-in matlab netcdf library |
---|
2865 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library |
---|
2866 | nc=netcdf.open(FileName,'NC_WRITE'); |
---|
2867 | netcdf.reDef(nc); |
---|
2868 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1); |
---|
2869 | dimid = netcdf.inqDimID(nc,nbname); |
---|
2870 | try |
---|
2871 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable |
---|
2872 | catch |
---|
2873 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist |
---|
2874 | end |
---|
2875 | netcdf.endDef(nc); |
---|
2876 | netcdf.putVar(nc,varid,UvData.PlotAxes.FF); |
---|
2877 | netcdf.close(nc); |
---|
2878 | else %old netcdf library |
---|
2879 | netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) |
---|
2880 | end |
---|
2881 | |
---|
2882 | %------------------------------------------------------------------- |
---|
2883 | %----Correct the netcdf file, using toolbox (old versions of Matlab). |
---|
2884 | %------------------------------------------------------------------- |
---|
2885 | function netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) |
---|
2886 | nc=netcdf(FileName,'write'); %open netcdf file |
---|
2887 | result=redef(nc); |
---|
2888 | eval(['nc.' attrname '=1;']); |
---|
2889 | theDim=nc(nbname) ;% get the number of velocity vectors |
---|
2890 | nb_vectors=size(theDim); |
---|
2891 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag |
---|
2892 | var_FixFlag(1:nb_vectors)=AxeData.FF;% |
---|
2893 | fin=close(nc); |
---|
2894 | |
---|
2895 | %------------------------------------------------------------------- |
---|
2896 | % --- Executes on button press in SubField |
---|
2897 | function SubField_Callback(hObject, eventdata, handles) |
---|
2898 | %------------------------------------------------------------------- |
---|
2899 | UvData=get(handles.uvmat,'UserData'); |
---|
2900 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated |
---|
2901 | set(handles.RootPath_1,'String','') |
---|
2902 | set(handles.RootFile_1,'String','') |
---|
2903 | set(handles.SubDir_1,'String',''); |
---|
2904 | set(handles.FileIndex_1,'String',''); |
---|
2905 | set(handles.FileExt_1,'String',''); |
---|
2906 | set(handles.RootPath_1,'Visible','off') |
---|
2907 | set(handles.RootFile_1,'Visible','off') |
---|
2908 | set(handles.SubDir_1,'Visible','off'); |
---|
2909 | set(handles.NomType_1,'Visible','off'); |
---|
2910 | set(handles.abs_time_1,'Visible','off') |
---|
2911 | set(handles.FileIndex_1,'Visible','off'); |
---|
2912 | set(handles.FileExt_1,'Visible','off'); |
---|
2913 | set(handles.FieldName_1,'Value',1);%set to blank state |
---|
2914 | set(handles.VelType_1,'Value',1);%set to blank state |
---|
2915 | set(handles.num_Opacity,'String','')% desactivate opacity setting |
---|
2916 | if ~strcmp(get(handles.VelType,'Visible'),'on') |
---|
2917 | set(handles.VelType_1,'Visible','off') |
---|
2918 | end |
---|
2919 | if isfield(UvData,'XmlData_1') |
---|
2920 | UvData=rmfield(UvData,'XmlData_1'); |
---|
2921 | end |
---|
2922 | set(handles.uvmat,'UserData',UvData); |
---|
2923 | transform_fct_list=get(handles.transform_fct,'String'); |
---|
2924 | transform_fct=transform_fct_list(get(handles.transform_fct,'Value')); |
---|
2925 | if strcmp(transform_fct,'sub_field') |
---|
2926 | set(handles.transform_fct,'Value',1)%suppress the sub_field transform |
---|
2927 | transform_fct_Callback(hObject, eventdata, handles); |
---|
2928 | else |
---|
2929 | run0_Callback(hObject, eventdata, handles) |
---|
2930 | end |
---|
2931 | else |
---|
2932 | MenuBrowse_1_Callback(hObject, eventdata, handles) |
---|
2933 | end |
---|
2934 | |
---|
2935 | %------------------------------------------------------------------------ |
---|
2936 | % --- read the data displayed for the input rootfile windows (new): TODO use read_GUI |
---|
2937 | |
---|
2938 | function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles) |
---|
2939 | %------------------------------------------------------------------------ |
---|
2940 | InputFile=read_GUI(handles.InputFile); |
---|
2941 | RootPath=InputFile.RootPath; |
---|
2942 | SubDir=regexprep(InputFile.SubDir,'/|\',''); |
---|
2943 | RootFile=regexprep(InputFile.RootFile,'/|\',''); |
---|
2944 | FileIndices=InputFile.FileIndex; |
---|
2945 | FileExt=InputFile.FileExt; |
---|
2946 | |
---|
2947 | |
---|
2948 | %------------------------------------------------------------------------ |
---|
2949 | % ---- read the data displayed for the second input rootfile windows |
---|
2950 | function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles) |
---|
2951 | %------------------------------------------------------------------------ |
---|
2952 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window |
---|
2953 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"') |
---|
2954 | RootPath_1=get(handles.RootPath,'String'); |
---|
2955 | end; |
---|
2956 | SubDir_1=get(handles.SubDir_1,'String'); |
---|
2957 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"') |
---|
2958 | SubDir_1=get(handles.SubDir,'String'); |
---|
2959 | end |
---|
2960 | SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
2961 | RootFile_1=get(handles.RootFile_1,'String'); |
---|
2962 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"') |
---|
2963 | RootFile_1=get(handles.RootFile,'String'); |
---|
2964 | end |
---|
2965 | RootFile_1=regexprep(RootFile_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
2966 | FileIndex_1=get(handles.FileIndex_1,'String'); |
---|
2967 | if isequal(get(handles.FileIndex_1,'Visible'),'off')|| isequal(FileIndex_1,'"') |
---|
2968 | FileIndex_1=get(handles.FileIndex,'String'); |
---|
2969 | end |
---|
2970 | FileExt_1=get(handles.FileExt_1,'String'); |
---|
2971 | if isequal(get(handles.FileExt_1,'Visible'),'off') || isequal(FileExt_1,'"') |
---|
2972 | FileExt_1=get(handles.FileExt,'String');%read FileExt by default |
---|
2973 | end |
---|
2974 | NomType_1=get(handles.NomType_1,'String'); |
---|
2975 | if isequal(get(handles.NomType_1,'Visible'),'off') || isequal(NomType_1,'"') |
---|
2976 | NomType_1=get(handles.NomType,'String');%read FileExt by default |
---|
2977 | end |
---|
2978 | %------------------------------------------------------------------------ |
---|
2979 | % --- Executes on menu selection FieldName |
---|
2980 | function FieldName_Callback(hObject, eventdata, handles) |
---|
2981 | %------------------------------------------------------------------------ |
---|
2982 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
2983 | index_fields=get(handles.FieldName,'Value');% selected string index |
---|
2984 | field= list_fields{index_fields(1)}; % selected string |
---|
2985 | if isequal(field,'get_field...') |
---|
2986 | set(handles.FixVelType,'visible','off') |
---|
2987 | set(handles.VelType,'visible','off') |
---|
2988 | set(handles.VelType_1,'visible','off') |
---|
2989 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
2990 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
2991 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
2992 | if ~isempty(hget_field) |
---|
2993 | delete(hget_field) |
---|
2994 | end |
---|
2995 | get_field(FileName); |
---|
2996 | return %no further action |
---|
2997 | end |
---|
2998 | |
---|
2999 | UvData=get(handles.uvmat,'UserData'); |
---|
3000 | |
---|
3001 | %read the rootfile input display |
---|
3002 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
3003 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
3004 | [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); |
---|
3005 | if isequal(field,'image') |
---|
3006 | if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file |
---|
3007 | imagename=UvData.Field.Civ2_ImageA; |
---|
3008 | elseif isfield(UvData.Field,'Civ1_ImageA')% |
---|
3009 | imagename=UvData.Field.Civ1_ImageA; |
---|
3010 | else |
---|
3011 | SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
3012 | imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); |
---|
3013 | end |
---|
3014 | if ~exist(imagename,'file') |
---|
3015 | [FileName,PathName] = uigetfile( ... |
---|
3016 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; |
---|
3017 | '*.jpg',' jpeg image files'; ... |
---|
3018 | '*.png','.png image files'; ... |
---|
3019 | '*.tif','.tif image files'; ... |
---|
3020 | '*.avi;*.AVI','.avi movie files'; ... |
---|
3021 | '*.vol','.volume images (png)'; ... |
---|
3022 | '*.*', 'All Files (*.*)'}, ... |
---|
3023 | 'Pick an image',imagename); |
---|
3024 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
3025 | imagename=[PathName FileName]; |
---|
3026 | end |
---|
3027 | % display the selected field and related information |
---|
3028 | display_file_name(handles,imagename)%display the image |
---|
3029 | return |
---|
3030 | else |
---|
3031 | ext=get(handles.FileExt,'String'); |
---|
3032 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file |
---|
3033 | [FileName,PathName] = uigetfile( ... |
---|
3034 | {'*.nc', ' (*.nc)'; |
---|
3035 | '*.nc',' netcdf files'; ... |
---|
3036 | '*.*', 'All Files (*.*)'}, ... |
---|
3037 | 'Pick a netcdf file',FileBase); |
---|
3038 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
3039 | FullFileName=[PathName FileName]; |
---|
3040 | % display the selected field and related information |
---|
3041 | display_file_name( handles,FullFileName) |
---|
3042 | return |
---|
3043 | end |
---|
3044 | end |
---|
3045 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
3046 | set(handles.FileIndex,'String',indices) |
---|
3047 | % set(handles.NomType,'String',NomType) |
---|
3048 | |
---|
3049 | %common to Fields_1_Callback |
---|
3050 | list_fields_1=get(handles.FieldName_1,'String');% list menu fields |
---|
3051 | field_1=''; |
---|
3052 | if ~isempty(list_fields_1) |
---|
3053 | field_1= list_fields_1{get(handles.FieldName_1,'Value')}; % selected string |
---|
3054 | end |
---|
3055 | if isequal(field,'image')||isequal(field_1,'image') |
---|
3056 | set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons |
---|
3057 | set(handles.TitleNpy,'Visible','on') |
---|
3058 | set(handles.num_Npx,'Visible','on') |
---|
3059 | set(handles.num_Npy,'Visible','on') |
---|
3060 | else |
---|
3061 | set(handles.TitleNpx,'Visible','off')% visible npx,pxcm... buttons |
---|
3062 | set(handles.TitleNpy,'Visible','off') |
---|
3063 | set(handles.num_Npx,'Visible','off') |
---|
3064 | set(handles.num_Npy,'Visible','off') |
---|
3065 | end |
---|
3066 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
3067 | run0_Callback(hObject, eventdata, handles) |
---|
3068 | end |
---|
3069 | |
---|
3070 | %--------------------------------------------------- |
---|
3071 | % --- Executes on menu selection FieldName |
---|
3072 | function FieldName_1_Callback(hObject, eventdata, handles) |
---|
3073 | %------------------------------------------------- |
---|
3074 | %% read input data |
---|
3075 | check_new=~get(handles.SubField,'Value'); %check_new=1 if a second field was not previously entered |
---|
3076 | UvData=get(handles.uvmat,'UserData'); |
---|
3077 | if check_new && isfield(UvData,'XmlData') |
---|
3078 | UvData.XmlData{2}=UvData.XmlData{1}; |
---|
3079 | end |
---|
3080 | if isfield(UvData,'Field_1') |
---|
3081 | UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read) |
---|
3082 | end |
---|
3083 | UvData.FileName_1='';% desactivate the use of a constant second file |
---|
3084 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
3085 | field= list_fields{get(handles.FieldName,'Value')}; % selected string |
---|
3086 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
3087 | field_1= list_fields{get(handles.FieldName_1,'Value')}; % selected string for the second field |
---|
3088 | if isempty(field_1)%||(numel(UvData.FileType)>=2 && strcmp(UvData.FileType{2},'image')) |
---|
3089 | set(handles.SubField,'Value',0) |
---|
3090 | SubField_Callback(hObject, eventdata, handles) |
---|
3091 | return |
---|
3092 | else |
---|
3093 | set(handles.SubField,'Value',1)%state that a second field is now entered |
---|
3094 | end |
---|
3095 | |
---|
3096 | %% read the rootfile input display |
---|
3097 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
3098 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
3099 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
3100 | switch field_1 |
---|
3101 | case 'get_field...' |
---|
3102 | set_veltype_display(0) % no veltype display |
---|
3103 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
3104 | if ~isempty(hget_field) |
---|
3105 | delete(hget_field) |
---|
3106 | end |
---|
3107 | hget_field=get_field(FileName_1); |
---|
3108 | set(hget_field,'name','get_field_1') |
---|
3109 | hhget_field=guidata(hget_field); |
---|
3110 | set(hhget_field.list_fig,'Value',1) |
---|
3111 | set(hhget_field.list_fig,'String',{'uvmat'}) |
---|
3112 | if check_new |
---|
3113 | UvData.FileType{2}=UvData.FileType{1}; |
---|
3114 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
3115 | set(handles.uvmat,'UserData',UvData) |
---|
3116 | end |
---|
3117 | case 'image' |
---|
3118 | % get the image name corresponding to the current netcdf name (no unique correspondance) |
---|
3119 | if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file |
---|
3120 | imagename=UvData.Field.Civ2_ImageA; |
---|
3121 | elseif isfield(UvData.Field,'Civ1_ImageA')% |
---|
3122 | imagename=UvData.Field.Civ1_ImageA; |
---|
3123 | else |
---|
3124 | SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
3125 | imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1); |
---|
3126 | end |
---|
3127 | if ~exist(imagename,'file') % browse for images if it is not found |
---|
3128 | [FileName,PathName] = uigetfile( ... |
---|
3129 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; |
---|
3130 | '*.jpg',' jpeg image files'; ... |
---|
3131 | '*.png','.png image files'; ... |
---|
3132 | '*.tif','.tif image files'; ... |
---|
3133 | '*.avi;*.AVI','.avi movie files'; ... |
---|
3134 | '*.vol','.volume images (png)'; ... |
---|
3135 | '*.*', 'All Files (*.*)'}, ... |
---|
3136 | 'Pick an image',imagename); |
---|
3137 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
3138 | imagename=[PathName FileName]; |
---|
3139 | end |
---|
3140 | if ~ischar(imagename)% quit if the browser has been closed |
---|
3141 | set(handles.SubField,'Value',0) |
---|
3142 | else %valid browser input: display the selected image |
---|
3143 | set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons |
---|
3144 | set(handles.TitleNpy,'Visible','on') |
---|
3145 | set(handles.num_Npx,'Visible','on') |
---|
3146 | set(handles.num_Npy,'Visible','on') |
---|
3147 | display_file_name(handles,imagename,2)%display the imag |
---|
3148 | end |
---|
3149 | otherwise |
---|
3150 | if check_new |
---|
3151 | UvData.FileType{2}=UvData.FileType{1}; |
---|
3152 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
3153 | set(handles.FileExt_1,'String',get(handles.FileExt,'String')) |
---|
3154 | end |
---|
3155 | if ~isequal(field,'image') |
---|
3156 | set(handles.TitleNpx,'Visible','off')% visible npx,pxcm... buttons |
---|
3157 | set(handles.TitleNpy,'Visible','off') |
---|
3158 | set(handles.num_Npx,'Visible','off') |
---|
3159 | set(handles.num_Npy,'Visible','off') |
---|
3160 | end |
---|
3161 | set(handles.uvmat,'UserData',UvData) |
---|
3162 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
3163 | run0_Callback(hObject, eventdata, handles) |
---|
3164 | end |
---|
3165 | end |
---|
3166 | |
---|
3167 | %------------------------------------------------------------------------ |
---|
3168 | % --- set the visibility of relevant velocity type menus: |
---|
3169 | function menu=set_veltype_display(Civ,FileType) |
---|
3170 | %------------------------------------------------------------------------ |
---|
3171 | if ~exist('FileType','var') |
---|
3172 | FileType='civx'; |
---|
3173 | end |
---|
3174 | switch FileType |
---|
3175 | case 'civx' |
---|
3176 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'}; |
---|
3177 | if isequal(Civ,0) |
---|
3178 | imax=0; |
---|
3179 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
3180 | imax=1; |
---|
3181 | elseif isequal(Civ,3) |
---|
3182 | imax=3; |
---|
3183 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
3184 | imax=4; |
---|
3185 | elseif isequal(Civ,6) %patch2 |
---|
3186 | imax=6; |
---|
3187 | end |
---|
3188 | case 'civdata' |
---|
3189 | menu={'civ1';'filter1';'civ2';'filter2'}; |
---|
3190 | if isequal(Civ,0) |
---|
3191 | imax=0; |
---|
3192 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
3193 | imax=1; |
---|
3194 | elseif isequal(Civ,3) |
---|
3195 | imax=2; |
---|
3196 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
3197 | imax=3; |
---|
3198 | elseif isequal(Civ,6) %patch2 |
---|
3199 | imax=4; |
---|
3200 | end |
---|
3201 | end |
---|
3202 | menu=menu(1:imax); |
---|
3203 | |
---|
3204 | %------------------------------------------------------------------------ |
---|
3205 | % --- Executes on button press in FixVelType. |
---|
3206 | function FixVelType_Callback(hObject, eventdata, handles) |
---|
3207 | %------------------------------------------------------------------------ |
---|
3208 | % refresh the current plot if the fixed veltype is unselected |
---|
3209 | if ~get(handles.FixVelType,'Value') |
---|
3210 | run0_Callback(hObject, eventdata, handles) |
---|
3211 | end |
---|
3212 | |
---|
3213 | %------------------------------------------------------------------------ |
---|
3214 | % --- Executes on button press in VelType. |
---|
3215 | function VelType_Callback(hObject, eventdata, handles) |
---|
3216 | %------------------------------------------------------------------------ |
---|
3217 | set(handles.FixVelType,'Value',1) |
---|
3218 | run0_Callback(hObject, eventdata, handles) |
---|
3219 | |
---|
3220 | %------------------------------------------------------------------------ |
---|
3221 | % --- Executes on choice selection in VelType_1. |
---|
3222 | function VelType_1_Callback(hObject, eventdata, handles) |
---|
3223 | %------------------------------------------------------------------------ |
---|
3224 | set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic) |
---|
3225 | UvData=get(handles.uvmat,'UserData'); |
---|
3226 | set(handles.run0,'BackgroundColor',[1 1 0])%paint run0 button in yellow to indicate its activation |
---|
3227 | drawnow |
---|
3228 | InputFile=read_GUI(handles.InputFile);% read the input file parameters |
---|
3229 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
3230 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
3231 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% name of the first input file |
---|
3232 | |
---|
3233 | check_refresh=0; |
---|
3234 | if isempty(InputFile.VelType_1) |
---|
3235 | FileName_1='';% we plot the first input field without the second field |
---|
3236 | set(handles.SubField,'Value',0) |
---|
3237 | SubField_Callback(hObject, eventdata, handles)% activate SubField_Callback and refresh current display, removing the second field |
---|
3238 | elseif get(handles.SubField,'Value')% if subfield is already 'on' |
---|
3239 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];% name of the second input file |
---|
3240 | check_refresh=1;%will refresh the current display |
---|
3241 | else% we introduce the same file (with a different field) for the second series |
---|
3242 | FileName_1=FileName;% we compare two fields in the same file |
---|
3243 | UvData.FileType{2}=UvData.FileType{1}; |
---|
3244 | UvData.XmlData{2}= UvData.XmlData{1}; |
---|
3245 | set(handles.SubField,'Value',1) |
---|
3246 | transform=get(handles.path_transform,'UserData'); |
---|
3247 | if (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
3248 | set(handles.transform_fct,'value',2); % set transform to sub_field if the current fct doe not accept two input fields |
---|
3249 | transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current display |
---|
3250 | else |
---|
3251 | check_refresh=1; |
---|
3252 | end |
---|
3253 | end |
---|
3254 | |
---|
3255 | % refresh the current display if it has not been done previously |
---|
3256 | if check_refresh |
---|
3257 | UvData.FileName_1='';% desactivate the use of a constant second file |
---|
3258 | set(handles.uvmat,'UserData',UvData) |
---|
3259 | num_i1=stra2num(get(handles.i1,'String')); |
---|
3260 | num_i2=stra2num(get(handles.i2,'String')); |
---|
3261 | num_j1=stra2num(get(handles.j1,'String')); |
---|
3262 | num_j2=stra2num(get(handles.j2,'String')); |
---|
3263 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(['xx' FileIndex_1]); |
---|
3264 | errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
3265 | if ~isempty(errormsg) |
---|
3266 | msgbox_uvmat('ERROR',errormsg); |
---|
3267 | else |
---|
3268 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
3269 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
3270 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
3271 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
3272 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
3273 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
3274 | end |
---|
3275 | set(handles.run0,'BackgroundColor',[1 0 0]) |
---|
3276 | end |
---|
3277 | |
---|
3278 | %----------------------------------------------- |
---|
3279 | % --- reset civ buttons |
---|
3280 | function reset_vel_type(handles_civ0,handle1) |
---|
3281 | for ibutton=1:length(handles_civ0) |
---|
3282 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784]) |
---|
3283 | set(handles_civ0(ibutton),'Value',0) |
---|
3284 | end |
---|
3285 | if exist('handle1','var')%handles of selected button |
---|
3286 | set(handle1,'BackgroundColor',[1 1 0]) |
---|
3287 | end |
---|
3288 | |
---|
3289 | %------------------------------------------------------- |
---|
3290 | % --- Executes on button press in MENUVOLUME. |
---|
3291 | %------------------------------------------------------- |
---|
3292 | function VOLUME_Callback(hObject, eventdata, handles) |
---|
3293 | %errordlg('command VOL not implemented yet') |
---|
3294 | if ishandle(handles.UVMAT_title) |
---|
3295 | delete(handles.UVMAT_title) |
---|
3296 | end |
---|
3297 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
3298 | if isequal(get(handles.VOLUME,'Value'),1) |
---|
3299 | set(handles.CheckZoom,'Value',0) |
---|
3300 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3301 | set(handles.edit_vect,'Value',0) |
---|
3302 | edit_vect_Callback(hObject, eventdata, handles) |
---|
3303 | set(handles.edit_object,'Value',0) |
---|
3304 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3305 | % set(handles.cal,'Value',0) |
---|
3306 | % set(handles.cal,'BackgroundColor',[0 1 0]) |
---|
3307 | set(handles.edit_vect,'Value',0) |
---|
3308 | edit_vect_Callback(hObject, eventdata, handles) |
---|
3309 | %initiate set_object GUI |
---|
3310 | data.Name='VOLUME'; |
---|
3311 | if isfield(UvData,'CoordType') |
---|
3312 | data.CoordType=UvData.CoordType; |
---|
3313 | end |
---|
3314 | if isfield(UvData.Field,'Mesh')&~isempty(UvData.Field.Mesh) |
---|
3315 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
3316 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
3317 | data.DX=UvData.Field.Mesh; |
---|
3318 | data.DY=UvData.Field.Mesh; |
---|
3319 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image |
---|
3320 | np=size(UvData.Field.A); |
---|
3321 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2); |
---|
3322 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1); |
---|
3323 | data.RangeY=max(meshx,meshy); |
---|
3324 | data.RangeX=max(meshx,meshy); |
---|
3325 | data.DX=max(meshx,meshy); |
---|
3326 | end |
---|
3327 | data.ParentButton=handles.VOLUME; |
---|
3328 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters |
---|
3329 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes, |
---|
3330 | % associate the set_object interface handle to the plotting axes |
---|
3331 | set(hset_object,'Position',get(handles.uvmat,'Position')+UvData.OpenParam.PosSetObject) |
---|
3332 | UvData.MouseAction='create_object'; |
---|
3333 | else |
---|
3334 | set(handles.VOLUME,'BackgroundColor',[0 1 0]) |
---|
3335 | end |
---|
3336 | set(handles.uvmat,'UserData',UvData) |
---|
3337 | |
---|
3338 | %------------------------------------------------------- |
---|
3339 | function edit_vect_Callback(hObject, eventdata, handles) |
---|
3340 | %------------------------------------------------------- |
---|
3341 | % |
---|
3342 | % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
3343 | if isequal(get(handles.edit_vect,'Value'),1) |
---|
3344 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); |
---|
3345 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]); |
---|
3346 | if ~test_civ2 && ~test_civ1 |
---|
3347 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
3348 | end |
---|
3349 | set(handles.record,'Visible','on') |
---|
3350 | set(handles.edit_vect,'BackgroundColor',[1 1 0]) |
---|
3351 | set(handles.edit_object,'Value',0) |
---|
3352 | set(handles.CheckZoom,'Value',0) |
---|
3353 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3354 | % set(handles.create,'Value',0) |
---|
3355 | % set(handles.create,'BackgroundColor',[0 1 0]) |
---|
3356 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3357 | set(gcf,'Pointer','arrow') |
---|
3358 | % UvData.MouseAction='edit_vect'; |
---|
3359 | else |
---|
3360 | set(handles.record,'Visible','off') |
---|
3361 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3362 | end |
---|
3363 | |
---|
3364 | %---------------------------------------------- |
---|
3365 | function save_mask_Callback(hObject, eventdata, handles) |
---|
3366 | %----------------------------------------------------------------------- |
---|
3367 | UvData=get(handles.uvmat,'UserData'); |
---|
3368 | |
---|
3369 | flag=1; |
---|
3370 | npx=size(UvData.Field.A,2); |
---|
3371 | npy=size(UvData.Field.A,1); |
---|
3372 | xi=0.5:npx-0.5; |
---|
3373 | yi=0.5:npy-0.5; |
---|
3374 | [Xi,Yi]=meshgrid(xi,yi); |
---|
3375 | if isfield(UvData,'Object') |
---|
3376 | for iobj=1:length(UvData.Object) |
---|
3377 | ObjectData=UvData.Object{iobj}; |
---|
3378 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
3379 | flagobj=1; |
---|
3380 | testphys=0; %coordinates in pixels by default |
---|
3381 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys') |
---|
3382 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
3383 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
3384 | testphys=1; |
---|
3385 | end |
---|
3386 | end |
---|
3387 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style') |
---|
3388 | if isequal(ObjectData.Type,'polygon') |
---|
3389 | X=ObjectData.Coord(:,1); |
---|
3390 | Y=ObjectData.Coord(:,2); |
---|
3391 | if testphys |
---|
3392 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases |
---|
3393 | end |
---|
3394 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
3395 | elseif isequal(ObjectData.Type,'ellipse') |
---|
3396 | if testphys |
---|
3397 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
3398 | end |
---|
3399 | RangeX=max(ObjectData.RangeX); |
---|
3400 | RangeY=max(ObjectData.RangeY); |
---|
3401 | X2Max=RangeX*RangeX; |
---|
3402 | Y2Max=RangeY*RangeY; |
---|
3403 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
3404 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
3405 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
3406 | elseif isequal(ObjectData.Type,'rectangle') |
---|
3407 | if testphys |
---|
3408 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
3409 | end |
---|
3410 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
3411 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
3412 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
3413 | end |
---|
3414 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
3415 | flagobj=~flagobj; |
---|
3416 | end |
---|
3417 | flag=flag & flagobj; |
---|
3418 | end |
---|
3419 | end |
---|
3420 | end |
---|
3421 | end |
---|
3422 | % flag=~flag; |
---|
3423 | %mask name |
---|
3424 | RootPath=get(handles.RootPath,'String'); |
---|
3425 | RootFile=get(handles.RootFile,'String'); |
---|
3426 | RootFile=regexprep(RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
3427 | filebase=fullfile(RootPath,RootFile); |
---|
3428 | list=get(handles.masklevel,'String'); |
---|
3429 | masknumber=num2str(length(list)); |
---|
3430 | maskindex=get(handles.masklevel,'Value'); |
---|
3431 | mask_name=fullfile_uvmat(RootPath,SubDir,[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
3432 | %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); |
---|
3433 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
3434 | imflag=flipdim(imflag,1); |
---|
3435 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200) |
---|
3436 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved']) |
---|
3437 | imwrite(imflag,mask_name,'BitDepth',8); |
---|
3438 | |
---|
3439 | %display the mask |
---|
3440 | figure; |
---|
3441 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
3442 | map=[vec' vec' vec']; |
---|
3443 | colormap(map) |
---|
3444 | |
---|
3445 | image(imflag); |
---|
3446 | |
---|
3447 | %------------------------------------------------------------------- |
---|
3448 | %------------------------------------------------------------------- |
---|
3449 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS |
---|
3450 | |
---|
3451 | %------------------------------------------------------------------ |
---|
3452 | %------------------------------------------------------------- |
---|
3453 | % --- Executes on selection change in transform_fct. |
---|
3454 | |
---|
3455 | function transform_fct_Callback(hObject, eventdata, handles) |
---|
3456 | %------------------------------------------------------------- |
---|
3457 | UvData=get(handles.uvmat,'UserData'); |
---|
3458 | menu=get(handles.transform_fct,'String');refresh |
---|
3459 | ichoice=get(handles.transform_fct,'Value');%item number in the menu |
---|
3460 | transform_name=menu{ichoice};% choice of the transform fct |
---|
3461 | list_path=get(handles.transform_fct,'UserData'); |
---|
3462 | |
---|
3463 | %% add a new item to the menu if the option 'more...' has been selected |
---|
3464 | prev_path=fullfile(get(handles.path_transform,'String')); |
---|
3465 | if ~exist(prev_path,'dir') |
---|
3466 | prev_path=fullfile(fileparts(which('uvmat')),'transform_field'); |
---|
3467 | end |
---|
3468 | if strcmp(transform_name,'more...'); |
---|
3469 | [FileName, PathName] = uigetfile( ... |
---|
3470 | {'*.m', ' (*.m)'; |
---|
3471 | '*.m', '.m files '; ... |
---|
3472 | '*.*', 'All Files (*.*)'}, ... |
---|
3473 | 'Pick the transform function', prev_path); |
---|
3474 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
3475 | path_transform_fct =fullfile(PathName,FileName); |
---|
3476 | if isempty(regexp(FileName,'.m$'))% detect file extension .m |
---|
3477 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
3478 | return |
---|
3479 | else |
---|
3480 | transform_name=regexprep(FileName,'.m',''); |
---|
3481 | end |
---|
3482 | ichoice=find(strcmp(transform_name,menu),1);%look for the selected fct in the existing menu |
---|
3483 | if isempty(ichoice)% if the item is not found, add it to the menu (before 'more...' and select it) |
---|
3484 | menu=[menu(1:end-1);{transform_name};{'more...'}]; |
---|
3485 | ichoice=numel(menu)-1; |
---|
3486 | end |
---|
3487 | list_path{ichoice}=PathName;%update the list fo fct paths |
---|
3488 | set(handles.transform_fct,'String',menu) |
---|
3489 | set(handles.transform_fct,'Value',ichoice) |
---|
3490 | |
---|
3491 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
3492 | dir_perso=prefdir;%personal Matalb directory |
---|
3493 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
3494 | if exist(profil_perso,'file') |
---|
3495 | nb_builtin=UvData.OpenParam.NbBuiltin;% number of 'builtin' (basic) transform fcts in uvmat |
---|
3496 | if nb_builtin<numel(list_path) |
---|
3497 | for ilist=nb_builtin+1:numel(list_path) |
---|
3498 | transform_fct{ilist-nb_builtin}=[fullfile(list_path{ilist},menu{ilist}) '.m']; |
---|
3499 | end |
---|
3500 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
3501 | end |
---|
3502 | end |
---|
3503 | end |
---|
3504 | |
---|
3505 | %% create the function handle of the selected fct |
---|
3506 | |
---|
3507 | if isempty(list_path{ichoice})% case of no selected fct |
---|
3508 | transform_handle=[]; |
---|
3509 | else |
---|
3510 | if ~exist(list_path{ichoice},'dir') |
---|
3511 | msgbox_uvmat('ERROR','invalid fct path: select the transform fct again with the option more...') |
---|
3512 | return |
---|
3513 | end |
---|
3514 | current_dir=pwd;%current working dir |
---|
3515 | cd(list_path{ichoice}) |
---|
3516 | transform_handle=str2func(transform_name); |
---|
3517 | cd(current_dir) |
---|
3518 | end |
---|
3519 | set(handles.path_transform,'String',list_path{ichoice}) |
---|
3520 | set(handles.path_transform,'UserData',transform_handle) |
---|
3521 | set(handles.transform_fct,'UserData',list_path) |
---|
3522 | |
---|
3523 | %% update the ToolTip string of the menu transform_fct with the first line of the selected fct file |
---|
3524 | if isempty(list_path{ichoice})% case of no selected fct |
---|
3525 | set(handles.transform_fct,'ToolTipString','transform_fct:choose a transform function') |
---|
3526 | else |
---|
3527 | try |
---|
3528 | [fid,errormsg] =fopen([fullfile(list_path{ichoice},transform_name) '.m']); |
---|
3529 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
3530 | fclose(fid) |
---|
3531 | set(handles.transform_fct,'ToolTipString',['transform_fct: ' InputText{1}{1}])% put the first line of the selected function as tooltip help |
---|
3532 | end |
---|
3533 | end |
---|
3534 | |
---|
3535 | %% adapt the GUI to the input/output conditions of the selected transform fct |
---|
3536 | DataOut=[]; |
---|
3537 | CoordUnit=''; |
---|
3538 | CoordUnitPrev=''; |
---|
3539 | if isfield(UvData,'Field')&&isfield(UvData.Field,'CoordUnit') |
---|
3540 | CoordUnitPrev=UvData.Field.CoordUnit; |
---|
3541 | end |
---|
3542 | if ~isempty(list_path{ichoice}) |
---|
3543 | if nargin(transform_handle)>1 && isfield(UvData,'XmlData')&&~isempty(UvData.XmlData) |
---|
3544 | XmlData=UvData.XmlData{1}; |
---|
3545 | DataOut=feval(transform_handle,'*',XmlData); |
---|
3546 | if isfield(DataOut,'CoordUnit') |
---|
3547 | CoordUnit=DataOut.CoordUnit; |
---|
3548 | end |
---|
3549 | if isfield(DataOut,'InputFieldType') |
---|
3550 | UvData.InputFieldType=DataOut.InputFieldType; |
---|
3551 | end |
---|
3552 | else |
---|
3553 | DataOut=feval(transform_handle,'*'); |
---|
3554 | end |
---|
3555 | end |
---|
3556 | |
---|
3557 | set(handles.CheckFixLimits,'Value',0) |
---|
3558 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3559 | |
---|
3560 | %% delete drawn objects if the output CooordUnit is different from the previous one |
---|
3561 | if ~strcmp(CoordUnit,CoordUnitPrev) |
---|
3562 | hother=findobj('Tag','proj_object');%find all the proj objects |
---|
3563 | for iobj=1:length(hother) |
---|
3564 | delete_object(hother(iobj)) |
---|
3565 | end |
---|
3566 | hother=findobj('Tag','DeformPoint');%find all the proj objects |
---|
3567 | for iobj=1:length(hother) |
---|
3568 | delete_object(hother(iobj)) |
---|
3569 | end |
---|
3570 | hh=findobj('Tag','calib_points'); |
---|
3571 | if ~isempty(hh) |
---|
3572 | delete(hh) |
---|
3573 | end |
---|
3574 | hhh=findobj('Tag','calib_marker'); |
---|
3575 | if ~isempty(hhh) |
---|
3576 | delete(hhh) |
---|
3577 | end |
---|
3578 | % if isfield(UvData,'Object') |
---|
3579 | % UvData.Object=UvData.Object(1); |
---|
3580 | % end |
---|
3581 | set(handles.ListObject,'Value',1) |
---|
3582 | set(handles.ListObject,'String',{''}) |
---|
3583 | set(handles.ListObject_1,'Value',1) |
---|
3584 | set(handles.ListObject_1,'String',{''}) |
---|
3585 | set(handles.ViewObject,'value',0) |
---|
3586 | ViewObject_Callback(hObject, eventdata, handles) |
---|
3587 | set(handles.ViewField,'value',0) |
---|
3588 | ViewField_Callback(hObject, eventdata, handles) |
---|
3589 | set(handles.edit_object,'Value',0) |
---|
3590 | edit_object_Callback(hObject, eventdata, handles) |
---|
3591 | UvData.Object={[]}; |
---|
3592 | end |
---|
3593 | set(handles.uvmat,'UserData',UvData) |
---|
3594 | |
---|
3595 | %% refresh the current plot |
---|
3596 | if isempty(list_path{ichoice}) || nargin(transform_handle)<3 |
---|
3597 | set(handles.SubField,'Value',0) |
---|
3598 | SubField_Callback(hObject, eventdata, handles) |
---|
3599 | else |
---|
3600 | run0_Callback(hObject, eventdata, handles) |
---|
3601 | end |
---|
3602 | |
---|
3603 | %------------------------------------------------ |
---|
3604 | %CALLBACKS FOR PLOTTING PARAMETERS |
---|
3605 | %------------------------------------------------- |
---|
3606 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3607 | % Plot coordinates |
---|
3608 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3609 | %------------------------------------------------------------------------ |
---|
3610 | function num_MinX_Callback(hObject, eventdata, handles) |
---|
3611 | %------------------------------------------------------------------------ |
---|
3612 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
3613 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
3614 | update_plot(handles); |
---|
3615 | |
---|
3616 | %------------------------------------------------------------------------ |
---|
3617 | function num_MaxX_Callback(hObject, eventdata, handles) |
---|
3618 | %------------------------------------------------------------------------ |
---|
3619 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
3620 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
3621 | update_plot(handles); |
---|
3622 | |
---|
3623 | %------------------------------------------------------------------------ |
---|
3624 | function num_MinY_Callback(hObject, eventdata, handles) |
---|
3625 | %------------------------------------------ |
---|
3626 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
3627 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
3628 | update_plot(handles); |
---|
3629 | |
---|
3630 | %------------------------------------------------------------------------ |
---|
3631 | function num_MaxY_Callback(hObject, eventdata, handles) |
---|
3632 | %------------------------------------------------------------------------ |
---|
3633 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
3634 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
3635 | update_plot(handles); |
---|
3636 | |
---|
3637 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3638 | % Scalar or image representation |
---|
3639 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3640 | %------------------------------------------------------------------------ |
---|
3641 | function num_MinA_Callback(hObject, eventdata, handles) |
---|
3642 | %------------------------------------------ |
---|
3643 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
3644 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
3645 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
3646 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
3647 | if MinA>MaxA% switch minA and maxA in case of error |
---|
3648 | MinA_old=MinA; |
---|
3649 | MinA=MaxA; |
---|
3650 | MaxA=MinA_old; |
---|
3651 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
3652 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
3653 | end |
---|
3654 | update_plot(handles); |
---|
3655 | |
---|
3656 | %------------------------------------------------------------------------ |
---|
3657 | function num_MaxA_Callback(hObject, eventdata, handles) |
---|
3658 | %------------------------------------------------------------------------ |
---|
3659 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
3660 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
3661 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
3662 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
3663 | if MinA>MaxA% switch minA and maxA in case of error |
---|
3664 | MinA_old=MinA; |
---|
3665 | MinA=MaxA; |
---|
3666 | MaxA=MinA_old; |
---|
3667 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
3668 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
3669 | end |
---|
3670 | update_plot(handles); |
---|
3671 | |
---|
3672 | %------------------------------------------------------------------------ |
---|
3673 | function CheckFixScalar_Callback(hObject, eventdata, handles) |
---|
3674 | %------------------------------------------------------------------------ |
---|
3675 | test=get(handles.CheckFixScalar,'Value'); |
---|
3676 | if test |
---|
3677 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
3678 | else |
---|
3679 | set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3680 | update_plot(handles); |
---|
3681 | end |
---|
3682 | |
---|
3683 | %------------------------------------------------------------------- |
---|
3684 | function CheckBW_Callback(hObject, eventdata, handles) |
---|
3685 | %------------------------------------------------------------------- |
---|
3686 | update_plot(handles); |
---|
3687 | |
---|
3688 | %------------------------------------------------------------------- |
---|
3689 | function num_Opacity_Callback(hObject, eventdata, handles) |
---|
3690 | update_plot(handles); |
---|
3691 | %------------------------------------------------------------------- |
---|
3692 | |
---|
3693 | %------------------------------------------------------------------- |
---|
3694 | function ListContour_Callback(hObject, eventdata, handles) |
---|
3695 | %------------------------------------------------------------------- |
---|
3696 | val=get(handles.ListContour,'Value'); |
---|
3697 | if val==2 |
---|
3698 | set(handles.interval_txt,'Visible','on') |
---|
3699 | set(handles.num_IncrA,'Visible','on') |
---|
3700 | else |
---|
3701 | set(handles.interval_txt,'Visible','off') |
---|
3702 | set(handles.num_IncrA,'Visible','off') |
---|
3703 | end |
---|
3704 | update_plot(handles); |
---|
3705 | |
---|
3706 | %------------------------------------------------------------------- |
---|
3707 | function num_IncrA_Callback(hObject, eventdata, handles) |
---|
3708 | %------------------------------------------------------------------- |
---|
3709 | update_plot(handles); |
---|
3710 | |
---|
3711 | |
---|
3712 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3713 | % Vector representation |
---|
3714 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3715 | %------------------------------------------------------------------- |
---|
3716 | function CheckHideWarning_Callback(hObject, eventdata, handles) |
---|
3717 | %------------------------------------------------------------------- |
---|
3718 | update_plot(handles); |
---|
3719 | |
---|
3720 | %------------------------------------------------------------------- |
---|
3721 | function CheckHideFalse_Callback(hObject, eventdata, handles) |
---|
3722 | %------------------------------------------------------------------- |
---|
3723 | update_plot(handles); |
---|
3724 | |
---|
3725 | %------------------------------------------------------------------- |
---|
3726 | function num_VecScale_Callback(hObject, eventdata, handles) |
---|
3727 | %------------------------------------------------------------------- |
---|
3728 | set(handles.CheckFixVectors,'Value',1); |
---|
3729 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
3730 | update_plot(handles); |
---|
3731 | |
---|
3732 | %------------------------------------------------------------------- |
---|
3733 | function CheckFixVectors_Callback(hObject, eventdata, handles) |
---|
3734 | %------------------------------------------------------------------- |
---|
3735 | test=get(handles.CheckFixVectors,'Value'); |
---|
3736 | if test |
---|
3737 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
3738 | else |
---|
3739 | update_plot(handles); |
---|
3740 | %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3)) |
---|
3741 | set(handles.CheckFixVectors,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3742 | end |
---|
3743 | |
---|
3744 | %------------------------------------------------------------------------ |
---|
3745 | % --- Executes on selection change in CheckDecimate4 (nb_vec/4). |
---|
3746 | function CheckDecimate4_Callback(hObject, eventdata, handles) |
---|
3747 | %------------------------------------------------------------------------ |
---|
3748 | update_plot(handles); |
---|
3749 | |
---|
3750 | %------------------------------------------------------------------------ |
---|
3751 | % --- Executes on selection change in ColorCode menu |
---|
3752 | function ColorCode_Callback(hObject, eventdata, handles) |
---|
3753 | %------------------------------------------------------------------------ |
---|
3754 | % edit the choice for color code |
---|
3755 | update_color_code_boxes(handles); |
---|
3756 | update_plot(handles); |
---|
3757 | |
---|
3758 | %------------------------------------------------------------------------ |
---|
3759 | function update_color_code_boxes(handles) |
---|
3760 | %------------------------------------------------------------------------ |
---|
3761 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
3762 | colcode= list_code{get(handles.ColorCode,'Value')}; % selected field |
---|
3763 | enable_slider='off';%default |
---|
3764 | enable_bounds='off';%default |
---|
3765 | enable_scalar='off';%default |
---|
3766 | switch colcode |
---|
3767 | case {'rgb','bgr'} |
---|
3768 | enable_slider='on'; |
---|
3769 | enable_bounds='on'; |
---|
3770 | enable_scalar='on'; |
---|
3771 | case '64 colors' |
---|
3772 | enable_bounds='on'; |
---|
3773 | enable_scalar='on'; |
---|
3774 | end |
---|
3775 | set(handles.Slider1,'Visible',enable_slider) |
---|
3776 | set(handles.Slider2,'Visible', enable_slider) |
---|
3777 | set(handles.num_ColCode1,'Visible',enable_slider) |
---|
3778 | set(handles.num_ColCode2,'Visible',enable_slider) |
---|
3779 | set(handles.TitleColCode1,'Visible',enable_slider) |
---|
3780 | set(handles.TitleColCode2,'Visible',enable_slider) |
---|
3781 | set(handles.CheckFixVecColor,'Visible',enable_bounds) |
---|
3782 | set(handles.num_MinVec,'Visible',enable_bounds) |
---|
3783 | set(handles.num_MaxVec,'Visible',enable_bounds) |
---|
3784 | set(handles.ColorScalar,'Visible',enable_scalar) |
---|
3785 | set_vec_col_bar(handles) |
---|
3786 | |
---|
3787 | %------------------------------------------------------------------ |
---|
3788 | % --- Executes on selection change in ColorScalar: choice of the color code. |
---|
3789 | function ColorScalar_Callback(hObject, eventdata, handles) |
---|
3790 | %------------------------------------------------------------------ |
---|
3791 | % edit the choice for color code |
---|
3792 | list_scalar=get(handles.ColorScalar,'String');% list menu fields |
---|
3793 | col_scalar= list_scalar{get(handles.ColorScalar,'Value')}; % selected field |
---|
3794 | if isequal(col_scalar,'ima_cor') |
---|
3795 | set(handles.CheckFixVecColor,'Value',1)%fixed scale by default |
---|
3796 | ColorCode='rgb'; |
---|
3797 | set(handles.num_MinVec,'String','0') |
---|
3798 | set(handles.num_MaxVec,'String','1') |
---|
3799 | set(handles.num_ColCode1,'String','0.333') |
---|
3800 | set(handles.num_ColCode2,'String','0.666') |
---|
3801 | else |
---|
3802 | set(handles.CheckFixVecColor,'Value',0)%auto scale between min,max by default |
---|
3803 | ColorCode='64 colors'; |
---|
3804 | end |
---|
3805 | ColorCodeList=get(handles.ColorCode,'String'); |
---|
3806 | ichoice=find(strcmp(ColorCode,ColorCodeList),1); |
---|
3807 | set(handles.ColorCode,'Value',ichoice)% set color code in the menu |
---|
3808 | |
---|
3809 | update_color_code_boxes(handles); |
---|
3810 | %replot the current graph |
---|
3811 | run0_Callback(hObject, eventdata, handles) |
---|
3812 | |
---|
3813 | %---------------------------------------------------------------- |
---|
3814 | % -- Executes on slider movement to set the color code |
---|
3815 | % |
---|
3816 | function Slider1_Callback(hObject, eventdata, handles) |
---|
3817 | %------------------------------------------------------------------ |
---|
3818 | slider1=get(handles.Slider1,'Value'); |
---|
3819 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
3820 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
3821 | col=min_val+(max_val-min_val)*slider1; |
---|
3822 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
3823 | if(get(handles.Slider2,'Value') < col)%move also the second slider at the same value if needed |
---|
3824 | set(handles.Slider2,'Value',col) |
---|
3825 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
3826 | end |
---|
3827 | set_vec_col_bar(handles) |
---|
3828 | update_plot(handles); |
---|
3829 | |
---|
3830 | %---------------------------------------------------------------- |
---|
3831 | % Executes on slider movement to set the color code |
---|
3832 | %---------------------------------------------------------------- |
---|
3833 | function Slider2_Callback(hObject, eventdata, handles) |
---|
3834 | slider2=get(handles.Slider2,'Value'); |
---|
3835 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
3836 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
3837 | col=min_val+(max_val-min_val)*slider2; |
---|
3838 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
3839 | if(get(handles.Slider1,'Value') > col)%move also the first slider at the same value if needed |
---|
3840 | set(handles.Slider1,'Value',col) |
---|
3841 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
3842 | end |
---|
3843 | set_vec_col_bar(handles) |
---|
3844 | update_plot(handles); |
---|
3845 | |
---|
3846 | %---------------------------------------------------------------- |
---|
3847 | % --- Execute on return carriage on the edit box corresponding to slider 1 |
---|
3848 | %---------------------------------------------------------------- |
---|
3849 | function num_ColCode1_Callback(hObject, eventdata, handles) |
---|
3850 | set_vec_col_bar(handles) |
---|
3851 | update_plot(handles); |
---|
3852 | |
---|
3853 | %---------------------------------------------------------------- |
---|
3854 | % --- Execute on return carriage on the edit box corresponding to slider 2 |
---|
3855 | %---------------------------------------------------------------- |
---|
3856 | function num_ColCode2_Callback(hObject, eventdata, handles) |
---|
3857 | set_vec_col_bar(handles) |
---|
3858 | update_plot(handles); |
---|
3859 | %------------------------------------------------------------------------ |
---|
3860 | %------------------------------------------------------- |
---|
3861 | % --- Executes on button press in CheckFixVecColor. |
---|
3862 | %------------------------------------------------------- |
---|
3863 | function VecColBar_Callback(hObject, eventdata, handles) |
---|
3864 | set_vec_col_bar(handles) |
---|
3865 | |
---|
3866 | %------------------------------------------------------------------------ |
---|
3867 | % --- Executes on button press in CheckFixVecColor. |
---|
3868 | function CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
3869 | %------------------------------------------------------------------------ |
---|
3870 | if ~get(handles.CheckFixVecColor,'Value') |
---|
3871 | update_plot(handles); |
---|
3872 | end |
---|
3873 | |
---|
3874 | %------------------------------------------------------------------------ |
---|
3875 | % --- Executes on selection change in num_MaxVec. |
---|
3876 | function num_MinVec_Callback(hObject, eventdata, handles) |
---|
3877 | %------------------------------------------------------------------------ |
---|
3878 | max_vec_Callback(hObject, eventdata, handles) |
---|
3879 | |
---|
3880 | %------------------------------------------------------------------------ |
---|
3881 | % --- Executes on selection change in num_MaxVec. |
---|
3882 | function num_MaxVec_Callback(hObject, eventdata, handles) |
---|
3883 | %------------------------------------------------------------------------ |
---|
3884 | set(handles.CheckFixVecColor,'Value',1) |
---|
3885 | CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
3886 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
3887 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
3888 | slider1=get(handles.Slider1,'Value'); |
---|
3889 | slider2=get(handles.Slider2,'Value'); |
---|
3890 | colcode1=min_val+(max_val-min_val)*slider1; |
---|
3891 | colcode2=min_val+(max_val-min_val)*slider2; |
---|
3892 | set(handles.num_ColCode1,'String',num2str(colcode1)) |
---|
3893 | set(handles.num_ColCode2,'String',num2str(colcode2)) |
---|
3894 | update_plot(handles); |
---|
3895 | |
---|
3896 | %------------------------------------------------------------------------ |
---|
3897 | % --- update the display of color code for vectors (on vecColBar) |
---|
3898 | function set_vec_col_bar(handles) |
---|
3899 | %------------------------------------------------------------------------ |
---|
3900 | %get the image of the color display button 'VecColBar' in pixels |
---|
3901 | set(handles.VecColBar,'Unit','pixel'); |
---|
3902 | pos_vert=get(handles.VecColBar,'Position'); |
---|
3903 | set(handles.VecColBar,'Unit','Normalized'); |
---|
3904 | width=ceil(pos_vert(3)); |
---|
3905 | height=ceil(pos_vert(4)); |
---|
3906 | |
---|
3907 | %get slider indications |
---|
3908 | list=get(handles.ColorCode,'String'); |
---|
3909 | ichoice=get(handles.ColorCode,'Value'); |
---|
3910 | colcode.ColorCode=list{ichoice}; |
---|
3911 | colcode.MinVec=str2num(get(handles.num_MinVec,'String')); |
---|
3912 | colcode.MaxVec=str2num(get(handles.num_MaxVec,'String')); |
---|
3913 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr'); |
---|
3914 | if test3color |
---|
3915 | colcode.ColCode1=str2num(get(handles.num_ColCode1,'String')); |
---|
3916 | colcode.ColCode2=str2num(get(handles.num_ColCode2,'String')); |
---|
3917 | end |
---|
3918 | vec_C=colcode.MinVec+(colcode.MaxVec-colcode.MinVec)*(0.5:width-0.5)/width;%sample of vec_C values from min to max |
---|
3919 | [colorlist,col_vec]=set_col_vec(colcode,vec_C); |
---|
3920 | oneheight=ones(1,height); |
---|
3921 | A1=colorlist(col_vec,1)*oneheight; |
---|
3922 | A2=colorlist(col_vec,2)*oneheight; |
---|
3923 | A3=colorlist(col_vec,3)*oneheight; |
---|
3924 | A(:,:,1)=A1'; |
---|
3925 | A(:,:,2)=A2'; |
---|
3926 | A(:,:,3)=A3'; |
---|
3927 | set(handles.VecColBar,'Cdata',A) |
---|
3928 | |
---|
3929 | %------------------------------------------------------------------- |
---|
3930 | function update_plot(handles) |
---|
3931 | %------------------------------------------------------------------- |
---|
3932 | UvData=get(handles.uvmat,'UserData'); |
---|
3933 | AxeData=UvData.PlotAxes;% retrieve the current plotted data |
---|
3934 | PlotParam=read_GUI(handles.uvmat); |
---|
3935 | [tild,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam); |
---|
3936 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters |
---|
3937 | |
---|
3938 | %------------------------------------------------------------------------ |
---|
3939 | %------------------------------------------------------------------------ |
---|
3940 | % SELECTION AND EDITION OF PROJECTION OBJECTS |
---|
3941 | %------------------------------------------------------------------------ |
---|
3942 | %------------------------------------------------------------------------ |
---|
3943 | |
---|
3944 | % --- Executes on selection change in ListObject_1. |
---|
3945 | function ListObject_1_Callback(hObject, eventdata, handles) |
---|
3946 | list_str=get(handles.ListObject,'String'); |
---|
3947 | UvData=get(handles.uvmat,'UserData'); |
---|
3948 | ObjectData=UvData.Object{get(handles.ListObject_1,'Value')}; |
---|
3949 | |
---|
3950 | %% update the projection plot on uvmat |
---|
3951 | ProjData= proj_field(UvData.Field,ObjectData);%project the current input field on object ObjectData |
---|
3952 | plot_field(ProjData,handles.PlotAxes,read_GUI(handles.uvmat));% plot the projected field; |
---|
3953 | %replot all the objects within the new projected field |
---|
3954 | for IndexObj=1:numel(list_str) |
---|
3955 | hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat; |
---|
3956 | if isempty(hobject) || ~ishandle(hobject) |
---|
3957 | hobject=handles.PlotAxes; |
---|
3958 | end |
---|
3959 | if isequal(IndexObj,get(handles.ListObject,'Value')) |
---|
3960 | objectcolor='m'; %paint in magenta the currently selected object in ListObject |
---|
3961 | else |
---|
3962 | objectcolor='b'; |
---|
3963 | end |
---|
3964 | UvData.Object{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.Object{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat |
---|
3965 | end |
---|
3966 | set(handles.uvmat,'UserData',UvData) |
---|
3967 | |
---|
3968 | %% display the object parameters if the GUI set_object is already opened |
---|
3969 | if ~get(handles.ViewObject,'Value') |
---|
3970 | ZBounds=0; % default |
---|
3971 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
3972 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
3973 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
3974 | end |
---|
3975 | ObjectData.Name=list_str{get(handles.ListObject_1,'Value')}; |
---|
3976 | set_object(ObjectData,[],ZBounds); |
---|
3977 | set(handles.ViewObject,'Value',1)% show that the selected object in ListObject_1 is currently visualised |
---|
3978 | end |
---|
3979 | |
---|
3980 | % desactivate the edit object mode |
---|
3981 | set(handles.edit_object,'Value',0) |
---|
3982 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
3983 | |
---|
3984 | %------------------------------------------------------------------------ |
---|
3985 | % --- Executes on selection change in ListObject. |
---|
3986 | function ListObject_Callback(hObject, eventdata, handles) |
---|
3987 | %------------------------------------------------------------------------ |
---|
3988 | list_str=get(handles.ListObject,'String'); |
---|
3989 | IndexObj=get(handles.ListObject,'Value');%present object selection |
---|
3990 | |
---|
3991 | %% The object is displayed in set_object if this GUI is already opened |
---|
3992 | UvData=get(handles.uvmat,'UserData'); |
---|
3993 | ObjectData=UvData.Object{IndexObj}; |
---|
3994 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
3995 | if ~isempty(hset_object) |
---|
3996 | ZBounds=0; % default |
---|
3997 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
3998 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
3999 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
4000 | end |
---|
4001 | ObjectData.Name=list_str{IndexObj}; |
---|
4002 | set_object(ObjectData,[],ZBounds); |
---|
4003 | set(handles.ViewField,'Value',1)% show that the selected object in ListObject is currently visualised |
---|
4004 | end |
---|
4005 | |
---|
4006 | %% desactivate the edit object mode |
---|
4007 | set(handles.edit_object,'Value',0) |
---|
4008 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
4009 | |
---|
4010 | %% update the plot on view_field if view_field is already openened |
---|
4011 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
4012 | if isempty(hview_field) |
---|
4013 | hhview_field.PlotAxes=[]; |
---|
4014 | else |
---|
4015 | Data=get(hview_field,'UserData'); |
---|
4016 | hhview_field=guidata(hview_field); |
---|
4017 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData |
---|
4018 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the uvmat interfachhview_fiel |
---|
4019 | write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
4020 | haxes=findobj(hview_field,'tag','axes3'); |
---|
4021 | pos=get(hview_field,'Position'); |
---|
4022 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
4023 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
4024 | pos_table=get(h_TableDisplay,'Position'); |
---|
4025 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
4026 | drawnow% needed to change position before the next command |
---|
4027 | set(hview_field,'UserData',Data);% restore the previously stored GUI position after GUI resizing |
---|
4028 | else |
---|
4029 | set(hview_field,'Position',Data.GUISize)% return to the previously stored GUI position and size |
---|
4030 | end |
---|
4031 | end |
---|
4032 | |
---|
4033 | %% update the color of the graphic object representation: the selected object in magenta, others in blue |
---|
4034 | update_object_color(handles.PlotAxes,hhview_field.PlotAxes,UvData.Object{IndexObj}.DisplayHandle.uvmat) |
---|
4035 | |
---|
4036 | %------------------------------------------------------------------------ |
---|
4037 | %--- update the color representation of objects (indicating the selected ones) |
---|
4038 | function update_object_color(axes_uvmat,axes_view_field,DisplayHandle) |
---|
4039 | %------------------------------------------------------------------------ |
---|
4040 | if isempty(axes_view_field)% case with no view_field plot |
---|
4041 | hother=[findobj(axes_uvmat,'Tag','proj_object');findobj(axes_uvmat,'Tag','DeformPoint')];%find all the proj object and deform point representations |
---|
4042 | else |
---|
4043 | hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object');... %find all the proj object representations |
---|
4044 | findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];%find all the deform point representations |
---|
4045 | end |
---|
4046 | for iobj=1:length(hother) |
---|
4047 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') |
---|
4048 | set(hother(iobj),'EdgeColor','b') |
---|
4049 | if isequal(get(hother(iobj),'FaceColor'),'m') |
---|
4050 | set(hother(iobj),'FaceColor','b') |
---|
4051 | end |
---|
4052 | elseif isequal(get(hother(iobj),'Type'),'image') |
---|
4053 | Acolor=get(hother(iobj),'CData'); |
---|
4054 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); |
---|
4055 | set(hother(iobj),'CData',Acolor); |
---|
4056 | else |
---|
4057 | set(hother(iobj),'Color','b') |
---|
4058 | end |
---|
4059 | set(hother(iobj),'Selected','off') |
---|
4060 | end |
---|
4061 | if ishandle(DisplayHandle) |
---|
4062 | linetype=get(DisplayHandle,'Type'); |
---|
4063 | if isequal(linetype,'line') |
---|
4064 | set(DisplayHandle,'Color','m'); %set the selected object to magenta color |
---|
4065 | elseif isequal(linetype,'rectangle') |
---|
4066 | set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color |
---|
4067 | elseif isequal(linetype,'patch') |
---|
4068 | set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color |
---|
4069 | end |
---|
4070 | SubObjectData=get(DisplayHandle,'UserData'); |
---|
4071 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject) |
---|
4072 | for iobj=1:length(SubObjectData.SubObject) |
---|
4073 | hsub=SubObjectData.SubObject(iobj); |
---|
4074 | if isequal(get(hsub,'Type'),'rectangle') |
---|
4075 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color |
---|
4076 | elseif isequal(get(hsub,'Type'),'image') |
---|
4077 | Acolor=get(hsub,'CData'); |
---|
4078 | Acolor(:,:,1)=Acolor(:,:,3); |
---|
4079 | set(hsub,'CData',Acolor); |
---|
4080 | else |
---|
4081 | set(hsub,'Color','m') |
---|
4082 | end |
---|
4083 | end |
---|
4084 | end |
---|
4085 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint) |
---|
4086 | set(SubObjectData.DeformPoint,'Color','m') |
---|
4087 | end |
---|
4088 | end |
---|
4089 | |
---|
4090 | %------------------------------------------------------------------- |
---|
4091 | % --- Executes on selection change in edit_object. |
---|
4092 | function edit_object_Callback(hObject, eventdata, handles) |
---|
4093 | %------------------------------------------------------------------- |
---|
4094 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
4095 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
4096 | if get(handles.edit_object,'Value') |
---|
4097 | set(handles.edit_object,'BackgroundColor',[1,1,0]) |
---|
4098 | %suppress the other options |
---|
4099 | set(handles.CheckZoom,'Value',0) |
---|
4100 | CheckZoom_Callback(hObject, eventdata, handles) |
---|
4101 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
4102 | if ishandle(hgeometry_calib) |
---|
4103 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
4104 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib |
---|
4105 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4106 | end |
---|
4107 | set(handles.ViewObject,'value',1) |
---|
4108 | ViewObject_Callback(hObject, eventdata, handles) |
---|
4109 | else % desctivate object edit mode |
---|
4110 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
4111 | if ~isempty(hset_object)% open the |
---|
4112 | hhset_object=guidata(hset_object); |
---|
4113 | set(hhset_object.PLOT,'enable','off'); |
---|
4114 | set(get(hset_object,'children'),'enable','inactive') |
---|
4115 | end |
---|
4116 | end |
---|
4117 | |
---|
4118 | |
---|
4119 | %------------------------------------------------------------------------ |
---|
4120 | % --- Executes on button press in ViewObject. |
---|
4121 | function ViewObject_Callback(hObject, eventdata, handles) |
---|
4122 | %------------------------------------------------------------------------ |
---|
4123 | check_view=get(handles.ViewObject,'Value'); |
---|
4124 | |
---|
4125 | if check_view %activate set_object |
---|
4126 | IndexObj=get(handles.ListObject,'Value'); |
---|
4127 | list_object=get(handles.ListObject,'String'); |
---|
4128 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
4129 | UvData.Object{IndexObj}.Name=list_object{IndexObj}; |
---|
4130 | if numel(UvData.Object)<IndexObj;% error in UvData |
---|
4131 | msgbox_uvmat('ERROR','invalid object list') |
---|
4132 | return |
---|
4133 | end |
---|
4134 | ZBounds=0; % default |
---|
4135 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
4136 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
4137 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
4138 | end |
---|
4139 | % set(handles.ListObject_1,'Value',IndexObj);%restore ListObject selection after set_object deletion |
---|
4140 | data=UvData.Object{IndexObj}; |
---|
4141 | if ~isfield(data,'Type')% default plane |
---|
4142 | data.Type='plane'; |
---|
4143 | end |
---|
4144 | % if isfield(UvData,'Field') |
---|
4145 | % Field=UvData.Field; |
---|
4146 | % if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh) |
---|
4147 | % data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
4148 | % if strcmp(data.Type,'line')||strcmp(data.Type,'polyline') |
---|
4149 | % data.RangeY=UvData.Field.Mesh; |
---|
4150 | % else |
---|
4151 | % data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
4152 | % end |
---|
4153 | % data.DX=UvData.Field.Mesh; |
---|
4154 | % data.DY=UvData.Field.Mesh; |
---|
4155 | % end |
---|
4156 | % if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) |
---|
4157 | % data.Coord=[0 0 0]; %default |
---|
4158 | % end |
---|
4159 | % if isfield(Field,'CoordUnit') |
---|
4160 | % data.CoordUnit=Field.CoordUnit; |
---|
4161 | % end |
---|
4162 | % end |
---|
4163 | hset_object=set_object(data,[],ZBounds); |
---|
4164 | hhset_object=guidata(hset_object); |
---|
4165 | if get(handles.edit_object,'Value')% edit mode |
---|
4166 | set(hhset_object.PLOT,'Enable','on') |
---|
4167 | set(get(hset_object,'children'),'enable','on') |
---|
4168 | else |
---|
4169 | set(hhset_object.PLOT,'Enable','off') |
---|
4170 | set(get(hset_object,'children'),'enable','inactive')% deactivate the GUI except SAVE |
---|
4171 | set(hhset_object.SAVE,'Enable','on') |
---|
4172 | end |
---|
4173 | else |
---|
4174 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
4175 | if ~isempty(hset_object) |
---|
4176 | delete(hset_object)% delete existing version of set_object |
---|
4177 | end |
---|
4178 | end |
---|
4179 | |
---|
4180 | |
---|
4181 | %------------------------------------------------------------------------ |
---|
4182 | % --- Executes on button press in ViewField. |
---|
4183 | function ViewField_Callback(hObject, eventdata, handles) |
---|
4184 | %------------------------------------------------------------------------ |
---|
4185 | check_view=get(handles.ViewField,'Value'); |
---|
4186 | |
---|
4187 | if check_view |
---|
4188 | IndexObj=get(handles.ListObject,'Value'); |
---|
4189 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
4190 | if numel(UvData.Object)<IndexObj(end);% error in UvData |
---|
4191 | msgbox_uvmat('ERROR','invalid object list') |
---|
4192 | return |
---|
4193 | end |
---|
4194 | ZBounds=0; % default |
---|
4195 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
4196 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
4197 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
4198 | end |
---|
4199 | set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion |
---|
4200 | if ~isfield(UvData.Object{IndexObj(1)},'Type')% default plane |
---|
4201 | UvData.Object{IndexObj(1)}.Type='plane'; |
---|
4202 | end |
---|
4203 | list_object=get(handles.ListObject,'String'); |
---|
4204 | UvData.Object{IndexObj(end)}.Name=list_object{IndexObj(end)}; |
---|
4205 | |
---|
4206 | %% show the projection of the selected object on view_field |
---|
4207 | ProjData= proj_field(UvData.Field,UvData.Object{IndexObj});%project the current field on ObjectData |
---|
4208 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
4209 | if isempty(hview_field) |
---|
4210 | hview_field=view_field; |
---|
4211 | end |
---|
4212 | hhview_field=guidata(hview_field); |
---|
4213 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the GUI view_field); |
---|
4214 | write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
4215 | haxes=findobj(hview_field,'tag','axes3'); |
---|
4216 | pos=get(hview_field,'Position'); |
---|
4217 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
4218 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
4219 | pos_table=get(h_TableDisplay,'Position'); |
---|
4220 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
4221 | else |
---|
4222 | Data=get(hview_field,'UserData'); |
---|
4223 | set(hview_field,'Position',Data.GUISize)% restore the size of view_field for plots |
---|
4224 | end |
---|
4225 | else |
---|
4226 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
4227 | if ~isempty(hview_field) |
---|
4228 | delete(hview_field)% delete existing version of set_object |
---|
4229 | end |
---|
4230 | end |
---|
4231 | |
---|
4232 | |
---|
4233 | %------------------------------------------------------------------------ |
---|
4234 | % --- Executes on button press in delete_object. |
---|
4235 | function delete_object_Callback(hObject, eventdata, handles) |
---|
4236 | %------------------------------------------------------------------------ |
---|
4237 | IndexObj=get(handles.ListObject,'Value');%projection object selected for view_field |
---|
4238 | IndexObj_1=get(handles.ListObject_1,'Value');%projection object selected for uvmat plot |
---|
4239 | if IndexObj>1 && ~isequal(IndexObj,IndexObj_1) % do not delete the object used for the uvmat plot |
---|
4240 | delete_object(IndexObj) |
---|
4241 | end |
---|
4242 | |
---|
4243 | %------------------------------------------------------------------------ |
---|
4244 | %------------------------------------------------------------------------ |
---|
4245 | % II - TOOLS FROM THE UPPER MENU BAR |
---|
4246 | %------------------------------------------------------------------------ |
---|
4247 | %------------------------------------------------------------------------ |
---|
4248 | |
---|
4249 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4250 | % Export Menu Callbacks |
---|
4251 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4252 | %------------------------------------------------------------------------ |
---|
4253 | % --- Executes on button press in Menu/Export/field in workspace. |
---|
4254 | function MenuExportField_Callback(hObject, eventdata, handles) |
---|
4255 | %------------------------------------------------------------------------ |
---|
4256 | global Data_uvmat |
---|
4257 | Data_uvmat=get(handles.uvmat,'UserData'); |
---|
4258 | evalin('base','global Data_uvmat')%make CurData global in the workspace |
---|
4259 | display('current field :') |
---|
4260 | evalin('base','Data_uvmat') %display CurData in the workspace |
---|
4261 | commandwindow; %brings the Matlab command window to the front |
---|
4262 | |
---|
4263 | %------------------------------------------------------------------------ |
---|
4264 | % --- Executes on button press in Menu/Export/extract figure. |
---|
4265 | function MenuExportFigure_Callback(hObject, eventdata, handles) |
---|
4266 | %------------------------------------------------------------------------ |
---|
4267 | % huvmat=get(handles.MenuExport,'parent'); |
---|
4268 | hfig=figure; |
---|
4269 | copyobj(handles.PlotAxes,hfig); |
---|
4270 | map=colormap(handles.PlotAxes); |
---|
4271 | colormap(map);%transmit the current colormap to the zoom fig |
---|
4272 | colorbar |
---|
4273 | |
---|
4274 | % -------------------------------------------------------------------- |
---|
4275 | function MenuExportAxis_Callback(hObject, eventdata, handles) |
---|
4276 | answer=msgbox_uvmat('CONFIRMATION','select a figure/axis on which the current uvmat plot will be exported') |
---|
4277 | if strcmp(answer,'Yes') |
---|
4278 | hchild=get(handles.PlotAxes,'children'); |
---|
4279 | copyobj(hchild,gca); |
---|
4280 | end |
---|
4281 | |
---|
4282 | %------------------------------------------------------------------------ |
---|
4283 | % -------------------------------------------------------------------- |
---|
4284 | function MenuExportMovie_Callback(hObject, eventdata, handles) |
---|
4285 | % -------------------------------------------------------------------- |
---|
4286 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button |
---|
4287 | huvmat=get(handles.run0,'parent'); |
---|
4288 | UvData=get(huvmat,'UserData'); |
---|
4289 | %[xx,xx,FileBase]=read_file_boxes(handles); |
---|
4290 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
4291 | FileBase=fullfile(RootPath,RootFile); |
---|
4292 | %read the current input file name |
---|
4293 | prompt = {'movie file name';'frames per second';'frame resolution (*[512x384] pixels)';'axis position relative to the frame';'total frame number (starting from the current uvmat display)'}; |
---|
4294 | dlg_title = 'select properties of the output avi movie'; |
---|
4295 | num_lines= 1; |
---|
4296 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'}; |
---|
4297 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on'); |
---|
4298 | aviname=answer{1}; |
---|
4299 | fps=str2double(answer{2}); |
---|
4300 | % check for existing file with output name aviname |
---|
4301 | if exist(aviname,'file') |
---|
4302 | backup=aviname; |
---|
4303 | testexist=2; |
---|
4304 | while testexist==2 |
---|
4305 | backup=[backup '~']; |
---|
4306 | testexist=exist(backup,'file'); |
---|
4307 | end |
---|
4308 | [success,message]=copyfile(aviname,backup);%make backup of the existing file |
---|
4309 | if isequal(success,1) |
---|
4310 | delete(aviname)%delete existing file |
---|
4311 | else |
---|
4312 | msgbox_uvmat('ERROR',message) |
---|
4313 | return |
---|
4314 | end |
---|
4315 | end |
---|
4316 | %create avi open |
---|
4317 | aviobj=avifile(aviname,'Compression','None','fps',fps); |
---|
4318 | |
---|
4319 | %display first view for tests |
---|
4320 | newfig=figure; |
---|
4321 | newaxes=copyobj(handles.PlotAxes,newfig);%new plotting axes in the new figure |
---|
4322 | set(newaxes,'Tag','movieaxes') |
---|
4323 | nbpix=[512 384]*str2double(answer{3}); |
---|
4324 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA |
---|
4325 | set(newaxes,'Position',eval(answer{4})); |
---|
4326 | map=colormap(handles.PlotAxes); |
---|
4327 | colormap(map);%transmit the current colormap to the zoom fig |
---|
4328 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;... |
---|
4329 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']}); |
---|
4330 | UvData.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes |
---|
4331 | set(huvmat,'UserData',UvData); |
---|
4332 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
4333 | set(handles.STOP,'Visible','on') |
---|
4334 | set(handles.speed,'Visible','on') |
---|
4335 | set(handles.speed_txt,'Visible','on') |
---|
4336 | set(handles.Movie,'BusyAction','queue') |
---|
4337 | |
---|
4338 | %imin=str2double(get(handles.i1,'String')); |
---|
4339 | imax=str2double(answer{5}); |
---|
4340 | % if isfield(UvData,'Time') |
---|
4341 | htitle=get(newaxes,'Title'); |
---|
4342 | xlim=get(newaxes,'XLim'); |
---|
4343 | ylim=get(newaxes,'YLim'); |
---|
4344 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0]) |
---|
4345 | time_str=get(handles.abs_time,'String'); |
---|
4346 | set(htitle,'String',['t=' time_str]) |
---|
4347 | set(handles.speed,'Value',1) |
---|
4348 | for i=1:imax |
---|
4349 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command |
---|
4350 | runpm(hObject,eventdata,handles,increment)% run plus |
---|
4351 | drawnow |
---|
4352 | time_str=get(handles.abs_time,'String'); |
---|
4353 | if ishandle(htitle) |
---|
4354 | set(htitle,'String',['t=' time_str]) |
---|
4355 | end |
---|
4356 | mov=getframe(newfig); |
---|
4357 | aviobj=addframe(aviobj,mov); |
---|
4358 | end |
---|
4359 | end |
---|
4360 | aviobj=close(aviobj); |
---|
4361 | UvData=rmfield(UvData,'plotaxes'); |
---|
4362 | %UvData.Object{1}.plotaxes=handles.PlotAxes; |
---|
4363 | set(huvmat,'UserData',UvData); |
---|
4364 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']}) |
---|
4365 | |
---|
4366 | |
---|
4367 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4368 | % Projection Objects Menu Callbacks |
---|
4369 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4370 | |
---|
4371 | % ----------------------------------------------------------------------- |
---|
4372 | function Menupoints_Callback(hObject, eventdata, handles) |
---|
4373 | %------------------------------------------------------------------------ |
---|
4374 | data.Type='points'; |
---|
4375 | data.ProjMode='projection';%default |
---|
4376 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4377 | create_object(data,handles) |
---|
4378 | |
---|
4379 | % ----------------------------------------------------------------------- |
---|
4380 | function Menuline_Callback(hObject, eventdata, handles) |
---|
4381 | %------------------------------------------------------------------------ |
---|
4382 | data.Type='line'; |
---|
4383 | data.ProjMode='projection';%default |
---|
4384 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4385 | create_object(data,handles) |
---|
4386 | |
---|
4387 | %------------------------------------------------------------------------ |
---|
4388 | function Menupolyline_Callback(hObject, eventdata, handles) |
---|
4389 | %------------------------------------------------------------------------ |
---|
4390 | data.Type='polyline'; |
---|
4391 | data.ProjMode='projection';%default |
---|
4392 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4393 | create_object(data,handles) |
---|
4394 | |
---|
4395 | %------------------------------------------------------------------------ |
---|
4396 | function Menupolygon_Callback(hObject, eventdata, handles) |
---|
4397 | %------------------------------------------------------------------------ |
---|
4398 | data.Type='polygon'; |
---|
4399 | data.ProjMode='inside';%default |
---|
4400 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4401 | create_object(data,handles) |
---|
4402 | |
---|
4403 | %------------------------------------------------------------------------ |
---|
4404 | function Menurectangle_Callback(hObject, eventdata, handles) |
---|
4405 | %------------------------------------------------------------------------ |
---|
4406 | data.Type='rectangle'; |
---|
4407 | data.ProjMode='inside';%default |
---|
4408 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4409 | create_object(data,handles) |
---|
4410 | |
---|
4411 | %------------------------------------------------------------------------ |
---|
4412 | function Menuellipse_Callback(hObject, eventdata, handles) |
---|
4413 | %------------------------------------------------------------------------ |
---|
4414 | data.Type='ellipse'; |
---|
4415 | data.ProjMode='inside';%default |
---|
4416 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4417 | create_object(data,handles) |
---|
4418 | |
---|
4419 | %------------------------------------------------------------------------ |
---|
4420 | function MenuMaskObject_Callback(hObject, eventdata, handles) |
---|
4421 | %------------------------------------------------------------------------ |
---|
4422 | data.Type='polygon'; |
---|
4423 | data.TypeMenu={'polygon'}; |
---|
4424 | data.ProjMode='mask_inside';%default |
---|
4425 | data.ProjModeMenu={'mask_inside';'mask_outside'}; |
---|
4426 | create_object(data,handles) |
---|
4427 | |
---|
4428 | %------------------------------------------------------------------------ |
---|
4429 | function Menuplane_Callback(hObject, eventdata, handles) |
---|
4430 | %------------------------------------------------------------------------ |
---|
4431 | data.Type='plane'; |
---|
4432 | data.ProjMode='projection';%default |
---|
4433 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4434 | create_object(data,handles) |
---|
4435 | |
---|
4436 | %------------------------------------------------------------------------ |
---|
4437 | function Menuvolume_Callback(hObject, eventdata, handles) |
---|
4438 | %------------------------------------------------------------------------ |
---|
4439 | data.Type='volume'; |
---|
4440 | data.ProjMode='interp';%default |
---|
4441 | data.ProjModeMenu={}; |
---|
4442 | % set(handles.create,'Visible','on') |
---|
4443 | % set(handles.create,'Value',1) |
---|
4444 | % VOLUME_Callback(hObject,eventdata,handles)data.ProjModeMenu={}; |
---|
4445 | create_object(data,handles) |
---|
4446 | |
---|
4447 | %------------------------------------------------------------------------ |
---|
4448 | % --- generic function used for the creation of a projection object |
---|
4449 | function create_object(data,handles) |
---|
4450 | %------------------------------------------------------------------------ |
---|
4451 | % desactivate geometric calibration if opened |
---|
4452 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
4453 | if ishandle(hgeometry_calib) |
---|
4454 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
4455 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib |
---|
4456 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4457 | end |
---|
4458 | set(handles.edit_object,'Value',0); %suppress the object edit mode |
---|
4459 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
4460 | ListObject=get(handles.ListObject,'String'); |
---|
4461 | if ~strcmp(ListObject{end},'') |
---|
4462 | ListObject=[ListObject;{''}]; %append a blank to the list (if nort already done) to indicate the creation of a new object |
---|
4463 | set(handles.ListObject,'String',ListObject) |
---|
4464 | end |
---|
4465 | IndexObj=length(ListObject); |
---|
4466 | set(handles.ListObject,'Value',IndexObj) |
---|
4467 | UvData=get(handles.uvmat,'UserData'); |
---|
4468 | UvData.Object{IndexObj}=[]; %create a new empty object |
---|
4469 | UvData.Object{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object |
---|
4470 | UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
4471 | data.Name=data.Type;% default name=type |
---|
4472 | data.Coord=[0 0]; %default |
---|
4473 | if isfield(UvData,'Field') |
---|
4474 | Field=UvData.Field; |
---|
4475 | if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh) |
---|
4476 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
4477 | if strcmp(data.Type,'line')||strcmp(data.Type,'polyline')||strcmp(data.Type,'points') |
---|
4478 | data.RangeY=UvData.Field.Mesh; |
---|
4479 | else |
---|
4480 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
4481 | end |
---|
4482 | data.DX=UvData.Field.Mesh; |
---|
4483 | data.DY=UvData.Field.Mesh; |
---|
4484 | end |
---|
4485 | if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) |
---|
4486 | data.Coord=[0 0 0]; %default |
---|
4487 | end |
---|
4488 | if isfield(Field,'CoordUnit') |
---|
4489 | data.CoordUnit=Field.CoordUnit; |
---|
4490 | end |
---|
4491 | end |
---|
4492 | if ishandle(handles.UVMAT_title) |
---|
4493 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered |
---|
4494 | end |
---|
4495 | hset_object=set_object(data,handles);% call the set_object interface |
---|
4496 | hhset_object=guidata(hset_object); |
---|
4497 | hchild=get(hset_object,'children'); |
---|
4498 | set(hchild,'enable','on') |
---|
4499 | set(handles.uvmat,'UserData',UvData) |
---|
4500 | set(handles.CheckZoom,'Value',0) %desactivate the zoom for object creation by the mouse |
---|
4501 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
4502 | set(handles.delete_object,'Visible','on') |
---|
4503 | |
---|
4504 | %------------------------------------------------------------------------ |
---|
4505 | function MenuBrowseObject_Callback(hObject, eventdata, handles) |
---|
4506 | %------------------------------------------------------------------------ |
---|
4507 | %get the object file |
---|
4508 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4509 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
4510 | '*.xml', '.xml files '; ... |
---|
4511 | '*.mat', '.mat matlab files '}, ... |
---|
4512 | 'Pick an xml Object file',get(handles.RootPath,'String')); |
---|
4513 | fileinput=[PathName FileName];%complete file name |
---|
4514 | sizf=size(fileinput); |
---|
4515 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
4516 | |
---|
4517 | %read the file |
---|
4518 | [data,heading]=xml2struct(fileinput); |
---|
4519 | if ~strcmp(heading,'ProjObject') |
---|
4520 | msgbox_uvmat('WARNING','The xml file does not have the heading ProjObject for projection objects') |
---|
4521 | end |
---|
4522 | [tild,data.Name]=fileparts(FileName);% object name set as file name |
---|
4523 | ListObject=get(handles.ListObject,'String'); |
---|
4524 | if ~strcmp(ListObject{end},'') |
---|
4525 | ListObject=[ListObject;{''}]; %append a blank to the list (if not already done) to indicate the creation of a new object |
---|
4526 | set(handles.ListObject,'String',ListObject) |
---|
4527 | end |
---|
4528 | IndexObj=length(ListObject); |
---|
4529 | |
---|
4530 | UvData=get(handles.uvmat,'UserData'); |
---|
4531 | UvData.Object{IndexObj}=[]; %create a new empty object |
---|
4532 | UvData.Object{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation |
---|
4533 | UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
4534 | set(handles.uvmat,'UserData',UvData) |
---|
4535 | set(handles.ListObject,'Value',IndexObj) |
---|
4536 | hset_object=set_object(data);% call the set_object interface |
---|
4537 | set(get(hset_object,'children'),'enable','on')% enable edit action on elements on GUI set_object |
---|
4538 | set(handles.edit_object,'Value',0); %suppress the object edit mode |
---|
4539 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
4540 | set(handles.delete_object,'Visible','on') |
---|
4541 | |
---|
4542 | |
---|
4543 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4544 | % MenuEdit Callbacks |
---|
4545 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4546 | %------------------------------------------------------------------------ |
---|
4547 | function MenuEditObject_Callback(hObject, eventdata, handles) |
---|
4548 | %------------------------------------------------------------------------ |
---|
4549 | set(handles.edit_object,'Value',1) |
---|
4550 | edit_Callback(hObject, eventdata, handles) |
---|
4551 | |
---|
4552 | %------------------------------------------------------------------------ |
---|
4553 | function MenuEditVectors_Callback(hObject, eventdata, handles) |
---|
4554 | %------------------------------------------------------------------------ |
---|
4555 | set(handles.edit_vect,'Visible','on') |
---|
4556 | set(handles.edit_vect,'Value',1) |
---|
4557 | edit_vect_Callback(hObject, eventdata, handles) |
---|
4558 | |
---|
4559 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4560 | % MenuTools Callbacks |
---|
4561 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4562 | %------------------------------------------------------------------------ |
---|
4563 | function MenuCalib_Callback(hObject, eventdata, handles) |
---|
4564 | %------------------------------------------------------------------------ |
---|
4565 | |
---|
4566 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
4567 | |
---|
4568 | %suppress competing options |
---|
4569 | set(handles.CheckZoom,'Value',0) |
---|
4570 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4571 | set(handles.ListObject,'Value',1) |
---|
4572 | % initiate display of GUI geometry_calib |
---|
4573 | data=[]; %default |
---|
4574 | if isfield(UvData,'CoordType') |
---|
4575 | data.CoordType=UvData.CoordType; |
---|
4576 | end |
---|
4577 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
4578 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
4579 | set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib |
---|
4580 | pos_uvmat=get(handles.uvmat,'Position'); |
---|
4581 | pos_cal(1)=pos_uvmat(1)+UvData.OpenParam.PosGeometryCalib(1)*pos_uvmat(3); |
---|
4582 | pos_cal(2)=pos_uvmat(2)+UvData.OpenParam.PosGeometryCalib(2)*pos_uvmat(4); |
---|
4583 | pos_cal(3:4)=UvData.OpenParam.PosGeometryCalib(3:4).* pos_uvmat(3:4); |
---|
4584 | geometry_calib(FileName,pos_cal);% call the geometry_calib interface |
---|
4585 | set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib |
---|
4586 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action |
---|
4587 | |
---|
4588 | %------------------------------------------------------------------------ |
---|
4589 | function MenuMask_Callback(hObject, eventdata, handles) |
---|
4590 | %------------------------------------------------------------------------ |
---|
4591 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
4592 | ListObj=UvData.Object; |
---|
4593 | select=zeros(1,numel(ListObj)); |
---|
4594 | for iobj=1:numel(ListObj); |
---|
4595 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside') |
---|
4596 | select(iobj)=1; |
---|
4597 | end |
---|
4598 | end |
---|
4599 | val=find(select); |
---|
4600 | if isempty(val) |
---|
4601 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar'); |
---|
4602 | return |
---|
4603 | else |
---|
4604 | % set(handles.ListObject,'Max',2);%allow multiple selection |
---|
4605 | set(handles.ListObject,'Value',val); |
---|
4606 | flag=1; |
---|
4607 | npx=size(UvData.Field.A,2); |
---|
4608 | npy=size(UvData.Field.A,1); |
---|
4609 | xi=0.5:npx-0.5; |
---|
4610 | yi=0.5:npy-0.5; |
---|
4611 | [Xi,Yi]=meshgrid(xi,yi); |
---|
4612 | if isfield(UvData,'Object') |
---|
4613 | for iobj=1:length(UvData.Object) |
---|
4614 | ObjectData=UvData.Object{iobj}; |
---|
4615 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
4616 | flagobj=1; |
---|
4617 | testphys=0; %coordinates in pixels by default |
---|
4618 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel') |
---|
4619 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
4620 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
4621 | testphys=1; |
---|
4622 | end |
---|
4623 | end |
---|
4624 | if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Type') |
---|
4625 | if isequal(ObjectData.Type,'polygon') |
---|
4626 | X=ObjectData.Coord(:,1); |
---|
4627 | Y=ObjectData.Coord(:,2); |
---|
4628 | if testphys |
---|
4629 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases |
---|
4630 | end |
---|
4631 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
4632 | elseif isequal(ObjectData.Type,'ellipse') |
---|
4633 | if testphys |
---|
4634 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
4635 | end |
---|
4636 | RangeX=max(ObjectData.RangeX); |
---|
4637 | RangeY=max(ObjectData.RangeY); |
---|
4638 | X2Max=RangeX*RangeX; |
---|
4639 | Y2Max=RangeY*RangeY; |
---|
4640 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
4641 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
4642 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
4643 | elseif isequal(ObjectData.Type,'rectangle') |
---|
4644 | if testphys |
---|
4645 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
4646 | end |
---|
4647 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
4648 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
4649 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
4650 | end |
---|
4651 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
4652 | flagobj=~flagobj; |
---|
4653 | end |
---|
4654 | flag=flag & flagobj; |
---|
4655 | end |
---|
4656 | end |
---|
4657 | end |
---|
4658 | end |
---|
4659 | %mask name |
---|
4660 | RootPath=get(handles.RootPath,'String'); |
---|
4661 | SubDir=get(handles.SubDir,'String'); |
---|
4662 | RootFile=get(handles.RootFile,'String'); |
---|
4663 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\')) |
---|
4664 | RootFile(1)=[]; |
---|
4665 | end |
---|
4666 | % filebase=fullfile(RootPath,RootFile); |
---|
4667 | list=get(handles.masklevel,'String'); |
---|
4668 | masknumber=num2str(length(list)); |
---|
4669 | maskindex=get(handles.masklevel,'Value'); |
---|
4670 | % mask_name=fullfile_uvmat(RootPath,'',[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
4671 | mask_name=fullfile_uvmat(RootPath,[SubDir '.mask'],'mask','.png','_1',maskindex); |
---|
4672 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
4673 | imflag=flipdim(imflag,1); |
---|
4674 | |
---|
4675 | %display the mask |
---|
4676 | hfigmask=figure; |
---|
4677 | set(hfigmask,'Name','mask image') |
---|
4678 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
4679 | map=[vec' vec' vec']; |
---|
4680 | colormap(map) |
---|
4681 | image(imflag); |
---|
4682 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name); |
---|
4683 | if ~strcmp(answer,'Cancel') |
---|
4684 | mask_dir=fileparts(answer); |
---|
4685 | if ~exist(mask_dir,'dir') |
---|
4686 | [xx,msg1]=mkdir(mask_dir); |
---|
4687 | if ~strcmp(msg1,'') |
---|
4688 | errormsg=['cannot create ' mask_dir ': ' msg1];%error message for directory creation |
---|
4689 | return |
---|
4690 | end |
---|
4691 | end |
---|
4692 | imwrite(imflag,answer,'BitDepth',8); |
---|
4693 | end |
---|
4694 | set(handles.ListObject,'Value',1) |
---|
4695 | end |
---|
4696 | |
---|
4697 | %------------------------------------------------------------------------ |
---|
4698 | %-- open the GUI set_grid.fig to create grid |
---|
4699 | function MenuGrid_Callback(hObject, eventdata, handles) |
---|
4700 | %------------------------------------------------------------------------ |
---|
4701 | %suppress the other options if grid is chosen |
---|
4702 | set(handles.edit_vect,'Value',0) |
---|
4703 | edit_vect_Callback(hObject, eventdata, handles) |
---|
4704 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4705 | set(handles.ListObject,'Value',1) |
---|
4706 | |
---|
4707 | %prepare display of the set_grid GUI |
---|
4708 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
4709 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
4710 | CoordList=get(handles.transform_fct,'String'); |
---|
4711 | val=get(handles.transform_fct,'Value'); |
---|
4712 | set_grid(FileName,CoordList{val});% call the set_object interface |
---|
4713 | |
---|
4714 | |
---|
4715 | %------------------------------------------------------------------------ |
---|
4716 | function MenuRuler_Callback(hObject, eventdata, handles) |
---|
4717 | %------------------------------------------------------------------------ |
---|
4718 | set(handles.CheckZoom,'Value',0) |
---|
4719 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
4720 | set(handles.MenuRuler,'checked','on') |
---|
4721 | UvData=get(handles.uvmat,'UserData'); |
---|
4722 | UvData.MouseAction='ruler'; |
---|
4723 | set(handles.uvmat,'UserData',UvData); |
---|
4724 | |
---|
4725 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4726 | % MenuRun Callbacks |
---|
4727 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4728 | |
---|
4729 | %------------------------------------------------------------------------ |
---|
4730 | % open the GUI 'series' |
---|
4731 | function MenuSeries_Callback(hObject, eventdata, handles) |
---|
4732 | %------------------------------------------------------------------------ |
---|
4733 | series; %first display of the GUI to fill waiting time |
---|
4734 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
4735 | Param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%first input file name |
---|
4736 | if isequal(get(handles.SubField,'Value'),1) |
---|
4737 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
4738 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
4739 | if ~isequal(FileName_1,Param.FileName) |
---|
4740 | Param.FileName_1=FileName_1;%second input file name if relevant |
---|
4741 | end |
---|
4742 | end |
---|
4743 | Param.NomType=get(handles.NomType,'String'); |
---|
4744 | Param.NomType_1=get(handles.NomType_1,'String'); |
---|
4745 | Param.CheckFixPair=get(handles.CheckFixPair,'Value'); |
---|
4746 | UvData=get(handles.uvmat,'UserData'); |
---|
4747 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'Time') |
---|
4748 | Param.Time=UvData.XmlData{1}.Time; |
---|
4749 | end |
---|
4750 | if isequal(get(handles.scan_i,'Value'),1) |
---|
4751 | Param.incr_i=str2num(get(handles.num_IndexIncrement,'String')); |
---|
4752 | elseif isequal(get(handles.scan_j,'Value'),1) |
---|
4753 | Param.incr_j=str2num(get(handles.num_IndexIncrement,'String')); |
---|
4754 | end |
---|
4755 | |
---|
4756 | %% transfer fields and coordinate names |
---|
4757 | Param.list_fields=get(handles.FieldName,'String');% list menu fields |
---|
4758 | FieldName=Param.list_fields{get(handles.FieldName,'Value')}; |
---|
4759 | ind_image=find(strcmp('image',Param.list_fields)); |
---|
4760 | if ~isempty(ind_image) && numel(Param.list_fields)>1 |
---|
4761 | Param.list_fields(ind_image)=[]; %suppress 'image' option |
---|
4762 | end |
---|
4763 | Param.index_fields=find(strcmp(FieldName,Param.list_fields));% selected string index |
---|
4764 | Param.list_fields_1=get(handles.FieldName_1,'String');% list menu fields |
---|
4765 | if ischar(Param.list_fields_1),Param.list_fields_1={Param.list_fields_1};end |
---|
4766 | FieldName_1=Param.list_fields_1{get(handles.FieldName_1,'Value')}; |
---|
4767 | ind_image=find(strcmp('image',Param.list_fields_1)); |
---|
4768 | if ~isempty(ind_image) && numel(Param.list_fields_1)>1 |
---|
4769 | Param.list_fields_1(ind_image)=[]; %suppress 'image' option |
---|
4770 | end |
---|
4771 | Param.index_fields_1=find(strcmp(FieldName_1,Param.list_fields_1));% selected string index |
---|
4772 | Param.transform_str=get(handles.transform_fct,'String'); |
---|
4773 | Param.transform_val=get(handles.transform_fct,'Value'); |
---|
4774 | Param.Coord_x_str=get(handles.Coord_x,'String'); |
---|
4775 | Param.Coord_x_val=get(handles.Coord_x,'Value'); |
---|
4776 | Param.Coord_y_str=get(handles.Coord_y,'String'); |
---|
4777 | Param.Coord_y_val=get(handles.Coord_y,'Value'); |
---|
4778 | series(Param); %run the series interface |
---|
4779 | |
---|
4780 | %------------------------------------------------------------------------ |
---|
4781 | % -- open the GUI civ.fig for PIV |
---|
4782 | function MenuPIV_Callback(hObject, eventdata, handles) |
---|
4783 | %------------------------------------------------------------------------ |
---|
4784 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
4785 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
4786 | civ(FileName);% interface de civ(not in the uvmat file) |
---|
4787 | |
---|
4788 | % -------------------------------------------------------------------- |
---|
4789 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
4790 | % -------------------------------------------------------------------- |
---|
4791 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
4792 | pathelp=fileparts(path_to_uvmat); |
---|
4793 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
4794 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
4795 | else |
---|
4796 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
4797 | web(helpfile); |
---|
4798 | end |
---|
4799 | |
---|
4800 | |
---|
4801 | % -------------------------------------------------------------------- |
---|
4802 | function MenuSetProject_Callback(hObject, eventdata, handles) |
---|
4803 | RootPath=get(handles.RootPath,'String'); |
---|
4804 | ProjectDir = uigetdir(fileparts(fileparts(RootPath)), 'select the project source directory'); |
---|
4805 | datatree_browser(ProjectDir) |
---|
4806 | |
---|
4807 | |
---|
4808 | % -------------------------------------------------------------------- |
---|
4809 | function MenuBrowseProject_Callback(hObject, eventdata, handles) |
---|
4810 | RootPath=get(handles.RootPath,'String'); |
---|
4811 | ProjectDir = uigetdir(fileparts(fileparts(RootPath)), 'select the project directory'); |
---|
4812 | datatree_browser(ProjectDir) |
---|
4813 | |
---|
4814 | |
---|
4815 | % --- Executes on selection change in Coord_y. |
---|
4816 | function Coord_y_Callback(hObject, eventdata, handles) |
---|
4817 | |
---|
4818 | % --- Executes on selection change in Coord_x. |
---|
4819 | function Coord_x_Callback(hObject, eventdata, handles) |
---|