[2] | 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
|
---|
[45] | 7 | %%
|
---|
[2] | 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
|
---|
[38] | 15 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr.
|
---|
[2] | 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 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 | % .CoordType: (char string) coordinate transform: e.g. 'phys' or 'px'
|
---|
| 50 | % .MouseAction: store the current effect of mouse button (create or edit objects)
|
---|
| 51 | % - Information on projection objects
|
---|
| 52 | % .Object: {[1x1 struct]}
|
---|
| 53 | % .CurrentObjectIndex: index of the projection object .Object currently selected for editing
|
---|
| 54 | % -Information on the current field (Field{i})
|
---|
| 55 | % .Txt : text information to display (e.g. error message)
|
---|
| 56 | % .NbDim: number of dimensions (=0 by default)
|
---|
| 57 | % .NbCoord: number of vector components
|
---|
| 58 | % .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')
|
---|
| 59 | % .dt: time interval for the corresponding image pair
|
---|
| 60 | % .Mesh: estimated typical distance between vectors
|
---|
| 61 | % .ZMax:
|
---|
| 62 | % .ZMin:
|
---|
| 63 | % .X, .Y, .Z: set of vector coordinates
|
---|
| 64 | % .U,.V,.W: corresponding set of vector components
|
---|
| 65 | % .F: corresponding set of warning flags
|
---|
| 66 | % .FF: corresponding set of false flags, =0 for good vectors
|
---|
| 67 | % .C: corresponding values of the scalar used for vector color
|
---|
| 68 | % (.X, .Y, .Z,.U,.V,.W,.F,.FF,.C are matlab vectors of the same length,
|
---|
| 69 | % equal to the number of vectors stored in the input open)
|
---|
| 70 | % .CName: name of the scalar .C
|
---|
| 71 | % .CType: type of the scalar .C, setting how the scalar is obtained (see 'Scalars' below)
|
---|
| 72 | % .A image or scalar
|
---|
| 73 | % .AX: vector of dimension 2 representing the first and last values
|
---|
| 74 | % of the X coordinates for the image or scalar known on a regular grid,
|
---|
| 75 | % or vector of dimension .A for a scaler defined on irregular grid.
|
---|
| 76 | % .AY: same as .AX along the Y direction
|
---|
| 77 | % .AName: name of the scalar, ='image' for an image
|
---|
| 78 |
|
---|
| 79 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%:
|
---|
| 80 | %
|
---|
| 81 | % Main input open second input open(_1) second image (pair animation)
|
---|
| 82 | % read_ncfield.m | |
|
---|
[45] | 83 | % read image.m | |
|
---|
[2] | 84 | % Field{1} Field{2}
|
---|
| 85 | % |
|
---|
| 86 | % coord transform (phys.m) or other user defined fct acting on Field{i} |
|
---|
| 87 | % Field{i}
|
---|
| 88 | % |
|
---|
| 89 | % calc_field.m: calculate scalar or other derived fields (vort, div..).
|
---|
| 90 | %
|
---|
| 91 | % sub_field.m: combine the input Field{i} in a single set of fields (vector + scalar):
|
---|
| 92 | % Field{i=1->3}.X --> UvData.X |
|
---|
| 93 | % |
|
---|
| 94 | % UvData
|
---|
| 95 | % |
|
---|
| 96 | % plot histograms of the whole field
|
---|
| 97 | % proj_field.m: project the set of fields on the current projection objects defined by UvData.Object
|
---|
| 98 | % | |
|
---|
| 99 | % ObjectData
|
---|
| 100 | % |
|
---|
| 101 | % plot_field.m: plot the projected fields and store them as user |
|
---|
| 102 | % data of the plotting axes |
|
---|
| 103 | % |
|
---|
| 104 | % AxeData
|
---|
| 105 | %
|
---|
[15] | 106 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%%
|
---|
[2] | 107 | % scalars are displayed either as an image or countour plot, either as a color of
|
---|
| 108 | % velocity vectors. The scalar values in the first case is represented by
|
---|
| 109 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X
|
---|
| 110 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and
|
---|
| 111 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar
|
---|
| 112 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the
|
---|
| 113 | % coordinates of the four image corners. The scalar name is represented by
|
---|
| 114 | % the strings .AName and/or .CName.
|
---|
| 115 | % If the scalar exists in an input open (image or scalar stored under its
|
---|
| 116 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}.
|
---|
| 117 | % Else only its name AName is recorded in Field{i}, and its field is then calculated
|
---|
| 118 | %by the fuction calc_scal after the coordinate transform or after projection on an edit
|
---|
| 119 |
|
---|
| 120 | % Properties attached to plotting figures (standard Matlab properties):
|
---|
| 121 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes');
|
---|
| 122 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned
|
---|
| 123 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned
|
---|
| 124 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure
|
---|
| 125 | % 'KeyPressFcn': function called by pressing a key on the key board
|
---|
| 126 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure
|
---|
| 127 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure
|
---|
| 128 |
|
---|
| 129 | % Properties attached to plotting axes:
|
---|
| 130 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates.
|
---|
| 131 | % AxeData:=get(gca,'UserData');
|
---|
| 132 | % AxeData.Drawing = create: create a new edit
|
---|
| 133 | % = deform: modify an existing edit by moving its defining create
|
---|
| 134 | % = off: no current drawing action
|
---|
| 135 | % = translate: translate an existing edit
|
---|
| 136 | % = zoom: isolate a subregion for zoom in=1 if an edit is being currently drawn, 0 else (set to 0 by releasing mouse button)
|
---|
| 137 | % .hset_edit=handle of the set_edit interface (if a projection edit is edited);
|
---|
| 138 | % .CurrentOrigin: Origin of a curently drawn edit
|
---|
| 139 | % .CurrentLine: currently drawn menuline (A REVOIR)
|
---|
| 140 | % .CurrentObject: handle of the currently drawn edit
|
---|
| 141 | % .CurrentRectZoom: current rectangle used for zoom
|
---|
| 142 | % .zoomon : zoom state (a revoir)
|
---|
| 143 | % .X, .Y, .Z: array of coordinates defining the position of the vector: ASSOCIER AU PLAN (OBJET) PLUTOT QU'A L'AXE ?
|
---|
| 144 | % .U, .V, .W: array of components of the vector
|
---|
| 145 | % .C:
|
---|
| 146 | % .F:
|
---|
| 147 | % .FF:
|
---|
| 148 | % .A
|
---|
| 149 |
|
---|
| 150 | % Properties attached to projection objects (create, menuline, menuplane...):
|
---|
| 151 | % 'Tag'='proj_edit': for all projection objects
|
---|
| 152 | % ObjectData.Style=...: style of projection edit:
|
---|
| 153 | % .ProjMode
|
---|
| 154 | % .Coord: defines the position of the edit
|
---|
| 155 | % .XMin,YMin....
|
---|
| 156 | % .XMax,YMax....
|
---|
| 157 | % .DX,DY,DZ
|
---|
| 158 | % .Phi, .Theta, .Psi : Euler angles
|
---|
| 159 | % .X,.Y,.U,.V.... : field data projected on the edit
|
---|
| 160 | % .IndexObj: index in the list of UvData.Object
|
---|
| 161 | %during plotting
|
---|
| 162 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object
|
---|
| 163 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes
|
---|
| 164 | % To each projection object #iobj, corresponds an axis
|
---|
| 165 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the
|
---|
| 166 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field;
|
---|
[89] | 167 |
|
---|
| 168 | %------------------------------------------------------------------------
|
---|
| 169 | %------------------------------------------------------------------------
|
---|
[2] | 170 | % I - MAIN FUNCTION UVMAT (DO NOT MODIFY)
|
---|
[89] | 171 | %------------------------------------------------------------------------
|
---|
| 172 | %------------------------------------------------------------------------
|
---|
[2] | 173 | function varargout = uvmat(varargin)
|
---|
| 174 |
|
---|
| 175 | % Begin initialization code - DO NOT EDIT
|
---|
| 176 | gui_Singleton = 1;
|
---|
| 177 | gui_State = struct('gui_Name', mfilename, ...
|
---|
| 178 | 'gui_Singleton', gui_Singleton, ...
|
---|
| 179 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ...
|
---|
| 180 | 'gui_OutputFcn', @uvmat_OutputFcn, ...
|
---|
| 181 | 'gui_LayoutFcn', [], ...
|
---|
| 182 | 'gui_Callback', []);
|
---|
[128] | 183 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once'))
|
---|
[2] | 184 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
| 185 | end
|
---|
| 186 |
|
---|
| 187 | if nargout
|
---|
| 188 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
|
---|
| 189 | else
|
---|
| 190 | gui_mainfcn(gui_State, varargin{:});
|
---|
| 191 | end
|
---|
| 192 | % End initialization code - DO NOT EDIT
|
---|
| 193 |
|
---|
[89] | 194 | %------------------------------------------------------------------------
|
---|
[141] | 195 | % --- Executes just before the GUI uvmat is made visible.
|
---|
[2] | 196 | function uvmat_OpeningFcn(hObject, eventdata, handles, input )
|
---|
[89] | 197 | %------------------------------------------------------------------------
|
---|
[71] | 198 | global nb_builtin
|
---|
| 199 |
|
---|
[2] | 200 | % Choose default command menuline output for uvmat
|
---|
| 201 | handles.output = hObject;
|
---|
| 202 |
|
---|
| 203 | % Update handles structure
|
---|
| 204 | guidata(hObject, handles);
|
---|
| 205 |
|
---|
| 206 | % set the position of colorbar and ancillary GUIs:
|
---|
| 207 | set(hObject,'Units','Normalized')
|
---|
| 208 | movegui(hObject,'center')
|
---|
| 209 | UvData.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
| 210 | UvData.SetObjectOrigin=[-0.05 -0.03]; %position for set_object
|
---|
| 211 | UvData.SetObjectSize=[0.3 0.7];
|
---|
| 212 | UvData.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE)
|
---|
| 213 | UvData.CalSize=[0.28 1];
|
---|
| 214 |
|
---|
| 215 | %functions for the mouse and keyboard
|
---|
| 216 | set(handles.histo_u,'NextPlot','replacechildren');
|
---|
| 217 | set(handles.histo_v,'NextPlot','replacechildren');
|
---|
| 218 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
|
---|
| 219 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
|
---|
| 220 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
|
---|
| 221 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
|
---|
[67] | 222 | set(hObject,'DeleteFcn',{@closefcn})%
|
---|
[2] | 223 |
|
---|
[89] | 224 | %refresh projection plane
|
---|
| 225 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 226 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 227 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 228 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
| 229 | set(handles.list_object_1,'Value',1);
|
---|
| 230 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
| 231 | end
|
---|
| 232 |
|
---|
| 233 | %TRANSFORM menu: builtin fcts
|
---|
[39] | 234 | menu_str={'';'phys';'px';'phys_polar'};
|
---|
| 235 | nb_builtin=numel(menu_str); %number of functions
|
---|
[45] | 236 | path_uvmat=fileparts(which('uvmat'));
|
---|
[39] | 237 | addpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 238 | fct_handle{1,1}=[];
|
---|
[60] | 239 | testexist=zeros(size(menu_str'));%default
|
---|
[39] | 240 | testexist(1)=1;
|
---|
| 241 | for ilist=2:length(menu_str)
|
---|
| 242 | if exist(menu_str{ilist},'file')
|
---|
| 243 | fct_handle{ilist,1}=str2func(menu_str{ilist});
|
---|
| 244 | testexist(ilist)=1;
|
---|
| 245 | else
|
---|
| 246 | testexist(ilist)=0;
|
---|
| 247 | end
|
---|
| 248 | end
|
---|
| 249 | rmpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 250 |
|
---|
[2] | 251 | %load the list of previously browsed files in menus Open and Open_1
|
---|
[40] | 252 | dir_perso=prefdir; % path to the directory .matlab for personal data
|
---|
| 253 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
|
---|
[2] | 254 | if exist(profil_perso,'file')
|
---|
| 255 | h=load (profil_perso);
|
---|
| 256 | if isfield(h,'MenuFile_1')
|
---|
| 257 | set(handles.MenuFile_1,'Label',h.MenuFile_1);
|
---|
| 258 | set(handles.MenuFile_1_1,'Label',h.MenuFile_1);
|
---|
| 259 | end
|
---|
| 260 | if isfield(h,'MenuFile_1')
|
---|
| 261 | set(handles.MenuFile_2,'Label',h.MenuFile_2);
|
---|
| 262 | set(handles.MenuFile_2_1,'Label',h.MenuFile_2);
|
---|
| 263 | end
|
---|
| 264 | if isfield(h,'MenuFile_1')
|
---|
| 265 | set(handles.MenuFile_3,'Label',h.MenuFile_3);
|
---|
| 266 | set(handles.MenuFile_3_1,'Label',h.MenuFile_3);
|
---|
| 267 | end
|
---|
| 268 | if isfield(h,'MenuFile_1')
|
---|
| 269 | set(handles.MenuFile_4,'Label',h.MenuFile_4);
|
---|
| 270 | set(handles.MenuFile_4_1,'Label',h.MenuFile_4);
|
---|
| 271 | end
|
---|
| 272 | if isfield(h,'MenuFile_1')
|
---|
| 273 | set(handles.MenuFile_5,'Label',h.MenuFile_5);
|
---|
| 274 | set(handles.MenuFile_5_1,'Label',h.MenuFile_5);
|
---|
[39] | 275 | end
|
---|
| 276 | if isfield(h,'transform_fct') && iscell(h.transform_fct)
|
---|
| 277 | for ilist=1:length(h.transform_fct);
|
---|
| 278 | [path,file]=fileparts(h.transform_fct{ilist});
|
---|
| 279 | addpath(path)
|
---|
| 280 | if exist(file,'file')
|
---|
| 281 | h_func=str2func(file);
|
---|
[89] | 282 | testexist=[testexist 1];
|
---|
[39] | 283 | else
|
---|
| 284 | h_func=[];
|
---|
[89] | 285 | testexist=[testexist 0];
|
---|
[39] | 286 | end
|
---|
[89] | 287 | fct_handle=[fct_handle; {h_func}]; %concatene the list of paths
|
---|
[39] | 288 | rmpath(path)
|
---|
[89] | 289 | menu_str=[menu_str; {file}];
|
---|
[39] | 290 | end
|
---|
| 291 | end
|
---|
[2] | 292 | end
|
---|
[45] | 293 | menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
|
---|
| 294 | fct_handle=fct_handle(testexist==1);
|
---|
[39] | 295 | menu_str=[menu_str;{'more...'}];
|
---|
| 296 | set(handles.transform_fct,'String',menu_str)
|
---|
| 297 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
|
---|
[2] | 298 |
|
---|
| 299 | %initiates menu of vector colors
|
---|
| 300 | list_menu=calc_field;
|
---|
| 301 | %list_menu=[{'ima_cor'};{'black'};{'white'};list_menu(3:end)];
|
---|
| 302 | set(handles.col_vec,'String',list_menu)
|
---|
| 303 |
|
---|
| 304 | %check the path and date of modification of all functions in uvmat
|
---|
| 305 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat
|
---|
| 306 | [errormsg,date_str]=check_functions;%check the path of the functions called by uvmat.m
|
---|
[45] | 307 | date_str=['last modification: ' date_str];
|
---|
[2] | 308 | %case of an input argument for uvmat
|
---|
| 309 | testinputfield=0;
|
---|
| 310 | inputfile=[];
|
---|
| 311 | Field=[];
|
---|
| 312 | if exist('input','var')
|
---|
| 313 | if ~isempty(errormsg)
|
---|
[38] | 314 | msgbox_uvmat('WARNING',errormsg)
|
---|
[2] | 315 | end
|
---|
| 316 | if ishandle(handles.UVMAT_title)
|
---|
| 317 | delete(handles.UVMAT_title)
|
---|
| 318 | end
|
---|
| 319 | if isstruct(input)
|
---|
| 320 | if isfield(input,'InputFile')
|
---|
| 321 | inputfile=input.InputFile;
|
---|
| 322 | end
|
---|
| 323 | Field=input;
|
---|
| 324 | elseif ischar(input)% file name introduced as input
|
---|
| 325 | inputfile=input;
|
---|
[59] | 326 | elseif isnumeric(input)%simple matrix introduced as input
|
---|
[2] | 327 | sizinput=size(input);
|
---|
| 328 | if sizinput(1)<=1 || sizinput(2)<=1
|
---|
[38] | 329 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted')
|
---|
[2] | 330 | return
|
---|
| 331 | end
|
---|
[59] | 332 | Field.ListVarName={'A','coord_y','coord_x'};
|
---|
| 333 | Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'};
|
---|
[2] | 334 | Field.A=input;
|
---|
[59] | 335 | Field.coord_x=[0.5 size(input,2)-0.5];
|
---|
| 336 | Field.coord_y=[size(input,1)-0.5 0.5];
|
---|
[2] | 337 | end
|
---|
| 338 | if ~isempty(inputfile)
|
---|
| 339 | display_file_name(hObject, eventdata, handles,inputfile)
|
---|
| 340 | testinputfield=1;
|
---|
| 341 | else
|
---|
| 342 | UvData.TestInputFile=0;
|
---|
| 343 | end
|
---|
| 344 | if ~isempty(Field)
|
---|
| 345 | set(handles.Fields,'Value',1)
|
---|
[39] | 346 | set(handles.Fields,'String',{'get_field...'})
|
---|
[2] | 347 | testinputfield=1;
|
---|
| 348 |
|
---|
| 349 | % set the colorbar position on the interface:
|
---|
| 350 | UvData.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
| 351 | elseif ischar(input)
|
---|
| 352 | scan_i_Callback(handles.scan_i, eventdata, handles);
|
---|
| 353 | end
|
---|
| 354 | else
|
---|
| 355 | if ishandle(handles.UVMAT_title)
|
---|
[34] | 356 | fid=fopen('revision.log');
|
---|
[33] | 357 | if fid~=-1
|
---|
[105] | 358 | a=textscan(fid,'%s%s%s',1,'HeaderLines',1,'Delimiter','|');
|
---|
| 359 | set(handles.UVMAT_title,'String',[{'Copyright Joel Sommeria, 2008, Coriolis/ LEGI / CNRS-UJF-INPG'};{'GNU General Public License'}; {path_to_uvmat}; ...
|
---|
| 360 | {['at revision ' a{1}{1}]};a{3}(1);{date_str};errormsg]);
|
---|
| 361 | fclose(fid);
|
---|
[30] | 362 | else
|
---|
[105] | 363 | set(handles.UVMAT_title,'String',[{'Copyright Joel Sommeria, 2008, Coriolis/ LEGI / CNRS-UJF-INPG'};{'GNU General Public License'};{path_to_uvmat};...
|
---|
| 364 | {date_str};errormsg]);
|
---|
[30] | 365 | end
|
---|
[2] | 366 | end
|
---|
| 367 | end
|
---|
| 368 | UvData.NewSeries=1;
|
---|
| 369 | set(hObject,'UserData',UvData)
|
---|
| 370 | if testinputfield
|
---|
| 371 | %delete drawn objects
|
---|
| 372 | hother=findobj(handles.axes3,'Tag','proj_object');%find all the proj objects
|
---|
| 373 | for iobj=1:length(hother)
|
---|
| 374 | delete_object(hother(iobj))
|
---|
| 375 | end
|
---|
| 376 | if isempty(inputfile)
|
---|
[59] | 377 | errormsg=refresh_field(handles,[],[],[],[],[],[],{Field});
|
---|
[2] | 378 | set(handles.MenuTools,'Enable','on')
|
---|
| 379 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 380 | set(handles.edit,'Visible','on')
|
---|
[61] | 381 | set(handles.list_object_1,'Visible','on')
|
---|
[2] | 382 | set(handles.frame_object,'Visible','on')
|
---|
[71] | 383 | if ~isempty(errormsg)
|
---|
| 384 | msgbox_uvmat('ERROR',errormsg)
|
---|
| 385 | end
|
---|
[2] | 386 | else
|
---|
| 387 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 388 | end
|
---|
| 389 | end
|
---|
[40] | 390 | set_vec_col_bar(handles) %update the display of color code for vectors
|
---|
[38] | 391 |
|
---|
[141] | 392 | %------------------------------------------------------------------------
|
---|
[2] | 393 | % --- Outputs from this function are returned to the command menuline.
|
---|
| 394 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles)
|
---|
| 395 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
|
---|
| 396 |
|
---|
[141] | 397 | %------------------------------------------------------------------------
|
---|
| 398 | %------------------------------------------------------------------------
|
---|
| 399 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
[2] | 400 | % automatically sets the global properties when the rootfile name is introduced
|
---|
| 401 | % then activate the view-field action if selected
|
---|
| 402 | % it is activated either by clicking on the RootPath window or by the
|
---|
| 403 | % browser
|
---|
[141] | 404 | %------------------------------------------------------------------------
|
---|
| 405 | %------------------------------------------------------------------------
|
---|
[2] | 406 | % --- Executes on the menu Open/Browse...
|
---|
| 407 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
| 408 | function MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 409 | oldfile=read_file_boxes(handles);
|
---|
| 410 |
|
---|
| 411 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
|
---|
| 412 | dir_perso=prefdir;
|
---|
| 413 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 414 | if exist(profil_perso,'file')
|
---|
| 415 | h=load (profil_perso);
|
---|
| 416 | if isfield(h,'MenuFile_1')
|
---|
| 417 | oldfile=h.MenuFile_1;
|
---|
| 418 | end
|
---|
| 419 | end
|
---|
| 420 | end
|
---|
| 421 | [FileName, PathName] = uigetfile( ...
|
---|
[73] | 422 | {'*.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)';
|
---|
[2] | 423 | '*.xml', '.xml files '; ...
|
---|
| 424 | '*.xls', '.xls files '; ...
|
---|
| 425 | '*.civ', '.civ files '; ...
|
---|
| 426 | '*.jpg',' jpeg image files'; ...
|
---|
| 427 | '*.png','.png image files'; ...
|
---|
| 428 | '*.tif','.tif image files'; ...
|
---|
| 429 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
[73] | 430 | '*.vol','.volume images (png)'; ...
|
---|
[2] | 431 | '*.nc','.netcdf files'; ...
|
---|
| 432 | '*.cdf','.netcdf files'; ...
|
---|
| 433 | '*.cmx','.cmx text files';...
|
---|
| 434 | '*.cmx2','.cmx2 text files';...
|
---|
| 435 | '*.fig','.fig files (matlab fig)';...
|
---|
| 436 | '*.log','.log text files ';...
|
---|
| 437 | '*.dat','.dat text files ';...
|
---|
[73] | 438 | '*.bat','.bat system command text files';...
|
---|
[2] | 439 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 440 | 'Pick a file',oldfile);
|
---|
| 441 | %global filebase
|
---|
| 442 | fileinput=[PathName FileName];%complete file name
|
---|
| 443 | testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 444 | if ~isempty(testblank)
|
---|
[38] | 445 | msgbox_uvmat('ERROR',['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name'])
|
---|
[2] | 446 | return
|
---|
| 447 | end
|
---|
| 448 | sizf=size(fileinput);
|
---|
| 449 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 450 |
|
---|
| 451 | % display the selected field and related information
|
---|
| 452 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 453 |
|
---|
| 454 | %update list of recent files in the menubar
|
---|
| 455 | MenuFile_1=fileinput;
|
---|
| 456 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 457 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 458 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 459 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 460 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 461 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 462 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 463 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 464 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 465 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 466 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 467 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 468 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 469 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 470 | dir_perso=prefdir;
|
---|
| 471 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 472 | if exist(profil_perso,'file')
|
---|
| 473 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 474 | else
|
---|
| 475 | txt=ver;
|
---|
| 476 | Release=txt(1).Release;
|
---|
| 477 | relnumb=str2double(Release(3:4));
|
---|
| 478 | if relnumb >= 14
|
---|
| 479 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 480 | else
|
---|
| 481 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 482 | end
|
---|
| 483 | end
|
---|
| 484 |
|
---|
[141] | 485 | % -----------------------------------------------------------------------
|
---|
| 486 | % --- Open again the file whose name has been recorded in MenuFile_1
|
---|
[2] | 487 | function MenuFile_1_Callback(hObject, eventdata, handles)
|
---|
| 488 | fileinput=get(handles.MenuFile_1,'Label');
|
---|
| 489 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 490 |
|
---|
[141] | 491 | % -----------------------------------------------------------------------
|
---|
| 492 | % --- Open again the file whose name has been recorded in MenuFile_2
|
---|
[2] | 493 | function MenuFile_2_Callback(hObject, eventdata, handles)
|
---|
| 494 | fileinput=get(handles.MenuFile_2,'Label');
|
---|
| 495 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 496 |
|
---|
[141] | 497 | % -----------------------------------------------------------------------
|
---|
| 498 | % --- Open again the file whose name has been recorded in MenuFile_3
|
---|
[2] | 499 | function MenuFile_3_Callback(hObject, eventdata, handles)
|
---|
| 500 | fileinput=get(handles.MenuFile_3,'Label');
|
---|
| 501 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 502 |
|
---|
[141] | 503 | % -----------------------------------------------------------------------
|
---|
| 504 | % --- Open again the file whose name has been recorded in MenuFile_4
|
---|
[2] | 505 | function MenuFile_4_Callback(hObject, eventdata, handles)
|
---|
| 506 | fileinput=get(handles.MenuFile_4,'Label');
|
---|
| 507 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 508 |
|
---|
[141] | 509 | % -----------------------------------------------------------------------
|
---|
| 510 | % --- Open again the file whose name has been recorded in MenuFile_5
|
---|
[2] | 511 | function MenuFile_5_Callback(hObject, eventdata, handles)
|
---|
| 512 | fileinput=get(handles.MenuFile_5,'Label');
|
---|
| 513 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 514 |
|
---|
[141] | 515 | %------------------------------------------------------------------------
|
---|
| 516 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
[2] | 517 | function display_file_name(hObject, eventdata, handles,fileinput)
|
---|
[29] | 518 | if ~exist(fileinput,'file')
|
---|
| 519 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist'])
|
---|
| 520 | return
|
---|
| 521 | end
|
---|
[2] | 522 | [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput);
|
---|
[29] | 523 | ext_test=''; %default
|
---|
| 524 | if ~isempty(ext)
|
---|
| 525 | form=imformats(ext(2:end));%test valid Matlab image formats
|
---|
| 526 | if ~isempty(form)
|
---|
| 527 | ext_test='.image';
|
---|
| 528 | imainfo=imfinfo(fileinput);
|
---|
| 529 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 530 | i1='1'; % set the frame counter to 1 by default
|
---|
| 531 | i2='';
|
---|
| 532 | str_a='';
|
---|
| 533 | str_b='';
|
---|
| 534 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 535 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
| 536 | end
|
---|
| 537 | elseif isequal(lower(ext),'.avi')
|
---|
| 538 | ext_test='.image';
|
---|
[2] | 539 | i1='1'; % set the frame counter to 1 by default
|
---|
| 540 | i2='';
|
---|
| 541 | str_a='';
|
---|
| 542 | str_b='';
|
---|
| 543 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 544 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
[29] | 545 | else
|
---|
| 546 | ext_test=lower(ext);
|
---|
[2] | 547 | end
|
---|
| 548 | end
|
---|
| 549 | switch ext_test
|
---|
[73] | 550 | case {'.civ','.log','.cmx','.cmx2','.txt','.bat'} %display text file
|
---|
[2] | 551 | edit(fileinput)
|
---|
| 552 | case '.fig' %display matlab figure
|
---|
| 553 | hfig=open(fileinput);
|
---|
| 554 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 555 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 556 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 557 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 558 | editxml(fileinput);
|
---|
| 559 | case {'.avi','.image','.vol','.nc','.cdf'}
|
---|
| 560 | set(handles.RootPath,'String',RootPath);
|
---|
| 561 | if isequal(SubDir,'')
|
---|
| 562 | rootname=fullfile(RootPath,RootFile);
|
---|
| 563 | else
|
---|
| 564 | rootname=fullfile(RootPath,SubDir,RootFile);
|
---|
| 565 | SubDir=['/' SubDir]; %display the separator
|
---|
| 566 | end
|
---|
| 567 | set(handles.SubDir,'String',SubDir);
|
---|
| 568 | set(handles.RootFile,'String',['/' RootFile]); %display the separator
|
---|
| 569 | indices=fileinput(length(rootname)+1:end);
|
---|
| 570 | indices(end-length(ext)+1:end)=[]; %remove extension
|
---|
| 571 | set(handles.FileIndex,'String',indices);
|
---|
| 572 | set(handles.FileIndex,'UserData',NomType);
|
---|
| 573 | set(handles.FileExt,'String',ext);
|
---|
| 574 | % fill file index counters
|
---|
[71] | 575 | set(handles.i1,'String',i1);
|
---|
[2] | 576 | set(handles.i2,'String',i2);
|
---|
| 577 | set(handles.j1,'String',str_a);
|
---|
| 578 | set(handles.j2,'String',str_b);
|
---|
| 579 |
|
---|
| 580 | % synchronise indices of the second input file if it exists
|
---|
| 581 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
|
---|
[71] | 582 | [ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
[2] | 583 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[89] | 584 | FileName_1=name_generator(FileBase_1,str2double(i1),str2double(i2),FileExt_1,NomType_1,1,stra2num(str_a),stra2num(str_b),SubDir_1);
|
---|
[71] | 585 | if exist(FileName_1,'file')
|
---|
[89] | 586 | FileIndex_1=name_generator('',str2double(i1),str2double(i2),'',NomType_1,1,stra2num(str_a),stra2num(str_b),'');
|
---|
[2] | 587 | set(handles.FileIndex_1,'String',FileIndex_1)
|
---|
| 588 | else
|
---|
| 589 | set(handles.SubField,'Value',0)
|
---|
| 590 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 591 | end
|
---|
| 592 | end
|
---|
| 593 |
|
---|
| 594 | %enable other menus
|
---|
| 595 | set(handles.MenuOpen_1,'Enable','on')
|
---|
| 596 | set(handles.MenuFile_1_1,'Enable','on')
|
---|
| 597 | set(handles.MenuFile_2_1,'Enable','on')
|
---|
| 598 | set(handles.MenuFile_3_1,'Enable','on')
|
---|
| 599 | set(handles.MenuFile_4_1,'Enable','on')
|
---|
| 600 | set(handles.MenuFile_5_1,'Enable','on')
|
---|
| 601 | set(handles.MenuExport,'Enable','on')
|
---|
| 602 | set(handles.MenuExportFigure,'Enable','on')
|
---|
| 603 | set(handles.MenuExportMovie,'Enable','on')
|
---|
| 604 | set(handles.MenuTools,'Enable','on')
|
---|
| 605 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 606 | set(handles.edit,'Visible','on')
|
---|
[61] | 607 | set(handles.list_object_1,'Visible','on')
|
---|
[2] | 608 | set(handles.frame_object,'Visible','on')
|
---|
| 609 | % initiate input file:
|
---|
| 610 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 611 | otherwise
|
---|
| 612 | msgbox_uvmat('ERROR',['invalid input file extension' ext])
|
---|
| 613 | end
|
---|
| 614 |
|
---|
[89] | 615 | %------------------------------------------------------------------------
|
---|
[141] | 616 | % --- Called by action in RootPath edit box
|
---|
[2] | 617 | function RootPath_Callback(hObject,eventdata,handles)
|
---|
[89] | 618 | %------------------------------------------------------------------------
|
---|
[2] | 619 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 620 |
|
---|
[89] | 621 | %------------------------------------------------------------------------
|
---|
[141] | 622 | % --- Called by action in RootFile edit box
|
---|
[2] | 623 | function SubDir_Callback(hObject, eventdata, handles)
|
---|
[89] | 624 | %------------------------------------------------------------------------
|
---|
[2] | 625 | %refresh the menu of input fields
|
---|
| 626 | Fields_Callback(hObject, eventdata, handles);
|
---|
| 627 | % refresh the current field
|
---|
| 628 | run0_Callback(hObject, eventdata, handles);
|
---|
| 629 |
|
---|
[89] | 630 | %------------------------------------------------------------------------
|
---|
[141] | 631 | % --- Called by action in RootFile edit box
|
---|
[2] | 632 | function RootFile_Callback(hObject, eventdata, handles)
|
---|
[89] | 633 | %------------------------------------------------------------------------
|
---|
[2] | 634 | update_rootinfo(hObject,eventdata,handles)
|
---|
| 635 |
|
---|
[89] | 636 | %------------------------------------------------------------------------
|
---|
[141] | 637 | % --- Called by action in FileIndex edit box
|
---|
[81] | 638 | function FileIndex_Callback(hObject, eventdata, handles)
|
---|
[89] | 639 | %------------------------------------------------------------------------
|
---|
[81] | 640 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 641 | if isempty(str2num(FileIndices))
|
---|
| 642 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices);
|
---|
| 643 | else
|
---|
| 644 | str1=FileIndices;
|
---|
| 645 | str2='';
|
---|
| 646 | str_a='';
|
---|
| 647 | str_b='';
|
---|
| 648 | end
|
---|
| 649 | set(handles.i1,'String',str1);
|
---|
| 650 | set(handles.i2,'String',str2);
|
---|
| 651 | set(handles.j1,'String',str_a);
|
---|
| 652 | set(handles.j2,'String',str_b);
|
---|
| 653 | run0_Callback(hObject, eventdata, handles)
|
---|
[2] | 654 |
|
---|
[89] | 655 | %------------------------------------------------------------------------
|
---|
[141] | 656 | % --- Update information about a new field series (indices to scan, timing,
|
---|
| 657 | % calibration from an xml file, then refresh current plots
|
---|
[2] | 658 | function update_rootinfo(hObject,eventdata,handles)
|
---|
[89] | 659 | %------------------------------------------------------------------------
|
---|
[2] | 660 | set(handles.RootPath,'BackgroundColor',[1 1 0])
|
---|
| 661 | drawnow
|
---|
| 662 | set(handles.Fields,'UserData',[])% reinialize data from uvmat opening
|
---|
[59] | 663 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
[2] | 664 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 665 | UvData.TestInputFile=1;
|
---|
[81] | 666 | set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window
|
---|
[2] | 667 |
|
---|
| 668 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 669 | if ~exist(FileName,'file')
|
---|
| 670 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 671 | return
|
---|
| 672 | end
|
---|
| 673 | nbfield=[];%default
|
---|
| 674 | nburst=[];%default
|
---|
| 675 |
|
---|
| 676 | % read timing and total frame number from the current file (movie files) !! may be overrid by xml file
|
---|
| 677 | XmlData.Time=[];%default
|
---|
| 678 | XmlData.GeometryCalib=[];%default
|
---|
| 679 | TimeUnit=[];%default
|
---|
| 680 | testima=0; %test for image input
|
---|
[89] | 681 | imainfo=[];
|
---|
| 682 | ColorType='falsecolor'; %default
|
---|
| 683 | hhh='';
|
---|
[2] | 684 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 685 | testima=1;
|
---|
[89] | 686 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 687 | nbfield=imainfo.NumFrames;
|
---|
[2] | 688 | nburst=1;
|
---|
[89] | 689 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 690 | XmlData.Time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
|
---|
[2] | 691 | TimeUnit='s';
|
---|
| 692 | hhh=which('mmreader');
|
---|
[89] | 693 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
[139] | 694 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image
|
---|
[2] | 695 | testima=1;
|
---|
| 696 | if ~isequal(SubDir,'')
|
---|
| 697 | RootFile=get(handles.RootFile,'String');
|
---|
| 698 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 699 | else
|
---|
| 700 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 701 | end
|
---|
[89] | 702 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
[2] | 703 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 704 | nbfield=length(imainfo);
|
---|
| 705 | nburst=1;
|
---|
| 706 | end
|
---|
[89] | 707 | end
|
---|
| 708 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 709 | UvData.MovieObject=mmreader([FileBase FileIndices FileExt]);
|
---|
| 710 | elseif isfield(UvData,'MovieObject')
|
---|
| 711 | UvData=rmfield(UvData,'MovieObject');
|
---|
| 712 | end
|
---|
| 713 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
| 714 | set(handles.npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
| 715 | set(handles.npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
| 716 | else
|
---|
[2] | 717 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
[89] | 718 | set(handles.npy,'String','');%fills nbre of pixels x box
|
---|
[2] | 719 | end
|
---|
[89] | 720 | set(handles.BW,'Value',strcmp(ColorType,'grayscale'))% select handles.BW if grayscale image
|
---|
[2] | 721 |
|
---|
| 722 | % read parameters (time, geometric calibration..) from a documentation file (.xml advised)
|
---|
| 723 | filexml=[FileBase '.xml'];
|
---|
| 724 | fileciv=[FileBase '.civ'];
|
---|
| 725 | warntext='';%default warning message
|
---|
| 726 | NbSlice=1;%default
|
---|
| 727 |
|
---|
| 728 | if exist(filexml,'file')
|
---|
| 729 | set(handles.view_xml,'Visible','on')
|
---|
| 730 | set(handles.view_xml,'BackgroundColor',[1 1 0])
|
---|
| 731 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 732 | set(handles.view_xml,'String','view .xml')
|
---|
| 733 | drawnow
|
---|
| 734 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 735 | if ~isempty(warntext)
|
---|
| 736 | msgbox_uvmat('WARNING',warntext)
|
---|
| 737 | end
|
---|
| 738 | if isfield(XmlData,'TimeUnit')
|
---|
| 739 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
|
---|
| 740 | TimeUnit=XmlData.TimeUnit;
|
---|
| 741 | end
|
---|
| 742 | end
|
---|
| 743 | set(handles.view_xml,'BackgroundColor',[1 1 1])
|
---|
| 744 | drawnow
|
---|
[116] | 745 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib)
|
---|
| 746 | hgeometry_calib=findobj('tag','geometry_calib');
|
---|
| 747 | if ~isempty(hgeometry_calib)
|
---|
| 748 | GUserData=get(hgeometry_calib,'UserData');
|
---|
| 749 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,filexml))
|
---|
| 750 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?');
|
---|
| 751 | if strcmp(answer,'Yes')
|
---|
| 752 | geometry_calib(filexml);%diplay the new calibration points and parameters in geometry_calib
|
---|
| 753 | end
|
---|
| 754 | end
|
---|
| 755 | end
|
---|
| 756 | end
|
---|
[2] | 757 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 758 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 759 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 760 | GeometryCalib.Tx=0;
|
---|
| 761 | GeometryCalib.Ty=0;
|
---|
| 762 | GeometryCalib.Tz=1;
|
---|
| 763 | GeometryCalib.dpx=1;
|
---|
| 764 | GeometryCalib.dpy=1;
|
---|
| 765 | GeometryCalib.sx=1;
|
---|
| 766 | GeometryCalib.Cx=0;
|
---|
| 767 | GeometryCalib.Cy=0;
|
---|
| 768 | GeometryCalib.f=1;
|
---|
| 769 | GeometryCalib.kappa1=0;
|
---|
| 770 | GeometryCalib.CoordUnit='cm';
|
---|
| 771 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 772 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 773 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 774 | end
|
---|
| 775 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 776 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 777 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 778 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 779 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 780 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 781 | set(handles.view_xml,'Visible','on')
|
---|
| 782 | set(handles.view_xml,'String','view .civ')
|
---|
| 783 | else
|
---|
| 784 | set(handles.view_xml,'Visible','off')
|
---|
| 785 | end
|
---|
| 786 |
|
---|
| 787 | % store last index in handles.lat_i and .last_j
|
---|
| 788 | if ~isempty(XmlData.Time)
|
---|
| 789 | nbfield=size(XmlData.Time,1);
|
---|
| 790 | nburst=size(XmlData.Time,2);
|
---|
[84] | 791 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
|
---|
| 792 | if isequal(nbfield,1) && ~isequal(nburst,1)% .Time is a line vector
|
---|
| 793 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 794 | if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
|
---|
| 795 | XmlData.Time=(XmlData.Time)';
|
---|
| 796 | nbfield=nburst;
|
---|
| 797 | nburst=1;
|
---|
| 798 | end
|
---|
| 799 | end
|
---|
[2] | 800 | end
|
---|
| 801 | last_i_cell=get(handles.last_i,'String');
|
---|
| 802 | if isempty(nbfield)
|
---|
| 803 | last_i_cell{1}='';
|
---|
| 804 | else
|
---|
| 805 | last_i_cell{1}=num2str(nbfield);
|
---|
| 806 | end
|
---|
| 807 | set(handles.last_i,'String',last_i_cell)
|
---|
| 808 | last_j_cell=get(handles.last_j,'String');
|
---|
| 809 | if isempty(nburst)
|
---|
| 810 | last_j_cell{1}='';
|
---|
| 811 | else
|
---|
| 812 | last_j_cell{1}=num2str(nburst);
|
---|
| 813 | end
|
---|
| 814 | set(handles.last_j,'String',last_j_cell);
|
---|
| 815 |
|
---|
| 816 | % store geometric calibration in UvData
|
---|
| 817 | if isfield(XmlData,'GeometryCalib')
|
---|
| 818 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 819 | if isempty(GeometryCalib)
|
---|
| 820 | set(handles.pxcm,'String','')
|
---|
| 821 | set(handles.pycm,'String','')
|
---|
[39] | 822 | set(handles.transform_fct,'Value',1); % no transform by default
|
---|
[2] | 823 | else
|
---|
[122] | 824 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
|
---|
[89] | 825 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
|
---|
[2] | 826 | set(handles.pxcm,'String','var')
|
---|
| 827 | set(handles.pycm,'String','var')
|
---|
[114] | 828 | elseif isfield(GeometryCalib,'fx_fy')
|
---|
[122] | 829 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 830 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
[2] | 831 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 832 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 833 | end
|
---|
[84] | 834 | if ~get(handles.FixedLimits,'Value')
|
---|
| 835 | set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off
|
---|
| 836 | end
|
---|
[2] | 837 | if isfield(GeometryCalib,'SliceCoord')
|
---|
[89] | 838 |
|
---|
[2] | 839 | siz=size(GeometryCalib.SliceCoord);
|
---|
| 840 | if siz(1)>1
|
---|
| 841 | NbSlice=siz(1);
|
---|
| 842 | set(handles.slices,'Visible','on')
|
---|
| 843 | set(handles.slices,'Value',1)
|
---|
| 844 | end
|
---|
[73] | 845 | if isfield(GeometryCalib,'NbSlice') && isequal(GeometryCalib.NbSlice,'volume')
|
---|
[60] | 846 | set(handles.nb_slice,'String','volume')
|
---|
| 847 | else
|
---|
| 848 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 849 | end
|
---|
[2] | 850 | slices_Callback(hObject, eventdata, handles)
|
---|
[89] | 851 | end
|
---|
[2] | 852 | end
|
---|
| 853 | end
|
---|
| 854 |
|
---|
| 855 | %update the data attached to the uvmat interface
|
---|
| 856 | if ~isempty(TimeUnit)
|
---|
| 857 | set(handles.time_txt,'String',['time (' TimeUnit ')'])
|
---|
| 858 | end
|
---|
| 859 | UvData.TimeUnit=TimeUnit;
|
---|
| 860 | UvData.XmlData=XmlData;
|
---|
| 861 | UvData.NewSeries=1;
|
---|
[59] | 862 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 863 |
|
---|
| 864 | %display warning message
|
---|
| 865 | if ~isequal(warntext,'')
|
---|
| 866 | msgbox_uvmat('WARNING',warntext);
|
---|
| 867 | end
|
---|
| 868 |
|
---|
| 869 | % set default options in menu 'Fields'
|
---|
| 870 | if testima
|
---|
| 871 | set(handles.Fields,'Value',1) % set menu to 'image'
|
---|
| 872 | set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
[45] | 873 | elseif isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
|
---|
[56] | 874 | Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ');
|
---|
[2] | 875 | col_vec=get(handles.col_vec,'String');
|
---|
[59] | 876 | if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)
|
---|
[2] | 877 | set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 878 | set(handles.Fields,'Value',3) % set menu to 'velocity'
|
---|
| 879 | col_vec{1}='ima_cor';
|
---|
[45] | 880 | else %general netcdf file (not civx)
|
---|
[2] | 881 | set(handles.Fields,'Value',1) % set menu to 'get_field...
|
---|
| 882 | set(handles.Fields,'String',{'get_field...'})
|
---|
| 883 | col_vec{1}='get_field...';
|
---|
| 884 | end
|
---|
| 885 | set(handles.col_vec,'String',col_vec)
|
---|
| 886 | else
|
---|
| 887 | msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
|
---|
| 888 | return
|
---|
| 889 | end
|
---|
| 890 |
|
---|
| 891 | % set index navigation options and refresh plots
|
---|
| 892 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 893 | drawnow
|
---|
| 894 | set_scan_options(hObject, eventdata, handles)
|
---|
| 895 |
|
---|
[141] | 896 | %------------------------------------------------------------------------
|
---|
| 897 | %--- Set index navigation options for new series input and refresh plot
|
---|
| 898 | %------------------------------------------------------------------------
|
---|
[2] | 899 | function set_scan_options(hObject, eventdata, handles)
|
---|
| 900 |
|
---|
[81] | 901 | % set the corresponding index navigation options
|
---|
| 902 | NomType=get(handles.FileIndex,'UserData');
|
---|
[2] | 903 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[81] | 904 | last_i_str=get(handles.last_i,'String');
|
---|
| 905 | nbfield=str2num(last_i_str{1});
|
---|
| 906 | if numel(last_i_str)==2
|
---|
| 907 | nbfield=min(nbfield,str2num(last_i_str{2}));
|
---|
| 908 | end
|
---|
[2] | 909 | state_j='off'; %default
|
---|
[81] | 910 | scan_option='i';%default
|
---|
[122] | 911 | NomTypeRaw=regexprep(NomType(2:end), '-', '');
|
---|
| 912 | if numel(regexp(NomTypeRaw,'\D'))>=1
|
---|
| 913 | % case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab','#A','%01dA','%02dA','%03dA','%04dA'},% two navigation indices
|
---|
[2] | 914 | state_j='on';
|
---|
[81] | 915 | if isequal(nbfield,1)
|
---|
[122] | 916 | scan_option='j'; %scan j index by default if nbfield=1
|
---|
[2] | 917 | end
|
---|
| 918 | end
|
---|
| 919 | if ~isempty(NomType_1)
|
---|
[122] | 920 | NomTypeRaw=regexprep(NomType_1(2:end), '-', '');
|
---|
| 921 | if numel(regexp(NomTypeRaw,'\D'))>=1
|
---|
| 922 | % switch NomType_1
|
---|
| 923 | % case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
|
---|
[2] | 924 | state_j='on';
|
---|
[81] | 925 | if isequal(nbfield,1)
|
---|
| 926 | scan_option='j';
|
---|
| 927 | end
|
---|
[2] | 928 | end
|
---|
| 929 | end
|
---|
| 930 | if isequal(scan_option,'i')
|
---|
| 931 | set(handles.scan_i,'Value',1)
|
---|
| 932 | scan_i_Callback(hObject, eventdata, handles);
|
---|
| 933 | else
|
---|
| 934 | set(handles.scan_j,'Value',1)
|
---|
| 935 | scan_j_Callback(hObject, eventdata, handles);
|
---|
| 936 | end
|
---|
| 937 | set(handles.scan_j,'Visible',state_j)
|
---|
| 938 | set(handles.j1,'Visible',state_j)
|
---|
| 939 | set(handles.j2,'Visible',state_j)
|
---|
| 940 | set(handles.last_j,'Visible',state_j);
|
---|
| 941 | set(handles.frame_j,'Visible',state_j);
|
---|
| 942 | set(handles.j_text,'Visible',state_j);
|
---|
| 943 |
|
---|
| 944 | % view the field
|
---|
| 945 | run0_Callback(hObject, eventdata, handles); %view field
|
---|
| 946 | mask_test=get(handles.mask_test,'value');
|
---|
| 947 | if mask_test
|
---|
| 948 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 949 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 950 | delete(MaskData.maskhandle) %delete old mask
|
---|
| 951 | end
|
---|
| 952 | mask_test_Callback(hObject, eventdata, handles)
|
---|
| 953 | end
|
---|
[59] | 954 |
|
---|
[141] | 955 | %------------------------------------------------------------------------
|
---|
| 956 | % --- Executes on the menu Open/Browse_1 for the second input field,
|
---|
| 957 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
[2] | 958 | function MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 959 | %-------------------------------------------------------------------
|
---|
[61] | 960 | % huvmat=get(handles.run0,'parent');
|
---|
| 961 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 962 |
|
---|
| 963 | RootPath=get(handles.RootPath,'String');
|
---|
| 964 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 965 | {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
|
---|
| 966 | '*.xml', '.xml files '; ...
|
---|
| 967 | '*.xls', '.xls files '; ...
|
---|
| 968 | '*.civ', '.civ files '; ...
|
---|
| 969 | '*.jpg','.jpg image files'; ...
|
---|
| 970 | '*.png','.png image files'; ...
|
---|
| 971 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 972 | '*.nc','.netcdf files'; ...
|
---|
| 973 | '*.cdf','.netcdf files'; ...
|
---|
| 974 | '*.cmx','.cmx text files';...
|
---|
| 975 | '*.cmx2','.cmx2 text files';...
|
---|
| 976 | '*.fig','.fig files (matlab fig)';...
|
---|
| 977 | '*.log','.log text files ';...
|
---|
| 978 | '*.dat','.dat text files ';...
|
---|
| 979 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 980 | 'Pick a file',RootPath);
|
---|
| 981 | fileinput_1=[PathName FileName];%complete file name
|
---|
| 982 | testblank=findstr(fileinput_1,' ');%look for blanks
|
---|
| 983 | if ~isempty(testblank)
|
---|
[38] | 984 | msgbox_uvmat('ERROR',['The input file name ' fileinput_1 ' contains blank character : This is not allowed. Please change name'])
|
---|
[2] | 985 | return
|
---|
| 986 | end
|
---|
| 987 | sizf=size(fileinput_1);
|
---|
[89] | 988 | if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end
|
---|
[2] | 989 |
|
---|
| 990 | % refresh the current displayed field
|
---|
| 991 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 992 |
|
---|
| 993 | %update list of recent files in the menubar
|
---|
| 994 | MenuFile_1=fileinput_1;
|
---|
| 995 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 996 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 997 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 998 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 999 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 1000 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 1001 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 1002 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 1003 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 1004 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 1005 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 1006 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 1007 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 1008 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 1009 | dir_perso=prefdir;
|
---|
| 1010 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 1011 | if exist(profil_perso,'file')
|
---|
| 1012 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 1013 | else
|
---|
| 1014 | txt=ver;
|
---|
| 1015 | Release=txt(1).Release;
|
---|
| 1016 | relnumb=str2num(Release(3:4));
|
---|
| 1017 | if relnumb >= 14
|
---|
| 1018 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 1019 | else
|
---|
| 1020 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 1021 | end
|
---|
| 1022 | end
|
---|
| 1023 |
|
---|
[141] | 1024 | % -----------------------------------------------------------------------
|
---|
| 1025 | % --- Open again as second field the file whose name has been recorded in MenuFile_1
|
---|
[2] | 1026 | function MenuFile_1_1_Callback(hObject, eventdata, handles)
|
---|
| 1027 | fileinput_1=get(handles.MenuFile_1_1,'Label');
|
---|
| 1028 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1029 |
|
---|
[141] | 1030 | % -----------------------------------------------------------------------
|
---|
| 1031 | % --- Open again as second field the file whose name has been recorded in MenuFile_2
|
---|
[2] | 1032 | function MenuFile_2_1_Callback(hObject, eventdata, handles)
|
---|
| 1033 | fileinput_1=get(handles.MenuFile_2_1,'Label');
|
---|
| 1034 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1035 |
|
---|
[141] | 1036 | % -----------------------------------------------------------------------
|
---|
| 1037 | % --- Open again as second field the file whose name has been recorded in MenuFile_3
|
---|
[2] | 1038 | function MenuFile_3_1_Callback(hObject, eventdata, handles)
|
---|
| 1039 | fileinput_1=get(handles.MenuFile_3_1,'Label');
|
---|
| 1040 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1041 |
|
---|
[141] | 1042 | % -----------------------------------------------------------------------
|
---|
| 1043 | % --- Open again as second field the file whose name has been recorded in MenuFile_4
|
---|
[2] | 1044 | function MenuFile_4_1_Callback(hObject, eventdata, handles)
|
---|
| 1045 | fileinput_1=get(handles.MenuFile_4_1,'Label');
|
---|
| 1046 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1047 |
|
---|
[141] | 1048 | % -----------------------------------------------------------------------
|
---|
| 1049 | % --- Open again as second field the file whose name has been recorded in MenuFile_5
|
---|
[2] | 1050 | function MenuFile_5_1_Callback(hObject, eventdata, handles)
|
---|
| 1051 | fileinput_1=get(handles.MenuFile_5_1,'Label');
|
---|
| 1052 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1053 |
|
---|
[141] | 1054 | %------------------------------------------------------------------------
|
---|
| 1055 | % fills the edit boxes RootPath_1, RootFile_1,NomType_1...from an input file name 'fileinput_1'
|
---|
| 1056 | %------------------------------------------------------------------------
|
---|
[2] | 1057 | function display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1058 |
|
---|
| 1059 | %[path,name,ext]=fileparts(fileinput_1);
|
---|
| 1060 | [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
|
---|
| 1061 | nbfield_1=1; %default
|
---|
| 1062 | ext_test=FileExt_1;%default
|
---|
| 1063 | form=imformats(FileExt_1(2:end));
|
---|
| 1064 | if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab
|
---|
| 1065 | imainfo=imfinfo(fileinput_1);
|
---|
| 1066 | nbfield_1=length(imainfo);
|
---|
| 1067 | ext_test='.image';
|
---|
| 1068 | elseif isequal(lower(FileExt_1),'.avi')
|
---|
| 1069 | info=aviinfo(fileinput_1);
|
---|
| 1070 | nbfield_1=info.NumFrames;
|
---|
| 1071 | ext_test='.image';
|
---|
| 1072 | end
|
---|
| 1073 |
|
---|
| 1074 | %open directly fig or text files
|
---|
| 1075 | switch ext_test
|
---|
| 1076 | case {'.civ','.log','.cmx','.cmx2','.txt'} %display text file
|
---|
| 1077 | edit(fileinput)
|
---|
| 1078 | return
|
---|
| 1079 | case '.fig' %display matlab figure
|
---|
| 1080 | hfig=open(fileinput);
|
---|
| 1081 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 1082 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 1083 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 1084 | return
|
---|
| 1085 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 1086 | heditxml=editxml(fileinput);
|
---|
| 1087 | return
|
---|
| 1088 | case {'.image','.nc','.cdf'}
|
---|
| 1089 | % set(handles.FileIndex,'UserData',NomType_1);
|
---|
| 1090 | otherwise
|
---|
[38] | 1091 | msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')
|
---|
[2] | 1092 | return
|
---|
| 1093 | end
|
---|
| 1094 |
|
---|
| 1095 | % test for image series in a single file and synchronise file indices of the two series
|
---|
| 1096 | if nbfield_1 >1 %case of image with multiple frames
|
---|
| 1097 | if nbfield_1 < num_i1
|
---|
[38] | 1098 | msgbox_uvmat('ERROR','current frame index beyond the input movie length')
|
---|
[2] | 1099 | return
|
---|
| 1100 | else
|
---|
| 1101 | NomType_1='*'; %indicate a set of indexed frames within a single file
|
---|
| 1102 | filename_new=fileinput_1;
|
---|
| 1103 | end
|
---|
| 1104 | else % cases of data files
|
---|
| 1105 | RootPath=get(handles.RootPath,'String');
|
---|
| 1106 | RootFile=get(handles.RootFile,'String');
|
---|
| 1107 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 1108 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 1109 | if isequal(FileBase,FileBase_1)
|
---|
| 1110 | filename_new=fileinput_1;
|
---|
| 1111 | else
|
---|
| 1112 | num_i1=stra2num(get(handles.i1,'String'));%get the current file indices from counters
|
---|
| 1113 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1114 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1115 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1116 | [filename_new,idetect]=...
|
---|
| 1117 | name_generator(FileBase_1,num_i1,num_j1,FileExt_1,NomType_1,1,num_i2,num_j2,SubDir_1);%create name with indices synchronised with the first file
|
---|
| 1118 | indices=''; %default
|
---|
| 1119 | if ~idetect
|
---|
[38] | 1120 | msgbox_uvmat('ERROR','second input file with indices corresponding to the first one does not exist')
|
---|
[2] | 1121 | return
|
---|
| 1122 | end
|
---|
| 1123 | end
|
---|
| 1124 | end
|
---|
[81] | 1125 | set(handles.FileIndex_1,'UserData',NomType_1);
|
---|
[2] | 1126 |
|
---|
| 1127 | % make visible and fill the second raw of edit boxes
|
---|
| 1128 | set(handles.RootPath_1,'Visible','on')
|
---|
| 1129 | set(handles.RootFile_1,'Visible','on')
|
---|
| 1130 | set(handles.SubDir_1,'Visible','on');
|
---|
| 1131 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 1132 | set(handles.FileExt_1,'Visible','on');
|
---|
| 1133 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 1134 | if isequal(FileBase,FileBase_1)
|
---|
| 1135 | set(handles.RootPath_1,'String','"')
|
---|
| 1136 | set(handles.RootFile_1,'String','"');
|
---|
| 1137 | else
|
---|
| 1138 | set(handles.RootPath_1,'String',RootPath_1)
|
---|
| 1139 | set(handles.RootFile_1,'String',['/' RootFile_1]);
|
---|
| 1140 | end
|
---|
| 1141 | if isequal(SubDir_1,'')
|
---|
| 1142 | set(handles.SubDir_1,'String','');
|
---|
| 1143 | FileBaseSub_1=FileBase_1;
|
---|
| 1144 | else
|
---|
| 1145 | set(handles.SubDir_1,'String',['/' SubDir_1]);
|
---|
| 1146 | FileBaseSub_1=fullfile(FileBase_1,SubDir_1);
|
---|
| 1147 | end
|
---|
| 1148 | indices=filename_new(length(FileBaseSub_1)+1:end);
|
---|
| 1149 | indices(end-length(FileExt_1)+1:end)=[]; %remove extension
|
---|
| 1150 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1151 | set(handles.FileIndex_1,'UserData',NomType_1)
|
---|
| 1152 | set(handles.FileExt_1,'String',FileExt_1);
|
---|
| 1153 |
|
---|
| 1154 | % default choice of fields
|
---|
| 1155 | if isequal(ext_test,'.image')
|
---|
| 1156 | set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1157 | set(handles.Fields_1,'Value',2) % set menu to 'image'
|
---|
[128] | 1158 | elseif strcmp(FileExt_1,'.nc')||strcmp(FileExt_1,'.cdf')
|
---|
[2] | 1159 | Data=nc2struct(fileinput_1,[]);
|
---|
| 1160 | if isfield(Data,'absolut_time_T0')
|
---|
| 1161 | set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1162 | set(handles.Fields_1,'Value',4) % set menu to 'velocity'
|
---|
| 1163 | else
|
---|
| 1164 | set(handles.Fields_1,'Value',2) % set menu to 'get_field...'
|
---|
| 1165 | set(handles.Fields_1,'String',{'';'get_field...'});
|
---|
| 1166 | end
|
---|
| 1167 | end
|
---|
| 1168 | set(handles.SubField,'Visible','on')
|
---|
| 1169 | set(handles.SubField,'Value',1)
|
---|
| 1170 | RootPath_1_Callback(hObject,eventdata,handles);
|
---|
| 1171 |
|
---|
[141] | 1172 | %-----------------------------------------------------------------------
|
---|
| 1173 | % --- Called by action in RootPath_1 edit box
|
---|
[2] | 1174 | function RootPath_1_Callback(hObject,eventdata,handles)
|
---|
| 1175 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1176 |
|
---|
[141] | 1177 | %-----------------------------------------------------------------------
|
---|
| 1178 | % --- Called by action in RootFile_1 edit box
|
---|
[2] | 1179 | function RootFile_1_Callback(hObject, eventdata, handles)
|
---|
| 1180 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
[141] | 1181 | %-----------------------------------------------------------------------
|
---|
[2] | 1182 |
|
---|
[141] | 1183 | %------------------------------------------------------------------------
|
---|
| 1184 | % --- Called by action in FileIndex_1 edit box
|
---|
| 1185 | function FileIndex_1_Callback(hObject, eventdata, handles)
|
---|
| 1186 | %------------------------------------------------------------------------
|
---|
| 1187 |
|
---|
| 1188 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1189 |
|
---|
| 1190 | %------------------------------------------------------------------------
|
---|
| 1191 | % --- Update information about a new second field series (indices to scan, timing,
|
---|
| 1192 | % calibration from an xml file, then refresh current plots
|
---|
[2] | 1193 | function update_rootinfo_1(hObject,eventdata,handles) %A REVOIR
|
---|
| 1194 |
|
---|
| 1195 | set(handles.RootPath_1,'BackgroundColor',[1 1 0])% indicate active program by yellow color
|
---|
| 1196 | drawnow
|
---|
[61] | 1197 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
[2] | 1198 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 1199 |
|
---|
[93] | 1200 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes_1(handles);
|
---|
[2] | 1201 | if ~exist(FileName,'file')
|
---|
| 1202 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 1203 | end
|
---|
| 1204 | nbfield_1=[];%default
|
---|
| 1205 | nburst_1=[];%default
|
---|
| 1206 | XmlData.Time=[];
|
---|
| 1207 | XmlData.GeometryCalib=[];%default
|
---|
| 1208 | TimeUnit=[];
|
---|
| 1209 | if isfield(UvData,'TimeUnit')
|
---|
| 1210 | TimeUnit=UvData.TimeUnit;
|
---|
| 1211 | end
|
---|
| 1212 | TimeUnit_1=[];
|
---|
[89] | 1213 | hhh='';%default, test for movie reading with mmreader
|
---|
| 1214 | imainfo=[];
|
---|
[2] | 1215 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
[89] | 1216 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 1217 | nbfield_1=imainfo.NumFrames;
|
---|
[2] | 1218 | nburst_1=1;
|
---|
| 1219 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
[89] | 1220 | time=[0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond]';
|
---|
| 1221 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
| 1222 | hhh=which('mmreader');
|
---|
| 1223 | elseif ~isempty(imformats(FileExt(2:end)))|| isequal(FileExt,'.vol')
|
---|
| 1224 | if ~isequal(SubDir,'')
|
---|
| 1225 | RootFile=get(handles.RootFile,'String');
|
---|
| 1226 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 1227 | else
|
---|
| 1228 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
[2] | 1229 | end
|
---|
[89] | 1230 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
[2] | 1231 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 1232 | nbfield_1=length(imainfo);
|
---|
| 1233 | nburst_1=1;
|
---|
[89] | 1234 | end
|
---|
[2] | 1235 | end
|
---|
[89] | 1236 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 1237 | UvData.MovieObject_1=mmreader([FileBase FileIndices FileExt]);
|
---|
| 1238 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 1239 | UvData=rmfield(UvData,'MovieObject_1');
|
---|
| 1240 | end
|
---|
[141] | 1241 | if ~isempty(imainfo)% (an image has been introduced as second fierld input)
|
---|
| 1242 | if strcmp(get(handles.npx,'String'),'') || strcmp(get(handles.npy,'String'),'')%update npx and npy if it is not already filled by the first input field
|
---|
| 1243 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
| 1244 | set(handles.npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
| 1245 | set(handles.npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
| 1246 | else
|
---|
| 1247 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 1248 | set(handles.npy,'String','');%fills nbre of pixels x box
|
---|
| 1249 | end
|
---|
| 1250 | set(handles.BW,'Value',strcmp(ColorType,'grayscale'))% select handles.BW if grayscale image
|
---|
[89] | 1251 | end
|
---|
| 1252 | end
|
---|
[2] | 1253 | % find scaling parameters
|
---|
| 1254 | filexml=[FileBase '.xml'];
|
---|
| 1255 | fileciv=[FileBase '.civ'];
|
---|
| 1256 | warntext='';%default warning text
|
---|
| 1257 | if exist(filexml,'file')
|
---|
| 1258 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 1259 | if ~isempty(warntext)
|
---|
| 1260 | msgbox_uvmat('WARNING',warntext)
|
---|
| 1261 | end
|
---|
| 1262 | if isfield(XmlData,'Camera')
|
---|
| 1263 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
|
---|
| 1264 | TimeUnit=XmlData.Camera.TimeUnit;
|
---|
| 1265 | end
|
---|
| 1266 | end
|
---|
| 1267 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 1268 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 1269 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 1270 | GeometryCalib.Tx=0;
|
---|
| 1271 | GeometryCalib.Ty=0;
|
---|
| 1272 | GeometryCalib.Tz=1;
|
---|
| 1273 | GeometryCalib.dpx=1;
|
---|
| 1274 | GeometryCalib.dpy=1;
|
---|
| 1275 | GeometryCalib.sx=1;
|
---|
| 1276 | GeometryCalib.Cx=0;
|
---|
| 1277 | GeometryCalib.Cy=0;
|
---|
| 1278 | GeometryCalib.f=1;
|
---|
| 1279 | GeometryCalib.kappa1=0;
|
---|
| 1280 | GeometryCalib.CoordUnit='cm';
|
---|
| 1281 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 1282 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 1283 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 1284 | end
|
---|
| 1285 |
|
---|
| 1286 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 1287 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 1288 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 1289 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 1290 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 1291 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 1292 | end
|
---|
| 1293 | if ~isempty(TimeUnit_1) && ~isequal(TimeUnit_1,TimeUnit)
|
---|
[38] | 1294 | msgbox_uvmat('WARNING','the time units for the second series differs from the first one')
|
---|
[2] | 1295 | end
|
---|
| 1296 |
|
---|
| 1297 | % store last index in handles.lat_i and .last_j
|
---|
| 1298 | if ~isempty(XmlData.Time)
|
---|
| 1299 | nbfield_1=size(XmlData.Time,1);
|
---|
| 1300 | nburst_1=size(XmlData.Time,2);
|
---|
| 1301 | end
|
---|
| 1302 | last_i_cell=get(handles.last_i,'String');
|
---|
| 1303 | if isempty(nbfield_1)
|
---|
| 1304 | last_i_cell{2}='';
|
---|
| 1305 | else
|
---|
| 1306 | last_i_cell{2}=num2str(nbfield_1);
|
---|
| 1307 | end
|
---|
| 1308 | set(handles.last_i,'String',last_i_cell)
|
---|
| 1309 | last_j_cell=get(handles.last_j,'String');
|
---|
| 1310 | if isempty(nburst_1)
|
---|
| 1311 | last_j_cell{2}='';
|
---|
| 1312 | else
|
---|
| 1313 | last_j_cell{2}=num2str(nburst_1);
|
---|
| 1314 | end
|
---|
| 1315 | set(handles.last_j,'String',last_j_cell);
|
---|
| 1316 | if ~isequal(last_i_cell{1},last_i_cell{2}) || ~isequal(last_j_cell{1},last_j_cell{2})
|
---|
[38] | 1317 | msgbox_uvmat('WARNING','the numbers of input file of the second series differs from the first one')
|
---|
[2] | 1318 | end
|
---|
| 1319 |
|
---|
| 1320 | % store calibration data
|
---|
| 1321 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 1322 | if isempty(GeometryCalib)
|
---|
| 1323 | if isfield(UvData, 'GeometryCalib_1')
|
---|
| 1324 | UvData=rmfield(UvData,'GeometryCalib_1');
|
---|
| 1325 | end
|
---|
| 1326 | else
|
---|
| 1327 | UvData.GeometryCalib_1=GeometryCalib;
|
---|
| 1328 | if (isfield(GeometryCalib,'R')& ~isequal(GeometryCalib.R(2,1),0) & ~isequal(GeometryCalib.R(1,2),0)) |...
|
---|
| 1329 | (isfield(GeometryCalib,'kappa1')& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 1330 | set(handles.pxcm,'String','var')
|
---|
| 1331 | set(handles.pycm,'String','var')
|
---|
| 1332 | else
|
---|
| 1333 | pixcmx=GeometryCalib.f*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 1334 | pixcmy=GeometryCalib.f*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
| 1335 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 1336 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 1337 | end
|
---|
| 1338 | end
|
---|
| 1339 | UvData.XmlData_1=XmlData;
|
---|
[61] | 1340 | set(handles.uvmat,'UserData',UvData)%update the data attached to the uvmat interface
|
---|
[2] | 1341 |
|
---|
| 1342 | if ~isequal(warntext,'')
|
---|
[38] | 1343 | msgbox_uvmat('WARNING',warntext)
|
---|
[2] | 1344 | end
|
---|
| 1345 |
|
---|
| 1346 | set(handles.RootPath_1,'BackgroundColor',[1 1 1])% signa the end the input operation
|
---|
| 1347 | drawnow
|
---|
| 1348 |
|
---|
| 1349 | set_scan_options(hObject, eventdata, handles)
|
---|
| 1350 |
|
---|
| 1351 | %---------------------------------------------------
|
---|
| 1352 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1353 | function scan_i_Callback(hObject, eventdata, handles)
|
---|
| 1354 | %---------------------------------------------------
|
---|
| 1355 | if get(handles.scan_i,'Value')==1
|
---|
| 1356 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1357 | set(handles.scan_j,'Value',0)
|
---|
[81] | 1358 | % set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
[2] | 1359 | else
|
---|
| 1360 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1361 | set(handles.scan_j,'Value',1)
|
---|
[81] | 1362 | % set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
[2] | 1363 | end
|
---|
[81] | 1364 | scan_j_Callback(hObject, eventdata, handles)
|
---|
[45] | 1365 |
|
---|
[2] | 1366 | %-------------------------------------------------------------------
|
---|
| 1367 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1368 | function scan_j_Callback(hObject, eventdata, handles)
|
---|
| 1369 | %-------------------------------------------------------------------
|
---|
| 1370 | if get(handles.scan_j,'Value')==1
|
---|
| 1371 | set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1372 | set(handles.scan_i,'Value',0)
|
---|
| 1373 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
[81] | 1374 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1375 | switch NomType
|
---|
| 1376 | case {'_i_j1-j2','#_ab','%3dab'},% pair with j index
|
---|
| 1377 | set(handles.fix_pair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off')
|
---|
| 1378 | otherwise
|
---|
| 1379 | set(handles.fix_pair,'Visible','off')
|
---|
| 1380 | end
|
---|
[2] | 1381 | else
|
---|
| 1382 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1383 | set(handles.scan_i,'Value',1)
|
---|
| 1384 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
[81] | 1385 | set(handles.fix_pair,'Visible','off')
|
---|
[2] | 1386 | end
|
---|
| 1387 |
|
---|
| 1388 | %-------------------------------------------------------------------
|
---|
| 1389 | function i1_Callback(hObject, eventdata, handles)
|
---|
| 1390 | %-------------------------------------------------------------------
|
---|
[139] | 1391 | set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[2] | 1392 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1393 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1394 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1395 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1396 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1397 | indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1398 | set(handles.FileIndex,'String',indices)
|
---|
[139] | 1399 | set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[2] | 1400 | if get(handles.SubField,'Value')==1
|
---|
| 1401 | NomType_1=get(handles.FileIndex_1,'String');
|
---|
| 1402 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 1403 | [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);
|
---|
| 1404 | indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
|
---|
| 1405 | set(handles.FileIndex_1,'String',indices)
|
---|
[139] | 1406 | set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[2] | 1407 | end
|
---|
[139] | 1408 | %Run0_Callback(hObject, eventdata, handles)
|
---|
[2] | 1409 |
|
---|
| 1410 | %-------------------------------------------------------------------
|
---|
| 1411 | function i2_Callback(hObject, eventdata, handles)
|
---|
[139] | 1412 | set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[2] | 1413 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1414 | %-------------------------------------------------------------------
|
---|
| 1415 |
|
---|
| 1416 | %-------------------------------------------------------------------
|
---|
| 1417 | function j1_Callback(hObject, eventdata, handles)
|
---|
[139] | 1418 | set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[2] | 1419 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1420 | %-------------------------------------------------------------------
|
---|
| 1421 |
|
---|
| 1422 | %-------------------------------------------------------------------
|
---|
| 1423 | function j2_Callback(hObject, eventdata, handles)
|
---|
[139] | 1424 | set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[2] | 1425 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1426 | %-------------------------------------------------------------------
|
---|
| 1427 |
|
---|
| 1428 | %-------------------------------------------------------------------
|
---|
| 1429 | function slices_Callback(hObject, eventdata, handles)
|
---|
| 1430 | %-------------------------------------------------------------------
|
---|
| 1431 | if get(handles.slices,'Value')==1
|
---|
| 1432 | set(handles.slices,'BackgroundColor',[1 1 0])
|
---|
| 1433 | set(handles.nb_slice,'Visible','on')
|
---|
| 1434 | set(handles.z_text,'Visible','on')
|
---|
| 1435 | set(handles.z_index,'Visible','on')
|
---|
| 1436 | nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1437 | else
|
---|
| 1438 | set(handles.nb_slice,'Visible','off')
|
---|
| 1439 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1440 | set(handles.z_text,'Visible','off')
|
---|
| 1441 | set(handles.z_index,'Visible','off')
|
---|
| 1442 | set(handles.masklevel,'Value',1)
|
---|
| 1443 | set(handles.masklevel,'String',{'1'})
|
---|
| 1444 | end
|
---|
| 1445 |
|
---|
| 1446 | %-------------------------------------------------------------------
|
---|
| 1447 | function nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1448 | %-------------------------------------------------------------------
|
---|
[71] | 1449 | nb_slice_str=get(handles.nb_slice,'String');
|
---|
[60] | 1450 | if isequal(nb_slice_str,'volume')
|
---|
| 1451 | num=stra2num(get(handles.j1,'String'));
|
---|
| 1452 | last_j=get(handles.last_j,'String');
|
---|
| 1453 | nbslice=str2double(last_j{1});
|
---|
| 1454 | else
|
---|
| 1455 | num=str2double(get(handles.i1,'String'));
|
---|
| 1456 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1457 | end
|
---|
| 1458 | z=mod(num-1,nbslice)+1;
|
---|
[2] | 1459 | set(handles.z_index,'String',num2str(z))
|
---|
| 1460 | for ilist=1:nbslice
|
---|
| 1461 | list_index{ilist,1}=num2str(ilist);
|
---|
| 1462 | end
|
---|
| 1463 | set(handles.masklevel,'String',list_index)
|
---|
| 1464 | set(handles.masklevel,'Value',z)
|
---|
| 1465 |
|
---|
| 1466 | %-------------------------------------------------------------------
|
---|
| 1467 | % --- Executes on button press in view_xml.
|
---|
| 1468 | function view_xml_Callback(hObject, eventdata, handles)
|
---|
| 1469 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
| 1470 | option=get(handles.view_xml,'String');
|
---|
| 1471 | if isequal(option,'view .xml')
|
---|
| 1472 | FileXml=[FileBase '.xml'];
|
---|
| 1473 | heditxml=editxml(FileXml);
|
---|
| 1474 | end
|
---|
| 1475 |
|
---|
| 1476 | %-------------------------------------------------------------------
|
---|
| 1477 | % --- Executes on button press in mask_test.
|
---|
| 1478 | function mask_test_Callback(hObject, eventdata, handles)
|
---|
| 1479 | %-------------------------------------------------------------------
|
---|
[139] | 1480 | %case of view mask selection
|
---|
[2] | 1481 | if isequal(get(handles.mask_test,'Value'),1)
|
---|
| 1482 | [FF,RootPath,FileBase]=read_file_boxes(handles);
|
---|
| 1483 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1484 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1485 | currentdir=pwd;
|
---|
| 1486 | cd(RootPath);
|
---|
| 1487 | maskfiles=dir('*_*mask_*.png');%look for a mask file
|
---|
| 1488 | cd(currentdir);%come back to the working directory
|
---|
| 1489 | mdetect=0;
|
---|
[139] | 1490 | if ~isempty(maskfiles)
|
---|
| 1491 | for ilist=1:length(maskfiles)
|
---|
| 1492 | maskname=maskfiles(ilist).name;% take the first mask file in the list
|
---|
| 1493 | [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
|
---|
| 1494 | if ~strcmp(Mask_NomType{ilist},Mask_NomType{1})
|
---|
| 1495 | msgbox_uvmat('ERROR',['inconsistent mask types ' Mask_NomType{1} Mask_NomType{ilist } ' coexist in the current image directory'])
|
---|
| 1496 | return
|
---|
| 1497 | end
|
---|
| 1498 | [Path2,Name,ext]=fileparts(maskname);
|
---|
| 1499 | Namedouble=double(Name);
|
---|
| 1500 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
|
---|
| 1501 | ind_mask=findstr('mask',Name);
|
---|
| 1502 | i=ind_mask-1;
|
---|
| 1503 | while val(i)==0 && i>0
|
---|
| 1504 | i=i-1;
|
---|
| 1505 | end
|
---|
| 1506 | nbmask_str=str2num(Name(i+1:ind_mask-1));
|
---|
| 1507 | if ~isempty(nbmask_str)
|
---|
| 1508 | nbslice(ilist)=nbmask_str; % number of different masks (slices)
|
---|
| 1509 | end
|
---|
| 1510 | end
|
---|
| 1511 | if isequal(min(nbslice),max(nbslice))
|
---|
| 1512 | nbslice=nbslice(1);
|
---|
| 1513 | else
|
---|
| 1514 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory')
|
---|
[2] | 1515 | return
|
---|
| 1516 | end
|
---|
[139] | 1517 | if ~isempty(nbslice) && Name(i)=='_'
|
---|
| 1518 | Mask.Base=[FileBase Name(i:ind_mask+3)];
|
---|
| 1519 | Mask.NbSlice=nbslice;
|
---|
| 1520 | num_i1=mod(num_i1-1,nbslice)+1;
|
---|
| 1521 | Mask.NomType=Mask_NomType{1};
|
---|
| 1522 | [maskname,mdetect]=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
|
---|
| 1523 | mdetect=exist(maskname,'file');
|
---|
| 1524 | if mdetect
|
---|
| 1525 | set(handles.nb_slice,'String',Name(i+1:ind_mask-1));
|
---|
| 1526 | set(handles.nb_slice,'BackgroundColor',[1 1 0])
|
---|
| 1527 | set(handles.mask_test,'UserData',Mask);
|
---|
| 1528 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
| 1529 | if nbslice > 1
|
---|
| 1530 | set(handles.slices,'value',1)
|
---|
| 1531 | slices_Callback(hObject, eventdata, handles)
|
---|
| 1532 | end
|
---|
| 1533 | end
|
---|
[2] | 1534 | end
|
---|
[139] | 1535 | % if mdetect==0
|
---|
| 1536 | % msgbox_uvmat('ERROR','no mask file detected (format ..._xxmask_ii.png needed), use the menu bar Tools/Make mask')
|
---|
| 1537 | % set(handles.mask_test,'Value',0)
|
---|
| 1538 | % return
|
---|
| 1539 | % end
|
---|
| 1540 | end
|
---|
| 1541 | errormsg=[];%default
|
---|
| 1542 | if mdetect==0
|
---|
| 1543 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 1544 | {'*.png', ' (*.png)';
|
---|
| 1545 | '*.png', '.png files '; ...
|
---|
| 1546 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 1547 | 'Pick a mask file *.png',FileBase);
|
---|
| 1548 | maskname=fullfile(PathName,FileName);
|
---|
| 1549 | if ~exist(maskname,'file')
|
---|
| 1550 | errormsg='no file browsed';
|
---|
[2] | 1551 | end
|
---|
[139] | 1552 | [RootDir,RootFile,x1,x2,xa,xb,xext,Mask.NomType]=name2display(maskname);
|
---|
| 1553 | Mask.Base=fullfile(RootDir,RootFile);
|
---|
| 1554 | Mask.NbSlice=1;
|
---|
| 1555 | set(handles.mask_test,'UserData',Mask);
|
---|
| 1556 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
[2] | 1557 | end
|
---|
[139] | 1558 | if isempty(errormsg)
|
---|
| 1559 | errormsg=update_mask(handles,num_i1,num_j1);
|
---|
[2] | 1560 | end
|
---|
[139] | 1561 | if ~isempty(errormsg)
|
---|
| 1562 | set(handles.mask_test,'Value',0)
|
---|
| 1563 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1564 | end
|
---|
| 1565 | else
|
---|
[2] | 1566 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1567 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 1568 | delete(MaskData.maskhandle)
|
---|
| 1569 | end
|
---|
| 1570 | set(handles.mask_test,'UserData',[])
|
---|
[61] | 1571 | %huvmat=get(handles.mask_test,'parent');
|
---|
| 1572 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1573 | if isfield(UvData,'MaskName')
|
---|
| 1574 | UvData=rmfield(UvData,'MaskName');
|
---|
[61] | 1575 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 1576 | end
|
---|
| 1577 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1578 | end
|
---|
| 1579 |
|
---|
| 1580 | %-------------------------------------------------------------------
|
---|
[139] | 1581 | function errormsg=update_mask(handles,num_i1,num_j1)
|
---|
[2] | 1582 | %-------------------------------------------------------------------
|
---|
[139] | 1583 | errormsg=[];%default
|
---|
[2] | 1584 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1585 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1586 | uistack(MaskData.maskhandle,'top');
|
---|
| 1587 | end
|
---|
| 1588 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
[139] | 1589 | MaskData.NomType
|
---|
| 1590 | MaskName=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
[2] | 1591 | huvmat=get(handles.mask_test,'parent');
|
---|
| 1592 | UvData=get(huvmat,'UserData');
|
---|
| 1593 |
|
---|
| 1594 | %update mask image if the mask is new
|
---|
| 1595 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
| 1596 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
| 1597 | set(huvmat,'UserData',UvData);
|
---|
[139] | 1598 | if ~exist(MaskName,'file')
|
---|
[2] | 1599 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1600 | delete(MaskData.maskhandle)
|
---|
| 1601 | end
|
---|
| 1602 | else
|
---|
| 1603 | %read mask image
|
---|
| 1604 | Mask.AName='image';
|
---|
| 1605 | Mask.A=imread(MaskName);
|
---|
| 1606 | npxy=size(Mask.A);
|
---|
[139] | 1607 | test_error=0;
|
---|
| 1608 | if length(npxy)>2
|
---|
| 1609 | errormsg=[MaskName ' is not a grey scale image'];
|
---|
| 1610 | return
|
---|
| 1611 | elseif ~isa(Mask.A,'uint8')
|
---|
| 1612 | errormsg=[MaskName ' is not a 8 bit grey level image'];
|
---|
| 1613 | return
|
---|
| 1614 | end
|
---|
[2] | 1615 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
| 1616 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
| 1617 | Mask.CoordType='px';
|
---|
| 1618 | if isequal(get(handles.slices,'Value'),1)
|
---|
| 1619 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
| 1620 | num_i1=str2num(get(handles.i1,'String'));
|
---|
| 1621 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
| 1622 | end
|
---|
| 1623 | %px to phys or other transform on field
|
---|
[39] | 1624 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1625 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1626 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1627 | transform_list=get(handles.transform_fct,'UserData');
|
---|
[38] | 1628 | transform=transform_list{choice_value};
|
---|
| 1629 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
[2] | 1630 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 1631 | Calib=UvData.XmlData.GeometryCalib;
|
---|
[38] | 1632 | Mask=transform(Mask,UvData.XmlData);
|
---|
[2] | 1633 | end
|
---|
| 1634 | end
|
---|
| 1635 | flagmask=Mask.A < 200;
|
---|
| 1636 |
|
---|
| 1637 | %make brown color image
|
---|
| 1638 | imflag(:,:,1)=0.9*flagmask;
|
---|
| 1639 | imflag(:,:,2)=0.7*flagmask;
|
---|
| 1640 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
| 1641 |
|
---|
| 1642 | %update mask image
|
---|
| 1643 | hmask=[]; %default
|
---|
| 1644 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1645 | hmask=MaskData.maskhandle;
|
---|
| 1646 | end
|
---|
| 1647 | if ~isempty(hmask)
|
---|
| 1648 | set(hmask,'CData',imflag)
|
---|
| 1649 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
| 1650 | set(hmask,'XData',Mask.AX);
|
---|
| 1651 | set(hmask,'YData',Mask.AY);
|
---|
| 1652 | % uistack(hmask,'top')
|
---|
| 1653 | else
|
---|
| 1654 | axes(handles.axes3)
|
---|
| 1655 | hold on
|
---|
| 1656 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
| 1657 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
| 1658 | set(handles.mask_test,'UserData',MaskData)
|
---|
| 1659 | end
|
---|
| 1660 | end
|
---|
| 1661 | end
|
---|
| 1662 |
|
---|
| 1663 |
|
---|
| 1664 | %-------------------------------------------------------------------
|
---|
| 1665 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
| 1666 | %-------------------------------------------------------------------
|
---|
| 1667 | huvmat=get(handles.MenuExport,'parent');
|
---|
[128] | 1668 | %UvData=get(huvmat,'UserData');
|
---|
[2] | 1669 | hfig=figure;
|
---|
[128] | 1670 | copyobj(handles.axes3,hfig);
|
---|
[2] | 1671 | map=colormap(handles.axes3);
|
---|
| 1672 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 1673 | colorbar
|
---|
| 1674 |
|
---|
| 1675 | %-------------------------------------------------------------------
|
---|
| 1676 | %-------------------------------------------------------------------
|
---|
| 1677 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
| 1678 | %-------------------------------------------------------------------
|
---|
| 1679 |
|
---|
| 1680 | %-------------------------------------------------------------------
|
---|
[85] | 1681 | % --- Executes on button press in runplus: make one step forward and call
|
---|
| 1682 | % --- run0. The step forward is along the fields series 1 or 2 depending on
|
---|
| 1683 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
[2] | 1684 | function runplus_Callback(hObject, eventdata, handles)
|
---|
[85] | 1685 | %-------------------------------------------------------------------
|
---|
| 1686 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1687 | drawnow
|
---|
[128] | 1688 | %TODO: introduce the option: increment ='*' to move to the next available view
|
---|
| 1689 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1690 | if isnan(increment)
|
---|
| 1691 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1692 | increment=1;
|
---|
| 1693 | end
|
---|
| 1694 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1695 | if ~isempty(errormsg)
|
---|
| 1696 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1697 | end
|
---|
| 1698 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
[2] | 1699 |
|
---|
| 1700 | %-------------------------------------------------------------------
|
---|
[85] | 1701 | % --- Executes on button press in runmin: make one step backward and call
|
---|
| 1702 | % --- run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 1703 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
| 1704 | function runmin_Callback(hObject, eventdata, handles)
|
---|
[2] | 1705 | %-------------------------------------------------------------------
|
---|
[85] | 1706 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1707 | drawnow
|
---|
[128] | 1708 | increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1709 | if isnan(increment)
|
---|
| 1710 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1711 | increment=1;
|
---|
| 1712 | end
|
---|
| 1713 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1714 | if ~isempty(errormsg)
|
---|
| 1715 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1716 | end
|
---|
| 1717 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
[2] | 1718 |
|
---|
| 1719 | %-------------------------------------------------------------------
|
---|
[81] | 1720 | % -- Executes on button press in Movie: make a series of +> steps
|
---|
| 1721 | function Movie_Callback(hObject, eventdata, handles)
|
---|
[2] | 1722 | %------------------------------------------------------------------
|
---|
[81] | 1723 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
[2] | 1724 | drawnow
|
---|
[128] | 1725 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1726 | if isnan(increment)
|
---|
| 1727 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1728 | increment=1;
|
---|
| 1729 | end
|
---|
[2] | 1730 | set(handles.STOP,'Visible','on')
|
---|
| 1731 | set(handles.speed,'Visible','on')
|
---|
| 1732 | set(handles.speed_txt,'Visible','on')
|
---|
[81] | 1733 | set(handles.Movie,'BusyAction','queue')
|
---|
[57] | 1734 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1735 |
|
---|
[122] | 1736 | while get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
|
---|
[72] | 1737 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1738 | if ~isempty(errormsg)
|
---|
[128] | 1739 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
[72] | 1740 | return
|
---|
| 1741 | end
|
---|
[2] | 1742 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1743 | end
|
---|
| 1744 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1745 | UvData.aviobj=close(UvData.aviobj);
|
---|
[57] | 1746 | set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 1747 | end
|
---|
[81] | 1748 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
[2] | 1749 |
|
---|
| 1750 | %-------------------------------------------------------------------
|
---|
[81] | 1751 | % -- Executes on button press in Movie: make a series of <- steps
|
---|
| 1752 | function MovieBackward_Callback(hObject, eventdata, handles)
|
---|
| 1753 | %------------------------------------------------------------------
|
---|
| 1754 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1755 | drawnow
|
---|
[128] | 1756 | increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1757 | if isnan(increment)
|
---|
| 1758 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1759 | increment=1;
|
---|
| 1760 | end
|
---|
[81] | 1761 | set(handles.STOP,'Visible','on')
|
---|
| 1762 | set(handles.speed,'Visible','on')
|
---|
| 1763 | set(handles.speed_txt,'Visible','on')
|
---|
| 1764 | set(handles.MovieBackward,'BusyAction','queue')
|
---|
| 1765 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1766 |
|
---|
[128] | 1767 | while get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
|
---|
[81] | 1768 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1769 | if ~isempty(errormsg)
|
---|
[128] | 1770 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
[81] | 1771 | return
|
---|
| 1772 | end
|
---|
| 1773 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1774 | end
|
---|
| 1775 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1776 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 1777 | set(handles.uvmat,'UserData',UvData);
|
---|
| 1778 | end
|
---|
| 1779 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1780 |
|
---|
| 1781 | %-------------------------------------------------------------------
|
---|
[2] | 1782 | function STOP_Callback(hObject, eventdata, handles)
|
---|
| 1783 | %-------------------------------------------------------------------
|
---|
[57] | 1784 | set(handles.movie_pair,'BusyAction','Cancel')
|
---|
| 1785 | set(handles.movie_pair,'value',0)
|
---|
[81] | 1786 | set(handles.Movie,'BusyAction','Cancel')
|
---|
| 1787 | set(handles.MovieBackward,'BusyAction','Cancel')
|
---|
[2] | 1788 | set(handles.MenuExportMovie,'BusyAction','Cancel')
|
---|
[85] | 1789 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1790 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1791 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
[2] | 1792 |
|
---|
| 1793 | %------------------------------------------------------------------
|
---|
[72] | 1794 | function errormsg=runpm(hObject,eventdata,handles,increment)
|
---|
[2] | 1795 | %------------------------------------------------------------------
|
---|
[120] | 1796 | %check for mï¿œovie pair status
|
---|
[57] | 1797 | movie_status=get(handles.movie_pair,'Value');
|
---|
| 1798 | if isequal(movie_status,1)
|
---|
[59] | 1799 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
|
---|
[57] | 1800 | end
|
---|
[2] | 1801 | %read the data on the current input rootfile(s)
|
---|
| 1802 |
|
---|
| 1803 | [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
|
---|
| 1804 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1805 |
|
---|
| 1806 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1807 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1808 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1809 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1810 |
|
---|
| 1811 | sub_value= get(handles.SubField,'Value');
|
---|
[59] | 1812 | if sub_value % a second input file has been entered
|
---|
[2] | 1813 | [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
[59] | 1814 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices_1);
|
---|
| 1815 | num1_1=stra2num(str1);%current set of indices for the second field (may be set different than the main indices)
|
---|
| 1816 | num2_1=stra2num(str2);
|
---|
| 1817 | num_a_1=stra2num(str_a);
|
---|
| 1818 | num_b_1=stra2num(str_b);
|
---|
| 1819 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 1820 | else
|
---|
| 1821 | filename_1=[];
|
---|
[2] | 1822 | end
|
---|
| 1823 |
|
---|
| 1824 | comp_input=get(handles.fix_pair,'Value');
|
---|
| 1825 |
|
---|
| 1826 | %case of scanning along the first direction (rootfile numbers)
|
---|
[59] | 1827 | if get(handles.scan_i,'Value')==1% case of scanning along index i
|
---|
[2] | 1828 | num1=num1+increment;
|
---|
| 1829 | num2=num2+increment;
|
---|
[128] | 1830 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
[59] | 1831 | if sub_value% set the second field name and indices
|
---|
| 1832 | num1_1=num1_1+increment;
|
---|
| 1833 | num2_1=num2_1+increment;
|
---|
| 1834 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
| 1835 | end
|
---|
| 1836 | else % case of scanning along index j (burst numbers)
|
---|
[2] | 1837 | num_a=num_a+increment;
|
---|
| 1838 | num_b=num_b+increment;
|
---|
[127] | 1839 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
[59] | 1840 | if sub_value
|
---|
| 1841 | num_a_1=num_a_1+increment;
|
---|
| 1842 | num_b_1=num_b_1+increment;
|
---|
| 1843 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
[127] | 1844 | end
|
---|
[2] | 1845 | end
|
---|
| 1846 |
|
---|
[59] | 1847 | % refresh plots
|
---|
| 1848 | errormsg=refresh_field(handles,filename,filename_1,num1,num2,num_a,num_b);
|
---|
| 1849 | if isempty(errormsg) %update the index counters
|
---|
| 1850 | set(handles.i1,'String',num2stra(num1,NomType,1));
|
---|
| 1851 | if isequal(num2,num1)
|
---|
| 1852 | set(handles.i2,'String','');
|
---|
| 1853 | else
|
---|
| 1854 | set(handles.i2,'String',num2stra(num2,NomType,1));
|
---|
| 1855 | end
|
---|
| 1856 | set(handles.j1,'String',num2stra(num_a,NomType,2));
|
---|
| 1857 | if isequal(num_b,num_a)
|
---|
| 1858 | set(handles.j2,'String','');
|
---|
| 1859 | else
|
---|
| 1860 | set(handles.j2,'String',num2stra(num_b,NomType,2));
|
---|
| 1861 | end
|
---|
| 1862 | [indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1863 | set(handles.FileIndex,'String',indices);
|
---|
[81] | 1864 | if ~isempty(filename_1)
|
---|
[59] | 1865 | indices_1=name_generator('',num1_1,num_a_1,'',NomType_1,1,num2_1,num_b_1,'');
|
---|
| 1866 | set(handles.FileIndex_1,'String',indices_1);
|
---|
| 1867 | end
|
---|
| 1868 | if isequal(movie_status,1)
|
---|
| 1869 | set(handles.movie_pair,'Value',1)
|
---|
| 1870 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
|
---|
| 1871 | end
|
---|
[57] | 1872 | end
|
---|
[2] | 1873 |
|
---|
| 1874 |
|
---|
| 1875 | %-------------------------------------------------------
|
---|
[57] | 1876 | % --- Executes on button press in movie_pair: create an alternating movie with two view
|
---|
[2] | 1877 | %-------------------------------------------------------
|
---|
| 1878 | function movie_pair_Callback(hObject, eventdata, handles)
|
---|
[57] | 1879 | status=get(handles.movie_pair,'value');
|
---|
| 1880 | if isequal(status,0)
|
---|
[59] | 1881 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
|
---|
| 1882 | set(handles.i2,'String','')
|
---|
| 1883 | set(handles.j2,'String','')
|
---|
[57] | 1884 | return
|
---|
| 1885 | else
|
---|
| 1886 | set(handles.movie_pair,'BusyAction','queue')
|
---|
| 1887 | end
|
---|
[2] | 1888 | %initialisation
|
---|
| 1889 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1890 | drawnow
|
---|
| 1891 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 1892 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 1893 | FieldName=list_fields{index_fields}; % selected field
|
---|
[65] | 1894 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1895 | if isequal(FieldName,'image')
|
---|
[65] | 1896 | test_1=0;
|
---|
| 1897 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
|
---|
| 1898 | NomType=get(handles.FileIndex,'UserData');
|
---|
[2] | 1899 | else
|
---|
[65] | 1900 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 1901 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 1902 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 1903 | if isequal(FieldName,'image')
|
---|
| 1904 | test_1=1;
|
---|
| 1905 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes_1(handles);
|
---|
| 1906 | NomType=get(handles.FileIndex_1,'UserData');
|
---|
| 1907 | else
|
---|
| 1908 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
|
---|
[85] | 1909 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
[65] | 1910 | return
|
---|
| 1911 | end
|
---|
[2] | 1912 | end
|
---|
[65] | 1913 |
|
---|
[89] | 1914 | num_i1=str2double(get(handles.i1,'String'));
|
---|
[57] | 1915 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
[89] | 1916 | num_i2=str2double(get(handles.i2,'String'));
|
---|
[57] | 1917 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
[89] | 1918 | if isnan(num_j2)
|
---|
[57] | 1919 | if isempty(num_i2)
|
---|
| 1920 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
|
---|
[85] | 1921 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
[2] | 1922 | return
|
---|
[57] | 1923 | else
|
---|
| 1924 | num_j2=num_j1;%repeat the index i1 by default
|
---|
[2] | 1925 | end
|
---|
[57] | 1926 | end
|
---|
[89] | 1927 | if isnan(num_i2)
|
---|
[57] | 1928 | num_i2=num_i1;%repeat the index i1 by default
|
---|
| 1929 | end
|
---|
| 1930 | imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
|
---|
| 1931 | if ~exist(imaname_1,'file')
|
---|
| 1932 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']);
|
---|
[85] | 1933 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
[57] | 1934 | return
|
---|
| 1935 | end
|
---|
[2] | 1936 |
|
---|
| 1937 | %read the second image
|
---|
| 1938 | Field.AName='image';
|
---|
[65] | 1939 | if test_1
|
---|
| 1940 | Field_a=UvData.Field_1;
|
---|
| 1941 | else
|
---|
| 1942 | Field_a=UvData.Field;
|
---|
| 1943 | end
|
---|
| 1944 | Field_b.AX=Field_a.AX;
|
---|
| 1945 | Field_b.AY=Field_a.AY;
|
---|
[57] | 1946 | % z index
|
---|
| 1947 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1948 | if ~isempty(nbslice)
|
---|
[65] | 1949 | Field_b.ZIndex=mod(num_i2-1,nbslice)+1;
|
---|
[57] | 1950 | end
|
---|
[65] | 1951 | Field_b.CoordType='px';
|
---|
[45] | 1952 | %determine the input file type
|
---|
[65] | 1953 | if (test_1 && isfield(UvData,'MovieObject_1'))||(~test_1 && isfield(UvData,'MovieObject'))
|
---|
[45] | 1954 | FileType='movie';
|
---|
| 1955 | elseif isequal(lower(Ext),'.avi')
|
---|
| 1956 | FileType='avi';
|
---|
| 1957 | elseif isequal(lower(Ext),'.vol')
|
---|
| 1958 | FileType='vol';
|
---|
| 1959 | else
|
---|
[122] | 1960 | form=imformats(Ext(2:end));
|
---|
[45] | 1961 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 1962 | if isequal(NomType,'*');
|
---|
| 1963 | FileType='multimage';
|
---|
| 1964 | else
|
---|
| 1965 | FileType='image';
|
---|
| 1966 | end
|
---|
| 1967 | end
|
---|
| 1968 | end
|
---|
| 1969 | switch FileType
|
---|
| 1970 | case 'movie'
|
---|
[65] | 1971 | if test_1
|
---|
| 1972 | Field_b.A=read(UvData.MovieObject_1,num_i2);
|
---|
| 1973 | else
|
---|
| 1974 | Field_b.A=read(UvData.MovieObject,num_i2);
|
---|
| 1975 | end
|
---|
[45] | 1976 | case 'avi'
|
---|
| 1977 | mov=aviread(imaname_1,num_i2);
|
---|
[65] | 1978 | Field_b.A=frame2im(mov(1));
|
---|
[45] | 1979 | case 'vol'
|
---|
[65] | 1980 | Field_b.A=imread(imaname_1);
|
---|
[45] | 1981 | case 'multimage'
|
---|
[65] | 1982 | Field_b.A=imread(imaname_1,num_i2);
|
---|
[45] | 1983 | case 'image'
|
---|
[65] | 1984 | Field_b.A=imread(imaname_1);
|
---|
[45] | 1985 | end
|
---|
[60] | 1986 | if get(handles.slices,'Value')
|
---|
| 1987 | Field.ZIndex=str2double(get(handles.z_index,'String'));
|
---|
| 1988 | end
|
---|
[2] | 1989 |
|
---|
| 1990 | %px to phys or other transform on field
|
---|
[39] | 1991 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1992 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1993 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1994 | transform_list=get(handles.transform_fct,'UserData');
|
---|
[38] | 1995 | transform=transform_list{choice_value};
|
---|
| 1996 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
[65] | 1997 | if test_1 && isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
[67] | 1998 | Field_a=transform(Field_a,UvData.XmlData_1);%the first field has been stored without transform
|
---|
[65] | 1999 | Field_b=transform(Field_b,UvData.XmlData_1);
|
---|
| 2000 | elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib
|
---|
| 2001 | Field_b=transform(Field_b,UvData.XmlData);
|
---|
[2] | 2002 | end
|
---|
| 2003 | end
|
---|
| 2004 |
|
---|
| 2005 | % make movie until movie speed is set to 0 or STOP is activated
|
---|
| 2006 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
|
---|
| 2007 | set(handles.STOP,'Visible','on')
|
---|
| 2008 | set(handles.speed,'Visible','on')
|
---|
| 2009 | set(handles.speed_txt,'Visible','on')
|
---|
[57] | 2010 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
|
---|
[2] | 2011 | % read and plot the series of images in non erase mode
|
---|
[65] | 2012 | set(hima,'CData',Field_b.A);
|
---|
[2] | 2013 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
[65] | 2014 | set(hima,'CData',Field_a.A);
|
---|
[2] | 2015 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 2016 | end
|
---|
| 2017 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 2018 |
|
---|
[59] | 2019 | %------------------------------------------------------------------------
|
---|
[2] | 2020 | % --- Executes on button press in run0.
|
---|
| 2021 | function run0_Callback(hObject, eventdata, handles)
|
---|
[59] | 2022 | %------------------------------------------------------------------------
|
---|
[85] | 2023 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 2024 | drawnow
|
---|
[59] | 2025 | filename=read_file_boxes(handles);
|
---|
[2] | 2026 |
|
---|
[59] | 2027 | filename_1=[];%default
|
---|
| 2028 | if get(handles.SubField,'Value')
|
---|
| 2029 | filename_1=read_file_boxes_1(handles);
|
---|
| 2030 | end
|
---|
| 2031 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 2032 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 2033 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 2034 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 2035 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
|
---|
| 2036 | if ~isempty(errormsg)
|
---|
| 2037 | msgbox_uvmat('ERROR',errormsg);
|
---|
[139] | 2038 | else
|
---|
| 2039 | set(handles.i1,'BackgroundColor',[1 1 1])
|
---|
| 2040 | set(handles.i2,'BackgroundColor',[1 1 1])
|
---|
| 2041 | set(handles.j1,'BackgroundColor',[1 1 1])
|
---|
| 2042 | set(handles.j2,'BackgroundColor',[1 1 1])
|
---|
| 2043 | set(handles.FileIndex,'BackgroundColor',[1 1 1])
|
---|
| 2044 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
|
---|
[59] | 2045 | end
|
---|
[85] | 2046 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
[128] | 2047 |
|
---|
[139] | 2048 |
|
---|
[59] | 2049 | %------------------------------------------------------------------------
|
---|
| 2050 | % --- read the input files and refresh all the plots, including projection.
|
---|
| 2051 | % OUTPUT:
|
---|
| 2052 | % errormsg: error message char string =[] by default
|
---|
| 2053 | % INPUT:
|
---|
| 2054 | % filename: first input file (=[] in the absence of input file)
|
---|
| 2055 | % filename_1: second input file (=[] in the asbsenc of secodn input file)
|
---|
| 2056 | % num_i1,num_i2,num_j1,num_j2; frame indices
|
---|
| 2057 | % Field: structure describing an optional input field (then replace the input file)
|
---|
| 2058 | function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
|
---|
| 2059 | %------------------------------------------------------------------------
|
---|
[81] | 2060 |
|
---|
[2] | 2061 | %initialisation
|
---|
[128] | 2062 | % errormsg=[]; % default error message
|
---|
[2] | 2063 | abstime=[];
|
---|
| 2064 | abstime_1=[];
|
---|
| 2065 | dt=[];
|
---|
[59] | 2066 | if ~exist('Field','var')
|
---|
| 2067 | Field={};
|
---|
| 2068 | end
|
---|
[45] | 2069 | UvData=get(handles.uvmat,'UserData');
|
---|
[75] | 2070 | %UvData =structure containing information stored outside the uicontrol of uvmat
|
---|
| 2071 | % .NewSeries: =1 for a new series (new root fiel introduced), 0 else
|
---|
| 2072 | % .MovieObject: movie object representing an input movie
|
---|
| 2073 | % .MovieObject_1: idem for a second input series (_1)
|
---|
| 2074 | % .filename_1 : last second input file name (to deal with a constant second input without reading again the file)
|
---|
| 2075 | % .VelType_1: last velocity type (civ1, civ2...) for the second input series
|
---|
| 2076 | % .FieldName_1: last field name(velocity, vorticity...) for the second input series
|
---|
| 2077 | % .NbDim: number of space dimensions of the input field
|
---|
| 2078 | % .ZMin, .ZMax: range of the z coordinate
|
---|
| 2079 | %..... to complement
|
---|
| 2080 |
|
---|
[2] | 2081 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat
|
---|
| 2082 | delete(handles.UVMAT_title)
|
---|
| 2083 | end
|
---|
| 2084 |
|
---|
[128] | 2085 | %% determine the main input file information for action
|
---|
[45] | 2086 | FileType=[];%default
|
---|
[59] | 2087 | if ~isempty(filename)
|
---|
[2] | 2088 | if ~exist(filename,'file')
|
---|
[59] | 2089 | errormsg=['input file ' filename ' does not exist'];
|
---|
[2] | 2090 | return
|
---|
| 2091 | end
|
---|
[59] | 2092 | Ext=get(handles.FileExt,'String');
|
---|
[2] | 2093 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 2094 | %update the z position index
|
---|
[60] | 2095 | nbslice_str=get(handles.nb_slice,'String');
|
---|
[128] | 2096 | % z_index=1;%default
|
---|
[60] | 2097 | if isequal(nbslice_str,'volume')
|
---|
| 2098 | z_index=num_j1;
|
---|
| 2099 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2100 | else
|
---|
| 2101 | nbslice=str2num(nbslice_str);
|
---|
[2] | 2102 | z_index=mod(num_i1-1,nbslice)+1;
|
---|
| 2103 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2104 | end
|
---|
[60] | 2105 | % refresh menu for save_mask if relevant
|
---|
| 2106 | masknumber=get(handles.masklevel,'String');
|
---|
| 2107 | if length(masknumber)>=z_index
|
---|
| 2108 | set(handles.masklevel,'Value',z_index)
|
---|
| 2109 | end
|
---|
| 2110 |
|
---|
[45] | 2111 | % determine the input file type
|
---|
| 2112 | if isequal(Ext,'.nc')||isequal(Ext,'.cdf')
|
---|
| 2113 | FileType='netcdf';
|
---|
| 2114 | elseif isfield(UvData,'MovieObject')
|
---|
| 2115 | FileType='movie';
|
---|
| 2116 | FieldName='image';
|
---|
| 2117 | elseif isequal(lower(Ext),'.avi')
|
---|
| 2118 | FileType='avi';
|
---|
| 2119 | FieldName='image';
|
---|
| 2120 | elseif isequal(lower(Ext),'.vol')
|
---|
| 2121 | FileType='vol';
|
---|
| 2122 | FieldName='image';
|
---|
[2] | 2123 | else
|
---|
[122] | 2124 | form=imformats(Ext(2:end));
|
---|
[2] | 2125 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
[45] | 2126 | if isequal(NomType,'*');
|
---|
| 2127 | FileType='multimage';
|
---|
| 2128 | else
|
---|
| 2129 | FileType='image';
|
---|
| 2130 | end
|
---|
[2] | 2131 | FieldName='image';
|
---|
| 2132 | end
|
---|
| 2133 | end
|
---|
| 2134 | else
|
---|
[45] | 2135 | FileType='netcdf';
|
---|
[2] | 2136 | FieldName='get_field...';
|
---|
| 2137 | end
|
---|
| 2138 | VelType=[];%default
|
---|
[45] | 2139 | if isequal(FileType,'netcdf')
|
---|
[2] | 2140 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 2141 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 2142 | FieldName= list_fields{index_fields}; % selected field
|
---|
[59] | 2143 | if ~isequal(FieldName,'get_field...')% read the field names on the interface get_field...
|
---|
[2] | 2144 | VelType=setfield(handles);
|
---|
| 2145 | end
|
---|
| 2146 | end
|
---|
[128] | 2147 | %% choose a second field if Subfield option is 'on'
|
---|
[2] | 2148 | FieldName_1=[];
|
---|
| 2149 | scal_color=[];
|
---|
| 2150 | VelType_1=setfield_1(handles);
|
---|
[128] | 2151 | % sub_value=get(handles.SubField,'Value');
|
---|
[45] | 2152 | FileType_1='none';%default
|
---|
[59] | 2153 | if ~isempty(filename_1)
|
---|
| 2154 | % test for a constant second field (comparison with a fixed field)
|
---|
[2] | 2155 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[71] | 2156 | Ext_1=get(handles.FileExt_1,'String');
|
---|
[45] | 2157 | % determine the input file type
|
---|
| 2158 | if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
|
---|
| 2159 | FileType_1='netcdf';
|
---|
| 2160 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 2161 | FileType_1='movie';
|
---|
| 2162 | FieldName_1='image';
|
---|
| 2163 | elseif isequal(lower(Ext_1),'.avi')
|
---|
| 2164 | FileType='avi';
|
---|
| 2165 | FieldName_1='image';
|
---|
| 2166 | elseif isequal(lower(Ext_1),'.vol')
|
---|
| 2167 | FileType_1='vol';
|
---|
| 2168 | FieldName_1='image';
|
---|
| 2169 | else
|
---|
[122] | 2170 | form=imformats(Ext_1(2:end));
|
---|
[45] | 2171 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 2172 | if isequal(NomType_1,'*');
|
---|
| 2173 | FileType_1='multimage';
|
---|
| 2174 | else
|
---|
| 2175 | FileType_1='image';
|
---|
| 2176 | end
|
---|
| 2177 | FieldName_1='image';
|
---|
| 2178 | end
|
---|
| 2179 | end
|
---|
| 2180 | if ~isequal(FieldName_1,'image')
|
---|
| 2181 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 2182 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 2183 | FieldName_1= list_fields{index_fields}; % selected field
|
---|
| 2184 | if isequal(VelType_1,'*')% free veltype choice
|
---|
[2] | 2185 | VelType_1=[];
|
---|
[45] | 2186 | elseif isequal(VelType_1,'"')% veltype the same as for the first field
|
---|
| 2187 | if isempty(VelType)
|
---|
| 2188 | VelType_1=[];
|
---|
| 2189 | else
|
---|
| 2190 | VelType_1=VelType;
|
---|
| 2191 | end
|
---|
[2] | 2192 | end
|
---|
| 2193 | end
|
---|
[59] | 2194 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
|
---|
| 2195 | if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
|
---|
[45] | 2196 | if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
|
---|
| 2197 | test_keepdata_1= isequal(filename_1,UvData.filename_1)&&...
|
---|
| 2198 | isequal(VelType_1,UvData.filename_1) && isequal(FieldName_1,UvData.FieldName_1);
|
---|
[2] | 2199 | end
|
---|
| 2200 | end
|
---|
[59] | 2201 | if test_keepdata_1
|
---|
| 2202 | Field{2}=UvData.Field_1;
|
---|
| 2203 | elseif ~exist(filename_1,'file')
|
---|
| 2204 | errormsg=['second file ' filename_1 ' does not exist'];
|
---|
| 2205 | return
|
---|
| 2206 | end
|
---|
[2] | 2207 | end
|
---|
| 2208 |
|
---|
[128] | 2209 | %% read the input field(s)
|
---|
[2] | 2210 | %read images
|
---|
[45] | 2211 | if ~isempty(filename) && isequal(FieldName,'image')
|
---|
| 2212 | switch FileType
|
---|
| 2213 | case 'movie'
|
---|
[84] | 2214 | try
|
---|
| 2215 | A=read(UvData.MovieObject,num_i1);
|
---|
| 2216 | catch
|
---|
| 2217 | errormsg=lasterr;
|
---|
| 2218 | return
|
---|
| 2219 | end
|
---|
[45] | 2220 | case 'avi'
|
---|
[84] | 2221 | try
|
---|
| 2222 | mov=aviread(filename,num_i1);
|
---|
| 2223 | catch
|
---|
| 2224 | errormsg=lasterr;
|
---|
| 2225 | return
|
---|
| 2226 | end
|
---|
[45] | 2227 | A=frame2im(mov(1));
|
---|
| 2228 | case 'vol'
|
---|
| 2229 | A=imread(filename);
|
---|
| 2230 | case 'multimage'
|
---|
| 2231 | A=imread(filename,num_i1);
|
---|
| 2232 | case 'image'
|
---|
| 2233 | A=imread(filename);
|
---|
[2] | 2234 | end
|
---|
| 2235 | npxy=size(A);
|
---|
| 2236 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
| 2237 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
| 2238 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 2239 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
| 2240 | Field{1}.AName='image';
|
---|
| 2241 | Field{1}.ListVarName={'AY','AX','A'}; %
|
---|
| 2242 | if size(A,3)==3;%color
|
---|
| 2243 | Field{1}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
| 2244 | else
|
---|
| 2245 | Field{1}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
| 2246 | end
|
---|
| 2247 | Field{1}.AY=Rangy;
|
---|
| 2248 | Field{1}.AX=Rangx;
|
---|
| 2249 | Field{1}.A=A;
|
---|
| 2250 | Field{1}.CoordType='px'; %used for mouse_motion
|
---|
| 2251 | Field{1}.CoordUnit='pixel'; %used for mouse_motion
|
---|
| 2252 | end
|
---|
[56] | 2253 |
|
---|
| 2254 | %read a second image
|
---|
[59] | 2255 | if ~isempty(filename_1) && ~test_keepdata_1 && isequal(FieldName_1,'image')
|
---|
[45] | 2256 | switch FileType_1
|
---|
| 2257 | case 'movie'
|
---|
| 2258 | A=read(UvData.MovieObject_1,num_i1);
|
---|
| 2259 | case 'avi'
|
---|
[65] | 2260 | mov=aviread(filename_1,num_i1);
|
---|
[45] | 2261 | A=frame2im(mov(1));
|
---|
| 2262 | case 'vol'
|
---|
[65] | 2263 | A=imread(filename_1);
|
---|
[45] | 2264 | case 'multimage'
|
---|
[65] | 2265 | A=imread(filename_1,num_i1);
|
---|
[45] | 2266 | case 'image'
|
---|
[65] | 2267 | A=imread(filename_1);
|
---|
| 2268 | case 'netcdf'
|
---|
| 2269 | otherwise
|
---|
| 2270 | errormsg=['unknown input file type ' filename_1];
|
---|
[45] | 2271 | end
|
---|
[2] | 2272 | npxy=size(A);
|
---|
| 2273 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
| 2274 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
| 2275 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 2276 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
| 2277 | Field{2}.AName='image';
|
---|
| 2278 | Field{2}.ListVarName={'AY','AX','A'}; %
|
---|
| 2279 | if size(A,3)==3;%color
|
---|
| 2280 | Field{2}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
| 2281 | else
|
---|
| 2282 | Field{2}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
| 2283 | end
|
---|
| 2284 | Field{2}.AY=Rangy;
|
---|
| 2285 | Field{2}.AX=Rangx;
|
---|
| 2286 | Field{2}.A=A;
|
---|
| 2287 | Field{2}.CoordType='px'; %used for mouse_motion
|
---|
| 2288 | Field{2}.CoordUnit='px'; %used for move_mou
|
---|
| 2289 | end
|
---|
| 2290 |
|
---|
| 2291 | %read ncfile(s)
|
---|
| 2292 | CivStage_1=0;%default
|
---|
| 2293 | VelType_out_1=[];
|
---|
| 2294 | InputField={FieldName};
|
---|
| 2295 | InputField_1={FieldName_1};
|
---|
[59] | 2296 | if (~isempty(filename)&& isequal(FileType,'netcdf')) || (~isempty(filename_1)&& isequal(FileType_1,'netcdf')) ;
|
---|
[2] | 2297 | %read the velocity field(s) from netcdf rootfile(s)
|
---|
| 2298 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 2299 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 2300 | scal_color= list_code{index_code(1)}; % selected field
|
---|
| 2301 | if isequal(FieldName,'velocity')&& ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
| 2302 | InputField=[InputField scal_color];
|
---|
| 2303 | end
|
---|
| 2304 | if isequal(FieldName_1,'velocity') && ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
| 2305 | InputField_1=[InputField_1 scal_color];
|
---|
| 2306 | end
|
---|
[45] | 2307 | if isequal(FileType,'netcdf') %read the first nc field
|
---|
[2] | 2308 | if isequal(FieldName,'get_field...')% read the field names on the interface get_field.
|
---|
[144] | 2309 | hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI
|
---|
[2] | 2310 | if isempty(hget_field)
|
---|
[89] | 2311 | hget_field= get_field(filename);%open the get_field GUI
|
---|
[144] | 2312 | % set(hget_field,'name','get_field')
|
---|
[128] | 2313 | elseif UvData.NewSeries% refresh the fet_field GUI for a new series
|
---|
[89] | 2314 | delete(hget_field)
|
---|
| 2315 | hget_field= get_field(filename);%open the get_field GUI
|
---|
[144] | 2316 | set(hget_field,'name','get_field')%rename get_field GUI for the 'slave' mode
|
---|
[2] | 2317 | end
|
---|
| 2318 | hhget_field=guidata(hget_field);
|
---|
[144] | 2319 | set(hhget_field.list_fig,'Value',1)
|
---|
| 2320 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
[89] | 2321 | funct_list=get(hhget_field.ACTION,'UserData');
|
---|
| 2322 | funct_index=get(hhget_field.ACTION,'Value');
|
---|
[128] | 2323 | funct=funct_list{funct_index};%select the current action in get_field, e;g. PLOT
|
---|
| 2324 | Field{1}=funct(hget_field); %%activate the current action selected in get_field, e;g.read the names of the variables to plot
|
---|
[2] | 2325 | CivStage=0;
|
---|
[89] | 2326 | VelType_out=[];
|
---|
[2] | 2327 | else
|
---|
| 2328 | [Field{1},VelType_out]=read_civxdata(filename,InputField,VelType);
|
---|
| 2329 | if isfield(Field{1},'Txt')
|
---|
[59] | 2330 | errormsg=Field{1}.Txt;
|
---|
[2] | 2331 | return
|
---|
| 2332 | end
|
---|
| 2333 | CivStage=Field{1}.CivStage;
|
---|
| 2334 | UvData.NbDim=Field{1}.nb_dim;
|
---|
| 2335 | end
|
---|
| 2336 | end
|
---|
[59] | 2337 | if ~isempty(filename_1) && ~test_keepdata_1 && isequal(FileType_1,'netcdf') %read the second file
|
---|
[2] | 2338 | if isequal(FieldName_1,'get_field...')% read the field names on the interface get_field.
|
---|
[144] | 2339 | hget_field_1=findobj(allchild(0),'Name','get_field_1');%find the get_field... GUI
|
---|
[89] | 2340 | if isempty(hget_field_1)
|
---|
| 2341 | hget_field_1= get_field(filename_1);%open the get_field GUI
|
---|
[144] | 2342 | set(hget_field_1,'name','get_field_1')
|
---|
| 2343 | elseif UvData.NewSeries% refresh the fet_field GUI for a new series
|
---|
| 2344 | delete(hget_field_1)
|
---|
| 2345 | hget_field_1= get_field(filename);%open the get_field GUI
|
---|
| 2346 | set(hget_field_1,'name','get_field_1')%rename get_field GUI for the 'slave' mode
|
---|
[2] | 2347 | end
|
---|
[89] | 2348 | hhget_field_1=guidata(hget_field_1);%handles of GUI elements in get_field
|
---|
[144] | 2349 | set(hhget_field_1.list_fig,'Value',1)
|
---|
| 2350 | set(hhget_field_1.list_fig,'String',{'uvmat'})
|
---|
[89] | 2351 | funct_list=get(hhget_field_1.ACTION,'UserData');
|
---|
| 2352 | funct_index=get(hhget_field_1.ACTION,'Value');
|
---|
| 2353 | funct=funct_list{funct_index};
|
---|
| 2354 | Field{2}=funct(hget_field_1); %read the names of the variables to plot in the get_field GUI
|
---|
[2] | 2355 | else
|
---|
[86] | 2356 | [Field{2},VelType_out_1]=read_civxdata(filename_1,InputField_1,VelType_1);
|
---|
[2] | 2357 | CivStage_1=Field{2}.CivStage;
|
---|
| 2358 | end
|
---|
[45] | 2359 | if ~isequal(FileType,'netcdf')
|
---|
[2] | 2360 | VelType_out=VelType_out_1;
|
---|
| 2361 | end
|
---|
| 2362 | end
|
---|
| 2363 | end
|
---|
| 2364 |
|
---|
[59] | 2365 | %store the second field for possible latter use
|
---|
| 2366 | if numel(Field)==2
|
---|
| 2367 | UvData.Field_1=Field{2};
|
---|
| 2368 | end
|
---|
| 2369 |
|
---|
[128] | 2370 | %% update the display buttons for the first velocity type (first menuline)
|
---|
[2] | 2371 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
[45] | 2372 | if ~isequal(FileType,'netcdf')
|
---|
[2] | 2373 | reset_vel_type(veltype_handles)
|
---|
[59] | 2374 | elseif isempty(VelType) && ~isequal(FieldName,'get_field...')
|
---|
[2] | 2375 | set_veltype_display(veltype_handles,CivStage)%update the display of available velocity types for the first field
|
---|
| 2376 | if isempty(VelType_out)
|
---|
| 2377 | reset_vel_type(veltype_handles)
|
---|
| 2378 | else
|
---|
| 2379 | handle1=eval(['handles.' VelType_out]);
|
---|
| 2380 | reset_vel_type(veltype_handles,handle1)
|
---|
| 2381 | end
|
---|
| 2382 | end
|
---|
| 2383 |
|
---|
[128] | 2384 | %% update the display buttons for the second velocity type (second menuline)
|
---|
[2] | 2385 | veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
[45] | 2386 | if ~isequal(FileType_1,'netcdf')
|
---|
[2] | 2387 | reset_vel_type(veltype_handles_1)
|
---|
[59] | 2388 | elseif isempty(VelType_1) && ~isequal(FieldName_1,'get_field...')
|
---|
[2] | 2389 | set_veltype_display(veltype_handles_1,CivStage_1)%update the display of available velocity types for the first field
|
---|
| 2390 | if isempty(VelType_out_1)
|
---|
| 2391 | reset_vel_type(veltype_handles_1)
|
---|
| 2392 | else
|
---|
| 2393 | handle1=eval(['handles.' VelType_out_1 '_1']);
|
---|
| 2394 | reset_vel_type(veltype_handles_1,handle1)
|
---|
| 2395 | end
|
---|
| 2396 | end
|
---|
| 2397 |
|
---|
[128] | 2398 | %% introduce w as background image by default for a new series (only for nbdim=2)
|
---|
[2] | 2399 | if ~isfield(UvData,'NewSeries')
|
---|
| 2400 | UvData.NewSeries=1;
|
---|
| 2401 | end
|
---|
| 2402 | %put W as background image by default if NbDim=2:
|
---|
[45] | 2403 | if ~isfield(UvData,'NbDim')||isempty(UvData.NbDim)||~isequal(UvData.NbDim,3)
|
---|
[2] | 2404 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W);
|
---|
| 2405 | set(handles.SubField,'Value',1);
|
---|
[45] | 2406 | %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
|
---|
[2] | 2407 | set(handles.RootPath_1,'String','"')
|
---|
| 2408 | set(handles.RootFile_1,'String','"')
|
---|
| 2409 | set(handles.SubDir_1,'String','"');
|
---|
| 2410 | [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
|
---|
| 2411 | set(handles.FileIndex_1,'String',indices)
|
---|
| 2412 | set(handles.FileExt_1,'String','"');
|
---|
| 2413 | set(handles.Fields_1,'Visible','on');
|
---|
| 2414 | set(handles.Fields_1,'Visible','on');
|
---|
| 2415 | set(handles.RootPath_1,'Visible','on')
|
---|
| 2416 | set(handles.RootFile_1,'Visible','on')
|
---|
| 2417 | set(handles.SubDir_1,'Visible','on');
|
---|
| 2418 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 2419 | set(handles.FileExt_1,'Visible','on');
|
---|
| 2420 | set(handles.Fields_1,'Visible','on');
|
---|
| 2421 | Field{1}.AName='w';
|
---|
[128] | 2422 | % testscal=1;
|
---|
[2] | 2423 | end
|
---|
| 2424 | end
|
---|
| 2425 |
|
---|
| 2426 | %multislice case
|
---|
[59] | 2427 | if ~isempty(filename) &&(~isfield(UvData,'NbDim') || isequal(UvData.NbDim,2))&&...%2D case
|
---|
[2] | 2428 | isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord')
|
---|
| 2429 | siz=size(UvData.XmlData.GeometryCalib.SliceCoord);
|
---|
[128] | 2430 | % if siz(1)>1
|
---|
| 2431 | % NbSlice=siz(1);
|
---|
| 2432 | % else
|
---|
| 2433 | % NbSlice=1;
|
---|
| 2434 | % end
|
---|
[2] | 2435 | end
|
---|
| 2436 |
|
---|
| 2437 | %store the current open names, fields and vel types in uvmat interface
|
---|
| 2438 | UvData.filename=filename;
|
---|
| 2439 | UvData.filename_1=filename_1;
|
---|
| 2440 | UvData.VelType=VelType;
|
---|
| 2441 | UvData.VelType_1=VelType_1;
|
---|
| 2442 | UvData.FieldName=FieldName;
|
---|
| 2443 | UvData.FieldName_1=FieldName_1;
|
---|
| 2444 | if ~isempty(scal_color)
|
---|
| 2445 | UvData.CName=scal_color;
|
---|
| 2446 | end
|
---|
| 2447 |
|
---|
[128] | 2448 | %% coordinate transform or user fct
|
---|
[2] | 2449 | XmlData=[];%default
|
---|
| 2450 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 2451 | XmlData=UvData.XmlData;
|
---|
| 2452 | end
|
---|
| 2453 | XmlData_1=[];%default
|
---|
| 2454 | if isfield(UvData,'XmlData_1')
|
---|
| 2455 | XmlData_1=UvData.XmlData_1;
|
---|
| 2456 | end
|
---|
[128] | 2457 | % menu_transform=get(handles.transform_fct,'String');
|
---|
[39] | 2458 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 2459 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 2460 | transform=transform_list{choice_value};%selected function handles
|
---|
[2] | 2461 | % z index
|
---|
[59] | 2462 | if ~isempty(filename)
|
---|
[60] | 2463 | Field{1}.ZIndex=z_index;
|
---|
[2] | 2464 | end
|
---|
| 2465 | %px to phys or other transform on field
|
---|
[59] | 2466 | if ~isempty(transform)
|
---|
[2] | 2467 | if length(Field)>=2
|
---|
[60] | 2468 | Field{2}.ZIndex=z_index;
|
---|
[38] | 2469 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
|
---|
[2] | 2470 | if isempty(Field{2})
|
---|
| 2471 | Field(2)=[];
|
---|
| 2472 | end
|
---|
| 2473 | else
|
---|
[38] | 2474 | Field{1}=transform(Field{1},XmlData);
|
---|
[2] | 2475 | end
|
---|
| 2476 | end
|
---|
| 2477 |
|
---|
[128] | 2478 | %% calculate scalar
|
---|
[45] | 2479 | if isequal(FileType,'netcdf') && ~isequal(FieldName,'get_field...')%
|
---|
[2] | 2480 | Field{1}=calc_field(InputField,Field{1});
|
---|
| 2481 | end
|
---|
[59] | 2482 | if length(Field)==2 && ~test_keepdata_1 && isequal(FileType_1,'netcdf') && ~isequal(FieldName_1,'get_field...')
|
---|
[2] | 2483 | Field{2}=calc_field(InputField_1,Field{2});
|
---|
| 2484 | end
|
---|
| 2485 | % combine the two input fields (e.g. substract velocity fields)
|
---|
| 2486 | if numel(Field)==2
|
---|
[59] | 2487 | UvData.Field=sub_field(Field{1},Field{2}); %TO UPDATE FOR MORE GENERAL INPUT
|
---|
[2] | 2488 | else
|
---|
| 2489 | UvData.Field=Field{1};
|
---|
| 2490 | end
|
---|
[59] | 2491 |
|
---|
[128] | 2492 | %% test 3D , default projection menuplane and typical mesh (needed to menuopen set_object)
|
---|
[2] | 2493 | test_x=0;
|
---|
| 2494 | test_z=0;% test for unstructured z coordinate
|
---|
| 2495 | UvData.ZMax=0;
|
---|
| 2496 | UvData.ZMin=0;%default
|
---|
| 2497 | UvData.Mesh=1; %default
|
---|
| 2498 | [UvData.Field,errormsg]=check_field_structure(UvData.Field);
|
---|
| 2499 | if ~isempty(errormsg)
|
---|
[59] | 2500 | errormsg=['error in uvmat/run0_Callback/check_field_structure: ' errormsg];
|
---|
[2] | 2501 | return
|
---|
| 2502 | end
|
---|
| 2503 | [CellVarIndex,NbDim,VarType]=find_field_indices(UvData.Field);
|
---|
| 2504 | [NbDim,imax]=max(NbDim);
|
---|
| 2505 | if isempty(imax)
|
---|
[45] | 2506 | % DimVarIndex=0;
|
---|
[2] | 2507 | coord_x=[];
|
---|
| 2508 | else
|
---|
[45] | 2509 | % VarIndex=CellVarIndex{imax};
|
---|
[2] | 2510 | coord_x=VarType{imax}.coord_x;
|
---|
| 2511 | end
|
---|
[45] | 2512 | if isfield(UvData,'NbDim') && ~isempty(UvData.NbDim)
|
---|
[2] | 2513 | NbDim=UvData.NbDim;
|
---|
| 2514 | else
|
---|
| 2515 | UvData.NbDim=NbDim;
|
---|
| 2516 | end
|
---|
[45] | 2517 | if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinate z
|
---|
[2] | 2518 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
|
---|
| 2519 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
|
---|
| 2520 | test_x=1;
|
---|
[45] | 2521 | elseif isfield(UvData.Field,'X') && isfield(UvData.Field,'Y')
|
---|
[2] | 2522 | XName='X';
|
---|
| 2523 | YName='Y';
|
---|
| 2524 | test_x=1;
|
---|
| 2525 | end
|
---|
| 2526 | if test_x
|
---|
| 2527 | eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
| 2528 | eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
| 2529 | eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
| 2530 | eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
| 2531 | eval(['nbvec=length(UvData.Field.' XName ');'])
|
---|
| 2532 | if NbDim==3%
|
---|
[45] | 2533 | if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_z)%unstructured coordinate z
|
---|
[42] | 2534 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
|
---|
[2] | 2535 | eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2536 | eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
| 2537 | test_z=1;
|
---|
| 2538 | elseif isfield(UvData,'Z')% usual civ data
|
---|
| 2539 | UvData.ZMax=max(UvData.Z);
|
---|
| 2540 | UvData.ZMin=min(UvData.Z);
|
---|
| 2541 | test_z=1;
|
---|
| 2542 | end
|
---|
| 2543 | end
|
---|
| 2544 | if isequal(UvData.ZMin,UvData.ZMax)%no z dependency
|
---|
| 2545 | NbDim=2;
|
---|
| 2546 | test_z=0;
|
---|
| 2547 | end
|
---|
| 2548 | if test_z
|
---|
| 2549 | UvData.Mesh=((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)*(UvData.ZMax-UvData.ZMin))/nbvec;% volume per vector
|
---|
| 2550 | UvData.Mesh=(UvData.Mesh)^(1/3);
|
---|
| 2551 | else
|
---|
| 2552 | UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/nbvec);%2D
|
---|
| 2553 | end
|
---|
| 2554 | end
|
---|
[128] | 2555 |
|
---|
[2] | 2556 | %case of structured coordinates
|
---|
[89] | 2557 | if isfield(UvData.Field,'AX') && isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')
|
---|
[2] | 2558 | UvData.XMax=max(UvData.Field.AX);
|
---|
| 2559 | UvData.XMin=min(UvData.Field.AX);
|
---|
| 2560 | UvData.YMax=max(UvData.Field.AY);
|
---|
| 2561 | UvData.YMin=min(UvData.Field.AY);
|
---|
| 2562 | np_A=size(UvData.Field.A);
|
---|
| 2563 | UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/((np_A(1)-1) * (np_A(2)-1))) ;
|
---|
| 2564 | end
|
---|
[89] | 2565 | if isempty(coord_x) && ~isempty(CellVarIndex)
|
---|
[2] | 2566 | VarIndex=CellVarIndex{imax}; % list of variable indices
|
---|
| 2567 | DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
|
---|
| 2568 | if NbDim==3
|
---|
| 2569 | nbpoints=UvData.Field.DimValue(DimIndex(1));
|
---|
[72] | 2570 | if isfield(VarType{imax},'coord_3')&& ~isequal(VarType{imax}.coord_3,0) % z is a dimension variable
|
---|
[81] | 2571 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_3};
|
---|
[2] | 2572 | eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2573 | eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
| 2574 | else
|
---|
| 2575 | testcoord_z=0;
|
---|
| 2576 | if length(UvData.Field.VarAttribute)>=VarIndex(1)
|
---|
| 2577 | if isfield(UvData.Field.VarAttribute{VarIndex(1)},'Coord_1')%regular grid
|
---|
| 2578 | Coord_z=UvData.Field.VarAttribute{VarIndex(1)}.Coord_1;
|
---|
| 2579 | UvData.ZMax=max(Coord_z);
|
---|
| 2580 | UvData.ZMin=min(Coord_z);
|
---|
| 2581 | testcoord_z=1;
|
---|
| 2582 | end
|
---|
| 2583 | end
|
---|
| 2584 | if ~testcoord_z
|
---|
| 2585 | UvData.ZMin=1;
|
---|
| 2586 | UvData.ZMax=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2587 | end
|
---|
| 2588 | end
|
---|
| 2589 | UvData.Mesh=(UvData.ZMax-UvData.ZMin)/(nbpoints-1);
|
---|
| 2590 | elseif NbDim==2
|
---|
| 2591 | nbpoints_y=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2592 | Yvar=VarType{imax}.coord_y;
|
---|
| 2593 | if Yvar~=0 % x is a dimension variable
|
---|
| 2594 | YName=UvData.Field.ListVarName{Yvar};
|
---|
| 2595 | eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
| 2596 | eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
| 2597 | else
|
---|
| 2598 | testcoord_y=0;
|
---|
| 2599 | if ~testcoord_y
|
---|
| 2600 | UvData.YMin=1;
|
---|
| 2601 | UvData.YMax=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2602 | end
|
---|
| 2603 | end
|
---|
| 2604 | DY=(UvData.YMax-UvData.YMin)/(nbpoints_y-1);
|
---|
| 2605 | nbpoints_x=UvData.Field.DimValue(DimIndex(2));
|
---|
| 2606 | Xvar=VarType{imax}.coord_x;
|
---|
| 2607 | if Xvar~=0 % x is a dimension variable
|
---|
| 2608 | XName=UvData.Field.ListVarName{Xvar};
|
---|
| 2609 | eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
| 2610 | eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
| 2611 | else
|
---|
| 2612 | testcoord_x=0;
|
---|
| 2613 | if ~testcoord_x
|
---|
| 2614 | UvData.XMin=1;
|
---|
| 2615 | UvData.XMax=UvData.Field.DimValue(DimIndex(2));
|
---|
| 2616 | end
|
---|
| 2617 | end
|
---|
| 2618 | DX=(UvData.XMax-UvData.XMin)/(nbpoints_x-1);
|
---|
| 2619 | UvData.Mesh= sqrt(DX*DY);
|
---|
| 2620 | end
|
---|
| 2621 | end
|
---|
| 2622 |
|
---|
| 2623 | %create a default projection menuplane
|
---|
| 2624 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 2625 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 2626 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 2627 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
[61] | 2628 | set(handles.list_object_1,'Value',1);
|
---|
[71] | 2629 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
[2] | 2630 | end
|
---|
| 2631 |
|
---|
| 2632 | %3D case (menuvolume)
|
---|
[74] | 2633 | if NbDim==3 && UvData.NewSeries
|
---|
[2] | 2634 | UvData.Object{1}.NbDim=UvData.NbDim;%test for 3D objects
|
---|
| 2635 | UvData.Object{1}.RangeZ=UvData.Mesh;%main plotting plane
|
---|
| 2636 | UvData.Object{1}.Coord(1,3)=(UvData.ZMin+UvData.ZMax)/2;%section at a middle plane chosen
|
---|
| 2637 | UvData.Object{1}.Phi=0;
|
---|
| 2638 | UvData.Object{1}.Theta=0;
|
---|
| 2639 | UvData.Object{1}.Psi=0;
|
---|
| 2640 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
|
---|
| 2641 | PlotHandles=get_plot_handles(handles);
|
---|
| 2642 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
| 2643 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
[72] | 2644 | UvData.Object{1}.Name='1-PLANE';
|
---|
| 2645 | UvData.Object{1}.enable_plot=1;
|
---|
[2] | 2646 | set_object(UvData.Object{1},PlotHandles,ZBounds);
|
---|
[61] | 2647 | set(handles.list_object_1,'Value',1);
|
---|
[2] | 2648 | %multilevel case (single menuplane in a 3D space)
|
---|
| 2649 | elseif isfield(UvData,'Z')
|
---|
[128] | 2650 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
|
---|
[2] | 2651 | XmlData=UvData.XmlData;
|
---|
| 2652 | if isfield(XmlData,'PlanePos')
|
---|
| 2653 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
|
---|
| 2654 | end
|
---|
| 2655 | if isfield(XmlData,'PlaneAngle')
|
---|
| 2656 | siz=size(XmlData.PlaneAngle);
|
---|
| 2657 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
|
---|
| 2658 | UvData.Object{1}.Phi=XmlData.PlaneAngle(indangle,1);
|
---|
| 2659 | UvData.Object{1}.Theta=XmlData.PlaneAngle(indangle,2);
|
---|
| 2660 | UvData.Object{1}.Psi=XmlData.PlaneAngle(indangle,3);
|
---|
| 2661 | end
|
---|
| 2662 | elseif isfield(UvData,'ZIndex')
|
---|
| 2663 | UvData.Object{1}.ZObject=UvData.ZIndex;
|
---|
| 2664 | end
|
---|
| 2665 | end
|
---|
| 2666 |
|
---|
[128] | 2667 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need)
|
---|
| 2668 | if isfield(UvData,'Mask')&& ~isfield(UvData,'A')
|
---|
[2] | 2669 | set(handles.MinA,'String','0')
|
---|
| 2670 | set(handles.MaxA,'String','255')
|
---|
| 2671 | end
|
---|
[128] | 2672 |
|
---|
| 2673 | %% Plot the projections on the selected projection objects
|
---|
| 2674 |
|
---|
| 2675 | % main projection object (uvmat display)
|
---|
| 2676 | IndexObj(1)=get(handles.list_object_1,'Value');%selected projection object for main view
|
---|
[65] | 2677 | if IndexObj(1)> numel(UvData.Object)
|
---|
[128] | 2678 | IndexObj(1)=1;%select the first object if the selected one does not exist
|
---|
| 2679 | set(handles.list_object_1,'Value',1)
|
---|
[65] | 2680 | end
|
---|
[128] | 2681 | plot_handles{1}=handles;
|
---|
| 2682 | haxes(1)=handles.axes3;
|
---|
| 2683 | PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
|
---|
| 2684 | keeplim(1)=get(handles.FixedLimits,'Value');% test for fixed graph limits
|
---|
| 2685 | PosColorbar{1}=UvData.PosColorbar;%prescribe the colorbar position on the uvmat interface
|
---|
| 2686 |
|
---|
| 2687 | % second projection object (view_field display)
|
---|
| 2688 | IndexObj_2=get(handles.list_object_2,'Value');%selected projection object for the second view
|
---|
| 2689 | if isequal(get(handles.list_object_2,'Visible'),'on') && IndexObj_2 <= numel(UvData.Object)&& ~isempty(UvData.Object{IndexObj_2})
|
---|
[65] | 2690 | IndexObj(2)=IndexObj_2;
|
---|
[128] | 2691 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI
|
---|
| 2692 | if ~isempty(view_field_handle)
|
---|
| 2693 | plot_handles{2}=guidata(view_field_handle);
|
---|
| 2694 | haxes(2)=plot_handles{2}.axes3;
|
---|
| 2695 | PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the uvmat interface
|
---|
| 2696 | keeplim(2)=get(plot_handles{2}.FixedLimits,'Value');
|
---|
| 2697 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
|
---|
| 2698 | end
|
---|
[65] | 2699 | end
|
---|
[128] | 2700 |
|
---|
| 2701 | %loop on the projection objects: one or two
|
---|
[71] | 2702 | for imap=1:numel(IndexObj)
|
---|
[128] | 2703 | iobj=IndexObj(imap);
|
---|
| 2704 | ObjectData=proj_field(UvData.Field,UvData.Object{iobj},iobj);% project field on the object
|
---|
| 2705 |
|
---|
| 2706 | %use of mask (TODO: check)
|
---|
| 2707 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A')
|
---|
| 2708 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
|
---|
| 2709 | AX=ObjectData.AX;%x coordiantes for the scalar field
|
---|
| 2710 | AY=ObjectData.AY;%y coordinates for the scalar field
|
---|
| 2711 | MaskX=ObjectData.MaskX;%x coordiantes for the mask
|
---|
| 2712 | MaskY=ObjectData.MaskY;%y coordiantes for the mask
|
---|
| 2713 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY)
|
---|
| 2714 | nxy=size(flag_mask);
|
---|
| 2715 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
|
---|
| 2716 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
|
---|
| 2717 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display
|
---|
| 2718 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display
|
---|
| 2719 | %project on the positions of the scalar
|
---|
| 2720 | npxy=size(ObjectData.A);
|
---|
| 2721 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
|
---|
| 2722 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
|
---|
| 2723 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end);
|
---|
| 2724 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end);
|
---|
| 2725 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
|
---|
| 2726 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
|
---|
[2] | 2727 | end
|
---|
[128] | 2728 | AClass=class(ObjectData.A);
|
---|
| 2729 | ObjectData.A=flag_mask.*double(ObjectData.A);
|
---|
| 2730 | ObjectData.A=feval(AClass,ObjectData.A);
|
---|
| 2731 | ind_off=[];
|
---|
| 2732 | if isfield(ObjectData,'ListVarName')
|
---|
| 2733 | for ilist=1:length(ObjectData.ListVarName)
|
---|
| 2734 | if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY')
|
---|
| 2735 | ind_off=[ind_off ilist];
|
---|
| 2736 | end
|
---|
[2] | 2737 | end
|
---|
[128] | 2738 | ObjectData.ListVarName(ind_off)=[];
|
---|
| 2739 | ObjectData.VarDimIndex(ind_off)=[];
|
---|
| 2740 | ind_off=[];
|
---|
| 2741 | for ilist=1:length(ObjectData.ListDimName)
|
---|
| 2742 | if isequal(ObjectData.ListDimName{ilist},'MaskX') || isequal(ObjectData.ListDimName{ilist},'MaskY')
|
---|
| 2743 | ind_off=[ind_off ilist];
|
---|
| 2744 | end
|
---|
| 2745 | end
|
---|
| 2746 | ObjectData.ListDimName(ind_off)=[];
|
---|
| 2747 | ObjectData.DimValue(ind_off)=[];
|
---|
| 2748 | end
|
---|
| 2749 | end
|
---|
| 2750 |
|
---|
| 2751 | if ~isempty(ObjectData)
|
---|
| 2752 | PlotType='none'; %default
|
---|
| 2753 | if imap==2 && isempty(view_field_handle)
|
---|
| 2754 | view_field(ObjectData)
|
---|
| 2755 | else
|
---|
| 2756 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},keeplim(imap),PosColorbar{imap});
|
---|
[132] | 2757 | write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters
|
---|
| 2758 | if imap==1
|
---|
| 2759 | UvData.ProjField=ObjectData;
|
---|
| 2760 | else
|
---|
| 2761 | ViewFieldData=get(view_field_handle,'UserData');
|
---|
| 2762 | ViewFieldData.ProjField=ObjectData;
|
---|
| 2763 | set(view_field_handle,'UserData',ViewFieldData)
|
---|
| 2764 | end
|
---|
[128] | 2765 | end
|
---|
| 2766 | if isequal(PlotType,'none')
|
---|
| 2767 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 2768 | if isempty(hget_field)
|
---|
| 2769 | get_field([],ObjectData)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
|
---|
[101] | 2770 | else
|
---|
[128] | 2771 | errormsg='The field defined by get_field cannot be plotted';
|
---|
| 2772 | return
|
---|
[101] | 2773 | end
|
---|
[128] | 2774 | end
|
---|
[2] | 2775 | end
|
---|
| 2776 | end
|
---|
| 2777 |
|
---|
[128] | 2778 | %write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
|
---|
[74] | 2779 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
|
---|
[45] | 2780 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 2781 |
|
---|
[128] | 2782 | %% update the mask
|
---|
[2] | 2783 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 2784 | update_mask(handles,num_i1,num_i2);
|
---|
| 2785 | end
|
---|
| 2786 |
|
---|
[128] | 2787 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case)
|
---|
| 2788 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display
|
---|
[2] | 2789 | ind_bad=[];
|
---|
| 2790 | nb_histo=1;
|
---|
[128] | 2791 |
|
---|
| 2792 | % suppress coordinates from the histogram menu
|
---|
| 2793 | for ivar=1:numel(menu_histo)%l loop on field variables:
|
---|
[2] | 2794 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
|
---|
| 2795 | Role=UvData.Field.VarAttribute{ivar}.Role;
|
---|
| 2796 | switch Role
|
---|
| 2797 | case {'coord_x','coord_y','coord_z','dimvar'}
|
---|
| 2798 | ind_bad=[ind_bad ivar];
|
---|
| 2799 | case {'vector_y'}
|
---|
| 2800 | nb_histo=nb_histo+1;
|
---|
| 2801 | end
|
---|
| 2802 | end
|
---|
| 2803 | DimCell=UvData.Field.VarDimName{ivar};
|
---|
| 2804 | DimName='';
|
---|
| 2805 | if ischar(DimCell)
|
---|
| 2806 | DimName=DimCell;
|
---|
| 2807 | elseif iscell(DimCell)&& numel(DimCell)==1
|
---|
| 2808 | DimName=DimCell{1};
|
---|
| 2809 | end
|
---|
| 2810 | if strcmp(DimName,menu_histo{ivar})
|
---|
| 2811 | ind_bad=[ind_bad ivar];
|
---|
| 2812 | end
|
---|
| 2813 | end
|
---|
| 2814 | menu_histo(ind_bad)=[];
|
---|
[128] | 2815 |
|
---|
| 2816 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
| 2817 | % display menus and plot histograms
|
---|
[2] | 2818 | test_v=0;
|
---|
| 2819 | if ~isempty(menu_histo)
|
---|
| 2820 | set(handles.histo1_menu,'Value',1)
|
---|
| 2821 | set(handles.histo1_menu,'String',menu_histo)
|
---|
[128] | 2822 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram
|
---|
| 2823 | % case of more than one variables (eg vector components)
|
---|
| 2824 | if nb_histo > 1
|
---|
[2] | 2825 | test_v=1;
|
---|
| 2826 | set(handles.histo2_menu,'Visible','on')
|
---|
| 2827 | set(handles.histo_v,'Visible','on')
|
---|
| 2828 | set(handles.histo2_menu,'String',menu_histo)
|
---|
| 2829 | set(handles.histo2_menu,'Value',2)
|
---|
[128] | 2830 | histo2_menu_Callback(handles.histo2_menu,[], handles)% plot second histogram
|
---|
[2] | 2831 | end
|
---|
| 2832 | end
|
---|
| 2833 | if ~test_v
|
---|
| 2834 | set(handles.histo2_menu,'Visible','off')
|
---|
| 2835 | set(handles.histo_v,'Visible','off')
|
---|
| 2836 | cla(handles.histo_v)
|
---|
| 2837 | set(handles.histo2_menu,'Value',1)
|
---|
| 2838 | end
|
---|
[128] | 2839 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
[2] | 2840 |
|
---|
[128] | 2841 | %% display time
|
---|
[2] | 2842 | testimedoc=0;
|
---|
| 2843 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
|
---|
[89] | 2844 | if isempty(num_i2)||isnan(num_i2)
|
---|
[2] | 2845 | num_i2=num_i1;
|
---|
| 2846 | end
|
---|
[89] | 2847 | if isempty(num_j1)||isnan(num_j1)
|
---|
[2] | 2848 | num_j1=1;
|
---|
| 2849 | end
|
---|
[89] | 2850 | if isempty(num_j2)||isnan(num_j2)
|
---|
[2] | 2851 | num_j2=num_j1;
|
---|
| 2852 | end
|
---|
| 2853 | siz=size(UvData.XmlData.Time);
|
---|
[128] | 2854 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
[2] | 2855 | abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
| 2856 | dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
|
---|
| 2857 | testimedoc=1;
|
---|
| 2858 | end
|
---|
| 2859 | end
|
---|
| 2860 | if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
|
---|
[128] | 2861 | [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
| 2862 | num_i2=str2double(str2);
|
---|
[2] | 2863 | if isempty(num_i2)
|
---|
| 2864 | num_i2=num_i1;
|
---|
| 2865 | end
|
---|
[128] | 2866 | num_j1=str2double(str_a);
|
---|
[2] | 2867 | if isempty(num_j1)
|
---|
| 2868 | num_j1=1;
|
---|
| 2869 | end
|
---|
[128] | 2870 | num_j2=str2double(str_b);
|
---|
[2] | 2871 | if isempty(num_j2)
|
---|
| 2872 | num_j2=num_j1;
|
---|
| 2873 | end
|
---|
[128] | 2874 | num_i1=str2double(str1);
|
---|
[2] | 2875 | siz=size(UvData.XmlData_1.Time);
|
---|
[128] | 2876 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
[2] | 2877 | abstime_1=(UvData.XmlData_1.Time(num_i1,num_j1)+UvData.XmlData_1.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
| 2878 | end
|
---|
| 2879 | end
|
---|
| 2880 | set(handles.abs_time,'String',num2str(abstime,4))
|
---|
| 2881 | set(handles.abs_time_1,'String',num2str(abstime_1,4))
|
---|
| 2882 | if testimedoc && isfield(UvData,'dt')
|
---|
| 2883 | dt=UvData.dt;
|
---|
| 2884 | end
|
---|
[121] | 2885 | if isempty(dt)||isequal(dt,0)
|
---|
[2] | 2886 | set(handles.Dt_txt,'String','')
|
---|
| 2887 | else
|
---|
| 2888 | if ~(isfield(UvData,'TimeUnit') && ~isempty(UvData.TimeUnit))
|
---|
| 2889 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] )
|
---|
| 2890 | else
|
---|
| 2891 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' UvData.TimeUnit] )
|
---|
| 2892 | end
|
---|
| 2893 | end
|
---|
[128] | 2894 |
|
---|
| 2895 | %% update the input file name in the get_field GUI
|
---|
[89] | 2896 | if isequal(FieldName,'get_field...')
|
---|
| 2897 | set(hhget_field.inputfile,'String',filename)
|
---|
| 2898 | Tabchar={''};%default
|
---|
| 2899 | Tabcell=[];
|
---|
[128] | 2900 | if isfield(Field{1},'ListGlobalAttribute')&& ~isempty(Field{1}.ListGlobalAttribute)
|
---|
[89] | 2901 | for iline=1:length(Field{1}.ListGlobalAttribute)
|
---|
| 2902 | Tabcell{iline,1}=Field{1}.ListGlobalAttribute{iline};
|
---|
| 2903 | if isfield(Field{1}, Field{1}.ListGlobalAttribute{iline})
|
---|
| 2904 | eval(['val=Field{1}.' Field{1}.ListGlobalAttribute{iline} ';'])
|
---|
| 2905 | if ischar(val);
|
---|
| 2906 | Tabcell{iline,2}=val;
|
---|
| 2907 | else
|
---|
| 2908 | Tabcell{iline,2}=num2str(val);
|
---|
| 2909 | end
|
---|
| 2910 | end
|
---|
| 2911 | end
|
---|
| 2912 | if ~isempty(Tabcell)
|
---|
| 2913 | Tabchar=cell2tab(Tabcell,'=');
|
---|
| 2914 | Tabchar=[{''};Tabchar];
|
---|
| 2915 | end
|
---|
| 2916 | end
|
---|
| 2917 | set(hhget_field.attributes,'String',Tabchar);%update list of global attributes in get_field
|
---|
| 2918 | end
|
---|
| 2919 | if isequal(FieldName_1,'get_field...')
|
---|
| 2920 | set(hhget_field_1.inputfile,'String',filename_1)
|
---|
| 2921 | Tabchar={''};%default
|
---|
| 2922 | Tabcell=[];
|
---|
[122] | 2923 | if isfield(Field{2},'ListGlobalAttribute')&& ~isempty(Field{2}.ListGlobalAttribute)
|
---|
[89] | 2924 | for iline=1:length(Field{2}.ListGlobalAttribute)
|
---|
| 2925 | Tabcell{iline,1}=Field{2}.ListGlobalAttribute{iline};
|
---|
| 2926 | if isfield(Field{2}, Field{2}.ListGlobalAttribute{iline})
|
---|
| 2927 | eval(['val=Field{2}.' Field{2}.ListGlobalAttribute{iline} ';'])
|
---|
| 2928 | if ischar(val);
|
---|
| 2929 | Tabcell{iline,2}=val;
|
---|
| 2930 | else
|
---|
| 2931 | Tabcell{iline,2}=num2str(val);
|
---|
| 2932 | end
|
---|
| 2933 | end
|
---|
| 2934 | end
|
---|
| 2935 | if ~isempty(Tabcell)
|
---|
| 2936 | Tabchar=cell2tab(Tabcell,'=');
|
---|
| 2937 | Tabchar=[{''};Tabchar];
|
---|
| 2938 | end
|
---|
| 2939 | end
|
---|
| 2940 | set(hhget_field_1.attributes,'String',Tabchar);%update list of global attributes in get_field
|
---|
| 2941 | end
|
---|
[2] | 2942 |
|
---|
| 2943 |
|
---|
| 2944 | %-------------------------------------------------------------------
|
---|
| 2945 | % --- translate coordinate to matrix index
|
---|
| 2946 | %-------------------------------------------------------------------
|
---|
| 2947 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
| 2948 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
| 2949 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
| 2950 |
|
---|
| 2951 | %-------------------------------------------------------------------
|
---|
| 2952 | % --- Executes on button press in 'FixedLimits'.
|
---|
| 2953 | %-------------------------------------------------------------------
|
---|
| 2954 | function FixedLimits_Callback(hObject, eventdata, handles)
|
---|
| 2955 | test=get(handles.FixedLimits,'Value');
|
---|
| 2956 | if test
|
---|
| 2957 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
| 2958 | else
|
---|
| 2959 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[84] | 2960 | update_plot(handles);
|
---|
[2] | 2961 | end
|
---|
| 2962 |
|
---|
| 2963 | %-------------------------------------------------------------------
|
---|
| 2964 | % --- Executes on button press in auto_xy.
|
---|
| 2965 | function auto_xy_Callback(hObject, eventdata, handles)
|
---|
| 2966 | test=get(handles.auto_xy,'Value');
|
---|
| 2967 | if test
|
---|
| 2968 | set(handles.auto_xy,'BackgroundColor',[1 1 0])
|
---|
| 2969 | cla(handles.axes3)
|
---|
[89] | 2970 | update_plot(handles);
|
---|
[2] | 2971 | else
|
---|
| 2972 | set(handles.auto_xy,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[89] | 2973 | update_plot(handles);
|
---|
[2] | 2974 | % axis(handles.axes3,'image')
|
---|
| 2975 | end
|
---|
| 2976 |
|
---|
| 2977 |
|
---|
| 2978 | %-------------------------------------------------------------------
|
---|
| 2979 |
|
---|
| 2980 | %-------------------------------------------------------------------
|
---|
| 2981 | % --- Executes on button press in 'zoom'.
|
---|
| 2982 | %-------------------------------------------------------------------
|
---|
| 2983 | function zoom_Callback(hObject, eventdata, handles)
|
---|
[60] | 2984 |
|
---|
[2] | 2985 | if (get(handles.zoom,'Value') == 1);
|
---|
| 2986 | set(handles.zoom,'BackgroundColor',[1 1 0])
|
---|
| 2987 | set(handles.FixedLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
[60] | 2988 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
[2] | 2989 | else
|
---|
| 2990 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2991 | end
|
---|
| 2992 |
|
---|
[60] | 2993 |
|
---|
[2] | 2994 | %-------------------------------------------------------------------
|
---|
| 2995 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
| 2996 | %-------------------------------------------------------------------
|
---|
| 2997 | function record_Callback(hObject, eventdata, handles)
|
---|
| 2998 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
| 2999 | filename=read_file_boxes(handles);
|
---|
| 3000 | AxeData=get(gca,'UserData');
|
---|
| 3001 | [erread,message]=fileattrib(filename);
|
---|
[55] | 3002 | if ~isempty(message) && ~isequal(message.UserWrite,1)
|
---|
[2] | 3003 | msgbox_uvmat('ERROR',['no writting access to ' filename])
|
---|
| 3004 | return
|
---|
| 3005 | end
|
---|
| 3006 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
[55] | 3007 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 3008 | if ~test_civ2 && ~test_civ1
|
---|
| 3009 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
[2] | 3010 | end
|
---|
[55] | 3011 | if test_civ2
|
---|
| 3012 | nbname='nb_vectors2';
|
---|
| 3013 | flagname='vec2_FixFlag';
|
---|
| 3014 | attrname='fix2';
|
---|
| 3015 | end
|
---|
| 3016 | if test_civ1
|
---|
| 3017 | nbname='nb_vectors';
|
---|
| 3018 | flagname='vec_FixFlag';
|
---|
| 3019 | attrname='fix';
|
---|
| 3020 | end
|
---|
| 3021 | %write fix flags in the netcdf file
|
---|
| 3022 | hhh=which('netcdf.open');% look for built-in matlab netcdf library
|
---|
| 3023 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
|
---|
| 3024 | nc=netcdf.open(filename,'NC_WRITE');
|
---|
| 3025 | netcdf.reDef(nc)
|
---|
| 3026 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
|
---|
| 3027 | dimid = netcdf.inqDimID(nc,nbname);
|
---|
| 3028 | try
|
---|
| 3029 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
|
---|
| 3030 | catch
|
---|
| 3031 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
|
---|
| 3032 | end
|
---|
| 3033 | netcdf.endDef(nc)
|
---|
| 3034 | netcdf.putVar(nc,varid,AxeData.FF);
|
---|
| 3035 | netcdf.close(nc)
|
---|
| 3036 | else %old netcdf library
|
---|
[56] | 3037 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
[55] | 3038 | end
|
---|
[2] | 3039 |
|
---|
[56] | 3040 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 3041 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
| 3042 | result=redef(nc);
|
---|
| 3043 | eval(['nc.' attrname '=1;']);
|
---|
| 3044 | theDim=nc(nbname) ;% get the number of velocity vectors
|
---|
| 3045 | nb_vectors=size(theDim);
|
---|
| 3046 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
| 3047 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
| 3048 | fin=close(nc);
|
---|
[2] | 3049 |
|
---|
| 3050 |
|
---|
| 3051 | %-------------------------------------------------------------------
|
---|
| 3052 | %determines the fields to read from the interface
|
---|
| 3053 | %------------------------------------------------------------------
|
---|
| 3054 | function [VelType,civ]=setfield(handles)
|
---|
| 3055 |
|
---|
| 3056 | VelType=[]; %default
|
---|
| 3057 | if (get(handles.civ1,'Value') == 1);
|
---|
| 3058 | VelType='civ1';
|
---|
| 3059 | % interp1
|
---|
| 3060 | elseif (get(handles.interp1,'Value') == 1);
|
---|
| 3061 | VelType='interp1';
|
---|
| 3062 | % filter1
|
---|
| 3063 | elseif (get(handles.filter1,'Value') == 1);
|
---|
| 3064 | VelType='filter1';
|
---|
| 3065 | % CIV2
|
---|
| 3066 | elseif (get(handles.civ2,'Value') == 1);
|
---|
| 3067 | VelType='civ2';
|
---|
| 3068 | % interp2
|
---|
| 3069 | elseif (get(handles.interp2,'Value') == 1);
|
---|
| 3070 | VelType='interp2';
|
---|
| 3071 | % filter2
|
---|
| 3072 | elseif (get(handles.filter2,'Value') == 1);
|
---|
| 3073 | VelType='filter2';
|
---|
| 3074 | end
|
---|
| 3075 |
|
---|
| 3076 | if isequal(get(handles.filter2,'Visible'),'on');
|
---|
| 3077 | civ=6;
|
---|
| 3078 | % interp1
|
---|
| 3079 | elseif isequal(get(handles.interp2,'Visible'),'on');
|
---|
| 3080 | civ=5;
|
---|
| 3081 | % filter1
|
---|
| 3082 | elseif isequal(get(handles.civ2,'Visible'),'on');
|
---|
| 3083 | civ=4;
|
---|
| 3084 | % CIV2
|
---|
| 3085 | elseif isequal(get(handles.filter1,'Visible'),'on');
|
---|
| 3086 | civ=3;
|
---|
| 3087 | % interp2
|
---|
| 3088 | elseif isequal(get(handles.interp1,'Visible'),'on');
|
---|
| 3089 | civ=2;
|
---|
| 3090 | % filter2
|
---|
| 3091 | elseif isequal(get(handles.civ1,'Visible'),'on');
|
---|
| 3092 | civ=1;
|
---|
| 3093 | else
|
---|
| 3094 | civ=0;
|
---|
| 3095 | end
|
---|
| 3096 |
|
---|
| 3097 | %-------------------------------------------------------------------
|
---|
| 3098 | %determines the veltype of the second field to read from the iinterface
|
---|
| 3099 | %------------------------------------------------------------------
|
---|
| 3100 | function VelType=setfield_1(handles)
|
---|
| 3101 |
|
---|
| 3102 | VelType=[]; %default
|
---|
| 3103 | if (get(handles.civ1_1,'Value') == 1);
|
---|
| 3104 | VelType='civ1';
|
---|
| 3105 | % interp1
|
---|
| 3106 | elseif (get(handles.interp1_1,'Value') == 1);
|
---|
| 3107 | VelType='interp1';
|
---|
| 3108 | % filter1
|
---|
| 3109 | elseif (get(handles.filter1_1,'Value') == 1);
|
---|
| 3110 | VelType='filter1';
|
---|
| 3111 | % CIV2
|
---|
| 3112 | elseif (get(handles.civ2_1,'Value') == 1);
|
---|
| 3113 | VelType='civ2';
|
---|
| 3114 | % interp2
|
---|
| 3115 | elseif (get(handles.interp2_1,'Value') == 1);
|
---|
| 3116 | VelType='interp2';
|
---|
| 3117 | % filter2
|
---|
| 3118 | elseif (get(handles.filter2_1,'Value') == 1);
|
---|
| 3119 | VelType='filter2';
|
---|
| 3120 | end
|
---|
| 3121 |
|
---|
| 3122 |
|
---|
| 3123 | %---------------------------------------------------
|
---|
| 3124 | % --- Executes on button press in SubField
|
---|
| 3125 | function SubField_Callback(hObject, eventdata, handles)
|
---|
| 3126 | huvmat=get(handles.run0,'parent');
|
---|
| 3127 | UvData=get(huvmat,'UserData');
|
---|
| 3128 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated
|
---|
| 3129 | set(handles.RootPath_1,'String','')
|
---|
| 3130 | set(handles.RootFile_1,'String','')
|
---|
| 3131 | set(handles.SubDir_1,'String','');
|
---|
| 3132 | set(handles.FileIndex_1,'String','');
|
---|
| 3133 | set(handles.FileExt_1,'String','');
|
---|
| 3134 | set(handles.RootPath_1,'Visible','off')
|
---|
| 3135 | set(handles.RootFile_1,'Visible','off')
|
---|
| 3136 | set(handles.SubDir_1,'Visible','off');
|
---|
| 3137 | set(handles.FileIndex_1,'Visible','off');
|
---|
| 3138 | set(handles.FileExt_1,'Visible','off');
|
---|
| 3139 | set(handles.Fields_1,'Value',1);%set to blank state
|
---|
| 3140 | set_veltype_display([handles.civ1_1 handles.interp1_1 handles.filter1_1 ...
|
---|
| 3141 | handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
|
---|
| 3142 | if isfield(UvData,'XmlData_1')
|
---|
| 3143 | UvData=rmfield(UvData,'XmlData_1');
|
---|
| 3144 | end
|
---|
| 3145 | set(huvmat,'UserData',UvData);
|
---|
| 3146 | run0_Callback(hObject, eventdata, handles); %run
|
---|
| 3147 | else
|
---|
| 3148 | MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 3149 | end
|
---|
| 3150 |
|
---|
[89] | 3151 | %------------------------------------------------------------------------
|
---|
| 3152 | % --- read the data displayed for the input rootfile windows (new)
|
---|
[2] | 3153 | function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
|
---|
[89] | 3154 | %------------------------------------------------------------------------
|
---|
[2] | 3155 | RootPath=get(handles.RootPath,'String');
|
---|
| 3156 | FileName=RootPath; %default
|
---|
| 3157 | SubDir=get(handles.SubDir,'String');
|
---|
| 3158 | if ~isempty(SubDir) && ~isequal(SubDir,'')
|
---|
| 3159 | if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
|
---|
| 3160 | SubDir(1)=[]; %suppress possible / or \ separator
|
---|
| 3161 | end
|
---|
| 3162 | FileName=fullfile(RootPath,SubDir);
|
---|
| 3163 | end
|
---|
| 3164 | RootFile=get(handles.RootFile,'String');
|
---|
| 3165 | if ~isempty(RootFile) && ~isequal(RootFile,'')
|
---|
| 3166 | if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 3167 | RootFile(1)=[]; %suppress possible / or \ separator
|
---|
| 3168 | end
|
---|
| 3169 | FileName=fullfile(FileName,RootFile);
|
---|
| 3170 | end
|
---|
| 3171 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 3172 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 3173 | FileExt=get(handles.FileExt,'String');
|
---|
| 3174 | FileName=[FileName FileIndices FileExt];
|
---|
| 3175 |
|
---|
[85] | 3176 | %------------------------------------------------------------------------
|
---|
| 3177 | % ---- read the data displayed for the second input rootfile windows
|
---|
[2] | 3178 | function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
|
---|
[85] | 3179 | %------------------------------------------------------------------------
|
---|
[86] | 3180 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
|
---|
[85] | 3181 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"')
|
---|
| 3182 | RootPath_1=get(handles.RootPath,'String');
|
---|
| 3183 | end;
|
---|
[2] | 3184 | FileName_1=RootPath_1; %default
|
---|
| 3185 | SubDir_1=get(handles.SubDir_1,'String');
|
---|
[85] | 3186 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"')
|
---|
[2] | 3187 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 3188 | end
|
---|
[85] | 3189 | if numel(SubDir_1)>=1
|
---|
[2] | 3190 | if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))
|
---|
| 3191 | SubDir_1(1)=[]; %suppress possible / or \ separator
|
---|
| 3192 | end
|
---|
| 3193 | FileName_1=fullfile(RootPath_1,SubDir_1);
|
---|
| 3194 | end
|
---|
| 3195 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
[85] | 3196 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"')
|
---|
| 3197 | RootFile_1=get(handles.RootFile,'String');
|
---|
| 3198 | end
|
---|
| 3199 | if numel(RootFile_1)>=1
|
---|
[2] | 3200 | if ~(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 3201 | RootFile_1(1)=[];%suppress possible / or \ separator
|
---|
| 3202 | end
|
---|
| 3203 | FileName_1=fullfile(FileName_1,RootFile_1);
|
---|
| 3204 | end
|
---|
| 3205 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
[85] | 3206 | if isequal(get(handles.FileIndex_1,'Visible'),'off')
|
---|
| 3207 | FileIndices_1=get(handles.FileIndex,'String');
|
---|
| 3208 | else
|
---|
| 3209 | FileIndices_1=get(handles.FileIndex_1,'String');
|
---|
| 3210 | end
|
---|
[2] | 3211 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 3212 | if isequal(FileExt_1,'"'),FileExt_1=get(handles.FileExt,'String'); end;
|
---|
| 3213 | FileName_1=[FileName_1 FileIndices_1 FileExt_1];
|
---|
| 3214 |
|
---|
[85] | 3215 | %------------------------------------------------------------------------
|
---|
[2] | 3216 | % --- Executes on menu selection Fields
|
---|
| 3217 | function Fields_Callback(hObject, eventdata, handles)
|
---|
[85] | 3218 | %------------------------------------------------------------------------
|
---|
[2] | 3219 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3220 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3221 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3222 | if isequal(field,'get_field...')
|
---|
| 3223 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3224 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3225 | filename=read_file_boxes(handles);
|
---|
[144] | 3226 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 3227 | if ~isempty(hget_field)
|
---|
| 3228 | delete(hget_field)
|
---|
[2] | 3229 | end
|
---|
[144] | 3230 | hget_field=get_field(filename);
|
---|
| 3231 | set(hget_field,'Name','get_field')
|
---|
| 3232 | hhget_field=guidata(hget_field);
|
---|
| 3233 | set(hhget_field.list_fig,'Value',1)
|
---|
| 3234 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
| 3235 | set(handles.transform_fct,'Value',1)% no transform by default
|
---|
| 3236 | set(handles.path_transform,'String','')
|
---|
[2] | 3237 | return %no action
|
---|
| 3238 | end
|
---|
| 3239 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3240 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3241 | field_1= list_fields{index_fields(1)}; % selected string
|
---|
[59] | 3242 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 3243 |
|
---|
| 3244 | %read the rootfile input display
|
---|
[82] | 3245 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
[2] | 3246 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
|
---|
| 3247 | NomTypeNew=NomType;%default
|
---|
| 3248 | if isequal(field,'image')
|
---|
| 3249 | % transform netc type to the corresponding image type
|
---|
[85] | 3250 | % if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')|| isequal(NomType,'#_ab')|| isequal(NomType,'_i1-i2')
|
---|
| 3251 | % UvData.SubDir=get(handles.SubDir,'String'); %preserve the subdir in memory
|
---|
| 3252 | % if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')||isequal(UvData.SubDir(1),'/'))
|
---|
| 3253 | % UvData.SubDir(1)=[];
|
---|
| 3254 | % end
|
---|
| 3255 | % set(handles.SubDir,'String','')
|
---|
| 3256 | % set(handles.FileExt,'String','.png');
|
---|
[45] | 3257 | if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')
|
---|
[2] | 3258 | NomTypeNew='_i_j';
|
---|
| 3259 | elseif isequal(NomType,'#_ab')
|
---|
| 3260 | NomTypeNew='#a';
|
---|
| 3261 | elseif isequal(NomType,'_i1-i2')
|
---|
| 3262 | NomTypeNew='_i';
|
---|
| 3263 | end
|
---|
[86] | 3264 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
[85] | 3265 | if ~exist(imagename,'file')
|
---|
| 3266 | [FileName,PathName] = uigetfile( ...
|
---|
| 3267 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3268 | '*.jpg',' jpeg image files'; ...
|
---|
| 3269 | '*.png','.png image files'; ...
|
---|
| 3270 | '*.tif','.tif image files'; ...
|
---|
| 3271 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3272 | '*.vol','.volume images (png)'; ...
|
---|
| 3273 | '*.*', 'All Files (*.*)'}, ...
|
---|
[86] | 3274 | 'Pick an image',imagename);
|
---|
[85] | 3275 | % display the selected field and related information
|
---|
| 3276 | imagename=[PathName FileName];
|
---|
| 3277 | end
|
---|
| 3278 | display_file_name(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3279 | return
|
---|
| 3280 | % end
|
---|
| 3281 | % veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3282 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
[2] | 3283 | else
|
---|
| 3284 | ext=get(handles.FileExt,'String');
|
---|
| 3285 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
[85] | 3286 | [FileName,PathName] = uigetfile( ...
|
---|
| 3287 | {'*.nc', ' (*.nc)';
|
---|
| 3288 | '*.nc',' netcdf files'; ...
|
---|
| 3289 | '*.*', 'All Files (*.*)'}, ...
|
---|
[86] | 3290 | 'Pick a netcdf file',FileBase);
|
---|
[85] | 3291 | % display the selected field and related information
|
---|
| 3292 | filename=[PathName FileName];
|
---|
| 3293 | display_file_name(hObject, eventdata, handles,filename)
|
---|
| 3294 | return
|
---|
| 3295 | % MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
[2] | 3296 | end
|
---|
| 3297 | if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
|
---|
| 3298 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3299 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3300 | set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3301 | set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3302 | elseif isequal(field,'more...');
|
---|
| 3303 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3304 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3305 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
[45] | 3306 | [ind_answer] = listdlg('PromptString','Select a file:',...
|
---|
[2] | 3307 | 'SelectionMode','single',...
|
---|
| 3308 | 'ListString',str);
|
---|
| 3309 | % edit the choice in the field and action menu
|
---|
| 3310 | scalar=cell2mat(str(ind_answer));
|
---|
| 3311 | menu=update_menu(handles.Fields,scalar);
|
---|
| 3312 | menu=[{''};menu];
|
---|
| 3313 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3314 | end
|
---|
| 3315 | end
|
---|
[45] | 3316 | indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
[2] | 3317 | set(handles.FileIndex,'String',indices)
|
---|
| 3318 | set(handles.FileIndex,'UserData',NomTypeNew)
|
---|
| 3319 | %common to Fields_1_Callback
|
---|
[45] | 3320 | if isequal(field,'image')||isequal(field_1,'image')
|
---|
[2] | 3321 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3322 | set(handles.npy_title,'Visible','on')
|
---|
| 3323 | set(handles.npx,'Visible','on')
|
---|
| 3324 | set(handles.npy,'Visible','on')
|
---|
| 3325 | else
|
---|
| 3326 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3327 | set(handles.npy_title,'Visible','off')
|
---|
| 3328 | set(handles.npx,'Visible','off')
|
---|
| 3329 | set(handles.npy,'Visible','off')
|
---|
| 3330 | end
|
---|
| 3331 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3332 |
|
---|
[45] | 3333 | if ~isfield(UvData,'NewSeries')||isequal(UvData.NewSeries,0)
|
---|
[2] | 3334 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3335 | end
|
---|
| 3336 |
|
---|
| 3337 | %---------------------------------------------------
|
---|
| 3338 | % --- Executes on menu selection Fields
|
---|
| 3339 | function Fields_1_Callback(hObject, eventdata, handles)
|
---|
| 3340 | %-------------------------------------------------
|
---|
| 3341 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3342 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3343 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3344 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3345 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3346 | field_1= list_fields{index_fields(1)}; % selected string for the second field
|
---|
| 3347 | if isequal(field_1,'') %remove second field if 'blank' field is selected
|
---|
| 3348 | set(handles.SubField,'Value',0)
|
---|
| 3349 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 3350 | return
|
---|
| 3351 | end
|
---|
[59] | 3352 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 3353 |
|
---|
| 3354 | %read the rootfile input display
|
---|
[85] | 3355 | [FileName,RootPath,FileBase,FileIndices,FileExt_prev]=read_file_boxes_1(handles);
|
---|
| 3356 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_prev]);
|
---|
[2] | 3357 | if isempty(FileExt_prev)|isequal(FileExt_prev,'')
|
---|
| 3358 | FileExt_1=get(handles.FileExt,'String');
|
---|
| 3359 | else
|
---|
| 3360 | FileExt_1=FileExt_prev;
|
---|
| 3361 | end
|
---|
| 3362 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 3363 | if isempty(NomType_1)|isequal(NomType_1,'')
|
---|
| 3364 | NomType_1=get(handles.FileIndex,'UserData');
|
---|
| 3365 | end
|
---|
| 3366 | NomTypeNew=NomType_1;%default
|
---|
| 3367 |
|
---|
| 3368 | set(handles.SubField,'Value',1)%introduce second field
|
---|
| 3369 | if isfield(UvData,'XmlData')
|
---|
| 3370 | UvData.XmlData_1=UvData.XmlData;
|
---|
| 3371 | end
|
---|
| 3372 | set(handles.FileIndex_1,'Visible','on')
|
---|
| 3373 | set(handles.FileExt_1,'Visible','on')
|
---|
| 3374 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3375 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
[82] | 3376 | if isempty(RootPath_1)||isequal(RootPath_1,'')
|
---|
[2] | 3377 | set(handles.RootPath_1,'String','"')
|
---|
| 3378 | end
|
---|
[82] | 3379 | if isempty(RootFile_1) || isequal(RootFile_1,'')
|
---|
[2] | 3380 | set(handles.RootFile_1,'String','"')
|
---|
| 3381 | end
|
---|
[82] | 3382 | if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
|
---|
[2] | 3383 | RootFile_1(1)=[];
|
---|
| 3384 | end
|
---|
| 3385 |
|
---|
| 3386 | if isequal(field_1,'get_field...')
|
---|
| 3387 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3388 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3389 | filename=read_file_boxes_1(handles);
|
---|
| 3390 | hget_field=findobj(allchild(0),'name','get_field_1');
|
---|
| 3391 | if ~isempty(hget_field)
|
---|
| 3392 | delete(hget_field)
|
---|
| 3393 | end
|
---|
| 3394 | hget_field=get_field(filename);
|
---|
| 3395 | set(hget_field,'name','get_field_1')
|
---|
[144] | 3396 | hhget_field=guidata(hget_field);
|
---|
| 3397 | set(hhget_field.list_fig,'Value',1)
|
---|
| 3398 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
| 3399 | set(handles.transform_fct,'Value',1)% no transform by default
|
---|
| 3400 | set(handles.path_transform,'String','')
|
---|
[2] | 3401 | return %no action
|
---|
| 3402 | end
|
---|
| 3403 | if isequal(field_1,'image')
|
---|
| 3404 | % transform netc type to the corresponding image type
|
---|
[85] | 3405 | % set(handles.FileExt_1,'String','.png');
|
---|
[2] | 3406 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')| isequal(NomType_1,'#_ab')| isequal(NomType_1,'_i1-i2')
|
---|
| 3407 | UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
|
---|
[85] | 3408 | % set(handles.SubDir_1,'String','')
|
---|
[2] | 3409 | % set(handles.FileExt_1,'String','.png');
|
---|
| 3410 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')
|
---|
| 3411 | NomTypeNew='_i_j';
|
---|
| 3412 | elseif isequal(NomType_1,'#_ab')
|
---|
| 3413 | NomTypeNew='#a';
|
---|
| 3414 | elseif isequal(NomType_1,'_i1-i2')
|
---|
| 3415 | NomTypeNew='_i';
|
---|
| 3416 | end
|
---|
| 3417 | end
|
---|
[85] | 3418 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
| 3419 | if ~exist(imagename,'file')
|
---|
| 3420 | [FileName,PathName] = uigetfile( ...
|
---|
| 3421 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3422 | '*.jpg',' jpeg image files'; ...
|
---|
| 3423 | '*.png','.png image files'; ...
|
---|
| 3424 | '*.tif','.tif image files'; ...
|
---|
| 3425 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3426 | '*.vol','.volume images (png)'; ...
|
---|
| 3427 | '*.*', 'All Files (*.*)'}, ...
|
---|
[86] | 3428 | 'Pick an image',imagename);
|
---|
[85] | 3429 | % display the selected field and related information
|
---|
| 3430 | imagename=[PathName FileName];
|
---|
| 3431 | end
|
---|
| 3432 | display_file_name_1(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3433 | return
|
---|
| 3434 | % veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3435 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
[2] | 3436 | else
|
---|
| 3437 | set(handles.SubDir_1,'Visible','on')
|
---|
| 3438 | if ~isequal(FileExt_prev,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 3439 | veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3440 | set_veltype_display(veltype_handles,6); % make all civ buttons visible
|
---|
| 3441 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3442 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3443 | if isempty(RootPath_1)|isequal(RootPath_1,'')
|
---|
| 3444 | set(handles.RootPath_1,'String','"')
|
---|
| 3445 | end
|
---|
| 3446 | if isempty(RootFile_1) | isequal(RootFile_1,'')
|
---|
| 3447 | set(handles.RootFile_1,'String','"')
|
---|
| 3448 | end
|
---|
| 3449 | if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 3450 | RootFile_1(1)=[];
|
---|
| 3451 | end
|
---|
| 3452 | filebase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 3453 | SubDir_1=get(handles.SubDir,'String');
|
---|
[82] | 3454 | if isempty(SubDir_1)||isequal(SubDir_1,'')
|
---|
[2] | 3455 | if isfield(UvData,'SubDir_1')
|
---|
| 3456 | SubDir_1=UvData.SubDir_1;%retrieve previous subdir
|
---|
| 3457 | else
|
---|
| 3458 | SubDir_1='?';
|
---|
| 3459 | end
|
---|
| 3460 | end
|
---|
[82] | 3461 | str1=get(handles.i1,'String');
|
---|
| 3462 | str_a=get(handles.j1,'String');
|
---|
| 3463 | if isequal(NomType_1,'#_ab')||isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')||isequal(NomType_1,'_i1-i2')
|
---|
[2] | 3464 | NomTypeNew=NomType_1;
|
---|
| 3465 | elseif isequal(NomType_1,'#a')
|
---|
[82] | 3466 | [filename, n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),stra2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
|
---|
[2] | 3467 | NomTypeNew='#_ab';
|
---|
| 3468 | elseif isequal(NomType_1,'_i_j')
|
---|
[82] | 3469 | [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2_j',0,str2num(str1),[],SubDir_1);
|
---|
[2] | 3470 | if idetect==1
|
---|
| 3471 | NomTypeNew='_i1-i2_j';
|
---|
| 3472 | else
|
---|
| 3473 | NomTypeNew='_i_j1-j2';
|
---|
| 3474 | end
|
---|
| 3475 | else %for instance avi files or any ima_num series
|
---|
[82] | 3476 | [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1);
|
---|
[2] | 3477 | NomTypeNew='_i1-i2';
|
---|
| 3478 | end
|
---|
| 3479 | [Path,Name]=fileparts(filebase_1);
|
---|
| 3480 | set(handles.FileExt_1,'String','.nc');
|
---|
[86] | 3481 | if ~isempty(SubDir_1) && ~strcmp(SubDir_1,'''')&& ~strcmp(SubDir_1,'"')&& ~strcmp(SubDir_1(1),'/')
|
---|
[2] | 3482 | SubDir_1=['/' SubDir_1];
|
---|
| 3483 | end
|
---|
| 3484 | set(handles.SubDir_1,'String',SubDir_1);
|
---|
| 3485 | end
|
---|
| 3486 | if isequal(field,'vort') | isequal(field,'div') | isequal(field,'strain')
|
---|
| 3487 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3488 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3489 | set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3490 | set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3491 | elseif isequal(field_1,'more...'); %add new item to the menu
|
---|
| 3492 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3493 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3494 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 3495 | [ind_answer,v] = listdlg('PromptString','Select a file:',...
|
---|
| 3496 | 'SelectionMode','single',...
|
---|
| 3497 | 'ListString',str);
|
---|
| 3498 | % edit the choice in the field and action menu
|
---|
| 3499 | scalar=cell2mat(str(ind_answer));
|
---|
| 3500 | menu=update_menu(handles.Fields_1,scalar);
|
---|
| 3501 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3502 | end
|
---|
| 3503 | end
|
---|
| 3504 | str1=get(handles.i1,'String');
|
---|
| 3505 | str2=get(handles.i2,'String');
|
---|
| 3506 | str_a=get(handles.j1,'String');
|
---|
| 3507 | str_b=get(handles.j2,'String');
|
---|
| 3508 | indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
|
---|
| 3509 | set(handles.FileIndex_1,'String',indices)
|
---|
| 3510 | set(handles.FileIndex_1,'UserData',NomTypeNew)
|
---|
| 3511 |
|
---|
| 3512 | %common to Fields_Callback
|
---|
| 3513 | if isequal(field,'image')|isequal(field_1,'image')
|
---|
| 3514 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3515 | set(handles.npy_title,'Visible','on')
|
---|
| 3516 | set(handles.npx,'Visible','on')
|
---|
| 3517 | set(handles.npy,'Visible','on')
|
---|
[81] | 3518 | % set(handles.fix_pair,'Value',0)
|
---|
[2] | 3519 | else
|
---|
| 3520 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3521 | set(handles.npy_title,'Visible','off')
|
---|
| 3522 | set(handles.npx,'Visible','off')
|
---|
| 3523 | set(handles.npy,'Visible','off')
|
---|
[81] | 3524 | % set(handles.fix_pair,'Value',1)
|
---|
[2] | 3525 | end
|
---|
| 3526 | if isequal(field,'velocity')|isequal(field_1,'velocity');
|
---|
| 3527 | state_vect='on';
|
---|
| 3528 | else
|
---|
| 3529 | state_vect='off';
|
---|
| 3530 | end
|
---|
| 3531 | if ~isequal(field,'velocity')|(~isequal(field_1,'velocity')&~isequal(field_1,''));
|
---|
| 3532 | state_scal='on';
|
---|
| 3533 | else
|
---|
| 3534 | state_scal='off';
|
---|
| 3535 | end
|
---|
[59] | 3536 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 3537 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3538 | if ~isfield(UvData,'NewSeries')|isequal(UvData.NewSeries,0)
|
---|
| 3539 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3540 | end
|
---|
| 3541 |
|
---|
[57] | 3542 | %------------------------------------------------------------------------
|
---|
| 3543 | % --- set the visibility of relevant velocity type menus:
|
---|
| 3544 | function set_veltype_display(handles,Civ)
|
---|
| 3545 | %------------------------------------------------------------------------
|
---|
[2] | 3546 | %Civ=0; all states 'off'
|
---|
| 3547 | %Civ=6; all states 'on'
|
---|
| 3548 | if isequal(Civ,0)
|
---|
| 3549 | imax=0;
|
---|
| 3550 | % set(handles(1),'Visible','on') % unvisible civ buttons
|
---|
| 3551 | % else
|
---|
| 3552 | % set(handles(1),'String','civ1')
|
---|
| 3553 | % end
|
---|
[57] | 3554 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
[2] | 3555 | imax=1;
|
---|
[57] | 3556 | elseif isequal(Civ,3)
|
---|
[2] | 3557 | imax=3;
|
---|
[57] | 3558 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
[2] | 3559 | imax=4;
|
---|
[57] | 3560 | elseif isequal(Civ,6) %patch2
|
---|
[2] | 3561 | imax=6;
|
---|
| 3562 | end
|
---|
| 3563 | for ibutton=1:imax;
|
---|
| 3564 | set(handles(ibutton),'Visible','on') % unvisible civ buttons
|
---|
| 3565 | end
|
---|
| 3566 | % for ibutton=max(imax+1,2):6;
|
---|
| 3567 | for ibutton=imax+1:6;
|
---|
| 3568 | set(handles(ibutton),'Visible','off') % unvisible civ buttons
|
---|
| 3569 | set(handles(ibutton),'Value',0)%unactivate unvisible buttons
|
---|
| 3570 | end
|
---|
| 3571 |
|
---|
| 3572 | %-------------------------------------------------------------------
|
---|
| 3573 | % --- Executes on button press in civ1.
|
---|
| 3574 | function civ1_Callback(hObject, eventdata, handles)
|
---|
| 3575 | %-------------------------------------------------------------------
|
---|
| 3576 | if get(handles.civ1,'Value')==1
|
---|
| 3577 | reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ1)
|
---|
| 3578 | else
|
---|
| 3579 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3580 | end
|
---|
| 3581 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3582 |
|
---|
| 3583 | %-------------------------------------------------------------------
|
---|
| 3584 | % --- Executes on button press in interp1.
|
---|
| 3585 | function interp1_Callback(hObject, eventdata, handles)
|
---|
| 3586 | %-------------------------------------------------------------------
|
---|
| 3587 | if get(handles.interp1,'Value')==1
|
---|
| 3588 | reset_vel_type([handles.civ1 handles.civ2 handles.filter1 handles.interp2 handles.filter2],handles.interp1)
|
---|
| 3589 | else
|
---|
| 3590 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3591 | end
|
---|
| 3592 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3593 |
|
---|
| 3594 | %-------------------------------------------------------------------
|
---|
| 3595 | % --- Executes on button press in filter1.
|
---|
| 3596 | function filter1_Callback(hObject, eventdata, handles)
|
---|
| 3597 | %-------------------------------------------------------------------
|
---|
| 3598 | if get(handles.filter1,'Value')==1
|
---|
| 3599 | reset_vel_type([handles.civ1 handles.civ2 handles.interp1 handles.interp2 handles.filter2],handles.filter1)
|
---|
| 3600 | else
|
---|
| 3601 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3602 | end
|
---|
| 3603 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3604 |
|
---|
| 3605 | %-------------------------------------------------------------------
|
---|
| 3606 | % --- Executes on button press in civ2.
|
---|
| 3607 | function civ2_Callback(hObject, eventdata, handles)
|
---|
| 3608 | %-------------------------------------------------------------------
|
---|
| 3609 | if get(handles.civ2,'Value')==1
|
---|
| 3610 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ2)
|
---|
| 3611 | else
|
---|
| 3612 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3613 | end
|
---|
| 3614 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3615 |
|
---|
| 3616 | %-----------------------------------------
|
---|
| 3617 | % --- Executes on button press in interp2.
|
---|
| 3618 | %-------------------------------------------
|
---|
| 3619 | function interp2_Callback(hObject, eventdata, handles)
|
---|
| 3620 | if get(handles.interp2,'Value')==1
|
---|
| 3621 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.filter2],handles.interp2)
|
---|
| 3622 | else
|
---|
| 3623 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3624 | end
|
---|
| 3625 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3626 | %---------------------------------------------
|
---|
| 3627 | % --- Executes on button press in filter2.
|
---|
| 3628 | %-------------------------------------------
|
---|
| 3629 | function filter2_Callback(hObject, eventdata, handles)
|
---|
| 3630 | if get(handles.filter2,'Value')==1
|
---|
| 3631 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2],handles.filter2)
|
---|
| 3632 | else
|
---|
| 3633 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3634 | end
|
---|
| 3635 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3636 |
|
---|
| 3637 | %---------------------------------------------
|
---|
| 3638 | function civ1_1_Callback(hObject, eventdata, handles)
|
---|
| 3639 | %---------------------------------------------
|
---|
| 3640 | if get(handles.civ1_1,'Value')==1
|
---|
| 3641 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.civ1_1)
|
---|
| 3642 | else
|
---|
| 3643 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3644 | end
|
---|
| 3645 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3646 |
|
---|
| 3647 | %--------------------------------------------
|
---|
| 3648 | function interp1_1_Callback(hObject, eventdata, handles)
|
---|
| 3649 | %--------------------------------------------
|
---|
| 3650 | if get(handles.interp1_1,'Value')==1
|
---|
| 3651 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.interp1_1)
|
---|
| 3652 | else
|
---|
| 3653 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3654 | end
|
---|
| 3655 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3656 |
|
---|
| 3657 | %--------------------------------------------
|
---|
| 3658 | function filter1_1_Callback(hObject, eventdata, handles)
|
---|
| 3659 | %--------------------------------------------
|
---|
| 3660 | if get(handles.filter1_1,'Value')==1
|
---|
| 3661 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.filter1_1)
|
---|
| 3662 | else
|
---|
| 3663 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3664 | end
|
---|
| 3665 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3666 |
|
---|
| 3667 | %--------------------------------------------
|
---|
| 3668 | function civ2_1_Callback(hObject, eventdata, handles)
|
---|
| 3669 | %--------------------------------------------
|
---|
| 3670 | if get(handles.civ2_1,'Value')==1
|
---|
| 3671 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.civ2_1)
|
---|
| 3672 | else
|
---|
| 3673 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3674 | end
|
---|
| 3675 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3676 |
|
---|
| 3677 | %--------------------------------------------
|
---|
| 3678 | function interp2_1_Callback(hObject, eventdata, handles)
|
---|
| 3679 | %--------------------------------------------
|
---|
| 3680 | if get(handles.interp2_1,'Value')==1
|
---|
| 3681 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.filter2_1],handles.interp2_1)
|
---|
| 3682 | else
|
---|
| 3683 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3684 | end
|
---|
| 3685 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3686 |
|
---|
| 3687 | %--------------------------------------------
|
---|
| 3688 | function filter2_1_Callback(hObject, eventdata, handles)
|
---|
| 3689 | %--------------------------------------------
|
---|
| 3690 | if get(handles.filter2_1,'Value')==1
|
---|
| 3691 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1],handles.filter2_1)
|
---|
| 3692 | else
|
---|
| 3693 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3694 | end
|
---|
| 3695 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3696 |
|
---|
| 3697 | %-----------------------------------------------
|
---|
| 3698 | % --- reset civ buttons
|
---|
| 3699 | function reset_vel_type(handles_civ0,handle1)
|
---|
| 3700 | for ibutton=1:length(handles_civ0)
|
---|
| 3701 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 3702 | set(handles_civ0(ibutton),'Value',0)
|
---|
| 3703 | end
|
---|
| 3704 | if exist('handle1','var')%handles of selected button
|
---|
| 3705 | set(handle1,'BackgroundColor',[1 1 0])
|
---|
| 3706 | end
|
---|
| 3707 |
|
---|
| 3708 | %-------------------------------------------------------
|
---|
| 3709 | % --- Executes on button press in MENUVOLUME.
|
---|
| 3710 | %-------------------------------------------------------
|
---|
| 3711 | function VOLUME_Callback(hObject, eventdata, handles)
|
---|
| 3712 | %errordlg('command VOL not implemented yet')
|
---|
| 3713 | if ishandle(handles.UVMAT_title)
|
---|
| 3714 | delete(handles.UVMAT_title)
|
---|
| 3715 | end
|
---|
[61] | 3716 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 3717 | if isequal(get(handles.VOLUME,'Value'),1)
|
---|
| 3718 | set(handles.zoom,'Value',0)
|
---|
| 3719 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3720 | set(handles.edit_vect,'Value',0)
|
---|
| 3721 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3722 | set(handles.edit,'Value',0)
|
---|
| 3723 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[61] | 3724 | % set(handles.cal,'Value',0)
|
---|
| 3725 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
[2] | 3726 | set(handles.edit_vect,'Value',0)
|
---|
| 3727 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3728 | %initiate set_object GUI
|
---|
| 3729 | data.TITLE='VOLUME';
|
---|
| 3730 | if isfield(UvData,'CoordType')
|
---|
| 3731 | data.CoordType=UvData.CoordType;
|
---|
| 3732 | end
|
---|
| 3733 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 3734 | data.RangeY=UvData.Mesh;
|
---|
| 3735 | data.RangeX=UvData.Mesh;
|
---|
| 3736 | data.DX=UvData.Mesh;
|
---|
| 3737 | data.DY=UvData.Mesh;
|
---|
| 3738 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
| 3739 | np=size(UvData.Field.A);
|
---|
| 3740 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 3741 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 3742 | data.RangeY=max(meshx,meshy);
|
---|
| 3743 | data.RangeX=max(meshx,meshy);
|
---|
| 3744 | data.DX=max(meshx,meshy);
|
---|
| 3745 | end
|
---|
| 3746 | data.ParentButton=handles.VOLUME;
|
---|
| 3747 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 3748 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
|
---|
| 3749 | % associate the set_edit interface handle to the plotting axes
|
---|
| 3750 | if isfield(UvData,'SetObjectOrigin')
|
---|
| 3751 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3752 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 3753 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 3754 | set(hset_object,'Position',pos_set_object)
|
---|
| 3755 | end
|
---|
| 3756 | UvData.MouseAction='create_object';
|
---|
| 3757 | else
|
---|
| 3758 | set(handles.VOLUME,'BackgroundColor',[0 1 0])
|
---|
| 3759 | UvData.MouseAction='none';
|
---|
| 3760 | end
|
---|
| 3761 | set(huvmat,'UserData',UvData)
|
---|
| 3762 |
|
---|
| 3763 | %-------------------------------------------------------
|
---|
| 3764 | function edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3765 | %-------------------------------------------------------
|
---|
[55] | 3766 |
|
---|
| 3767 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 3768 | if isequal(get(handles.edit_vect,'Value'),1)
|
---|
[55] | 3769 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
| 3770 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 3771 | if ~test_civ2 && ~test_civ1
|
---|
| 3772 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 3773 | end
|
---|
[2] | 3774 | set(handles.record,'Visible','on')
|
---|
| 3775 | set(handles.edit_vect,'BackgroundColor',[1 1 0])
|
---|
| 3776 | set(handles.edit,'Value',0)
|
---|
[61] | 3777 | set(handles.zoom,'Value',0)
|
---|
| 3778 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3779 | % set(handles.create,'Value',0)
|
---|
| 3780 | % set(handles.create,'BackgroundColor',[0 1 0])
|
---|
[2] | 3781 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3782 | set(gcf,'Pointer','arrow')
|
---|
| 3783 | UvData.MouseAction='edit_vect';
|
---|
| 3784 | else
|
---|
| 3785 | set(handles.record,'Visible','off')
|
---|
| 3786 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3787 | UvData.MouseAction='none';
|
---|
| 3788 | end
|
---|
[55] | 3789 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 3790 |
|
---|
| 3791 | %----------------------------------------------
|
---|
| 3792 | function save_mask_Callback(hObject, eventdata, handles)
|
---|
| 3793 | %-----------------------------------------------------------------------
|
---|
[82] | 3794 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 3795 |
|
---|
| 3796 | flag=1;
|
---|
| 3797 | npx=size(UvData.Field.A,2);
|
---|
| 3798 | npy=size(UvData.Field.A,1);
|
---|
| 3799 | xi=[0.5:npx-0.5];
|
---|
| 3800 | yi=[0.5:npy-0.5];
|
---|
| 3801 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 3802 | if isfield(UvData,'Object')
|
---|
| 3803 | for iobj=1:length(UvData.Object)
|
---|
| 3804 | ObjectData=UvData.Object{iobj};
|
---|
| 3805 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 3806 | flagobj=1;
|
---|
| 3807 | testphys=0; %coordinates in pixels by default
|
---|
| 3808 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
| 3809 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 3810 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 3811 | testphys=1;
|
---|
| 3812 | end
|
---|
| 3813 | end
|
---|
| 3814 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 3815 | if isequal(ObjectData.Style,'polygon')
|
---|
| 3816 | X=ObjectData.Coord(:,1);
|
---|
| 3817 | Y=ObjectData.Coord(:,2);
|
---|
| 3818 | if testphys
|
---|
| 3819 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 3820 | end
|
---|
[82] | 3821 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
[2] | 3822 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 3823 | if testphys
|
---|
| 3824 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3825 | end
|
---|
| 3826 | RangeX=max(ObjectData.RangeX);
|
---|
| 3827 | RangeY=max(ObjectData.RangeY);
|
---|
| 3828 | X2Max=RangeX*RangeX;
|
---|
| 3829 | Y2Max=RangeY*RangeY;
|
---|
| 3830 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 3831 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 3832 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 3833 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 3834 | if testphys
|
---|
| 3835 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3836 | end
|
---|
| 3837 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 3838 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 3839 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 3840 | end
|
---|
| 3841 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 3842 | flagobj=~flagobj;
|
---|
| 3843 | end
|
---|
| 3844 | flag=flag & flagobj;
|
---|
| 3845 | end
|
---|
| 3846 | end
|
---|
| 3847 | end
|
---|
| 3848 | end
|
---|
| 3849 | % flag=~flag;
|
---|
| 3850 | %mask name
|
---|
| 3851 | RootPath=get(handles.RootPath,'String');
|
---|
| 3852 | RootFile=get(handles.RootFile,'String');
|
---|
| 3853 | if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
|
---|
| 3854 | RootFile(1)=[];
|
---|
| 3855 | end
|
---|
| 3856 | filebase=fullfile(RootPath,RootFile);
|
---|
| 3857 | list=get(handles.masklevel,'String');
|
---|
| 3858 | masknumber=num2str(length(list));
|
---|
| 3859 | maskindex=get(handles.masklevel,'Value');
|
---|
| 3860 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 3861 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 3862 | imflag=flipdim(imflag,1);
|
---|
| 3863 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)
|
---|
[38] | 3864 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved'])
|
---|
[2] | 3865 | imwrite(imflag,mask_name,'BitDepth',8);
|
---|
| 3866 |
|
---|
| 3867 | %display the mask
|
---|
| 3868 | %update_mask(handles,num_i1,num_j1)
|
---|
| 3869 | figure;
|
---|
| 3870 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 3871 | map=[vec' vec' vec'];
|
---|
| 3872 | colormap(map)
|
---|
| 3873 |
|
---|
| 3874 | image(imflag);
|
---|
| 3875 |
|
---|
| 3876 | %-------------------------------------------------------------------
|
---|
| 3877 | %-------------------------------------------------------------------
|
---|
| 3878 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
| 3879 |
|
---|
| 3880 | %------------------------------------------------------------------
|
---|
| 3881 |
|
---|
| 3882 |
|
---|
| 3883 |
|
---|
| 3884 | %------------------------------------------------------------------
|
---|
| 3885 | % --- Executes on selection change in col_vec: choice of the color code.
|
---|
| 3886 | %
|
---|
| 3887 | function col_vec_Callback(hObject, eventdata, handles)
|
---|
| 3888 | %------------------------------------------------------------------
|
---|
| 3889 | % edit the choice for color code
|
---|
| 3890 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 3891 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 3892 | col_code= list_code{index_code(1)}; % selected field
|
---|
[122] | 3893 | if isequal(col_code,'black') || isequal(col_code,'white')
|
---|
[2] | 3894 | set(handles.slider1,'Visible','off')
|
---|
| 3895 | set(handles.slider2,'Visible','off')
|
---|
| 3896 | set(handles.colcode1,'Visible','off')
|
---|
| 3897 | set(handles.colcode2,'Visible','off')
|
---|
| 3898 | set(handles.AutoVecColor,'Visible','off')
|
---|
| 3899 | set_vec_col_bar(handles)
|
---|
| 3900 | else
|
---|
| 3901 | set(handles.slider1,'Visible','on')
|
---|
| 3902 | set(handles.slider2,'Visible','on')
|
---|
| 3903 | set(handles.colcode1,'Visible','on')
|
---|
| 3904 | set(handles.colcode2,'Visible','on')
|
---|
| 3905 | set(handles.AutoVecColor,'Visible','on')
|
---|
| 3906 | if isequal(col_code,'ima_cor')
|
---|
| 3907 | set(handles.AutoVecColor,'Value',0)%fixed scale by default
|
---|
| 3908 | set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
|
---|
| 3909 | set(handles.slider1,'Min',0);
|
---|
| 3910 | set(handles.slider1,'Max',1);
|
---|
| 3911 | set(handles.slider2,'Min',0);
|
---|
| 3912 | set(handles.slider2,'Max',1);
|
---|
| 3913 | % set(handles.min_title_vec,'String','0')
|
---|
| 3914 | set(handles.max_vec,'String','1')
|
---|
| 3915 | set(handles.colcode1,'String','0.333')
|
---|
| 3916 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3917 | set(handles.colcode2,'String','0.666')
|
---|
| 3918 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3919 | else
|
---|
| 3920 | set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
|
---|
| 3921 | set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
|
---|
| 3922 | minval=get(handles.slider1,'Min');
|
---|
| 3923 | maxval=get(handles.slider1,'Max');
|
---|
| 3924 | set(handles.slider1,'Value',minval)
|
---|
| 3925 | set(handles.slider2,'Value',maxval)
|
---|
| 3926 | set_vec_col_bar(handles)
|
---|
| 3927 | end
|
---|
| 3928 | % slider_update(handles)
|
---|
| 3929 | end
|
---|
| 3930 | %replot the current graph
|
---|
| 3931 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3932 |
|
---|
| 3933 |
|
---|
| 3934 | %----------------------------------------------------------------
|
---|
| 3935 | % -- Executes on slider movement to set the color code
|
---|
| 3936 | %
|
---|
| 3937 | function slider1_Callback(hObject, eventdata, handles)
|
---|
| 3938 | %------------------------------------------------------------------
|
---|
| 3939 | slider1=get(handles.slider1,'Value');
|
---|
| 3940 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3941 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3942 | col=min_val+(max_val-min_val)*slider1;
|
---|
| 3943 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3944 | if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
| 3945 | set(handles.slider2,'Value',col)
|
---|
| 3946 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3947 | end
|
---|
| 3948 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3949 |
|
---|
| 3950 | %----------------------------------------------------------------
|
---|
| 3951 | % Executes on slider movement to set the color code
|
---|
| 3952 | %----------------------------------------------------------------
|
---|
| 3953 | function slider2_Callback(hObject, eventdata, handles)
|
---|
| 3954 | slider2=get(handles.slider2,'Value');
|
---|
| 3955 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3956 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3957 | col=min_val+(max_val-min_val)*slider2;
|
---|
| 3958 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3959 | if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
| 3960 | set(handles.slider1,'Value',col)
|
---|
| 3961 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3962 | end
|
---|
| 3963 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3964 |
|
---|
| 3965 | %----------------------------------------------------------------
|
---|
| 3966 | %execute on return carriage on the edit box corresponding to slider 1
|
---|
| 3967 | %----------------------------------------------------------------
|
---|
| 3968 | function colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3969 | % col=str2num(get(handles.colcode1,'String'));
|
---|
| 3970 | % set(handles.slider1,'Value',col)
|
---|
| 3971 | set_vec_col_bar(handles)
|
---|
[89] | 3972 | update_plot(handles);
|
---|
[2] | 3973 |
|
---|
| 3974 | %----------------------------------------------------------------
|
---|
| 3975 | %execute on return carriage on the edit box corresponding to slider 2
|
---|
| 3976 | %----------------------------------------------------------------
|
---|
| 3977 | function colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3978 | % col=str2num(get(handles.colcode2,'String'));
|
---|
| 3979 | % set(handles.slider2,'Value',col)
|
---|
| 3980 | % slider2_Callback(hObject, eventdata, handles)
|
---|
| 3981 | set_vec_col_bar(handles)
|
---|
[89] | 3982 | update_plot(handles);
|
---|
[2] | 3983 | %------------------------------------------------------------
|
---|
| 3984 | %update the slider values after displaying vectors
|
---|
| 3985 | %--------------------------------------------------------
|
---|
| 3986 | % function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
|
---|
| 3987 | % set(handles.slider1,'Min',minC)
|
---|
| 3988 | % set(handles.slider1,'Max',maxC)
|
---|
| 3989 | % set(handles.slider2,'Min',minC)
|
---|
| 3990 | % set(handles.slider2,'Max',maxC)
|
---|
| 3991 | % set(handles.min_title_vec,'String',num2str(minC))
|
---|
| 3992 | % set(handles.max_vec,'String',num2str(maxC))
|
---|
| 3993 | % if auto
|
---|
| 3994 | % set(handles.colcode1,'String',num2str(colcode1,3))%update display
|
---|
| 3995 | % set(handles.colcode2,'String',num2str(colcode2,3))
|
---|
| 3996 | % end
|
---|
| 3997 | % set(handles.slider1,'Value',colcode1)%update slider with constant display
|
---|
| 3998 | % set(handles.slider2,'Value',colcode2)
|
---|
| 3999 | % set_vec_col_bar(handles)
|
---|
| 4000 |
|
---|
| 4001 |
|
---|
| 4002 | %-------------------------------------------------------
|
---|
| 4003 | % --- Executes on button press in AutoVecColor.
|
---|
| 4004 | %-------------------------------------------------------
|
---|
| 4005 | function vec_col_bar_Callback(hObject, eventdata, handles)
|
---|
| 4006 | set_vec_col_bar(handles)
|
---|
| 4007 |
|
---|
| 4008 | %-------------------------------------------------------------
|
---|
[39] | 4009 | % --- Executes on selection change in transform_fct.
|
---|
| 4010 | function transform_fct_Callback(hObject, eventdata, handles)
|
---|
[2] | 4011 | %-------------------------------------------------------------
|
---|
[39] | 4012 | global nb_builtin
|
---|
| 4013 |
|
---|
| 4014 | huvmat=get(handles.transform_fct,'parent');
|
---|
| 4015 | menu=get(handles.transform_fct,'String');
|
---|
| 4016 | ind_coord=get(handles.transform_fct,'Value');
|
---|
[2] | 4017 | coord_option=menu{ind_coord};
|
---|
[39] | 4018 | list_transform=get(handles.transform_fct,'UserData');
|
---|
[40] | 4019 | ff=functions(list_transform{end});
|
---|
[2] | 4020 | if isequal(coord_option,'more...');
|
---|
| 4021 | coord_fct='';
|
---|
| 4022 | prompt = {'Enter the name of the transform function'};
|
---|
| 4023 | dlg_title = 'user defined transform';
|
---|
| 4024 | num_lines= 1;
|
---|
[89] | 4025 | [FileName, PathName] = uigetfile( ...
|
---|
[2] | 4026 | {'*.m', ' (*.m)';
|
---|
| 4027 | '*.m', '.m files '; ...
|
---|
| 4028 | '*.*', 'All Files (*.*)'}, ...
|
---|
[39] | 4029 | 'Pick a file', ff.file);
|
---|
[2] | 4030 | if isequal(PathName(end),'/')||isequal(PathName(end),'\')
|
---|
| 4031 | PathName(end)=[];
|
---|
| 4032 | end
|
---|
[39] | 4033 | transform_selected =fullfile(PathName,FileName);
|
---|
| 4034 | if ~exist(transform_selected,'file')
|
---|
| 4035 | return
|
---|
| 4036 | end
|
---|
| 4037 | [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m
|
---|
| 4038 | if ~isequal(ext_fct,'.m')
|
---|
| 4039 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
| 4040 | return
|
---|
| 4041 | end
|
---|
| 4042 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
|
---|
| 4043 | ind_coord=get(handles.transform_fct,'Value');
|
---|
| 4044 | addpath(PathName)
|
---|
| 4045 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
|
---|
| 4046 | set(handles.transform_fct,'UserData',list_transform)
|
---|
| 4047 | rmpath(PathName)
|
---|
| 4048 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
| 4049 | dir_perso=prefdir;%personal Matalb directory
|
---|
| 4050 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 4051 | if exist(profil_perso,'file')
|
---|
| 4052 | for ilist=nb_builtin+1:numel(list_transform)
|
---|
| 4053 | ff=functions(list_transform{ilist});
|
---|
| 4054 | transform_fct{ilist-nb_builtin}=ff.file;
|
---|
| 4055 | end
|
---|
| 4056 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
|
---|
| 4057 | end
|
---|
[2] | 4058 | end
|
---|
| 4059 |
|
---|
| 4060 | %check the current path to the selected function
|
---|
[40] | 4061 | if isa(list_transform{ind_coord},'function_handle')
|
---|
| 4062 | func=functions(list_transform{ind_coord});
|
---|
| 4063 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
|
---|
| 4064 | else
|
---|
| 4065 | set(handles.path_transform,'String','')
|
---|
| 4066 | end
|
---|
[71] | 4067 |
|
---|
[2] | 4068 | set(handles.FixedLimits,'Value',0)
|
---|
| 4069 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4070 |
|
---|
| 4071 | UvData=get(huvmat,'UserData');
|
---|
| 4072 |
|
---|
| 4073 | %delete drawn objects
|
---|
| 4074 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 4075 | for iobj=1:length(hother)
|
---|
| 4076 | delete_object(hother(iobj))
|
---|
| 4077 | end
|
---|
| 4078 | hother=findobj('Tag','DeformPoint');%find all the proj objects
|
---|
| 4079 | for iobj=1:length(hother)
|
---|
| 4080 | delete_object(hother(iobj))
|
---|
| 4081 | end
|
---|
| 4082 | hh=findobj('Tag','calib_points');
|
---|
| 4083 | if ~isempty(hh)
|
---|
| 4084 | delete(hh)
|
---|
| 4085 | end
|
---|
| 4086 | hhh=findobj('Tag','calib_marker');
|
---|
| 4087 | if ~isempty(hhh)
|
---|
| 4088 | delete(hhh)
|
---|
| 4089 | end
|
---|
| 4090 | if isfield(UvData,'Object')
|
---|
[71] | 4091 | UvData.Object=UvData.Object(1);
|
---|
[2] | 4092 | end
|
---|
[71] | 4093 | list_object=get(handles.list_object_1,'String');
|
---|
| 4094 | set(handles.list_object_1,'Value',1)
|
---|
| 4095 | set(handles.list_object_1,'String',list_object(1))
|
---|
| 4096 | set(handles.list_object_2,'Value',2)
|
---|
| 4097 | set(handles.list_object_2,'String',[list_object(1);{'...'}])
|
---|
| 4098 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
[2] | 4099 |
|
---|
| 4100 | %delete mask if it is displayed
|
---|
| 4101 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 4102 | UvData=rmfield(UvData,'MaskName'); %will impose mask refresh
|
---|
| 4103 | end
|
---|
| 4104 | set(huvmat,'UserData',UvData)
|
---|
| 4105 | run0_Callback(hObject, eventdata, handles)
|
---|
| 4106 |
|
---|
| 4107 | %--------------------------------------------
|
---|
| 4108 | function histo1_menu_Callback(hObject, eventdata, handles)
|
---|
| 4109 | %--------------------------------------------
|
---|
| 4110 | %plot first histo
|
---|
| 4111 | huvmat=get(handles.histo1_menu,'parent');
|
---|
| 4112 | histo_menu=get(handles.histo1_menu,'String');
|
---|
| 4113 | histo_value=get(handles.histo1_menu,'Value');
|
---|
| 4114 | FieldName=histo_menu{histo_value};
|
---|
[128] | 4115 | % UvData=get(huvmat,'UserData');
|
---|
[2] | 4116 | update_histo(handles.histo_u,huvmat,FieldName)
|
---|
| 4117 |
|
---|
| 4118 | %----------------------------------------------
|
---|
| 4119 | function histo2_menu_Callback(hObject, eventdata, handles)
|
---|
| 4120 | %----------------------------------------------
|
---|
| 4121 | %plot second histo
|
---|
| 4122 | huvmat=get(handles.histo2_menu,'parent');
|
---|
| 4123 | histo_menu=get(handles.histo2_menu,'String');
|
---|
| 4124 | histo_value=get(handles.histo2_menu,'Value');
|
---|
| 4125 | FieldName=histo_menu{histo_value};
|
---|
[128] | 4126 | % UvData=get(huvmat,'UserData');
|
---|
[2] | 4127 | update_histo(handles.histo_v,huvmat,FieldName)
|
---|
| 4128 |
|
---|
| 4129 |
|
---|
| 4130 | %--------------------------------------------
|
---|
| 4131 | %read the field .Fieldname stored in UvData and plot its histogram
|
---|
| 4132 | function update_histo(haxes,huvmat,FieldName)
|
---|
| 4133 | UvData=get(huvmat,'UserData');
|
---|
| 4134 | if ~isfield(UvData.Field,FieldName)
|
---|
| 4135 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram'])
|
---|
| 4136 | return
|
---|
| 4137 | end
|
---|
| 4138 | Field=UvData.Field;
|
---|
| 4139 | FieldHisto=eval(['Field.' FieldName]);
|
---|
[128] | 4140 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto))
|
---|
[2] | 4141 | indsel=find(Field.FF==0);%find values marked as false
|
---|
| 4142 | if ~isempty(indsel)
|
---|
| 4143 | FieldHisto=FieldHisto(indsel);
|
---|
| 4144 | end
|
---|
| 4145 | end
|
---|
| 4146 | if isempty(Field)
|
---|
| 4147 | msgbox_uvmat('ERROR',['empty field ' FieldName])
|
---|
| 4148 | else
|
---|
| 4149 | nxy=size(FieldHisto);
|
---|
| 4150 | Amin=double(min(min(min(FieldHisto))));%min of image
|
---|
| 4151 | Amax=double(max(max(max(FieldHisto))));%max of image
|
---|
| 4152 | if isequal(Amin,Amax)
|
---|
| 4153 | Histo.Txt=['uniform field =' num2str(Amin)];
|
---|
| 4154 | else
|
---|
| 4155 | Histo.ListVarName={FieldName,'histo'};
|
---|
| 4156 | if numel(nxy)==2
|
---|
| 4157 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
| 4158 | else %color images
|
---|
| 4159 | Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
|
---|
| 4160 | end
|
---|
| 4161 | %unit
|
---|
| 4162 | units=[]; %default
|
---|
| 4163 | for ivar=1:numel(Field.ListVarName)
|
---|
| 4164 | if strcmp(Field.ListVarName{ivar},FieldName)
|
---|
| 4165 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
|
---|
| 4166 | units=Field.VarAttribute{ivar}.units;
|
---|
| 4167 | break
|
---|
| 4168 | end
|
---|
| 4169 | end
|
---|
| 4170 | end
|
---|
| 4171 | if ~isempty(units)
|
---|
| 4172 | Histo.VarAttribute{1}.units=units;
|
---|
| 4173 | end
|
---|
| 4174 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
|
---|
| 4175 | for col=1:size(FieldHisto,3)
|
---|
| 4176 | B=FieldHisto(:,:,col);
|
---|
| 4177 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
|
---|
| 4178 | eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
| 4179 | end
|
---|
| 4180 | set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
|
---|
| 4181 | set(haxes,'YLimMode','auto')
|
---|
| 4182 | plot_field(Histo,haxes);
|
---|
| 4183 | end
|
---|
| 4184 | end
|
---|
| 4185 |
|
---|
| 4186 |
|
---|
| 4187 |
|
---|
| 4188 | %------------------------------------------------
|
---|
| 4189 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
| 4190 | %-------------------------------------------------
|
---|
| 4191 |
|
---|
| 4192 | %-----------------------------------------------------------------
|
---|
| 4193 | function MinA_Callback(hObject, eventdata, handles)
|
---|
| 4194 | %------------------------------------------
|
---|
| 4195 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
| 4196 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
[89] | 4197 | update_plot(handles);
|
---|
[2] | 4198 |
|
---|
| 4199 | %-----------------------------------------------------------------
|
---|
| 4200 | function MaxA_Callback(hObject, eventdata, handles)
|
---|
| 4201 | %--------------------------------------------
|
---|
| 4202 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
| 4203 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
[89] | 4204 | update_plot(handles);
|
---|
[2] | 4205 |
|
---|
| 4206 | %-----------------------------------------------
|
---|
| 4207 | function AutoScal_Callback(hObject, eventdata, handles)
|
---|
| 4208 | %--------------------------------------------
|
---|
| 4209 | test=get(handles.AutoScal,'Value');
|
---|
| 4210 | if test
|
---|
| 4211 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 4212 | else
|
---|
| 4213 | set(handles.AutoScal,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4214 | update_plot(handles);
|
---|
| 4215 | end
|
---|
| 4216 |
|
---|
| 4217 | %-------------------------------------------------------------------
|
---|
| 4218 | function BW_Callback(hObject, eventdata, handles)
|
---|
| 4219 | %-------------------------------------------------------------------
|
---|
[89] | 4220 | update_plot(handles);
|
---|
[2] | 4221 |
|
---|
| 4222 | %-------------------------------------------------------------------
|
---|
| 4223 | function Contours_Callback(hObject, eventdata, handles)
|
---|
| 4224 | %-------------------------------------------------------------------
|
---|
| 4225 | val=get(handles.Contours,'Value');
|
---|
| 4226 | if val==2
|
---|
| 4227 | set(handles.interval_txt,'Visible','on')
|
---|
| 4228 | set(handles.IncrA,'Visible','on')
|
---|
| 4229 | else
|
---|
| 4230 | set(handles.interval_txt,'Visible','off')
|
---|
| 4231 | set(handles.IncrA,'Visible','off')
|
---|
| 4232 | end
|
---|
[89] | 4233 | update_plot(handles);
|
---|
[2] | 4234 |
|
---|
| 4235 | %-------------------------------------------------------------------
|
---|
| 4236 | function IncrA_Callback(hObject, eventdata, handles)
|
---|
| 4237 | %-------------------------------------------------------------------
|
---|
[89] | 4238 | update_plot(handles);
|
---|
[2] | 4239 |
|
---|
| 4240 | %-------------------------------------------------------------------
|
---|
| 4241 | function HideWarning_Callback(hObject, eventdata, handles)
|
---|
| 4242 | %-------------------------------------------------------------------
|
---|
[89] | 4243 | update_plot(handles);
|
---|
[2] | 4244 |
|
---|
| 4245 | %-------------------------------------------------------------------
|
---|
| 4246 | function HideFalse_Callback(hObject, eventdata, handles)
|
---|
| 4247 | %-------------------------------------------------------------------
|
---|
[89] | 4248 | update_plot(handles);
|
---|
[2] | 4249 |
|
---|
| 4250 | %-------------------------------------------------------------------
|
---|
| 4251 | function VecScale_Callback(hObject, eventdata, handles)
|
---|
| 4252 | %-------------------------------------------------------------------
|
---|
| 4253 | set(handles.AutoVec,'Value',1);
|
---|
| 4254 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
[89] | 4255 | update_plot(handles);
|
---|
[2] | 4256 |
|
---|
| 4257 | %-------------------------------------------------------------------
|
---|
| 4258 | function AutoVec_Callback(hObject, eventdata, handles)
|
---|
| 4259 | %-------------------------------------------------------------------
|
---|
| 4260 | test=get(handles.AutoVec,'Value');
|
---|
| 4261 | if test
|
---|
| 4262 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
| 4263 | else
|
---|
| 4264 | update_plot(handles);
|
---|
| 4265 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4266 | set(handles.AutoVec,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4267 | end
|
---|
| 4268 |
|
---|
[89] | 4269 | %------------------------------------------------------------------------
|
---|
[2] | 4270 | % --- Executes on selection change in decimate4 (nb_vec/4).
|
---|
| 4271 | function decimate4_Callback(hObject, eventdata, handles)
|
---|
[89] | 4272 | %------------------------------------------------------------------------
|
---|
| 4273 | update_plot(handles);
|
---|
[2] | 4274 |
|
---|
[89] | 4275 | %------------------------------------------------------------------------
|
---|
[2] | 4276 | % --- Executes on selection change in color_code menu
|
---|
| 4277 | function color_code_Callback(hObject, eventdata, handles)
|
---|
[89] | 4278 | %------------------------------------------------------------------------
|
---|
[2] | 4279 | set_vec_col_bar(handles)
|
---|
| 4280 | update_plot(handles);
|
---|
| 4281 |
|
---|
[89] | 4282 | %------------------------------------------------------------------------
|
---|
[2] | 4283 | % --- Executes on button press in AutoVecColor.
|
---|
| 4284 | function AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
[89] | 4285 | %------------------------------------------------------------------------
|
---|
[2] | 4286 | test=get(handles.AutoVecColor,'Value');
|
---|
| 4287 | if test
|
---|
| 4288 | set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
|
---|
| 4289 | else
|
---|
| 4290 | update_plot(handles);
|
---|
| 4291 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4292 | set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4293 | end
|
---|
| 4294 |
|
---|
[89] | 4295 | %------------------------------------------------------------------------
|
---|
[2] | 4296 | % --- Executes on selection change in max_vec.
|
---|
| 4297 | function min_vec_Callback(hObject, eventdata, handles)
|
---|
[89] | 4298 | %------------------------------------------------------------------------
|
---|
[2] | 4299 | max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4300 |
|
---|
[89] | 4301 | %------------------------------------------------------------------------
|
---|
[2] | 4302 | % --- Executes on selection change in max_vec.
|
---|
| 4303 | function max_vec_Callback(hObject, eventdata, handles)
|
---|
[89] | 4304 | %------------------------------------------------------------------------
|
---|
[2] | 4305 | set(handles.AutoVecColor,'Value',1)
|
---|
| 4306 | AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4307 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 4308 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 4309 | slider1=get(handles.slider1,'Value');
|
---|
| 4310 | slider2=get(handles.slider2,'Value');
|
---|
| 4311 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
| 4312 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
| 4313 | set(handles.colcode1,'String',num2str(colcode1))
|
---|
| 4314 | set(handles.colcode2,'String',num2str(colcode2))
|
---|
| 4315 | update_plot(handles);
|
---|
| 4316 |
|
---|
[89] | 4317 | %------------------------------------------------------------------------
|
---|
| 4318 | % --- update the display of color code for vectors
|
---|
[2] | 4319 | function set_vec_col_bar(handles)
|
---|
[89] | 4320 | %------------------------------------------------------------------------
|
---|
[2] | 4321 | %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 4322 | set(handles.vec_col_bar,'Unit','pixel');
|
---|
| 4323 | pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 4324 | set(handles.vec_col_bar,'Unit','Normalized');
|
---|
| 4325 | width=ceil(pos_vert(3));
|
---|
| 4326 | height=ceil(pos_vert(4));
|
---|
| 4327 |
|
---|
| 4328 | %get slider indications
|
---|
| 4329 | list=get(handles.color_code,'String');
|
---|
| 4330 | ichoice=get(handles.color_code,'Value');
|
---|
| 4331 | colcode.ColorCode=list{ichoice};
|
---|
| 4332 | colcode.MinC=str2num(get(handles.min_vec,'String'));
|
---|
| 4333 | colcode.MaxC=str2num(get(handles.max_vec,'String'));
|
---|
| 4334 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
|
---|
| 4335 | if test3color
|
---|
| 4336 | colcode.colcode1=str2num(get(handles.colcode1,'String'));
|
---|
| 4337 | colcode.colcode2=str2num(get(handles.colcode2,'String'));
|
---|
| 4338 | end
|
---|
| 4339 | % colcode.option=get(handles.vec_col_bar,'Value');
|
---|
| 4340 | colcode.FixedCbounds=0;
|
---|
| 4341 | % list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 4342 | % index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 4343 | % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
|
---|
| 4344 | colcode.FixedCbounds=1;
|
---|
| 4345 | vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
| 4346 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 4347 | oneheight=ones(1,height);
|
---|
| 4348 | A1=colorlist(col_vec,1)*oneheight;
|
---|
| 4349 | A2=colorlist(col_vec,2)*oneheight;
|
---|
| 4350 | A3=colorlist(col_vec,3)*oneheight;
|
---|
| 4351 | A(:,:,1)=A1';
|
---|
| 4352 | A(:,:,2)=A2';
|
---|
| 4353 | A(:,:,3)=A3';
|
---|
| 4354 | set(handles.vec_col_bar,'Cdata',A)
|
---|
| 4355 |
|
---|
| 4356 |
|
---|
| 4357 | %-------------------------------------------------------------------
|
---|
[132] | 4358 | function update_plot(handles)
|
---|
[2] | 4359 | %-------------------------------------------------------------------
|
---|
| 4360 | haxes= handles.axes3;
|
---|
| 4361 | AxeData=get(haxes,'UserData');
|
---|
| 4362 | PlotParam=read_plot_param(handles);
|
---|
| 4363 | [PlotType,PlotParamOut]= plot_field(AxeData,haxes,PlotParam,1);
|
---|
| 4364 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
| 4365 |
|
---|
| 4366 | %-------------------------------------------------------------------
|
---|
| 4367 | % --- Executes on button press in grid.
|
---|
| 4368 | function grid_Callback(hObject, eventdata, handles)
|
---|
| 4369 |
|
---|
[61] | 4370 |
|
---|
[2] | 4371 |
|
---|
| 4372 | %-------------------------------------------------------------------
|
---|
| 4373 | % --- Executes on selection change in edit.
|
---|
| 4374 | function edit_Callback(hObject, eventdata, handles)
|
---|
| 4375 | %-------------------------------------------------------------------
|
---|
[61] | 4376 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 4377 | test=get(handles.edit,'Value');
|
---|
| 4378 | if test
|
---|
| 4379 | UvData.MouseAction='edit_object';
|
---|
| 4380 | set(handles.edit,'BackgroundColor',[1,1,0])
|
---|
| 4381 | %suppress the other options
|
---|
| 4382 | set(handles.zoom,'Value',0)
|
---|
| 4383 | zoom_Callback(hObject, eventdata, handles)
|
---|
| 4384 | set(handles.edit_vect,'Value',0)
|
---|
| 4385 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
[61] | 4386 | %list_object_Callback(hObject, eventdata, handles)
|
---|
[2] | 4387 | else
|
---|
| 4388 | UvData.MouseAction='none';
|
---|
| 4389 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4390 | end
|
---|
[61] | 4391 | set(handles.uvmat,'UserData',UvData);
|
---|
| 4392 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
| 4393 | if ~isempty(hset_object)
|
---|
| 4394 | hhset_object=guidata(hset_object);
|
---|
| 4395 | if test
|
---|
[71] | 4396 | set(hhset_object.PLOT,'enable','on');
|
---|
[61] | 4397 | else
|
---|
[71] | 4398 | set(hhset_object.PLOT,'enable','off');
|
---|
[61] | 4399 | end
|
---|
| 4400 | end
|
---|
[2] | 4401 |
|
---|
[61] | 4402 | %------------------------------------------------------------------------
|
---|
| 4403 | % --- Executes on selection change in list_object_1.
|
---|
| 4404 | function list_object_1_Callback(hObject, eventdata, handles)
|
---|
| 4405 | %------------------------------------------------------------------------
|
---|
| 4406 | list_str=get(handles.list_object_1,'String');
|
---|
| 4407 | IndexObj=get(handles.list_object_1,'Value');
|
---|
| 4408 | str_1=list_str{IndexObj};
|
---|
| 4409 | val_2=get(handles.list_object_2,'Value');
|
---|
| 4410 | str_2=get(handles.list_object_2,'String');
|
---|
[71] | 4411 | if isequal(val_2,IndexObj)% if the first selection is equal to the second, it will suppress the second
|
---|
| 4412 | set(handles.list_object_2,'Value',numel(str_2))%select the end of the list ('...')
|
---|
[61] | 4413 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4414 | end
|
---|
[71] | 4415 | update_object(handles,IndexObj,1,str_1)
|
---|
[61] | 4416 |
|
---|
| 4417 | %------------------------------------------------------------------------
|
---|
| 4418 | % --- Executes on selection change in list_object_1.
|
---|
| 4419 | function list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4420 | %------------------------------------------------------------------------
|
---|
| 4421 | list_str=get(handles.list_object_2,'String');
|
---|
| 4422 | IndexObj=get(handles.list_object_2,'Value');
|
---|
| 4423 | if isequal(list_str{IndexObj},'...')
|
---|
[71] | 4424 | hview_field=findobj(allchild(0),'Tag','view_field');
|
---|
[61] | 4425 | if ~isempty(hview_field)
|
---|
| 4426 | delete(hview_field)
|
---|
| 4427 | end
|
---|
| 4428 | else
|
---|
[71] | 4429 | update_object(handles,IndexObj,2,list_str{IndexObj})
|
---|
[61] | 4430 | end
|
---|
| 4431 |
|
---|
| 4432 | %------------------------------------------------------------------------
|
---|
[71] | 4433 | function update_object(handles,IndexObj,option,ObjectName)
|
---|
[61] | 4434 | %------------------------------------------------------------------------
|
---|
[60] | 4435 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 4436 | if ~(length(UvData.Object)>=IndexObj);
|
---|
| 4437 | return
|
---|
| 4438 | end
|
---|
| 4439 | ObjectData=UvData.Object{IndexObj};
|
---|
[71] | 4440 | ObjectData.Name=ObjectName;
|
---|
| 4441 | if isequal(get(handles.edit,'Value'),1)
|
---|
| 4442 | ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode
|
---|
[2] | 4443 | end
|
---|
| 4444 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4445 | ZBounds=0; % default
|
---|
| 4446 | if isfield(UvData,'ZMin') && isfield(UvData,'ZMax')
|
---|
| 4447 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
| 4448 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
| 4449 | end
|
---|
[71] | 4450 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
[61] | 4451 | if ~isempty(hset_object)
|
---|
| 4452 | delete(hset_object)% delete existing version of set_object
|
---|
| 4453 | end
|
---|
| 4454 | hset_object=set_object(ObjectData,PlotHandles,ZBounds);% call the set_object interface,
|
---|
[99] | 4455 | %set(hset_object,'name',ObjectName)
|
---|
[82] | 4456 |
|
---|
| 4457 | % %project the current field on the object and plot it
|
---|
| 4458 | % ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
|
---|
| 4459 | % if option==1%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes)
|
---|
| 4460 | % plot_field(ProjData,handles.axes3,PlotHandles);
|
---|
| 4461 | % UvData.Object{IndexObj}.plotaxes=handles.axes3;
|
---|
| 4462 | % else
|
---|
| 4463 | % UvData.Object{IndexObj}.plotaxes=view_field(ProjData);
|
---|
[76] | 4464 | % end
|
---|
[82] | 4465 | % set(handles.uvmat,'UserData',UvData)
|
---|
[102] | 4466 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 4467 | for iobj=1:length(hother)
|
---|
| 4468 | if isequal(get(hother(iobj),'Type'),'rectangle')|isequal(get(hother(iobj),'Type'),'patch')
|
---|
| 4469 | set(hother(iobj),'EdgeColor','b')
|
---|
| 4470 | if isequal(get(hother(iobj),'FaceColor'),'m')
|
---|
| 4471 | set(hother(iobj),'FaceColor','b')
|
---|
| 4472 | end
|
---|
| 4473 | elseif isequal(get(hother(iobj),'Type'),'image')
|
---|
| 4474 | Acolor=get(hother(iobj),'CData');
|
---|
| 4475 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
|
---|
| 4476 | set(hother(iobj),'CData',Acolor);
|
---|
| 4477 | else
|
---|
| 4478 | set(hother(iobj),'Color','b')
|
---|
| 4479 | end
|
---|
| 4480 | set(hother(iobj),'Selected','off')
|
---|
| 4481 | end
|
---|
[2] | 4482 | hother=findobj('Tag','DeformPoint');
|
---|
| 4483 | set(hother,'Color','b');
|
---|
| 4484 | set(hother,'Selected','off')
|
---|
| 4485 | if isfield(ObjectData,'HandlesDisplay')
|
---|
| 4486 | for iview=1:length(ObjectData.HandlesDisplay)
|
---|
| 4487 | if ishandle(ObjectData.HandlesDisplay(iview))
|
---|
| 4488 | uistack(ObjectData.HandlesDisplay(iview),'top')
|
---|
| 4489 | linetype=get(ObjectData.HandlesDisplay(iview),'Type');
|
---|
| 4490 | if isequal(linetype,'line')
|
---|
| 4491 | set(ObjectData.HandlesDisplay(iview),'Color','m'); %set the selected object to magenta color
|
---|
| 4492 | elseif isequal(linetype,'rectangle')
|
---|
| 4493 | set(ObjectData.HandlesDisplay(iview),'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4494 | elseif isequal(linetype,'patch')
|
---|
| 4495 | set(ObjectData.HandlesDisplay(iview),'FaceColor','m'); %set the selected object to magenta color
|
---|
| 4496 | end
|
---|
| 4497 | SubObjectData=get(ObjectData.HandlesDisplay(iview),'UserData');
|
---|
| 4498 | if isfield(SubObjectData,'SubObject')& ishandle(SubObjectData.SubObject)
|
---|
| 4499 | uistack(SubObjectData.SubObject,'top')
|
---|
| 4500 | for iobj=1:length(SubObjectData.SubObject)
|
---|
| 4501 | hsub=SubObjectData.SubObject(iobj);
|
---|
| 4502 | if isequal(get(hsub,'Type'),'rectangle')
|
---|
| 4503 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4504 | elseif isequal(get(hsub,'Type'),'image')
|
---|
| 4505 | Acolor=get(hsub,'CData');
|
---|
| 4506 | Acolor(:,:,1)=Acolor(:,:,3);
|
---|
| 4507 | set(hsub,'CData',Acolor);
|
---|
| 4508 | else
|
---|
| 4509 | set(hsub,'Color','m')
|
---|
| 4510 | end
|
---|
| 4511 | end
|
---|
| 4512 | end
|
---|
| 4513 | if isfield(SubObjectData,'DeformPoint')& ishandle(SubObjectData.DeformPoint)
|
---|
| 4514 | set(SubObjectData.DeformPoint,'Color','m')
|
---|
| 4515 | end
|
---|
| 4516 | end
|
---|
| 4517 | end
|
---|
| 4518 | end
|
---|
[61] | 4519 | pause(0.1)
|
---|
| 4520 | figure(hset_object)%put set_object in front
|
---|
[2] | 4521 |
|
---|
| 4522 | %------------------------------------------------------
|
---|
| 4523 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
| 4524 | %------------------------------------------------------
|
---|
| 4525 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
[89] | 4526 | global Data_uvmat
|
---|
| 4527 | Data_uvmat=get(handles.uvmat,'UserData');
|
---|
| 4528 | evalin('base','global Data_uvmat')%make CurData global in the workspace
|
---|
[122] | 4529 | display('current field :')
|
---|
[89] | 4530 | evalin('base','Data_uvmat') %display CurData in the workspace
|
---|
[82] | 4531 | commandwindow; %brings the Matlab command window to the front
|
---|
[2] | 4532 |
|
---|
| 4533 | %------------------------------------------------------
|
---|
| 4534 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
| 4535 | %------------------------------------------------------
|
---|
| 4536 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
| 4537 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
| 4538 | UvData=get(huvmat,'UserData');
|
---|
| 4539 | hfig=figure;
|
---|
| 4540 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 4541 | map=colormap(handles.axes3);
|
---|
| 4542 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4543 | colorbar
|
---|
| 4544 |
|
---|
| 4545 |
|
---|
| 4546 | % --------------------------------------------------------------------
|
---|
| 4547 | function Insert_Callback(hObject, eventdata, handles)
|
---|
| 4548 |
|
---|
| 4549 |
|
---|
| 4550 | % --------------------------------------------------------------------
|
---|
| 4551 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
| 4552 | % --------------------------------------------------------------------
|
---|
| 4553 | path_to_uvmat=which ('uvmat');% check the path of uvmat
|
---|
| 4554 | pathelp=fileparts(path_to_uvmat);
|
---|
[36] | 4555 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
| 4556 | 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')
|
---|
[2] | 4557 | else
|
---|
[36] | 4558 | addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
[2] | 4559 | web(helpfile);
|
---|
| 4560 | end
|
---|
| 4561 |
|
---|
| 4562 |
|
---|
| 4563 | % --------------------------------------------------------------------
|
---|
| 4564 | function MenuExportMovie_Callback(hObject, eventdata, handles)
|
---|
| 4565 | % --------------------------------------------------------------------
|
---|
| 4566 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button
|
---|
| 4567 | huvmat=get(handles.run0,'parent');
|
---|
| 4568 | UvData=get(huvmat,'UserData');
|
---|
| 4569 | [xx,xx,FileBase]=read_file_boxes(handles);
|
---|
| 4570 | %read the current input file name
|
---|
| 4571 | 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)'};
|
---|
| 4572 | dlg_title = 'select properties of the output avi movie';
|
---|
| 4573 | num_lines= 1;
|
---|
[128] | 4574 | % nbfield_cell=get(handles.last_i,'String');
|
---|
[2] | 4575 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
|
---|
| 4576 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
|
---|
| 4577 | aviname=answer{1};
|
---|
[128] | 4578 | fps=str2double(answer{2});
|
---|
[2] | 4579 | % check for existing file with output name aviname
|
---|
| 4580 | if exist(aviname,'file')
|
---|
| 4581 | backup=aviname;
|
---|
| 4582 | testexist=2;
|
---|
| 4583 | while testexist==2
|
---|
| 4584 | backup=[backup '~'];
|
---|
| 4585 | testexist=exist(backup,'file');
|
---|
| 4586 | end
|
---|
| 4587 | [success,message]=copyfile(aviname,backup);%make backup of the existing file
|
---|
| 4588 | if isequal(success,1)
|
---|
| 4589 | delete(aviname)%delete existing file
|
---|
| 4590 | else
|
---|
| 4591 | msgbox_uvmat('ERROR',message)
|
---|
| 4592 | return
|
---|
| 4593 | end
|
---|
| 4594 | end
|
---|
| 4595 | %create avi open
|
---|
| 4596 | aviobj=avifile(aviname,'Compression','None','fps',fps);
|
---|
| 4597 |
|
---|
| 4598 | %display first view for tests
|
---|
| 4599 | newfig=figure;
|
---|
| 4600 | newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure
|
---|
| 4601 | set(newaxes,'Tag','movieaxes')
|
---|
[128] | 4602 | nbpix=[512 384]*str2double(answer{3});
|
---|
[2] | 4603 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA
|
---|
| 4604 | set(newaxes,'Position',eval(answer{4}));
|
---|
| 4605 | map=colormap(handles.axes3);
|
---|
| 4606 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4607 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;...
|
---|
| 4608 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']});
|
---|
| 4609 | UvData.Object{1}.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
|
---|
| 4610 | set(huvmat,'UserData',UvData);
|
---|
[128] | 4611 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 4612 | if isnan(increment)
|
---|
| 4613 | set(handles.increment_scan,'String','1')%default value
|
---|
| 4614 | increment=1;
|
---|
| 4615 | end
|
---|
[2] | 4616 | set(handles.STOP,'Visible','on')
|
---|
| 4617 | set(handles.speed,'Visible','on')
|
---|
| 4618 | set(handles.speed_txt,'Visible','on')
|
---|
[81] | 4619 | set(handles.Movie,'BusyAction','queue')
|
---|
[2] | 4620 |
|
---|
[128] | 4621 | %imin=str2double(get(handles.i1,'String'));
|
---|
| 4622 | imax=str2double(answer{5});
|
---|
[2] | 4623 | % if isfield(UvData,'Time')
|
---|
| 4624 | htitle=get(newaxes,'Title');
|
---|
| 4625 | xlim=get(newaxes,'XLim');
|
---|
| 4626 | ylim=get(newaxes,'YLim');
|
---|
| 4627 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0])
|
---|
| 4628 | time_str=get(handles.abs_time,'String');
|
---|
| 4629 | set(htitle,'String',['t=' time_str])
|
---|
| 4630 | set(handles.speed,'Value',1)
|
---|
| 4631 | for i=1:imax
|
---|
[128] | 4632 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
|
---|
| 4633 | runpm(hObject,eventdata,handles,increment)% run plus
|
---|
[2] | 4634 | drawnow
|
---|
| 4635 | time_str=get(handles.abs_time,'String');
|
---|
| 4636 | if ishandle(htitle)
|
---|
| 4637 | set(htitle,'String',['t=' time_str])
|
---|
| 4638 | end
|
---|
| 4639 | mov=getframe(newfig);
|
---|
| 4640 | aviobj=addframe(aviobj,mov);
|
---|
| 4641 | end
|
---|
| 4642 | end
|
---|
[128] | 4643 | close(aviobj);
|
---|
[2] | 4644 | UvData.Object{1}.plotaxes=handles.axes3;
|
---|
| 4645 | set(huvmat,'UserData',UvData);
|
---|
| 4646 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
|
---|
| 4647 |
|
---|
| 4648 |
|
---|
| 4649 | % ------------------------------------------------------------------
|
---|
| 4650 | function MenuCalib_Callback(hObject, eventdata, handles)
|
---|
[71] | 4651 |
|
---|
[61] | 4652 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[71] | 4653 |
|
---|
| 4654 | %suppress competing options
|
---|
[61] | 4655 | set(handles.zoom,'Value',0)
|
---|
| 4656 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[71] | 4657 | set(handles.MenuMask,'enable','off')
|
---|
| 4658 | set(handles.MenuGrid,'enable','off')
|
---|
[67] | 4659 | set(handles.MenuObject,'enable','off')
|
---|
| 4660 | set(handles.MenuEdit,'enable','off')
|
---|
[61] | 4661 | set(handles.list_object_1,'Value',1)
|
---|
| 4662 | % initiate display of GUI geometry_calib
|
---|
| 4663 | data=[]; %default
|
---|
| 4664 | if isfield(UvData,'CoordType')
|
---|
| 4665 | data.CoordType=UvData.CoordType;
|
---|
| 4666 | end
|
---|
| 4667 | pos=get(handles.uvmat,'Position');
|
---|
| 4668 | pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
|
---|
| 4669 | pos(2)=pos(2)-0.02;
|
---|
| 4670 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
[116] | 4671 | [UvData.hset_object,UvData.sethandles]=geometry_calib(FileName,pos);% call the geometry_calib interface
|
---|
[61] | 4672 | pos_uvmat=get(handles.uvmat,'Position');
|
---|
[71] | 4673 |
|
---|
[61] | 4674 | if isfield(UvData,'CalOrigin')
|
---|
| 4675 | pos_cal(1)=pos_uvmat(1)+UvData.CalOrigin(1)*pos_uvmat(3);
|
---|
| 4676 | pos_cal(2)=pos_uvmat(2)+UvData.CalOrigin(2)*pos_uvmat(4);
|
---|
| 4677 | pos_cal(3:4)=UvData.CalSize .* pos_uvmat(3:4);
|
---|
| 4678 | set(UvData.hset_object,'Position',pos_cal)
|
---|
| 4679 | end
|
---|
| 4680 | UvData.MouseAction='calib';
|
---|
| 4681 | set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 4682 |
|
---|
[61] | 4683 |
|
---|
[2] | 4684 | % ------------------------------------------------------------------
|
---|
| 4685 | function MenuMask_Callback(hObject, eventdata, handles)
|
---|
[82] | 4686 | % set(handles.TOOLS_txt,'Visible','on')
|
---|
| 4687 | % set(handles.frame_tools,'Visible','on')
|
---|
| 4688 | % % set(handles.create,'Visible','on')
|
---|
| 4689 | % % set(handles.create,'Value',1)
|
---|
| 4690 | % % set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow
|
---|
| 4691 | % set(handles.save_mask,'Visible','on')
|
---|
| 4692 | % set(handles.masklevel,'Visible','on')
|
---|
| 4693 | % if isequal(get(handles.z_index,'Visible'),'on')
|
---|
| 4694 | % nb_slice=str2num(get(handles.nb_slice,'String'));
|
---|
| 4695 | % for ilist=1:nb_slice
|
---|
| 4696 | % list_index{ilist,1}=num2str(ilist);
|
---|
| 4697 | % end
|
---|
| 4698 | % set(handles.masklevel,'String',list_index)
|
---|
| 4699 | % val=str2num(get(handles.z_index,'String'));
|
---|
| 4700 | % if val<=nb_slice
|
---|
| 4701 | % set(handles.masklevel,'Value',val)
|
---|
| 4702 | % end
|
---|
| 4703 | % else
|
---|
| 4704 | % set(handles.masklevel,'String',{'1'})
|
---|
| 4705 | % set(handles.masklevel,'Value',1)
|
---|
| 4706 | % end
|
---|
| 4707 | % if ishandle(handles.UVMAT_title)
|
---|
| 4708 | % delete(handles.UVMAT_title)
|
---|
| 4709 | % end
|
---|
[61] | 4710 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[82] | 4711 | % set(handles.zoom,'Value',0)
|
---|
| 4712 | % set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4713 | % set(handles.edit_vect,'Value',0)
|
---|
| 4714 | % edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4715 | % set(handles.edit,'Value',0)
|
---|
| 4716 | % set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4717 | % set(handles.edit_vect,'Value',0)
|
---|
| 4718 | % edit_vect_Callback(hObject, eventdata, handles)
|
---|
[61] | 4719 | % set(handles.cal,'Value',0)
|
---|
| 4720 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
[2] | 4721 |
|
---|
| 4722 | %initiate the GUI set_object
|
---|
[82] | 4723 | % data.TITLE='MASK';
|
---|
| 4724 | % if isfield(UvData,'CoordType')
|
---|
| 4725 | % data.CoordType=UvData.CoordType;
|
---|
| 4726 | % end
|
---|
| 4727 | % if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh)
|
---|
| 4728 | % data.YMax=UvData.Mesh;
|
---|
| 4729 | % elseif isfield(UvData.Field,'AX')&&isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image
|
---|
| 4730 | % np=size(UvData.Field.A);
|
---|
| 4731 | % meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);
|
---|
| 4732 | % meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);
|
---|
| 4733 | % data.YMax=max(meshx,meshy);
|
---|
| 4734 | % data.DX=max(meshx,meshy);
|
---|
| 4735 | % end
|
---|
| 4736 | % data.Coord=[0 0 0]; %default
|
---|
| 4737 | % PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
|
---|
| 4738 | % [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
|
---|
| 4739 | % pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4740 | % if isfield(UvData,'SetObjectOrigin')
|
---|
| 4741 | % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 4742 | % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 4743 | % set(hset_object,'Position',pos_set_object)
|
---|
| 4744 | % end
|
---|
| 4745 | ListObj=UvData.Object;
|
---|
| 4746 | select=zeros(1,numel(ListObj));
|
---|
| 4747 | for iobj=1:numel(ListObj);
|
---|
| 4748 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside')
|
---|
| 4749 | select(iobj)=1;
|
---|
| 4750 | end
|
---|
[2] | 4751 | end
|
---|
[82] | 4752 | val=find(select);
|
---|
| 4753 | if isempty(val)
|
---|
| 4754 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar');
|
---|
| 4755 | return
|
---|
| 4756 | else
|
---|
| 4757 | set(handles.list_object_1,'Max',2);%allow multiple selection
|
---|
| 4758 | set(handles.list_object_1,'Value',val);
|
---|
| 4759 | % answer=msgbox_uvmat('INPUT_Y-N',['make the mask image from ' num2str(numel(val)) ' polygons']);
|
---|
| 4760 | % if ~isempty(answer)
|
---|
| 4761 | flag=1;
|
---|
| 4762 | npx=size(UvData.Field.A,2);
|
---|
| 4763 | npy=size(UvData.Field.A,1);
|
---|
[122] | 4764 | xi=0.5:npx-0.5;
|
---|
| 4765 | yi=0.5:npy-0.5;
|
---|
[82] | 4766 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 4767 | if isfield(UvData,'Object')
|
---|
| 4768 | for iobj=1:length(UvData.Object)
|
---|
| 4769 | ObjectData=UvData.Object{iobj};
|
---|
| 4770 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 4771 | flagobj=1;
|
---|
| 4772 | testphys=0; %coordinates in pixels by default
|
---|
| 4773 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
| 4774 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 4775 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 4776 | testphys=1;
|
---|
| 4777 | end
|
---|
| 4778 | end
|
---|
| 4779 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 4780 | if isequal(ObjectData.Style,'polygon')
|
---|
| 4781 | X=ObjectData.Coord(:,1);
|
---|
| 4782 | Y=ObjectData.Coord(:,2);
|
---|
| 4783 | if testphys
|
---|
| 4784 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 4785 | end
|
---|
| 4786 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
| 4787 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 4788 | if testphys
|
---|
| 4789 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4790 | end
|
---|
| 4791 | RangeX=max(ObjectData.RangeX);
|
---|
| 4792 | RangeY=max(ObjectData.RangeY);
|
---|
| 4793 | X2Max=RangeX*RangeX;
|
---|
| 4794 | Y2Max=RangeY*RangeY;
|
---|
| 4795 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 4796 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 4797 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 4798 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 4799 | if testphys
|
---|
| 4800 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4801 | end
|
---|
| 4802 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 4803 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 4804 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 4805 | end
|
---|
| 4806 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 4807 | flagobj=~flagobj;
|
---|
| 4808 | end
|
---|
| 4809 | flag=flag & flagobj;
|
---|
| 4810 | end
|
---|
| 4811 | end
|
---|
| 4812 | end
|
---|
| 4813 | end
|
---|
| 4814 | % flag=~flag;
|
---|
| 4815 | %mask name
|
---|
| 4816 | RootPath=get(handles.RootPath,'String');
|
---|
| 4817 | RootFile=get(handles.RootFile,'String');
|
---|
| 4818 | if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
|
---|
| 4819 | RootFile(1)=[];
|
---|
| 4820 | end
|
---|
| 4821 | filebase=fullfile(RootPath,RootFile);
|
---|
| 4822 | list=get(handles.masklevel,'String');
|
---|
| 4823 | masknumber=num2str(length(list));
|
---|
| 4824 | maskindex=get(handles.masklevel,'Value');
|
---|
| 4825 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 4826 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 4827 | imflag=flipdim(imflag,1);
|
---|
| 4828 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when
|
---|
| 4829 | % 20<imflag<200)
|
---|
| 4830 |
|
---|
| 4831 | %display the mask
|
---|
| 4832 | %update_mask(handles,num_i1,num_j1)
|
---|
| 4833 | figure;
|
---|
| 4834 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 4835 | map=[vec' vec' vec'];
|
---|
| 4836 | colormap(map)
|
---|
| 4837 | image(imflag);
|
---|
[86] | 4838 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name);
|
---|
[82] | 4839 | if ~strcmp(answer,'Cancel')
|
---|
[139] | 4840 | mask_dir=fileparts(answer);
|
---|
| 4841 | if ~exist(mask_dir,'dir')
|
---|
| 4842 | msgbox_uvmat('ERROR',['directory ' mask_dir ' does not exist'])
|
---|
| 4843 | return
|
---|
| 4844 | end
|
---|
[82] | 4845 | imwrite(imflag,answer,'BitDepth',8);
|
---|
| 4846 | end
|
---|
[114] | 4847 | set(handles.list_object_1,'Value',1)
|
---|
| 4848 | set(handles.list_object_1,'Max',1)
|
---|
[82] | 4849 | % end
|
---|
| 4850 | end
|
---|
| 4851 |
|
---|
| 4852 |
|
---|
| 4853 | % UvData.MouseAction='create_object';
|
---|
[61] | 4854 | set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 4855 |
|
---|
| 4856 | % ------------------------------------------------------------------
|
---|
| 4857 | %-- open the GUI set_grid.fig to create grid
|
---|
| 4858 | function MenuGrid_Callback(hObject, eventdata, handles)
|
---|
[84] | 4859 | %UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 4860 |
|
---|
[84] | 4861 | %suppress the other options if grid is chosen
|
---|
| 4862 | set(handles.edit_vect,'Value',0)
|
---|
| 4863 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4864 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4865 | set(handles.list_object_1,'Value',1)
|
---|
| 4866 |
|
---|
| 4867 | %prepare display of the set_grid GUI
|
---|
| 4868 | FileName=read_file_boxes(handles);
|
---|
| 4869 | CoordList=get(handles.transform_fct,'String');
|
---|
| 4870 | val=get(handles.transform_fct,'Value');
|
---|
| 4871 | set_grid(FileName,CoordList{val});% call the set_object interface
|
---|
| 4872 | %set(handles.uvmat,'UserData',UvData);
|
---|
| 4873 |
|
---|
[2] | 4874 | %----------------------------------------------------------------
|
---|
| 4875 | % open the GUI 'series'
|
---|
| 4876 | %----------------------------------------------------------------
|
---|
| 4877 | function MenuSeries_Callback(hObject, eventdata, handles)
|
---|
[40] | 4878 | %-------------------------------------------------------------------
|
---|
[2] | 4879 |
|
---|
| 4880 | [param.FileName]=read_file_boxes(handles);
|
---|
| 4881 | if isequal(get(handles.SubField,'Value'),1)
|
---|
| 4882 | FileName_1=read_file_boxes_1(handles);%
|
---|
| 4883 | if ~isequal(FileName_1,param.FileName)
|
---|
| 4884 | param.FileName_1=FileName_1;
|
---|
| 4885 | end
|
---|
| 4886 | end
|
---|
| 4887 | param.NomType=get(handles.FileIndex,'UserData');
|
---|
| 4888 | param.NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 4889 | param.comp_input=get(handles.fix_pair,'Value');
|
---|
| 4890 | huvmat=get(handles.MenuSeries,'parent');
|
---|
| 4891 | UvData=get(huvmat,'UserData');
|
---|
| 4892 | if isfield(UvData,'Time')
|
---|
| 4893 | param.Time=UvData.XmlData.Time;
|
---|
| 4894 | end
|
---|
| 4895 | if isequal(get(handles.scan_i,'Value'),1)
|
---|
[128] | 4896 | param.incr_i=str2double(get(handles.increment_scan,'String'));
|
---|
[2] | 4897 | elseif isequal(get(handles.scan_j,'Value'),1)
|
---|
[128] | 4898 | param.incr_j=str2double(get(handles.increment_scan,'String'));
|
---|
[2] | 4899 | end
|
---|
| 4900 | param.list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 4901 | param.list_fields(1)=[]; %suppress 'image' option
|
---|
| 4902 | param.index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 4903 | if param.index_fields>1
|
---|
| 4904 | param.index_fields=param.index_fields-1;
|
---|
| 4905 | end
|
---|
| 4906 | param.list_fields_1=get(handles.Fields_1,'String');% list menu fields
|
---|
| 4907 | param.list_fields_1(1)=[]; %suppress 'image' option
|
---|
| 4908 | param.index_fields_1=get(handles.Fields_1,'Value')-1;% selected string index
|
---|
| 4909 | if param.index_fields_1>1
|
---|
| 4910 | param.index_fields_1=param.index_fields_1-1;
|
---|
| 4911 | end
|
---|
| 4912 | param.civ1=get(handles.civ1,'Value');
|
---|
| 4913 | param.civ2=get(handles.civ2,'Value');
|
---|
| 4914 | param.interp1=get(handles.interp1,'Value');
|
---|
| 4915 | param.interp2=get(handles.interp2,'Value');
|
---|
| 4916 | param.filter1=get(handles.filter1,'Value');
|
---|
| 4917 | param.filter2=get(handles.filter2,'Value');
|
---|
[39] | 4918 | param.menu_coord_str=get(handles.transform_fct,'String');
|
---|
| 4919 | param.menu_coord_val=get(handles.transform_fct,'Value');
|
---|
[2] | 4920 |
|
---|
| 4921 | series(param); %run the series interface
|
---|
| 4922 |
|
---|
| 4923 | % ------------------------------------------------------------------
|
---|
| 4924 | % -- open the GUI civ.fig for civx (PIV)
|
---|
| 4925 | % ------------------------------------------------------------------
|
---|
| 4926 | function MenuPIV_Callback(hObject, eventdata, handles)
|
---|
| 4927 |
|
---|
| 4928 | [FileName,RootPath,filebase,FileIndices,ext,SubDir]=read_file_boxes(handles);
|
---|
[45] | 4929 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 4930 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 4931 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 4932 | num_b=stra2num(get(handles.j2,'String'));
|
---|
[2] | 4933 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 4934 | ind_opening=1; % default (images): will advice civ1 option by default in the civ interface
|
---|
| 4935 | if isequal(ext,'.nc') || isequal(ext,'.cdf')% netcdf files
|
---|
| 4936 | ind_opening=2;% propose 'fix' as the default option
|
---|
| 4937 | % +read the current netcdf rootfile
|
---|
| 4938 | Data=nc2struct(FileName,[]);
|
---|
| 4939 | if isfield(Data,'fix') & isequal(Data.fix,1)
|
---|
| 4940 | ind_opening=3;
|
---|
| 4941 | end
|
---|
| 4942 | if isfield(Data,'patch') & isequal(Data.patch,1)
|
---|
| 4943 | ind_opening=4;
|
---|
| 4944 | end
|
---|
| 4945 | if isfield(Data,'civ2') & isequal(Data.civ2,1)
|
---|
| 4946 | ind_opening=5;
|
---|
| 4947 | end
|
---|
| 4948 | if isfield(Data,'fix2') & isequal(Data.fix2,1)
|
---|
| 4949 | ind_opening=6;
|
---|
| 4950 | end
|
---|
| 4951 | end
|
---|
[71] | 4952 | param.RootName=filebase;
|
---|
| 4953 | param.NomType=NomType;
|
---|
| 4954 | param.num1=num1;
|
---|
| 4955 | param.num2=num2;
|
---|
| 4956 | param.num_a=num_a;
|
---|
| 4957 | param.num_b=num_b;
|
---|
| 4958 | param.SubDir=SubDir;
|
---|
| 4959 | param.IndOpening=ind_opening;% A REVOIR +TRANSMETTRE IMADOC INFO
|
---|
| 4960 | param.ImaExt=ext;
|
---|
| 4961 | civ(param);% interface de civ(not in the uvmat file)
|
---|
[2] | 4962 |
|
---|
| 4963 | % ------------------------------------------------------------------
|
---|
| 4964 | function MenuTools_Callback(hObject, eventdata, handles)
|
---|
| 4965 |
|
---|
| 4966 | % ------------------------------------------------------------------
|
---|
[67] | 4967 | function MenuEditObject_Callback(hObject, eventdata, handles)
|
---|
| 4968 | set(handles.edit,'Value',1)
|
---|
| 4969 | edit_Callback(hObject, eventdata, handles)
|
---|
[2] | 4970 |
|
---|
| 4971 | %--------------------------------------------------------------------------
|
---|
| 4972 | function enable_transform(handles,state)
|
---|
[39] | 4973 | set(handles.transform_fct,'Visible',state)
|
---|
[2] | 4974 | set(handles.TRANSFORM_txt,'Visible',state)
|
---|
[39] | 4975 | set(handles.transform_fct,'Visible',state)
|
---|
[2] | 4976 | set(handles.path_transform,'Visible',state)
|
---|
| 4977 | set(handles.pxcmx_txt,'Visible',state)
|
---|
| 4978 | set(handles.pxcmy_txt,'Visible',state)
|
---|
| 4979 | set(handles.pxcm,'Visible',state)
|
---|
| 4980 | set(handles.pycm,'Visible',state)
|
---|
| 4981 |
|
---|
[40] | 4982 | %------------------------------------------------------------------------
|
---|
[2] | 4983 | function MenuEditVectors_Callback(hObject, eventdata, handles)
|
---|
[40] | 4984 | %------------------------------------------------------------------------
|
---|
[2] | 4985 | set(handles.edit_vect,'Visible','on')
|
---|
| 4986 | set(handles.edit_vect,'Value',1)
|
---|
| 4987 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4988 |
|
---|
[40] | 4989 | % --------------------------------------------------------------------
|
---|
| 4990 | function Menupoints_Callback(hObject, eventdata, handles)
|
---|
| 4991 | data.Style='points';
|
---|
| 4992 | data.ProjMode='projection';%default
|
---|
[55] | 4993 | create_object(data,handles)
|
---|
[2] | 4994 |
|
---|
[40] | 4995 | % --------------------------------------------------------------------
|
---|
| 4996 | function Menuline_Callback(hObject, eventdata, handles)
|
---|
| 4997 | % set(handles.create,'Visible','on')
|
---|
| 4998 | % set(handles.create,'Value',1)
|
---|
| 4999 | % LINE_Callback(hObject,eventdata,handles)
|
---|
| 5000 | data.Style='line';
|
---|
| 5001 | data.ProjMode='projection';%default
|
---|
[55] | 5002 | create_object(data,handles)
|
---|
[2] | 5003 |
|
---|
[40] | 5004 | %------------------------------------------------------------------------
|
---|
| 5005 | function Menupolyline_Callback(hObject, eventdata, handles)
|
---|
| 5006 | %------------------------------------------------------------------------
|
---|
| 5007 | data.Style='polyline';
|
---|
| 5008 | data.ProjMode='projection';%default
|
---|
[55] | 5009 | create_object(data,handles)
|
---|
[2] | 5010 |
|
---|
[55] | 5011 | %------------------------------------------------------------------------
|
---|
[40] | 5012 | function Menupolygon_Callback(hObject, eventdata, handles)
|
---|
[55] | 5013 | %------------------------------------------------------------------------
|
---|
[45] | 5014 | data.Style='polygon';
|
---|
| 5015 | data.ProjMode='inside';%default
|
---|
[55] | 5016 | create_object(data,handles)
|
---|
[40] | 5017 |
|
---|
| 5018 | %------------------------------------------------------------------------
|
---|
| 5019 | function Menurectangle_Callback(hObject, eventdata, handles)
|
---|
| 5020 | %------------------------------------------------------------------------
|
---|
| 5021 | data.Style='rectangle';
|
---|
| 5022 | data.ProjMode='inside';%default
|
---|
[55] | 5023 | create_object(data,handles)
|
---|
[40] | 5024 |
|
---|
| 5025 | %------------------------------------------------------------------------
|
---|
| 5026 | function Menuellipse_Callback(hObject, eventdata, handles)
|
---|
| 5027 | %------------------------------------------------------------------------
|
---|
| 5028 | data.Style='ellipse';
|
---|
| 5029 | data.ProjMode='inside';%default
|
---|
[55] | 5030 | create_object(data,handles)
|
---|
[40] | 5031 |
|
---|
[82] | 5032 | %------------------------------------------------------------------------
|
---|
| 5033 | function MenuMaskObject_Callback(hObject, eventdata, handles)
|
---|
| 5034 | %------------------------------------------------------------------------
|
---|
| 5035 | data.Style='polygon';
|
---|
| 5036 | data.StyleMenu={'polygon'};
|
---|
| 5037 | data.ProjMode='mask_inside';%default
|
---|
| 5038 | data.ProjMenu={'mask_inside';'mask_outside'};
|
---|
| 5039 | create_object(data,handles)
|
---|
| 5040 |
|
---|
[40] | 5041 | % ------------------------------------------------------------------
|
---|
| 5042 | function Menuplane_Callback(hObject, eventdata, handles)
|
---|
| 5043 | data.Style='plane';
|
---|
| 5044 | data.ProjMode='projection';%default
|
---|
| 5045 |
|
---|
[55] | 5046 | create_object(data,handles)
|
---|
| 5047 |
|
---|
[40] | 5048 | % ------------------------------------------------------------------
|
---|
| 5049 | function Menuvolume_Callback(hObject, eventdata, handles)
|
---|
[77] | 5050 | data.Style='volume';
|
---|
| 5051 | data.ProjMode='interp';%default
|
---|
[61] | 5052 | % set(handles.create,'Visible','on')
|
---|
| 5053 | % set(handles.create,'Value',1)
|
---|
[77] | 5054 | % VOLUME_Callback(hObject,eventdata,handles)
|
---|
| 5055 | create_object(data,handles)
|
---|
[40] | 5056 |
|
---|
| 5057 | %------------------------------------------------------------------------
|
---|
| 5058 | function MenuBrowseObject_Callback(hObject, eventdata, handles)
|
---|
| 5059 | %------------------------------------------------------------------------
|
---|
| 5060 | %get the object file
|
---|
| 5061 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 5062 | {'*.xml;*.mat', ' (*.xml,*.mat)';
|
---|
| 5063 | '*.xml', '.xml files '; ...
|
---|
| 5064 | '*.mat', '.mat matlab files '}, ...
|
---|
[89] | 5065 | 'Pick an xml Object file',get(handles.RootPath,'String'));
|
---|
[40] | 5066 | fileinput=[PathName FileName];%complete file name
|
---|
| 5067 | testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 5068 | if ~isempty(testblank)
|
---|
| 5069 | msgbox_uvmat('ERROR','forbidden input file name: contain blanks')
|
---|
| 5070 | return
|
---|
| 5071 | end
|
---|
| 5072 | sizf=size(fileinput);
|
---|
| 5073 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 5074 |
|
---|
| 5075 | %read the file
|
---|
[55] | 5076 | t=xmltree(fileinput);
|
---|
| 5077 | data=convert(t);
|
---|
[71] | 5078 | data.enable_plot=1;
|
---|
| 5079 | [pp,data.Name]=fileparts(FileName);
|
---|
| 5080 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
[99] | 5081 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
[55] | 5082 | if ~isempty(hset_object)
|
---|
| 5083 | delete(hset_object)% delete existing version of set_object
|
---|
| 5084 | end
|
---|
[71] | 5085 | UvData=get(handles.uvmat,'UserData');
|
---|
[81] | 5086 | [hset_object,UvData.sethandles]=set_object(data);% call the set_object interface
|
---|
[75] | 5087 | % %position the set_object GUI with respect to uvmat
|
---|
| 5088 | % pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 5089 | % if isfield(UvData,'SetObjectOrigin')
|
---|
| 5090 | % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 5091 | % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 5092 | % set(hset_object,'Position',pos_set_object)
|
---|
| 5093 | % end
|
---|
[61] | 5094 | set(handles.edit,'Value',0); %suppress the object edit mode
|
---|
| 5095 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
[55] | 5096 | UvData.MouseAction='create_object';
|
---|
| 5097 | set(handles.uvmat,'UserData',UvData)
|
---|
[72] | 5098 | set(handles.delete_object,'Visible','on')
|
---|
| 5099 | set(handles.uvmat_title,'Visible','on')
|
---|
[75] | 5100 | set(handles.view_field_title,'Visible','on')
|
---|
[40] | 5101 |
|
---|
| 5102 | %------------------------------------------------------------------------
|
---|
[71] | 5103 | % --- generic function used for the creation of a projection object
|
---|
[55] | 5104 | function create_object(data,handles)
|
---|
[40] | 5105 | %------------------------------------------------------------------------
|
---|
[75] | 5106 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
[40] | 5107 | if ~isempty(hset_object)
|
---|
| 5108 | delete(hset_object)% delete existing version of set_object
|
---|
| 5109 | end
|
---|
[55] | 5110 | UvData=get(handles.uvmat,'UserData');
|
---|
[61] | 5111 | set(handles.edit,'Value',0); %suppress the object edit mode
|
---|
| 5112 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
[71] | 5113 | data.enable_plot=1;
|
---|
[82] | 5114 | transform_list=get(handles.transform_fct,'String');
|
---|
| 5115 | val=get(handles.transform_fct,'Value');
|
---|
| 5116 | data.CoordType=transform_list{val};
|
---|
| 5117 | % if isfield(UvData,'CoordType')
|
---|
| 5118 | % data.CoordType=UvData.CoordType;
|
---|
| 5119 | % end
|
---|
[55] | 5120 | if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh)
|
---|
[40] | 5121 | data.RangeX=UvData.Mesh;
|
---|
| 5122 | data.RangeY=UvData.Mesh;
|
---|
| 5123 | data.DX=UvData.Mesh;
|
---|
| 5124 | data.DY=UvData.Mesh;
|
---|
[55] | 5125 | elseif isfield(UvData.Field,'AX')&& isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image
|
---|
[40] | 5126 | np=size(UvData.Field.A);
|
---|
| 5127 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 5128 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 5129 | data.RangeY=max(meshx,meshy);
|
---|
| 5130 | data.RangeX=max(meshx,meshy);
|
---|
| 5131 | data.DX=max(meshx,meshy);
|
---|
| 5132 | end
|
---|
[75] | 5133 | if isfield(UvData,'NbDim')
|
---|
| 5134 | data.NbDim=UvData.NbDim;
|
---|
| 5135 | end
|
---|
[55] | 5136 | data.Coord=[0 0 0]; %default
|
---|
| 5137 | if isfield(data,'Style') && isequal(data.Style,'line')
|
---|
| 5138 | if isfield(data,'DX')
|
---|
| 5139 | data.Coord=[[0 0 0];[data.DX 0 0]]; %default
|
---|
| 5140 | else
|
---|
| 5141 | data.Coord=[[0 0 0];[1 0 0]]; %default
|
---|
| 5142 | end
|
---|
[40] | 5143 | end
|
---|
| 5144 | %data.ParentButton=handles.create;
|
---|
[55] | 5145 | if ishandle(handles.UVMAT_title)
|
---|
| 5146 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
|
---|
| 5147 | end
|
---|
| 5148 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
[40] | 5149 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
|
---|
[61] | 5150 |
|
---|
[40] | 5151 | UvData.MouseAction='create_object';
|
---|
[55] | 5152 | set(handles.uvmat,'UserData',UvData)
|
---|
| 5153 | set(handles.zoom,'Value',0)
|
---|
| 5154 | zoom_Callback(handles.uvmat, [], handles)
|
---|
[72] | 5155 | set(handles.delete_object,'Visible','on')
|
---|
| 5156 | set(handles.uvmat_title,'Visible','on')
|
---|
[75] | 5157 | set(handles.view_field_title,'Visible','on')
|
---|
[40] | 5158 |
|
---|
[71] | 5159 | %------------------------------------------------------------------------
|
---|
[60] | 5160 | function MenuRuler_Callback(hObject, eventdata, handles)
|
---|
[71] | 5161 | %------------------------------------------------------------------------
|
---|
[60] | 5162 | set(handles.zoom,'Value',0)
|
---|
| 5163 | zoom_Callback(handles.uvmat, [], handles)
|
---|
| 5164 | UvData=get(handles.uvmat,'UserData');
|
---|
| 5165 | UvData.MouseAction='ruler';
|
---|
| 5166 | set(handles.uvmat,'UserData',UvData);
|
---|
| 5167 |
|
---|
[67] | 5168 | %------------------------------------------------------------------------
|
---|
[71] | 5169 | % --- executed when closing: set the parent interface button to value 0
|
---|
[67] | 5170 | function closefcn(gcbo,eventdata)
|
---|
| 5171 | %------------------------------------------------------------------------
|
---|
| 5172 | %delete all the associated figures if exist
|
---|
| 5173 | hh=findobj(allchild(0),'tag','view_field');
|
---|
| 5174 | if ~isempty(hh)
|
---|
| 5175 | delete(hh)
|
---|
| 5176 | end
|
---|
[99] | 5177 | hh=findobj(allchild(0),'tag','geometry_calib');
|
---|
[67] | 5178 | if ~isempty(hh)
|
---|
| 5179 | delete(hh)
|
---|
| 5180 | end
|
---|
| 5181 | hh=findobj(allchild(0),'tag','set_object');
|
---|
| 5182 | if ~isempty(hh)
|
---|
| 5183 | hhh=findobj(hh,'tag','PLOT');
|
---|
| 5184 | set(hhh,'enable','off')
|
---|
[71] | 5185 | end
|
---|
| 5186 |
|
---|
| 5187 |
|
---|
| 5188 | % --- Executes on button press in delete_object.
|
---|
| 5189 | function delete_object_Callback(hObject, eventdata, handles)
|
---|
| 5190 | IndexObj=get(handles.list_object_2,'Value');
|
---|
| 5191 | if IndexObj>1
|
---|
| 5192 | delete_object(IndexObj)
|
---|
| 5193 | end
|
---|
| 5194 |
|
---|
| 5195 |
|
---|
[81] | 5196 |
|
---|
| 5197 |
|
---|
| 5198 |
|
---|