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 fields (with fields
|
---|
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:
|
---|
31 | % 'Strings' of all edit boxes and menus: get(handles.Tag,'String')
|
---|
32 | % 'Values' of all menus and toggle buttons: get(handles.Tag,'Value')
|
---|
33 | % Matlab structure called UvData stored as 'UserData' of the figure uvmat.fig,(can be obtained by right mouse click on the interface).
|
---|
34 | % It contains the following fields:
|
---|
35 | % - Fixed specifiacation of plotting figures and axes (defined bu uvmat_OpeningFcn)
|
---|
36 | % .PosColorbar: [0.8210 0.4710 0.0190 0.4450]; specified position of the colorbar on figures
|
---|
37 | % - Information read in the documentation open of a series (activated by RootPath_Callback) :
|
---|
38 | % .XmlData, with fields:
|
---|
39 | % .Time: matrix of times of the images with index i and j
|
---|
40 | % .GeometryCalib: [1x1 struct]
|
---|
41 | % - Information defined from the interface:
|
---|
42 | % .NewSeries: =1 when the first view of a new field series is displayed, else 0
|
---|
43 | % .filename:(char string)
|
---|
44 | % .VelType:(char string) type of velocity field selected
|
---|
45 | % .VelType_1:(char string) REMPLACER LE CELL ACTUEL
|
---|
46 | % .FieldName: (char string) main field selected('image', 'velocity'...)
|
---|
47 | % .FieldName_1:(char string) second field selected('image', 'velocity'...)
|
---|
48 | % .CName: (char string)name of the scalar used for vector colors
|
---|
49 | % .MovieObject: movie object representing an input movie
|
---|
50 | % .MovieObject_1: idem for a second input series (_1)
|
---|
51 | % .filename_1 : last second input file name (to deal with a constant second input without reading again the file)
|
---|
52 | % .VelType_1: last velocity type (VelType, civ2...) for the second input series
|
---|
53 | % .FieldName_1: last field name(velocity, vorticity...) for the second input series
|
---|
54 | % .ZMin, .ZMax: range of the z coordinate
|
---|
55 | %..... to complement
|
---|
56 | % - Information on projection objects
|
---|
57 | % .Object: {[1x1 struct]}
|
---|
58 | % .CurrentObjectIndex: index of the projection object .Object currently selected for editing
|
---|
59 | % -Information on the current field (Field{i})
|
---|
60 | % .Txt : text information to display (e.g. error message)
|
---|
61 | % .NbDim: number of dimensions (=0 by default)
|
---|
62 | % .NbCoord: number of vector components
|
---|
63 | % .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')
|
---|
64 | % .dt: time interval for the corresponding image pair
|
---|
65 | % .Mesh: estimated typical distance between vectors
|
---|
66 | % .ZMax:
|
---|
67 | % .ZMin:
|
---|
68 | % .X, .Y, .Z: set of vector coordinates
|
---|
69 | % .U,.V,.W: corresponding set of vector components
|
---|
70 | % .F: corresponding set of warning flags
|
---|
71 | % .FF: corresponding set of false flags, =0 for good vectors
|
---|
72 | % .C: corresponding values of the scalar used for vector color
|
---|
73 | % (.X, .Y, .Z,.U,.V,.W,.F,.FF,.C are matlab vectors of the same length,
|
---|
74 | % equal to the number of vectors stored in the input open)
|
---|
75 | % .CName: name of the scalar .C
|
---|
76 | % .CType: type of the scalar .C, setting how the scalar is obtained (see 'Scalars' below)
|
---|
77 | % .A image or scalar
|
---|
78 | % .AX: vector of dimension 2 representing the first and last values
|
---|
79 | % of the X coordinates for the image or scalar known on a regular grid,
|
---|
80 | % or vector of dimension .A for a scaler defined on irregular grid.
|
---|
81 | % .AY: same as .AX along the Y direction
|
---|
82 | % .AName: name of the scalar, ='image' for an image
|
---|
83 |
|
---|
84 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%:
|
---|
85 | %
|
---|
86 | % fields are opened and visualised by the sub-function refresh_field.m
|
---|
87 | % (called by uvmat_opening, RUN0, runp and runm)
|
---|
88 | % The function first reads the name of the input file from the edit boxes of the GUI
|
---|
89 | % A second input file can be introduced for filed comparison
|
---|
90 | % It then reads the input file(s) with the appropriate function, read for
|
---|
91 | % images, read_civxdata.m for CIVx PIV data, nc2struct for other netcdf
|
---|
92 | % files.
|
---|
93 | % Main input open second input open(_1) second image (pair animation)
|
---|
94 | % | |
|
---|
95 | % | |
|
---|
96 | % Field{1} Field{2}
|
---|
97 | % |
|
---|
98 | % coord transform (phys.m) or other user defined fct acting on Field{i} |
|
---|
99 | % Field{i}
|
---|
100 | % |
|
---|
101 | % calc_field.m: calculate scalar or other derived fields (vort, div..).
|
---|
102 | %
|
---|
103 | % sub_field.m: combine the input Field{i} in a single set of fields (vector + scalar):
|
---|
104 | % Field{i=1->3}.X --> UvData.X |
|
---|
105 | % |
|
---|
106 | % UvData
|
---|
107 | % |
|
---|
108 | % plot histograms of the whole field
|
---|
109 | % proj_field.m: project the set of fields on the current projection objects defined by UvData.Object
|
---|
110 | % | |
|
---|
111 | % ObjectData
|
---|
112 | % |
|
---|
113 | % plot_field.m: plot the projected fields and store them as |
|
---|
114 | % UvData.axes3 |
|
---|
115 | % |
|
---|
116 | % AxeData
|
---|
117 | %
|
---|
118 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%%
|
---|
119 | % scalars are displayed either as an image or countour plot, either as a color of
|
---|
120 | % velocity vectors. The scalar values in the first case is represented by
|
---|
121 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X
|
---|
122 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and
|
---|
123 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar
|
---|
124 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the
|
---|
125 | % coordinates of the four image corners. The scalar name is represented by
|
---|
126 | % the strings .AName and/or .CName.
|
---|
127 | % If the scalar exists in an input open (image or scalar stored under its
|
---|
128 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}.
|
---|
129 | % Else only its name AName is recorded in Field{i}, and its field is then calculated
|
---|
130 | %by the fuction calc_scal after the coordinate transform or after projection on an edit_object
|
---|
131 |
|
---|
132 | % Properties attached to plotting figures (standard Matlab properties):
|
---|
133 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes');
|
---|
134 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned
|
---|
135 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned
|
---|
136 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure
|
---|
137 | % 'KeyPressFcn': function called by pressing a key on the key board
|
---|
138 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure
|
---|
139 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure
|
---|
140 |
|
---|
141 | % Properties attached to plotting axes:
|
---|
142 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates.
|
---|
143 | % AxeData:=get(gca,'UserData');
|
---|
144 | % AxeData.Drawing = create: create a new object
|
---|
145 | % = deform: modify an existing object by moving its defining create
|
---|
146 | % = off: no current drawing action
|
---|
147 | % = translate: translate an existing object
|
---|
148 | % = calibration: move a calibration point
|
---|
149 | % = CheckZoom: isolate a subregion for CheckZoom in=1 if an object is being currently drawn, 0 else (set to 0 by releasing mouse button)
|
---|
150 | % .CurrentOrigin: Origin of a curently drawn edit_object
|
---|
151 | % .CurrentLine: currently drawn menuline (A REVOIR)
|
---|
152 | % .CurrentObject: handle of the currently drawn edit_object
|
---|
153 | % .CurrentRectZoom: current rectangle used for CheckZoom
|
---|
154 |
|
---|
155 | % Properties attached to projection objects (create, menuline, menuplane...):
|
---|
156 | % 'Tag'='proj_object': for all projection objects
|
---|
157 | % ObjectData.Style=...: style of projection object:
|
---|
158 | % .ProjMode
|
---|
159 | % .Coord: defines the position of the object
|
---|
160 | % .XMin,YMin....
|
---|
161 | % .XMax,YMax....
|
---|
162 | % .DX,DY,DZ
|
---|
163 | % .Phi, .Theta, .Psi : Euler angles
|
---|
164 | % .X,.Y,.U,.V.... : field data projected on the object
|
---|
165 | % .IndexObj: index in the list of UvData.Object
|
---|
166 | %during plotting
|
---|
167 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object
|
---|
168 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes
|
---|
169 | % To each projection object #iobj, corresponds an axis
|
---|
170 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the
|
---|
171 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field;
|
---|
172 |
|
---|
173 | %------------------------------------------------------------------------
|
---|
174 | %------------------------------------------------------------------------
|
---|
175 | % I - MAIN FUNCTION UVMAT (DO NOT MODIFY)
|
---|
176 | %------------------------------------------------------------------------
|
---|
177 | %------------------------------------------------------------------------
|
---|
178 | function varargout = uvmat(varargin)
|
---|
179 |
|
---|
180 | % Begin initialization code - DO NOT EDIT
|
---|
181 | gui_Singleton = 1;
|
---|
182 | gui_State = struct('gui_Name', mfilename, ...
|
---|
183 | 'gui_Singleton', gui_Singleton, ...
|
---|
184 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ...
|
---|
185 | 'gui_OutputFcn', @uvmat_OutputFcn, ...
|
---|
186 | 'gui_LayoutFcn', [], ...
|
---|
187 | 'gui_Callback', []);
|
---|
188 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once'))
|
---|
189 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
190 | end
|
---|
191 |
|
---|
192 | if nargout
|
---|
193 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
|
---|
194 | else
|
---|
195 | gui_mainfcn(gui_State, varargin{:});
|
---|
196 | end
|
---|
197 | % End initialization code - DO NOT EDIT
|
---|
198 |
|
---|
199 | %------------------------------------------------------------------------
|
---|
200 | % --- Executes just before the GUI uvmat is made visible.
|
---|
201 | function uvmat_OpeningFcn(hObject, eventdata, handles, input )
|
---|
202 | %------------------------------------------------------------------------
|
---|
203 |
|
---|
204 | %% Choose default command menuline output for uvmat (standard GUI)
|
---|
205 | handles.output = hObject;
|
---|
206 |
|
---|
207 | %% Update handles structure (standard GUI)
|
---|
208 | guidata(hObject, handles);
|
---|
209 |
|
---|
210 | %% check the path and date of modification of all functions in uvmat
|
---|
211 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat
|
---|
212 | [errormsg,date_str,svn_info]=check_files;%check the path of the functions called by uvmat.m
|
---|
213 | date_str=['last modification: ' date_str];
|
---|
214 |
|
---|
215 |
|
---|
216 | %% set the position of colorbar and ancillary GUIs:
|
---|
217 | set(hObject,'Units','Normalized')
|
---|
218 | movegui(hObject,'center')
|
---|
219 | UvData.OpenParam.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
220 | UvData.OpenParam.SetObjectOrigin=[-0.05 -0.03]; %position for set_object
|
---|
221 | UvData.OpenParam.SetObjectSize=[0.3 0.7];
|
---|
222 | UvData.OpenParam.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE)
|
---|
223 | UvData.OpenParam.CalSize=[0.28 1];
|
---|
224 | UvData.axes3=[];%initiate the record of plotted field
|
---|
225 | UvData.axes2=[];
|
---|
226 | UvData.axes1=[];
|
---|
227 | AxeData.LimEditBox=1; %initialise AxeData
|
---|
228 | set(handles.axes3,'UserData',AxeData)
|
---|
229 |
|
---|
230 | %% set functions for the mouse and keyboard
|
---|
231 | set(handles.histo_u,'NextPlot','replacechildren');
|
---|
232 | set(handles.histo_v,'NextPlot','replacechildren');
|
---|
233 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
|
---|
234 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
|
---|
235 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
|
---|
236 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
|
---|
237 | set(hObject,'DeleteFcn',{@closefcn})%
|
---|
238 |
|
---|
239 | %% refresh projection plane
|
---|
240 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
241 | set(handles.Fields,'Value',1)
|
---|
242 | set(handles.Fields,'string',{''})
|
---|
243 |
|
---|
244 | %% TRANSFORM menu: builtin fcts
|
---|
245 | menu_str={'';'phys';'px';'phys_polar'};
|
---|
246 | UvData.OpenParam.NbBuiltin=numel(menu_str); %number of functions
|
---|
247 | path_uvmat=fileparts(which('uvmat'));
|
---|
248 | addpath (path_uvmat) ; %add the path to UVMAT, (useful in case of change of working directory after civ has been s opened in the working directory)
|
---|
249 | addpath(fullfile(path_uvmat,'transform_field'))%add the path to transform functions,
|
---|
250 | fct_handle{1,1}=[];
|
---|
251 | testexist=zeros(size(menu_str'));%default
|
---|
252 | testexist(1)=1;
|
---|
253 | for ilist=2:length(menu_str)
|
---|
254 | if exist(menu_str{ilist},'file')
|
---|
255 | fct_handle{ilist,1}=str2func(menu_str{ilist});
|
---|
256 | testexist(ilist)=1;
|
---|
257 | else
|
---|
258 | testexist(ilist)=0;
|
---|
259 | end
|
---|
260 | end
|
---|
261 | rmpath(fullfile(path_uvmat,'transform_field'))
|
---|
262 |
|
---|
263 | %% load the list of previously browsed files in menus Open and Open_1
|
---|
264 | dir_perso=prefdir; % path to the directory .matlab for personal data
|
---|
265 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
|
---|
266 | if exist(profil_perso,'file')
|
---|
267 | h=load (profil_perso);
|
---|
268 | if isfield(h,'MenuFile')
|
---|
269 | for ifile=1:min(length(h.MenuFile),5)
|
---|
270 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});'])
|
---|
271 | eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});'])
|
---|
272 | end
|
---|
273 | end
|
---|
274 | if isfield(h,'transform_fct') && iscell(h.transform_fct)
|
---|
275 | for ilist=1:length(h.transform_fct);
|
---|
276 | if exist(h.transform_fct{ilist},'file')
|
---|
277 | [path,file]=fileparts(h.transform_fct{ilist});
|
---|
278 | addpath(path)
|
---|
279 | h_func=str2func(file);
|
---|
280 | rmpath(path)
|
---|
281 | testexist=[testexist 1];
|
---|
282 | else
|
---|
283 | file='';
|
---|
284 | h_func=[];
|
---|
285 | testexist=[testexist 0];
|
---|
286 | end
|
---|
287 | fct_handle=[fct_handle; {h_func}]; %concatene the list of paths
|
---|
288 | menu_str=[menu_str; {file}];
|
---|
289 | end
|
---|
290 | end
|
---|
291 | end
|
---|
292 | menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
|
---|
293 | fct_handle=fct_handle(testexist==1);
|
---|
294 | menu_str=[menu_str;{'more...'}];
|
---|
295 | set(handles.transform_fct,'String',menu_str)
|
---|
296 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
|
---|
297 |
|
---|
298 | %% case of an input argument for uvmat
|
---|
299 | testinputfield=0;
|
---|
300 | inputfile=[];
|
---|
301 | Field=[];
|
---|
302 | if exist('input','var')
|
---|
303 | % if ~isempty(errormsg)
|
---|
304 | % msgbox_uvmat('WARNING',errormsg)
|
---|
305 | % end
|
---|
306 | if ishandle(handles.UVMAT_title)
|
---|
307 | delete(handles.UVMAT_title)
|
---|
308 | end
|
---|
309 | if isstruct(input)
|
---|
310 | if isfield(input,'InputFile')
|
---|
311 | inputfile=input.InputFile;
|
---|
312 | end
|
---|
313 | if isfield(input,'TimeIndex')
|
---|
314 | set(handles.i1,num2str(input.TimeIndex))
|
---|
315 | end
|
---|
316 | if isfield(input,'FieldsString')
|
---|
317 | % set(handles.Fields,'Value',1)
|
---|
318 | UvData.FieldsString=input.FieldsString;
|
---|
319 | end
|
---|
320 | elseif ischar(input)% file name introduced as input
|
---|
321 | inputfile=input;
|
---|
322 | elseif isnumeric(input)%simple matrix introduced as input
|
---|
323 | sizinput=size(input);
|
---|
324 | if sizinput(1)<=1 || sizinput(2)<=1
|
---|
325 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted')
|
---|
326 | return
|
---|
327 | end
|
---|
328 | UvData.Field.ListVarName={'A','coord_y','coord_x'};
|
---|
329 | UvData.Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'};
|
---|
330 | UvData.Field.A=input;
|
---|
331 | UvData.Field.coord_x=[0.5 size(input,2)-0.5];
|
---|
332 | UvData.Field.coord_y=[size(input,1)-0.5 0.5];
|
---|
333 | testinputfield=1;
|
---|
334 | end
|
---|
335 | else
|
---|
336 | if ishandle(handles.UVMAT_title)
|
---|
337 | set(handles.UVMAT_title,'String',...
|
---|
338 | [{'Copyright LEGI UMR 5519 /CNRS-UJF-Grenoble INP, 2010'};...
|
---|
339 | {'GNU General Public License'};...
|
---|
340 | {path_to_uvmat};...
|
---|
341 | {date_str};...
|
---|
342 | {['SVN revision : ' num2str(svn_info.cur_rev)]};...
|
---|
343 | errormsg]);
|
---|
344 | end
|
---|
345 | end
|
---|
346 | set(handles.uvmat,'UserData',UvData)
|
---|
347 | if ~isempty(inputfile)
|
---|
348 | %%%%% display the input field %%%%%%%
|
---|
349 | display_file_name(hObject, eventdata, handles,inputfile)
|
---|
350 | %%%%%%%
|
---|
351 | testinputfield=1;
|
---|
352 | end
|
---|
353 |
|
---|
354 | %% plot input field if exists
|
---|
355 | if testinputfield
|
---|
356 | %delete drawn objects
|
---|
357 | hother=findobj(handles.axes3,'Tag','proj_object');%find all the proj objects
|
---|
358 | for iobj=1:length(hother)
|
---|
359 | delete_object(hother(iobj))
|
---|
360 | end
|
---|
361 | if isempty(inputfile)
|
---|
362 | errormsg=refresh_field(handles,[],[],[],[],[],[],{Field});
|
---|
363 | set(handles.MenuTools,'Enable','on')
|
---|
364 | set(handles.OBJECT_txt,'Visible','on')
|
---|
365 | set(handles.edit_object,'Visible','on')
|
---|
366 | set(handles.ListObject,'Visible','on')
|
---|
367 | set(handles.frame_object,'Visible','on')
|
---|
368 | if ~isempty(errormsg)
|
---|
369 | msgbox_uvmat('ERROR',errormsg)
|
---|
370 | end
|
---|
371 | end
|
---|
372 | end
|
---|
373 |
|
---|
374 | set_vec_col_bar(handles) %update the display of color code for vectors
|
---|
375 |
|
---|
376 | %------------------------------------------------------------------------
|
---|
377 | % --- Outputs from this function are returned to the command menuline.
|
---|
378 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles)
|
---|
379 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
|
---|
380 |
|
---|
381 | %------------------------------------------------------------------------
|
---|
382 | %------------------------------------------------------------------------
|
---|
383 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
384 | % automatically sets the global properties when the rootfile name is introduced
|
---|
385 | % then activate the view-field action if selected
|
---|
386 | % it is activated either by clicking on the RootPath window or by the
|
---|
387 | % browser
|
---|
388 | %------------------------------------------------------------------------
|
---|
389 | %------------------------------------------------------------------------
|
---|
390 | % --- Executes on the menu Open/Browse...
|
---|
391 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
392 | function MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
393 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
394 | oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
|
---|
395 | % oldfile=read_file_box,es(handles);
|
---|
396 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
|
---|
397 | dir_perso=prefdir;
|
---|
398 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
399 | if exist(profil_perso,'file')
|
---|
400 | h=load (profil_perso);
|
---|
401 | if isfield(h,'MenuFile_1')
|
---|
402 | oldfile=h.MenuFile_1;
|
---|
403 | end
|
---|
404 | end
|
---|
405 | end
|
---|
406 | [FileName, PathName] = uigetfile( ...
|
---|
407 | {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol;*.nc;*.cmx;*.fig;*.log;*.dat;*.bat;', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.vol,*.nc,*.cmx,*.fig,*.log,*.dat,*.bat)';
|
---|
408 | '*.xml', '.xml files '; ...
|
---|
409 | '*.xls', '.xls files '; ...
|
---|
410 | '*.civ', '.civ files '; ...
|
---|
411 | '*.jpg',' jpeg image files'; ...
|
---|
412 | '*.png','.png image files'; ...
|
---|
413 | '*.tif','.tif image files'; ...
|
---|
414 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
415 | '*.vol','.volume images (png)'; ...
|
---|
416 | '*.nc','.netcdf files'; ...
|
---|
417 | '*.cdf','.netcdf files'; ...
|
---|
418 | '*.cmx','.cmx text files ';...
|
---|
419 | '*.fig','.fig files (matlab fig)';...
|
---|
420 | '*.log','.log text files ';...
|
---|
421 | '*.dat','.dat text files ';...
|
---|
422 | '*.bat','.bat system command text files';...
|
---|
423 | '*.*', 'All Files (*.*)'}, ...
|
---|
424 | 'Pick a file',oldfile);
|
---|
425 | fileinput=[PathName FileName];%complete file name
|
---|
426 | sizf=size(fileinput);
|
---|
427 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
428 |
|
---|
429 | % display the selected field and related information
|
---|
430 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
431 |
|
---|
432 | % -----------------------------------------------------------------------
|
---|
433 | % --- Open again the file whose name has been recorded in MenuFile_1
|
---|
434 | function MenuFile_1_Callback(hObject, eventdata, handles)
|
---|
435 | %------------------------------------------------------------------------
|
---|
436 | fileinput=get(handles.MenuFile_1,'Label');
|
---|
437 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
438 |
|
---|
439 | % -----------------------------------------------------------------------
|
---|
440 | % --- Open again the file whose name has been recorded in MenuFile_2
|
---|
441 | function MenuFile_2_Callback(hObject, eventdata, handles)
|
---|
442 | %------------------------------------------------------------------------
|
---|
443 | fileinput=get(handles.MenuFile_2,'Label');
|
---|
444 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
445 |
|
---|
446 | % -----------------------------------------------------------------------
|
---|
447 | % --- Open again the file whose name has been recorded in MenuFile_3
|
---|
448 | function MenuFile_3_Callback(hObject, eventdata, handles)
|
---|
449 | %------------------------------------------------------------------------
|
---|
450 | fileinput=get(handles.MenuFile_3,'Label');
|
---|
451 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
452 |
|
---|
453 | % -----------------------------------------------------------------------
|
---|
454 | % --- Open again the file whose name has been recorded in MenuFile_4
|
---|
455 | function MenuFile_4_Callback(hObject, eventdata, handles)
|
---|
456 | %------------------------------------------------------------------------
|
---|
457 | fileinput=get(handles.MenuFile_4,'Label');
|
---|
458 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
459 |
|
---|
460 | % -----------------------------------------------------------------------
|
---|
461 | % --- Open again the file whose name has been recorded in MenuFile_5
|
---|
462 | function MenuFile_5_Callback(hObject, eventdata, handles)
|
---|
463 | %------------------------------------------------------------------------
|
---|
464 | fileinput=get(handles.MenuFile_5,'Label');
|
---|
465 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
466 |
|
---|
467 | %------------------------------------------------------------------------
|
---|
468 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
469 | function display_file_name(hObject, eventdata, handles,fileinput,index)
|
---|
470 | %------------------------------------------------------------------------
|
---|
471 | %% look for the input file existence
|
---|
472 | if ~exist(fileinput,'file')
|
---|
473 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist'])
|
---|
474 | return
|
---|
475 | end
|
---|
476 |
|
---|
477 | %% set the mouse pointer to 'watch'
|
---|
478 | set(handles.uvmat,'Pointer','watch')
|
---|
479 | set(handles.RootPath,'BackgroundColor',[1 1 0])
|
---|
480 | drawnow
|
---|
481 |
|
---|
482 | %% define the relevant handles for the first fiel series (index=1) or the second file series (index=2)
|
---|
483 | if ~exist('index','var')
|
---|
484 | index=1;
|
---|
485 | end
|
---|
486 | if index==1
|
---|
487 | handles_RootPath=handles.RootPath;
|
---|
488 | handles_SubDir=handles.SubDir;
|
---|
489 | handles_RootFile=handles.RootFile;
|
---|
490 | handles_FileIndex=handles.FileIndex;
|
---|
491 | handles_NomType=handles.NomType;
|
---|
492 | handles_FileExt=handles.FileExt;
|
---|
493 | handles_Fields=handles.Fields;
|
---|
494 | elseif index==2
|
---|
495 | handles_RootPath=handles.RootPath_1;
|
---|
496 | handles_SubDir=handles.SubDir_1;
|
---|
497 | handles_RootFile=handles.RootFile_1;
|
---|
498 | handles_FileIndex=handles.FileIndex_1;
|
---|
499 | handles_NomType=handles.NomType_1;
|
---|
500 | handles_FileExt=handles.FileExt_1;
|
---|
501 | handles_Fields=handles.Fields_1;
|
---|
502 | set(handles.RootPath_1,'Visible','on')
|
---|
503 | set(handles.RootFile_1,'Visible','on')
|
---|
504 | set(handles.SubDir_1,'Visible','on');
|
---|
505 | set(handles.FileIndex_1,'Visible','on');
|
---|
506 | set(handles.FileExt_1,'Visible','on');
|
---|
507 | set(handles.NomType_1,'Visible','on');
|
---|
508 | end
|
---|
509 |
|
---|
510 | %% detect root name, nomenclature and indices in the input file name:
|
---|
511 | [tild,SubDir,tild,i1,i2,j1,j2,FileExt]=fileparts_uvmat(fileinput);
|
---|
512 | % detect the file type, get the movie object if relevant, and look for the corresponding file series:
|
---|
513 | [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fileinput);
|
---|
514 | if strcmp(NomType,'*')% movies will be opened at the first frame
|
---|
515 | i1=1;
|
---|
516 | i2=[];
|
---|
517 | j1=[];
|
---|
518 | j2=[];
|
---|
519 | end
|
---|
520 |
|
---|
521 | %% open the file or fill the GUI uvmat according to the detected file type
|
---|
522 | switch FileType
|
---|
523 | case ''
|
---|
524 | msgbox_uvmat('ERROR','invalid input file type')
|
---|
525 | case 'txt'
|
---|
526 | edit(fileinput)
|
---|
527 | case 'figure' %display matlab figure
|
---|
528 | hfig=open(fileinput);
|
---|
529 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
530 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
531 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
532 | case {'xml','xls'} % edit xml or Excel files
|
---|
533 | editxml(fileinput);
|
---|
534 | otherwise
|
---|
535 | set(handles_RootPath,'String',RootPath);
|
---|
536 | rootname=fullfile(RootPath,SubDir,RootFile);
|
---|
537 | set(handles_SubDir,'String',['/' SubDir]);
|
---|
538 | set(handles_RootFile,'String',['/' RootFile]); %display the separator
|
---|
539 | indices=fileinput(length(rootname)+1:end);
|
---|
540 | indices(end-length(FileExt)+1:end)=[]; %remove extension
|
---|
541 | set(handles_FileIndex,'String',indices);
|
---|
542 | set(handles_NomType,'String',NomType);
|
---|
543 | set(handles_FileExt,'String',FileExt);
|
---|
544 | if index==1
|
---|
545 | % fill file index counters if the first file series is opened
|
---|
546 | set(handles.i1,'String',num2str(i1));
|
---|
547 | set(handles.i2,'String',num2str(i2));
|
---|
548 | set(handles.j1,'String',num2stra(j1,NomType));
|
---|
549 | set(handles.j2,'String',num2stra(j2,NomType));
|
---|
550 | else %read the current field index if the second file series is opened
|
---|
551 | i1=str2num(get(handles.i1,'String'));
|
---|
552 | i2=str2num(get(handles.i2,'String'));
|
---|
553 | j1=stra2num(get(handles.j1,'String'));
|
---|
554 | j2=stra2num(get(handles.j2,'String'));
|
---|
555 | end
|
---|
556 |
|
---|
557 | % synchronise indices of the second input file if it exists
|
---|
558 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
|
---|
559 | Input=read_GUI(handles.InputFile);
|
---|
560 | if ~isfield(Input,'RootPath_1')||strcmp(Input.RootPath_1,'"')
|
---|
561 | Input.RootPath_1=Input.RootPath;
|
---|
562 | end
|
---|
563 | if ~isfield(Input,'SubDir_1')||strcmp(Input.SubDir_1,'"')
|
---|
564 | Input.SubDir_1=Input.SubDir;
|
---|
565 | end
|
---|
566 | if ~isfield(Input,'RootFile_1')||strcmp(Input.RootFile_1,'"')
|
---|
567 | Input.RootFile_1=Input.RootFile;
|
---|
568 | end
|
---|
569 | %updtate the indices of the second field series to correspond to the newly opened one
|
---|
570 | FileName_1=fullfile_uvmat(Input.RootPath_1,Input.SubDir_1,Input.RootFile_1,Input.FileExt_1,Input.NomType_1,i1,i2,j1,j2);
|
---|
571 | if exist(FileName_1,'file')
|
---|
572 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1,i2,j1,j2);
|
---|
573 | set(handles.FileIndex_1,'String',FileIndex_1)
|
---|
574 | else
|
---|
575 | set(handles.SubField,'Value',0)
|
---|
576 | SubField_Callback(hObject, eventdata, handles)
|
---|
577 | end
|
---|
578 | end
|
---|
579 |
|
---|
580 | %enable other menus
|
---|
581 | set(handles.MenuOpen_1,'Enable','on')
|
---|
582 | set(handles.MenuFile_1_1,'Enable','on')
|
---|
583 | set(handles.MenuFile_2_1,'Enable','on')
|
---|
584 | set(handles.MenuFile_3_1,'Enable','on')
|
---|
585 | set(handles.MenuFile_4_1,'Enable','on')
|
---|
586 | set(handles.MenuFile_5_1,'Enable','on')
|
---|
587 | set(handles.MenuExport,'Enable','on')
|
---|
588 | set(handles.MenuExportFigure,'Enable','on')
|
---|
589 | set(handles.MenuExportMovie,'Enable','on')
|
---|
590 | set(handles.MenuTools,'Enable','on')
|
---|
591 | set(handles.OBJECT_txt,'Visible','on')
|
---|
592 | set(handles.edit_object,'Visible','on')
|
---|
593 | set(handles.ListObject,'Visible','on')
|
---|
594 | set(handles.frame_object,'Visible','on')
|
---|
595 |
|
---|
596 | % initiate input file series and refresh the current field view:
|
---|
597 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,index);
|
---|
598 |
|
---|
599 | end
|
---|
600 |
|
---|
601 | %% set back the mouse pointer to arrow
|
---|
602 | set(handles.uvmat,'Pointer','arrow')
|
---|
603 |
|
---|
604 | %------------------------------------------------------------------------
|
---|
605 | % --- Called by action in RootPath edit box
|
---|
606 | function RootPath_Callback(hObject,eventdata,handles)
|
---|
607 | %------------------------------------------------------------------------
|
---|
608 | % read the current input file name:
|
---|
609 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
610 | fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
|
---|
611 | % detect the file type, get the movie object if relevant, and look for the corresponding file series:
|
---|
612 | [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fileinput);
|
---|
613 | % initiate the input file series and refresh the current field view:
|
---|
614 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject);
|
---|
615 |
|
---|
616 | %------------------------------------------------------------------------
|
---|
617 | % --- Called by action in RootFile edit box
|
---|
618 | function SubDir_Callback(hObject, eventdata, handles)
|
---|
619 | %------------------------------------------------------------------------
|
---|
620 | %refresh the menu of input fields
|
---|
621 | Fields_Callback(hObject, eventdata, handles);
|
---|
622 | % refresh the current field view
|
---|
623 | run0_Callback(hObject, eventdata, handles);
|
---|
624 |
|
---|
625 | %------------------------------------------------------------------------
|
---|
626 | % --- Called by action in RootFile edit box
|
---|
627 | function RootFile_Callback(hObject, eventdata, handles)
|
---|
628 | %------------------------------------------------------------------------
|
---|
629 | RootPath_Callback(hObject,eventdata,handles)
|
---|
630 |
|
---|
631 | %------------------------------------------------------------------------
|
---|
632 | % --- Called by action in FileIndex edit box
|
---|
633 | function FileIndex_Callback(hObject, eventdata, handles)
|
---|
634 | %------------------------------------------------------------------------
|
---|
635 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));
|
---|
636 | set(handles.i1,'String',num2str(i1));
|
---|
637 | set(handles.i2,'String',num2str(i2));
|
---|
638 | set(handles.j1,'String',num2str(j1));
|
---|
639 | set(handles.j2,'String',num2str(j2));
|
---|
640 |
|
---|
641 | % refresh the current field view
|
---|
642 | run0_Callback(hObject, eventdata, handles)
|
---|
643 |
|
---|
644 | %------------------------------------------------------------------------
|
---|
645 | % --- Update information about a new field series (indices to scan, timing,
|
---|
646 | % calibration from an xml file, then refresh current plots
|
---|
647 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,index)
|
---|
648 | %------------------------------------------------------------------------
|
---|
649 | %% define the relevant handles depending on the index (1=first file series, 2= second file series)
|
---|
650 | if ~exist('index','var')
|
---|
651 | index=1;
|
---|
652 | end
|
---|
653 | if index==1
|
---|
654 | handles_RootPath=handles.RootPath;
|
---|
655 | handles_Fields=handles.Fields;
|
---|
656 | elseif index==2
|
---|
657 | handles_RootPath=handles.RootPath_1;
|
---|
658 | handles_Fields=handles.Fields_1;
|
---|
659 | end
|
---|
660 |
|
---|
661 | set(handles_RootPath,'BackgroundColor',[1 1 0])
|
---|
662 | drawnow
|
---|
663 | set(handles.Fields,'UserData',[])% reinialize data from uvmat opening
|
---|
664 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
665 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
666 | UvData.TestInputFile=1;
|
---|
667 | UvData.FileType{index}=FileType;
|
---|
668 | UvData.i1_series{index}=i1_series;
|
---|
669 | UvData.i2_series{index}=i2_series;
|
---|
670 | UvData.j1_series{index}=j1_series;
|
---|
671 | UvData.j2_series{index}=j2_series;
|
---|
672 | % set(handles.CheckFixPair,'Value',1) % activate by default the comp_input '-'input window
|
---|
673 | set(handles.FixVelType,'Value',0); %desactivate fixed veltype
|
---|
674 | if index==1
|
---|
675 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
676 | else
|
---|
677 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
|
---|
678 | end
|
---|
679 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
|
---|
680 | FileBase=fullfile(RootPath,RootFile);
|
---|
681 | if ~exist(FileName,'file')
|
---|
682 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
683 | return
|
---|
684 | end
|
---|
685 | nbfield=[];%default
|
---|
686 | nbfield_j=[];%default
|
---|
687 |
|
---|
688 | %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file
|
---|
689 | XmlData.Time=[];%default
|
---|
690 | XmlData.GeometryCalib=[];%default
|
---|
691 | TimeUnit=[];%default
|
---|
692 | testima=0; %test for image input
|
---|
693 | imainfo=[];
|
---|
694 | ColorType='falsecolor'; %default
|
---|
695 | hhh='';
|
---|
696 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
697 | testima=1;
|
---|
698 | imainfo=aviinfo([FileName]);
|
---|
699 | nbfield=imainfo.NumFrames;
|
---|
700 | nbfield_j=1;
|
---|
701 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
702 | XmlData.Time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
|
---|
703 | TimeUnit='s';
|
---|
704 | hhh=which('mmreader');
|
---|
705 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
706 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image
|
---|
707 | testima=1;
|
---|
708 | if ~isequal(SubDir,'')
|
---|
709 | RootFile=get(handles.RootFile,'String');
|
---|
710 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
711 | else
|
---|
712 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
713 | end
|
---|
714 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
715 | if length(imainfo) >1 %case of image with multiple frames
|
---|
716 | nbfield=length(imainfo);
|
---|
717 | nbfield_j=1;
|
---|
718 | end
|
---|
719 | end
|
---|
720 | if ~strcmp(hhh,'')% if the function mmreader is found (recent version of matlab)
|
---|
721 | UvData.MovieObject{index}=mmreader([FileBase FileIndices FileExt]);
|
---|
722 | else
|
---|
723 | UvData.MovieObject{index}=[];
|
---|
724 | end
|
---|
725 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
726 | if length(imainfo)>1
|
---|
727 | set(handles.num_Npx,'String',num2str(imainfo(1).Width));%fills nbre of pixels x box
|
---|
728 | set(handles.num_Npy,'String',num2str(imainfo(1).Height));%fills nbre of pixels x box
|
---|
729 | else
|
---|
730 | set(handles.num_Npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
731 | set(handles.num_Npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
732 | end
|
---|
733 | else
|
---|
734 | set(handles.num_Npx,'String','');%fills nbre of pixels x box
|
---|
735 | set(handles.num_Npy,'String','');%fills nbre of pixels x box
|
---|
736 | end
|
---|
737 | set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image
|
---|
738 |
|
---|
739 | %% read parameters (time, geometric calibration..) from a documentation file (.xml advised)
|
---|
740 | filexml=[FileBase '.xml'];
|
---|
741 | fileciv=[FileBase '.civ'];
|
---|
742 | warntext='';%default warning message
|
---|
743 | NbSlice=1;%default
|
---|
744 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
745 | if exist(filexml,'file')
|
---|
746 | set(handles.view_xml,'Visible','on')
|
---|
747 | set(handles.view_xml,'BackgroundColor',[1 1 0])
|
---|
748 | set(handles.view_xml,'String','view .xml')
|
---|
749 | drawnow
|
---|
750 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
751 | if ~isempty(warntext)
|
---|
752 | msgbox_uvmat('WARNING',warntext)
|
---|
753 | end
|
---|
754 | if isfield(XmlData,'TimeUnit')
|
---|
755 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
|
---|
756 | TimeUnit=XmlData.TimeUnit;
|
---|
757 | end
|
---|
758 | end
|
---|
759 | set(handles.view_xml,'BackgroundColor',[1 1 1])
|
---|
760 | drawnow
|
---|
761 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib)
|
---|
762 | if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y')
|
---|
763 | set (handles.nb_slice,'String','volume')
|
---|
764 | end
|
---|
765 | hgeometry_calib=findobj('tag','geometry_calib');
|
---|
766 | if ~isempty(hgeometry_calib)
|
---|
767 | GUserData=get(hgeometry_calib,'UserData');
|
---|
768 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,filexml))
|
---|
769 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?');
|
---|
770 | if strcmp(answer,'Yes')
|
---|
771 | geometry_calib(filexml);%diplay the new calibration points and parameters in geometry_calib
|
---|
772 | end
|
---|
773 | end
|
---|
774 | end
|
---|
775 | end
|
---|
776 | elseif exist(fileciv,'file')% if .civ file found
|
---|
777 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
778 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
779 | GeometryCalib.Tx=0;
|
---|
780 | GeometryCalib.Ty=0;
|
---|
781 | GeometryCalib.Tz=1;
|
---|
782 | GeometryCalib.dpx=1;
|
---|
783 | GeometryCalib.dpy=1;
|
---|
784 | GeometryCalib.sx=1;
|
---|
785 | GeometryCalib.Cx=0;
|
---|
786 | GeometryCalib.Cy=0;
|
---|
787 | GeometryCalib.f=1;
|
---|
788 | GeometryCalib.kappa1=0;
|
---|
789 | GeometryCalib.CoordUnit='cm';
|
---|
790 | XmlData.GeometryCalib=GeometryCalib;
|
---|
791 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
792 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
793 | end
|
---|
794 | set(handles.num_Npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
795 | set(handles.num_Npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
796 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
797 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
798 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
799 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
800 | set(handles.view_xml,'Visible','on')
|
---|
801 | set(handles.view_xml,'String','view .civ')
|
---|
802 | else
|
---|
803 | set(handles.view_xml,'Visible','off')
|
---|
804 | end
|
---|
805 |
|
---|
806 | %% store last index in handles.lat_i and .last_j
|
---|
807 | nbfield=max(max(i2_series));
|
---|
808 | if isempty(nbfield)
|
---|
809 | nbfield=max(max(i1_series));
|
---|
810 | end
|
---|
811 | nbfield_j=max(max(j2_series));
|
---|
812 | if isempty(nbfield_j)
|
---|
813 | nbfield_j=max(max(j1_series));
|
---|
814 | end
|
---|
815 | if ~isempty(XmlData.Time)
|
---|
816 | nbfield=size(XmlData.Time,1);
|
---|
817 | nbfield_j=size(XmlData.Time,2);
|
---|
818 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
|
---|
819 | if isequal(nbfield,1) && ~isequal(nbfield_j,1)% .Time is a line vector
|
---|
820 | NomType=get(handles.NomType,'String');
|
---|
821 | if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
|
---|
822 | XmlData.Time=(XmlData.Time)';
|
---|
823 | nbfield=nbfield_j;
|
---|
824 | nbfield_j=1;
|
---|
825 | end
|
---|
826 | end
|
---|
827 | end
|
---|
828 | last_i_cell=get(handles.last_i,'String');
|
---|
829 | if isempty(nbfield)
|
---|
830 | last_i_cell{1}='';
|
---|
831 | else
|
---|
832 | last_i_cell{1}=num2str(nbfield);
|
---|
833 | end
|
---|
834 | set(handles.last_i,'String',last_i_cell)
|
---|
835 | last_j_cell=get(handles.last_j,'String');
|
---|
836 | if isempty(nbfield_j)
|
---|
837 | last_j_cell{1}='';
|
---|
838 | else
|
---|
839 | last_j_cell{1}=num2str(nbfield_j);
|
---|
840 | end
|
---|
841 | set(handles.last_j,'String',last_j_cell);
|
---|
842 |
|
---|
843 | %% store geometric calibration in UvData
|
---|
844 | if isfield(XmlData,'GeometryCalib')
|
---|
845 | GeometryCalib=XmlData.GeometryCalib;
|
---|
846 | if isempty(GeometryCalib)
|
---|
847 | set(handles.pxcm,'String','')
|
---|
848 | set(handles.pycm,'String','')
|
---|
849 | set(handles.transform_fct,'Value',1); % no transform by default
|
---|
850 | else
|
---|
851 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
|
---|
852 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
|
---|
853 | set(handles.pxcm,'String','var')
|
---|
854 | set(handles.pycm,'String','var')
|
---|
855 | elseif isfield(GeometryCalib,'fx_fy')
|
---|
856 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
857 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
858 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
859 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
860 | end
|
---|
861 | if ~get(handles.CheckFixLimits,'Value')
|
---|
862 | set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off
|
---|
863 | end
|
---|
864 | if isfield(GeometryCalib,'SliceCoord')
|
---|
865 |
|
---|
866 | siz=size(GeometryCalib.SliceCoord);
|
---|
867 | if siz(1)>1
|
---|
868 | NbSlice=siz(1);
|
---|
869 | set(handles.slices,'Visible','on')
|
---|
870 | set(handles.slices,'Value',1)
|
---|
871 | end
|
---|
872 | if isfield(GeometryCalib,'VolumeScan') && isequal(GeometryCalib.VolumeScan,'y')
|
---|
873 | set(handles.nb_slice,'String','volume')
|
---|
874 | else
|
---|
875 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
876 | end
|
---|
877 | slices_Callback([],[], handles)
|
---|
878 | end
|
---|
879 | end
|
---|
880 | end
|
---|
881 |
|
---|
882 | %% update the data attached to the uvmat interface
|
---|
883 | if ~isempty(TimeUnit)
|
---|
884 | set(handles.time_txt,'String',['time (' TimeUnit ')'])
|
---|
885 | end
|
---|
886 | UvData.TimeUnit=TimeUnit;
|
---|
887 | UvData.XmlData{index}=XmlData;
|
---|
888 | UvData.NewSeries=1;
|
---|
889 | % UvData.MovieObject=MovieObject;
|
---|
890 |
|
---|
891 | %display warning message
|
---|
892 | if ~isequal(warntext,'')
|
---|
893 | msgbox_uvmat('WARNING',warntext);
|
---|
894 | end
|
---|
895 |
|
---|
896 | %% set default options in menu 'Fields'
|
---|
897 | if ~testima
|
---|
898 | testcivx=0;
|
---|
899 | if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field)
|
---|
900 | set(handles_Fields,'Value',1)
|
---|
901 | set(handles_Fields,'String',{'get_field...'})
|
---|
902 | UvData=rmfield(UvData,'FieldsString');
|
---|
903 | else
|
---|
904 | Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ');
|
---|
905 | if strcmp(Data.Conventions,'uvmat/civdata') ||( ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0))%if the new input is Civx
|
---|
906 | FieldList=calc_field;
|
---|
907 | set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
|
---|
908 | set(handles_Fields,'Value',2) % set menu to 'velocity'
|
---|
909 | col_vec=FieldList;
|
---|
910 | col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar)
|
---|
911 | testcivx=1;
|
---|
912 | end
|
---|
913 | if ~testcivx
|
---|
914 | set(handles_Fields,'Value',1) % set menu to 'get_field...
|
---|
915 | set(handles_Fields,'String',{'get_field...'})
|
---|
916 | col_vec={'get_field...'};
|
---|
917 | end
|
---|
918 | set(handles.ListColorScalar,'String',col_vec)
|
---|
919 | end
|
---|
920 | end
|
---|
921 | set(handles.uvmat,'UserData',UvData)
|
---|
922 |
|
---|
923 | %% set index navigation options and refresh plots
|
---|
924 | scan_option='i';%default
|
---|
925 | state_j='off'; %default
|
---|
926 | if index==2
|
---|
927 | if get(handles.scan_j,'Value')
|
---|
928 | scan_option='j'; %keep the scan option for the second fiel series
|
---|
929 | end
|
---|
930 | if strcmp(get(handles.j1,'Visible'),'on')
|
---|
931 | state_j='on';
|
---|
932 | end
|
---|
933 | end
|
---|
934 | if ~isempty(j1_series)
|
---|
935 | state_j='on';
|
---|
936 | if isequal(nbfield,1) &&index==1
|
---|
937 | scan_option='j'; %scan j index by default if nbfield=1
|
---|
938 | end
|
---|
939 | end
|
---|
940 | if isequal(scan_option,'i')
|
---|
941 | set(handles.scan_i,'Value',1)
|
---|
942 | scan_i_Callback([],[], handles);
|
---|
943 | else
|
---|
944 | set(handles.scan_j,'Value',1)
|
---|
945 | scan_j_Callback([],[], handles);
|
---|
946 | end
|
---|
947 | set(handles.scan_j,'Visible',state_j)
|
---|
948 | set(handles.j1,'Visible',state_j)
|
---|
949 | set(handles.j2,'Visible',state_j)
|
---|
950 | set(handles.last_j,'Visible',state_j);
|
---|
951 | set(handles.frame_j,'Visible',state_j);
|
---|
952 | set(handles.j_text,'Visible',state_j);
|
---|
953 | if ~isempty(i2_series)||~isempty(j2_series)
|
---|
954 | set(handles.CheckFixPair,'Visible','on')
|
---|
955 | elseif index==1
|
---|
956 | set(handles.CheckFixPair,'Visible','off')
|
---|
957 | end
|
---|
958 |
|
---|
959 | %% view the field
|
---|
960 | run0_Callback([],[], handles); %view field
|
---|
961 | mask_test=get(handles.CheckMask,'value');
|
---|
962 | if mask_test
|
---|
963 | MaskData=get(handles.CheckMask,'UserData');
|
---|
964 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
965 | delete(MaskData.maskhandle) %delete old mask
|
---|
966 | end
|
---|
967 | CheckMask_Callback([],[],handles)
|
---|
968 | end
|
---|
969 |
|
---|
970 | %% update list of recent files in the menubar
|
---|
971 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...
|
---|
972 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];
|
---|
973 | str_find=strcmp(FileName,MenuFile);
|
---|
974 | if isempty(find(str_find,1))
|
---|
975 | MenuFile=[{FileName};MenuFile];%insert the current file if not already in the list
|
---|
976 | end
|
---|
977 | for ifile=1:min(length(MenuFile),5)
|
---|
978 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
|
---|
979 | eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',MenuFile{ifile});'])
|
---|
980 | end
|
---|
981 | dir_perso=prefdir;
|
---|
982 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
983 | if exist(profil_perso,'file')
|
---|
984 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat
|
---|
985 | else
|
---|
986 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat
|
---|
987 | end
|
---|
988 |
|
---|
989 |
|
---|
990 | %------------------------------------------------------------------------
|
---|
991 | % --- Executes on the menu Open/Browse_1 for the second input field,
|
---|
992 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
993 | function MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
994 | %------------------------------------------------------------------------
|
---|
995 | % huvmat=get(handles.run0,'parent');
|
---|
996 | UvData=get(handles.uvmat,'UserData');
|
---|
997 |
|
---|
998 | RootPath=get(handles.RootPath,'String');
|
---|
999 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
1000 | {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
|
---|
1001 | '*.xml', '.xml files '; ...
|
---|
1002 | '*.xls', '.xls files '; ...
|
---|
1003 | '*.civ', '.civ files '; ...
|
---|
1004 | '*.jpg','.jpg image files'; ...
|
---|
1005 | '*.png','.png image files'; ...
|
---|
1006 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
1007 | '*.nc','.netcdf files'; ...
|
---|
1008 | '*.cdf','.netcdf files'; ...
|
---|
1009 | '*.cmx','.cmx text files';...
|
---|
1010 | '*.cmx2','.cmx2 text files';...
|
---|
1011 | '*.fig','.fig files (matlab fig)';...
|
---|
1012 | '*.log','.log text files ';...
|
---|
1013 | '*.dat','.dat text files ';...
|
---|
1014 | '*.*', 'All Files (*.*)'}, ...
|
---|
1015 | 'Pick a second file for comparison',RootPath);
|
---|
1016 | fileinput_1=[PathName FileName];%complete file name
|
---|
1017 | sizf=size(fileinput_1);
|
---|
1018 | if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end
|
---|
1019 |
|
---|
1020 | % refresh the current displayed field
|
---|
1021 | set(handles.SubField,'Value',1)
|
---|
1022 | display_file_name(hObject,eventdata,handles,fileinput_1,2)
|
---|
1023 |
|
---|
1024 | %update list of recent files in the menubar
|
---|
1025 | MenuFile_1=fileinput_1;
|
---|
1026 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
1027 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
1028 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
1029 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
1030 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
1031 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
1032 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
1033 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
1034 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
1035 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
1036 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
1037 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
1038 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
1039 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
1040 | dir_perso=prefdir;
|
---|
1041 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
1042 | if exist(profil_perso,'file')
|
---|
1043 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
1044 | else
|
---|
1045 | txt=ver('MATLAB');
|
---|
1046 | Release=txt.Release;
|
---|
1047 | relnumb=str2double(Release(3:4));
|
---|
1048 | if relnumb >= 14
|
---|
1049 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
1050 | else
|
---|
1051 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
1052 | end
|
---|
1053 | end
|
---|
1054 |
|
---|
1055 | % -----------------------------------------------------------------------
|
---|
1056 | % --- Open again as second field the file whose name has been recorded in MenuFile_1
|
---|
1057 | function MenuFile_1_1_Callback(hObject, eventdata, handles)
|
---|
1058 | % -----------------------------------------------------------------------
|
---|
1059 | fileinput_1=get(handles.MenuFile_1_1,'Label');
|
---|
1060 | set(handles.SubField,'Value',1)
|
---|
1061 | display_file_name(hObject,eventdata,handles,fileinput_1,2)
|
---|
1062 |
|
---|
1063 | % -----------------------------------------------------------------------
|
---|
1064 | % --- Open again as second field the file whose name has been recorded in MenuFile_2
|
---|
1065 | function MenuFile_2_1_Callback(hObject, eventdata, handles)
|
---|
1066 | % -----------------------------------------------------------------------
|
---|
1067 | fileinput_1=get(handles.MenuFile_2_1,'Label');
|
---|
1068 | set(handles.SubField,'Value',1)
|
---|
1069 | display_file_name(hObject,eventdata,handles,fileinput_1,2)
|
---|
1070 |
|
---|
1071 | % -----------------------------------------------------------------------
|
---|
1072 | % --- Open again as second field the file whose name has been recorded in MenuFile_3
|
---|
1073 | function MenuFile_3_1_Callback(hObject, eventdata, handles)
|
---|
1074 | % -----------------------------------------------------------------------
|
---|
1075 | fileinput_1=get(handles.MenuFile_3_1,'Label');
|
---|
1076 | set(handles.SubField,'Value',1)
|
---|
1077 | display_file_name(hObject,eventdata,handles,fileinput_1,2)
|
---|
1078 |
|
---|
1079 | % -----------------------------------------------------------------------
|
---|
1080 | % --- Open again as second field the file whose name has been recorded in MenuFile_4
|
---|
1081 | function MenuFile_4_1_Callback(hObject, eventdata, handles)
|
---|
1082 | % -----------------------------------------------------------------------
|
---|
1083 | fileinput_1=get(handles.MenuFile_4_1,'Label');
|
---|
1084 | set(handles.SubField,'Value',1)
|
---|
1085 | display_file_name(hObject,eventdata,handles,fileinput_1,2)
|
---|
1086 |
|
---|
1087 | % -----------------------------------------------------------------------
|
---|
1088 | % --- Open again as second field the file whose name has been recorded in MenuFile_5
|
---|
1089 | function MenuFile_5_1_Callback(hObject, eventdata, handles)
|
---|
1090 | % -----------------------------------------------------------------------
|
---|
1091 | fileinput_1=get(handles.MenuFile_5_1,'Label');
|
---|
1092 | set(handles.SubField,'Value',1)
|
---|
1093 | display_file_name(hObject,eventdata,handles,fileinput_1,2)
|
---|
1094 |
|
---|
1095 | %-----------------------------------------------------------------------
|
---|
1096 | % --- Called by action in RootPath_1 edit box
|
---|
1097 | function RootPath_1_Callback(hObject,eventdata,handles)
|
---|
1098 | % -----------------------------------------------------------------------
|
---|
1099 | % update_rootinfo_1(hObject,eventdata,handles)
|
---|
1100 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
|
---|
1101 | fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
|
---|
1102 | % detect the file type, get the movie object if relevant, and look for the corresponding file series:
|
---|
1103 | [tild,tild,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fileinput);
|
---|
1104 | % initiate the input file series and refresh the current field view:
|
---|
1105 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2);
|
---|
1106 | %-----------------------------------------------------------------------
|
---|
1107 | % --- Called by action in RootFile_1 edit box
|
---|
1108 | function RootFile_1_Callback(hObject, eventdata, handles)
|
---|
1109 | % -----------------------------------------------------------------------
|
---|
1110 | RootPath_1_Callback(hObject,eventdata,handles)
|
---|
1111 |
|
---|
1112 | %------------------------------------------------------------------------
|
---|
1113 | % --- Called by action in FileIndex_1 edit box
|
---|
1114 | function FileIndex_1_Callback(hObject, eventdata, handles)
|
---|
1115 | %------------------------------------------------------------------------
|
---|
1116 | run0_Callback(hObject, eventdata, handles)
|
---|
1117 |
|
---|
1118 | %------------------------------------------------------------------------
|
---|
1119 | % --- switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
1120 | function scan_i_Callback(hObject, eventdata, handles)
|
---|
1121 | %------------------------------------------------------------------------
|
---|
1122 | if get(handles.scan_i,'Value')==1
|
---|
1123 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
1124 | set(handles.scan_j,'Value',0)
|
---|
1125 | else
|
---|
1126 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
1127 | set(handles.scan_j,'Value',1)
|
---|
1128 | end
|
---|
1129 | scan_j_Callback(hObject, eventdata, handles)
|
---|
1130 |
|
---|
1131 | %------------------------------------------------------------------------
|
---|
1132 | % --- switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
1133 | function scan_j_Callback(hObject, eventdata, handles)
|
---|
1134 | %------------------------------------------------------------------------
|
---|
1135 | if get(handles.scan_j,'Value')==1
|
---|
1136 | set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
1137 | set(handles.scan_i,'Value',0)
|
---|
1138 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
1139 | % NomType=get(handles.NomType,'String');
|
---|
1140 | % switch NomType
|
---|
1141 | % case {'_1_1-2','#_ab','%3dab'},% pair with j index
|
---|
1142 | % set(handles.CheckFixPair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off')
|
---|
1143 | % otherwise
|
---|
1144 | % set(handles.CheckFixPair,'Visible','off')
|
---|
1145 | % end
|
---|
1146 | else
|
---|
1147 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
1148 | set(handles.scan_i,'Value',1)
|
---|
1149 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
1150 | set(handles.CheckFixPair,'Visible','off')
|
---|
1151 | end
|
---|
1152 |
|
---|
1153 | %------------------------------------------------------------------------
|
---|
1154 | function i1_Callback(hObject, eventdata, handles)
|
---|
1155 | %------------------------------------------------------------------------
|
---|
1156 | set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
1157 | NomType=get(handles.NomType,'String');
|
---|
1158 | i1=stra2num(get(handles.i1,'String'));
|
---|
1159 | i2=stra2num(get(handles.i2,'String'));
|
---|
1160 | j1=stra2num(get(handles.j1,'String'));
|
---|
1161 | j2=stra2num(get(handles.j2,'String'));
|
---|
1162 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
|
---|
1163 | %indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
1164 | set(handles.FileIndex,'String',indices)
|
---|
1165 | set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])
|
---|
1166 | if get(handles.SubField,'Value')==1
|
---|
1167 | NomType_1=get(handles.NomType_1,'String');
|
---|
1168 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
|
---|
1169 | %indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
|
---|
1170 | set(handles.FileIndex_1,'String',indices)
|
---|
1171 | set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
1172 | end
|
---|
1173 |
|
---|
1174 | %------------------------------------------------------------------------
|
---|
1175 | function i2_Callback(hObject, eventdata, handles)
|
---|
1176 | %------------------------------------------------------------------------
|
---|
1177 | set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])
|
---|
1178 | i1_Callback(hObject, eventdata, handles)
|
---|
1179 |
|
---|
1180 | %------------------------------------------------------------------------
|
---|
1181 | function j1_Callback(hObject, eventdata, handles)
|
---|
1182 | %------------------------------------------------------------------------
|
---|
1183 | set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
1184 | i1_Callback(hObject, eventdata, handles)
|
---|
1185 |
|
---|
1186 | %------------------------------------------------------------------------
|
---|
1187 | function j2_Callback(hObject, eventdata, handles)
|
---|
1188 | %------------------------------------------------------------------------
|
---|
1189 | set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])
|
---|
1190 | i1_Callback(hObject, eventdata, handles)
|
---|
1191 |
|
---|
1192 | %------------------------------------------------------------------------
|
---|
1193 | function slices_Callback(hObject, eventdata, handles)
|
---|
1194 | %------------------------------------------------------------------------
|
---|
1195 | if get(handles.slices,'Value')==1
|
---|
1196 | set(handles.slices,'BackgroundColor',[1 1 0])
|
---|
1197 | set(handles.nb_slice,'Visible','on')
|
---|
1198 | set(handles.z_text,'Visible','on')
|
---|
1199 | set(handles.z_index,'Visible','on')
|
---|
1200 | nb_slice_Callback(hObject, eventdata, handles)
|
---|
1201 | else
|
---|
1202 | set(handles.nb_slice,'Visible','off')
|
---|
1203 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7])
|
---|
1204 | set(handles.z_text,'Visible','off')
|
---|
1205 | set(handles.z_index,'Visible','off')
|
---|
1206 | set(handles.masklevel,'Value',1)
|
---|
1207 | set(handles.masklevel,'String',{'1'})
|
---|
1208 | end
|
---|
1209 |
|
---|
1210 | %------------------------------------------------------------------------
|
---|
1211 | function nb_slice_Callback(hObject, eventdata, handles)
|
---|
1212 | %------------------------------------------------------------------------
|
---|
1213 | nb_slice_str=get(handles.nb_slice,'String');
|
---|
1214 | if isequal(nb_slice_str,'volume')
|
---|
1215 | num=stra2num(get(handles.j1,'String'));
|
---|
1216 | last_j=get(handles.last_j,'String');
|
---|
1217 | nbslice=str2double(last_j{1});
|
---|
1218 | else
|
---|
1219 | num=str2double(get(handles.i1,'String'));
|
---|
1220 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
1221 | end
|
---|
1222 | z=mod(num-1,nbslice)+1;
|
---|
1223 | set(handles.z_index,'String',num2str(z))
|
---|
1224 | for ilist=1:nbslice
|
---|
1225 | list_index{ilist,1}=num2str(ilist);
|
---|
1226 | end
|
---|
1227 | set(handles.masklevel,'String',list_index)
|
---|
1228 | set(handles.masklevel,'Value',z)
|
---|
1229 |
|
---|
1230 | %------------------------------------------------------------------------
|
---|
1231 | % --- Executes on button press in view_xml.
|
---|
1232 | function view_xml_Callback(hObject, eventdata, handles)
|
---|
1233 | %------------------------------------------------------------------------
|
---|
1234 | %[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
1235 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
1236 | FileBase=fullfile(RootPath,RootFile);
|
---|
1237 | option=get(handles.view_xml,'String');
|
---|
1238 | if isequal(option,'view .xml')
|
---|
1239 | FileXml=[FileBase '.xml'];
|
---|
1240 | heditxml=editxml(FileXml);
|
---|
1241 | end
|
---|
1242 |
|
---|
1243 | %------------------------------------------------------------------------
|
---|
1244 | % --- Executes on button press in CheckMask.
|
---|
1245 | function CheckMask_Callback(hObject, eventdata, handles)
|
---|
1246 | %------------------------------------------------------------------------
|
---|
1247 | %case of view mask selection
|
---|
1248 | if isequal(get(handles.CheckMask,'Value'),1)
|
---|
1249 | % [FF,RootPath,FileBase]=read_file_boxes(handles);
|
---|
1250 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
1251 | FileBase=fullfile(RootPath,RootFile);
|
---|
1252 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
1253 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
1254 | currentdir=pwd;
|
---|
1255 | cd(RootPath);
|
---|
1256 | maskfiles=dir('*_*mask_*.png');%look for a mask file
|
---|
1257 | cd(currentdir);%come back to the working directory
|
---|
1258 | mdetect=0;
|
---|
1259 | if ~isempty(maskfiles)
|
---|
1260 | for ilist=1:length(maskfiles)
|
---|
1261 | maskname=maskfiles(ilist).name;% take the first mask file in the list
|
---|
1262 | [tild,tild,tild,tild,tild,tild,tild,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname);
|
---|
1263 | % [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
|
---|
1264 | [tild,Name]=fileparts(maskname);
|
---|
1265 | Namedouble=double(Name);
|
---|
1266 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
|
---|
1267 | ind_mask=findstr('mask',Name);
|
---|
1268 | i=ind_mask-1;
|
---|
1269 | while val(i)==0 && i>0
|
---|
1270 | i=i-1;
|
---|
1271 | end
|
---|
1272 | nbmask_str=str2num(Name(i+1:ind_mask-1));
|
---|
1273 | if ~isempty(nbmask_str)
|
---|
1274 | nbslice(ilist)=nbmask_str; % number of different masks (slices)
|
---|
1275 | end
|
---|
1276 | end
|
---|
1277 | if isequal(min(nbslice),max(nbslice))
|
---|
1278 | nbslice=nbslice(1);
|
---|
1279 | else
|
---|
1280 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory')
|
---|
1281 | return
|
---|
1282 | end
|
---|
1283 | if ~isempty(nbslice) && Name(i)=='_'
|
---|
1284 | Mask.Base=[FileBase Name(i:ind_mask+3)];
|
---|
1285 | Mask.NbSlice=nbslice;
|
---|
1286 | num_i1=mod(num_i1-1,nbslice)+1;
|
---|
1287 | Mask.NomType=regexprep(Mask_NomType{1},'0','');%remove '0' in nom type for masks
|
---|
1288 | [RootPath,RootFile]=fileparts(Mask.Base);
|
---|
1289 | maskname=fullfile_uvmat(RootPath,'',RootFile,'.png',Mask.NomType,num_i1,[],num_j1);
|
---|
1290 | %maskname=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
|
---|
1291 | mdetect=exist(maskname,'file');
|
---|
1292 | if mdetect
|
---|
1293 | set(handles.nb_slice,'String',Name(i+1:ind_mask-1));
|
---|
1294 | set(handles.nb_slice,'BackgroundColor',[1 1 0])
|
---|
1295 | set(handles.CheckMask,'UserData',Mask);
|
---|
1296 | set(handles.CheckMask,'BackgroundColor',[1 1 0])
|
---|
1297 | if nbslice > 1
|
---|
1298 | set(handles.slices,'value',1)
|
---|
1299 | slices_Callback(hObject, eventdata, handles)
|
---|
1300 | end
|
---|
1301 | end
|
---|
1302 | end
|
---|
1303 | end
|
---|
1304 | errormsg=[];%default
|
---|
1305 | if mdetect==0
|
---|
1306 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
1307 | {'*.png', ' (*.png)';
|
---|
1308 | '*.png', '.png files '; ...
|
---|
1309 | '*.*', 'All Files (*.*)'}, ...
|
---|
1310 | 'Pick a mask file *.png',FileBase);
|
---|
1311 | maskname=fullfile(PathName,FileName);
|
---|
1312 | if ~exist(maskname,'file')
|
---|
1313 | errormsg='no file browsed';
|
---|
1314 | end
|
---|
1315 | [RootDir,tild,RootFile,tild,tild,tild,tild,tild,Mask.NomType]=fileparts_uvmat(maskname);
|
---|
1316 | % [RootDir,RootFile,x1,x2,xa,xb,xext,Mask.NomType]=name2display(maskname);
|
---|
1317 | Mask.Base=fullfile(RootDir,RootFile);
|
---|
1318 | Mask.NbSlice=1;
|
---|
1319 | set(handles.CheckMask,'UserData',Mask);
|
---|
1320 | set(handles.CheckMask,'BackgroundColor',[1 1 0])
|
---|
1321 | end
|
---|
1322 | if isempty(errormsg)
|
---|
1323 | errormsg=update_mask(handles,num_i1,num_j1);
|
---|
1324 | end
|
---|
1325 | if ~isempty(errormsg)
|
---|
1326 | set(handles.CheckMask,'Value',0)
|
---|
1327 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7])
|
---|
1328 | end
|
---|
1329 | else % desactivate mask display
|
---|
1330 | MaskData=get(handles.CheckMask,'UserData');
|
---|
1331 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
1332 | delete(MaskData.maskhandle)
|
---|
1333 | end
|
---|
1334 | set(handles.CheckMask,'UserData',[])
|
---|
1335 | UvData=get(handles.uvmat,'UserData');
|
---|
1336 | if isfield(UvData,'MaskName')
|
---|
1337 | UvData=rmfield(UvData,'MaskName');
|
---|
1338 | set(handles.uvmat,'UserData',UvData)
|
---|
1339 | end
|
---|
1340 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7])
|
---|
1341 | end
|
---|
1342 |
|
---|
1343 | %------------------------------------------------------------------------
|
---|
1344 | function errormsg=update_mask(handles,num_i1,num_j1)
|
---|
1345 | %------------------------------------------------------------------------
|
---|
1346 | errormsg=[];%default
|
---|
1347 | MaskData=get(handles.CheckMask,'UserData');
|
---|
1348 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
1349 | uistack(MaskData.maskhandle,'top');
|
---|
1350 | end
|
---|
1351 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
1352 | [RootPath,RootFile]=fileparts(MaskData.Base);
|
---|
1353 | MaskName=fullfile_uvmat(RootPath,'',RootFile,'.png',MaskData.NomType,num_i1_mask,[],num_j1);
|
---|
1354 | %MaskName=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
1355 | huvmat=get(handles.CheckMask,'parent');
|
---|
1356 | UvData=get(huvmat,'UserData');
|
---|
1357 |
|
---|
1358 | %update mask image if the mask is new
|
---|
1359 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
1360 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
1361 | set(huvmat,'UserData',UvData);
|
---|
1362 | if ~exist(MaskName,'file')
|
---|
1363 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
1364 | delete(MaskData.maskhandle)
|
---|
1365 | end
|
---|
1366 | else
|
---|
1367 | %read mask image
|
---|
1368 | Mask.AName='image';
|
---|
1369 | Mask.A=imread(MaskName);
|
---|
1370 | npxy=size(Mask.A);
|
---|
1371 | test_error=0;
|
---|
1372 | if length(npxy)>2
|
---|
1373 | errormsg=[MaskName ' is not a grey scale image'];
|
---|
1374 | return
|
---|
1375 | elseif ~isa(Mask.A,'uint8')
|
---|
1376 | errormsg=[MaskName ' is not a 8 bit grey level image'];
|
---|
1377 | return
|
---|
1378 | end
|
---|
1379 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
1380 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
1381 | Mask.CoordUnit='pixel';
|
---|
1382 | if isequal(get(handles.slices,'Value'),1)
|
---|
1383 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
1384 | num_i1=str2num(get(handles.i1,'String'));
|
---|
1385 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
1386 | end
|
---|
1387 | %px to phys or other transform on field
|
---|
1388 | menu_transform=get(handles.transform_fct,'String');
|
---|
1389 | choice_value=get(handles.transform_fct,'Value');
|
---|
1390 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
1391 | transform_list=get(handles.transform_fct,'UserData');
|
---|
1392 | transform=transform_list{choice_value};
|
---|
1393 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
1394 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
1395 | Calib=UvData.XmlData{1}.GeometryCalib;
|
---|
1396 | Mask=transform(Mask,UvData.XmlData{1});
|
---|
1397 | end
|
---|
1398 | end
|
---|
1399 | flagmask=Mask.A < 200;
|
---|
1400 |
|
---|
1401 | %make brown color image
|
---|
1402 | imflag(:,:,1)=0.9*flagmask;
|
---|
1403 | imflag(:,:,2)=0.7*flagmask;
|
---|
1404 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
1405 |
|
---|
1406 | %update mask image
|
---|
1407 | hmask=[]; %default
|
---|
1408 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
1409 | hmask=MaskData.maskhandle;
|
---|
1410 | end
|
---|
1411 | if ~isempty(hmask)
|
---|
1412 | set(hmask,'CData',imflag)
|
---|
1413 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
1414 | set(hmask,'XData',Mask.AX);
|
---|
1415 | set(hmask,'YData',Mask.AY);
|
---|
1416 | % uistack(hmask,'top')
|
---|
1417 | else
|
---|
1418 | axes(handles.axes3)
|
---|
1419 | hold on
|
---|
1420 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
1421 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
1422 | set(handles.CheckMask,'UserData',MaskData)
|
---|
1423 | end
|
---|
1424 | end
|
---|
1425 | end
|
---|
1426 |
|
---|
1427 |
|
---|
1428 | %------------------------------------------------------------------------
|
---|
1429 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
1430 | %------------------------------------------------------------------------
|
---|
1431 | huvmat=get(handles.MenuExport,'parent');
|
---|
1432 | hfig=figure;
|
---|
1433 | copyobj(handles.axes3,hfig);
|
---|
1434 | map=colormap(handles.axes3);
|
---|
1435 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
1436 | colorbar
|
---|
1437 |
|
---|
1438 | %------------------------------------------------------------------------
|
---|
1439 | %------------------------------------------------------------------------
|
---|
1440 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
1441 | %------------------------------------------------------------------------
|
---|
1442 |
|
---|
1443 | %------------------------------------------------------------------------
|
---|
1444 | % --- Executes on button press in runplus: make one step forward and call
|
---|
1445 | % --- run0. The step forward is along the fields series 1 or 2 depending on
|
---|
1446 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
1447 | function runplus_Callback(hObject, eventdata, handles)
|
---|
1448 | %------------------------------------------------------------------------
|
---|
1449 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
1450 | drawnow
|
---|
1451 | %TODO: introduce the option: increment ='*' to move to the next available view
|
---|
1452 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
1453 | % if isnan(increment)
|
---|
1454 | % set(handles.increment_scan,'String','1')%default value
|
---|
1455 | % increment=1;
|
---|
1456 | % end
|
---|
1457 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
1458 | if ~isempty(errormsg)
|
---|
1459 | msgbox_uvmat('ERROR',errormsg);
|
---|
1460 | end
|
---|
1461 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
1462 |
|
---|
1463 | %------------------------------------------------------------------------
|
---|
1464 | % --- Executes on button press in runmin: make one step backward and call
|
---|
1465 | % --- run0. The step backward is along the fields series 1 or 2 depending on
|
---|
1466 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
1467 | function runmin_Callback(hObject, eventdata, handles)
|
---|
1468 | %------------------------------------------------------------------------
|
---|
1469 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
1470 | drawnow
|
---|
1471 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
1472 | % if isnan(increment)
|
---|
1473 | % set(handles.increment_scan,'String','1')%default value
|
---|
1474 | % increment=1;
|
---|
1475 | % end
|
---|
1476 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
1477 | if ~isempty(errormsg)
|
---|
1478 | msgbox_uvmat('ERROR',errormsg);
|
---|
1479 | end
|
---|
1480 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
1481 |
|
---|
1482 | %------------------------------------------------------------------------
|
---|
1483 | % -- Executes on button press in Movie: make a series of +> steps
|
---|
1484 | function Movie_Callback(hObject, eventdata, handles)
|
---|
1485 | %------------------------------------------------------------------------
|
---|
1486 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
1487 | drawnow
|
---|
1488 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
1489 | % if isnan(increment)
|
---|
1490 | % set(handles.increment_scan,'String','1')%default value
|
---|
1491 | % increment=1;
|
---|
1492 | % end
|
---|
1493 | set(handles.STOP,'Visible','on')
|
---|
1494 | set(handles.speed,'Visible','on')
|
---|
1495 | set(handles.speed_txt,'Visible','on')
|
---|
1496 | set(handles.Movie,'BusyAction','queue')
|
---|
1497 | UvData=get(handles.uvmat,'UserData');
|
---|
1498 |
|
---|
1499 | while get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
|
---|
1500 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
1501 | if ~isempty(errormsg)
|
---|
1502 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
1503 | return
|
---|
1504 | end
|
---|
1505 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
1506 | end
|
---|
1507 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
1508 | UvData.aviobj=close(UvData.aviobj);
|
---|
1509 | set(handles.uvmat,'UserData',UvData);
|
---|
1510 | end
|
---|
1511 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
1512 |
|
---|
1513 | %------------------------------------------------------------------------
|
---|
1514 | % -- Executes on button press in Movie: make a series of <- steps
|
---|
1515 | function MovieBackward_Callback(hObject, eventdata, handles)
|
---|
1516 | %------------------------------------------------------------------------
|
---|
1517 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
1518 | drawnow
|
---|
1519 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
1520 | set(handles.STOP,'Visible','on')
|
---|
1521 | set(handles.speed,'Visible','on')
|
---|
1522 | set(handles.speed_txt,'Visible','on')
|
---|
1523 | set(handles.MovieBackward,'BusyAction','queue')
|
---|
1524 | UvData=get(handles.uvmat,'UserData');
|
---|
1525 |
|
---|
1526 | while get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
|
---|
1527 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
1528 | if ~isempty(errormsg)
|
---|
1529 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
1530 | return
|
---|
1531 | end
|
---|
1532 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
1533 | end
|
---|
1534 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
1535 | UvData.aviobj=close(UvData.aviobj);
|
---|
1536 | set(handles.uvmat,'UserData',UvData);
|
---|
1537 | end
|
---|
1538 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
1539 |
|
---|
1540 | %------------------------------------------------------------------------
|
---|
1541 | function STOP_Callback(hObject, eventdata, handles)
|
---|
1542 | %------------------------------------------------------------------------
|
---|
1543 | set(handles.movie_pair,'BusyAction','Cancel')
|
---|
1544 | set(handles.movie_pair,'value',0)
|
---|
1545 | set(handles.Movie,'BusyAction','Cancel')
|
---|
1546 | set(handles.MovieBackward,'BusyAction','Cancel')
|
---|
1547 | set(handles.MenuExportMovie,'BusyAction','Cancel')
|
---|
1548 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
1549 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
1550 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
1551 |
|
---|
1552 | %------------------------------------------------------------------------
|
---|
1553 | % --- function activated by runplus and run minus
|
---|
1554 | function errormsg=runpm(hObject,eventdata,handles,increment)
|
---|
1555 | %------------------------------------------------------------------------
|
---|
1556 | errormsg='';%default
|
---|
1557 | %% check for movie pair status
|
---|
1558 | movie_status=get(handles.movie_pair,'Value');
|
---|
1559 | if isequal(movie_status,1)
|
---|
1560 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
|
---|
1561 | end
|
---|
1562 |
|
---|
1563 | %% read the current input file name(s) and field indices
|
---|
1564 | InputFile=read_GUI(handles.InputFile);
|
---|
1565 | InputFile.RootFile=regexprep(InputFile.RootFile,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string
|
---|
1566 | InputFile.SubDir=regexprep(InputFile.SubDir,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string
|
---|
1567 | FileExt=InputFile.FileExt;
|
---|
1568 | NomType=get(handles.NomType,'String');
|
---|
1569 | i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
|
---|
1570 | i2=str2num(get(handles.i2,'String'));
|
---|
1571 | j1=stra2num(get(handles.j1,'String'));
|
---|
1572 | j2=stra2num(get(handles.j2,'String'));
|
---|
1573 | sub_value= get(handles.SubField,'Value');
|
---|
1574 | if sub_value % a second input file has been entered
|
---|
1575 | [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
1576 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndices_1);
|
---|
1577 | NomType_1=get(handles.NomType_1,'String');
|
---|
1578 | else
|
---|
1579 | filename_1=[];
|
---|
1580 | end
|
---|
1581 |
|
---|
1582 | %% increment (or decrement) the field indices and update the input filename(s)
|
---|
1583 | CheckSearch=0;
|
---|
1584 | if isempty(increment)
|
---|
1585 | CheckSearch=1;% search for the next available file
|
---|
1586 | set(handles.CheckFixPair,'Value',0)
|
---|
1587 | end
|
---|
1588 | CheckFixPair=get(handles.CheckFixPair,'Value');
|
---|
1589 | if CheckFixPair
|
---|
1590 | if get(handles.scan_i,'Value')==1% case of scanning along index i
|
---|
1591 | i1=i1+increment;
|
---|
1592 | i2=i2+increment;
|
---|
1593 | if sub_value
|
---|
1594 | i1_1=i1_1+increment;
|
---|
1595 | i2_1=i2_1+increment;
|
---|
1596 | end
|
---|
1597 | else % case of scanning along index j (burst numbers)
|
---|
1598 | j1=j1+increment;
|
---|
1599 | j2=j2+increment;
|
---|
1600 | if sub_value
|
---|
1601 | j1_1=j1_1+increment;
|
---|
1602 | j2_1=j2_1+increment;
|
---|
1603 | end
|
---|
1604 | end
|
---|
1605 | else
|
---|
1606 | UvData=get(handles.uvmat,'UserData');
|
---|
1607 | ref_i=i1;
|
---|
1608 | if ~isempty(i2)
|
---|
1609 | ref_i=floor((i1+i2)/2);
|
---|
1610 | end
|
---|
1611 | ref_j=1;
|
---|
1612 | if ~isempty(j1)
|
---|
1613 | ref_j=j1;
|
---|
1614 | if ~isempty(j2)
|
---|
1615 | ref_j=floor((j1+j2)/2);
|
---|
1616 | end
|
---|
1617 | end
|
---|
1618 | if ~isempty(increment)
|
---|
1619 | if get(handles.scan_i,'Value')==1% case of scanning along index i
|
---|
1620 | ref_i=ref_i+increment;
|
---|
1621 | else % case of scanning along index j (burst numbers)
|
---|
1622 | ref_j=ref_j+increment;
|
---|
1623 | end
|
---|
1624 | else% free increment
|
---|
1625 | if isequal(get(handles.runplus,'BackgroundColor'),[1 1 0])% if runplus is activated
|
---|
1626 | step=1;
|
---|
1627 | else
|
---|
1628 | step=-1;
|
---|
1629 | end
|
---|
1630 | if get(handles.scan_i,'Value')==1% case of scanning along index i
|
---|
1631 | ref_i=ref_i+step;
|
---|
1632 | while ref_i>=0 && size(UvData.i1_series{1},1)>=ref_i+1 && UvData.i1_series{1}(ref_i+1,ref_j+1,1)==0
|
---|
1633 | ref_i=ref_i+step;
|
---|
1634 | end
|
---|
1635 | else % case of scanning along index j (burst numbers)
|
---|
1636 | ref_j=ref_j+step;
|
---|
1637 | while ref_j>=0 && size(UvData.i1_series{1},2)>=ref_j+1 && UvData.i1_series{1}(ref_i+1,ref_j+1,1)==0
|
---|
1638 | ref_j=ref_j+step;
|
---|
1639 | end
|
---|
1640 | end
|
---|
1641 | end
|
---|
1642 | if ref_i<0
|
---|
1643 | errormsg='minimum i index reached';
|
---|
1644 | elseif ref_j<0
|
---|
1645 | errormsg='minimum j index reached';
|
---|
1646 | elseif ref_i+1>size(UvData.i1_series{1},1)
|
---|
1647 | errormsg='maximum i index reached';
|
---|
1648 | elseif ref_j+1>size(UvData.i1_series{1},2)
|
---|
1649 | errormsg='maximum j index reached';
|
---|
1650 | end
|
---|
1651 | if ~isempty(errormsg)
|
---|
1652 | return
|
---|
1653 | end
|
---|
1654 | i1=UvData.i1_series{1}(ref_i+1,ref_j+1,1);
|
---|
1655 | if ~isempty(UvData.i2_series{1})
|
---|
1656 | i2=UvData.i2_series{1}(ref_i+1,ref_j+1,1);
|
---|
1657 | end
|
---|
1658 | if ~isempty(UvData.j1_series{1})
|
---|
1659 | j1=UvData.j1_series{1}(ref_i+1,ref_j+1,1);
|
---|
1660 | end
|
---|
1661 | if ~isempty(UvData.j2_series{1})
|
---|
1662 | j2=UvData.j2_series{1}(ref_i+1,ref_j+1,1);
|
---|
1663 | end
|
---|
1664 | end
|
---|
1665 | filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2);
|
---|
1666 | if sub_value
|
---|
1667 | filename_1=fullfile_uvmat(InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,FileExt_1,NomType_1,i1_1,i2_1,j1_1,j2_1);
|
---|
1668 | end
|
---|
1669 |
|
---|
1670 | %% refresh plots
|
---|
1671 | errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2);
|
---|
1672 |
|
---|
1673 | %% update the index counters if the index move is successfull
|
---|
1674 | if isempty(errormsg)
|
---|
1675 | set(handles.i1,'String',num2stra(i1,NomType,1));
|
---|
1676 | if isequal(i2,i1)
|
---|
1677 | set(handles.i2,'String','');
|
---|
1678 | else
|
---|
1679 | set(handles.i2,'String',num2stra(i2,NomType,1));
|
---|
1680 | end
|
---|
1681 | set(handles.j1,'String',num2stra(j1,NomType,2));
|
---|
1682 | if isequal(j2,j1)
|
---|
1683 | set(handles.j2,'String','');
|
---|
1684 | else
|
---|
1685 | set(handles.j2,'String',num2stra(j2,NomType,2));
|
---|
1686 | end
|
---|
1687 | % [indices]=name_generator('',i1,j1,'',NomType,1,i2,j2,'');
|
---|
1688 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
|
---|
1689 | set(handles.FileIndex,'String',indices);
|
---|
1690 | if ~isempty(filename_1)
|
---|
1691 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,j2_1);
|
---|
1692 | %indices_1=name_generator('',i1_1,j1_1,'',NomType_1,1,i2_1,j2_1,'');
|
---|
1693 | set(handles.FileIndex_1,'String',indices_1);
|
---|
1694 | end
|
---|
1695 | if isequal(movie_status,1)
|
---|
1696 | set(handles.movie_pair,'Value',1)
|
---|
1697 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
|
---|
1698 | end
|
---|
1699 | end
|
---|
1700 |
|
---|
1701 | %------------------------------------------------------------------------
|
---|
1702 | % --- Executes on button press in movie_pair: create an alternating movie with two view
|
---|
1703 | function movie_pair_Callback(hObject, eventdata, handles)
|
---|
1704 | %------------------------------------------------------------------------
|
---|
1705 | %% stop movie action if the movie_pair button is off
|
---|
1706 | if ~get(handles.movie_pair,'value')
|
---|
1707 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
|
---|
1708 | set(handles.i2,'String','')
|
---|
1709 | set(handles.j2,'String','')
|
---|
1710 | return
|
---|
1711 | else
|
---|
1712 | set(handles.movie_pair,'BusyAction','queue')
|
---|
1713 | end
|
---|
1714 |
|
---|
1715 | %% initialisation
|
---|
1716 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
1717 | drawnow
|
---|
1718 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
1719 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
1720 | FieldName=list_fields{index_fields}; % selected field
|
---|
1721 | UvData=get(handles.uvmat,'UserData');
|
---|
1722 | if isequal(FieldName,'image')
|
---|
1723 | test_1=0;
|
---|
1724 | [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles);
|
---|
1725 | NomType=get(handles.NomType,'String');
|
---|
1726 | else
|
---|
1727 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
1728 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
1729 | FieldName=list_fields{index_fields}; % selected field
|
---|
1730 | if isequal(FieldName,'image')
|
---|
1731 | test_1=1;
|
---|
1732 | [RootPath,tild,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles);
|
---|
1733 | else
|
---|
1734 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
|
---|
1735 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
1736 | set(handles.movie_pair,'Value',0)
|
---|
1737 | return
|
---|
1738 | end
|
---|
1739 | end
|
---|
1740 | num_i1=str2num(get(handles.i1,'String'));
|
---|
1741 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
1742 | num_i2=str2num(get(handles.i2,'String'));
|
---|
1743 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
1744 | if isempty(num_j2)
|
---|
1745 | if isempty(num_i2)
|
---|
1746 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
|
---|
1747 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
1748 | set(handles.movie_pair,'Value',0)
|
---|
1749 | return
|
---|
1750 | else
|
---|
1751 | num_j2=num_j1;%repeat the index i1 by default
|
---|
1752 | end
|
---|
1753 | end
|
---|
1754 | if isempty(num_i2)
|
---|
1755 | num_i2=num_i1;%repeat the index i1 by default
|
---|
1756 | end
|
---|
1757 | % imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
|
---|
1758 | imaname_1=fullfile_uvmat(RootPath,'',RootFile,Ext,NomType,num_i2,[],num_j2);
|
---|
1759 | if ~exist(imaname_1,'file')
|
---|
1760 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']);
|
---|
1761 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
1762 | set(handles.movie_pair,'Value',0)
|
---|
1763 | return
|
---|
1764 | end
|
---|
1765 |
|
---|
1766 | %% read the second image
|
---|
1767 | Field.AName='image';
|
---|
1768 | if test_1
|
---|
1769 | Field_a=UvData.Field_1;
|
---|
1770 | else
|
---|
1771 | Field_a=UvData.Field;
|
---|
1772 | end
|
---|
1773 | Field_b.AX=Field_a.AX;
|
---|
1774 | Field_b.AY=Field_a.AY;
|
---|
1775 | % z index
|
---|
1776 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
1777 | if ~isempty(nbslice)
|
---|
1778 | Field_b.ZIndex=mod(num_i2-1,nbslice)+1;
|
---|
1779 | end
|
---|
1780 | Field_b.CoordUnit='pixel';
|
---|
1781 |
|
---|
1782 | %% determine the input file type
|
---|
1783 | if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1}))
|
---|
1784 | FileType='movie';
|
---|
1785 | elseif isequal(lower(Ext),'.avi')
|
---|
1786 | FileType='avi';
|
---|
1787 | elseif isequal(lower(Ext),'.vol')
|
---|
1788 | FileType='vol';
|
---|
1789 | else
|
---|
1790 | form=imformats(Ext(2:end));
|
---|
1791 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
1792 | if isequal(NomType,'*');
|
---|
1793 | FileType='multimage';
|
---|
1794 | else
|
---|
1795 | FileType='image';
|
---|
1796 | end
|
---|
1797 | end
|
---|
1798 | end
|
---|
1799 | switch FileType
|
---|
1800 | case 'movie'
|
---|
1801 | if test_1
|
---|
1802 | Field_b.A=read(UvData.MovieObject{2},num_i2);
|
---|
1803 | else
|
---|
1804 | Field_b.A=read(UvData.MovieObject{1},num_i2);
|
---|
1805 | end
|
---|
1806 | case 'avi'
|
---|
1807 | mov=aviread(imaname_1,num_i2);
|
---|
1808 | Field_b.A=frame2im(mov(1));
|
---|
1809 | case 'vol'
|
---|
1810 | Field_b.A=imread(imaname_1);
|
---|
1811 | case 'multimage'
|
---|
1812 | Field_b.A=imread(imaname_1,num_i2);
|
---|
1813 | case 'image'
|
---|
1814 | Field_b.A=imread(imaname_1);
|
---|
1815 | end
|
---|
1816 | if get(handles.slices,'Value')
|
---|
1817 | Field.ZIndex=str2double(get(handles.z_index,'String'));
|
---|
1818 | end
|
---|
1819 |
|
---|
1820 | %px to phys or other transform on field
|
---|
1821 | menu_transform=get(handles.transform_fct,'String');
|
---|
1822 | choice_value=get(handles.transform_fct,'Value');
|
---|
1823 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
1824 | transform_list=get(handles.transform_fct,'UserData');
|
---|
1825 | transform=transform_list{choice_value};
|
---|
1826 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
1827 | if test_1 && isfield(UvData,'XmlData') && numel(UvData.XmlData)==2 && isfield(UvData.XmlData{2},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
1828 | Field_a=transform(Field_a,UvData.XmlData{2});%the first field has been stored without transform
|
---|
1829 | Field_b=transform(Field_b,UvData.XmlData{2});
|
---|
1830 | elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib
|
---|
1831 | Field_b=transform(Field_b,UvData.XmlData{1});
|
---|
1832 | end
|
---|
1833 | end
|
---|
1834 |
|
---|
1835 | % make movie until movie speed is set to 0 or STOP is activated
|
---|
1836 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
|
---|
1837 | set(handles.STOP,'Visible','on')
|
---|
1838 | set(handles.speed,'Visible','on')
|
---|
1839 | set(handles.speed_txt,'Visible','on')
|
---|
1840 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
|
---|
1841 | % read and plot the series of images in non erase mode
|
---|
1842 | set(hima,'CData',Field_b.A);
|
---|
1843 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
1844 | set(hima,'CData',Field_a.A);
|
---|
1845 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
1846 | end
|
---|
1847 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
1848 | set(handles.movie_pair,'Value',0)
|
---|
1849 |
|
---|
1850 | %------------------------------------------------------------------------
|
---|
1851 | % --- Executes on button press in run0.
|
---|
1852 | function run0_Callback(hObject, eventdata, handles)
|
---|
1853 | %------------------------------------------------------------------------
|
---|
1854 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
1855 | drawnow
|
---|
1856 | %filename=read_file_boxes(handles);
|
---|
1857 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
1858 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
|
---|
1859 | filename_1=[];%default
|
---|
1860 | if get(handles.SubField,'Value')
|
---|
1861 | [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
|
---|
1862 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
|
---|
1863 | % filename_1=read_file_boxes_1(handles);
|
---|
1864 | end
|
---|
1865 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
1866 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
1867 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
1868 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
1869 |
|
---|
1870 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
|
---|
1871 |
|
---|
1872 | if ~isempty(errormsg)
|
---|
1873 | msgbox_uvmat('ERROR',errormsg);
|
---|
1874 | else
|
---|
1875 | set(handles.i1,'BackgroundColor',[1 1 1])
|
---|
1876 | set(handles.i2,'BackgroundColor',[1 1 1])
|
---|
1877 | set(handles.j1,'BackgroundColor',[1 1 1])
|
---|
1878 | set(handles.j2,'BackgroundColor',[1 1 1])
|
---|
1879 | set(handles.FileIndex,'BackgroundColor',[1 1 1])
|
---|
1880 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
|
---|
1881 | end
|
---|
1882 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
1883 |
|
---|
1884 |
|
---|
1885 | %------------------------------------------------------------------------
|
---|
1886 | % --- read the input files and refresh all the plots, including projection.
|
---|
1887 | % OUTPUT:
|
---|
1888 | % errormsg: error message char string =[] by default
|
---|
1889 | % INPUT:
|
---|
1890 | % filename: first input file (=[] in the absence of input file)
|
---|
1891 | % filename_1: second input file (=[] in the asbsenc of secodn input file)
|
---|
1892 | % num_i1,num_i2,num_j1,num_j2; frame indices
|
---|
1893 | % Field: structure describing an optional input field (then replace the input file)
|
---|
1894 | function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
|
---|
1895 | %------------------------------------------------------------------------
|
---|
1896 |
|
---|
1897 | %% initialisation
|
---|
1898 | abstime=[];
|
---|
1899 | abstime_1=[];
|
---|
1900 | dt=[];
|
---|
1901 | if ~exist('Field','var')
|
---|
1902 | Field={};
|
---|
1903 | end
|
---|
1904 | UvData=get(handles.uvmat,'UserData');
|
---|
1905 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat
|
---|
1906 | delete(handles.UVMAT_title)
|
---|
1907 | end
|
---|
1908 |
|
---|
1909 | %% determine the main input file information for action
|
---|
1910 | FileType=[];%default
|
---|
1911 | if ~exist(filename,'file')
|
---|
1912 | errormsg=['input file ' filename ' does not exist'];
|
---|
1913 | return
|
---|
1914 | end
|
---|
1915 | NomType=get(handles.NomType,'String');
|
---|
1916 | % NomType=get(handles.FileIndex,'UserData');
|
---|
1917 | %update the z position index
|
---|
1918 | nbslice_str=get(handles.nb_slice,'String');
|
---|
1919 | if isequal(nbslice_str,'volume')%NOT USED
|
---|
1920 | z_index=num_j1;
|
---|
1921 | set(handles.z_index,'String',num2str(z_index))
|
---|
1922 | else
|
---|
1923 | nbslice=str2num(nbslice_str);
|
---|
1924 | z_index=mod(num_i1-1,nbslice)+1;
|
---|
1925 | set(handles.z_index,'String',num2str(z_index))
|
---|
1926 | end
|
---|
1927 | % refresh menu for save_mask if relevant
|
---|
1928 | masknumber=get(handles.masklevel,'String');
|
---|
1929 | if length(masknumber)>=z_index
|
---|
1930 | set(handles.masklevel,'Value',z_index)
|
---|
1931 | end
|
---|
1932 |
|
---|
1933 | %% read the first input field if a filename has been introduced
|
---|
1934 | if ~isempty(filename)
|
---|
1935 | ObjectName=filename;
|
---|
1936 | FieldName=[];%default
|
---|
1937 | VelType=[];%default
|
---|
1938 | FileExt=get(handles.FileExt,'String');
|
---|
1939 | FileType=UvData.FileType{1};
|
---|
1940 | switch FileType
|
---|
1941 | % if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf')
|
---|
1942 | case {'civx','civdata','netcdf'};
|
---|
1943 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
1944 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
1945 | FieldName= list_fields{index_fields}; % selected field
|
---|
1946 | if ~strcmp(FieldName,'get_field...')
|
---|
1947 | TestVelType=get(handles.FixVelType,'Value');
|
---|
1948 | if TestVelType
|
---|
1949 | VelType=setfield(handles);% read the velocity type.
|
---|
1950 | end
|
---|
1951 | end
|
---|
1952 | if strcmp(FieldName,'velocity')
|
---|
1953 | list_code=get(handles.ListColorCode,'String');% list menu fields
|
---|
1954 | index_code=get(handles.ListColorCode,'Value');% selected string index
|
---|
1955 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white')
|
---|
1956 | list_code=get(handles.ListColorScalar,'String');% list menu fields
|
---|
1957 | index_code=get(handles.ListColorScalar,'Value');% selected string index
|
---|
1958 | ParamIn.ColorVar= list_code{index_code}; % selected field
|
---|
1959 | end
|
---|
1960 | end
|
---|
1961 | case 'video'
|
---|
1962 | ObjectName=UvData.MovieObject{1};
|
---|
1963 | case 'vol' %TODO: update
|
---|
1964 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')
|
---|
1965 | ParamIn.Npy=UvData.XmlData.Npy;
|
---|
1966 | ParamIn.Npx=UvData.XmlData.Npx;
|
---|
1967 | else
|
---|
1968 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
|
---|
1969 | return
|
---|
1970 | end
|
---|
1971 | end
|
---|
1972 | ParamIn.FieldName=FieldName;
|
---|
1973 | ParamIn.VelType=VelType;
|
---|
1974 | ParamIn.GUIName='get_field';
|
---|
1975 | [Field{1},ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num_i1);
|
---|
1976 | if ~isempty(errormsg)
|
---|
1977 | errormsg=['error in reading ' filename ': ' errormsg];
|
---|
1978 | return
|
---|
1979 | end
|
---|
1980 | if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy')
|
---|
1981 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface
|
---|
1982 | set(handles.num_Npy,'String',num2str(ParamOut.Npy));
|
---|
1983 | end
|
---|
1984 | if isfield(ParamOut,'TimeIndex')
|
---|
1985 | set(handles.i1,'String',num2str(ParamOut.TimeIndex))
|
---|
1986 | end
|
---|
1987 | if isfield(ParamOut,'TimeValue')
|
---|
1988 | Field{1}.Time=ParamOut.TimeValue;
|
---|
1989 | end
|
---|
1990 | end
|
---|
1991 |
|
---|
1992 | %% choose a second field filename_1 if defined
|
---|
1993 | VelType_1=[];%default
|
---|
1994 | FieldName_1=[];
|
---|
1995 | ParamOut_1=[];
|
---|
1996 | if ~isempty(filename_1)
|
---|
1997 | if ~exist(filename_1,'file')
|
---|
1998 | errormsg=['second file ' filename_1 ' does not exist'];
|
---|
1999 | return
|
---|
2000 | end
|
---|
2001 | Name=filename_1;
|
---|
2002 | FileType_1=UvData.FileType{2};
|
---|
2003 | switch FileType_1
|
---|
2004 | % if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf')
|
---|
2005 | case {'civx','civdata','netcdf'};
|
---|
2006 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
2007 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
2008 | FieldName_1= list_fields{index_fields}; % selected field
|
---|
2009 | if ~strcmp(FieldName,'get_field...')
|
---|
2010 | TestVelType=get(handles.FixVelType,'Value');
|
---|
2011 | if TestVelType
|
---|
2012 | VelType_1=setfield(handles);% read the velocity type.
|
---|
2013 | end
|
---|
2014 | end
|
---|
2015 | if strcmp(FieldName_1,'velocity')
|
---|
2016 | list_code=get(handles.ListColorCode,'String');% list menu fields
|
---|
2017 | index_code=get(handles.ListColorCode,'Value');% selected string index
|
---|
2018 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white')
|
---|
2019 | list_code=get(handles.ListColorScalar,'String');% list menu fields
|
---|
2020 | index_code=get(handles.ListColorScalar,'Value');% selected string index
|
---|
2021 | ParamIn.ColorVar= list_code{index_code}; % selected field
|
---|
2022 | end
|
---|
2023 | end
|
---|
2024 | case 'video'
|
---|
2025 | Name=UvData.MovieObject{2};
|
---|
2026 | case 'vol' %TODO: update
|
---|
2027 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')
|
---|
2028 | ParamIn.Npy=UvData.XmlData.Npy;
|
---|
2029 | ParamIn.Npx=UvData.XmlData.Npx;
|
---|
2030 | else
|
---|
2031 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
|
---|
2032 | return
|
---|
2033 | end
|
---|
2034 | end
|
---|
2035 | NomType_1=get(handles.NomType_1,'String');
|
---|
2036 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
|
---|
2037 | if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
|
---|
2038 | if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
|
---|
2039 | test_keepdata_1= strcmp(filename_1,UvData.filename_1) && strcmp(VelType_1,UvData.VelType_1) && strcmp(FieldName_1,UvData.FieldName_1);
|
---|
2040 | end
|
---|
2041 | end
|
---|
2042 | if test_keepdata_1
|
---|
2043 | Field{2}=UvData.Field_1;
|
---|
2044 | else
|
---|
2045 | ParamIn.FieldName=FieldName_1;
|
---|
2046 | ParamIn.VelType=VelType_1;
|
---|
2047 | ParamIn.GUIName='get_field_1';
|
---|
2048 | [Field{2},ParamOut_1,errormsg] = read_field(Name,FileType_1,ParamIn,num_i1);
|
---|
2049 | if ~isempty(errormsg)
|
---|
2050 | errormsg=['error in reading ' FieldName_1 ' in ' filename_1 ': ' errormsg];
|
---|
2051 | return
|
---|
2052 | end
|
---|
2053 | UvData.Field_1=Field{2}; %store the second field for possible use at next RUN
|
---|
2054 | end
|
---|
2055 | % end
|
---|
2056 | end
|
---|
2057 |
|
---|
2058 | %% update uvmat interface
|
---|
2059 | if isfield(ParamOut,'Npx')
|
---|
2060 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface
|
---|
2061 | set(handles.num_Npy,'String',num2str(ParamOut.Npy));
|
---|
2062 | elseif isfield(ParamOut_1,'Npx')
|
---|
2063 | set(handles.num_Npx,'String',num2str(ParamOut_1.Npx));% display image size on the interface
|
---|
2064 | set(handles.num_Npy,'String',num2str(ParamOut_1.Npy));
|
---|
2065 | end
|
---|
2066 |
|
---|
2067 | %% update the display menu for the first velocity type (first menuline)
|
---|
2068 | test_veltype=0;
|
---|
2069 | % if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...')
|
---|
2070 | if (strcmp(FileType,'civx')||strcmp(FileType,'civdata'))&& ~strcmp(FieldName,'get_field...')
|
---|
2071 | test_veltype=1;
|
---|
2072 | set(handles.VelType,'Visible','on')
|
---|
2073 | set(handles.VelType_1,'Visible','on')
|
---|
2074 | set(handles.FixVelType,'Visible','on')
|
---|
2075 | menu=set_veltype_display(ParamOut.CivStage);
|
---|
2076 | index_menu=strcmp(ParamOut.VelType,menu);
|
---|
2077 | set(handles.VelType,'Value',find(index_menu,1))
|
---|
2078 | if ~get(handles.SubField,'value')
|
---|
2079 | set(handles.VelType,'String',menu)
|
---|
2080 | set(handles.VelType_1,'Value',1)
|
---|
2081 | set(handles.VelType_1,'String',[{''};menu])
|
---|
2082 | end
|
---|
2083 | else
|
---|
2084 | set(handles.VelType,'Visible','off')
|
---|
2085 | end
|
---|
2086 | field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList);
|
---|
2087 | set(handles.Fields,'String',ParamOut.FieldList); %update the field menu
|
---|
2088 | set(handles.Fields,'Value',find(field_index,1))
|
---|
2089 |
|
---|
2090 | %% update the display menu for the second velocity type (second menuline)
|
---|
2091 | test_veltype_1=0;
|
---|
2092 | if isempty(filename_1)
|
---|
2093 | set(handles.Fields_1,'Value',1); %update the field menu
|
---|
2094 | set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu
|
---|
2095 | else
|
---|
2096 | if ~isequal(FileType_1,'netcdf')|| isequal(FieldName_1,'get_field...')
|
---|
2097 | set(handles.VelType_1,'Visible','off')
|
---|
2098 | else
|
---|
2099 | test_veltype_1=1;
|
---|
2100 | set(handles.VelType_1,'Visible','on')
|
---|
2101 | if ~get(handles.FixVelType,'Value')
|
---|
2102 | menu=set_veltype_display(ParamOut_1.CivStage);
|
---|
2103 | index_menu=strcmp(ParamOut_1.VelType,menu);
|
---|
2104 | set(handles.VelType_1,'Value',1+find(index_menu,1))
|
---|
2105 | set(handles.VelType_1,'String',[{''};menu])
|
---|
2106 | end
|
---|
2107 | end
|
---|
2108 | end
|
---|
2109 | if test_veltype||test_veltype_1
|
---|
2110 | set(handles.FixVelType,'Visible','on')
|
---|
2111 | else
|
---|
2112 | set(handles.FixVelType,'Visible','off')
|
---|
2113 | end
|
---|
2114 |
|
---|
2115 | %% introduce w as background image by default for a new series (only for nbdim=2)
|
---|
2116 | if ~isfield(UvData,'NewSeries')
|
---|
2117 | UvData.NewSeries=1;
|
---|
2118 | end
|
---|
2119 | %put W as background image by default if NbDim=2:
|
---|
2120 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3);
|
---|
2121 | set(handles.SubField,'Value',1);
|
---|
2122 | %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
|
---|
2123 | set(handles.RootPath_1,'String','"')
|
---|
2124 | set(handles.RootFile_1,'String','"')
|
---|
2125 | set(handles.SubDir_1,'String','"');
|
---|
2126 | indices=fullfile_uvmat('','','','',NomType,num_i1,num_i2,num_j1,num_j2);
|
---|
2127 | %[indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
|
---|
2128 | set(handles.FileIndex_1,'String',indices)
|
---|
2129 | set(handles.FileExt_1,'String','"');
|
---|
2130 | set(handles.Fields_1,'Visible','on');
|
---|
2131 | set(handles.Fields_1,'Visible','on');
|
---|
2132 | set(handles.RootPath_1,'Visible','on')
|
---|
2133 | set(handles.RootFile_1,'Visible','on')
|
---|
2134 | set(handles.SubDir_1,'Visible','on');
|
---|
2135 | set(handles.FileIndex_1,'Visible','on');
|
---|
2136 | set(handles.FileExt_1,'Visible','on');
|
---|
2137 | set(handles.Fields_1,'Visible','on');
|
---|
2138 | Field{1}.AName='w';
|
---|
2139 | end
|
---|
2140 |
|
---|
2141 | %% store the current open names, fields and vel types in uvmat interface
|
---|
2142 | UvData.filename_1=filename_1;
|
---|
2143 | UvData.VelType_1=[];%default
|
---|
2144 | UvData.FieldName_1=[];
|
---|
2145 | if isfield(ParamOut_1,VelType)
|
---|
2146 | UvData.VelType_1=ParamOut_1.VelType;
|
---|
2147 | end
|
---|
2148 | if isfield(ParamOut_1,FieldName)
|
---|
2149 | UvData.FieldName_1=ParamOut_1.FieldName;
|
---|
2150 | end
|
---|
2151 |
|
---|
2152 | %% apply coordinate transform or other user fct
|
---|
2153 | XmlData=[];%default
|
---|
2154 | XmlData_1=[];%default
|
---|
2155 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
2156 | XmlData=UvData.XmlData{1};
|
---|
2157 | if numel(UvData.XmlData)==2
|
---|
2158 | XmlData_1=UvData.XmlData{2};
|
---|
2159 | end
|
---|
2160 | end
|
---|
2161 |
|
---|
2162 | % menu_transform=get(handles.transform_fct,'String');
|
---|
2163 | choice_value=get(handles.transform_fct,'Value');
|
---|
2164 | transform_list=get(handles.transform_fct,'UserData');
|
---|
2165 | transform=transform_list{choice_value};%selected function handles
|
---|
2166 | % z index
|
---|
2167 | if ~isempty(filename)
|
---|
2168 | Field{1}.ZIndex=z_index;
|
---|
2169 | end
|
---|
2170 | %px to phys or other transform on field
|
---|
2171 | if ~isempty(transform)
|
---|
2172 | if length(Field)>=2
|
---|
2173 | Field{2}.ZIndex=z_index;
|
---|
2174 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
|
---|
2175 | if isempty(Field{2})
|
---|
2176 | Field(2)=[];
|
---|
2177 | end
|
---|
2178 | else
|
---|
2179 | Field{1}=transform(Field{1},XmlData);
|
---|
2180 | end
|
---|
2181 | end
|
---|
2182 |
|
---|
2183 | %% calculate scalar
|
---|
2184 | if strcmp(FileType(1:3),'civ') && ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
|
---|
2185 | Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1});
|
---|
2186 | end
|
---|
2187 | if numel(Field)==2 && ~test_keepdata_1 && isequal(FileType_1(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)
|
---|
2188 | Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2});
|
---|
2189 | end
|
---|
2190 |
|
---|
2191 | %% combine the two input fields (e.g. substract velocity fields)
|
---|
2192 | if numel(Field)==2
|
---|
2193 | UvData.Field=sub_field(Field{1},Field{2});
|
---|
2194 | else
|
---|
2195 | UvData.Field=Field{1};
|
---|
2196 | end
|
---|
2197 |
|
---|
2198 | %% get bounds and mesh (needed for mouse action and to open set_object)
|
---|
2199 | test_x=0;
|
---|
2200 | test_z=0;% test for unstructured z coordinate
|
---|
2201 | [UvData.Field,errormsg]=check_field_structure(UvData.Field);
|
---|
2202 | if ~isempty(errormsg)
|
---|
2203 | errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];
|
---|
2204 | return
|
---|
2205 | end
|
---|
2206 | [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(UvData.Field);
|
---|
2207 | if ~isempty(errormsg)
|
---|
2208 | errormsg=['error in uvmat/refresh_field/find_field_indices: ' errormsg];
|
---|
2209 | return
|
---|
2210 | end
|
---|
2211 | [NbDim,imax]=max(NbDim);
|
---|
2212 | if isfield(UvData.Field,'NbDim')
|
---|
2213 | NbDim=UvData.Field.NbDim;% deal with plane fields containing z coordinates
|
---|
2214 | end
|
---|
2215 | if ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinates
|
---|
2216 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
|
---|
2217 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
|
---|
2218 | eval(['nbvec=length(UvData.Field.' XName ');'])%nbre of measurement points (e.g. vectors)
|
---|
2219 | test_x=1;%test for unstructured coordinates
|
---|
2220 | if ~isempty(VarType{imax}.coord_z)
|
---|
2221 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
|
---|
2222 | else
|
---|
2223 | NbDim=2;
|
---|
2224 | end
|
---|
2225 | elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 %structured coordinate
|
---|
2226 | XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
|
---|
2227 | if NbDim>1
|
---|
2228 | YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
|
---|
2229 | end
|
---|
2230 | end
|
---|
2231 | if NbDim==3
|
---|
2232 | if ~test_x
|
---|
2233 | ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D
|
---|
2234 | end
|
---|
2235 | eval(['ZMax=max(UvData.Field.' ZName ');'])
|
---|
2236 | eval(['ZMin=min(UvData.Field.' ZName ');'])
|
---|
2237 | UvData.Field.ZMax=ZMax;
|
---|
2238 | UvData.Field.ZMin=ZMin;
|
---|
2239 | test_z=1;
|
---|
2240 | if isequal(ZMin,ZMax)%no z dependency
|
---|
2241 | NbDim=2;
|
---|
2242 | test_z=0;
|
---|
2243 | end
|
---|
2244 | end
|
---|
2245 | if exist('XName','var')
|
---|
2246 | eval(['XMax=max(max(UvData.Field.' XName '));'])
|
---|
2247 | eval(['XMin=min(min(UvData.Field.' XName '));'])
|
---|
2248 | UvData.Field.NbDim=NbDim;
|
---|
2249 | UvData.Field.XMax=XMax;
|
---|
2250 | UvData.Field.XMin=XMin;
|
---|
2251 | if NbDim >1
|
---|
2252 | eval(['YMax=max(max(UvData.Field.' YName '));'])
|
---|
2253 | eval(['YMin=min(min(UvData.Field.' YName '));'])
|
---|
2254 | UvData.Field.YMax=YMax;
|
---|
2255 | UvData.Field.YMin=YMin;
|
---|
2256 | end
|
---|
2257 | eval(['nbvec=length(UvData.Field.' XName ');'])
|
---|
2258 | if test_x %unstructured coordinates
|
---|
2259 | if test_z
|
---|
2260 | UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector
|
---|
2261 | UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3);
|
---|
2262 | else
|
---|
2263 | UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D
|
---|
2264 | end
|
---|
2265 | else
|
---|
2266 | VarIndex=CellVarIndex{imax}; % list of variable indices
|
---|
2267 | DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
|
---|
2268 | nbpoints_x=UvData.Field.DimValue(DimIndex(NbDim));
|
---|
2269 | DX=(XMax-XMin)/(nbpoints_x-1);
|
---|
2270 | if NbDim >1
|
---|
2271 | nbpoints_y=UvData.Field.DimValue(DimIndex(NbDim-1));
|
---|
2272 | DY=(YMax-YMin)/(nbpoints_y-1);
|
---|
2273 | end
|
---|
2274 | if NbDim==3
|
---|
2275 | nbpoints_z=UvData.Field.DimValue(DimIndex(1));
|
---|
2276 | DZ=(ZMax-ZMin)/(nbpoints_z-1);
|
---|
2277 | UvData.Field.Mesh=(DX*DY*DZ)^(1/3);
|
---|
2278 | UvData.Field.ZMax=ZMax;
|
---|
2279 | UvData.Field.ZMin=ZMin;
|
---|
2280 | else
|
---|
2281 | UvData.Field.Mesh=DX;%sqrt(DX*DY);
|
---|
2282 | end
|
---|
2283 | end
|
---|
2284 | end
|
---|
2285 |
|
---|
2286 | %% 3D case (menuvolume)
|
---|
2287 | if NbDim==3% && UvData.NewSeries
|
---|
2288 | test_set_object=1;
|
---|
2289 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
|
---|
2290 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
|
---|
2291 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
|
---|
2292 | if ~isempty(hset_object) %if set_object is detected
|
---|
2293 | % hhset_object=guidata(hset_object);
|
---|
2294 | % % ZBounds_old(1)=get(hhset_object.z_slider,'Min');
|
---|
2295 | % % ZBounds_old(2)=get(hhset_object.z_slider,'Max');
|
---|
2296 | % % if isequal(ZBounds_old,ZBounds)
|
---|
2297 | % test_set_object=0;% do not refresh the GUI set_object
|
---|
2298 | % else
|
---|
2299 | delete(hset_object);% delete the GUI set_object if it does not fit
|
---|
2300 | % end
|
---|
2301 | end
|
---|
2302 | if test_set_object% reinitiate the GUI set_object
|
---|
2303 | 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
|
---|
2304 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
2305 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
2306 | UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
|
---|
2307 | UvData.Object{1}.NbDim=NbDim;%test for 3D objects
|
---|
2308 | UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
|
---|
2309 | UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
|
---|
2310 | UvData.Object{1}.Angle=[0 0 0];
|
---|
2311 | % UvData.Object{1}.Theta=0;
|
---|
2312 | % UvData.Object{1}.Psi=0;
|
---|
2313 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
|
---|
2314 | % PlotHandles=get_plot_handles(handles);
|
---|
2315 | UvData.Object{1}.Name='1-PLANE';
|
---|
2316 | UvData.Object{1}.enable_plot=1;
|
---|
2317 | set_object(UvData.Object{1},handles,ZBounds);
|
---|
2318 | set(handles.ListObject,'Value',1);
|
---|
2319 | set(handles.ListObject,'String',{'1-PLANE'});
|
---|
2320 | set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor
|
---|
2321 | edit_object_Callback([],[], handles)
|
---|
2322 | end
|
---|
2323 | %multilevel case (single menuplane in a 3D space)
|
---|
2324 | elseif isfield(UvData,'Z')
|
---|
2325 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
|
---|
2326 | XmlData=UvData.XmlData{1};
|
---|
2327 | if isfield(XmlData,'PlanePos')
|
---|
2328 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
|
---|
2329 | end
|
---|
2330 | if isfield(XmlData,'PlaneAngle')
|
---|
2331 | siz=size(XmlData.PlaneAngle);
|
---|
2332 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
|
---|
2333 | UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
|
---|
2334 | end
|
---|
2335 | elseif isfield(UvData,'ZIndex')
|
---|
2336 | UvData.Object{1}.ZObject=UvData.ZIndex;
|
---|
2337 | end
|
---|
2338 | else
|
---|
2339 | % create a default projection
|
---|
2340 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
2341 | UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
|
---|
2342 | set(handles.ListObject,'Value',1);
|
---|
2343 | list_object=get(handles.ListObject,'String');
|
---|
2344 | if isempty(list_object)
|
---|
2345 | list_object={''};
|
---|
2346 | elseif ~isempty(list_object{1})
|
---|
2347 | list_object=[{''};list_object];
|
---|
2348 | end
|
---|
2349 | set(handles.ListObject,'String',list_object);
|
---|
2350 | % set(handles.list_object_2,'String',list_object);
|
---|
2351 | end
|
---|
2352 | testnewseries=UvData.NewSeries;
|
---|
2353 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
|
---|
2354 | set(handles.uvmat,'UserData',UvData)
|
---|
2355 |
|
---|
2356 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need)
|
---|
2357 | if isfield(UvData,'Mask')&& ~isfield(UvData,'A')
|
---|
2358 | set(handles.num_MinA,'String','0')
|
---|
2359 | set(handles.num_MaxA,'String','255')
|
---|
2360 | end
|
---|
2361 |
|
---|
2362 | %% Plot the projections on the selected projection objects
|
---|
2363 | % main projection object (uvmat display)
|
---|
2364 | list_object=get(handles.ListObject,'String');
|
---|
2365 | if isequal(list_object,{''})%refresh list of objects if the menu is empty
|
---|
2366 | UvData.Object={[]};
|
---|
2367 | set(handles.ListObject,'Value',1)
|
---|
2368 | end
|
---|
2369 | IndexObj=get(handles.ListObject,'Value');%selected projection object for main view
|
---|
2370 | if IndexObj(1)> numel(UvData.Object)
|
---|
2371 | IndexObj(1)=1;%select the first object if the selected one does not exist
|
---|
2372 | set(handles.ListObject,'Value',1)
|
---|
2373 | end
|
---|
2374 | plot_handles{1}=handles;
|
---|
2375 | if isfield(UvData,'plotaxes')%case of movies
|
---|
2376 | haxes(1)=UvData.plotaxes;
|
---|
2377 | else
|
---|
2378 | haxes(1)=handles.axes3;
|
---|
2379 | end
|
---|
2380 | %PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
|
---|
2381 | PlotParam{1}=read_GUI(handles.uvmat);
|
---|
2382 | if ~isfield(PlotParam{1},'Vectors')
|
---|
2383 | PlotParam{1}.Vectors.MaxVec=1;
|
---|
2384 | PlotParam{1}.Vectors.MinVec=0;
|
---|
2385 | PlotParam{1}.Vectors.CheckFixVecColor=1;
|
---|
2386 | PlotParam{1}.Vectors.ColCode1=0.33;
|
---|
2387 | PlotParam{1}.Vectors.ColCode2=0.66;
|
---|
2388 | PlotParam{1}.Vectors.ListColorScalar={'ima_cor'};
|
---|
2389 | PlotParam{1}.Vectors.ListColorCode= {'rgb'};
|
---|
2390 | end
|
---|
2391 | keeplim(1)=get(handles.CheckFixLimits,'Value');% test for fixed graph limits
|
---|
2392 | PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface
|
---|
2393 |
|
---|
2394 | % second projection object (view_field display)
|
---|
2395 | if length( IndexObj)>=2
|
---|
2396 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI
|
---|
2397 | if ~isempty(view_field_handle)
|
---|
2398 | plot_handles{2}=guidata(view_field_handle);
|
---|
2399 | haxes(2)=plot_handles{2}.axes3;
|
---|
2400 | %PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the viewinterface
|
---|
2401 | PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface
|
---|
2402 | keeplim(2)=get(plot_handles{2}.CheckFixLimits,'Value');
|
---|
2403 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
|
---|
2404 | end
|
---|
2405 | end
|
---|
2406 |
|
---|
2407 | %loop on the projection objects: one or two
|
---|
2408 | for imap=1:numel(IndexObj)
|
---|
2409 | iobj=IndexObj(imap);
|
---|
2410 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
|
---|
2411 |
|
---|
2412 | if ~isempty(errormsg)
|
---|
2413 | return
|
---|
2414 | end
|
---|
2415 | % if testnewseries && isfield(ObjectData,'CoordUnit')&& isfield(PlotParam{imap},'Coordinates')
|
---|
2416 | % PlotParam{imap}.Coordinates=rmfield(PlotParam{imap}.Coordinates,'CheckFixEqual'); %set FixEqual to depend on the field (=1 if Data.CoordUnit=1 in plot_field)
|
---|
2417 | % end
|
---|
2418 | if testnewseries && isfield(ObjectData,'CoordUnit')
|
---|
2419 | PlotParam{imap}.Coordinates.CheckFixEqual=1;
|
---|
2420 | end
|
---|
2421 | %use of mask (TODO: check)
|
---|
2422 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A')
|
---|
2423 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
|
---|
2424 | AX=ObjectData.AX;%x coordiantes for the scalar field
|
---|
2425 | AY=ObjectData.AY;%y coordinates for the scalar field
|
---|
2426 | MaskX=ObjectData.MaskX;%x coordiantes for the mask
|
---|
2427 | MaskY=ObjectData.MaskY;%y coordiantes for the mask
|
---|
2428 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY)
|
---|
2429 | nxy=size(flag_mask);
|
---|
2430 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
|
---|
2431 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
|
---|
2432 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display
|
---|
2433 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display
|
---|
2434 | %project on the positions of the scalar
|
---|
2435 | npxy=size(ObjectData.A);
|
---|
2436 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
|
---|
2437 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
|
---|
2438 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end);
|
---|
2439 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end);
|
---|
2440 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
|
---|
2441 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
|
---|
2442 | end
|
---|
2443 | AClass=class(ObjectData.A);
|
---|
2444 | ObjectData.A=flag_mask.*double(ObjectData.A);
|
---|
2445 | ObjectData.A=feval(AClass,ObjectData.A);
|
---|
2446 | ind_off=[];
|
---|
2447 | if isfield(ObjectData,'ListVarName')
|
---|
2448 | for ilist=1:length(ObjectData.ListVarName)
|
---|
2449 | if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY')
|
---|
2450 | ind_off=[ind_off ilist];
|
---|
2451 | end
|
---|
2452 | end
|
---|
2453 | ObjectData.ListVarName(ind_off)=[];
|
---|
2454 | ObjectData.VarDimIndex(ind_off)=[];
|
---|
2455 | ind_off=[];
|
---|
2456 | for ilist=1:length(ObjectData.ListDimName)
|
---|
2457 | if isequal(ObjectData.ListDimName{ilist},'MaskX') || isequal(ObjectData.ListDimName{ilist},'MaskY')
|
---|
2458 | ind_off=[ind_off ilist];
|
---|
2459 | end
|
---|
2460 | end
|
---|
2461 | ObjectData.ListDimName(ind_off)=[];
|
---|
2462 | ObjectData.DimValue(ind_off)=[];
|
---|
2463 | end
|
---|
2464 | end
|
---|
2465 | if ~isempty(ObjectData)
|
---|
2466 | PlotType='none'; %default
|
---|
2467 | if imap==2 && isempty(view_field_handle)
|
---|
2468 | view_field(ObjectData)
|
---|
2469 | else
|
---|
2470 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap});
|
---|
2471 | write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters
|
---|
2472 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
|
---|
2473 | ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot)
|
---|
2474 | end
|
---|
2475 | end
|
---|
2476 | if isequal(PlotType,'none')
|
---|
2477 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
2478 | if isempty(hget_field)
|
---|
2479 | get_field(filename)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
|
---|
2480 | end
|
---|
2481 | errormsg='The field defined by get_field cannot be plotted';
|
---|
2482 | return
|
---|
2483 | end
|
---|
2484 | end
|
---|
2485 | end
|
---|
2486 |
|
---|
2487 | %% update the mask
|
---|
2488 | if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on
|
---|
2489 | update_mask(handles,num_i1,num_i2);
|
---|
2490 | end
|
---|
2491 |
|
---|
2492 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case)
|
---|
2493 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display
|
---|
2494 | ind_bad=[];
|
---|
2495 | nb_histo=1;
|
---|
2496 |
|
---|
2497 | % suppress coordinates from the histogram menu
|
---|
2498 | for ivar=1:numel(menu_histo)%l loop on field variables:
|
---|
2499 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
|
---|
2500 | Role=UvData.Field.VarAttribute{ivar}.Role;
|
---|
2501 | switch Role
|
---|
2502 | case {'coord_x','coord_y','coord_z','dimvar'}
|
---|
2503 | ind_bad=[ind_bad ivar];
|
---|
2504 | case {'vector_y'}
|
---|
2505 | nb_histo=nb_histo+1;
|
---|
2506 | end
|
---|
2507 | end
|
---|
2508 | DimCell=UvData.Field.VarDimName{ivar};
|
---|
2509 | DimName='';
|
---|
2510 | if ischar(DimCell)
|
---|
2511 | DimName=DimCell;
|
---|
2512 | elseif iscell(DimCell)&& numel(DimCell)==1
|
---|
2513 | DimName=DimCell{1};
|
---|
2514 | end
|
---|
2515 | if strcmp(DimName,menu_histo{ivar})
|
---|
2516 | ind_bad=[ind_bad ivar];
|
---|
2517 | end
|
---|
2518 | end
|
---|
2519 | menu_histo(ind_bad)=[];
|
---|
2520 |
|
---|
2521 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
2522 | % display menus and plot histograms
|
---|
2523 | test_v=0;
|
---|
2524 | if ~isempty(menu_histo)
|
---|
2525 | set(handles.histo1_menu,'Value',1)
|
---|
2526 | set(handles.histo1_menu,'String',menu_histo)
|
---|
2527 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram
|
---|
2528 | % case of more than one variables (eg vector components)
|
---|
2529 | if nb_histo > 1
|
---|
2530 | test_v=1;
|
---|
2531 | set(handles.histo2_menu,'Visible','on')
|
---|
2532 | set(handles.histo_v,'Visible','on')
|
---|
2533 | set(handles.histo2_menu,'String',menu_histo)
|
---|
2534 | set(handles.histo2_menu,'Value',2)
|
---|
2535 | histo2_menu_Callback(handles.histo2_menu,[], handles)% plot second histogram
|
---|
2536 | end
|
---|
2537 | end
|
---|
2538 | if ~test_v
|
---|
2539 | set(handles.histo2_menu,'Visible','off')
|
---|
2540 | set(handles.histo_v,'Visible','off')
|
---|
2541 | cla(handles.histo_v)
|
---|
2542 | set(handles.histo2_menu,'Value',1)
|
---|
2543 | end
|
---|
2544 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
2545 |
|
---|
2546 | %% display time
|
---|
2547 | testimedoc=0;
|
---|
2548 | TimeUnit='';
|
---|
2549 | if isfield(UvData.Field,'Time')
|
---|
2550 | abstime=UvData.Field.Time;%time read from the netcdf input file
|
---|
2551 | end
|
---|
2552 | if isfield(UvData,'Field_1') && isfield(UvData.Field_1,'Time')
|
---|
2553 | abstime_1=UvData.Field_1.Time;%time read from the netcdf input file
|
---|
2554 | end
|
---|
2555 | if isfield(UvData.Field,'dt')
|
---|
2556 | dt=UvData.Field.dt;%dt read from the netcdf input file
|
---|
2557 | if isfield(UvData.Field,'TimeUnit')
|
---|
2558 | TimeUnit=UvData.Field.TimeUnit;
|
---|
2559 | end
|
---|
2560 | elseif isfield(UvData,'Field_1') && isfield(UvData.Field_1,'dt')%dt obtained from the second field if not defined in the first
|
---|
2561 | dt=UvData.Field_1.dt;%dt read from the netcdf input file
|
---|
2562 | if isfield(UvData.Field_1,'TimeUnit')
|
---|
2563 | TimeUnit=UvData.Field_1.TimeUnit;
|
---|
2564 | end
|
---|
2565 | end
|
---|
2566 | % time from xml file overset previous result
|
---|
2567 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time')
|
---|
2568 | if isempty(num_i2)||isnan(num_i2)
|
---|
2569 | num_i2=num_i1;
|
---|
2570 | end
|
---|
2571 | if isempty(num_j1)||isnan(num_j1)
|
---|
2572 | num_j1=1;
|
---|
2573 | end
|
---|
2574 | if isempty(num_j2)||isnan(num_j2)
|
---|
2575 | num_j2=num_j1;
|
---|
2576 | end
|
---|
2577 | siz=size(UvData.XmlData{1}.Time);
|
---|
2578 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
2579 | abstime=(UvData.XmlData{1}.Time(num_i1,num_j1)+UvData.XmlData{1}.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
2580 | dt=(UvData.XmlData{1}.Time(num_i2,num_j2)-UvData.XmlData{1}.Time(num_i1,num_j1));
|
---|
2581 | testimedoc=1;
|
---|
2582 | if isfield(UvData.XmlData{1},'TimeUnit')
|
---|
2583 | TimeUnit=UvData.XmlData{1}.TimeUnit;
|
---|
2584 | end
|
---|
2585 | end
|
---|
2586 | if numel(UvData.XmlData)==2
|
---|
2587 | [tild,tild,tild,num_i1,num_i2,num_j1,num_j2]=fileparts_uvmat(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
2588 | % [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
2589 | if isempty(num_i2)
|
---|
2590 | num_i2=num_i1;
|
---|
2591 | end
|
---|
2592 | if isempty(num_j1)
|
---|
2593 | num_j1=1;
|
---|
2594 | end
|
---|
2595 | if isempty(num_j2)
|
---|
2596 | num_j2=num_j1;
|
---|
2597 | end
|
---|
2598 | siz=size(UvData.XmlData{2}.Time);
|
---|
2599 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
2600 | abstime_1=(UvData.XmlData{2}.Time(num_i1,num_j1)+UvData.XmlData{2}.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
2601 | end
|
---|
2602 | end
|
---|
2603 | end
|
---|
2604 |
|
---|
2605 | if ~isequal(numel(abstime),1)
|
---|
2606 | abstime=[];
|
---|
2607 | end
|
---|
2608 | if ~isequal(numel(abstime_1),1)
|
---|
2609 | abstime_1=[];
|
---|
2610 | end
|
---|
2611 | set(handles.abs_time,'String',num2str(abstime,4))
|
---|
2612 | set(handles.abs_time_1,'String',num2str(abstime_1,4))
|
---|
2613 | if testimedoc && isfield(UvData,'dt')
|
---|
2614 | dt=UvData.dt;
|
---|
2615 | end
|
---|
2616 | if isempty(dt)||isequal(dt,0)
|
---|
2617 | set(handles.Dt_txt,'String','')
|
---|
2618 | else
|
---|
2619 | if isempty(TimeUnit)
|
---|
2620 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] )
|
---|
2621 | else
|
---|
2622 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' TimeUnit] )
|
---|
2623 | end
|
---|
2624 | end
|
---|
2625 |
|
---|
2626 |
|
---|
2627 | %-------------------------------------------------------------------
|
---|
2628 | % --- translate coordinate to matrix index
|
---|
2629 | %-------------------------------------------------------------------
|
---|
2630 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
2631 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
2632 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
2633 |
|
---|
2634 | %-------------------------------------------------------------------
|
---|
2635 | % --- Executes on button press in 'CheckFixLimits'.
|
---|
2636 | %-------------------------------------------------------------------
|
---|
2637 | function CheckFixLimits_Callback(hObject, eventdata, handles)
|
---|
2638 | test=get(handles.CheckFixLimits,'Value');
|
---|
2639 | if test
|
---|
2640 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
2641 | else
|
---|
2642 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
2643 | update_plot(handles);
|
---|
2644 | end
|
---|
2645 |
|
---|
2646 | %-------------------------------------------------------------------
|
---|
2647 | % --- Executes on button press in CheckFixEqual.
|
---|
2648 | function CheckFixEqual_Callback(hObject, eventdata, handles)
|
---|
2649 | test=get(handles.CheckFixEqual,'Value');
|
---|
2650 | if test
|
---|
2651 | set(handles.CheckFixEqual,'BackgroundColor',[1 1 0])
|
---|
2652 | cla(handles.axes3)
|
---|
2653 | update_plot(handles);
|
---|
2654 | else
|
---|
2655 | set(handles.CheckFixEqual,'BackgroundColor',[0.7 0.7 0.7])
|
---|
2656 | update_plot(handles);
|
---|
2657 | % axis(handles.axes3,'image')
|
---|
2658 | end
|
---|
2659 |
|
---|
2660 | %-------------------------------------------------------------------
|
---|
2661 |
|
---|
2662 | %-------------------------------------------------------------------
|
---|
2663 | % --- Executes on button press in 'CheckZoom'.
|
---|
2664 | %-------------------------------------------------------------------
|
---|
2665 | function CheckZoom_Callback(hObject, eventdata, handles)
|
---|
2666 |
|
---|
2667 | if (get(handles.CheckZoom,'Value') == 1);
|
---|
2668 | set(handles.CheckZoom,'BackgroundColor',[1 1 0])
|
---|
2669 | set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
2670 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
2671 | else
|
---|
2672 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
2673 | end
|
---|
2674 |
|
---|
2675 | %-------------------------------------------------------------------
|
---|
2676 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
2677 | %-------------------------------------------------------------------
|
---|
2678 | function record_Callback(hObject, eventdata, handles)
|
---|
2679 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
2680 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
2681 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
|
---|
2682 | %filename=read_file_boxes(handles);
|
---|
2683 | [erread,message]=fileattrib(filename);
|
---|
2684 | if ~isempty(message) && ~isequal(message.UserWrite,1)
|
---|
2685 | msgbox_uvmat('ERROR',['no writting access to ' filename])
|
---|
2686 | return
|
---|
2687 | end
|
---|
2688 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
2689 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]);
|
---|
2690 | if ~test_civ2 && ~test_civ1
|
---|
2691 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
2692 | end
|
---|
2693 | if test_civ2
|
---|
2694 | nbname='nb_vectors2';
|
---|
2695 | flagname='vec2_FixFlag';
|
---|
2696 | attrname='fix2';
|
---|
2697 | end
|
---|
2698 | if test_civ1
|
---|
2699 | nbname='nb_vectors';
|
---|
2700 | flagname='vec_FixFlag';
|
---|
2701 | attrname='fix';
|
---|
2702 | end
|
---|
2703 | %write fix flags in the netcdf file
|
---|
2704 | UvData=get(handles.uvmat,'UserData');
|
---|
2705 | hhh=which('netcdf.open');% look for built-in matlab netcdf library
|
---|
2706 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
|
---|
2707 | nc=netcdf.open(filename,'NC_WRITE');
|
---|
2708 | netcdf.reDef(nc);
|
---|
2709 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1);
|
---|
2710 | dimid = netcdf.inqDimID(nc,nbname);
|
---|
2711 | try
|
---|
2712 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
|
---|
2713 | catch
|
---|
2714 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
|
---|
2715 | end
|
---|
2716 | netcdf.endDef(nc);
|
---|
2717 | netcdf.putVar(nc,varid,UvData.axes3.FF);
|
---|
2718 | netcdf.close(nc);
|
---|
2719 | else %old netcdf library
|
---|
2720 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
2721 | end
|
---|
2722 |
|
---|
2723 | %-------------------------------------------------------------------
|
---|
2724 | %----Correct the netcdf file, using toolbox (old versions of Matlab).
|
---|
2725 | %-------------------------------------------------------------------
|
---|
2726 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
2727 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
2728 | result=redef(nc);
|
---|
2729 | eval(['nc.' attrname '=1;']);
|
---|
2730 | theDim=nc(nbname) ;% get the number of velocity vectors
|
---|
2731 | nb_vectors=size(theDim);
|
---|
2732 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
2733 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
2734 | fin=close(nc);
|
---|
2735 |
|
---|
2736 | %-------------------------------------------------------------------
|
---|
2737 | %determines the fields to read from the interface
|
---|
2738 | %------------------------------------------------------------------
|
---|
2739 | function VelType=setfield(handles)
|
---|
2740 | VelTypeList=get(handles.VelType,'String');
|
---|
2741 | index=get(handles.VelType,'Value');
|
---|
2742 | VelType=VelTypeList{index};
|
---|
2743 |
|
---|
2744 | %-------------------------------------------------------------------
|
---|
2745 | %determines the veltype of the second field to read from the iinterface
|
---|
2746 | %------------------------------------------------------------------
|
---|
2747 | function VelType=setfield_1(handles)
|
---|
2748 | VelTypeList=get(handles.VelType_1,'String');
|
---|
2749 | index=get(handles.VelType_1,'Value');
|
---|
2750 | VelType=VelTypeList{index};
|
---|
2751 |
|
---|
2752 | %---------------------------------------------------
|
---|
2753 | % --- Executes on button press in SubField
|
---|
2754 | function SubField_Callback(hObject, eventdata, handles)
|
---|
2755 | % huvmat=get(handles.run0,'parent');
|
---|
2756 | UvData=get(handles.uvmat,'UserData');
|
---|
2757 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated
|
---|
2758 | set(handles.RootPath_1,'String','')
|
---|
2759 | set(handles.RootFile_1,'String','')
|
---|
2760 | set(handles.SubDir_1,'String','');
|
---|
2761 | set(handles.FileIndex_1,'String','');
|
---|
2762 | set(handles.FileExt_1,'String','');
|
---|
2763 | set(handles.RootPath_1,'Visible','off')
|
---|
2764 | set(handles.RootFile_1,'Visible','off')
|
---|
2765 | set(handles.SubDir_1,'Visible','off');
|
---|
2766 | set(handles.NomType_1,'Visible','off');
|
---|
2767 | set(handles.abs_time_1,'Visible','off')
|
---|
2768 | set(handles.FileIndex_1,'Visible','off');
|
---|
2769 | set(handles.FileExt_1,'Visible','off');
|
---|
2770 | set(handles.Fields_1,'Value',1);%set to blank state
|
---|
2771 | set(handles.VelType_1,'Value',1);%set to blank state
|
---|
2772 | if ~strcmp(get(handles.VelType,'Visible'),'on')
|
---|
2773 | set(handles.VelType_1,'Visible','off')
|
---|
2774 | end
|
---|
2775 | % set_veltype_display([handles.VelType_1 handles.interp1_1 handles.filter1_1 ...
|
---|
2776 | % handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
|
---|
2777 | if isfield(UvData,'XmlData_1')
|
---|
2778 | UvData=rmfield(UvData,'XmlData_1');
|
---|
2779 | end
|
---|
2780 | set(handles.uvmat,'UserData',UvData);
|
---|
2781 | run0_Callback(hObject, eventdata, handles); %run
|
---|
2782 | else
|
---|
2783 | MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
2784 | end
|
---|
2785 |
|
---|
2786 | %------------------------------------------------------------------------
|
---|
2787 | % --- read the data displayed for the input rootfile windows (new): TODO use read_GUI
|
---|
2788 |
|
---|
2789 | function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles)
|
---|
2790 | %------------------------------------------------------------------------
|
---|
2791 | InputFile=read_GUI(handles.InputFile);
|
---|
2792 | RootPath=InputFile.RootPath;
|
---|
2793 | SubDir=regexprep(InputFile.SubDir,'/|\','');
|
---|
2794 | RootFile=regexprep(InputFile.RootFile,'/|\','');
|
---|
2795 | FileIndices=InputFile.FileIndex;
|
---|
2796 | FileExt=InputFile.FileExt;
|
---|
2797 |
|
---|
2798 |
|
---|
2799 | %------------------------------------------------------------------------
|
---|
2800 | % ---- read the data displayed for the second input rootfile windows
|
---|
2801 | function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles)
|
---|
2802 | %------------------------------------------------------------------------
|
---|
2803 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
|
---|
2804 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"')
|
---|
2805 | RootPath_1=get(handles.RootPath,'String');
|
---|
2806 | end;
|
---|
2807 | SubDir_1=get(handles.SubDir_1,'String');
|
---|
2808 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"')
|
---|
2809 | SubDir_1=get(handles.SubDir,'String');
|
---|
2810 | end
|
---|
2811 | SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string
|
---|
2812 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
2813 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"')
|
---|
2814 | RootFile_1=get(handles.RootFile,'String');
|
---|
2815 | end
|
---|
2816 | RootFile_1=regexprep(RootFile_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string
|
---|
2817 | FileIndex_1=get(handles.FileIndex_1,'String');
|
---|
2818 | if isequal(get(handles.FileIndex_1,'Visible'),'off')|| isequal(FileIndex_1,'"')
|
---|
2819 | FileIndex_1=get(handles.FileIndex,'String');
|
---|
2820 | end
|
---|
2821 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
2822 | if isequal(get(handles.FileExt_1,'Visible'),'off') || isequal(FileExt_1,'"')
|
---|
2823 | FileExt_1=get(handles.FileExt,'String');%read FileExt by default
|
---|
2824 | end
|
---|
2825 | NomType_1=get(handles.NomType_1,'String');
|
---|
2826 | if isequal(get(handles.NomType_1,'Visible'),'off') || isequal(NomType_1,'"')
|
---|
2827 | NomType_1=get(handles.NomType,'String');%read FileExt by default
|
---|
2828 | end
|
---|
2829 | %------------------------------------------------------------------------
|
---|
2830 | % --- Executes on menu selection Fields
|
---|
2831 | function Fields_Callback(hObject, eventdata, handles)
|
---|
2832 | %------------------------------------------------------------------------
|
---|
2833 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
2834 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
2835 | field= list_fields{index_fields(1)}; % selected string
|
---|
2836 | if isequal(field,'get_field...')
|
---|
2837 | set(handles.FixVelType,'visible','off')
|
---|
2838 | set(handles.VelType,'visible','off')
|
---|
2839 | set(handles.VelType_1,'visible','off')
|
---|
2840 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
2841 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
|
---|
2842 | %filename=read_file_boxes(handles);
|
---|
2843 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
2844 | if ~isempty(hget_field)
|
---|
2845 | delete(hget_field)
|
---|
2846 | end
|
---|
2847 | hget_field=get_field(filename);
|
---|
2848 | set(hget_field,'Name','get_field')
|
---|
2849 | hhget_field=guidata(hget_field);
|
---|
2850 | set(hhget_field.list_fig,'Value',1)
|
---|
2851 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
2852 | set(handles.transform_fct,'Value',1)% no transform by default
|
---|
2853 | set(handles.path_transform,'String','')
|
---|
2854 | return %no action
|
---|
2855 | end
|
---|
2856 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
2857 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
2858 | field_1= list_fields{index_fields(1)}; % selected string
|
---|
2859 | UvData=get(handles.uvmat,'UserData');
|
---|
2860 |
|
---|
2861 | %read the rootfile input display
|
---|
2862 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
2863 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
|
---|
2864 | [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]);
|
---|
2865 | % NomTypeNew=NomType;%default
|
---|
2866 | if isequal(field,'image')
|
---|
2867 | % if isequal(NomType,'_1-2_1')||isequal(NomType,'_1_1-2')
|
---|
2868 | % NomTypeNew='_1_1';
|
---|
2869 | % elseif isequal(NomType,'#_ab')
|
---|
2870 | % NomTypeNew='#a';
|
---|
2871 | % elseif isequal(NomType,'_1-2')
|
---|
2872 | % NomTypeNew='_1';
|
---|
2873 | % end
|
---|
2874 | imagename=fullfile_uvmat(RootPath,SubDir,RootFile,'.png',NomType,i1,[],j1,[]);
|
---|
2875 | if ~exist(imagename,'file')
|
---|
2876 | [FileName,PathName] = uigetfile( ...
|
---|
2877 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
2878 | '*.jpg',' jpeg image files'; ...
|
---|
2879 | '*.png','.png image files'; ...
|
---|
2880 | '*.tif','.tif image files'; ...
|
---|
2881 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
2882 | '*.vol','.volume images (png)'; ...
|
---|
2883 | '*.*', 'All Files (*.*)'}, ...
|
---|
2884 | 'Pick an image',imagename);
|
---|
2885 | imagename=[PathName FileName];
|
---|
2886 | end
|
---|
2887 | % display the selected field and related information
|
---|
2888 | display_file_name(hObject, eventdata, handles,imagename)%display the image
|
---|
2889 | return
|
---|
2890 | else
|
---|
2891 | ext=get(handles.FileExt,'String');
|
---|
2892 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
2893 | [FileName,PathName] = uigetfile( ...
|
---|
2894 | {'*.nc', ' (*.nc)';
|
---|
2895 | '*.nc',' netcdf files'; ...
|
---|
2896 | '*.*', 'All Files (*.*)'}, ...
|
---|
2897 | 'Pick a netcdf file',FileBase);
|
---|
2898 | filename=[PathName FileName];
|
---|
2899 | % display the selected field and related information
|
---|
2900 | display_file_name(hObject, eventdata, handles,filename)
|
---|
2901 | return
|
---|
2902 | end
|
---|
2903 | end
|
---|
2904 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
|
---|
2905 | set(handles.FileIndex,'String',indices)
|
---|
2906 | % set(handles.NomType,'String',NomType)
|
---|
2907 |
|
---|
2908 | %common to Fields_1_Callback
|
---|
2909 | if isequal(field,'image')||isequal(field_1,'image')
|
---|
2910 | set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons
|
---|
2911 | set(handles.TitleNpy,'Visible','on')
|
---|
2912 | set(handles.num_Npx,'Visible','on')
|
---|
2913 | set(handles.num_Npy,'Visible','on')
|
---|
2914 | else
|
---|
2915 | set(handles.TitleNpx,'Visible','off')% visible npx,pxcm... buttons
|
---|
2916 | set(handles.TitleNpy,'Visible','off')
|
---|
2917 | set(handles.num_Npx,'Visible','off')
|
---|
2918 | set(handles.num_Npy,'Visible','off')
|
---|
2919 | end
|
---|
2920 | setfield(handles);% update the field structure ('civ1'....)
|
---|
2921 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
|
---|
2922 | run0_Callback(hObject, eventdata, handles)
|
---|
2923 | end
|
---|
2924 |
|
---|
2925 | %---------------------------------------------------
|
---|
2926 | % --- Executes on menu selection Fields
|
---|
2927 | function Fields_1_Callback(hObject, eventdata, handles)
|
---|
2928 | %-------------------------------------------------
|
---|
2929 | %% read input data
|
---|
2930 | check_new=~get(handles.SubField,'Value'); %check_new=1 if a second field was not previously entered
|
---|
2931 | UvData=get(handles.uvmat,'UserData');
|
---|
2932 | if check_new && isfield(UvData,'XmlData')
|
---|
2933 | UvData.XmlData{2}=UvData.XmlData{1};
|
---|
2934 | end
|
---|
2935 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
2936 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
2937 | field= list_fields{index_fields(1)}; % selected string
|
---|
2938 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
2939 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
2940 | field_1= list_fields{index_fields(1)}; % selected string for the second field
|
---|
2941 | if isequal(field_1,'')||(numel(UvData.FileType)>=2 && strcmp(UvData.FileType{2},'image'))
|
---|
2942 | set(handles.SubField,'Value',0)
|
---|
2943 | check_new=1;
|
---|
2944 | SubField_Callback(hObject, eventdata, handles)
|
---|
2945 | if isempty(field_1)%remove second field if 'blank' field is selected
|
---|
2946 | return
|
---|
2947 | end
|
---|
2948 | end
|
---|
2949 | set(handles.SubField,'Value',1)%state that a second field is now entered
|
---|
2950 |
|
---|
2951 | %% read the rootfile input display
|
---|
2952 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomTYpe_1]=read_file_boxes_1(handles);
|
---|
2953 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
|
---|
2954 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));
|
---|
2955 | set(handles.FileIndex_1,'Visible','on')
|
---|
2956 | set(handles.FileExt_1,'Visible','on')
|
---|
2957 | switch field_1
|
---|
2958 | case 'get_field...'
|
---|
2959 | set_veltype_display(0) % no veltype display
|
---|
2960 | hget_field=findobj(allchild(0),'name','get_field_1');
|
---|
2961 | if ~isempty(hget_field)
|
---|
2962 | delete(hget_field)
|
---|
2963 | end
|
---|
2964 | hget_field=get_field(filename_1);
|
---|
2965 | set(hget_field,'name','get_field_1')
|
---|
2966 | hhget_field=guidata(hget_field);
|
---|
2967 | set(hhget_field.list_fig,'Value',1)
|
---|
2968 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
2969 | set(handles.transform_fct,'Value',1)% no transform by default
|
---|
2970 | set(handles.path_transform,'String','')
|
---|
2971 | case 'image'
|
---|
2972 | % transform netc type to the corresponding image type
|
---|
2973 | NomType=get(handles.NomType,'string');
|
---|
2974 | check_letter=~isempty(regexp(NomType,'[ab|AB]$'));%detect pair label by letter
|
---|
2975 | % NomType_1=NomType;
|
---|
2976 | % if check_letter
|
---|
2977 | % NomType_1=NomType_1(1:end-1);
|
---|
2978 | % else
|
---|
2979 | % r=regexp(NomType_1,'.-(?<num2>\d+$','names');
|
---|
2980 | % if ~isempty(r)
|
---|
2981 | % NomType_1=regexprep(NomType_1,['-' r.num2],'');
|
---|
2982 | % end
|
---|
2983 | % end
|
---|
2984 | imagename=fullfile_uvmat(RootPath_1,'',RootFile_1,'.png',NomType,i1,[],j1);
|
---|
2985 | if ~exist(imagename,'file')
|
---|
2986 | [FileName,PathName] = uigetfile( ...
|
---|
2987 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
2988 | '*.jpg',' jpeg image files'; ...
|
---|
2989 | '*.png','.png image files'; ...
|
---|
2990 | '*.tif','.tif image files'; ...
|
---|
2991 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
2992 | '*.vol','.volume images (png)'; ...
|
---|
2993 | '*.*', 'All Files (*.*)'}, ...
|
---|
2994 | 'Pick an image',imagename);
|
---|
2995 | % display the selected field and related information
|
---|
2996 | imagename=[PathName FileName];
|
---|
2997 | end
|
---|
2998 | set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons
|
---|
2999 | set(handles.TitleNpy,'Visible','on')
|
---|
3000 | set(handles.num_Npx,'Visible','on')
|
---|
3001 | set(handles.num_Npy,'Visible','on')
|
---|
3002 | display_file_name(hObject, eventdata, handles,imagename,2)%display the imag
|
---|
3003 | otherwise
|
---|
3004 | if check_new
|
---|
3005 | UvData.FileType{2}=UvData.FileType{1};
|
---|
3006 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String'))
|
---|
3007 | set(handles.FileExt_1,'String',get(handles.FileExt,'String'))
|
---|
3008 | end
|
---|
3009 | if ~isequal(field,'image')
|
---|
3010 | set(handles.TitleNpx,'Visible','off')% visible npx,pxcm... buttons
|
---|
3011 | set(handles.TitleNpy,'Visible','off')
|
---|
3012 | set(handles.num_Npx,'Visible','off')
|
---|
3013 | set(handles.num_Npy,'Visible','off')
|
---|
3014 | end
|
---|
3015 | set(handles.uvmat,'UserData',UvData)
|
---|
3016 | setfield(handles);% update the field structure ('civ1'....)
|
---|
3017 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
|
---|
3018 | run0_Callback(hObject, eventdata, handles)
|
---|
3019 | end
|
---|
3020 | end
|
---|
3021 |
|
---|
3022 | %------------------------------------------------------------------------
|
---|
3023 | % --- set the visibility of relevant velocity type menus:
|
---|
3024 | function menu=set_veltype_display(Civ)
|
---|
3025 | %------------------------------------------------------------------------
|
---|
3026 | if isequal(Civ,0)
|
---|
3027 | imax=0;
|
---|
3028 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
3029 | imax=1;
|
---|
3030 | elseif isequal(Civ,3)
|
---|
3031 | imax=3;
|
---|
3032 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
3033 | imax=4;
|
---|
3034 | elseif isequal(Civ,6) %patch2
|
---|
3035 | imax=6;
|
---|
3036 | end
|
---|
3037 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'};
|
---|
3038 | menu=menu(1:imax);
|
---|
3039 |
|
---|
3040 | %------------------------------------------------------------------------
|
---|
3041 | % --- Executes on button press in VelType.
|
---|
3042 | function VelType_Callback(hObject, eventdata, handles)
|
---|
3043 | %------------------------------------------------------------------------
|
---|
3044 | set(handles.FixVelType,'Value',1)
|
---|
3045 | run0_Callback(hObject, eventdata, handles)
|
---|
3046 |
|
---|
3047 | %------------------------------------------------------------------------
|
---|
3048 | % --- Executes on button press in VelType.
|
---|
3049 | function VelType_1_Callback(hObject, eventdata, handles)
|
---|
3050 | %------------------------------------------------------------------------
|
---|
3051 |
|
---|
3052 | set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic)
|
---|
3053 | %refresh field with a second filename=first fiel name
|
---|
3054 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
3055 | drawnow
|
---|
3056 | InputFile=read_GUI(handles.InputFile);
|
---|
3057 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
3058 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
|
---|
3059 | %filename=read_file_boxes(handles);
|
---|
3060 |
|
---|
3061 | index=get(handles.VelType_1,'Value');
|
---|
3062 | if index==1
|
---|
3063 | filename_1='';% we plot the current field without the second field
|
---|
3064 | set(handles.SubField,'Value',0)
|
---|
3065 | SubField_Callback(hObject, eventdata, handles)
|
---|
3066 | elseif get(handles.SubField,'Value')% if subfield is already 'on'
|
---|
3067 | [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
|
---|
3068 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
|
---|
3069 | %filename_1=read_file_boxes_1(handles); %read the current second field
|
---|
3070 | else
|
---|
3071 | filename_1=filename;% we compare two fields in the same file
|
---|
3072 | set(handles.SubField,'Value',1)
|
---|
3073 | end
|
---|
3074 |
|
---|
3075 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
3076 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
3077 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
3078 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
3079 |
|
---|
3080 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
|
---|
3081 |
|
---|
3082 | if ~isempty(errormsg)
|
---|
3083 | msgbox_uvmat('ERROR',errormsg);
|
---|
3084 | else
|
---|
3085 | set(handles.i1,'BackgroundColor',[1 1 1])
|
---|
3086 | set(handles.i2,'BackgroundColor',[1 1 1])
|
---|
3087 | set(handles.j1,'BackgroundColor',[1 1 1])
|
---|
3088 | set(handles.j2,'BackgroundColor',[1 1 1])
|
---|
3089 | set(handles.FileIndex,'BackgroundColor',[1 1 1])
|
---|
3090 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
|
---|
3091 | end
|
---|
3092 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
3093 |
|
---|
3094 | %-----------------------------------------------
|
---|
3095 | % --- reset civ buttons
|
---|
3096 | function reset_vel_type(handles_civ0,handle1)
|
---|
3097 | for ibutton=1:length(handles_civ0)
|
---|
3098 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
|
---|
3099 | set(handles_civ0(ibutton),'Value',0)
|
---|
3100 | end
|
---|
3101 | if exist('handle1','var')%handles of selected button
|
---|
3102 | set(handle1,'BackgroundColor',[1 1 0])
|
---|
3103 | end
|
---|
3104 |
|
---|
3105 | %-------------------------------------------------------
|
---|
3106 | % --- Executes on button press in MENUVOLUME.
|
---|
3107 | %-------------------------------------------------------
|
---|
3108 | function VOLUME_Callback(hObject, eventdata, handles)
|
---|
3109 | %errordlg('command VOL not implemented yet')
|
---|
3110 | if ishandle(handles.UVMAT_title)
|
---|
3111 | delete(handles.UVMAT_title)
|
---|
3112 | end
|
---|
3113 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
3114 | if isequal(get(handles.VOLUME,'Value'),1)
|
---|
3115 | set(handles.CheckZoom,'Value',0)
|
---|
3116 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3117 | set(handles.edit_vect,'Value',0)
|
---|
3118 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
3119 | set(handles.edit_object,'Value',0)
|
---|
3120 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3121 | % set(handles.cal,'Value',0)
|
---|
3122 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
3123 | set(handles.edit_vect,'Value',0)
|
---|
3124 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
3125 | %initiate set_object GUI
|
---|
3126 | data.TITLE='VOLUME';
|
---|
3127 | if isfield(UvData,'CoordType')
|
---|
3128 | data.CoordType=UvData.CoordType;
|
---|
3129 | end
|
---|
3130 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
3131 | data.RangeY=UvData.Mesh;
|
---|
3132 | data.RangeX=UvData.Mesh;
|
---|
3133 | data.DX=UvData.Mesh;
|
---|
3134 | data.DY=UvData.Mesh;
|
---|
3135 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
3136 | np=size(UvData.Field.A);
|
---|
3137 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
3138 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
3139 | data.RangeY=max(meshx,meshy);
|
---|
3140 | data.RangeX=max(meshx,meshy);
|
---|
3141 | data.DX=max(meshx,meshy);
|
---|
3142 | end
|
---|
3143 | data.ParentButton=handles.VOLUME;
|
---|
3144 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
3145 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
|
---|
3146 | % associate the set_object interface handle to the plotting axes
|
---|
3147 | if isfield(UvData.OpenParam,'SetObjectOrigin')
|
---|
3148 | pos_uvmat=get(huvmat,'Position');
|
---|
3149 | pos_set_object(1:2)=UvData.OpenParam.SetObjectOrigin + pos_uvmat(1:2);
|
---|
3150 | pos_set_object(3:4)=UvData.OpenParam.SetObjectSize .* pos_uvmat(3:4);
|
---|
3151 | set(hset_object,'Position',pos_set_object)
|
---|
3152 | end
|
---|
3153 | UvData.MouseAction='create_object';
|
---|
3154 | else
|
---|
3155 | set(handles.VOLUME,'BackgroundColor',[0 1 0])
|
---|
3156 | UvData.MouseAction='none';
|
---|
3157 | end
|
---|
3158 | set(huvmat,'UserData',UvData)
|
---|
3159 |
|
---|
3160 | %-------------------------------------------------------
|
---|
3161 | function edit_vect_Callback(hObject, eventdata, handles)
|
---|
3162 | %-------------------------------------------------------
|
---|
3163 | %
|
---|
3164 | % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
3165 | if isequal(get(handles.edit_vect,'Value'),1)
|
---|
3166 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
3167 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]);
|
---|
3168 | if ~test_civ2 && ~test_civ1
|
---|
3169 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
3170 | end
|
---|
3171 | set(handles.record,'Visible','on')
|
---|
3172 | set(handles.edit_vect,'BackgroundColor',[1 1 0])
|
---|
3173 | set(handles.edit_object,'Value',0)
|
---|
3174 | set(handles.CheckZoom,'Value',0)
|
---|
3175 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3176 | % set(handles.create,'Value',0)
|
---|
3177 | % set(handles.create,'BackgroundColor',[0 1 0])
|
---|
3178 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3179 | set(gcf,'Pointer','arrow')
|
---|
3180 | % UvData.MouseAction='edit_vect';
|
---|
3181 | else
|
---|
3182 | set(handles.record,'Visible','off')
|
---|
3183 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3184 | % UvData.MouseAction='none';
|
---|
3185 | end
|
---|
3186 | % set(handles.uvmat,'UserData',UvData)
|
---|
3187 |
|
---|
3188 | %----------------------------------------------
|
---|
3189 | function save_mask_Callback(hObject, eventdata, handles)
|
---|
3190 | %-----------------------------------------------------------------------
|
---|
3191 | UvData=get(handles.uvmat,'UserData');
|
---|
3192 |
|
---|
3193 | flag=1;
|
---|
3194 | npx=size(UvData.Field.A,2);
|
---|
3195 | npy=size(UvData.Field.A,1);
|
---|
3196 | xi=0.5:npx-0.5;
|
---|
3197 | yi=0.5:npy-0.5;
|
---|
3198 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
3199 | if isfield(UvData,'Object')
|
---|
3200 | for iobj=1:length(UvData.Object)
|
---|
3201 | ObjectData=UvData.Object{iobj};
|
---|
3202 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
3203 | flagobj=1;
|
---|
3204 | testphys=0; %coordinates in pixels by default
|
---|
3205 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
3206 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib')
|
---|
3207 | Calib=UvData.XmlData{1}.GeometryCalib;
|
---|
3208 | testphys=1;
|
---|
3209 | end
|
---|
3210 | end
|
---|
3211 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
3212 | if isequal(ObjectData.Style,'polygon')
|
---|
3213 | X=ObjectData.Coord(:,1);
|
---|
3214 | Y=ObjectData.Coord(:,2);
|
---|
3215 | if testphys
|
---|
3216 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
3217 | end
|
---|
3218 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
3219 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
3220 | if testphys
|
---|
3221 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
3222 | end
|
---|
3223 | RangeX=max(ObjectData.RangeX);
|
---|
3224 | RangeY=max(ObjectData.RangeY);
|
---|
3225 | X2Max=RangeX*RangeX;
|
---|
3226 | Y2Max=RangeY*RangeY;
|
---|
3227 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
3228 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
3229 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
3230 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
3231 | if testphys
|
---|
3232 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
3233 | end
|
---|
3234 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
3235 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
3236 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
3237 | end
|
---|
3238 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
3239 | flagobj=~flagobj;
|
---|
3240 | end
|
---|
3241 | flag=flag & flagobj;
|
---|
3242 | end
|
---|
3243 | end
|
---|
3244 | end
|
---|
3245 | end
|
---|
3246 | % flag=~flag;
|
---|
3247 | %mask name
|
---|
3248 | RootPath=get(handles.RootPath,'String');
|
---|
3249 | RootFile=get(handles.RootFile,'String');
|
---|
3250 | RootFile=regexprep(RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string
|
---|
3251 | filebase=fullfile(RootPath,RootFile);
|
---|
3252 | list=get(handles.masklevel,'String');
|
---|
3253 | masknumber=num2str(length(list));
|
---|
3254 | maskindex=get(handles.masklevel,'Value');
|
---|
3255 | mask_name=fullfile_uvmat(RootPath,SubDir,[RootFile '_' masknumber 'mask'],'.png','_1',maskindex);
|
---|
3256 | %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
3257 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
3258 | imflag=flipdim(imflag,1);
|
---|
3259 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)
|
---|
3260 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved'])
|
---|
3261 | imwrite(imflag,mask_name,'BitDepth',8);
|
---|
3262 |
|
---|
3263 | %display the mask
|
---|
3264 | figure;
|
---|
3265 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
3266 | map=[vec' vec' vec'];
|
---|
3267 | colormap(map)
|
---|
3268 |
|
---|
3269 | image(imflag);
|
---|
3270 |
|
---|
3271 | %-------------------------------------------------------------------
|
---|
3272 | %-------------------------------------------------------------------
|
---|
3273 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
3274 |
|
---|
3275 | %------------------------------------------------------------------
|
---|
3276 |
|
---|
3277 | %------------------------------------------------------------------
|
---|
3278 | % --- Executes on selection change in ListColorScalar: choice of the color code.
|
---|
3279 | function ListColorScalar_Callback(hObject, eventdata, handles)
|
---|
3280 | %------------------------------------------------------------------
|
---|
3281 | % edit the choice for color code
|
---|
3282 | list_code=get(handles.ListColorScalar,'String');% list menu fields
|
---|
3283 | index_code=get(handles.ListColorScalar,'Value');% selected string index
|
---|
3284 | col_code= list_code{index_code(1)}; % selected field
|
---|
3285 | if isequal(col_code,'black') || isequal(col_code,'white')
|
---|
3286 | set(handles.Slider1,'Visible','off')
|
---|
3287 | set(handles.Slider2,'Visible','off')
|
---|
3288 | set(handles.num_ColCode1,'Visible','off')
|
---|
3289 | set(handles.num_ColCode2,'Visible','off')
|
---|
3290 | set(handles.CheckFixVecColor,'Visible','off')
|
---|
3291 | set_vec_col_bar(handles)
|
---|
3292 | else
|
---|
3293 | set(handles.Slider1,'Visible','on')
|
---|
3294 | set(handles.Slider2,'Visible','on')
|
---|
3295 | set(handles.num_ColCode1,'Visible','on')
|
---|
3296 | set(handles.num_ColCode2,'Visible','on')
|
---|
3297 | set(handles.CheckFixVecColor,'Visible','on')
|
---|
3298 | if isequal(col_code,'ima_cor')
|
---|
3299 | set(handles.CheckFixVecColor,'Value',0)%fixed scale by default
|
---|
3300 | set(handles.VecColBar,'Value',0)% 3 colors r,g,b by default
|
---|
3301 | set(handles.Slider1,'Min',0);
|
---|
3302 | set(handles.Slider1,'Max',1);
|
---|
3303 | set(handles.Slider2,'Min',0);
|
---|
3304 | set(handles.Slider2,'Max',1);
|
---|
3305 | % set(handles.min_title_vec,'String','0')
|
---|
3306 | set(handles.num_MaxVec,'String','1')
|
---|
3307 | set(handles.num_ColCode1,'String','0.333')
|
---|
3308 | num_ColCode1_Callback(hObject, eventdata, handles)
|
---|
3309 | set(handles.num_ColCode2,'String','0.666')
|
---|
3310 | num_ColCode2_Callback(hObject, eventdata, handles)
|
---|
3311 | else
|
---|
3312 | set(handles.CheckFixVecColor,'Value',1)%auto scale between min,max by default
|
---|
3313 | set(handles.VecColBar,'Value',1)% colormap 'jet' by default
|
---|
3314 | minval=get(handles.Slider1,'Min');
|
---|
3315 | maxval=get(handles.Slider1,'Max');
|
---|
3316 | set(handles.Slider1,'Value',minval)
|
---|
3317 | set(handles.Slider2,'Value',maxval)
|
---|
3318 | set_vec_col_bar(handles)
|
---|
3319 | end
|
---|
3320 | % slider_update(handles)
|
---|
3321 | end
|
---|
3322 | %replot the current graph
|
---|
3323 | run0_Callback(hObject, eventdata, handles)
|
---|
3324 |
|
---|
3325 |
|
---|
3326 | %----------------------------------------------------------------
|
---|
3327 | % -- Executes on slider movement to set the color code
|
---|
3328 | %
|
---|
3329 | function Slider1_Callback(hObject, eventdata, handles)
|
---|
3330 | %------------------------------------------------------------------
|
---|
3331 | slider1=get(handles.Slider1,'Value');
|
---|
3332 | min_val=str2num(get(handles.num_MinVec,'String'));
|
---|
3333 | max_val=str2num(get(handles.num_MaxVec,'String'));
|
---|
3334 | col=min_val+(max_val-min_val)*slider1;
|
---|
3335 | set(handles.num_ColCode1,'String',num2str(col))
|
---|
3336 | if(get(handles.Slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
3337 | set(handles.Slider2,'Value',col)
|
---|
3338 | set(handles.num_ColCode2,'String',num2str(col))
|
---|
3339 | end
|
---|
3340 | num_ColCode1_Callback(hObject, eventdata, handles)
|
---|
3341 |
|
---|
3342 | %----------------------------------------------------------------
|
---|
3343 | % Executes on slider movement to set the color code
|
---|
3344 | %----------------------------------------------------------------
|
---|
3345 | function Slider2_Callback(hObject, eventdata, handles)
|
---|
3346 | slider2=get(handles.Slider2,'Value');
|
---|
3347 | min_val=str2num(get(handles.num_MinVec,'String'));
|
---|
3348 | max_val=str2num(get(handles.num_MaxVec,'String'));
|
---|
3349 | col=min_val+(max_val-min_val)*slider2;
|
---|
3350 | set(handles.num_ColCode2,'String',num2str(col))
|
---|
3351 | if(get(handles.Slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
3352 | set(handles.Slider1,'Value',col)
|
---|
3353 | set(handles.num_ColCode1,'String',num2str(col))
|
---|
3354 | end
|
---|
3355 | num_ColCode2_Callback(hObject, eventdata, handles)
|
---|
3356 |
|
---|
3357 | %----------------------------------------------------------------
|
---|
3358 | % --- Execute on return carriage on the edit box corresponding to slider 1
|
---|
3359 | %----------------------------------------------------------------
|
---|
3360 | function num_ColCode1_Callback(hObject, eventdata, handles)
|
---|
3361 | set_vec_col_bar(handles)
|
---|
3362 | update_plot(handles);
|
---|
3363 |
|
---|
3364 | %----------------------------------------------------------------
|
---|
3365 | % --- Execute on return carriage on the edit box corresponding to slider 2
|
---|
3366 | %----------------------------------------------------------------
|
---|
3367 | function num_ColCode2_Callback(hObject, eventdata, handles)
|
---|
3368 | set_vec_col_bar(handles)
|
---|
3369 | update_plot(handles);
|
---|
3370 | %------------------------------------------------------------------------
|
---|
3371 | %-------------------------------------------------------
|
---|
3372 | % --- Executes on button press in CheckFixVecColor.
|
---|
3373 | %-------------------------------------------------------
|
---|
3374 | function VecColBar_Callback(hObject, eventdata, handles)
|
---|
3375 | set_vec_col_bar(handles)
|
---|
3376 |
|
---|
3377 | %-------------------------------------------------------------
|
---|
3378 | % --- Executes on selection change in transform_fct.
|
---|
3379 | function transform_fct_Callback(hObject, eventdata, handles)
|
---|
3380 | %-------------------------------------------------------------
|
---|
3381 | UvData=get(handles.uvmat,'UserData');
|
---|
3382 | menu=get(handles.transform_fct,'String');
|
---|
3383 | ind_coord=get(handles.transform_fct,'Value');
|
---|
3384 | coord_option=menu{ind_coord};
|
---|
3385 | list_transform=get(handles.transform_fct,'UserData');
|
---|
3386 | ff=functions(list_transform{end});
|
---|
3387 | if isequal(coord_option,'more...');
|
---|
3388 | coord_fct='';
|
---|
3389 | prompt = {'Enter the name of the transform function'};
|
---|
3390 | dlg_title = 'user defined transform';
|
---|
3391 | num_lines= 1;
|
---|
3392 | [FileName, PathName] = uigetfile( ...
|
---|
3393 | {'*.m', ' (*.m)';
|
---|
3394 | '*.m', '.m files '; ...
|
---|
3395 | '*.*', 'All Files (*.*)'}, ...
|
---|
3396 | 'Pick a file', ff.file);
|
---|
3397 | if isequal(PathName(end),'/')||isequal(PathName(end),'\')
|
---|
3398 | PathName(end)=[];
|
---|
3399 | end
|
---|
3400 | transform_selected =fullfile(PathName,FileName);
|
---|
3401 | if ~exist(transform_selected,'file')
|
---|
3402 | return
|
---|
3403 | end
|
---|
3404 | [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m
|
---|
3405 | if ~isequal(ext_fct,'.m')
|
---|
3406 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
3407 | return
|
---|
3408 | end
|
---|
3409 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
|
---|
3410 | ind_coord=get(handles.transform_fct,'Value');
|
---|
3411 | addpath(PathName)
|
---|
3412 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
|
---|
3413 | set(handles.transform_fct,'UserData',list_transform)
|
---|
3414 | rmpath(PathName)
|
---|
3415 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
3416 | dir_perso=prefdir;%personal Matalb directory
|
---|
3417 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
3418 | if exist(profil_perso,'file')
|
---|
3419 | nb_builtin=UvData.OpenParam.NbBuiltin;
|
---|
3420 | for ilist=nb_builtin+1:numel(list_transform)
|
---|
3421 | ff=functions(list_transform{ilist});
|
---|
3422 | transform_fct{ilist-nb_builtin}=ff.file;
|
---|
3423 | end
|
---|
3424 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
|
---|
3425 | end
|
---|
3426 | end
|
---|
3427 |
|
---|
3428 | %check the current path to the selected function
|
---|
3429 | if isa(list_transform{ind_coord},'function_handle')
|
---|
3430 | func=functions(list_transform{ind_coord});
|
---|
3431 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
|
---|
3432 | else
|
---|
3433 | set(handles.path_transform,'String','')
|
---|
3434 | end
|
---|
3435 |
|
---|
3436 | set(handles.CheckFixLimits,'Value',0)
|
---|
3437 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3438 |
|
---|
3439 | %delete drawn objects
|
---|
3440 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
3441 | for iobj=1:length(hother)
|
---|
3442 | delete_object(hother(iobj))
|
---|
3443 | end
|
---|
3444 | hother=findobj('Tag','DeformPoint');%find all the proj objects
|
---|
3445 | for iobj=1:length(hother)
|
---|
3446 | delete_object(hother(iobj))
|
---|
3447 | end
|
---|
3448 | hh=findobj('Tag','calib_points');
|
---|
3449 | if ~isempty(hh)
|
---|
3450 | delete(hh)
|
---|
3451 | end
|
---|
3452 | hhh=findobj('Tag','calib_marker');
|
---|
3453 | if ~isempty(hhh)
|
---|
3454 | delete(hhh)
|
---|
3455 | end
|
---|
3456 | if isfield(UvData,'Object')
|
---|
3457 | UvData.Object=UvData.Object(1);
|
---|
3458 | end
|
---|
3459 | set(handles.ListObject,'Value',1)
|
---|
3460 | set(handles.ListObject,'String',{''})
|
---|
3461 |
|
---|
3462 | %delete mask if it is displayed
|
---|
3463 | if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on
|
---|
3464 | UvData=rmfield(UvData,'MaskName'); %will impose mask refresh
|
---|
3465 | end
|
---|
3466 | set(handles.uvmat,'UserData',UvData)
|
---|
3467 | run0_Callback(hObject, eventdata, handles)
|
---|
3468 |
|
---|
3469 | %------------------------------------------------------------------------
|
---|
3470 | function histo1_menu_Callback(hObject, eventdata, handles)
|
---|
3471 | %--------------------------------------------
|
---|
3472 | %plot first histo
|
---|
3473 | huvmat=get(handles.histo1_menu,'parent');
|
---|
3474 | histo_menu=get(handles.histo1_menu,'String');
|
---|
3475 | histo_value=get(handles.histo1_menu,'Value');
|
---|
3476 | FieldName=histo_menu{histo_value};
|
---|
3477 | update_histo(handles.histo_u,huvmat,FieldName)
|
---|
3478 |
|
---|
3479 | %------------------------------------------------------------------------
|
---|
3480 | function histo2_menu_Callback(hObject, eventdata, handles)
|
---|
3481 | %------------------------------------------------------------------------
|
---|
3482 | %plot second histo
|
---|
3483 | huvmat=get(handles.histo2_menu,'parent');
|
---|
3484 | histo_menu=get(handles.histo2_menu,'String');
|
---|
3485 | histo_value=get(handles.histo2_menu,'Value');
|
---|
3486 | FieldName=histo_menu{histo_value};
|
---|
3487 | update_histo(handles.histo_v,huvmat,FieldName)
|
---|
3488 |
|
---|
3489 | %------------------------------------------------------------------------
|
---|
3490 | %read the field .Fieldname stored in UvData and plot its histogram
|
---|
3491 | function update_histo(haxes,huvmat,FieldName)
|
---|
3492 | %------------------------------------------------------------------------
|
---|
3493 | UvData=get(huvmat,'UserData');
|
---|
3494 | if ~isfield(UvData.Field,FieldName)
|
---|
3495 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram'])
|
---|
3496 | return
|
---|
3497 | end
|
---|
3498 | Field=UvData.Field;
|
---|
3499 | FieldHisto=eval(['Field.' FieldName]);
|
---|
3500 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto))
|
---|
3501 | indsel=find(Field.FF==0);%find values marked as false
|
---|
3502 | if ~isempty(indsel)
|
---|
3503 | FieldHisto=FieldHisto(indsel);
|
---|
3504 | end
|
---|
3505 | end
|
---|
3506 | if isempty(Field)
|
---|
3507 | msgbox_uvmat('ERROR',['empty field ' FieldName])
|
---|
3508 | else
|
---|
3509 | nxy=size(FieldHisto);
|
---|
3510 | Amin=double(min(min(min(FieldHisto))));%min of image
|
---|
3511 | Amax=double(max(max(max(FieldHisto))));%max of image
|
---|
3512 | if isequal(Amin,Amax)
|
---|
3513 | %msgbox_uvmat('WARNING',['uniform field =' num2str(Amin)]);
|
---|
3514 | cla(haxes)
|
---|
3515 | else
|
---|
3516 | Histo.ListVarName={FieldName,'histo'};
|
---|
3517 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3)
|
---|
3518 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
3519 | else
|
---|
3520 | if numel(nxy)==2
|
---|
3521 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
3522 | else
|
---|
3523 | Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
|
---|
3524 | end
|
---|
3525 | end
|
---|
3526 | %unit
|
---|
3527 | units=[]; %default
|
---|
3528 | for ivar=1:numel(Field.ListVarName)
|
---|
3529 | if strcmp(Field.ListVarName{ivar},FieldName)
|
---|
3530 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
|
---|
3531 | units=Field.VarAttribute{ivar}.units;
|
---|
3532 | break
|
---|
3533 | end
|
---|
3534 | end
|
---|
3535 | end
|
---|
3536 | if ~isempty(units)
|
---|
3537 | Histo.VarAttribute{1}.units=units;
|
---|
3538 | end
|
---|
3539 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
|
---|
3540 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3)
|
---|
3541 | C=reshape(double(FieldHisto),1,[]);% reshape in a vector
|
---|
3542 | eval(['Histo.histo(:,1)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
3543 | else
|
---|
3544 | for col=1:size(FieldHisto,3)
|
---|
3545 | B=FieldHisto(:,:,col);
|
---|
3546 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
|
---|
3547 | eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
3548 | end
|
---|
3549 | end
|
---|
3550 | plot_field(Histo,haxes);
|
---|
3551 | end
|
---|
3552 | end
|
---|
3553 |
|
---|
3554 | %------------------------------------------------
|
---|
3555 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
3556 | %-------------------------------------------------
|
---|
3557 |
|
---|
3558 | %------------------------------------------------------------------------
|
---|
3559 | function num_MinX_Callback(hObject, eventdata, handles)
|
---|
3560 | %------------------------------------------------------------------------
|
---|
3561 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
3562 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
3563 | update_plot(handles);
|
---|
3564 |
|
---|
3565 | %------------------------------------------------------------------------
|
---|
3566 | function num_MaxX_Callback(hObject, eventdata, handles)
|
---|
3567 | %------------------------------------------------------------------------
|
---|
3568 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
3569 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
3570 | update_plot(handles);
|
---|
3571 |
|
---|
3572 | %------------------------------------------------------------------------
|
---|
3573 | function num_MinY_Callback(hObject, eventdata, handles)
|
---|
3574 | %------------------------------------------
|
---|
3575 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
3576 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
3577 | update_plot(handles);
|
---|
3578 |
|
---|
3579 | %------------------------------------------------------------------------
|
---|
3580 | function num_MaxY_Callback(hObject, eventdata, handles)
|
---|
3581 | %------------------------------------------------------------------------
|
---|
3582 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
3583 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
3584 | update_plot(handles);
|
---|
3585 |
|
---|
3586 | %------------------------------------------------------------------------
|
---|
3587 | function num_MinA_Callback(hObject, eventdata, handles)
|
---|
3588 | %------------------------------------------
|
---|
3589 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode
|
---|
3590 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
|
---|
3591 | MinA=str2double(get(handles.num_MinA,'String'));
|
---|
3592 | MaxA=str2double(get(handles.num_MaxA,'String'));
|
---|
3593 | if MinA>MaxA% switch minA and maxA in case of error
|
---|
3594 | MinA_old=MinA;
|
---|
3595 | MinA=MaxA;
|
---|
3596 | MaxA=MinA_old;
|
---|
3597 | set(handles.num_MinA,'String',num2str(MinA,5));
|
---|
3598 | set(handles.num_MaxA,'String',num2str(MaxA,5));
|
---|
3599 | end
|
---|
3600 | update_plot(handles);
|
---|
3601 |
|
---|
3602 | %------------------------------------------------------------------------
|
---|
3603 | function num_MaxA_Callback(hObject, eventdata, handles)
|
---|
3604 | %------------------------------------------------------------------------
|
---|
3605 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode
|
---|
3606 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
|
---|
3607 | MinA=str2double(get(handles.num_MinA,'String'));
|
---|
3608 | MaxA=str2double(get(handles.num_MaxA,'String'));
|
---|
3609 | if MinA>MaxA% switch minA and maxA in case of error
|
---|
3610 | MinA_old=MinA;
|
---|
3611 | MinA=MaxA;
|
---|
3612 | MaxA=MinA_old;
|
---|
3613 | set(handles.num_MinA,'String',num2str(MinA,5));
|
---|
3614 | set(handles.num_MaxA,'String',num2str(MaxA,5));
|
---|
3615 | end
|
---|
3616 | update_plot(handles);
|
---|
3617 |
|
---|
3618 | %------------------------------------------------------------------------
|
---|
3619 | function CheckFixScalar_Callback(hObject, eventdata, handles)
|
---|
3620 | %------------------------------------------------------------------------
|
---|
3621 | test=get(handles.CheckFixScalar,'Value');
|
---|
3622 | if test
|
---|
3623 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
|
---|
3624 | else
|
---|
3625 | set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3626 | update_plot(handles);
|
---|
3627 | end
|
---|
3628 |
|
---|
3629 | %-------------------------------------------------------------------
|
---|
3630 | function CheckBW_Callback(hObject, eventdata, handles)
|
---|
3631 | %-------------------------------------------------------------------
|
---|
3632 | update_plot(handles);
|
---|
3633 |
|
---|
3634 | %-------------------------------------------------------------------
|
---|
3635 | function ListContour_Callback(hObject, eventdata, handles)
|
---|
3636 | %-------------------------------------------------------------------
|
---|
3637 | val=get(handles.ListContour,'Value');
|
---|
3638 | if val==2
|
---|
3639 | set(handles.interval_txt,'Visible','on')
|
---|
3640 | set(handles.num_IncrA,'Visible','on')
|
---|
3641 | else
|
---|
3642 | set(handles.interval_txt,'Visible','off')
|
---|
3643 | set(handles.num_IncrA,'Visible','off')
|
---|
3644 | end
|
---|
3645 | update_plot(handles);
|
---|
3646 |
|
---|
3647 | %-------------------------------------------------------------------
|
---|
3648 | function num_IncrA_Callback(hObject, eventdata, handles)
|
---|
3649 | %-------------------------------------------------------------------
|
---|
3650 | update_plot(handles);
|
---|
3651 |
|
---|
3652 | %-------------------------------------------------------------------
|
---|
3653 | function CheckHideWarning_Callback(hObject, eventdata, handles)
|
---|
3654 | %-------------------------------------------------------------------
|
---|
3655 | update_plot(handles);
|
---|
3656 |
|
---|
3657 | %-------------------------------------------------------------------
|
---|
3658 | function CheckHideFalse_Callback(hObject, eventdata, handles)
|
---|
3659 | %-------------------------------------------------------------------
|
---|
3660 | update_plot(handles);
|
---|
3661 |
|
---|
3662 | %-------------------------------------------------------------------
|
---|
3663 | function num_VecScale_Callback(hObject, eventdata, handles)
|
---|
3664 | %-------------------------------------------------------------------
|
---|
3665 | set(handles.CheckFixVectors,'Value',1);
|
---|
3666 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0])
|
---|
3667 | update_plot(handles);
|
---|
3668 |
|
---|
3669 | %-------------------------------------------------------------------
|
---|
3670 | function CheckFixVectors_Callback(hObject, eventdata, handles)
|
---|
3671 | %-------------------------------------------------------------------
|
---|
3672 | test=get(handles.CheckFixVectors,'Value');
|
---|
3673 | if test
|
---|
3674 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0])
|
---|
3675 | else
|
---|
3676 | update_plot(handles);
|
---|
3677 | %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3))
|
---|
3678 | set(handles.CheckFixVectors,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3679 | end
|
---|
3680 |
|
---|
3681 | %------------------------------------------------------------------------
|
---|
3682 | % --- Executes on selection change in CheckDecimate4 (nb_vec/4).
|
---|
3683 | function CheckDecimate4_Callback(hObject, eventdata, handles)
|
---|
3684 | %------------------------------------------------------------------------
|
---|
3685 | update_plot(handles);
|
---|
3686 |
|
---|
3687 | %------------------------------------------------------------------------
|
---|
3688 | % --- Executes on selection change in ListColorCode menu
|
---|
3689 | function ListColorCode_Callback(hObject, eventdata, handles)
|
---|
3690 | %------------------------------------------------------------------------
|
---|
3691 | set_vec_col_bar(handles)
|
---|
3692 | update_plot(handles);
|
---|
3693 |
|
---|
3694 | %------------------------------------------------------------------------
|
---|
3695 | % --- Executes on button press in CheckFixVecColor.
|
---|
3696 | function CheckFixVecColor_Callback(hObject, eventdata, handles)
|
---|
3697 | %------------------------------------------------------------------------
|
---|
3698 | test=get(handles.CheckFixVecColor,'Value');
|
---|
3699 | if test
|
---|
3700 | set(handles.CheckFixVecColor,'BackgroundColor',[1 1 0])
|
---|
3701 | else
|
---|
3702 | update_plot(handles);
|
---|
3703 | %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3))
|
---|
3704 | set(handles.CheckFixVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3705 | end
|
---|
3706 |
|
---|
3707 | %------------------------------------------------------------------------
|
---|
3708 | % --- Executes on selection change in num_MaxVec.
|
---|
3709 | function num_MinVec_Callback(hObject, eventdata, handles)
|
---|
3710 | %------------------------------------------------------------------------
|
---|
3711 | max_vec_Callback(hObject, eventdata, handles)
|
---|
3712 |
|
---|
3713 | %------------------------------------------------------------------------
|
---|
3714 | % --- Executes on selection change in num_MaxVec.
|
---|
3715 | function num_MaxVec_Callback(hObject, eventdata, handles)
|
---|
3716 | %------------------------------------------------------------------------
|
---|
3717 | set(handles.CheckFixVecColor,'Value',1)
|
---|
3718 | CheckFixVecColor_Callback(hObject, eventdata, handles)
|
---|
3719 | min_val=str2num(get(handles.num_MinVec,'String'));
|
---|
3720 | max_val=str2num(get(handles.num_MaxVec,'String'));
|
---|
3721 | slider1=get(handles.Slider1,'Value');
|
---|
3722 | slider2=get(handles.Slider2,'Value');
|
---|
3723 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
3724 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
3725 | set(handles.num_ColCode1,'String',num2str(colcode1))
|
---|
3726 | set(handles.num_ColCode2,'String',num2str(colcode2))
|
---|
3727 | update_plot(handles);
|
---|
3728 |
|
---|
3729 | %------------------------------------------------------------------------
|
---|
3730 | % --- update the display of color code for vectors
|
---|
3731 | function set_vec_col_bar(handles)
|
---|
3732 | %------------------------------------------------------------------------
|
---|
3733 | %get the image of the color display button 'VecColBar' in pixels
|
---|
3734 | set(handles.VecColBar,'Unit','pixel');
|
---|
3735 | pos_vert=get(handles.VecColBar,'Position');
|
---|
3736 | set(handles.VecColBar,'Unit','Normalized');
|
---|
3737 | width=ceil(pos_vert(3));
|
---|
3738 | height=ceil(pos_vert(4));
|
---|
3739 |
|
---|
3740 | %get slider indications
|
---|
3741 | list=get(handles.ListColorCode,'String');
|
---|
3742 | ichoice=get(handles.ListColorCode,'Value');
|
---|
3743 | colcode.ListColorCode=list{ichoice};
|
---|
3744 | colcode.MinVec=str2num(get(handles.num_MinVec,'String'));
|
---|
3745 | colcode.MaxVec=str2num(get(handles.num_MaxVec,'String'));
|
---|
3746 | test3color=strcmp(colcode.ListColorCode,'rgb') || strcmp(colcode.ListColorCode,'bgr');
|
---|
3747 | if test3color
|
---|
3748 | colcode.ColCode1=str2num(get(handles.num_ColCode1,'String'));
|
---|
3749 | colcode.ColCode2=str2num(get(handles.num_ColCode2,'String'));
|
---|
3750 | end
|
---|
3751 | % colcode.FixedCbounds=0;
|
---|
3752 | %colcode.CheckFixVecColor=1;
|
---|
3753 | vec_C=colcode.MinVec+(colcode.MaxVec-colcode.MinVec)*(0.5:width-0.5)/width;%sample of vec_C values from min to max
|
---|
3754 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
3755 | oneheight=ones(1,height);
|
---|
3756 | A1=colorlist(col_vec,1)*oneheight;
|
---|
3757 | A2=colorlist(col_vec,2)*oneheight;
|
---|
3758 | A3=colorlist(col_vec,3)*oneheight;
|
---|
3759 | A(:,:,1)=A1';
|
---|
3760 | A(:,:,2)=A2';
|
---|
3761 | A(:,:,3)=A3';
|
---|
3762 | set(handles.VecColBar,'Cdata',A)
|
---|
3763 |
|
---|
3764 | %-------------------------------------------------------------------
|
---|
3765 | function update_plot(handles)
|
---|
3766 | %-------------------------------------------------------------------
|
---|
3767 | UvData=get(handles.uvmat,'UserData');
|
---|
3768 | AxeData=UvData.axes3;% retrieve the current plotted data
|
---|
3769 | PlotParam=read_GUI(handles.uvmat);
|
---|
3770 | [PP,PlotParamOut]= plot_field(AxeData,handles.axes3,PlotParam);
|
---|
3771 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
3772 |
|
---|
3773 | %-------------------------------------------------------------------
|
---|
3774 | % --- Executes on selection change in edit_object.
|
---|
3775 | function edit_object_Callback(hObject, eventdata, handles)
|
---|
3776 | %-------------------------------------------------------------------
|
---|
3777 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
3778 | test=get(handles.edit_object,'Value');
|
---|
3779 | if test
|
---|
3780 | set(handles.edit_object,'BackgroundColor',[1,1,0])
|
---|
3781 | %suppress the other options
|
---|
3782 | set(handles.CheckZoom,'Value',0)
|
---|
3783 | CheckZoom_Callback(hObject, eventdata, handles)
|
---|
3784 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
|
---|
3785 | if ishandle(hgeometry_calib)
|
---|
3786 | hhgeometry_calib=guidata(hgeometry_calib);
|
---|
3787 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
|
---|
3788 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3789 | end
|
---|
3790 | else
|
---|
3791 | UvData.MouseAction='none';
|
---|
3792 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
3793 | end
|
---|
3794 | set(handles.uvmat,'UserData',UvData);
|
---|
3795 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
3796 | if ~isempty(hset_object)
|
---|
3797 | hhset_object=guidata(hset_object);
|
---|
3798 | if test
|
---|
3799 | set(hhset_object.PLOT,'enable','on');
|
---|
3800 | else
|
---|
3801 | set(hhset_object.PLOT,'enable','off');
|
---|
3802 | end
|
---|
3803 | end
|
---|
3804 |
|
---|
3805 | %------------------------------------------------------------------------
|
---|
3806 | % --- Executes on selection change in ListObject.
|
---|
3807 | function ListObject_Callback(hObject, eventdata, handles)
|
---|
3808 | %------------------------------------------------------------------------
|
---|
3809 |
|
---|
3810 | list_str=get(handles.ListObject,'String');
|
---|
3811 | IndexObj_old=get(handles.ListObject,'UserData');%retrieve previous selection
|
---|
3812 | IndexObj=get(handles.ListObject,'Value');%present object selection
|
---|
3813 |
|
---|
3814 | %% we select two objects or more at once (using the Ctrl key), keep only the last two items: the first is projected on uvmat, the second on view_field
|
---|
3815 | if length(IndexObj)>2
|
---|
3816 | IndexObj=[IndexObj(end-1) IndexObj(end)];%keeps only the last two selected items at most
|
---|
3817 | end
|
---|
3818 |
|
---|
3819 | %% we select one object
|
---|
3820 | if length(IndexObj)==1%
|
---|
3821 | if length(IndexObj_old)>=2 && isequal(IndexObj_old(1),IndexObj) % we select the first previously selected object->
|
---|
3822 | IndexObj=[1 IndexObj_old(2)];% it desactivates this object and selects the first object for uvmat
|
---|
3823 | elseif length(IndexObj_old)>=2 && isequal(IndexObj_old(2),IndexObj) % we select the second previously selected object->
|
---|
3824 | IndexObj=IndexObj_old(1);% it desactivates this object and keeps only the first previously selected object (uvmat)
|
---|
3825 | else %
|
---|
3826 | IndexObj=[IndexObj_old(1) IndexObj];% activates a second object while keeping the first previously selected one
|
---|
3827 | end
|
---|
3828 | end
|
---|
3829 | set(handles.ListObject,'Value',IndexObj); % marks the selected objects in the list
|
---|
3830 | set(handles.ListObject,'UserData',IndexObj)% keep the current object selection in memory for next time
|
---|
3831 |
|
---|
3832 | %% update the object representation
|
---|
3833 | set(handles.edit_object,'Value',0) % desactivate the edit object mode
|
---|
3834 | edit_object_Callback(hObject, eventdata, handles)
|
---|
3835 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
3836 | if numel(UvData.Object)<max(IndexObj);
|
---|
3837 | msgbox_uvmat('ERROR','invalid object list')
|
---|
3838 | return
|
---|
3839 | end
|
---|
3840 | if numel(IndexObj)>=2
|
---|
3841 | UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));%update the current object graphic representation
|
---|
3842 | set(handles.uvmat,'UserData',UvData)
|
---|
3843 | end
|
---|
3844 |
|
---|
3845 | %% project on the selected object and update the corresponding plot
|
---|
3846 | % hview_field=findobj(allchild(0),'tag','view_field');
|
---|
3847 | % ViewObjectAxes=[];%default
|
---|
3848 | if ~isequal(IndexObj(1),IndexObj_old(1))
|
---|
3849 | update_object(handles,IndexObj(1),handles.axes3,list_str{IndexObj(1)})%plot the projection in uvmat
|
---|
3850 | end
|
---|
3851 | hview_field=findobj(allchild(0),'tag','view_field');
|
---|
3852 | if length(IndexObj)==2 && (length(IndexObj_old)==1 || ~isequal(IndexObj(2),IndexObj_old(2)))
|
---|
3853 | if isempty(hview_field)
|
---|
3854 | hview_field=view_field;
|
---|
3855 | end
|
---|
3856 | PlotHandles=guidata(hview_field);
|
---|
3857 | update_object(handles,IndexObj(2),PlotHandles.axes3,list_str{IndexObj(2)})%plot the projection in view_field
|
---|
3858 | update_object_color(handles.axes3,PlotHandles.axes3,UvData.Object{IndexObj(2)}.DisplayHandle_uvmat)
|
---|
3859 | else
|
---|
3860 | if ~isempty(hview_field)
|
---|
3861 | delete(hview_field)
|
---|
3862 | end
|
---|
3863 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
3864 | if ~isempty(hset_object)
|
---|
3865 | delete(hset_object)
|
---|
3866 | end
|
---|
3867 | update_object_color(handles.axes3,handles.axes3,[])
|
---|
3868 | end
|
---|
3869 |
|
---|
3870 | %% update the color of the gfraphic object representation: the selected object in magenta, others in blue
|
---|
3871 | % update_object_color(handles.axes3,PlotHandles.axes3,UvData.Object{IndexObj(2)}.DisplayHandle_uvmat)
|
---|
3872 |
|
---|
3873 | %------------------------------------------------------------------------
|
---|
3874 | function update_object(handles,IndexObj,ViewObjectAxes,ObjectName)
|
---|
3875 | %------------------------------------------------------------------------
|
---|
3876 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
3877 | ObjectData=UvData.Object{IndexObj};
|
---|
3878 | ObjectData.Name=ObjectName;
|
---|
3879 | if isequal(get(handles.edit_object,'Value'),1)
|
---|
3880 | ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode
|
---|
3881 | end
|
---|
3882 | ZBounds=0; % default
|
---|
3883 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
|
---|
3884 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
|
---|
3885 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
|
---|
3886 | end
|
---|
3887 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
3888 | if ~isempty(hset_object)
|
---|
3889 | delete(hset_object)% delete existing version of set_object
|
---|
3890 | end
|
---|
3891 | hset_object=set_object(ObjectData,[],ZBounds);
|
---|
3892 | % end
|
---|
3893 | edit_test=get(handles.edit_object,'Value');
|
---|
3894 | if edit_test
|
---|
3895 | ObjectData.enable_plot=1;
|
---|
3896 | else
|
---|
3897 | if isfield(ObjectData,'enable_plot')
|
---|
3898 | ObjectData=rmfield(ObjectData,'enable_plot');
|
---|
3899 | end
|
---|
3900 | end
|
---|
3901 |
|
---|
3902 | uistack(ViewObjectAxes,'top')% display the plotting axes at the top
|
---|
3903 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
|
---|
3904 | plot_field(ProjData,ViewObjectAxes,read_GUI(get(ViewObjectAxes,'Parent')));%read plotting parameters on the uvmat interfacPlotHandles);
|
---|
3905 |
|
---|
3906 | %------------------------------------------------------------------------
|
---|
3907 | %--- update the representation of objects
|
---|
3908 | function update_object_color(axes_uvmat,axes_view_field,DisplayHandle)
|
---|
3909 | %------------------------------------------------------------------------
|
---|
3910 | hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object')] ;%find all the proj objects
|
---|
3911 | hother=[hother ;findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];
|
---|
3912 | for iobj=1:length(hother)
|
---|
3913 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch')
|
---|
3914 | set(hother(iobj),'EdgeColor','b')
|
---|
3915 | if isequal(get(hother(iobj),'FaceColor'),'m')
|
---|
3916 | set(hother(iobj),'FaceColor','b')
|
---|
3917 | end
|
---|
3918 | elseif isequal(get(hother(iobj),'Type'),'image')
|
---|
3919 | Acolor=get(hother(iobj),'CData');
|
---|
3920 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
|
---|
3921 | set(hother(iobj),'CData',Acolor);
|
---|
3922 | else
|
---|
3923 | set(hother(iobj),'Color','b')
|
---|
3924 | end
|
---|
3925 | set(hother(iobj),'Selected','off')
|
---|
3926 | end
|
---|
3927 | if ~isempty(DisplayHandle)
|
---|
3928 | linetype=get(DisplayHandle,'Type');
|
---|
3929 | if isequal(linetype,'line')
|
---|
3930 | set(DisplayHandle,'Color','m'); %set the selected object to magenta color
|
---|
3931 | elseif isequal(linetype,'rectangle')
|
---|
3932 | set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color
|
---|
3933 | elseif isequal(linetype,'patch')
|
---|
3934 | set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color
|
---|
3935 | end
|
---|
3936 | SubObjectData=get(DisplayHandle,'UserData');
|
---|
3937 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject)
|
---|
3938 | for iobj=1:length(SubObjectData.SubObject)
|
---|
3939 | hsub=SubObjectData.SubObject(iobj);
|
---|
3940 | if isequal(get(hsub,'Type'),'rectangle')
|
---|
3941 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color
|
---|
3942 | elseif isequal(get(hsub,'Type'),'image')
|
---|
3943 | Acolor=get(hsub,'CData');
|
---|
3944 | Acolor(:,:,1)=Acolor(:,:,3);
|
---|
3945 | set(hsub,'CData',Acolor);
|
---|
3946 | else
|
---|
3947 | set(hsub,'Color','m')
|
---|
3948 | end
|
---|
3949 | end
|
---|
3950 | end
|
---|
3951 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint)
|
---|
3952 | set(SubObjectData.DeformPoint,'Color','m')
|
---|
3953 | end
|
---|
3954 | end
|
---|
3955 |
|
---|
3956 | %------------------------------------------------------
|
---|
3957 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
3958 | %------------------------------------------------------
|
---|
3959 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
3960 | global Data_uvmat
|
---|
3961 | Data_uvmat=get(handles.uvmat,'UserData');
|
---|
3962 | evalin('base','global Data_uvmat')%make CurData global in the workspace
|
---|
3963 | display('current field :')
|
---|
3964 | evalin('base','Data_uvmat') %display CurData in the workspace
|
---|
3965 | commandwindow; %brings the Matlab command window to the front
|
---|
3966 |
|
---|
3967 | %------------------------------------------------------
|
---|
3968 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
3969 | %------------------------------------------------------
|
---|
3970 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
3971 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
3972 | UvData=get(huvmat,'UserData');
|
---|
3973 | hfig=figure;
|
---|
3974 | newaxes=copyobj(handles.axes3,hfig);
|
---|
3975 | map=colormap(handles.axes3);
|
---|
3976 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
3977 | colorbar
|
---|
3978 |
|
---|
3979 |
|
---|
3980 | % --------------------------------------------------------------------
|
---|
3981 | function Insert_Callback(hObject, eventdata, handles)
|
---|
3982 |
|
---|
3983 |
|
---|
3984 | % --------------------------------------------------------------------
|
---|
3985 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
3986 | % --------------------------------------------------------------------
|
---|
3987 | path_to_uvmat=which ('uvmat');% check the path of uvmat
|
---|
3988 | pathelp=fileparts(path_to_uvmat);
|
---|
3989 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
3990 | 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')
|
---|
3991 | else
|
---|
3992 | addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
3993 | web(helpfile);
|
---|
3994 | end
|
---|
3995 |
|
---|
3996 | %------------------------------------------------------------------------
|
---|
3997 | % --------------------------------------------------------------------
|
---|
3998 | function MenuExportMovie_Callback(hObject, eventdata, handles)
|
---|
3999 | % --------------------------------------------------------------------
|
---|
4000 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button
|
---|
4001 | huvmat=get(handles.run0,'parent');
|
---|
4002 | UvData=get(huvmat,'UserData');
|
---|
4003 | %[xx,xx,FileBase]=read_file_boxes(handles);
|
---|
4004 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
4005 | FileBase=fullfile(RootPath,RootFile);
|
---|
4006 | %read the current input file name
|
---|
4007 | 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)'};
|
---|
4008 | dlg_title = 'select properties of the output avi movie';
|
---|
4009 | num_lines= 1;
|
---|
4010 | % nbfield_cell=get(handles.last_i,'String');
|
---|
4011 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
|
---|
4012 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
|
---|
4013 | aviname=answer{1};
|
---|
4014 | fps=str2double(answer{2});
|
---|
4015 | % check for existing file with output name aviname
|
---|
4016 | if exist(aviname,'file')
|
---|
4017 | backup=aviname;
|
---|
4018 | testexist=2;
|
---|
4019 | while testexist==2
|
---|
4020 | backup=[backup '~'];
|
---|
4021 | testexist=exist(backup,'file');
|
---|
4022 | end
|
---|
4023 | [success,message]=copyfile(aviname,backup);%make backup of the existing file
|
---|
4024 | if isequal(success,1)
|
---|
4025 | delete(aviname)%delete existing file
|
---|
4026 | else
|
---|
4027 | msgbox_uvmat('ERROR',message)
|
---|
4028 | return
|
---|
4029 | end
|
---|
4030 | end
|
---|
4031 | %create avi open
|
---|
4032 | aviobj=avifile(aviname,'Compression','None','fps',fps);
|
---|
4033 |
|
---|
4034 | %display first view for tests
|
---|
4035 | newfig=figure;
|
---|
4036 | newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure
|
---|
4037 | set(newaxes,'Tag','movieaxes')
|
---|
4038 | nbpix=[512 384]*str2double(answer{3});
|
---|
4039 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA
|
---|
4040 | set(newaxes,'Position',eval(answer{4}));
|
---|
4041 | map=colormap(handles.axes3);
|
---|
4042 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
4043 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;...
|
---|
4044 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']});
|
---|
4045 | UvData.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
|
---|
4046 | set(huvmat,'UserData',UvData);
|
---|
4047 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
4048 | set(handles.STOP,'Visible','on')
|
---|
4049 | set(handles.speed,'Visible','on')
|
---|
4050 | set(handles.speed_txt,'Visible','on')
|
---|
4051 | set(handles.Movie,'BusyAction','queue')
|
---|
4052 |
|
---|
4053 | %imin=str2double(get(handles.i1,'String'));
|
---|
4054 | imax=str2double(answer{5});
|
---|
4055 | % if isfield(UvData,'Time')
|
---|
4056 | htitle=get(newaxes,'Title');
|
---|
4057 | xlim=get(newaxes,'XLim');
|
---|
4058 | ylim=get(newaxes,'YLim');
|
---|
4059 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0])
|
---|
4060 | time_str=get(handles.abs_time,'String');
|
---|
4061 | set(htitle,'String',['t=' time_str])
|
---|
4062 | set(handles.speed,'Value',1)
|
---|
4063 | for i=1:imax
|
---|
4064 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
|
---|
4065 | runpm(hObject,eventdata,handles,increment)% run plus
|
---|
4066 | drawnow
|
---|
4067 | time_str=get(handles.abs_time,'String');
|
---|
4068 | if ishandle(htitle)
|
---|
4069 | set(htitle,'String',['t=' time_str])
|
---|
4070 | end
|
---|
4071 | mov=getframe(newfig);
|
---|
4072 | aviobj=addframe(aviobj,mov);
|
---|
4073 | end
|
---|
4074 | end
|
---|
4075 | aviobj=close(aviobj);
|
---|
4076 | UvData=rmfield(UvData,'plotaxes');
|
---|
4077 | %UvData.Object{1}.plotaxes=handles.axes3;
|
---|
4078 | set(huvmat,'UserData',UvData);
|
---|
4079 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
|
---|
4080 |
|
---|
4081 | %------------------------------------------------------------------------
|
---|
4082 | function MenuCalib_Callback(hObject, eventdata, handles)
|
---|
4083 | %------------------------------------------------------------------------
|
---|
4084 |
|
---|
4085 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
4086 |
|
---|
4087 | %suppress competing options
|
---|
4088 | set(handles.CheckZoom,'Value',0)
|
---|
4089 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
4090 | set(handles.ListObject,'Value',1)
|
---|
4091 | % initiate display of GUI geometry_calib
|
---|
4092 | data=[]; %default
|
---|
4093 | if isfield(UvData,'CoordType')
|
---|
4094 | data.CoordType=UvData.CoordType;
|
---|
4095 | end
|
---|
4096 | pos=get(handles.uvmat,'Position');
|
---|
4097 | pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
|
---|
4098 | pos(2)=pos(2)-0.02;
|
---|
4099 | %[FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
4100 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
4101 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
|
---|
4102 | set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib
|
---|
4103 | if isfield(UvData.OpenParam,'CalOrigin')
|
---|
4104 | pos_uvmat=get(handles.uvmat,'Position');
|
---|
4105 | pos_cal(1)=pos_uvmat(1)+UvData.OpenParam.CalOrigin(1)*pos_uvmat(3);
|
---|
4106 | pos_cal(2)=pos_uvmat(2)+UvData.OpenParam.CalOrigin(2)*pos_uvmat(4);
|
---|
4107 | pos_cal(3:4)=UvData.OpenParam.CalSize .* pos_uvmat(3:4);
|
---|
4108 | end
|
---|
4109 | geometry_calib(FileName,pos_cal);% call the geometry_calib interface
|
---|
4110 | set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib
|
---|
4111 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action
|
---|
4112 |
|
---|
4113 | %------------------------------------------------------------------------
|
---|
4114 | function MenuMask_Callback(hObject, eventdata, handles)
|
---|
4115 | %------------------------------------------------------------------------
|
---|
4116 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
4117 | ListObj=UvData.Object;
|
---|
4118 | select=zeros(1,numel(ListObj));
|
---|
4119 | for iobj=1:numel(ListObj);
|
---|
4120 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside')
|
---|
4121 | select(iobj)=1;
|
---|
4122 | end
|
---|
4123 | end
|
---|
4124 | val=find(select);
|
---|
4125 | if isempty(val)
|
---|
4126 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar');
|
---|
4127 | return
|
---|
4128 | else
|
---|
4129 | set(handles.ListObject,'Max',2);%allow multiple selection
|
---|
4130 | set(handles.ListObject,'Value',val);
|
---|
4131 | flag=1;
|
---|
4132 | npx=size(UvData.Field.A,2);
|
---|
4133 | npy=size(UvData.Field.A,1);
|
---|
4134 | xi=0.5:npx-0.5;
|
---|
4135 | yi=0.5:npy-0.5;
|
---|
4136 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
4137 | if isfield(UvData,'Object')
|
---|
4138 | for iobj=1:length(UvData.Object)
|
---|
4139 | ObjectData=UvData.Object{iobj};
|
---|
4140 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
4141 | flagobj=1;
|
---|
4142 | testphys=0; %coordinates in pixels by default
|
---|
4143 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel')
|
---|
4144 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib')
|
---|
4145 | Calib=UvData.XmlData{1}.GeometryCalib;
|
---|
4146 | testphys=1;
|
---|
4147 | end
|
---|
4148 | end
|
---|
4149 | if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Style')
|
---|
4150 | if isequal(ObjectData.Style,'polygon')
|
---|
4151 | X=ObjectData.Coord(:,1);
|
---|
4152 | Y=ObjectData.Coord(:,2);
|
---|
4153 | if testphys
|
---|
4154 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
4155 | end
|
---|
4156 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
4157 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
4158 | if testphys
|
---|
4159 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
4160 | end
|
---|
4161 | RangeX=max(ObjectData.RangeX);
|
---|
4162 | RangeY=max(ObjectData.RangeY);
|
---|
4163 | X2Max=RangeX*RangeX;
|
---|
4164 | Y2Max=RangeY*RangeY;
|
---|
4165 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
4166 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
4167 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
4168 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
4169 | if testphys
|
---|
4170 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
4171 | end
|
---|
4172 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
4173 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
4174 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
4175 | end
|
---|
4176 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
4177 | flagobj=~flagobj;
|
---|
4178 | end
|
---|
4179 | flag=flag & flagobj;
|
---|
4180 | end
|
---|
4181 | end
|
---|
4182 | end
|
---|
4183 | end
|
---|
4184 | %mask name
|
---|
4185 | RootPath=get(handles.RootPath,'String');
|
---|
4186 | RootFile=get(handles.RootFile,'String');
|
---|
4187 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
4188 | RootFile(1)=[];
|
---|
4189 | end
|
---|
4190 | filebase=fullfile(RootPath,RootFile);
|
---|
4191 | list=get(handles.masklevel,'String');
|
---|
4192 | masknumber=num2str(length(list));
|
---|
4193 | maskindex=get(handles.masklevel,'Value');
|
---|
4194 | mask_name=fullfile_uvmat(RootPath,SubDir,[RootFile '_' masknumber 'mask'],'.png','_1',maskindex);
|
---|
4195 | %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
4196 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
4197 | imflag=flipdim(imflag,1);
|
---|
4198 |
|
---|
4199 | %display the mask
|
---|
4200 | hfigmask=figure;
|
---|
4201 | set(hfigmask,'Name','mask image')
|
---|
4202 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
4203 | map=[vec' vec' vec'];
|
---|
4204 | colormap(map)
|
---|
4205 | image(imflag);
|
---|
4206 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name);
|
---|
4207 | if ~strcmp(answer,'Cancel')
|
---|
4208 | mask_dir=fileparts(answer);
|
---|
4209 | if ~exist(mask_dir,'dir')
|
---|
4210 | msgbox_uvmat('ERROR',['directory ' mask_dir ' does not exist'])
|
---|
4211 | return
|
---|
4212 | end
|
---|
4213 | imwrite(imflag,answer,'BitDepth',8);
|
---|
4214 | end
|
---|
4215 | set(handles.ListObject,'Value',1)
|
---|
4216 | set(handles.ListObject,'Max',1)
|
---|
4217 | end
|
---|
4218 |
|
---|
4219 | %------------------------------------------------------------------------
|
---|
4220 | %-- open the GUI set_grid.fig to create grid
|
---|
4221 | function MenuGrid_Callback(hObject, eventdata, handles)
|
---|
4222 | %------------------------------------------------------------------------
|
---|
4223 | %suppress the other options if grid is chosen
|
---|
4224 | set(handles.edit_vect,'Value',0)
|
---|
4225 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
4226 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
4227 | set(handles.ListObject,'Value',1)
|
---|
4228 |
|
---|
4229 | %prepare display of the set_grid GUI
|
---|
4230 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
4231 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
|
---|
4232 | CoordList=get(handles.transform_fct,'String');
|
---|
4233 | val=get(handles.transform_fct,'Value');
|
---|
4234 | set_grid(FileName,CoordList{val});% call the set_object interface
|
---|
4235 |
|
---|
4236 | %------------------------------------------------------------------------
|
---|
4237 | % open the GUI 'series'
|
---|
4238 | function MenuSeries_Callback(hObject, eventdata, handles)
|
---|
4239 | %------------------------------------------------------------------------
|
---|
4240 | series; %first display of the GUI to fill waiting time
|
---|
4241 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
4242 | param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
|
---|
4243 | if isequal(get(handles.SubField,'Value'),1)
|
---|
4244 | [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
|
---|
4245 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
|
---|
4246 | %FileName_1=read_file_boxes_1(handles);%
|
---|
4247 | if ~isequal(FileName_1,param.FileName)
|
---|
4248 | param.FileName_1=FileName_1;
|
---|
4249 | end
|
---|
4250 | end
|
---|
4251 | param.NomType=get(handles.NomType,'String');
|
---|
4252 | % param.NomType=get(handles.FileIndex,'UserData');
|
---|
4253 | param.NomType_1=get(handles.NomType_1,'String');
|
---|
4254 | % param.NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
4255 | param.CheckFixPair=get(handles.CheckFixPair,'Value');
|
---|
4256 | huvmat=get(handles.MenuSeries,'parent');
|
---|
4257 | UvData=get(huvmat,'UserData');
|
---|
4258 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'Time')
|
---|
4259 | param.Time=UvData.XmlData{1}.Time;
|
---|
4260 | end
|
---|
4261 | if isequal(get(handles.scan_i,'Value'),1)
|
---|
4262 | param.incr_i=str2num(get(handles.increment_scan,'String'));
|
---|
4263 | elseif isequal(get(handles.scan_j,'Value'),1)
|
---|
4264 | param.incr_j=str2num(get(handles.increment_scan,'String'));
|
---|
4265 | end
|
---|
4266 | param.list_fields=get(handles.Fields,'String');% list menu fields
|
---|
4267 | param.list_fields(1)=[]; %suppress 'image' option
|
---|
4268 | param.index_fields=get(handles.Fields,'Value');% selected string index
|
---|
4269 | if param.index_fields>1
|
---|
4270 | param.index_fields=param.index_fields-1;
|
---|
4271 | end
|
---|
4272 | param.list_fields_1=get(handles.Fields_1,'String');% list menu fields
|
---|
4273 | param.list_fields_1(1)=[]; %suppress 'image' option
|
---|
4274 | param.index_fields_1=get(handles.Fields_1,'Value')-1;% selected string index
|
---|
4275 | if param.index_fields_1>1
|
---|
4276 | param.index_fields_1=param.index_fields_1-1;
|
---|
4277 | end
|
---|
4278 | param.menu_coord_str=get(handles.transform_fct,'String');
|
---|
4279 | param.menu_coord_val=get(handles.transform_fct,'Value');
|
---|
4280 | series(param); %run the series interface
|
---|
4281 |
|
---|
4282 | %------------------------------------------------------------------------
|
---|
4283 | % -- open the GUI civ.fig for civx (PIV)
|
---|
4284 | function MenuPIV_Callback(hObject, eventdata, handles)
|
---|
4285 | %------------------------------------------------------------------------
|
---|
4286 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
4287 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
|
---|
4288 | civ(FileName);% interface de civ(not in the uvmat file)
|
---|
4289 |
|
---|
4290 | %------------------------------------------------------------------------
|
---|
4291 | function MenuTools_Callback(hObject, eventdata, handles)
|
---|
4292 | %------------------------------------------------------------------------
|
---|
4293 |
|
---|
4294 | %------------------------------------------------------------------------
|
---|
4295 | function MenuEditObject_Callback(hObject, eventdata, handles)
|
---|
4296 | %------------------------------------------------------------------------
|
---|
4297 | set(handles.edit_object,'Value',1)
|
---|
4298 | edit_Callback(hObject, eventdata, handles)
|
---|
4299 |
|
---|
4300 | %------------------------------------------------------------------------
|
---|
4301 | function enable_transform(handles,state)
|
---|
4302 | %------------------------------------------------------------------------
|
---|
4303 | set(handles.transform_fct,'Visible',state)
|
---|
4304 | set(handles.TRANSFORM_txt,'Visible',state)
|
---|
4305 | set(handles.transform_fct,'Visible',state)
|
---|
4306 | set(handles.path_transform,'Visible',state)
|
---|
4307 | set(handles.pxcmx_txt,'Visible',state)
|
---|
4308 | set(handles.pxcmy_txt,'Visible',state)
|
---|
4309 | set(handles.pxcm,'Visible',state)
|
---|
4310 | set(handles.pycm,'Visible',state)
|
---|
4311 |
|
---|
4312 | %------------------------------------------------------------------------
|
---|
4313 | function MenuEditVectors_Callback(hObject, eventdata, handles)
|
---|
4314 | %------------------------------------------------------------------------
|
---|
4315 | set(handles.edit_vect,'Visible','on')
|
---|
4316 | set(handles.edit_vect,'Value',1)
|
---|
4317 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
4318 |
|
---|
4319 | % -----------------------------------------------------------------------
|
---|
4320 | function Menupoints_Callback(hObject, eventdata, handles)
|
---|
4321 | %------------------------------------------------------------------------
|
---|
4322 | data.Style='points';
|
---|
4323 | data.ProjMode='projection';%default
|
---|
4324 | create_object(data,handles)
|
---|
4325 |
|
---|
4326 | % -----------------------------------------------------------------------
|
---|
4327 | function Menuline_Callback(hObject, eventdata, handles)
|
---|
4328 | %------------------------------------------------------------------------
|
---|
4329 | data.Style='line';
|
---|
4330 | data.ProjMode='projection';%default
|
---|
4331 | create_object(data,handles)
|
---|
4332 |
|
---|
4333 | %------------------------------------------------------------------------
|
---|
4334 | function Menupolyline_Callback(hObject, eventdata, handles)
|
---|
4335 | %------------------------------------------------------------------------
|
---|
4336 | data.Style='polyline';
|
---|
4337 | data.ProjMode='projection';%default
|
---|
4338 | create_object(data,handles)
|
---|
4339 |
|
---|
4340 | %------------------------------------------------------------------------
|
---|
4341 | function Menupolygon_Callback(hObject, eventdata, handles)
|
---|
4342 | %------------------------------------------------------------------------
|
---|
4343 | data.Style='polygon';
|
---|
4344 | data.ProjMode='inside';%default
|
---|
4345 | create_object(data,handles)
|
---|
4346 |
|
---|
4347 | %------------------------------------------------------------------------
|
---|
4348 | function Menurectangle_Callback(hObject, eventdata, handles)
|
---|
4349 | %------------------------------------------------------------------------
|
---|
4350 | data.Style='rectangle';
|
---|
4351 | data.ProjMode='inside';%default
|
---|
4352 | create_object(data,handles)
|
---|
4353 |
|
---|
4354 | %------------------------------------------------------------------------
|
---|
4355 | function Menuellipse_Callback(hObject, eventdata, handles)
|
---|
4356 | %------------------------------------------------------------------------
|
---|
4357 | data.Style='ellipse';
|
---|
4358 | data.ProjMode='inside';%default
|
---|
4359 | create_object(data,handles)
|
---|
4360 |
|
---|
4361 | %------------------------------------------------------------------------
|
---|
4362 | function MenuMaskObject_Callback(hObject, eventdata, handles)
|
---|
4363 | %------------------------------------------------------------------------
|
---|
4364 | data.Style='polygon';
|
---|
4365 | data.StyleMenu={'polygon'};
|
---|
4366 | data.ProjMode='mask_inside';%default
|
---|
4367 | data.ProjMenu={'mask_inside';'mask_outside'};
|
---|
4368 | create_object(data,handles)
|
---|
4369 |
|
---|
4370 | %------------------------------------------------------------------------
|
---|
4371 | function Menuplane_Callback(hObject, eventdata, handles)
|
---|
4372 | %------------------------------------------------------------------------
|
---|
4373 | data.Style='plane';
|
---|
4374 | data.ProjMode='projection';%default
|
---|
4375 |
|
---|
4376 | create_object(data,handles)
|
---|
4377 |
|
---|
4378 | %------------------------------------------------------------------------
|
---|
4379 | function Menuvolume_Callback(hObject, eventdata, handles)
|
---|
4380 | %------------------------------------------------------------------------
|
---|
4381 | data.Style='volume';
|
---|
4382 | data.ProjMode='interp';%default
|
---|
4383 | % set(handles.create,'Visible','on')
|
---|
4384 | % set(handles.create,'Value',1)
|
---|
4385 | % VOLUME_Callback(hObject,eventdata,handles)
|
---|
4386 | create_object(data,handles)
|
---|
4387 |
|
---|
4388 | %------------------------------------------------------------------------
|
---|
4389 | function MenuBrowseObject_Callback(hObject, eventdata, handles)
|
---|
4390 | %------------------------------------------------------------------------
|
---|
4391 | %get the object file
|
---|
4392 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
4393 | {'*.xml;*.mat', ' (*.xml,*.mat)';
|
---|
4394 | '*.xml', '.xml files '; ...
|
---|
4395 | '*.mat', '.mat matlab files '}, ...
|
---|
4396 | 'Pick an xml Object file',get(handles.RootPath,'String'));
|
---|
4397 | fileinput=[PathName FileName];%complete file name
|
---|
4398 | sizf=size(fileinput);
|
---|
4399 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
4400 |
|
---|
4401 | %read the file
|
---|
4402 | t=xmltree(fileinput);
|
---|
4403 | data=convert(t);
|
---|
4404 | data.enable_plot=1;
|
---|
4405 | [pp,data.Name]=fileparts(FileName);
|
---|
4406 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
4407 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
4408 | if ~isempty(hset_object)
|
---|
4409 | delete(hset_object)% delete existing version of set_object
|
---|
4410 | end
|
---|
4411 | set_object(data);% call the set_object interface
|
---|
4412 | set(handles.edit_object,'Value',0); %suppress the object edit mode
|
---|
4413 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
4414 | set(handles.MenuObject,'checked','on')
|
---|
4415 | set(handles.delete_object,'Visible','on')
|
---|
4416 |
|
---|
4417 | %------------------------------------------------------------------------
|
---|
4418 | % --- generic function used for the creation of a projection object
|
---|
4419 | function create_object(data,handles)
|
---|
4420 | %------------------------------------------------------------------------
|
---|
4421 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
4422 | if ~isempty(hset_object)
|
---|
4423 | delete(hset_object)% delete existing version of set_object
|
---|
4424 | end
|
---|
4425 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
|
---|
4426 | if ishandle(hgeometry_calib)
|
---|
4427 | hhgeometry_calib=guidata(hgeometry_calib);
|
---|
4428 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
|
---|
4429 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
|
---|
4430 | end
|
---|
4431 | UvData=get(handles.uvmat,'UserData');
|
---|
4432 | set(handles.edit_object,'Value',0); %suppress the object edit mode
|
---|
4433 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
4434 | data.enable_plot=1;
|
---|
4435 | transform_list=get(handles.transform_fct,'String');
|
---|
4436 | val=get(handles.transform_fct,'Value');
|
---|
4437 | %data.CoordType=transform_list{val};
|
---|
4438 | if isfield(UvData,'Field')
|
---|
4439 | Field=UvData.Field;
|
---|
4440 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
|
---|
4441 | data.RangeX=Field.Mesh;
|
---|
4442 | data.RangeY=Field.Mesh;
|
---|
4443 | data.DX=Field.Mesh;
|
---|
4444 | data.DY=Field.Mesh;
|
---|
4445 | elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image
|
---|
4446 | np=size(Field.A);
|
---|
4447 | meshx=(Field.AX(end)-Field.AX(1))/np(2);
|
---|
4448 | meshy=abs(Field.AY(end)-Field.AY(1))/np(1);
|
---|
4449 | data.RangeY=max(meshx,meshy);
|
---|
4450 | data.RangeX=max(meshx,meshy);
|
---|
4451 | data.DX=max(meshx,meshy);
|
---|
4452 | end
|
---|
4453 | if isfield(Field,'NbDim')
|
---|
4454 | data.NbDim=Field.NbDim;
|
---|
4455 | end
|
---|
4456 | if isfield(Field,'CoordUnit')
|
---|
4457 | data.CoordUnit=Field.CoordUnit;
|
---|
4458 | end
|
---|
4459 | end
|
---|
4460 | data.Coord=[0 0 0]; %default
|
---|
4461 | if isfield(data,'Style') && isequal(data.Style,'line')
|
---|
4462 | if isfield(data,'DX')
|
---|
4463 | data.Coord=[[0 0 0];[data.DX 0 0]]; %default
|
---|
4464 | else
|
---|
4465 | data.Coord=[[0 0 0];[1 0 0]]; %default
|
---|
4466 | end
|
---|
4467 | end
|
---|
4468 | if ishandle(handles.UVMAT_title)
|
---|
4469 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
|
---|
4470 | end
|
---|
4471 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
4472 | set_object(data,handles);% call the set_object interface
|
---|
4473 | set(handles.MenuObject,'checked','on')
|
---|
4474 | set(handles.uvmat,'UserData',UvData)
|
---|
4475 | set(handles.CheckZoom,'Value',0)
|
---|
4476 | CheckZoom_Callback(handles.uvmat, [], handles)
|
---|
4477 | set(handles.delete_object,'Visible','on')
|
---|
4478 | % set(handles._title,'Visible','on')
|
---|
4479 | % set(handles.view_field_title,'Visible','on')
|
---|
4480 |
|
---|
4481 | %------------------------------------------------------------------------
|
---|
4482 | function MenuRuler_Callback(hObject, eventdata, handles)
|
---|
4483 | %------------------------------------------------------------------------
|
---|
4484 | set(handles.CheckZoom,'Value',0)
|
---|
4485 | CheckZoom_Callback(handles.uvmat, [], handles)
|
---|
4486 | set(handles.MenuRuler,'checked','on')
|
---|
4487 | UvData=get(handles.uvmat,'UserData');
|
---|
4488 | UvData.MouseAction='ruler';
|
---|
4489 | set(handles.uvmat,'UserData',UvData);
|
---|
4490 |
|
---|
4491 | %------------------------------------------------------------------------
|
---|
4492 | % --- executed when closing: set the parent interface button to value 0
|
---|
4493 | function closefcn(gcbo,eventdata)
|
---|
4494 | %------------------------------------------------------------------------
|
---|
4495 | %delete all the associated figures if exist
|
---|
4496 | hh=findobj(allchild(0),'tag','view_field');
|
---|
4497 | if ~isempty(hh)
|
---|
4498 | delete(hh)
|
---|
4499 | end
|
---|
4500 | hh=findobj(allchild(0),'tag','geometry_calib');
|
---|
4501 | if ~isempty(hh)
|
---|
4502 | delete(hh)
|
---|
4503 | end
|
---|
4504 | hh=findobj(allchild(0),'tag','set_object');
|
---|
4505 | if ~isempty(hh)
|
---|
4506 | hhh=findobj(hh,'tag','PLOT');
|
---|
4507 | set(hhh,'enable','off')
|
---|
4508 | end
|
---|
4509 |
|
---|
4510 | %------------------------------------------------------------------------
|
---|
4511 | % --- Executes on button press in delete_object.
|
---|
4512 | function delete_object_Callback(hObject, eventdata, handles)
|
---|
4513 | %------------------------------------------------------------------------
|
---|
4514 | IndexObj=get(handles.ListObject,'Value');
|
---|
4515 | if IndexObj(end)>1
|
---|
4516 | delete_object(IndexObj(end))
|
---|
4517 | end
|
---|
4518 |
|
---|
4519 | % --- Executes on button press in FixVelType.
|
---|
4520 | function FixVelType_Callback(hObject, eventdata, handles)
|
---|
4521 | val=get(handles.FixVelType,'Value');
|
---|
4522 | if ~val
|
---|
4523 | run0_Callback(hObject, eventdata, handles)
|
---|
4524 | end
|
---|
4525 |
|
---|
4526 | % --- Executes on button press in ViewObject.
|
---|
4527 | function ViewObject_Callback(hObject, eventdata, handles)
|
---|
4528 | IndexObj=get(handles.ListObject,'Value');
|
---|
4529 | IndexObj=IndexObj(end); %keeps only the secodn value
|
---|
4530 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
4531 | if numel(UvData.Object)<IndexObj;% error in UvData
|
---|
4532 | msgbox_uvmat('ERROR','invalid object list')
|
---|
4533 | return
|
---|
4534 | end
|
---|
4535 | ObjectData=UvData.Object{IndexObj};
|
---|
4536 | ZBounds=0; % default
|
---|
4537 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
|
---|
4538 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
|
---|
4539 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
|
---|
4540 | end
|
---|
4541 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
4542 | if ~isempty(hset_object)
|
---|
4543 | delete(hset_object)% delete existing version of set_object
|
---|
4544 | end
|
---|
4545 | hset_object=set_object(ObjectData,[],ZBounds);
|
---|
4546 |
|
---|
4547 |
|
---|
4548 | function NomType_Callback(hObject, eventdata, handles)
|
---|
4549 |
|
---|
4550 |
|
---|
4551 | function NomType_1_Callback(hObject, eventdata, handles)
|
---|
4552 |
|
---|