[199] | 1 | %'uvmat': function associated with the GUI 'uvmat.fig' for images and data field visualization
|
---|
| 2 | %------------------------------------------------------------------------
|
---|
| 3 | % function huvmat=uvmat(input)
|
---|
| 4 | %
|
---|
| 5 | %OUTPUT
|
---|
| 6 | % huvmat=current handles of the GUI uvmat.fig
|
---|
| 7 | %%
|
---|
| 8 | %
|
---|
| 9 | %INPUT:
|
---|
| 10 | % input: input file name (if character chain), or input image matrix to
|
---|
| 11 | % visualize, or Matlab structure representing netcdf fields (with fields
|
---|
| 12 | % ListVarName....)
|
---|
| 13 | %
|
---|
| 14 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 15 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr.
|
---|
| 16 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 17 | % This open is part of the toolbox UVMAT.
|
---|
| 18 | %
|
---|
| 19 | % UVMAT is free software; you can redistribute it and/or modify
|
---|
| 20 | % it under the terms of the GNU General Public License as published by
|
---|
| 21 | % the Free Software Foundation; either version 2 of the License, or
|
---|
| 22 | % (at your option) any later version.
|
---|
| 23 | %
|
---|
| 24 | % UVMAT is distributed in the hope that it will be useful,
|
---|
| 25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 27 | % GNU General Public License (open UVMAT/COPYING.txt) for more details.
|
---|
| 28 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 29 | %
|
---|
| 30 | % Information stored on the interface:
|
---|
| 31 | % 'Strings' of all edit boxes and menus: get(handles.Tag,'String')
|
---|
| 32 | % 'Values' of all menus and toggle buttons: get(handles.Tag,'Value')
|
---|
| 33 | % Matlab structure called UvData stored as 'UserData' of the figure uvmat.fig,(can be obtained by right mouse click on the interface).
|
---|
| 34 | % It contains the following fields:
|
---|
| 35 | % - Fixed specifiacation of plotting figures and axes (defined bu uvmat_OpeningFcn)
|
---|
| 36 | % .PosColorbar: [0.8210 0.4710 0.0190 0.4450]; specified position of the colorbar on figures
|
---|
| 37 | % - Information read in the documentation open of a series (activated by RootPath_Callback) :
|
---|
| 38 | % .XmlData, with fields:
|
---|
| 39 | % .Time: matrix of times of the images with index i and j
|
---|
| 40 | % .GeometryCalib: [1x1 struct]
|
---|
| 41 | % - Information defined from the interface:
|
---|
| 42 | % .NewSeries: =1 when the first view of a new field series is displayed, else 0
|
---|
| 43 | % .filename:(char string)
|
---|
| 44 | % .VelType:(char string) type of velocity field selected
|
---|
| 45 | % .VelType_1:(char string) REMPLACER LE CELL ACTUEL
|
---|
| 46 | % .FieldName: (char string) main field selected('image', 'velocity'...)
|
---|
| 47 | % .FieldName_1:(char string) second field selected('image', 'velocity'...)
|
---|
| 48 | % .CName: (char string)name of the scalar used for vector colors
|
---|
| 49 | % .MovieObject: movie object representing an input movie
|
---|
| 50 | % .MovieObject_1: idem for a second input series (_1)
|
---|
| 51 | % .filename_1 : last second input file name (to deal with a constant second input without reading again the file)
|
---|
| 52 | % .VelType_1: last velocity type (civ1, civ2...) for the second input series
|
---|
| 53 | % .FieldName_1: last field name(velocity, vorticity...) for the second input series
|
---|
| 54 | % .ZMin, .ZMax: range of the z coordinate
|
---|
| 55 | %..... to complement
|
---|
| 56 | % - Information on projection objects
|
---|
| 57 | % .Object: {[1x1 struct]}
|
---|
| 58 | % .CurrentObjectIndex: index of the projection object .Object currently selected for editing
|
---|
| 59 | % -Information on the current field (Field{i})
|
---|
| 60 | % .Txt : text information to display (e.g. error message)
|
---|
| 61 | % .NbDim: number of dimensions (=0 by default)
|
---|
| 62 | % .NbCoord: number of vector components
|
---|
| 63 | % .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')
|
---|
| 64 | % .dt: time interval for the corresponding image pair
|
---|
| 65 | % .Mesh: estimated typical distance between vectors
|
---|
| 66 | % .ZMax:
|
---|
| 67 | % .ZMin:
|
---|
| 68 | % .X, .Y, .Z: set of vector coordinates
|
---|
| 69 | % .U,.V,.W: corresponding set of vector components
|
---|
| 70 | % .F: corresponding set of warning flags
|
---|
| 71 | % .FF: corresponding set of false flags, =0 for good vectors
|
---|
| 72 | % .C: corresponding values of the scalar used for vector color
|
---|
| 73 | % (.X, .Y, .Z,.U,.V,.W,.F,.FF,.C are matlab vectors of the same length,
|
---|
| 74 | % equal to the number of vectors stored in the input open)
|
---|
| 75 | % .CName: name of the scalar .C
|
---|
| 76 | % .CType: type of the scalar .C, setting how the scalar is obtained (see 'Scalars' below)
|
---|
| 77 | % .A image or scalar
|
---|
| 78 | % .AX: vector of dimension 2 representing the first and last values
|
---|
| 79 | % of the X coordinates for the image or scalar known on a regular grid,
|
---|
| 80 | % or vector of dimension .A for a scaler defined on irregular grid.
|
---|
| 81 | % .AY: same as .AX along the Y direction
|
---|
| 82 | % .AName: name of the scalar, ='image' for an image
|
---|
| 83 |
|
---|
| 84 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%:
|
---|
| 85 | %
|
---|
| 86 | % fields are opened and visualised by the sub-function refresh_field.m
|
---|
| 87 | % (called by uvmat_opening, RUN0, runp and runm)
|
---|
| 88 | % The function first reads the name of the input file from the edit boxes of the GUI
|
---|
| 89 | % A second input file can be introduced for filed comparison
|
---|
| 90 | % It then reads the input file(s) with the appropriate function, read for
|
---|
| 91 | % images, read_civxdata.m for CIVx PIV data, nc2struct for other netcdf
|
---|
| 92 | % files.
|
---|
| 93 | % Main input open second input open(_1) second image (pair animation)
|
---|
| 94 | % | |
|
---|
| 95 | % | |
|
---|
| 96 | % Field{1} Field{2}
|
---|
| 97 | % |
|
---|
| 98 | % coord transform (phys.m) or other user defined fct acting on Field{i} |
|
---|
| 99 | % Field{i}
|
---|
| 100 | % |
|
---|
| 101 | % calc_field.m: calculate scalar or other derived fields (vort, div..).
|
---|
| 102 | %
|
---|
| 103 | % sub_field.m: combine the input Field{i} in a single set of fields (vector + scalar):
|
---|
| 104 | % Field{i=1->3}.X --> UvData.X |
|
---|
| 105 | % |
|
---|
| 106 | % UvData
|
---|
| 107 | % |
|
---|
| 108 | % plot histograms of the whole field
|
---|
| 109 | % proj_field.m: project the set of fields on the current projection objects defined by UvData.Object
|
---|
| 110 | % | |
|
---|
| 111 | % ObjectData
|
---|
| 112 | % |
|
---|
| 113 | % plot_field.m: plot the projected fields and store them as |
|
---|
| 114 | % UvData.axes3 |
|
---|
| 115 | % |
|
---|
| 116 | % AxeData
|
---|
| 117 | %
|
---|
| 118 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%%
|
---|
| 119 | % scalars are displayed either as an image or countour plot, either as a color of
|
---|
| 120 | % velocity vectors. The scalar values in the first case is represented by
|
---|
| 121 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X
|
---|
| 122 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and
|
---|
| 123 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar
|
---|
| 124 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the
|
---|
| 125 | % coordinates of the four image corners. The scalar name is represented by
|
---|
| 126 | % the strings .AName and/or .CName.
|
---|
| 127 | % If the scalar exists in an input open (image or scalar stored under its
|
---|
| 128 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}.
|
---|
| 129 | % Else only its name AName is recorded in Field{i}, and its field is then calculated
|
---|
| 130 | %by the fuction calc_scal after the coordinate transform or after projection on an edit_object
|
---|
| 131 |
|
---|
| 132 | % Properties attached to plotting figures (standard Matlab properties):
|
---|
| 133 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes');
|
---|
| 134 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned
|
---|
| 135 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned
|
---|
| 136 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure
|
---|
| 137 | % 'KeyPressFcn': function called by pressing a key on the key board
|
---|
| 138 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure
|
---|
| 139 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure
|
---|
| 140 |
|
---|
| 141 | % Properties attached to plotting axes:
|
---|
| 142 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates.
|
---|
| 143 | % AxeData:=get(gca,'UserData');
|
---|
| 144 | % AxeData.Drawing = create: create a new object
|
---|
| 145 | % = deform: modify an existing object by moving its defining create
|
---|
| 146 | % = off: no current drawing action
|
---|
| 147 | % = translate: translate an existing object
|
---|
| 148 | % = calibration: move a calibration point
|
---|
| 149 | % = zoom: isolate a subregion for zoom in=1 if an object is being currently drawn, 0 else (set to 0 by releasing mouse button)
|
---|
| 150 | % .CurrentOrigin: Origin of a curently drawn edit_object
|
---|
| 151 | % .CurrentLine: currently drawn menuline (A REVOIR)
|
---|
| 152 | % .CurrentObject: handle of the currently drawn edit_object
|
---|
| 153 | % .CurrentRectZoom: current rectangle used for zoom
|
---|
| 154 |
|
---|
| 155 | % Properties attached to projection objects (create, menuline, menuplane...):
|
---|
| 156 | % 'Tag'='proj_object': for all projection objects
|
---|
| 157 | % ObjectData.Style=...: style of projection object:
|
---|
| 158 | % .ProjMode
|
---|
| 159 | % .Coord: defines the position of the object
|
---|
| 160 | % .XMin,YMin....
|
---|
| 161 | % .XMax,YMax....
|
---|
| 162 | % .DX,DY,DZ
|
---|
| 163 | % .Phi, .Theta, .Psi : Euler angles
|
---|
| 164 | % .X,.Y,.U,.V.... : field data projected on the object
|
---|
| 165 | % .IndexObj: index in the list of UvData.Object
|
---|
| 166 | %during plotting
|
---|
| 167 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object
|
---|
| 168 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes
|
---|
| 169 | % To each projection object #iobj, corresponds an axis
|
---|
| 170 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the
|
---|
| 171 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field;
|
---|
| 172 |
|
---|
| 173 | %------------------------------------------------------------------------
|
---|
| 174 | %------------------------------------------------------------------------
|
---|
| 175 | % I - MAIN FUNCTION UVMAT (DO NOT MODIFY)
|
---|
| 176 | %------------------------------------------------------------------------
|
---|
| 177 | %------------------------------------------------------------------------
|
---|
| 178 | function varargout = uvmat(varargin)
|
---|
| 179 |
|
---|
| 180 | % Begin initialization code - DO NOT EDIT
|
---|
| 181 | gui_Singleton = 1;
|
---|
| 182 | gui_State = struct('gui_Name', mfilename, ...
|
---|
| 183 | 'gui_Singleton', gui_Singleton, ...
|
---|
| 184 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ...
|
---|
| 185 | 'gui_OutputFcn', @uvmat_OutputFcn, ...
|
---|
| 186 | 'gui_LayoutFcn', [], ...
|
---|
| 187 | 'gui_Callback', []);
|
---|
| 188 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once'))
|
---|
| 189 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
| 190 | end
|
---|
| 191 |
|
---|
| 192 | if nargout
|
---|
| 193 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
|
---|
| 194 | else
|
---|
| 195 | gui_mainfcn(gui_State, varargin{:});
|
---|
| 196 | end
|
---|
| 197 | % End initialization code - DO NOT EDIT
|
---|
| 198 |
|
---|
| 199 | %------------------------------------------------------------------------
|
---|
| 200 | % --- Executes just before the GUI uvmat is made visible.
|
---|
| 201 | function uvmat_OpeningFcn(hObject, eventdata, handles, input )
|
---|
| 202 | %------------------------------------------------------------------------
|
---|
| 203 |
|
---|
| 204 | %% Choose default command menuline output for uvmat (standard GUI)
|
---|
| 205 | handles.output = hObject;
|
---|
| 206 |
|
---|
| 207 | %% Update handles structure (standard GUI)
|
---|
| 208 | guidata(hObject, handles);
|
---|
| 209 |
|
---|
| 210 | %% set the position of colorbar and ancillary GUIs:
|
---|
| 211 | set(hObject,'Units','Normalized')
|
---|
| 212 | movegui(hObject,'center')
|
---|
| 213 | UvData.OpenParam.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
| 214 | UvData.OpenParam.SetObjectOrigin=[-0.05 -0.03]; %position for set_object
|
---|
| 215 | UvData.OpenParam.SetObjectSize=[0.3 0.7];
|
---|
| 216 | UvData.OpenParam.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE)
|
---|
| 217 | UvData.OpenParam.CalSize=[0.28 1];
|
---|
| 218 | UvData.axes3=[];%initiate the record of plotted field
|
---|
| 219 | UvData.axes2=[];
|
---|
| 220 | UvData.axes1=[];
|
---|
| 221 | AxeData.LimEditBox=1; %initialise AxeData
|
---|
| 222 | set(handles.axes3,'UserData',AxeData)
|
---|
| 223 |
|
---|
| 224 | %% set functions for the mouse and keyboard
|
---|
| 225 | set(handles.histo_u,'NextPlot','replacechildren');
|
---|
| 226 | set(handles.histo_v,'NextPlot','replacechildren');
|
---|
| 227 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
|
---|
| 228 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
|
---|
| 229 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
|
---|
| 230 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
|
---|
| 231 | set(hObject,'DeleteFcn',{@closefcn})%
|
---|
| 232 |
|
---|
| 233 | %% refresh projection plane
|
---|
| 234 | %UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 235 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 236 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 237 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
| 238 | set(handles.list_object_1,'Value',1);
|
---|
| 239 | % set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
| 240 | set(handles.list_object_1,'String',{''});
|
---|
| 241 | end
|
---|
| 242 | set(handles.Fields,'Value',1)
|
---|
| 243 | set(handles.Fields,'string',{''})
|
---|
| 244 |
|
---|
| 245 | %% TRANSFORM menu: builtin fcts
|
---|
| 246 | menu_str={'';'phys';'px';'phys_polar'};
|
---|
| 247 | UvData.OpenParam.NbBuiltin=numel(menu_str); %number of functions
|
---|
| 248 | path_uvmat=fileparts(which('uvmat'));
|
---|
| 249 | addpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 250 | fct_handle{1,1}=[];
|
---|
| 251 | testexist=zeros(size(menu_str'));%default
|
---|
| 252 | testexist(1)=1;
|
---|
| 253 | for ilist=2:length(menu_str)
|
---|
| 254 | if exist(menu_str{ilist},'file')
|
---|
| 255 | fct_handle{ilist,1}=str2func(menu_str{ilist});
|
---|
| 256 | testexist(ilist)=1;
|
---|
| 257 | else
|
---|
| 258 | testexist(ilist)=0;
|
---|
| 259 | end
|
---|
| 260 | end
|
---|
| 261 | rmpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 262 |
|
---|
| 263 | %% load the list of previously browsed files in menus Open and Open_1
|
---|
| 264 | dir_perso=prefdir; % path to the directory .matlab for personal data
|
---|
| 265 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
|
---|
| 266 | if exist(profil_perso,'file')
|
---|
| 267 | h=load (profil_perso);
|
---|
| 268 | if isfield(h,'MenuFile_1')
|
---|
| 269 | set(handles.MenuFile_1,'Label',h.MenuFile_1);
|
---|
| 270 | set(handles.MenuFile_1_1,'Label',h.MenuFile_1);
|
---|
| 271 | end
|
---|
| 272 | if isfield(h,'MenuFile_2')
|
---|
| 273 | set(handles.MenuFile_2,'Label',h.MenuFile_2);
|
---|
| 274 | set(handles.MenuFile_2_1,'Label',h.MenuFile_2);
|
---|
| 275 | end
|
---|
| 276 | if isfield(h,'MenuFile_3')
|
---|
| 277 | set(handles.MenuFile_3,'Label',h.MenuFile_3);
|
---|
| 278 | set(handles.MenuFile_3_1,'Label',h.MenuFile_3);
|
---|
| 279 | end
|
---|
| 280 | if isfield(h,'MenuFile_4')
|
---|
| 281 | set(handles.MenuFile_4,'Label',h.MenuFile_4);
|
---|
| 282 | set(handles.MenuFile_4_1,'Label',h.MenuFile_4);
|
---|
| 283 | end
|
---|
| 284 | if isfield(h,'MenuFile_5')
|
---|
| 285 | set(handles.MenuFile_5,'Label',h.MenuFile_5);
|
---|
| 286 | set(handles.MenuFile_5_1,'Label',h.MenuFile_5);
|
---|
| 287 | end
|
---|
| 288 | if isfield(h,'transform_fct') && iscell(h.transform_fct)
|
---|
| 289 | for ilist=1:length(h.transform_fct);
|
---|
| 290 | if exist(h.transform_fct{ilist},'file')
|
---|
| 291 | [path,file]=fileparts(h.transform_fct{ilist});
|
---|
| 292 | addpath(path)
|
---|
| 293 | h_func=str2func(file);
|
---|
| 294 | rmpath(path)
|
---|
| 295 | testexist=[testexist 1];
|
---|
| 296 | else
|
---|
| 297 | file='';
|
---|
| 298 | h_func=[];
|
---|
| 299 | testexist=[testexist 0];
|
---|
| 300 | end
|
---|
| 301 | fct_handle=[fct_handle; {h_func}]; %concatene the list of paths
|
---|
| 302 | menu_str=[menu_str; {file}];
|
---|
| 303 | end
|
---|
| 304 | end
|
---|
| 305 | end
|
---|
| 306 | menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
|
---|
| 307 | fct_handle=fct_handle(testexist==1);
|
---|
| 308 | menu_str=[menu_str;{'more...'}];
|
---|
| 309 | set(handles.transform_fct,'String',menu_str)
|
---|
| 310 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
|
---|
| 311 | set(handles.uvmat,'UserData',UvData)
|
---|
| 312 |
|
---|
| 313 | %% check the path and date of modification of all functions in uvmat
|
---|
| 314 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat
|
---|
| 315 | [errormsg,date_str]=check_functions;%check the path of the functions called by uvmat.m
|
---|
| 316 | date_str=['last modification: ' date_str];
|
---|
| 317 |
|
---|
| 318 | %% case of an input argument for uvmat
|
---|
| 319 | testinputfield=0;
|
---|
| 320 | inputfile=[];
|
---|
| 321 | Field=[];
|
---|
| 322 | if exist('input','var')
|
---|
| 323 | if ~isempty(errormsg)
|
---|
| 324 | msgbox_uvmat('WARNING',errormsg)
|
---|
| 325 | end
|
---|
| 326 | if ishandle(handles.UVMAT_title)
|
---|
| 327 | delete(handles.UVMAT_title)
|
---|
| 328 | end
|
---|
| 329 | if isstruct(input)
|
---|
| 330 | if isfield(input,'InputFile')
|
---|
| 331 | inputfile=input.InputFile;
|
---|
| 332 | end
|
---|
| 333 | Field=input;
|
---|
| 334 | elseif ischar(input)% file name introduced as input
|
---|
| 335 | inputfile=input;
|
---|
| 336 | elseif isnumeric(input)%simple matrix introduced as input
|
---|
| 337 | sizinput=size(input);
|
---|
| 338 | if sizinput(1)<=1 || sizinput(2)<=1
|
---|
| 339 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted')
|
---|
| 340 | return
|
---|
| 341 | end
|
---|
| 342 | Field.ListVarName={'A','coord_y','coord_x'};
|
---|
| 343 | Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'};
|
---|
| 344 | Field.A=input;
|
---|
| 345 | Field.coord_x=[0.5 size(input,2)-0.5];
|
---|
| 346 | Field.coord_y=[size(input,1)-0.5 0.5];
|
---|
| 347 | end
|
---|
| 348 | if ~isempty(inputfile)
|
---|
| 349 | %%%%% display the indput field %%%%%%%
|
---|
| 350 | display_file_name(hObject, eventdata, handles,inputfile)
|
---|
| 351 | %%%%%%%
|
---|
| 352 | testinputfield=1;
|
---|
| 353 | end
|
---|
| 354 | else
|
---|
| 355 | if ishandle(handles.UVMAT_title)
|
---|
| 356 | fid=fopen('revision.log');
|
---|
| 357 | if fid~=-1
|
---|
| 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);
|
---|
| 362 | else
|
---|
| 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]);
|
---|
| 365 | end
|
---|
| 366 | end
|
---|
| 367 | end
|
---|
| 368 | % set(handles.uvmat,'UserData',UvData)
|
---|
| 369 |
|
---|
| 370 | %% plot input field if exists
|
---|
| 371 | if testinputfield
|
---|
| 372 | %delete drawn objects
|
---|
| 373 | hother=findobj(handles.axes3,'Tag','proj_object');%find all the proj objects
|
---|
| 374 | for iobj=1:length(hother)
|
---|
| 375 | delete_object(hother(iobj))
|
---|
| 376 | end
|
---|
| 377 | if isempty(inputfile)
|
---|
| 378 | errormsg=refresh_field(handles,[],[],[],[],[],[],{Field});
|
---|
| 379 | set(handles.MenuTools,'Enable','on')
|
---|
| 380 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 381 | set(handles.edit_object,'Visible','on')
|
---|
| 382 | set(handles.list_object_1,'Visible','on')
|
---|
| 383 | set(handles.frame_object,'Visible','on')
|
---|
| 384 | if ~isempty(errormsg)
|
---|
| 385 | msgbox_uvmat('ERROR',errormsg)
|
---|
| 386 | end
|
---|
| 387 | end
|
---|
| 388 | end
|
---|
| 389 | set_vec_col_bar(handles) %update the display of color code for vectors
|
---|
| 390 |
|
---|
| 391 | %------------------------------------------------------------------------
|
---|
| 392 | % --- Outputs from this function are returned to the command menuline.
|
---|
| 393 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles)
|
---|
| 394 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
|
---|
| 395 |
|
---|
| 396 | %------------------------------------------------------------------------
|
---|
| 397 | %------------------------------------------------------------------------
|
---|
| 398 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
| 399 | % automatically sets the global properties when the rootfile name is introduced
|
---|
| 400 | % then activate the view-field action if selected
|
---|
| 401 | % it is activated either by clicking on the RootPath window or by the
|
---|
| 402 | % browser
|
---|
| 403 | %------------------------------------------------------------------------
|
---|
| 404 | %------------------------------------------------------------------------
|
---|
| 405 | % --- Executes on the menu Open/Browse...
|
---|
| 406 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
| 407 | function MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 408 | oldfile=read_file_boxes(handles);
|
---|
| 409 |
|
---|
| 410 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
|
---|
| 411 | dir_perso=prefdir;
|
---|
| 412 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 413 | if exist(profil_perso,'file')
|
---|
| 414 | h=load (profil_perso);
|
---|
| 415 | if isfield(h,'MenuFile_1')
|
---|
| 416 | oldfile=h.MenuFile_1;
|
---|
| 417 | end
|
---|
| 418 | end
|
---|
| 419 | end
|
---|
| 420 | [FileName, PathName] = uigetfile( ...
|
---|
| 421 | {'*.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)';
|
---|
| 422 | '*.xml', '.xml files '; ...
|
---|
| 423 | '*.xls', '.xls files '; ...
|
---|
| 424 | '*.civ', '.civ files '; ...
|
---|
| 425 | '*.jpg',' jpeg image files'; ...
|
---|
| 426 | '*.png','.png image files'; ...
|
---|
| 427 | '*.tif','.tif image files'; ...
|
---|
| 428 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 429 | '*.vol','.volume images (png)'; ...
|
---|
| 430 | '*.nc','.netcdf files'; ...
|
---|
| 431 | '*.cdf','.netcdf files'; ...
|
---|
| 432 | '*.cmx','.cmx text files ';...
|
---|
| 433 | '*.fig','.fig files (matlab fig)';...
|
---|
| 434 | '*.log','.log text files ';...
|
---|
| 435 | '*.dat','.dat text files ';...
|
---|
| 436 | '*.bat','.bat system command text files';...
|
---|
| 437 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 438 | 'Pick a file',oldfile);
|
---|
| 439 | %global filebase
|
---|
| 440 | fileinput=[PathName FileName];%complete file name
|
---|
| 441 | % testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 442 | % if ~isempty(testblank)
|
---|
| 443 | % msgbox_uvmat('ERROR',['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name'])
|
---|
| 444 | % return
|
---|
| 445 | % end
|
---|
| 446 | sizf=size(fileinput);
|
---|
| 447 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 448 |
|
---|
| 449 | % display the selected field and related information
|
---|
| 450 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 451 |
|
---|
| 452 | %update list of recent files in the menubar
|
---|
| 453 | MenuFile_1=fileinput;
|
---|
| 454 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 455 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 456 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 457 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 458 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 459 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 460 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 461 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 462 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 463 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 464 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 465 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 466 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 467 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 468 | dir_perso=prefdir;
|
---|
| 469 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 470 | if exist(profil_perso,'file')
|
---|
| 471 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 472 | else
|
---|
| 473 | txt=ver('MATLAB');
|
---|
| 474 | Release=txt.Release;
|
---|
| 475 | relnumb=str2double(Release(3:4));
|
---|
| 476 | if relnumb >= 14
|
---|
| 477 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 478 | else
|
---|
| 479 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 480 | end
|
---|
| 481 | end
|
---|
| 482 |
|
---|
| 483 | % -----------------------------------------------------------------------
|
---|
| 484 | % --- Open again the file whose name has been recorded in MenuFile_1
|
---|
| 485 | function MenuFile_1_Callback(hObject, eventdata, handles)
|
---|
| 486 | fileinput=get(handles.MenuFile_1,'Label');
|
---|
| 487 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 488 |
|
---|
| 489 | % -----------------------------------------------------------------------
|
---|
| 490 | % --- Open again the file whose name has been recorded in MenuFile_2
|
---|
| 491 | function MenuFile_2_Callback(hObject, eventdata, handles)
|
---|
| 492 | fileinput=get(handles.MenuFile_2,'Label');
|
---|
| 493 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 494 |
|
---|
| 495 | % -----------------------------------------------------------------------
|
---|
| 496 | % --- Open again the file whose name has been recorded in MenuFile_3
|
---|
| 497 | function MenuFile_3_Callback(hObject, eventdata, handles)
|
---|
| 498 | fileinput=get(handles.MenuFile_3,'Label');
|
---|
| 499 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 500 |
|
---|
| 501 | % -----------------------------------------------------------------------
|
---|
| 502 | % --- Open again the file whose name has been recorded in MenuFile_4
|
---|
| 503 | function MenuFile_4_Callback(hObject, eventdata, handles)
|
---|
| 504 | fileinput=get(handles.MenuFile_4,'Label');
|
---|
| 505 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 506 |
|
---|
| 507 | % -----------------------------------------------------------------------
|
---|
| 508 | % --- Open again the file whose name has been recorded in MenuFile_5
|
---|
| 509 | function MenuFile_5_Callback(hObject, eventdata, handles)
|
---|
| 510 | fileinput=get(handles.MenuFile_5,'Label');
|
---|
| 511 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 512 |
|
---|
| 513 | %------------------------------------------------------------------------
|
---|
| 514 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
| 515 | function display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 516 | if ~exist(fileinput,'file')
|
---|
| 517 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist'])
|
---|
| 518 | return
|
---|
| 519 | end
|
---|
| 520 | [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput);
|
---|
| 521 | ext_test=''; %default
|
---|
| 522 | if ~isempty(ext)
|
---|
| 523 | form=imformats(ext(2:end));%test valid Matlab image formats
|
---|
| 524 | if ~isempty(form)
|
---|
| 525 | ext_test='.image';
|
---|
| 526 | imainfo=imfinfo(fileinput);
|
---|
| 527 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 528 | i1='1'; % set the frame counter to 1 by default
|
---|
| 529 | i2='';
|
---|
| 530 | str_a='';
|
---|
| 531 | str_b='';
|
---|
| 532 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 533 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
| 534 | end
|
---|
| 535 | elseif isequal(lower(ext),'.avi')
|
---|
| 536 | ext_test='.image';
|
---|
| 537 | i1='1'; % set the frame counter to 1 by default
|
---|
| 538 | i2='';
|
---|
| 539 | str_a='';
|
---|
| 540 | str_b='';
|
---|
| 541 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 542 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
| 543 | else
|
---|
| 544 | ext_test=lower(ext);
|
---|
| 545 | end
|
---|
| 546 | end
|
---|
| 547 | switch ext_test
|
---|
| 548 | case {'.civ','.log','.cmx','.cmx2','.txt','.bat'} %display text file
|
---|
| 549 | edit(fileinput)
|
---|
| 550 | case '.fig' %display matlab figure
|
---|
| 551 | hfig=open(fileinput);
|
---|
| 552 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 553 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 554 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 555 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 556 | editxml(fileinput);
|
---|
| 557 | case {'.avi','.image','.vol','.nc','.cdf'}
|
---|
| 558 | set(handles.RootPath,'String',RootPath);
|
---|
| 559 | if isequal(SubDir,'')
|
---|
| 560 | rootname=fullfile(RootPath,RootFile);
|
---|
| 561 | else
|
---|
| 562 | rootname=fullfile(RootPath,SubDir,RootFile);
|
---|
| 563 | SubDir=['/' SubDir]; %display the separator
|
---|
| 564 | end
|
---|
| 565 | set(handles.SubDir,'String',SubDir);
|
---|
| 566 | set(handles.RootFile,'String',['/' RootFile]); %display the separator
|
---|
| 567 | indices=fileinput(length(rootname)+1:end);
|
---|
| 568 | indices(end-length(ext)+1:end)=[]; %remove extension
|
---|
| 569 | set(handles.FileIndex,'String',indices);
|
---|
| 570 | set(handles.FileIndex,'UserData',NomType);
|
---|
| 571 | set(handles.FileExt,'String',ext);
|
---|
| 572 | % fill file index counters
|
---|
| 573 | set(handles.i1,'String',i1);
|
---|
| 574 | set(handles.i2,'String',i2);
|
---|
| 575 | set(handles.j1,'String',str_a);
|
---|
| 576 | set(handles.j2,'String',str_b);
|
---|
| 577 |
|
---|
| 578 | % synchronise indices of the second input file if it exists
|
---|
| 579 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
|
---|
| 580 | [ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
| 581 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 582 | FileName_1=name_generator(FileBase_1,str2double(i1),str2double(i2),FileExt_1,NomType_1,1,stra2num(str_a),stra2num(str_b),SubDir_1);
|
---|
| 583 | if exist(FileName_1,'file')
|
---|
| 584 | FileIndex_1=name_generator('',str2double(i1),str2double(i2),'',NomType_1,1,stra2num(str_a),stra2num(str_b),'');
|
---|
| 585 | set(handles.FileIndex_1,'String',FileIndex_1)
|
---|
| 586 | else
|
---|
| 587 | set(handles.SubField,'Value',0)
|
---|
| 588 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 589 | end
|
---|
| 590 | end
|
---|
| 591 |
|
---|
| 592 | %enable other menus
|
---|
| 593 | set(handles.MenuOpen_1,'Enable','on')
|
---|
| 594 | set(handles.MenuFile_1_1,'Enable','on')
|
---|
| 595 | set(handles.MenuFile_2_1,'Enable','on')
|
---|
| 596 | set(handles.MenuFile_3_1,'Enable','on')
|
---|
| 597 | set(handles.MenuFile_4_1,'Enable','on')
|
---|
| 598 | set(handles.MenuFile_5_1,'Enable','on')
|
---|
| 599 | set(handles.MenuExport,'Enable','on')
|
---|
| 600 | set(handles.MenuExportFigure,'Enable','on')
|
---|
| 601 | set(handles.MenuExportMovie,'Enable','on')
|
---|
| 602 | set(handles.MenuTools,'Enable','on')
|
---|
| 603 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 604 | set(handles.edit_object,'Visible','on')
|
---|
| 605 | set(handles.list_object_1,'Visible','on')
|
---|
| 606 | set(handles.frame_object,'Visible','on')
|
---|
| 607 | %%%%%% initiate input file:
|
---|
| 608 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 609 | otherwise
|
---|
| 610 | msgbox_uvmat('ERROR',['invalid input file extension' ext])
|
---|
| 611 | end
|
---|
| 612 |
|
---|
| 613 | %------------------------------------------------------------------------
|
---|
| 614 | % --- Called by action in RootPath edit box
|
---|
| 615 | function RootPath_Callback(hObject,eventdata,handles)
|
---|
| 616 | %------------------------------------------------------------------------
|
---|
| 617 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 618 |
|
---|
| 619 | %------------------------------------------------------------------------
|
---|
| 620 | % --- Called by action in RootFile edit box
|
---|
| 621 | function SubDir_Callback(hObject, eventdata, handles)
|
---|
| 622 | %------------------------------------------------------------------------
|
---|
| 623 | %refresh the menu of input fields
|
---|
| 624 | Fields_Callback(hObject, eventdata, handles);
|
---|
| 625 | % refresh the current field
|
---|
| 626 | run0_Callback(hObject, eventdata, handles);
|
---|
| 627 |
|
---|
| 628 | %------------------------------------------------------------------------
|
---|
| 629 | % --- Called by action in RootFile edit box
|
---|
| 630 | function RootFile_Callback(hObject, eventdata, handles)
|
---|
| 631 | %------------------------------------------------------------------------
|
---|
| 632 | update_rootinfo(hObject,eventdata,handles)
|
---|
| 633 |
|
---|
| 634 | %------------------------------------------------------------------------
|
---|
| 635 | % --- Called by action in FileIndex edit box
|
---|
| 636 | function FileIndex_Callback(hObject, eventdata, handles)
|
---|
| 637 | %------------------------------------------------------------------------
|
---|
| 638 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 639 | if isempty(str2num(FileIndices))
|
---|
| 640 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices);
|
---|
| 641 | else
|
---|
| 642 | str1=FileIndices;
|
---|
| 643 | str2='';
|
---|
| 644 | str_a='';
|
---|
| 645 | str_b='';
|
---|
| 646 | end
|
---|
| 647 | set(handles.i1,'String',str1);
|
---|
| 648 | set(handles.i2,'String',str2);
|
---|
| 649 | set(handles.j1,'String',str_a);
|
---|
| 650 | set(handles.j2,'String',str_b);
|
---|
| 651 | run0_Callback(hObject, eventdata, handles)
|
---|
| 652 |
|
---|
| 653 | %------------------------------------------------------------------------
|
---|
| 654 | % --- Update information about a new field series (indices to scan, timing,
|
---|
| 655 | % calibration from an xml file, then refresh current plots
|
---|
| 656 | function update_rootinfo(hObject,eventdata,handles)
|
---|
| 657 | %------------------------------------------------------------------------
|
---|
| 658 | set(handles.RootPath,'BackgroundColor',[1 1 0])
|
---|
| 659 | drawnow
|
---|
| 660 | set(handles.Fields,'UserData',[])% reinialize data from uvmat opening
|
---|
| 661 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
| 662 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 663 | UvData.TestInputFile=1;
|
---|
| 664 | set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window
|
---|
| 665 |
|
---|
| 666 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 667 | if ~exist(FileName,'file')
|
---|
| 668 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 669 | return
|
---|
| 670 | end
|
---|
| 671 | nbfield=[];%default
|
---|
| 672 | nburst=[];%default
|
---|
| 673 |
|
---|
| 674 | % read timing and total frame number from the current file (movie files) !! may be overrid by xml file
|
---|
| 675 | XmlData.Time=[];%default
|
---|
| 676 | XmlData.GeometryCalib=[];%default
|
---|
| 677 | TimeUnit=[];%default
|
---|
| 678 | testima=0; %test for image input
|
---|
| 679 | imainfo=[];
|
---|
| 680 | ColorType='falsecolor'; %default
|
---|
| 681 | hhh='';
|
---|
| 682 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 683 | testima=1;
|
---|
| 684 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 685 | nbfield=imainfo.NumFrames;
|
---|
| 686 | nburst=1;
|
---|
| 687 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 688 | XmlData.Time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
|
---|
| 689 | TimeUnit='s';
|
---|
| 690 | hhh=which('mmreader');
|
---|
| 691 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
| 692 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image
|
---|
| 693 | testima=1;
|
---|
| 694 | if ~isequal(SubDir,'')
|
---|
| 695 | RootFile=get(handles.RootFile,'String');
|
---|
| 696 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 697 | else
|
---|
| 698 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 699 | end
|
---|
| 700 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
| 701 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 702 | nbfield=length(imainfo);
|
---|
| 703 | nburst=1;
|
---|
| 704 | end
|
---|
| 705 | end
|
---|
| 706 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 707 | UvData.MovieObject=mmreader([FileBase FileIndices FileExt]);
|
---|
| 708 | elseif isfield(UvData,'MovieObject')
|
---|
| 709 | UvData=rmfield(UvData,'MovieObject');
|
---|
| 710 | end
|
---|
| 711 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
| 712 | set(handles.npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
| 713 | set(handles.npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
| 714 | else
|
---|
| 715 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 716 | set(handles.npy,'String','');%fills nbre of pixels x box
|
---|
| 717 | end
|
---|
| 718 | set(handles.BW,'Value',strcmp(ColorType,'grayscale'))% select handles.BW if grayscale image
|
---|
| 719 |
|
---|
| 720 | % read parameters (time, geometric calibration..) from a documentation file (.xml advised)
|
---|
| 721 | filexml=[FileBase '.xml'];
|
---|
| 722 | fileciv=[FileBase '.civ'];
|
---|
| 723 | warntext='';%default warning message
|
---|
| 724 | NbSlice=1;%default
|
---|
| 725 |
|
---|
| 726 | if exist(filexml,'file')
|
---|
| 727 | set(handles.view_xml,'Visible','on')
|
---|
| 728 | set(handles.view_xml,'BackgroundColor',[1 1 0])
|
---|
| 729 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 730 | set(handles.view_xml,'String','view .xml')
|
---|
| 731 | drawnow
|
---|
| 732 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 733 | if ~isempty(warntext)
|
---|
| 734 | msgbox_uvmat('WARNING',warntext)
|
---|
| 735 | end
|
---|
| 736 | if isfield(XmlData,'TimeUnit')
|
---|
| 737 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
|
---|
| 738 | TimeUnit=XmlData.TimeUnit;
|
---|
| 739 | end
|
---|
| 740 | end
|
---|
| 741 | set(handles.view_xml,'BackgroundColor',[1 1 1])
|
---|
| 742 | drawnow
|
---|
| 743 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib)
|
---|
| 744 | XmlData.GeometryCalib
|
---|
| 745 | if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y')
|
---|
| 746 | set (handles.nb_slice,'String','volume')
|
---|
| 747 | end
|
---|
| 748 | hgeometry_calib=findobj('tag','geometry_calib');
|
---|
| 749 | if ~isempty(hgeometry_calib)
|
---|
| 750 | GUserData=get(hgeometry_calib,'UserData');
|
---|
| 751 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,filexml))
|
---|
| 752 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?');
|
---|
| 753 | if strcmp(answer,'Yes')
|
---|
| 754 | geometry_calib(filexml);%diplay the new calibration points and parameters in geometry_calib
|
---|
| 755 | end
|
---|
| 756 | end
|
---|
| 757 | end
|
---|
| 758 | end
|
---|
| 759 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 760 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 761 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 762 | GeometryCalib.Tx=0;
|
---|
| 763 | GeometryCalib.Ty=0;
|
---|
| 764 | GeometryCalib.Tz=1;
|
---|
| 765 | GeometryCalib.dpx=1;
|
---|
| 766 | GeometryCalib.dpy=1;
|
---|
| 767 | GeometryCalib.sx=1;
|
---|
| 768 | GeometryCalib.Cx=0;
|
---|
| 769 | GeometryCalib.Cy=0;
|
---|
| 770 | GeometryCalib.f=1;
|
---|
| 771 | GeometryCalib.kappa1=0;
|
---|
| 772 | GeometryCalib.CoordUnit='cm';
|
---|
| 773 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 774 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 775 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 776 | end
|
---|
| 777 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 778 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 779 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 780 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 781 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 782 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 783 | set(handles.view_xml,'Visible','on')
|
---|
| 784 | set(handles.view_xml,'String','view .civ')
|
---|
| 785 | else
|
---|
| 786 | set(handles.view_xml,'Visible','off')
|
---|
| 787 | end
|
---|
| 788 |
|
---|
| 789 | % store last index in handles.lat_i and .last_j
|
---|
| 790 | if ~isempty(XmlData.Time)
|
---|
| 791 | nbfield=size(XmlData.Time,1);
|
---|
| 792 | nburst=size(XmlData.Time,2);
|
---|
| 793 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
|
---|
| 794 | if isequal(nbfield,1) && ~isequal(nburst,1)% .Time is a line vector
|
---|
| 795 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 796 | if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
|
---|
| 797 | XmlData.Time=(XmlData.Time)';
|
---|
| 798 | nbfield=nburst;
|
---|
| 799 | nburst=1;
|
---|
| 800 | end
|
---|
| 801 | end
|
---|
| 802 | end
|
---|
| 803 | last_i_cell=get(handles.last_i,'String');
|
---|
| 804 | if isempty(nbfield)
|
---|
| 805 | last_i_cell{1}='';
|
---|
| 806 | else
|
---|
| 807 | last_i_cell{1}=num2str(nbfield);
|
---|
| 808 | end
|
---|
| 809 | set(handles.last_i,'String',last_i_cell)
|
---|
| 810 | last_j_cell=get(handles.last_j,'String');
|
---|
| 811 | if isempty(nburst)
|
---|
| 812 | last_j_cell{1}='';
|
---|
| 813 | else
|
---|
| 814 | last_j_cell{1}=num2str(nburst);
|
---|
| 815 | end
|
---|
| 816 | set(handles.last_j,'String',last_j_cell);
|
---|
| 817 |
|
---|
| 818 | % store geometric calibration in UvData
|
---|
| 819 | if isfield(XmlData,'GeometryCalib')
|
---|
| 820 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 821 | if isempty(GeometryCalib)
|
---|
| 822 | set(handles.pxcm,'String','')
|
---|
| 823 | set(handles.pycm,'String','')
|
---|
| 824 | set(handles.transform_fct,'Value',1); % no transform by default
|
---|
| 825 | else
|
---|
| 826 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
|
---|
| 827 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 828 | set(handles.pxcm,'String','var')
|
---|
| 829 | set(handles.pycm,'String','var')
|
---|
| 830 | elseif isfield(GeometryCalib,'fx_fy')
|
---|
| 831 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 832 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
| 833 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 834 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 835 | end
|
---|
| 836 | if ~get(handles.FixLimits,'Value')
|
---|
| 837 | set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off
|
---|
| 838 | end
|
---|
| 839 | if isfield(GeometryCalib,'SliceCoord')
|
---|
| 840 |
|
---|
| 841 | siz=size(GeometryCalib.SliceCoord);
|
---|
| 842 | if siz(1)>1
|
---|
| 843 | NbSlice=siz(1);
|
---|
| 844 | set(handles.slices,'Visible','on')
|
---|
| 845 | set(handles.slices,'Value',1)
|
---|
| 846 | end
|
---|
| 847 | if isfield(GeometryCalib,'VolumeScan') && isequal(GeometryCalib.VolumeScan,'y')
|
---|
| 848 | set(handles.nb_slice,'String','volume')
|
---|
| 849 | else
|
---|
| 850 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 851 | end
|
---|
| 852 | slices_Callback(hObject, eventdata, handles)
|
---|
| 853 | end
|
---|
| 854 | end
|
---|
| 855 | end
|
---|
| 856 |
|
---|
| 857 | %update the data attached to the uvmat interface
|
---|
| 858 | if ~isempty(TimeUnit)
|
---|
| 859 | set(handles.time_txt,'String',['time (' TimeUnit ')'])
|
---|
| 860 | end
|
---|
| 861 | UvData.TimeUnit=TimeUnit;
|
---|
| 862 | UvData.XmlData=XmlData;
|
---|
| 863 | UvData.NewSeries=1;
|
---|
| 864 | set(handles.uvmat,'UserData',UvData)
|
---|
| 865 |
|
---|
| 866 | %display warning message
|
---|
| 867 | if ~isequal(warntext,'')
|
---|
| 868 | msgbox_uvmat('WARNING',warntext);
|
---|
| 869 | end
|
---|
| 870 |
|
---|
| 871 | % set default options in menu 'Fields'
|
---|
| 872 |
|
---|
| 873 | if testima
|
---|
| 874 | elseif isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
|
---|
| 875 | Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ');
|
---|
| 876 | %col_vec=get(handles.col_vec,'String');
|
---|
| 877 | if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)%if the new input is Civx
|
---|
| 878 | FieldList=calc_field;
|
---|
| 879 | set(handles.Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
|
---|
| 880 | set(handles.Fields,'Value',2) % set menu to 'velocity'
|
---|
| 881 | col_vec=FieldList;
|
---|
| 882 | col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar)
|
---|
| 883 | else %general netcdf file (not civx)
|
---|
| 884 | set(handles.Fields,'Value',1) % set menu to 'get_field...
|
---|
| 885 | set(handles.Fields,'String',{'get_field...'})
|
---|
| 886 | col_vec={'get_field...'};
|
---|
| 887 | hget_field=findobj('Name','get_field');
|
---|
| 888 | if ~isempty(hget_field)%delete any existing get_field GUI for reinitialisation withthe new file series
|
---|
| 889 | hhget_field=guidata(hget_field);
|
---|
| 890 | if ~strcmp(get(hhget_field.inputfile,'String'),FileName)%delete any existing get_field GUI with file name different than the input
|
---|
| 891 | delete(hget_field)
|
---|
| 892 | end
|
---|
| 893 | end
|
---|
| 894 | end
|
---|
| 895 | set(handles.col_vec,'String',col_vec)
|
---|
| 896 | else
|
---|
| 897 | msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
|
---|
| 898 | return
|
---|
| 899 | end
|
---|
| 900 |
|
---|
| 901 | %% set index navigation options and refresh plots
|
---|
| 902 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 903 | drawnow
|
---|
| 904 | set_scan_options(hObject, eventdata, handles)
|
---|
| 905 |
|
---|
| 906 | %------------------------------------------------------------------------
|
---|
| 907 | %--- Set index navigation options for new series input and refresh plot
|
---|
| 908 | %------------------------------------------------------------------------
|
---|
| 909 | function set_scan_options(hObject, eventdata, handles)
|
---|
| 910 |
|
---|
| 911 | % set the corresponding index navigation options
|
---|
| 912 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 913 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 914 | last_i_str=get(handles.last_i,'String');
|
---|
| 915 | nbfield=str2num(last_i_str{1});
|
---|
| 916 | if numel(last_i_str)==2
|
---|
| 917 | nbfield=min(nbfield,str2num(last_i_str{2}));
|
---|
| 918 | end
|
---|
| 919 | state_j='off'; %default
|
---|
| 920 | scan_option='i';%default
|
---|
| 921 | NomTypeRaw=regexprep(NomType(2:end), '-', '');
|
---|
| 922 | if numel(regexp(NomTypeRaw,'\D'))>=1
|
---|
| 923 | state_j='on';
|
---|
| 924 | if isequal(nbfield,1)
|
---|
| 925 | scan_option='j'; %scan j index by default if nbfield=1
|
---|
| 926 | end
|
---|
| 927 | end
|
---|
| 928 | if ~isempty(NomType_1)
|
---|
| 929 | NomTypeRaw=regexprep(NomType_1(2:end), '-', '');
|
---|
| 930 | if numel(regexp(NomTypeRaw,'\D'))>=1
|
---|
| 931 | state_j='on';
|
---|
| 932 | if isequal(nbfield,1)
|
---|
| 933 | scan_option='j';
|
---|
| 934 | end
|
---|
| 935 | end
|
---|
| 936 | end
|
---|
| 937 | if isequal(scan_option,'i')
|
---|
| 938 | set(handles.scan_i,'Value',1)
|
---|
| 939 | scan_i_Callback(hObject, eventdata, handles);
|
---|
| 940 | else
|
---|
| 941 | set(handles.scan_j,'Value',1)
|
---|
| 942 | scan_j_Callback(hObject, eventdata, handles);
|
---|
| 943 | end
|
---|
| 944 | set(handles.scan_j,'Visible',state_j)
|
---|
| 945 | set(handles.j1,'Visible',state_j)
|
---|
| 946 | set(handles.j2,'Visible',state_j)
|
---|
| 947 | set(handles.last_j,'Visible',state_j);
|
---|
| 948 | set(handles.frame_j,'Visible',state_j);
|
---|
| 949 | set(handles.j_text,'Visible',state_j);
|
---|
| 950 |
|
---|
| 951 | %% view the field
|
---|
| 952 | run0_Callback(hObject, eventdata, handles); %view field
|
---|
| 953 | mask_test=get(handles.mask_test,'value');
|
---|
| 954 | if mask_test
|
---|
| 955 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 956 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 957 | delete(MaskData.maskhandle) %delete old mask
|
---|
| 958 | end
|
---|
| 959 | mask_test_Callback(hObject, eventdata, handles)
|
---|
| 960 | end
|
---|
| 961 |
|
---|
| 962 | %------------------------------------------------------------------------
|
---|
| 963 | % --- Executes on the menu Open/Browse_1 for the second input field,
|
---|
| 964 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
| 965 | function MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 966 | %------------------------------------------------------------------------
|
---|
| 967 | % huvmat=get(handles.run0,'parent');
|
---|
| 968 | UvData=get(handles.uvmat,'UserData');
|
---|
| 969 |
|
---|
| 970 | RootPath=get(handles.RootPath,'String');
|
---|
| 971 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 972 | {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
|
---|
| 973 | '*.xml', '.xml files '; ...
|
---|
| 974 | '*.xls', '.xls files '; ...
|
---|
| 975 | '*.civ', '.civ files '; ...
|
---|
| 976 | '*.jpg','.jpg image files'; ...
|
---|
| 977 | '*.png','.png image files'; ...
|
---|
| 978 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 979 | '*.nc','.netcdf files'; ...
|
---|
| 980 | '*.cdf','.netcdf files'; ...
|
---|
| 981 | '*.cmx','.cmx text files';...
|
---|
| 982 | '*.cmx2','.cmx2 text files';...
|
---|
| 983 | '*.fig','.fig files (matlab fig)';...
|
---|
| 984 | '*.log','.log text files ';...
|
---|
| 985 | '*.dat','.dat text files ';...
|
---|
| 986 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 987 | 'Pick a file',RootPath);
|
---|
| 988 | fileinput_1=[PathName FileName];%complete file name
|
---|
| 989 | % testblank=findstr(fileinput_1,' ');%look for blanks
|
---|
| 990 | % if ~isempty(testblank)
|
---|
| 991 | % msgbox_uvmat('ERROR',['The input file name ' fileinput_1 ' contains blank character : This is not allowed. Please change name'])
|
---|
| 992 | % return
|
---|
| 993 | % end
|
---|
| 994 | sizf=size(fileinput_1);
|
---|
| 995 | if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end
|
---|
| 996 |
|
---|
| 997 | % refresh the current displayed field
|
---|
| 998 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 999 |
|
---|
| 1000 | %update list of recent files in the menubar
|
---|
| 1001 | MenuFile_1=fileinput_1;
|
---|
| 1002 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 1003 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 1004 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 1005 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 1006 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 1007 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 1008 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 1009 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 1010 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 1011 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 1012 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 1013 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 1014 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 1015 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 1016 | dir_perso=prefdir;
|
---|
| 1017 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 1018 | if exist(profil_perso,'file')
|
---|
| 1019 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 1020 | else
|
---|
| 1021 | txt=ver('MATLAB');
|
---|
| 1022 | Release=txt.Release;
|
---|
| 1023 | relnumb=str2double(Release(3:4));
|
---|
| 1024 | if relnumb >= 14
|
---|
| 1025 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 1026 | else
|
---|
| 1027 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 1028 | end
|
---|
| 1029 | end
|
---|
| 1030 |
|
---|
| 1031 | % -----------------------------------------------------------------------
|
---|
| 1032 | % --- Open again as second field the file whose name has been recorded in MenuFile_1
|
---|
| 1033 | function MenuFile_1_1_Callback(hObject, eventdata, handles)
|
---|
| 1034 | % -----------------------------------------------------------------------
|
---|
| 1035 | fileinput_1=get(handles.MenuFile_1_1,'Label');
|
---|
| 1036 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1037 |
|
---|
| 1038 | % -----------------------------------------------------------------------
|
---|
| 1039 | % --- Open again as second field the file whose name has been recorded in MenuFile_2
|
---|
| 1040 | function MenuFile_2_1_Callback(hObject, eventdata, handles)
|
---|
| 1041 | % -----------------------------------------------------------------------
|
---|
| 1042 | fileinput_1=get(handles.MenuFile_2_1,'Label');
|
---|
| 1043 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1044 |
|
---|
| 1045 | % -----------------------------------------------------------------------
|
---|
| 1046 | % --- Open again as second field the file whose name has been recorded in MenuFile_3
|
---|
| 1047 | function MenuFile_3_1_Callback(hObject, eventdata, handles)
|
---|
| 1048 | % -----------------------------------------------------------------------
|
---|
| 1049 | fileinput_1=get(handles.MenuFile_3_1,'Label');
|
---|
| 1050 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1051 |
|
---|
| 1052 | % -----------------------------------------------------------------------
|
---|
| 1053 | % --- Open again as second field the file whose name has been recorded in MenuFile_4
|
---|
| 1054 | function MenuFile_4_1_Callback(hObject, eventdata, handles)
|
---|
| 1055 | % -----------------------------------------------------------------------
|
---|
| 1056 | fileinput_1=get(handles.MenuFile_4_1,'Label');
|
---|
| 1057 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1058 |
|
---|
| 1059 | % -----------------------------------------------------------------------
|
---|
| 1060 | % --- Open again as second field the file whose name has been recorded in MenuFile_5
|
---|
| 1061 | function MenuFile_5_1_Callback(hObject, eventdata, handles)
|
---|
| 1062 | % -----------------------------------------------------------------------
|
---|
| 1063 | fileinput_1=get(handles.MenuFile_5_1,'Label');
|
---|
| 1064 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1065 |
|
---|
| 1066 | %------------------------------------------------------------------------
|
---|
| 1067 | % fills the edit boxes RootPath_1, RootFile_1,NomType_1...from an input file name 'fileinput_1'
|
---|
| 1068 | %------------------------------------------------------------------------
|
---|
| 1069 | function display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1070 |
|
---|
| 1071 | %[path,name,ext]=fileparts(fileinput_1);
|
---|
| 1072 | [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
|
---|
| 1073 | nbfield_1=1; %default
|
---|
| 1074 | ext_test=FileExt_1;%default
|
---|
| 1075 | form=imformats(FileExt_1(2:end));
|
---|
| 1076 | if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab
|
---|
| 1077 | imainfo=imfinfo(fileinput_1);
|
---|
| 1078 | nbfield_1=length(imainfo);
|
---|
| 1079 | ext_test='.image';
|
---|
| 1080 | elseif isequal(lower(FileExt_1),'.avi')
|
---|
| 1081 | info=aviinfo(fileinput_1);
|
---|
| 1082 | nbfield_1=info.NumFrames;
|
---|
| 1083 | ext_test='.image';
|
---|
| 1084 | end
|
---|
| 1085 |
|
---|
| 1086 | %open directly fig or text files
|
---|
| 1087 | switch ext_test
|
---|
| 1088 | case {'.civ','.log','.cmx','.cmx2','.txt'} %display text file
|
---|
| 1089 | edit(fileinput)
|
---|
| 1090 | return
|
---|
| 1091 | case '.fig' %display matlab figure
|
---|
| 1092 | hfig=open(fileinput);
|
---|
| 1093 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 1094 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 1095 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 1096 | return
|
---|
| 1097 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 1098 | heditxml=editxml(fileinput);
|
---|
| 1099 | return
|
---|
| 1100 | case {'.image','.nc','.cdf'}
|
---|
| 1101 | % set(handles.FileIndex,'UserData',NomType_1);
|
---|
| 1102 | otherwise
|
---|
| 1103 | msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')
|
---|
| 1104 | return
|
---|
| 1105 | end
|
---|
| 1106 |
|
---|
| 1107 | % test for image series in a single file and synchronise file indices of the two series
|
---|
| 1108 | if nbfield_1 >1 %case of image with multiple frames
|
---|
| 1109 | if nbfield_1 < num_i1
|
---|
| 1110 | msgbox_uvmat('ERROR','current frame index beyond the input movie length')
|
---|
| 1111 | return
|
---|
| 1112 | else
|
---|
| 1113 | NomType_1='*'; %indicate a set of indexed frames within a single file
|
---|
| 1114 | filename_new=fileinput_1;
|
---|
| 1115 | end
|
---|
| 1116 | else % cases of data files
|
---|
| 1117 | RootPath=get(handles.RootPath,'String');
|
---|
| 1118 | RootFile=get(handles.RootFile,'String');
|
---|
| 1119 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 1120 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 1121 | if isequal(FileBase,FileBase_1)
|
---|
| 1122 | filename_new=fileinput_1;
|
---|
| 1123 | else
|
---|
| 1124 | num_i1=stra2num(get(handles.i1,'String'));%get the current file indices from counters
|
---|
| 1125 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1126 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1127 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1128 | [filename_new,idetect]=...
|
---|
| 1129 | 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
|
---|
| 1130 | indices=''; %default
|
---|
| 1131 | if ~idetect
|
---|
| 1132 | msgbox_uvmat('ERROR','second input file with indices corresponding to the first one does not exist')
|
---|
| 1133 | return
|
---|
| 1134 | end
|
---|
| 1135 | end
|
---|
| 1136 | end
|
---|
| 1137 | set(handles.FileIndex_1,'UserData',NomType_1);
|
---|
| 1138 |
|
---|
| 1139 | % make visible and fill the second raw of edit boxes
|
---|
| 1140 | set(handles.RootPath_1,'Visible','on')
|
---|
| 1141 | set(handles.RootFile_1,'Visible','on')
|
---|
| 1142 | set(handles.SubDir_1,'Visible','on');
|
---|
| 1143 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 1144 | set(handles.FileExt_1,'Visible','on');
|
---|
| 1145 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 1146 | if isequal(FileBase,FileBase_1)
|
---|
| 1147 | set(handles.RootPath_1,'String','"')
|
---|
| 1148 | set(handles.RootFile_1,'String','"');
|
---|
| 1149 | else
|
---|
| 1150 | set(handles.RootPath_1,'String',RootPath_1)
|
---|
| 1151 | set(handles.RootFile_1,'String',['/' RootFile_1]);
|
---|
| 1152 | end
|
---|
| 1153 | if isequal(SubDir_1,'')
|
---|
| 1154 | set(handles.SubDir_1,'String','');
|
---|
| 1155 | FileBaseSub_1=FileBase_1;
|
---|
| 1156 | else
|
---|
| 1157 | set(handles.SubDir_1,'String',['/' SubDir_1]);
|
---|
| 1158 | FileBaseSub_1=fullfile(FileBase_1,SubDir_1);
|
---|
| 1159 | end
|
---|
| 1160 | indices=filename_new(length(FileBaseSub_1)+1:end);
|
---|
| 1161 | indices(end-length(FileExt_1)+1:end)=[]; %remove extension
|
---|
| 1162 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1163 | set(handles.FileIndex_1,'UserData',NomType_1)
|
---|
| 1164 | set(handles.FileExt_1,'String',FileExt_1);
|
---|
| 1165 |
|
---|
| 1166 | % % default choice of fields
|
---|
| 1167 | % if isequal(ext_test,'.image')
|
---|
| 1168 | % % set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1169 | % % set(handles.Fields_1,'Value',2) % set menu to 'image'
|
---|
| 1170 | % elseif strcmp(FileExt_1,'.nc')||strcmp(FileExt_1,'.cdf')
|
---|
| 1171 | % Data=nc2struct(fileinput_1,[]);
|
---|
| 1172 | % % if isfield(Data,'absolut_time_T0')
|
---|
| 1173 | % % set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1174 | % % set(handles.Fields_1,'Value',4) % set menu to 'velocity'
|
---|
| 1175 | % % else
|
---|
| 1176 | % % set(handles.Fields_1,'Value',2) % set menu to 'get_field...'
|
---|
| 1177 | % % set(handles.Fields_1,'String',{'';'get_field...'});
|
---|
| 1178 | % % end
|
---|
| 1179 | % end
|
---|
| 1180 | set(handles.SubField,'Visible','on')
|
---|
| 1181 | set(handles.SubField,'Value',1)
|
---|
| 1182 | RootPath_1_Callback(hObject,eventdata,handles);
|
---|
| 1183 |
|
---|
| 1184 | %-----------------------------------------------------------------------
|
---|
| 1185 | % --- Called by action in RootPath_1 edit box
|
---|
| 1186 | function RootPath_1_Callback(hObject,eventdata,handles)
|
---|
| 1187 | % -----------------------------------------------------------------------
|
---|
| 1188 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1189 |
|
---|
| 1190 | %-----------------------------------------------------------------------
|
---|
| 1191 | % --- Called by action in RootFile_1 edit box
|
---|
| 1192 | function RootFile_1_Callback(hObject, eventdata, handles)
|
---|
| 1193 | % -----------------------------------------------------------------------
|
---|
| 1194 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1195 |
|
---|
| 1196 | %------------------------------------------------------------------------
|
---|
| 1197 | % --- Called by action in FileIndex_1 edit box
|
---|
| 1198 | function FileIndex_1_Callback(hObject, eventdata, handles)
|
---|
| 1199 | %------------------------------------------------------------------------
|
---|
| 1200 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1201 |
|
---|
| 1202 | %------------------------------------------------------------------------
|
---|
| 1203 | % --- Update information about a new second field series (indices to scan, timing,
|
---|
| 1204 | % calibration from an xml file, then refresh current plots
|
---|
| 1205 | function update_rootinfo_1(hObject,eventdata,handles) %A REVOIR
|
---|
| 1206 | % -----------------------------------------------------------------------
|
---|
| 1207 | set(handles.RootPath_1,'BackgroundColor',[1 1 0])% indicate active program by yellow color
|
---|
| 1208 | drawnow
|
---|
| 1209 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
| 1210 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 1211 |
|
---|
| 1212 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes_1(handles);
|
---|
| 1213 | if ~exist(FileName,'file')
|
---|
| 1214 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 1215 | end
|
---|
| 1216 | nbfield_1=[];%default
|
---|
| 1217 | nburst_1=[];%default
|
---|
| 1218 | XmlData.Time=[];
|
---|
| 1219 | XmlData.GeometryCalib=[];%default
|
---|
| 1220 | TimeUnit=[];
|
---|
| 1221 | if isfield(UvData,'TimeUnit')
|
---|
| 1222 | TimeUnit=UvData.TimeUnit;
|
---|
| 1223 | end
|
---|
| 1224 | TimeUnit_1=[];
|
---|
| 1225 | hhh='';%default, test for movie reading with mmreader
|
---|
| 1226 | imainfo=[];
|
---|
| 1227 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 1228 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 1229 | nbfield_1=imainfo.NumFrames;
|
---|
| 1230 | nburst_1=1;
|
---|
| 1231 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 1232 | time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
|
---|
| 1233 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
| 1234 | hhh=which('mmreader');
|
---|
| 1235 | elseif ~isempty(imformats(FileExt(2:end)))|| isequal(FileExt,'.vol')
|
---|
| 1236 | if ~isequal(SubDir,'')
|
---|
| 1237 | RootFile=get(handles.RootFile,'String');
|
---|
| 1238 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 1239 | else
|
---|
| 1240 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 1241 | end
|
---|
| 1242 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
| 1243 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 1244 | nbfield_1=length(imainfo);
|
---|
| 1245 | nburst_1=1;
|
---|
| 1246 | end
|
---|
| 1247 | end
|
---|
| 1248 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 1249 | UvData.MovieObject_1=mmreader([FileBase FileIndices FileExt]);
|
---|
| 1250 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 1251 | UvData=rmfield(UvData,'MovieObject_1');
|
---|
| 1252 | end
|
---|
| 1253 | if ~isempty(imainfo)% (an image has been introduced as second fierld input)
|
---|
| 1254 | 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
|
---|
| 1255 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
| 1256 | set(handles.npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
| 1257 | set(handles.npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
| 1258 | else
|
---|
| 1259 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 1260 | set(handles.npy,'String','');%fills nbre of pixels x box
|
---|
| 1261 | end
|
---|
| 1262 | set(handles.BW,'Value',strcmp(ColorType,'grayscale'))% select handles.BW if grayscale image
|
---|
| 1263 | end
|
---|
| 1264 | end
|
---|
| 1265 | % find scaling parameters
|
---|
| 1266 | filexml=[FileBase '.xml'];
|
---|
| 1267 | fileciv=[FileBase '.civ'];
|
---|
| 1268 | warntext='';%default warning text
|
---|
| 1269 | if exist(filexml,'file')
|
---|
| 1270 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 1271 | if ~isempty(warntext)
|
---|
| 1272 | msgbox_uvmat('WARNING',warntext)
|
---|
| 1273 | end
|
---|
| 1274 | if isfield(XmlData,'Camera')
|
---|
| 1275 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
|
---|
| 1276 | TimeUnit=XmlData.Camera.TimeUnit;
|
---|
| 1277 | end
|
---|
| 1278 | end
|
---|
| 1279 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 1280 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 1281 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 1282 | GeometryCalib.Tx=0;
|
---|
| 1283 | GeometryCalib.Ty=0;
|
---|
| 1284 | GeometryCalib.Tz=1;
|
---|
| 1285 | GeometryCalib.dpx=1;
|
---|
| 1286 | GeometryCalib.dpy=1;
|
---|
| 1287 | GeometryCalib.sx=1;
|
---|
| 1288 | GeometryCalib.Cx=0;
|
---|
| 1289 | GeometryCalib.Cy=0;
|
---|
| 1290 | GeometryCalib.f=1;
|
---|
| 1291 | GeometryCalib.kappa1=0;
|
---|
| 1292 | GeometryCalib.CoordUnit='cm';
|
---|
| 1293 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 1294 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 1295 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 1296 | end
|
---|
| 1297 |
|
---|
| 1298 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 1299 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 1300 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 1301 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 1302 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 1303 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 1304 | end
|
---|
| 1305 | if ~isempty(TimeUnit_1) && ~isequal(TimeUnit_1,TimeUnit)
|
---|
| 1306 | msgbox_uvmat('WARNING','the time units for the second series differs from the first one')
|
---|
| 1307 | end
|
---|
| 1308 |
|
---|
| 1309 | % store last index in handles.lat_i and .last_j
|
---|
| 1310 | if ~isempty(XmlData.Time)
|
---|
| 1311 | nbfield_1=size(XmlData.Time,1);
|
---|
| 1312 | nburst_1=size(XmlData.Time,2);
|
---|
| 1313 | end
|
---|
| 1314 | last_i_cell=get(handles.last_i,'String');
|
---|
| 1315 | if isempty(nbfield_1)
|
---|
| 1316 | last_i_cell{2}='';
|
---|
| 1317 | else
|
---|
| 1318 | last_i_cell{2}=num2str(nbfield_1);
|
---|
| 1319 | end
|
---|
| 1320 | set(handles.last_i,'String',last_i_cell)
|
---|
| 1321 | last_j_cell=get(handles.last_j,'String');
|
---|
| 1322 | if isempty(nburst_1)
|
---|
| 1323 | last_j_cell{2}='';
|
---|
| 1324 | else
|
---|
| 1325 | last_j_cell{2}=num2str(nburst_1);
|
---|
| 1326 | end
|
---|
| 1327 | set(handles.last_j,'String',last_j_cell);
|
---|
| 1328 | if ~isequal(last_i_cell{1},last_i_cell{2}) || ~isequal(last_j_cell{1},last_j_cell{2})
|
---|
| 1329 | msgbox_uvmat('WARNING','the numbers of input file of the second series differs from the first one')
|
---|
| 1330 | end
|
---|
| 1331 |
|
---|
| 1332 | % store calibration data
|
---|
| 1333 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 1334 | if isempty(GeometryCalib)
|
---|
| 1335 | if isfield(UvData, 'GeometryCalib_1')
|
---|
| 1336 | UvData=rmfield(UvData,'GeometryCalib_1');
|
---|
| 1337 | end
|
---|
| 1338 | else
|
---|
| 1339 | UvData.GeometryCalib_1=GeometryCalib;
|
---|
| 1340 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
|
---|
| 1341 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 1342 | set(handles.pxcm,'String','var')
|
---|
| 1343 | set(handles.pycm,'String','var')
|
---|
| 1344 | else
|
---|
| 1345 | if isfield(GeometryCalib,'fx_fy')
|
---|
| 1346 | pixcmx=GeometryCalib.fx_fy(1);
|
---|
| 1347 | pixcmy=GeometryCalib.fx_fy(2);
|
---|
| 1348 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 1349 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 1350 | end
|
---|
| 1351 | end
|
---|
| 1352 | end
|
---|
| 1353 | UvData.XmlData_1=XmlData;
|
---|
| 1354 | set(handles.uvmat,'UserData',UvData)%update the data attached to the uvmat interface
|
---|
| 1355 |
|
---|
| 1356 | if ~isequal(warntext,'')
|
---|
| 1357 | msgbox_uvmat('WARNING',warntext)
|
---|
| 1358 | end
|
---|
| 1359 |
|
---|
| 1360 | set(handles.RootPath_1,'BackgroundColor',[1 1 1])% signa the end the input operation
|
---|
| 1361 | drawnow
|
---|
| 1362 |
|
---|
| 1363 | set_scan_options(hObject, eventdata, handles)
|
---|
| 1364 |
|
---|
| 1365 | %---------------------------------------------------
|
---|
| 1366 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1367 | function scan_i_Callback(hObject, eventdata, handles)
|
---|
| 1368 | %---------------------------------------------------
|
---|
| 1369 | if get(handles.scan_i,'Value')==1
|
---|
| 1370 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1371 | set(handles.scan_j,'Value',0)
|
---|
| 1372 | % set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1373 | else
|
---|
| 1374 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1375 | set(handles.scan_j,'Value',1)
|
---|
| 1376 | % set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1377 | end
|
---|
| 1378 | scan_j_Callback(hObject, eventdata, handles)
|
---|
| 1379 |
|
---|
| 1380 | %-------------------------------------------------------------------
|
---|
| 1381 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1382 | function scan_j_Callback(hObject, eventdata, handles)
|
---|
| 1383 | %-------------------------------------------------------------------
|
---|
| 1384 | if get(handles.scan_j,'Value')==1
|
---|
| 1385 | set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1386 | set(handles.scan_i,'Value',0)
|
---|
| 1387 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1388 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1389 | switch NomType
|
---|
| 1390 | case {'_i_j1-j2','#_ab','%3dab'},% pair with j index
|
---|
| 1391 | set(handles.fix_pair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off')
|
---|
| 1392 | otherwise
|
---|
| 1393 | set(handles.fix_pair,'Visible','off')
|
---|
| 1394 | end
|
---|
| 1395 | else
|
---|
| 1396 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1397 | set(handles.scan_i,'Value',1)
|
---|
| 1398 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1399 | set(handles.fix_pair,'Visible','off')
|
---|
| 1400 | end
|
---|
| 1401 |
|
---|
| 1402 | %-------------------------------------------------------------------
|
---|
| 1403 | function i1_Callback(hObject, eventdata, handles)
|
---|
| 1404 | %-------------------------------------------------------------------
|
---|
| 1405 | set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1406 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1407 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1408 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1409 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1410 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1411 | indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1412 | set(handles.FileIndex,'String',indices)
|
---|
| 1413 | set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1414 | if get(handles.SubField,'Value')==1
|
---|
| 1415 | NomType_1=get(handles.FileIndex_1,'String');
|
---|
| 1416 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 1417 | [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);
|
---|
| 1418 | indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
|
---|
| 1419 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1420 | set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1421 | end
|
---|
| 1422 | %Run0_Callback(hObject, eventdata, handles)
|
---|
| 1423 |
|
---|
| 1424 | %-------------------------------------------------------------------
|
---|
| 1425 | function i2_Callback(hObject, eventdata, handles)
|
---|
| 1426 | set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1427 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1428 | %-------------------------------------------------------------------
|
---|
| 1429 |
|
---|
| 1430 | %-------------------------------------------------------------------
|
---|
| 1431 | function j1_Callback(hObject, eventdata, handles)
|
---|
| 1432 | set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1433 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1434 | %-------------------------------------------------------------------
|
---|
| 1435 |
|
---|
| 1436 | %-------------------------------------------------------------------
|
---|
| 1437 | function j2_Callback(hObject, eventdata, handles)
|
---|
| 1438 | set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1439 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1440 | %-------------------------------------------------------------------
|
---|
| 1441 |
|
---|
| 1442 | %-------------------------------------------------------------------
|
---|
| 1443 | function slices_Callback(hObject, eventdata, handles)
|
---|
| 1444 | %-------------------------------------------------------------------
|
---|
| 1445 | if get(handles.slices,'Value')==1
|
---|
| 1446 | set(handles.slices,'BackgroundColor',[1 1 0])
|
---|
| 1447 | set(handles.nb_slice,'Visible','on')
|
---|
| 1448 | set(handles.z_text,'Visible','on')
|
---|
| 1449 | set(handles.z_index,'Visible','on')
|
---|
| 1450 | nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1451 | else
|
---|
| 1452 | set(handles.nb_slice,'Visible','off')
|
---|
| 1453 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1454 | set(handles.z_text,'Visible','off')
|
---|
| 1455 | set(handles.z_index,'Visible','off')
|
---|
| 1456 | set(handles.masklevel,'Value',1)
|
---|
| 1457 | set(handles.masklevel,'String',{'1'})
|
---|
| 1458 | end
|
---|
| 1459 |
|
---|
| 1460 | %-------------------------------------------------------------------
|
---|
| 1461 | function nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1462 | %-------------------------------------------------------------------
|
---|
| 1463 | nb_slice_str=get(handles.nb_slice,'String');
|
---|
| 1464 | if isequal(nb_slice_str,'volume')
|
---|
| 1465 | num=stra2num(get(handles.j1,'String'));
|
---|
| 1466 | last_j=get(handles.last_j,'String');
|
---|
| 1467 | nbslice=str2double(last_j{1});
|
---|
| 1468 | else
|
---|
| 1469 | num=str2double(get(handles.i1,'String'));
|
---|
| 1470 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1471 | end
|
---|
| 1472 | z=mod(num-1,nbslice)+1;
|
---|
| 1473 | set(handles.z_index,'String',num2str(z))
|
---|
| 1474 | for ilist=1:nbslice
|
---|
| 1475 | list_index{ilist,1}=num2str(ilist);
|
---|
| 1476 | end
|
---|
| 1477 | set(handles.masklevel,'String',list_index)
|
---|
| 1478 | set(handles.masklevel,'Value',z)
|
---|
| 1479 |
|
---|
| 1480 | %------------------------------------------------------------------------
|
---|
| 1481 | % --- Executes on button press in view_xml.
|
---|
| 1482 | function view_xml_Callback(hObject, eventdata, handles)
|
---|
| 1483 | %------------------------------------------------------------------------
|
---|
| 1484 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
| 1485 | option=get(handles.view_xml,'String');
|
---|
| 1486 | if isequal(option,'view .xml')
|
---|
| 1487 | FileXml=[FileBase '.xml'];
|
---|
| 1488 | heditxml=editxml(FileXml);
|
---|
| 1489 | end
|
---|
| 1490 |
|
---|
| 1491 | %------------------------------------------------------------------------
|
---|
| 1492 | % --- Executes on button press in mask_test.
|
---|
| 1493 | function mask_test_Callback(hObject, eventdata, handles)
|
---|
| 1494 | %------------------------------------------------------------------------
|
---|
| 1495 | %case of view mask selection
|
---|
| 1496 | if isequal(get(handles.mask_test,'Value'),1)
|
---|
| 1497 | [FF,RootPath,FileBase]=read_file_boxes(handles);
|
---|
| 1498 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1499 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1500 | currentdir=pwd;
|
---|
| 1501 | cd(RootPath);
|
---|
| 1502 | maskfiles=dir('*_*mask_*.png');%look for a mask file
|
---|
| 1503 | cd(currentdir);%come back to the working directory
|
---|
| 1504 | mdetect=0;
|
---|
| 1505 | if ~isempty(maskfiles)
|
---|
| 1506 | for ilist=1:length(maskfiles)
|
---|
| 1507 | maskname=maskfiles(ilist).name;% take the first mask file in the list
|
---|
| 1508 | [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
|
---|
| 1509 | if ~strcmp(Mask_NomType{ilist},Mask_NomType{1})
|
---|
| 1510 | msgbox_uvmat('ERROR',['inconsistent mask types ' Mask_NomType{1} Mask_NomType{ilist } ' coexist in the current image directory'])
|
---|
| 1511 | return
|
---|
| 1512 | end
|
---|
| 1513 | [Path2,Name,ext]=fileparts(maskname);
|
---|
| 1514 | Namedouble=double(Name);
|
---|
| 1515 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
|
---|
| 1516 | ind_mask=findstr('mask',Name);
|
---|
| 1517 | i=ind_mask-1;
|
---|
| 1518 | while val(i)==0 && i>0
|
---|
| 1519 | i=i-1;
|
---|
| 1520 | end
|
---|
| 1521 | nbmask_str=str2num(Name(i+1:ind_mask-1));
|
---|
| 1522 | if ~isempty(nbmask_str)
|
---|
| 1523 | nbslice(ilist)=nbmask_str; % number of different masks (slices)
|
---|
| 1524 | end
|
---|
| 1525 | end
|
---|
| 1526 | if isequal(min(nbslice),max(nbslice))
|
---|
| 1527 | nbslice=nbslice(1);
|
---|
| 1528 | else
|
---|
| 1529 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory')
|
---|
| 1530 | return
|
---|
| 1531 | end
|
---|
| 1532 | if ~isempty(nbslice) && Name(i)=='_'
|
---|
| 1533 | Mask.Base=[FileBase Name(i:ind_mask+3)];
|
---|
| 1534 | Mask.NbSlice=nbslice;
|
---|
| 1535 | num_i1=mod(num_i1-1,nbslice)+1;
|
---|
| 1536 | Mask.NomType=Mask_NomType{1};
|
---|
| 1537 | [maskname,mdetect]=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
|
---|
| 1538 | mdetect=exist(maskname,'file');
|
---|
| 1539 | if mdetect
|
---|
| 1540 | set(handles.nb_slice,'String',Name(i+1:ind_mask-1));
|
---|
| 1541 | set(handles.nb_slice,'BackgroundColor',[1 1 0])
|
---|
| 1542 | set(handles.mask_test,'UserData',Mask);
|
---|
| 1543 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
| 1544 | if nbslice > 1
|
---|
| 1545 | set(handles.slices,'value',1)
|
---|
| 1546 | slices_Callback(hObject, eventdata, handles)
|
---|
| 1547 | end
|
---|
| 1548 | end
|
---|
| 1549 | end
|
---|
| 1550 | end
|
---|
| 1551 | errormsg=[];%default
|
---|
| 1552 | if mdetect==0
|
---|
| 1553 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 1554 | {'*.png', ' (*.png)';
|
---|
| 1555 | '*.png', '.png files '; ...
|
---|
| 1556 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 1557 | 'Pick a mask file *.png',FileBase);
|
---|
| 1558 | maskname=fullfile(PathName,FileName);
|
---|
| 1559 | if ~exist(maskname,'file')
|
---|
| 1560 | errormsg='no file browsed';
|
---|
| 1561 | end
|
---|
| 1562 | [RootDir,RootFile,x1,x2,xa,xb,xext,Mask.NomType]=name2display(maskname);
|
---|
| 1563 | Mask.Base=fullfile(RootDir,RootFile);
|
---|
| 1564 | Mask.NbSlice=1;
|
---|
| 1565 | set(handles.mask_test,'UserData',Mask);
|
---|
| 1566 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
| 1567 | end
|
---|
| 1568 | if isempty(errormsg)
|
---|
| 1569 | errormsg=update_mask(handles,num_i1,num_j1);
|
---|
| 1570 | end
|
---|
| 1571 | if ~isempty(errormsg)
|
---|
| 1572 | set(handles.mask_test,'Value',0)
|
---|
| 1573 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1574 | end
|
---|
| 1575 | else
|
---|
| 1576 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1577 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 1578 | delete(MaskData.maskhandle)
|
---|
| 1579 | end
|
---|
| 1580 | set(handles.mask_test,'UserData',[])
|
---|
| 1581 | %huvmat=get(handles.mask_test,'parent');
|
---|
| 1582 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1583 | if isfield(UvData,'MaskName')
|
---|
| 1584 | UvData=rmfield(UvData,'MaskName');
|
---|
| 1585 | set(handles.uvmat,'UserData',UvData)
|
---|
| 1586 | end
|
---|
| 1587 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1588 | end
|
---|
| 1589 |
|
---|
| 1590 | %-------------------------------------------------------------------
|
---|
| 1591 | function errormsg=update_mask(handles,num_i1,num_j1)
|
---|
| 1592 | %-------------------------------------------------------------------
|
---|
| 1593 | errormsg=[];%default
|
---|
| 1594 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1595 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1596 | uistack(MaskData.maskhandle,'top');
|
---|
| 1597 | end
|
---|
| 1598 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
| 1599 | MaskName=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
| 1600 | huvmat=get(handles.mask_test,'parent');
|
---|
| 1601 | UvData=get(huvmat,'UserData');
|
---|
| 1602 |
|
---|
| 1603 | %update mask image if the mask is new
|
---|
| 1604 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
| 1605 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
| 1606 | set(huvmat,'UserData',UvData);
|
---|
| 1607 | if ~exist(MaskName,'file')
|
---|
| 1608 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1609 | delete(MaskData.maskhandle)
|
---|
| 1610 | end
|
---|
| 1611 | else
|
---|
| 1612 | %read mask image
|
---|
| 1613 | Mask.AName='image';
|
---|
| 1614 | Mask.A=imread(MaskName);
|
---|
| 1615 | npxy=size(Mask.A);
|
---|
| 1616 | test_error=0;
|
---|
| 1617 | if length(npxy)>2
|
---|
| 1618 | errormsg=[MaskName ' is not a grey scale image'];
|
---|
| 1619 | return
|
---|
| 1620 | elseif ~isa(Mask.A,'uint8')
|
---|
| 1621 | errormsg=[MaskName ' is not a 8 bit grey level image'];
|
---|
| 1622 | return
|
---|
| 1623 | end
|
---|
| 1624 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
| 1625 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
| 1626 | Mask.CoordUnit='pixel';
|
---|
| 1627 | if isequal(get(handles.slices,'Value'),1)
|
---|
| 1628 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
| 1629 | num_i1=str2num(get(handles.i1,'String'));
|
---|
| 1630 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
| 1631 | end
|
---|
| 1632 | %px to phys or other transform on field
|
---|
| 1633 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1634 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1635 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1636 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 1637 | transform=transform_list{choice_value};
|
---|
| 1638 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
| 1639 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 1640 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 1641 | Mask=transform(Mask,UvData.XmlData);
|
---|
| 1642 | end
|
---|
| 1643 | end
|
---|
| 1644 | flagmask=Mask.A < 200;
|
---|
| 1645 |
|
---|
| 1646 | %make brown color image
|
---|
| 1647 | imflag(:,:,1)=0.9*flagmask;
|
---|
| 1648 | imflag(:,:,2)=0.7*flagmask;
|
---|
| 1649 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
| 1650 |
|
---|
| 1651 | %update mask image
|
---|
| 1652 | hmask=[]; %default
|
---|
| 1653 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1654 | hmask=MaskData.maskhandle;
|
---|
| 1655 | end
|
---|
| 1656 | if ~isempty(hmask)
|
---|
| 1657 | set(hmask,'CData',imflag)
|
---|
| 1658 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
| 1659 | set(hmask,'XData',Mask.AX);
|
---|
| 1660 | set(hmask,'YData',Mask.AY);
|
---|
| 1661 | % uistack(hmask,'top')
|
---|
| 1662 | else
|
---|
| 1663 | axes(handles.axes3)
|
---|
| 1664 | hold on
|
---|
| 1665 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
| 1666 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
| 1667 | set(handles.mask_test,'UserData',MaskData)
|
---|
| 1668 | end
|
---|
| 1669 | end
|
---|
| 1670 | end
|
---|
| 1671 |
|
---|
| 1672 |
|
---|
| 1673 | %-------------------------------------------------------------------
|
---|
| 1674 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
| 1675 | %-------------------------------------------------------------------
|
---|
| 1676 | huvmat=get(handles.MenuExport,'parent');
|
---|
| 1677 | %UvData=get(huvmat,'UserData');
|
---|
| 1678 | hfig=figure;
|
---|
| 1679 | copyobj(handles.axes3,hfig);
|
---|
| 1680 | map=colormap(handles.axes3);
|
---|
| 1681 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 1682 | colorbar
|
---|
| 1683 |
|
---|
| 1684 | %-------------------------------------------------------------------
|
---|
| 1685 | %-------------------------------------------------------------------
|
---|
| 1686 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
| 1687 | %-------------------------------------------------------------------
|
---|
| 1688 |
|
---|
| 1689 | %-------------------------------------------------------------------
|
---|
| 1690 | % --- Executes on button press in runplus: make one step forward and call
|
---|
| 1691 | % --- run0. The step forward is along the fields series 1 or 2 depending on
|
---|
| 1692 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
| 1693 | function runplus_Callback(hObject, eventdata, handles)
|
---|
| 1694 | %-------------------------------------------------------------------
|
---|
| 1695 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1696 | drawnow
|
---|
| 1697 | %TODO: introduce the option: increment ='*' to move to the next available view
|
---|
| 1698 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1699 | if isnan(increment)
|
---|
| 1700 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1701 | increment=1;
|
---|
| 1702 | end
|
---|
| 1703 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1704 | if ~isempty(errormsg)
|
---|
| 1705 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1706 | end
|
---|
| 1707 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
| 1708 |
|
---|
| 1709 | %-------------------------------------------------------------------
|
---|
| 1710 | % --- Executes on button press in runmin: make one step backward and call
|
---|
| 1711 | % --- run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 1712 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
| 1713 | function runmin_Callback(hObject, eventdata, handles)
|
---|
| 1714 | %-------------------------------------------------------------------
|
---|
| 1715 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1716 | drawnow
|
---|
| 1717 | increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1718 | if isnan(increment)
|
---|
| 1719 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1720 | increment=1;
|
---|
| 1721 | end
|
---|
| 1722 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1723 | if ~isempty(errormsg)
|
---|
| 1724 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1725 | end
|
---|
| 1726 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
| 1727 |
|
---|
| 1728 | %-------------------------------------------------------------------
|
---|
| 1729 | % -- Executes on button press in Movie: make a series of +> steps
|
---|
| 1730 | function Movie_Callback(hObject, eventdata, handles)
|
---|
| 1731 | %------------------------------------------------------------------
|
---|
| 1732 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1733 | drawnow
|
---|
| 1734 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1735 | if isnan(increment)
|
---|
| 1736 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1737 | increment=1;
|
---|
| 1738 | end
|
---|
| 1739 | set(handles.STOP,'Visible','on')
|
---|
| 1740 | set(handles.speed,'Visible','on')
|
---|
| 1741 | set(handles.speed_txt,'Visible','on')
|
---|
| 1742 | set(handles.Movie,'BusyAction','queue')
|
---|
| 1743 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1744 |
|
---|
| 1745 | while get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
|
---|
| 1746 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1747 | if ~isempty(errormsg)
|
---|
| 1748 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1749 | return
|
---|
| 1750 | end
|
---|
| 1751 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1752 | end
|
---|
| 1753 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1754 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 1755 | set(handles.uvmat,'UserData',UvData);
|
---|
| 1756 | end
|
---|
| 1757 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1758 |
|
---|
| 1759 | %-------------------------------------------------------------------
|
---|
| 1760 | % -- Executes on button press in Movie: make a series of <- steps
|
---|
| 1761 | function MovieBackward_Callback(hObject, eventdata, handles)
|
---|
| 1762 | %------------------------------------------------------------------
|
---|
| 1763 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1764 | drawnow
|
---|
| 1765 | increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1766 | if isnan(increment)
|
---|
| 1767 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1768 | increment=1;
|
---|
| 1769 | end
|
---|
| 1770 | set(handles.STOP,'Visible','on')
|
---|
| 1771 | set(handles.speed,'Visible','on')
|
---|
| 1772 | set(handles.speed_txt,'Visible','on')
|
---|
| 1773 | set(handles.MovieBackward,'BusyAction','queue')
|
---|
| 1774 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1775 |
|
---|
| 1776 | while get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
|
---|
| 1777 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1778 | if ~isempty(errormsg)
|
---|
| 1779 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1780 | return
|
---|
| 1781 | end
|
---|
| 1782 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1783 | end
|
---|
| 1784 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1785 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 1786 | set(handles.uvmat,'UserData',UvData);
|
---|
| 1787 | end
|
---|
| 1788 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1789 |
|
---|
| 1790 | %-------------------------------------------------------------------
|
---|
| 1791 | function STOP_Callback(hObject, eventdata, handles)
|
---|
| 1792 | %-------------------------------------------------------------------
|
---|
| 1793 | set(handles.movie_pair,'BusyAction','Cancel')
|
---|
| 1794 | set(handles.movie_pair,'value',0)
|
---|
| 1795 | set(handles.Movie,'BusyAction','Cancel')
|
---|
| 1796 | set(handles.MovieBackward,'BusyAction','Cancel')
|
---|
| 1797 | set(handles.MenuExportMovie,'BusyAction','Cancel')
|
---|
| 1798 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1799 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1800 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1801 |
|
---|
| 1802 | %------------------------------------------------------------------
|
---|
| 1803 | function errormsg=runpm(hObject,eventdata,handles,increment)
|
---|
| 1804 | %------------------------------------------------------------------
|
---|
| 1805 | %check for mï¿œovie pair status
|
---|
| 1806 | movie_status=get(handles.movie_pair,'Value');
|
---|
| 1807 | if isequal(movie_status,1)
|
---|
| 1808 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
|
---|
| 1809 | end
|
---|
| 1810 | %read the data on the current input rootfile(s)
|
---|
| 1811 |
|
---|
| 1812 | [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
|
---|
| 1813 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1814 |
|
---|
| 1815 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1816 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1817 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1818 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1819 |
|
---|
| 1820 | sub_value= get(handles.SubField,'Value');
|
---|
| 1821 | if sub_value % a second input file has been entered
|
---|
| 1822 | [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
| 1823 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices_1);
|
---|
| 1824 | num1_1=stra2num(str1);%current set of indices for the second field (may be set different than the main indices)
|
---|
| 1825 | num2_1=stra2num(str2);
|
---|
| 1826 | num_a_1=stra2num(str_a);
|
---|
| 1827 | num_b_1=stra2num(str_b);
|
---|
| 1828 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 1829 | else
|
---|
| 1830 | filename_1=[];
|
---|
| 1831 | end
|
---|
| 1832 |
|
---|
| 1833 | comp_input=get(handles.fix_pair,'Value');
|
---|
| 1834 |
|
---|
| 1835 | %case of scanning along the first direction (rootfile numbers)
|
---|
| 1836 | if get(handles.scan_i,'Value')==1% case of scanning along index i
|
---|
| 1837 | num1=num1+increment;
|
---|
| 1838 | num2=num2+increment;
|
---|
| 1839 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
| 1840 | if sub_value% set the second field name and indices
|
---|
| 1841 | num1_1=num1_1+increment;
|
---|
| 1842 | num2_1=num2_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);
|
---|
| 1844 | end
|
---|
| 1845 | else % case of scanning along index j (burst numbers)
|
---|
| 1846 | num_a=num_a+increment;
|
---|
| 1847 | num_b=num_b+increment;
|
---|
| 1848 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
| 1849 | if sub_value
|
---|
| 1850 | num_a_1=num_a_1+increment;
|
---|
| 1851 | num_b_1=num_b_1+increment;
|
---|
| 1852 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
| 1853 | end
|
---|
| 1854 | end
|
---|
| 1855 |
|
---|
| 1856 | % refresh plots
|
---|
| 1857 | errormsg=refresh_field(handles,filename,filename_1,num1,num2,num_a,num_b);
|
---|
| 1858 | if isempty(errormsg) %update the index counters
|
---|
| 1859 | set(handles.i1,'String',num2stra(num1,NomType,1));
|
---|
| 1860 | if isequal(num2,num1)
|
---|
| 1861 | set(handles.i2,'String','');
|
---|
| 1862 | else
|
---|
| 1863 | set(handles.i2,'String',num2stra(num2,NomType,1));
|
---|
| 1864 | end
|
---|
| 1865 | set(handles.j1,'String',num2stra(num_a,NomType,2));
|
---|
| 1866 | if isequal(num_b,num_a)
|
---|
| 1867 | set(handles.j2,'String','');
|
---|
| 1868 | else
|
---|
| 1869 | set(handles.j2,'String',num2stra(num_b,NomType,2));
|
---|
| 1870 | end
|
---|
| 1871 | [indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1872 | set(handles.FileIndex,'String',indices);
|
---|
| 1873 | if ~isempty(filename_1)
|
---|
| 1874 | indices_1=name_generator('',num1_1,num_a_1,'',NomType_1,1,num2_1,num_b_1,'');
|
---|
| 1875 | set(handles.FileIndex_1,'String',indices_1);
|
---|
| 1876 | end
|
---|
| 1877 | if isequal(movie_status,1)
|
---|
| 1878 | set(handles.movie_pair,'Value',1)
|
---|
| 1879 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
|
---|
| 1880 | end
|
---|
| 1881 | end
|
---|
| 1882 |
|
---|
| 1883 |
|
---|
| 1884 | %-------------------------------------------------------
|
---|
| 1885 | % --- Executes on button press in movie_pair: create an alternating movie with two view
|
---|
| 1886 | %-------------------------------------------------------
|
---|
| 1887 | function movie_pair_Callback(hObject, eventdata, handles)
|
---|
| 1888 | status=get(handles.movie_pair,'value');
|
---|
| 1889 | if isequal(status,0)
|
---|
| 1890 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
|
---|
| 1891 | set(handles.i2,'String','')
|
---|
| 1892 | set(handles.j2,'String','')
|
---|
| 1893 | return
|
---|
| 1894 | else
|
---|
| 1895 | set(handles.movie_pair,'BusyAction','queue')
|
---|
| 1896 | end
|
---|
| 1897 | %initialisation
|
---|
| 1898 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1899 | drawnow
|
---|
| 1900 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 1901 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 1902 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 1903 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1904 | if isequal(FieldName,'image')
|
---|
| 1905 | test_1=0;
|
---|
| 1906 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
|
---|
| 1907 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1908 | else
|
---|
| 1909 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 1910 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 1911 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 1912 | if isequal(FieldName,'image')
|
---|
| 1913 | test_1=1;
|
---|
| 1914 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes_1(handles);
|
---|
| 1915 | NomType=get(handles.FileIndex_1,'UserData');
|
---|
| 1916 | else
|
---|
| 1917 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
|
---|
| 1918 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1919 | return
|
---|
| 1920 | end
|
---|
| 1921 | end
|
---|
| 1922 |
|
---|
| 1923 | num_i1=str2double(get(handles.i1,'String'));
|
---|
| 1924 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1925 | num_i2=str2double(get(handles.i2,'String'));
|
---|
| 1926 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1927 | if isnan(num_j2)
|
---|
| 1928 | if isempty(num_i2)
|
---|
| 1929 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
|
---|
| 1930 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1931 | return
|
---|
| 1932 | else
|
---|
| 1933 | num_j2=num_j1;%repeat the index i1 by default
|
---|
| 1934 | end
|
---|
| 1935 | end
|
---|
| 1936 | if isnan(num_i2)
|
---|
| 1937 | num_i2=num_i1;%repeat the index i1 by default
|
---|
| 1938 | end
|
---|
| 1939 | imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
|
---|
| 1940 | if ~exist(imaname_1,'file')
|
---|
| 1941 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']);
|
---|
| 1942 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1943 | return
|
---|
| 1944 | end
|
---|
| 1945 |
|
---|
| 1946 | %read the second image
|
---|
| 1947 | Field.AName='image';
|
---|
| 1948 | if test_1
|
---|
| 1949 | Field_a=UvData.Field_1;
|
---|
| 1950 | else
|
---|
| 1951 | Field_a=UvData.Field;
|
---|
| 1952 | end
|
---|
| 1953 | Field_b.AX=Field_a.AX;
|
---|
| 1954 | Field_b.AY=Field_a.AY;
|
---|
| 1955 | % z index
|
---|
| 1956 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1957 | if ~isempty(nbslice)
|
---|
| 1958 | Field_b.ZIndex=mod(num_i2-1,nbslice)+1;
|
---|
| 1959 | end
|
---|
| 1960 | Field_b.CoordUnit='pixel';
|
---|
| 1961 | %determine the input file type
|
---|
| 1962 | if (test_1 && isfield(UvData,'MovieObject_1'))||(~test_1 && isfield(UvData,'MovieObject'))
|
---|
| 1963 | FileType='movie';
|
---|
| 1964 | elseif isequal(lower(Ext),'.avi')
|
---|
| 1965 | FileType='avi';
|
---|
| 1966 | elseif isequal(lower(Ext),'.vol')
|
---|
| 1967 | FileType='vol';
|
---|
| 1968 | else
|
---|
| 1969 | form=imformats(Ext(2:end));
|
---|
| 1970 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 1971 | if isequal(NomType,'*');
|
---|
| 1972 | FileType='multimage';
|
---|
| 1973 | else
|
---|
| 1974 | FileType='image';
|
---|
| 1975 | end
|
---|
| 1976 | end
|
---|
| 1977 | end
|
---|
| 1978 | switch FileType
|
---|
| 1979 | case 'movie'
|
---|
| 1980 | if test_1
|
---|
| 1981 | Field_b.A=read(UvData.MovieObject_1,num_i2);
|
---|
| 1982 | else
|
---|
| 1983 | Field_b.A=read(UvData.MovieObject,num_i2);
|
---|
| 1984 | end
|
---|
| 1985 | case 'avi'
|
---|
| 1986 | mov=aviread(imaname_1,num_i2);
|
---|
| 1987 | Field_b.A=frame2im(mov(1));
|
---|
| 1988 | case 'vol'
|
---|
| 1989 | Field_b.A=imread(imaname_1);
|
---|
| 1990 | case 'multimage'
|
---|
| 1991 | Field_b.A=imread(imaname_1,num_i2);
|
---|
| 1992 | case 'image'
|
---|
| 1993 | Field_b.A=imread(imaname_1);
|
---|
| 1994 | end
|
---|
| 1995 | if get(handles.slices,'Value')
|
---|
| 1996 | Field.ZIndex=str2double(get(handles.z_index,'String'));
|
---|
| 1997 | end
|
---|
| 1998 |
|
---|
| 1999 | %px to phys or other transform on field
|
---|
| 2000 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 2001 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 2002 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 2003 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 2004 | transform=transform_list{choice_value};
|
---|
| 2005 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
| 2006 | if test_1 && isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 2007 | Field_a=transform(Field_a,UvData.XmlData_1);%the first field has been stored without transform
|
---|
| 2008 | Field_b=transform(Field_b,UvData.XmlData_1);
|
---|
| 2009 | elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib
|
---|
| 2010 | Field_b=transform(Field_b,UvData.XmlData);
|
---|
| 2011 | end
|
---|
| 2012 | end
|
---|
| 2013 |
|
---|
| 2014 | % make movie until movie speed is set to 0 or STOP is activated
|
---|
| 2015 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
|
---|
| 2016 | set(handles.STOP,'Visible','on')
|
---|
| 2017 | set(handles.speed,'Visible','on')
|
---|
| 2018 | set(handles.speed_txt,'Visible','on')
|
---|
| 2019 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
|
---|
| 2020 | % read and plot the series of images in non erase mode
|
---|
| 2021 | set(hima,'CData',Field_b.A);
|
---|
| 2022 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 2023 | set(hima,'CData',Field_a.A);
|
---|
| 2024 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 2025 | end
|
---|
| 2026 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 2027 |
|
---|
| 2028 | %------------------------------------------------------------------------
|
---|
| 2029 | % --- Executes on button press in run0.
|
---|
| 2030 | function run0_Callback(hObject, eventdata, handles)
|
---|
| 2031 | %------------------------------------------------------------------------
|
---|
| 2032 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 2033 | drawnow
|
---|
| 2034 | filename=read_file_boxes(handles);
|
---|
| 2035 |
|
---|
| 2036 | filename_1=[];%default
|
---|
| 2037 | if get(handles.SubField,'Value')
|
---|
| 2038 | filename_1=read_file_boxes_1(handles);
|
---|
| 2039 | end
|
---|
| 2040 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 2041 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 2042 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 2043 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 2044 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
|
---|
| 2045 | if ~isempty(errormsg)
|
---|
| 2046 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 2047 | else
|
---|
| 2048 | set(handles.i1,'BackgroundColor',[1 1 1])
|
---|
| 2049 | set(handles.i2,'BackgroundColor',[1 1 1])
|
---|
| 2050 | set(handles.j1,'BackgroundColor',[1 1 1])
|
---|
| 2051 | set(handles.j2,'BackgroundColor',[1 1 1])
|
---|
| 2052 | set(handles.FileIndex,'BackgroundColor',[1 1 1])
|
---|
| 2053 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
|
---|
| 2054 | end
|
---|
| 2055 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
| 2056 |
|
---|
| 2057 |
|
---|
| 2058 | %------------------------------------------------------------------------
|
---|
| 2059 | % --- read the input files and refresh all the plots, including projection.
|
---|
| 2060 | % OUTPUT:
|
---|
| 2061 | % errormsg: error message char string =[] by default
|
---|
| 2062 | % INPUT:
|
---|
| 2063 | % filename: first input file (=[] in the absence of input file)
|
---|
| 2064 | % filename_1: second input file (=[] in the asbsenc of secodn input file)
|
---|
| 2065 | % num_i1,num_i2,num_j1,num_j2; frame indices
|
---|
| 2066 | % Field: structure describing an optional input field (then replace the input file)
|
---|
| 2067 | function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
|
---|
| 2068 | %------------------------------------------------------------------------
|
---|
| 2069 |
|
---|
| 2070 | %% initialisation
|
---|
| 2071 | abstime=[];
|
---|
| 2072 | abstime_1=[];
|
---|
| 2073 | dt=[];
|
---|
| 2074 | if ~exist('Field','var')
|
---|
| 2075 | Field={};
|
---|
| 2076 | end
|
---|
| 2077 | UvData=get(handles.uvmat,'UserData');
|
---|
| 2078 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat
|
---|
| 2079 | delete(handles.UVMAT_title)
|
---|
| 2080 | end
|
---|
| 2081 |
|
---|
| 2082 | %% determine the main input file information for action
|
---|
| 2083 | FileType=[];%default
|
---|
| 2084 | if ~exist(filename,'file')
|
---|
| 2085 | errormsg=['input file ' filename ' does not exist'];
|
---|
| 2086 | return
|
---|
| 2087 | end
|
---|
| 2088 | %Ext=get(handles.FileExt,'String');
|
---|
| 2089 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 2090 | %update the z position index
|
---|
| 2091 | nbslice_str=get(handles.nb_slice,'String');
|
---|
| 2092 | if isequal(nbslice_str,'volume')%NOT USED
|
---|
| 2093 | z_index=num_j1;
|
---|
| 2094 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2095 | else
|
---|
| 2096 | nbslice=str2num(nbslice_str);
|
---|
| 2097 | z_index=mod(num_i1-1,nbslice)+1;
|
---|
| 2098 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2099 | end
|
---|
| 2100 | % refresh menu for save_mask if relevant
|
---|
| 2101 | masknumber=get(handles.masklevel,'String');
|
---|
| 2102 | if length(masknumber)>=z_index
|
---|
| 2103 | set(handles.masklevel,'Value',z_index)
|
---|
| 2104 | end
|
---|
| 2105 |
|
---|
| 2106 | %% read the first input field if a filename has been introduced
|
---|
| 2107 | if ~isempty(filename)
|
---|
| 2108 | ObjectName=filename;
|
---|
| 2109 | FieldName=[];%default
|
---|
| 2110 | VelType=[];%default
|
---|
| 2111 | Ext=get(handles.FileExt,'String');
|
---|
| 2112 | if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf')
|
---|
| 2113 | FileType='netcdf';
|
---|
| 2114 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 2115 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 2116 | FieldName= list_fields{index_fields}; % selected field
|
---|
| 2117 | if ~strcmp(FieldName,'get_field...')% read the field names on the interface get_field...
|
---|
| 2118 | VelType=setfield(handles);
|
---|
| 2119 | end
|
---|
| 2120 | if strcmp(FieldName,'velocity')
|
---|
| 2121 | list_code=get(handles.color_code,'String');% list menu fields
|
---|
| 2122 | index_code=get(handles.color_code,'Value');% selected string index
|
---|
| 2123 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white')
|
---|
| 2124 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 2125 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 2126 | ParamIn.ColorVar= list_code{index_code}; % selected field
|
---|
| 2127 | end
|
---|
| 2128 | end
|
---|
| 2129 | elseif isfield(UvData,'MovieObject')
|
---|
| 2130 | ObjectName=UvData.MovieObject;
|
---|
| 2131 | FileType='movie';
|
---|
| 2132 | elseif isequal(lower(Ext),'.avi')
|
---|
| 2133 | FileType='avi';
|
---|
| 2134 | elseif isequal(lower(Ext),'.vol')
|
---|
| 2135 | FileType='vol';
|
---|
| 2136 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')
|
---|
| 2137 | ParamIn.Npy=UvData.XmlData.Npy;
|
---|
| 2138 | ParamIn.Npx=UvData.XmlData.Npx;
|
---|
| 2139 | else
|
---|
| 2140 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
|
---|
| 2141 | return
|
---|
| 2142 | end
|
---|
| 2143 | else
|
---|
| 2144 | form=imformats(Ext(2:end));
|
---|
| 2145 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 2146 | if isequal(NomType,'*');
|
---|
| 2147 | FileType='multimage';
|
---|
| 2148 | else
|
---|
| 2149 | FileType='image';
|
---|
| 2150 | end
|
---|
| 2151 | end
|
---|
| 2152 | end
|
---|
| 2153 | ParamIn.FieldName=FieldName;
|
---|
| 2154 | ParamIn.VelType=VelType;
|
---|
| 2155 | ParamIn.GUIName='get_field';
|
---|
| 2156 | [Field{1},ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num_i1);
|
---|
| 2157 | if ~isempty(errormsg)
|
---|
| 2158 | errormsg=['error in reading ' filename ': ' errormsg];
|
---|
| 2159 | return
|
---|
| 2160 | end
|
---|
| 2161 | if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy')
|
---|
| 2162 | set(handles.npx,'String',num2str(ParamOut.Npx));% display image size on the interface
|
---|
| 2163 | set(handles.npy,'String',num2str(ParamOut.Npy));
|
---|
| 2164 | end
|
---|
| 2165 | end
|
---|
| 2166 |
|
---|
| 2167 | %% choose a second field if Subfield option is 'on', and if the field has changed
|
---|
| 2168 | VelType_1=[];%default
|
---|
| 2169 | FieldName_1=[];
|
---|
| 2170 | ParamOut_1=[];
|
---|
| 2171 | if ~isempty(filename_1)
|
---|
| 2172 | if ~exist(filename_1,'file')
|
---|
| 2173 | errormsg=['second file ' filename_1 ' does not exist'];
|
---|
| 2174 | return
|
---|
| 2175 | else
|
---|
| 2176 | Name=filename_1;
|
---|
| 2177 | FieldName_1=[];%default
|
---|
| 2178 | VelType_1=[];%default
|
---|
| 2179 | Ext_1=get(handles.FileExt_1,'String');
|
---|
| 2180 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 2181 | if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
|
---|
| 2182 | FileType_1='netcdf';
|
---|
| 2183 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 2184 | Name=UvData.MovieObject_1;
|
---|
| 2185 | FileType_1='movie';
|
---|
| 2186 | elseif isequal(lower(Ext_1),'.avi')
|
---|
| 2187 | FileType_1='avi';
|
---|
| 2188 | elseif isequal(lower(Ext_1),'.vol')
|
---|
| 2189 | FileType_1='vol';
|
---|
| 2190 | if isfield(UvData.XmlData_1,'Npy') && isfield(UvData.XmlData_1,'Npx')
|
---|
| 2191 | ParamIn.Npy=UvData.XmlData_1.Npy;
|
---|
| 2192 | ParamIn.Npx=UvData.XmlData_1.Npx;
|
---|
| 2193 | else
|
---|
| 2194 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
|
---|
| 2195 | return
|
---|
| 2196 | end
|
---|
| 2197 | else
|
---|
| 2198 | form=imformats(Ext_1(2:end));
|
---|
| 2199 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 2200 | if isequal(NomType_1,'*');
|
---|
| 2201 | FileType_1='multimage';
|
---|
| 2202 | else
|
---|
| 2203 | FileType_1='image';
|
---|
| 2204 | end
|
---|
| 2205 | end
|
---|
| 2206 | end
|
---|
| 2207 | if strcmp(FileType_1,'netcdf')
|
---|
| 2208 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 2209 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 2210 | FieldName_1= list_fields{index_fields}; % selected field
|
---|
| 2211 | if ~isequal(FieldName_1,'get_field...')% read the field names on the interface get_field...
|
---|
| 2212 | VelType_1=setfield_1(handles);
|
---|
| 2213 | end
|
---|
| 2214 | if strcmp(VelType_1,'*')% free veltype choice
|
---|
| 2215 | VelType_1=[];
|
---|
| 2216 | elseif strcmp(VelType_1,'"')% veltype the same as for the first field
|
---|
| 2217 | if isempty(VelType)
|
---|
| 2218 | VelType_1=[];
|
---|
| 2219 | else
|
---|
| 2220 | VelType_1=VelType;
|
---|
| 2221 | end
|
---|
| 2222 | end
|
---|
| 2223 | if strcmp(FieldName_1,'velocity')
|
---|
| 2224 | list_code=get(handles.color_code,'String');% list menu fields
|
---|
| 2225 | index_code=get(handles.color_code,'Value');% selected string index
|
---|
| 2226 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white')
|
---|
| 2227 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 2228 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 2229 | ParamIn.ColorVar= list_code{index_code}; % selected field
|
---|
| 2230 | end
|
---|
| 2231 | end
|
---|
| 2232 | end
|
---|
| 2233 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
|
---|
| 2234 | if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
|
---|
| 2235 | if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
|
---|
| 2236 | test_keepdata_1= strcmp(filename_1,UvData.filename_1) && strcmp(VelType_1,UvData.VelType_1) && strcmp(FieldName_1,UvData.FieldName_1);
|
---|
| 2237 | end
|
---|
| 2238 | end
|
---|
| 2239 | if test_keepdata_1
|
---|
| 2240 | Field{2}=UvData.Field_1;
|
---|
| 2241 | else
|
---|
| 2242 | ParamIn.FieldName=FieldName_1;
|
---|
| 2243 | ParamIn.VelType=VelType_1;
|
---|
| 2244 | ParamIn.GUIName='get_field_1';
|
---|
| 2245 | [Field{2},ParamOut_1,errormsg] = read_field(Name,FileType_1,ParamIn,num_i1);
|
---|
| 2246 | if ~isempty(errormsg)
|
---|
| 2247 | errormsg=['error in reading ' filename_1 ': ' errormsg];
|
---|
| 2248 | return
|
---|
| 2249 | end
|
---|
| 2250 | UvData.Field_1=Field{2}; %store the second field for possible use at next RUN
|
---|
| 2251 | end
|
---|
| 2252 | end
|
---|
| 2253 | end
|
---|
| 2254 |
|
---|
| 2255 | %% update uvmat interface
|
---|
| 2256 | if isfield(ParamOut,'Npx')
|
---|
| 2257 | set(handles.npx,'String',num2str(ParamOut.Npx));% display image size on the interface
|
---|
| 2258 | set(handles.npy,'String',num2str(ParamOut.Npy));
|
---|
| 2259 | elseif isfield(ParamOut_1,'Npx')
|
---|
| 2260 | set(handles.npx,'String',num2str(ParamOut_1.Npx));% display image size on the interface
|
---|
| 2261 | set(handles.npy,'String',num2str(ParamOut_1.Npy));
|
---|
| 2262 | end
|
---|
| 2263 |
|
---|
| 2264 | %% update the display buttons for the first velocity type (first menuline)
|
---|
| 2265 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 2266 | if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...')
|
---|
| 2267 | % reset_vel_type(veltype_handles)
|
---|
| 2268 | set(veltype_handles,'Visible','off')
|
---|
| 2269 | else% if isempty(ParamOut.VelType) && ~isequal(FieldName,'get_field...')
|
---|
| 2270 | set_veltype_display(veltype_handles,ParamOut.CivStage)%update the display of available velocity types for the first field
|
---|
| 2271 | if isempty(ParamOut.VelType)
|
---|
| 2272 | reset_vel_type(veltype_handles)
|
---|
| 2273 | else
|
---|
| 2274 | handle1=eval(['handles.' ParamOut.VelType]);
|
---|
| 2275 | reset_vel_type(veltype_handles,handle1)
|
---|
| 2276 | end
|
---|
| 2277 | end
|
---|
| 2278 | field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList);
|
---|
| 2279 | set(handles.Fields,'String',ParamOut.FieldList); %update the field menu
|
---|
| 2280 | set(handles.Fields,'Value',find(field_index,1))
|
---|
| 2281 |
|
---|
| 2282 | %% update the display buttons for the second velocity type (second menuline)
|
---|
| 2283 | if ~isempty(filename_1)
|
---|
| 2284 | veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 2285 | if ~isequal(FileType_1,'netcdf')|| isequal(FieldName_1,'get_field...')
|
---|
| 2286 | set(veltype_handles_1,'Visible','off')
|
---|
| 2287 | %reset_vel_type(veltype_handles_1)
|
---|
| 2288 | else %if isempty(VelType_1) && ~isequal(FieldName_1,'get_field...')
|
---|
| 2289 | set_veltype_display(veltype_handles_1,ParamOut_1.CivStage)%update the display of available velocity types for the first field
|
---|
| 2290 | if isempty(ParamOut_1.VelType)
|
---|
| 2291 | reset_vel_type(veltype_handles_1)
|
---|
| 2292 | else
|
---|
| 2293 | handle1=eval(['handles.' ParamOut_1.VelType '_1']);
|
---|
| 2294 | reset_vel_type(veltype_handles_1,handle1)
|
---|
| 2295 | end
|
---|
| 2296 | end
|
---|
| 2297 | field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
|
---|
| 2298 | set(handles.Fields_1,'String',ParamOut_1.FieldList); %update the field menu
|
---|
| 2299 | set(handles.Fields_1,'Value',find(field_index,1))
|
---|
| 2300 | end
|
---|
| 2301 |
|
---|
| 2302 | %% introduce w as background image by default for a new series (only for nbdim=2)
|
---|
| 2303 | if ~isfield(UvData,'NewSeries')
|
---|
| 2304 | UvData.NewSeries=1;
|
---|
| 2305 | end
|
---|
| 2306 | %put W as background image by default if NbDim=2:
|
---|
| 2307 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3);
|
---|
| 2308 | set(handles.SubField,'Value',1);
|
---|
| 2309 | %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
|
---|
| 2310 | set(handles.RootPath_1,'String','"')
|
---|
| 2311 | set(handles.RootFile_1,'String','"')
|
---|
| 2312 | set(handles.SubDir_1,'String','"');
|
---|
| 2313 | [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
|
---|
| 2314 | set(handles.FileIndex_1,'String',indices)
|
---|
| 2315 | set(handles.FileExt_1,'String','"');
|
---|
| 2316 | set(handles.Fields_1,'Visible','on');
|
---|
| 2317 | set(handles.Fields_1,'Visible','on');
|
---|
| 2318 | set(handles.RootPath_1,'Visible','on')
|
---|
| 2319 | set(handles.RootFile_1,'Visible','on')
|
---|
| 2320 | set(handles.SubDir_1,'Visible','on');
|
---|
| 2321 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 2322 | set(handles.FileExt_1,'Visible','on');
|
---|
| 2323 | set(handles.Fields_1,'Visible','on');
|
---|
| 2324 | Field{1}.AName='w';
|
---|
| 2325 | end
|
---|
| 2326 |
|
---|
| 2327 | %% store the current open names, fields and vel types in uvmat interface
|
---|
| 2328 | UvData.filename_1=filename_1;
|
---|
| 2329 | UvData.VelType_1=[];%default
|
---|
| 2330 | UvData.FieldName_1=[];
|
---|
| 2331 | if isfield(ParamOut_1,VelType)
|
---|
| 2332 | UvData.VelType_1=ParamOut_1.VelType;
|
---|
| 2333 | end
|
---|
| 2334 | if isfield(ParamOut_1,FieldName)
|
---|
| 2335 | UvData.FieldName_1=ParamOut_1.FieldName;
|
---|
| 2336 | end
|
---|
| 2337 |
|
---|
| 2338 | %% apply coordinate transform or other user fct
|
---|
| 2339 | XmlData=[];%default
|
---|
| 2340 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 2341 | XmlData=UvData.XmlData;
|
---|
| 2342 | end
|
---|
| 2343 | XmlData_1=[];%default
|
---|
| 2344 | if isfield(UvData,'XmlData_1')
|
---|
| 2345 | XmlData_1=UvData.XmlData_1;
|
---|
| 2346 | end
|
---|
| 2347 | % menu_transform=get(handles.transform_fct,'String');
|
---|
| 2348 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 2349 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 2350 | transform=transform_list{choice_value};%selected function handles
|
---|
| 2351 | % z index
|
---|
| 2352 | if ~isempty(filename)
|
---|
| 2353 | Field{1}.ZIndex=z_index;
|
---|
| 2354 | end
|
---|
| 2355 | %px to phys or other transform on field
|
---|
| 2356 | if ~isempty(transform)
|
---|
| 2357 | if length(Field)>=2
|
---|
| 2358 | Field{2}.ZIndex=z_index;
|
---|
| 2359 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
|
---|
| 2360 | if isempty(Field{2})
|
---|
| 2361 | Field(2)=[];
|
---|
| 2362 | end
|
---|
| 2363 | else
|
---|
| 2364 | Field{1}=transform(Field{1},XmlData);
|
---|
| 2365 | end
|
---|
| 2366 | end
|
---|
| 2367 |
|
---|
| 2368 | %% calculate scalar
|
---|
| 2369 | if isequal(FileType,'netcdf') && ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
|
---|
| 2370 | Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1});
|
---|
| 2371 | end
|
---|
| 2372 | if length(Field)==2 && ~test_keepdata_1 && isequal(FileType_1,'netcdf') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)
|
---|
| 2373 | Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2});
|
---|
| 2374 | end
|
---|
| 2375 |
|
---|
| 2376 | %% combine the two input fields (e.g. substract velocity fields)
|
---|
| 2377 | if numel(Field)==2
|
---|
| 2378 | UvData.Field=sub_field(Field{1},Field{2});
|
---|
| 2379 | else
|
---|
| 2380 | UvData.Field=Field{1};
|
---|
| 2381 | end
|
---|
| 2382 |
|
---|
| 2383 | %% get bounds and mesh (needed for mouse action and to open set_object)
|
---|
| 2384 | test_x=0;
|
---|
| 2385 | test_z=0;% test for unstructured z coordinate
|
---|
| 2386 | [UvData.Field,errormsg]=check_field_structure(UvData.Field);
|
---|
| 2387 | if ~isempty(errormsg)
|
---|
| 2388 | errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];
|
---|
| 2389 | return
|
---|
| 2390 | end
|
---|
[210] | 2391 | [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(UvData.Field);
|
---|
[199] | 2392 | if ~isempty(errormsg)
|
---|
| 2393 | errormsg=['error in uvmat/refresh_field/find_field_indices: ' errormsg];
|
---|
| 2394 | return
|
---|
| 2395 | end
|
---|
| 2396 | [NbDim,imax]=max(NbDim);
|
---|
[210] | 2397 | if isfield(UvData.Field,'NbDim')
|
---|
| 2398 | NbDim=UvData.Field.NbDim;% deal with plane fields containing z coordinates
|
---|
| 2399 | end
|
---|
[199] | 2400 | if ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinates
|
---|
| 2401 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
|
---|
| 2402 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
|
---|
| 2403 | eval(['nbvec=length(UvData.Field.' XName ');'])%nbre of measurement points (e.g. vectors)
|
---|
| 2404 | test_x=1;%test for unstructured coordinates
|
---|
[206] | 2405 | if ~isempty(VarType{imax}.coord_z)
|
---|
| 2406 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
|
---|
| 2407 | else
|
---|
| 2408 | NbDim=2;
|
---|
| 2409 | end
|
---|
[199] | 2410 | elseif VarType{imax}.coord(NbDim)>0 %structured coordinate
|
---|
| 2411 | XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
|
---|
| 2412 | if NbDim>1
|
---|
| 2413 | YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
|
---|
| 2414 | end
|
---|
| 2415 | end
|
---|
| 2416 | if NbDim==3
|
---|
[206] | 2417 | if ~test_x
|
---|
| 2418 | ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D
|
---|
| 2419 | end
|
---|
[199] | 2420 | eval(['ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2421 | eval(['ZMin=min(UvData.Field.' ZName ');'])
|
---|
[206] | 2422 | UvData.Field.ZMax=ZMax;
|
---|
| 2423 | UvData.Field.ZMin=ZMin;
|
---|
[199] | 2424 | test_z=1;
|
---|
| 2425 | if isequal(ZMin,ZMax)%no z dependency
|
---|
| 2426 | NbDim=2;
|
---|
| 2427 | test_z=0;
|
---|
| 2428 | end
|
---|
| 2429 | end
|
---|
| 2430 | if exist('XName','var')
|
---|
[206] | 2431 | eval(['XMax=max(UvData.Field.' XName ');'])
|
---|
| 2432 | eval(['XMin=min(UvData.Field.' XName ');'])
|
---|
| 2433 | UvData.Field.NbDim=NbDim;
|
---|
| 2434 | UvData.Field.XMax=XMax;
|
---|
| 2435 | UvData.Field.XMin=XMin;
|
---|
[199] | 2436 | if NbDim >1
|
---|
[206] | 2437 | eval(['YMax=max(UvData.Field.' YName ');'])
|
---|
| 2438 | eval(['YMin=min(UvData.Field.' YName ');'])
|
---|
| 2439 | UvData.Field.YMax=YMax;
|
---|
| 2440 | UvData.Field.YMin=YMin;
|
---|
[199] | 2441 | end
|
---|
[206] | 2442 | eval(['nbvec=length(UvData.Field.' XName ');'])
|
---|
| 2443 | if test_x %unstructured coordinates
|
---|
| 2444 | if test_z
|
---|
| 2445 | UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector
|
---|
| 2446 | UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3);
|
---|
| 2447 | else
|
---|
| 2448 | UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D
|
---|
| 2449 | end
|
---|
[199] | 2450 | else
|
---|
[206] | 2451 | VarIndex=CellVarIndex{imax}; % list of variable indices
|
---|
| 2452 | DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
|
---|
| 2453 | nbpoints_x=UvData.Field.DimValue(DimIndex(NbDim));
|
---|
| 2454 | DX=(XMax-XMin)/(nbpoints_x-1);
|
---|
| 2455 | if NbDim >1
|
---|
| 2456 | nbpoints_y=UvData.Field.DimValue(DimIndex(NbDim-1));
|
---|
| 2457 | DY=(YMax-YMin)/(nbpoints_y-1);
|
---|
| 2458 | end
|
---|
| 2459 | if NbDim==3
|
---|
| 2460 | nbpoints_z=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2461 | DZ=(ZMax-ZMin)/(nbpoints_z-1);
|
---|
| 2462 | UvData.Field.Mesh=sqrt(DX*DY*DZ);
|
---|
| 2463 | UvData.Field.ZMax=ZMax;
|
---|
| 2464 | UvData.Field.ZMin=ZMin;
|
---|
| 2465 | else
|
---|
| 2466 | UvData.Field.Mesh=sqrt(DX*DY);
|
---|
| 2467 | end
|
---|
[199] | 2468 | end
|
---|
| 2469 | end
|
---|
| 2470 |
|
---|
| 2471 | %% 3D case (menuvolume)
|
---|
| 2472 | if NbDim==3% && UvData.NewSeries
|
---|
| 2473 | test_set_object=1;
|
---|
| 2474 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
|
---|
| 2475 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
|
---|
| 2476 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
|
---|
| 2477 | if ~isempty(hset_object) %if set_object is detected
|
---|
| 2478 | % hhset_object=guidata(hset_object);
|
---|
| 2479 | % % ZBounds_old(1)=get(hhset_object.z_slider,'Min');
|
---|
| 2480 | % % ZBounds_old(2)=get(hhset_object.z_slider,'Max');
|
---|
| 2481 | % % if isequal(ZBounds_old,ZBounds)
|
---|
| 2482 | % test_set_object=0;% do not refresh the GUI set_object
|
---|
| 2483 | % else
|
---|
| 2484 | delete(hset_object);% delete the GUI set_object if it does not fit
|
---|
| 2485 | % end
|
---|
| 2486 | end
|
---|
| 2487 | if test_set_object% reinitiate the GUI set_object
|
---|
| 2488 | delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.list_object_1 and 2
|
---|
| 2489 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 2490 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 2491 | UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
|
---|
| 2492 | UvData.Object{1}.NbDim=NbDim;%test for 3D objects
|
---|
| 2493 | UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
|
---|
| 2494 | UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
|
---|
[206] | 2495 | UvData.Object{1}.Angle=[0 0 0];
|
---|
| 2496 | % UvData.Object{1}.Theta=0;
|
---|
| 2497 | % UvData.Object{1}.Psi=0;
|
---|
[199] | 2498 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
|
---|
[206] | 2499 | % PlotHandles=get_plot_handles(handles);
|
---|
[199] | 2500 | UvData.Object{1}.Name='1-PLANE';
|
---|
| 2501 | UvData.Object{1}.enable_plot=1;
|
---|
[206] | 2502 | set_object(UvData.Object{1},handles,ZBounds);
|
---|
[199] | 2503 | set(handles.list_object_1,'Value',1);
|
---|
| 2504 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
| 2505 | set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor
|
---|
| 2506 | edit_object_Callback([],[], handles)
|
---|
| 2507 | end
|
---|
| 2508 | %multilevel case (single menuplane in a 3D space)
|
---|
| 2509 | elseif isfield(UvData,'Z')
|
---|
| 2510 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
|
---|
| 2511 | XmlData=UvData.XmlData;
|
---|
| 2512 | if isfield(XmlData,'PlanePos')
|
---|
| 2513 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
|
---|
| 2514 | end
|
---|
| 2515 | if isfield(XmlData,'PlaneAngle')
|
---|
| 2516 | siz=size(XmlData.PlaneAngle);
|
---|
| 2517 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
|
---|
[206] | 2518 | UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
|
---|
[199] | 2519 | end
|
---|
| 2520 | elseif isfield(UvData,'ZIndex')
|
---|
| 2521 | UvData.Object{1}.ZObject=UvData.ZIndex;
|
---|
| 2522 | end
|
---|
| 2523 | else
|
---|
| 2524 | % create a default projection menuplane
|
---|
| 2525 | %UvData.Object{1}.Style='none';%main plotting plane
|
---|
| 2526 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 2527 | UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
|
---|
| 2528 | set(handles.list_object_1,'Value',1);
|
---|
| 2529 | set(handles.list_object_1,'String',{''});
|
---|
| 2530 | end
|
---|
| 2531 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 2532 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
| 2533 | end
|
---|
| 2534 | testnewseries=UvData.NewSeries;
|
---|
| 2535 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
|
---|
| 2536 | set(handles.uvmat,'UserData',UvData)
|
---|
| 2537 |
|
---|
| 2538 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need)
|
---|
| 2539 | if isfield(UvData,'Mask')&& ~isfield(UvData,'A')
|
---|
| 2540 | set(handles.MinA,'String','0')
|
---|
| 2541 | set(handles.MaxA,'String','255')
|
---|
| 2542 | end
|
---|
| 2543 |
|
---|
| 2544 | %% Plot the projections on the selected projection objects
|
---|
| 2545 |
|
---|
| 2546 | % main projection object (uvmat display)
|
---|
| 2547 | IndexObj(1)=get(handles.list_object_1,'Value');%selected projection object for main view
|
---|
| 2548 | if IndexObj(1)> numel(UvData.Object)
|
---|
| 2549 | IndexObj(1)=1;%select the first object if the selected one does not exist
|
---|
| 2550 | set(handles.list_object_1,'Value',1)
|
---|
| 2551 | end
|
---|
| 2552 | plot_handles{1}=handles;
|
---|
| 2553 | haxes(1)=handles.axes3;
|
---|
| 2554 | PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
|
---|
| 2555 | keeplim(1)=get(handles.FixLimits,'Value');% test for fixed graph limits
|
---|
| 2556 | PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface
|
---|
| 2557 |
|
---|
| 2558 | % second projection object (view_field display)
|
---|
| 2559 | IndexObj_2=get(handles.list_object_2,'Value');%selected projection object for the second view
|
---|
| 2560 | if isequal(get(handles.list_object_2,'Visible'),'on') && IndexObj_2 <= numel(UvData.Object)&& ~isempty(UvData.Object{IndexObj_2})
|
---|
| 2561 | IndexObj(2)=IndexObj_2;
|
---|
| 2562 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI
|
---|
| 2563 | if ~isempty(view_field_handle)
|
---|
| 2564 | plot_handles{2}=guidata(view_field_handle);
|
---|
| 2565 | haxes(2)=plot_handles{2}.axes3;
|
---|
| 2566 | PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the uvmat interface
|
---|
| 2567 | keeplim(2)=get(plot_handles{2}.FixLimits,'Value');
|
---|
| 2568 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
|
---|
| 2569 | end
|
---|
| 2570 | end
|
---|
| 2571 |
|
---|
| 2572 | %loop on the projection objects: one or two
|
---|
| 2573 | for imap=1:numel(IndexObj)
|
---|
[206] | 2574 | iobj=IndexObj(imap);
|
---|
[199] | 2575 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
|
---|
| 2576 | if testnewseries && isfield(ObjectData,'CoordUnit')
|
---|
| 2577 | PlotParam{imap}=rmfield(PlotParam{imap},'FixEqual'); %set FixEqual to depend on the field (=1 if Data.CoordUnit=1 in plot_field)
|
---|
| 2578 | end
|
---|
| 2579 | if ~isempty(errormsg)
|
---|
| 2580 | return
|
---|
| 2581 | end
|
---|
| 2582 | %use of mask (TODO: check)
|
---|
| 2583 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A')
|
---|
| 2584 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
|
---|
| 2585 | AX=ObjectData.AX;%x coordiantes for the scalar field
|
---|
| 2586 | AY=ObjectData.AY;%y coordinates for the scalar field
|
---|
| 2587 | MaskX=ObjectData.MaskX;%x coordiantes for the mask
|
---|
| 2588 | MaskY=ObjectData.MaskY;%y coordiantes for the mask
|
---|
| 2589 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY)
|
---|
| 2590 | nxy=size(flag_mask);
|
---|
| 2591 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
|
---|
| 2592 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
|
---|
| 2593 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display
|
---|
| 2594 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display
|
---|
| 2595 | %project on the positions of the scalar
|
---|
| 2596 | npxy=size(ObjectData.A);
|
---|
| 2597 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
|
---|
| 2598 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
|
---|
| 2599 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end);
|
---|
| 2600 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end);
|
---|
| 2601 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
|
---|
| 2602 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
|
---|
| 2603 | end
|
---|
| 2604 | AClass=class(ObjectData.A);
|
---|
| 2605 | ObjectData.A=flag_mask.*double(ObjectData.A);
|
---|
| 2606 | ObjectData.A=feval(AClass,ObjectData.A);
|
---|
| 2607 | ind_off=[];
|
---|
| 2608 | if isfield(ObjectData,'ListVarName')
|
---|
| 2609 | for ilist=1:length(ObjectData.ListVarName)
|
---|
| 2610 | if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY')
|
---|
| 2611 | ind_off=[ind_off ilist];
|
---|
| 2612 | end
|
---|
| 2613 | end
|
---|
| 2614 | ObjectData.ListVarName(ind_off)=[];
|
---|
| 2615 | ObjectData.VarDimIndex(ind_off)=[];
|
---|
| 2616 | ind_off=[];
|
---|
| 2617 | for ilist=1:length(ObjectData.ListDimName)
|
---|
| 2618 | if isequal(ObjectData.ListDimName{ilist},'MaskX') || isequal(ObjectData.ListDimName{ilist},'MaskY')
|
---|
| 2619 | ind_off=[ind_off ilist];
|
---|
| 2620 | end
|
---|
| 2621 | end
|
---|
| 2622 | ObjectData.ListDimName(ind_off)=[];
|
---|
| 2623 | ObjectData.DimValue(ind_off)=[];
|
---|
| 2624 | end
|
---|
| 2625 | end
|
---|
| 2626 | if ~isempty(ObjectData)
|
---|
| 2627 | PlotType='none'; %default
|
---|
| 2628 | if imap==2 && isempty(view_field_handle)
|
---|
| 2629 | view_field(ObjectData)
|
---|
| 2630 | else
|
---|
| 2631 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap});
|
---|
| 2632 | write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters
|
---|
| 2633 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
|
---|
| 2634 | ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot)
|
---|
| 2635 | end
|
---|
| 2636 | end
|
---|
| 2637 | if isequal(PlotType,'none')
|
---|
| 2638 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 2639 | if isempty(hget_field)
|
---|
| 2640 | get_field(filename)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
|
---|
| 2641 | end
|
---|
| 2642 | errormsg='The field defined by get_field cannot be plotted';
|
---|
| 2643 | return
|
---|
| 2644 | end
|
---|
| 2645 | end
|
---|
| 2646 | end
|
---|
| 2647 |
|
---|
| 2648 | %% update the mask
|
---|
| 2649 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 2650 | update_mask(handles,num_i1,num_i2);
|
---|
| 2651 | end
|
---|
| 2652 |
|
---|
| 2653 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case)
|
---|
| 2654 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display
|
---|
| 2655 | ind_bad=[];
|
---|
| 2656 | nb_histo=1;
|
---|
| 2657 |
|
---|
| 2658 | % suppress coordinates from the histogram menu
|
---|
| 2659 | for ivar=1:numel(menu_histo)%l loop on field variables:
|
---|
| 2660 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
|
---|
| 2661 | Role=UvData.Field.VarAttribute{ivar}.Role;
|
---|
| 2662 | switch Role
|
---|
| 2663 | case {'coord_x','coord_y','coord_z','dimvar'}
|
---|
| 2664 | ind_bad=[ind_bad ivar];
|
---|
| 2665 | case {'vector_y'}
|
---|
| 2666 | nb_histo=nb_histo+1;
|
---|
| 2667 | end
|
---|
| 2668 | end
|
---|
| 2669 | DimCell=UvData.Field.VarDimName{ivar};
|
---|
| 2670 | DimName='';
|
---|
| 2671 | if ischar(DimCell)
|
---|
| 2672 | DimName=DimCell;
|
---|
| 2673 | elseif iscell(DimCell)&& numel(DimCell)==1
|
---|
| 2674 | DimName=DimCell{1};
|
---|
| 2675 | end
|
---|
| 2676 | if strcmp(DimName,menu_histo{ivar})
|
---|
| 2677 | ind_bad=[ind_bad ivar];
|
---|
| 2678 | end
|
---|
| 2679 | end
|
---|
| 2680 | menu_histo(ind_bad)=[];
|
---|
| 2681 |
|
---|
| 2682 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
| 2683 | % display menus and plot histograms
|
---|
| 2684 | test_v=0;
|
---|
| 2685 | if ~isempty(menu_histo)
|
---|
| 2686 | set(handles.histo1_menu,'Value',1)
|
---|
| 2687 | set(handles.histo1_menu,'String',menu_histo)
|
---|
| 2688 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram
|
---|
| 2689 | % case of more than one variables (eg vector components)
|
---|
| 2690 | if nb_histo > 1
|
---|
| 2691 | test_v=1;
|
---|
| 2692 | set(handles.histo2_menu,'Visible','on')
|
---|
| 2693 | set(handles.histo_v,'Visible','on')
|
---|
| 2694 | set(handles.histo2_menu,'String',menu_histo)
|
---|
| 2695 | set(handles.histo2_menu,'Value',2)
|
---|
| 2696 | histo2_menu_Callback(handles.histo2_menu,[], handles)% plot second histogram
|
---|
| 2697 | end
|
---|
| 2698 | end
|
---|
| 2699 | if ~test_v
|
---|
| 2700 | set(handles.histo2_menu,'Visible','off')
|
---|
| 2701 | set(handles.histo_v,'Visible','off')
|
---|
| 2702 | cla(handles.histo_v)
|
---|
| 2703 | set(handles.histo2_menu,'Value',1)
|
---|
| 2704 | end
|
---|
| 2705 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
| 2706 |
|
---|
| 2707 | %% display time
|
---|
| 2708 | testimedoc=0;
|
---|
| 2709 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
|
---|
| 2710 | if isempty(num_i2)||isnan(num_i2)
|
---|
| 2711 | num_i2=num_i1;
|
---|
| 2712 | end
|
---|
| 2713 | if isempty(num_j1)||isnan(num_j1)
|
---|
| 2714 | num_j1=1;
|
---|
| 2715 | end
|
---|
| 2716 | if isempty(num_j2)||isnan(num_j2)
|
---|
| 2717 | num_j2=num_j1;
|
---|
| 2718 | end
|
---|
| 2719 | siz=size(UvData.XmlData.Time);
|
---|
| 2720 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
| 2721 | abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
| 2722 | dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
|
---|
| 2723 | testimedoc=1;
|
---|
| 2724 | end
|
---|
| 2725 | end
|
---|
| 2726 | if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
|
---|
| 2727 | [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
| 2728 | num_i2=str2double(str2);
|
---|
| 2729 | if isnan(num_i2)
|
---|
| 2730 | num_i2=num_i1;
|
---|
| 2731 | end
|
---|
| 2732 | num_j1=str2double(str_a);
|
---|
| 2733 | if isnan(num_j1)
|
---|
| 2734 | num_j1=1;
|
---|
| 2735 | end
|
---|
| 2736 | num_j2=str2double(str_b);
|
---|
| 2737 | if isnan(num_j2)
|
---|
| 2738 | num_j2=num_j1;
|
---|
| 2739 | end
|
---|
| 2740 | num_i1=str2double(str1);
|
---|
| 2741 | siz=size(UvData.XmlData_1.Time);
|
---|
| 2742 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
| 2743 | 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
|
---|
| 2744 | end
|
---|
| 2745 | end
|
---|
| 2746 | set(handles.abs_time,'String',num2str(abstime,4))
|
---|
| 2747 | set(handles.abs_time_1,'String',num2str(abstime_1,4))
|
---|
| 2748 | if testimedoc && isfield(UvData,'dt')
|
---|
| 2749 | dt=UvData.dt;
|
---|
| 2750 | end
|
---|
| 2751 | if isempty(dt)||isequal(dt,0)
|
---|
| 2752 | set(handles.Dt_txt,'String','')
|
---|
| 2753 | else
|
---|
| 2754 | if ~(isfield(UvData,'TimeUnit') && ~isempty(UvData.TimeUnit))
|
---|
| 2755 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] )
|
---|
| 2756 | else
|
---|
| 2757 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' UvData.TimeUnit] )
|
---|
| 2758 | end
|
---|
| 2759 | end
|
---|
| 2760 |
|
---|
| 2761 |
|
---|
| 2762 | %-------------------------------------------------------------------
|
---|
| 2763 | % --- translate coordinate to matrix index
|
---|
| 2764 | %-------------------------------------------------------------------
|
---|
| 2765 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
| 2766 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
| 2767 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
| 2768 |
|
---|
| 2769 | %-------------------------------------------------------------------
|
---|
| 2770 | % --- Executes on button press in 'FixLimits'.
|
---|
| 2771 | %-------------------------------------------------------------------
|
---|
| 2772 | function FixLimits_Callback(hObject, eventdata, handles)
|
---|
| 2773 | test=get(handles.FixLimits,'Value');
|
---|
| 2774 | if test
|
---|
| 2775 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 2776 | else
|
---|
| 2777 | set(handles.FixLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2778 | update_plot(handles);
|
---|
| 2779 | end
|
---|
| 2780 |
|
---|
| 2781 | %-------------------------------------------------------------------
|
---|
| 2782 | % --- Executes on button press in FixEqual.
|
---|
| 2783 | function FixEqual_Callback(hObject, eventdata, handles)
|
---|
| 2784 | test=get(handles.FixEqual,'Value');
|
---|
| 2785 | if test
|
---|
| 2786 | set(handles.FixEqual,'BackgroundColor',[1 1 0])
|
---|
| 2787 | cla(handles.axes3)
|
---|
| 2788 | update_plot(handles);
|
---|
| 2789 | else
|
---|
| 2790 | set(handles.FixEqual,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2791 | update_plot(handles);
|
---|
| 2792 | % axis(handles.axes3,'image')
|
---|
| 2793 | end
|
---|
| 2794 |
|
---|
| 2795 |
|
---|
| 2796 | %-------------------------------------------------------------------
|
---|
| 2797 |
|
---|
| 2798 | %-------------------------------------------------------------------
|
---|
| 2799 | % --- Executes on button press in 'zoom'.
|
---|
| 2800 | %-------------------------------------------------------------------
|
---|
| 2801 | function zoom_Callback(hObject, eventdata, handles)
|
---|
| 2802 |
|
---|
| 2803 | if (get(handles.zoom,'Value') == 1);
|
---|
| 2804 | set(handles.zoom,'BackgroundColor',[1 1 0])
|
---|
| 2805 | set(handles.FixLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
| 2806 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 2807 | else
|
---|
| 2808 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2809 | end
|
---|
| 2810 |
|
---|
| 2811 |
|
---|
| 2812 | %-------------------------------------------------------------------
|
---|
| 2813 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
| 2814 | %-------------------------------------------------------------------
|
---|
| 2815 | function record_Callback(hObject, eventdata, handles)
|
---|
| 2816 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
| 2817 | filename=read_file_boxes(handles);
|
---|
| 2818 | [erread,message]=fileattrib(filename);
|
---|
| 2819 | if ~isempty(message) && ~isequal(message.UserWrite,1)
|
---|
| 2820 | msgbox_uvmat('ERROR',['no writting access to ' filename])
|
---|
| 2821 | return
|
---|
| 2822 | end
|
---|
| 2823 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
| 2824 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 2825 | if ~test_civ2 && ~test_civ1
|
---|
| 2826 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 2827 | end
|
---|
| 2828 | if test_civ2
|
---|
| 2829 | nbname='nb_vectors2';
|
---|
| 2830 | flagname='vec2_FixFlag';
|
---|
| 2831 | attrname='fix2';
|
---|
| 2832 | end
|
---|
| 2833 | if test_civ1
|
---|
| 2834 | nbname='nb_vectors';
|
---|
| 2835 | flagname='vec_FixFlag';
|
---|
| 2836 | attrname='fix';
|
---|
| 2837 | end
|
---|
| 2838 | %write fix flags in the netcdf file
|
---|
| 2839 | UvData=get(handles.uvmat,'UserData');
|
---|
| 2840 | hhh=which('netcdf.open');% look for built-in matlab netcdf library
|
---|
| 2841 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
|
---|
| 2842 | nc=netcdf.open(filename,'NC_WRITE');
|
---|
| 2843 | netcdf.reDef(nc);
|
---|
| 2844 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1);
|
---|
| 2845 | dimid = netcdf.inqDimID(nc,nbname);
|
---|
| 2846 | try
|
---|
| 2847 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
|
---|
| 2848 | catch
|
---|
| 2849 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
|
---|
| 2850 | end
|
---|
| 2851 | netcdf.endDef(nc);
|
---|
| 2852 | netcdf.putVar(nc,varid,UvData.axes3.FF);
|
---|
| 2853 | netcdf.close(nc);
|
---|
| 2854 | else %old netcdf library
|
---|
| 2855 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 2856 | end
|
---|
| 2857 |
|
---|
| 2858 | %-------------------------------------------------------------------
|
---|
| 2859 | %----Correct the netcdf file, using toolbox (old versions of Matlab).
|
---|
| 2860 | %-------------------------------------------------------------------
|
---|
| 2861 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 2862 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
| 2863 | result=redef(nc);
|
---|
| 2864 | eval(['nc.' attrname '=1;']);
|
---|
| 2865 | theDim=nc(nbname) ;% get the number of velocity vectors
|
---|
| 2866 | nb_vectors=size(theDim);
|
---|
| 2867 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
| 2868 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
| 2869 | fin=close(nc);
|
---|
| 2870 |
|
---|
| 2871 |
|
---|
| 2872 | %-------------------------------------------------------------------
|
---|
| 2873 | %determines the fields to read from the interface
|
---|
| 2874 | %------------------------------------------------------------------
|
---|
| 2875 | function [VelType,civ]=setfield(handles)
|
---|
| 2876 |
|
---|
| 2877 | VelType=[]; %default
|
---|
| 2878 | if (get(handles.civ1,'Value') == 1);
|
---|
| 2879 | VelType='civ1';
|
---|
| 2880 | % interp1
|
---|
| 2881 | elseif (get(handles.interp1,'Value') == 1);
|
---|
| 2882 | VelType='interp1';
|
---|
| 2883 | % filter1
|
---|
| 2884 | elseif (get(handles.filter1,'Value') == 1);
|
---|
| 2885 | VelType='filter1';
|
---|
| 2886 | % CIV2
|
---|
| 2887 | elseif (get(handles.civ2,'Value') == 1);
|
---|
| 2888 | VelType='civ2';
|
---|
| 2889 | % interp2
|
---|
| 2890 | elseif (get(handles.interp2,'Value') == 1);
|
---|
| 2891 | VelType='interp2';
|
---|
| 2892 | % filter2
|
---|
| 2893 | elseif (get(handles.filter2,'Value') == 1);
|
---|
| 2894 | VelType='filter2';
|
---|
| 2895 | end
|
---|
| 2896 |
|
---|
| 2897 | if isequal(get(handles.filter2,'Visible'),'on');
|
---|
| 2898 | civ=6;
|
---|
| 2899 | % interp1
|
---|
| 2900 | elseif isequal(get(handles.interp2,'Visible'),'on');
|
---|
| 2901 | civ=5;
|
---|
| 2902 | % filter1
|
---|
| 2903 | elseif isequal(get(handles.civ2,'Visible'),'on');
|
---|
| 2904 | civ=4;
|
---|
| 2905 | % CIV2
|
---|
| 2906 | elseif isequal(get(handles.filter1,'Visible'),'on');
|
---|
| 2907 | civ=3;
|
---|
| 2908 | % interp2
|
---|
| 2909 | elseif isequal(get(handles.interp1,'Visible'),'on');
|
---|
| 2910 | civ=2;
|
---|
| 2911 | % filter2
|
---|
| 2912 | elseif isequal(get(handles.civ1,'Visible'),'on');
|
---|
| 2913 | civ=1;
|
---|
| 2914 | else
|
---|
| 2915 | civ=0;
|
---|
| 2916 | end
|
---|
| 2917 |
|
---|
| 2918 | %-------------------------------------------------------------------
|
---|
| 2919 | %determines the veltype of the second field to read from the iinterface
|
---|
| 2920 | %------------------------------------------------------------------
|
---|
| 2921 | function VelType=setfield_1(handles)
|
---|
| 2922 |
|
---|
| 2923 | VelType=[]; %default
|
---|
| 2924 | if (get(handles.civ1_1,'Value') == 1);
|
---|
| 2925 | VelType='civ1';
|
---|
| 2926 | % interp1
|
---|
| 2927 | elseif (get(handles.interp1_1,'Value') == 1);
|
---|
| 2928 | VelType='interp1';
|
---|
| 2929 | % filter1
|
---|
| 2930 | elseif (get(handles.filter1_1,'Value') == 1);
|
---|
| 2931 | VelType='filter1';
|
---|
| 2932 | % CIV2
|
---|
| 2933 | elseif (get(handles.civ2_1,'Value') == 1);
|
---|
| 2934 | VelType='civ2';
|
---|
| 2935 | % interp2
|
---|
| 2936 | elseif (get(handles.interp2_1,'Value') == 1);
|
---|
| 2937 | VelType='interp2';
|
---|
| 2938 | % filter2
|
---|
| 2939 | elseif (get(handles.filter2_1,'Value') == 1);
|
---|
| 2940 | VelType='filter2';
|
---|
| 2941 | end
|
---|
| 2942 |
|
---|
| 2943 |
|
---|
| 2944 | %---------------------------------------------------
|
---|
| 2945 | % --- Executes on button press in SubField
|
---|
| 2946 | function SubField_Callback(hObject, eventdata, handles)
|
---|
| 2947 | huvmat=get(handles.run0,'parent');
|
---|
| 2948 | UvData=get(huvmat,'UserData');
|
---|
| 2949 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated
|
---|
| 2950 | set(handles.RootPath_1,'String','')
|
---|
| 2951 | set(handles.RootFile_1,'String','')
|
---|
| 2952 | set(handles.SubDir_1,'String','');
|
---|
| 2953 | set(handles.FileIndex_1,'String','');
|
---|
| 2954 | set(handles.FileExt_1,'String','');
|
---|
| 2955 | set(handles.RootPath_1,'Visible','off')
|
---|
| 2956 | set(handles.RootFile_1,'Visible','off')
|
---|
| 2957 | set(handles.SubDir_1,'Visible','off');
|
---|
| 2958 | set(handles.FileIndex_1,'Visible','off');
|
---|
| 2959 | set(handles.FileExt_1,'Visible','off');
|
---|
| 2960 | set(handles.Fields_1,'Value',1);%set to blank state
|
---|
| 2961 | set_veltype_display([handles.civ1_1 handles.interp1_1 handles.filter1_1 ...
|
---|
| 2962 | handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
|
---|
| 2963 | if isfield(UvData,'XmlData_1')
|
---|
| 2964 | UvData=rmfield(UvData,'XmlData_1');
|
---|
| 2965 | end
|
---|
| 2966 | set(huvmat,'UserData',UvData);
|
---|
| 2967 | run0_Callback(hObject, eventdata, handles); %run
|
---|
| 2968 | else
|
---|
| 2969 | MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 2970 | end
|
---|
| 2971 |
|
---|
| 2972 | %------------------------------------------------------------------------
|
---|
| 2973 | % --- read the data displayed for the input rootfile windows (new)
|
---|
| 2974 | function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
|
---|
| 2975 | %------------------------------------------------------------------------
|
---|
| 2976 | RootPath=get(handles.RootPath,'String');
|
---|
| 2977 | FileName=RootPath; %default
|
---|
| 2978 | SubDir=get(handles.SubDir,'String');
|
---|
| 2979 | if ~isempty(SubDir) && ~isequal(SubDir,'')
|
---|
| 2980 | if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
|
---|
| 2981 | SubDir(1)=[]; %suppress possible / or \ separator
|
---|
| 2982 | end
|
---|
| 2983 | FileName=fullfile(RootPath,SubDir);
|
---|
| 2984 | end
|
---|
| 2985 | RootFile=get(handles.RootFile,'String');
|
---|
| 2986 | if ~isempty(RootFile) && ~isequal(RootFile,'')
|
---|
| 2987 | if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 2988 | RootFile(1)=[]; %suppress possible / or \ separator
|
---|
| 2989 | end
|
---|
| 2990 | FileName=fullfile(FileName,RootFile);
|
---|
| 2991 | end
|
---|
| 2992 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 2993 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 2994 | FileExt=get(handles.FileExt,'String');
|
---|
| 2995 | FileName=[FileName FileIndices FileExt];
|
---|
| 2996 |
|
---|
| 2997 | %------------------------------------------------------------------------
|
---|
| 2998 | % ---- read the data displayed for the second input rootfile windows
|
---|
| 2999 | function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
|
---|
| 3000 | %------------------------------------------------------------------------
|
---|
| 3001 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
|
---|
| 3002 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"')
|
---|
| 3003 | RootPath_1=get(handles.RootPath,'String');
|
---|
| 3004 | end;
|
---|
| 3005 | FileName_1=RootPath_1; %default
|
---|
| 3006 | SubDir_1=get(handles.SubDir_1,'String');
|
---|
| 3007 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"')
|
---|
| 3008 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 3009 | end
|
---|
| 3010 | if numel(SubDir_1)>=1
|
---|
| 3011 | if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))
|
---|
| 3012 | SubDir_1(1)=[]; %suppress possible / or \ separator
|
---|
| 3013 | end
|
---|
| 3014 | FileName_1=fullfile(RootPath_1,SubDir_1);
|
---|
| 3015 | end
|
---|
| 3016 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3017 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"')
|
---|
| 3018 | RootFile_1=get(handles.RootFile,'String');
|
---|
| 3019 | end
|
---|
| 3020 | if numel(RootFile_1)>=1
|
---|
[210] | 3021 | if ~(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
|
---|
[199] | 3022 | RootFile_1(1)=[];%suppress possible / or \ separator
|
---|
| 3023 | end
|
---|
| 3024 | FileName_1=fullfile(FileName_1,RootFile_1);
|
---|
| 3025 | end
|
---|
| 3026 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 3027 | if isequal(get(handles.FileIndex_1,'Visible'),'off')
|
---|
| 3028 | FileIndices_1=get(handles.FileIndex,'String');
|
---|
| 3029 | else
|
---|
| 3030 | FileIndices_1=get(handles.FileIndex_1,'String');
|
---|
| 3031 | end
|
---|
| 3032 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 3033 | if isequal(FileExt_1,'"'),FileExt_1=get(handles.FileExt,'String'); end;
|
---|
| 3034 | FileName_1=[FileName_1 FileIndices_1 FileExt_1];
|
---|
| 3035 |
|
---|
| 3036 | %------------------------------------------------------------------------
|
---|
| 3037 | % --- Executes on menu selection Fields
|
---|
| 3038 | function Fields_Callback(hObject, eventdata, handles)
|
---|
| 3039 | %------------------------------------------------------------------------
|
---|
| 3040 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3041 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3042 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3043 | if isequal(field,'get_field...')
|
---|
| 3044 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3045 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3046 | filename=read_file_boxes(handles);
|
---|
| 3047 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 3048 | if ~isempty(hget_field)
|
---|
| 3049 | delete(hget_field)
|
---|
| 3050 | end
|
---|
| 3051 | hget_field=get_field(filename);
|
---|
| 3052 | set(hget_field,'Name','get_field')
|
---|
| 3053 | hhget_field=guidata(hget_field);
|
---|
| 3054 | set(hhget_field.list_fig,'Value',1)
|
---|
| 3055 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
| 3056 | set(handles.transform_fct,'Value',1)% no transform by default
|
---|
| 3057 | set(handles.path_transform,'String','')
|
---|
| 3058 | return %no action
|
---|
| 3059 | end
|
---|
| 3060 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3061 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3062 | field_1= list_fields{index_fields(1)}; % selected string
|
---|
| 3063 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3064 |
|
---|
| 3065 | %read the rootfile input display
|
---|
| 3066 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
| 3067 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
|
---|
| 3068 | NomTypeNew=NomType;%default
|
---|
| 3069 | if isequal(field,'image')
|
---|
| 3070 | % transform netc type to the corresponding image type
|
---|
| 3071 | % if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')|| isequal(NomType,'#_ab')|| isequal(NomType,'_i1-i2')
|
---|
| 3072 | % UvData.SubDir=get(handles.SubDir,'String'); %preserve the subdir in memory
|
---|
| 3073 | % if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')||isequal(UvData.SubDir(1),'/'))
|
---|
| 3074 | % UvData.SubDir(1)=[];
|
---|
| 3075 | % end
|
---|
| 3076 | % set(handles.SubDir,'String','')
|
---|
| 3077 | % set(handles.FileExt,'String','.png');
|
---|
| 3078 | if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')
|
---|
| 3079 | NomTypeNew='_i_j';
|
---|
| 3080 | elseif isequal(NomType,'#_ab')
|
---|
| 3081 | NomTypeNew='#a';
|
---|
| 3082 | elseif isequal(NomType,'_i1-i2')
|
---|
| 3083 | NomTypeNew='_i';
|
---|
| 3084 | end
|
---|
| 3085 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
| 3086 | if ~exist(imagename,'file')
|
---|
| 3087 | [FileName,PathName] = uigetfile( ...
|
---|
| 3088 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3089 | '*.jpg',' jpeg image files'; ...
|
---|
| 3090 | '*.png','.png image files'; ...
|
---|
| 3091 | '*.tif','.tif image files'; ...
|
---|
| 3092 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3093 | '*.vol','.volume images (png)'; ...
|
---|
| 3094 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 3095 | 'Pick an image',imagename);
|
---|
| 3096 | % display the selected field and related information
|
---|
| 3097 | imagename=[PathName FileName];
|
---|
| 3098 | end
|
---|
| 3099 | display_file_name(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3100 | return
|
---|
| 3101 | % end
|
---|
| 3102 | % veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3103 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3104 | else
|
---|
| 3105 | ext=get(handles.FileExt,'String');
|
---|
| 3106 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 3107 | [FileName,PathName] = uigetfile( ...
|
---|
| 3108 | {'*.nc', ' (*.nc)';
|
---|
| 3109 | '*.nc',' netcdf files'; ...
|
---|
| 3110 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 3111 | 'Pick a netcdf file',FileBase);
|
---|
| 3112 | % display the selected field and related information
|
---|
| 3113 | filename=[PathName FileName];
|
---|
| 3114 | display_file_name(hObject, eventdata, handles,filename)
|
---|
| 3115 | return
|
---|
| 3116 | % MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 3117 | end
|
---|
| 3118 | if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
|
---|
| 3119 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3120 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3121 | set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3122 | set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3123 | elseif isequal(field,'more...');
|
---|
| 3124 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3125 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3126 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 3127 | [ind_answer] = listdlg('PromptString','Select a file:',...
|
---|
| 3128 | 'SelectionMode','single',...
|
---|
| 3129 | 'ListString',str);
|
---|
| 3130 | % edit the choice in the field and action menu
|
---|
| 3131 | scalar=cell2mat(str(ind_answer));
|
---|
| 3132 | menu=update_menu(handles.Fields,scalar);
|
---|
| 3133 | menu=[{''};menu];
|
---|
| 3134 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3135 | end
|
---|
| 3136 | end
|
---|
| 3137 | indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
| 3138 | set(handles.FileIndex,'String',indices)
|
---|
| 3139 | set(handles.FileIndex,'UserData',NomTypeNew)
|
---|
| 3140 | %common to Fields_1_Callback
|
---|
| 3141 | if isequal(field,'image')||isequal(field_1,'image')
|
---|
| 3142 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3143 | set(handles.npy_title,'Visible','on')
|
---|
| 3144 | set(handles.npx,'Visible','on')
|
---|
| 3145 | set(handles.npy,'Visible','on')
|
---|
| 3146 | else
|
---|
| 3147 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3148 | set(handles.npy_title,'Visible','off')
|
---|
| 3149 | set(handles.npx,'Visible','off')
|
---|
| 3150 | set(handles.npy,'Visible','off')
|
---|
| 3151 | end
|
---|
| 3152 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3153 |
|
---|
| 3154 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
|
---|
| 3155 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3156 | end
|
---|
| 3157 |
|
---|
| 3158 | %---------------------------------------------------
|
---|
| 3159 | % --- Executes on menu selection Fields
|
---|
| 3160 | function Fields_1_Callback(hObject, eventdata, handles)
|
---|
| 3161 | %-------------------------------------------------
|
---|
| 3162 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3163 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3164 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3165 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3166 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3167 | field_1= list_fields{index_fields(1)}; % selected string for the second field
|
---|
| 3168 | if isequal(field_1,'') %remove second field if 'blank' field is selected
|
---|
| 3169 | set(handles.SubField,'Value',0)
|
---|
| 3170 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 3171 | return
|
---|
| 3172 | end
|
---|
| 3173 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3174 |
|
---|
| 3175 | %read the rootfile input display
|
---|
| 3176 | [FileName,RootPath,FileBase,FileIndices,FileExt_prev]=read_file_boxes_1(handles);
|
---|
| 3177 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_prev]);
|
---|
[210] | 3178 | if isempty(FileExt_prev)|| strcmp(FileExt_prev,'')
|
---|
[199] | 3179 | FileExt_1=get(handles.FileExt,'String');
|
---|
| 3180 | else
|
---|
| 3181 | FileExt_1=FileExt_prev;
|
---|
| 3182 | end
|
---|
| 3183 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[210] | 3184 | if isempty(NomType_1)|| strcmp(NomType_1,'')
|
---|
[199] | 3185 | NomType_1=get(handles.FileIndex,'UserData');
|
---|
| 3186 | end
|
---|
| 3187 | NomTypeNew=NomType_1;%default
|
---|
| 3188 |
|
---|
| 3189 | set(handles.SubField,'Value',1)%introduce second field
|
---|
| 3190 | if isfield(UvData,'XmlData')
|
---|
| 3191 | UvData.XmlData_1=UvData.XmlData;
|
---|
| 3192 | end
|
---|
| 3193 | set(handles.FileIndex_1,'Visible','on')
|
---|
| 3194 | set(handles.FileExt_1,'Visible','on')
|
---|
| 3195 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3196 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3197 | if isempty(RootPath_1)||isequal(RootPath_1,'')
|
---|
| 3198 | set(handles.RootPath_1,'String','"')
|
---|
| 3199 | end
|
---|
| 3200 | if isempty(RootFile_1) || isequal(RootFile_1,'')
|
---|
| 3201 | set(handles.RootFile_1,'String','"')
|
---|
| 3202 | end
|
---|
| 3203 | if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
|
---|
| 3204 | RootFile_1(1)=[];
|
---|
| 3205 | end
|
---|
| 3206 |
|
---|
| 3207 | if isequal(field_1,'get_field...')
|
---|
| 3208 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3209 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3210 | filename=read_file_boxes_1(handles);
|
---|
| 3211 | hget_field=findobj(allchild(0),'name','get_field_1');
|
---|
| 3212 | if ~isempty(hget_field)
|
---|
| 3213 | delete(hget_field)
|
---|
| 3214 | end
|
---|
| 3215 | hget_field=get_field(filename);
|
---|
| 3216 | set(hget_field,'name','get_field_1')
|
---|
| 3217 | hhget_field=guidata(hget_field);
|
---|
| 3218 | set(hhget_field.list_fig,'Value',1)
|
---|
| 3219 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
| 3220 | set(handles.transform_fct,'Value',1)% no transform by default
|
---|
| 3221 | set(handles.path_transform,'String','')
|
---|
| 3222 | return %no action
|
---|
| 3223 | end
|
---|
| 3224 | if isequal(field_1,'image')
|
---|
| 3225 | % transform netc type to the corresponding image type
|
---|
| 3226 | % set(handles.FileExt_1,'String','.png');
|
---|
| 3227 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')| isequal(NomType_1,'#_ab')| isequal(NomType_1,'_i1-i2')
|
---|
| 3228 | UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
|
---|
| 3229 | % set(handles.SubDir_1,'String','')
|
---|
| 3230 | % set(handles.FileExt_1,'String','.png');
|
---|
| 3231 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')
|
---|
| 3232 | NomTypeNew='_i_j';
|
---|
| 3233 | elseif isequal(NomType_1,'#_ab')
|
---|
| 3234 | NomTypeNew='#a';
|
---|
| 3235 | elseif isequal(NomType_1,'_i1-i2')
|
---|
| 3236 | NomTypeNew='_i';
|
---|
| 3237 | end
|
---|
| 3238 | end
|
---|
| 3239 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
| 3240 | if ~exist(imagename,'file')
|
---|
| 3241 | [FileName,PathName] = uigetfile( ...
|
---|
| 3242 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3243 | '*.jpg',' jpeg image files'; ...
|
---|
| 3244 | '*.png','.png image files'; ...
|
---|
| 3245 | '*.tif','.tif image files'; ...
|
---|
| 3246 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3247 | '*.vol','.volume images (png)'; ...
|
---|
| 3248 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 3249 | 'Pick an image',imagename);
|
---|
| 3250 | % display the selected field and related information
|
---|
| 3251 | imagename=[PathName FileName];
|
---|
| 3252 | end
|
---|
| 3253 | display_file_name_1(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3254 | return
|
---|
| 3255 | % veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3256 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3257 | else
|
---|
| 3258 | set(handles.SubDir_1,'Visible','on')
|
---|
| 3259 | if ~isequal(FileExt_prev,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 3260 | veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3261 | set_veltype_display(veltype_handles,6); % make all civ buttons visible
|
---|
| 3262 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3263 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3264 | if isempty(RootPath_1)|isequal(RootPath_1,'')
|
---|
| 3265 | set(handles.RootPath_1,'String','"')
|
---|
| 3266 | end
|
---|
| 3267 | if isempty(RootFile_1) | isequal(RootFile_1,'')
|
---|
| 3268 | set(handles.RootFile_1,'String','"')
|
---|
| 3269 | end
|
---|
| 3270 | if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 3271 | RootFile_1(1)=[];
|
---|
| 3272 | end
|
---|
| 3273 | filebase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 3274 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 3275 | if isempty(SubDir_1)||isequal(SubDir_1,'')
|
---|
| 3276 | if isfield(UvData,'SubDir_1')
|
---|
| 3277 | SubDir_1=UvData.SubDir_1;%retrieve previous subdir
|
---|
| 3278 | else
|
---|
| 3279 | SubDir_1='?';
|
---|
| 3280 | end
|
---|
| 3281 | end
|
---|
| 3282 | str1=get(handles.i1,'String');
|
---|
| 3283 | str_a=get(handles.j1,'String');
|
---|
| 3284 | if isequal(NomType_1,'#_ab')||isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')||isequal(NomType_1,'_i1-i2')
|
---|
| 3285 | NomTypeNew=NomType_1;
|
---|
| 3286 | elseif isequal(NomType_1,'#a')
|
---|
| 3287 | [filename, n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),stra2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
|
---|
| 3288 | NomTypeNew='#_ab';
|
---|
| 3289 | elseif isequal(NomType_1,'_i_j')
|
---|
| 3290 | [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);
|
---|
| 3291 | if idetect==1
|
---|
| 3292 | NomTypeNew='_i1-i2_j';
|
---|
| 3293 | else
|
---|
| 3294 | NomTypeNew='_i_j1-j2';
|
---|
| 3295 | end
|
---|
| 3296 | else %for instance avi files or any ima_num series
|
---|
| 3297 | [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1);
|
---|
| 3298 | NomTypeNew='_i1-i2';
|
---|
| 3299 | end
|
---|
| 3300 | [Path,Name]=fileparts(filebase_1);
|
---|
| 3301 | set(handles.FileExt_1,'String','.nc');
|
---|
| 3302 | if ~isempty(SubDir_1) && ~strcmp(SubDir_1,'''')&& ~strcmp(SubDir_1,'"')&& ~strcmp(SubDir_1(1),'/')
|
---|
| 3303 | SubDir_1=['/' SubDir_1];
|
---|
| 3304 | end
|
---|
| 3305 | set(handles.SubDir_1,'String',SubDir_1);
|
---|
| 3306 | end
|
---|
| 3307 | if isequal(field,'vort') | isequal(field,'div') | isequal(field,'strain')
|
---|
| 3308 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3309 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3310 | set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3311 | set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3312 | elseif isequal(field_1,'more...'); %add new item to the menu
|
---|
| 3313 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3314 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3315 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 3316 | [ind_answer,v] = listdlg('PromptString','Select a file:',...
|
---|
| 3317 | 'SelectionMode','single',...
|
---|
| 3318 | 'ListString',str);
|
---|
| 3319 | % edit the choice in the field and action menu
|
---|
| 3320 | scalar=cell2mat(str(ind_answer));
|
---|
| 3321 | menu=update_menu(handles.Fields_1,scalar);
|
---|
| 3322 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3323 | end
|
---|
| 3324 | end
|
---|
| 3325 | str1=get(handles.i1,'String');
|
---|
| 3326 | str2=get(handles.i2,'String');
|
---|
| 3327 | str_a=get(handles.j1,'String');
|
---|
| 3328 | str_b=get(handles.j2,'String');
|
---|
| 3329 | indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
|
---|
| 3330 | set(handles.FileIndex_1,'String',indices)
|
---|
| 3331 | set(handles.FileIndex_1,'UserData',NomTypeNew)
|
---|
| 3332 |
|
---|
| 3333 | %common to Fields_Callback
|
---|
| 3334 | if isequal(field,'image')|isequal(field_1,'image')
|
---|
| 3335 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3336 | set(handles.npy_title,'Visible','on')
|
---|
| 3337 | set(handles.npx,'Visible','on')
|
---|
| 3338 | set(handles.npy,'Visible','on')
|
---|
| 3339 | % set(handles.fix_pair,'Value',0)
|
---|
| 3340 | else
|
---|
| 3341 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3342 | set(handles.npy_title,'Visible','off')
|
---|
| 3343 | set(handles.npx,'Visible','off')
|
---|
| 3344 | set(handles.npy,'Visible','off')
|
---|
| 3345 | % set(handles.fix_pair,'Value',1)
|
---|
| 3346 | end
|
---|
| 3347 | if isequal(field,'velocity')|isequal(field_1,'velocity');
|
---|
| 3348 | state_vect='on';
|
---|
| 3349 | else
|
---|
| 3350 | state_vect='off';
|
---|
| 3351 | end
|
---|
| 3352 | if ~isequal(field,'velocity')|(~isequal(field_1,'velocity')&~isequal(field_1,''));
|
---|
| 3353 | state_scal='on';
|
---|
| 3354 | else
|
---|
| 3355 | state_scal='off';
|
---|
| 3356 | end
|
---|
| 3357 | set(handles.uvmat,'UserData',UvData)
|
---|
| 3358 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3359 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
|
---|
| 3360 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3361 | end
|
---|
| 3362 |
|
---|
| 3363 | %------------------------------------------------------------------------
|
---|
| 3364 | % --- set the visibility of relevant velocity type menus:
|
---|
| 3365 | function set_veltype_display(handles,Civ)
|
---|
| 3366 | %------------------------------------------------------------------------
|
---|
| 3367 | %Civ=0; all states 'off'
|
---|
| 3368 | %Civ=6; all states 'on'
|
---|
| 3369 | if isequal(Civ,0)
|
---|
| 3370 | imax=0;
|
---|
| 3371 | % set(handles(1),'Visible','on') % unvisible civ buttons
|
---|
| 3372 | % else
|
---|
| 3373 | % set(handles(1),'String','civ1')
|
---|
| 3374 | % end
|
---|
| 3375 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
| 3376 | imax=1;
|
---|
| 3377 | elseif isequal(Civ,3)
|
---|
| 3378 | imax=3;
|
---|
| 3379 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
| 3380 | imax=4;
|
---|
| 3381 | elseif isequal(Civ,6) %patch2
|
---|
| 3382 | imax=6;
|
---|
| 3383 | end
|
---|
| 3384 | for ibutton=1:imax;
|
---|
| 3385 | set(handles(ibutton),'Visible','on') % unvisible civ buttons
|
---|
| 3386 | end
|
---|
| 3387 | % for ibutton=max(imax+1,2):6;
|
---|
| 3388 | for ibutton=imax+1:6;
|
---|
| 3389 | set(handles(ibutton),'Visible','off') % unvisible civ buttons
|
---|
| 3390 | set(handles(ibutton),'Value',0)%unactivate unvisible buttons
|
---|
| 3391 | end
|
---|
| 3392 |
|
---|
| 3393 | %-------------------------------------------------------------------
|
---|
| 3394 | % --- Executes on button press in civ1.
|
---|
| 3395 | function civ1_Callback(hObject, eventdata, handles)
|
---|
| 3396 | %-------------------------------------------------------------------
|
---|
| 3397 | if get(handles.civ1,'Value')==1
|
---|
| 3398 | reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ1)
|
---|
| 3399 | else
|
---|
| 3400 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3401 | end
|
---|
| 3402 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3403 |
|
---|
| 3404 | %-------------------------------------------------------------------
|
---|
| 3405 | % --- Executes on button press in interp1.
|
---|
| 3406 | function interp1_Callback(hObject, eventdata, handles)
|
---|
| 3407 | %-------------------------------------------------------------------
|
---|
| 3408 | if get(handles.interp1,'Value')==1
|
---|
| 3409 | reset_vel_type([handles.civ1 handles.civ2 handles.filter1 handles.interp2 handles.filter2],handles.interp1)
|
---|
| 3410 | else
|
---|
| 3411 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3412 | end
|
---|
| 3413 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3414 |
|
---|
| 3415 | %-------------------------------------------------------------------
|
---|
| 3416 | % --- Executes on button press in filter1.
|
---|
| 3417 | function filter1_Callback(hObject, eventdata, handles)
|
---|
| 3418 | %-------------------------------------------------------------------
|
---|
| 3419 | if get(handles.filter1,'Value')==1
|
---|
| 3420 | reset_vel_type([handles.civ1 handles.civ2 handles.interp1 handles.interp2 handles.filter2],handles.filter1)
|
---|
| 3421 | else
|
---|
| 3422 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3423 | end
|
---|
| 3424 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3425 |
|
---|
| 3426 | %-------------------------------------------------------------------
|
---|
| 3427 | % --- Executes on button press in civ2.
|
---|
| 3428 | function civ2_Callback(hObject, eventdata, handles)
|
---|
| 3429 | %-------------------------------------------------------------------
|
---|
| 3430 | if get(handles.civ2,'Value')==1
|
---|
| 3431 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ2)
|
---|
| 3432 | else
|
---|
| 3433 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3434 | end
|
---|
| 3435 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3436 |
|
---|
| 3437 | %-----------------------------------------
|
---|
| 3438 | % --- Executes on button press in interp2.
|
---|
| 3439 | %-------------------------------------------
|
---|
| 3440 | function interp2_Callback(hObject, eventdata, handles)
|
---|
| 3441 | if get(handles.interp2,'Value')==1
|
---|
| 3442 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.filter2],handles.interp2)
|
---|
| 3443 | else
|
---|
| 3444 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3445 | end
|
---|
| 3446 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3447 | %---------------------------------------------
|
---|
| 3448 | % --- Executes on button press in filter2.
|
---|
| 3449 | %-------------------------------------------
|
---|
| 3450 | function filter2_Callback(hObject, eventdata, handles)
|
---|
| 3451 | if get(handles.filter2,'Value')==1
|
---|
| 3452 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2],handles.filter2)
|
---|
| 3453 | else
|
---|
| 3454 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3455 | end
|
---|
| 3456 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3457 |
|
---|
| 3458 | %---------------------------------------------
|
---|
| 3459 | function civ1_1_Callback(hObject, eventdata, handles)
|
---|
| 3460 | %---------------------------------------------
|
---|
| 3461 | if get(handles.civ1_1,'Value')==1
|
---|
| 3462 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.civ1_1)
|
---|
| 3463 | else
|
---|
| 3464 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3465 | end
|
---|
| 3466 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3467 |
|
---|
| 3468 | %--------------------------------------------
|
---|
| 3469 | function interp1_1_Callback(hObject, eventdata, handles)
|
---|
| 3470 | %--------------------------------------------
|
---|
| 3471 | if get(handles.interp1_1,'Value')==1
|
---|
| 3472 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.interp1_1)
|
---|
| 3473 | else
|
---|
| 3474 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3475 | end
|
---|
| 3476 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3477 |
|
---|
| 3478 | %--------------------------------------------
|
---|
| 3479 | function filter1_1_Callback(hObject, eventdata, handles)
|
---|
| 3480 | %--------------------------------------------
|
---|
| 3481 | if get(handles.filter1_1,'Value')==1
|
---|
| 3482 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.filter1_1)
|
---|
| 3483 | else
|
---|
| 3484 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3485 | end
|
---|
| 3486 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3487 |
|
---|
| 3488 | %--------------------------------------------
|
---|
| 3489 | function civ2_1_Callback(hObject, eventdata, handles)
|
---|
| 3490 | %--------------------------------------------
|
---|
| 3491 | if get(handles.civ2_1,'Value')==1
|
---|
| 3492 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.civ2_1)
|
---|
| 3493 | else
|
---|
| 3494 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3495 | end
|
---|
| 3496 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3497 |
|
---|
| 3498 | %--------------------------------------------
|
---|
| 3499 | function interp2_1_Callback(hObject, eventdata, handles)
|
---|
| 3500 | %--------------------------------------------
|
---|
| 3501 | if get(handles.interp2_1,'Value')==1
|
---|
| 3502 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.filter2_1],handles.interp2_1)
|
---|
| 3503 | else
|
---|
| 3504 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3505 | end
|
---|
| 3506 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3507 |
|
---|
| 3508 | %--------------------------------------------
|
---|
| 3509 | function filter2_1_Callback(hObject, eventdata, handles)
|
---|
| 3510 | %--------------------------------------------
|
---|
| 3511 | if get(handles.filter2_1,'Value')==1
|
---|
| 3512 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1],handles.filter2_1)
|
---|
| 3513 | else
|
---|
| 3514 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3515 | end
|
---|
| 3516 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3517 |
|
---|
| 3518 | %-----------------------------------------------
|
---|
| 3519 | % --- reset civ buttons
|
---|
| 3520 | function reset_vel_type(handles_civ0,handle1)
|
---|
| 3521 | for ibutton=1:length(handles_civ0)
|
---|
| 3522 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 3523 | set(handles_civ0(ibutton),'Value',0)
|
---|
| 3524 | end
|
---|
| 3525 | if exist('handle1','var')%handles of selected button
|
---|
| 3526 | set(handle1,'BackgroundColor',[1 1 0])
|
---|
| 3527 | end
|
---|
| 3528 |
|
---|
| 3529 | %-------------------------------------------------------
|
---|
| 3530 | % --- Executes on button press in MENUVOLUME.
|
---|
| 3531 | %-------------------------------------------------------
|
---|
| 3532 | function VOLUME_Callback(hObject, eventdata, handles)
|
---|
| 3533 | %errordlg('command VOL not implemented yet')
|
---|
| 3534 | if ishandle(handles.UVMAT_title)
|
---|
| 3535 | delete(handles.UVMAT_title)
|
---|
| 3536 | end
|
---|
| 3537 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 3538 | if isequal(get(handles.VOLUME,'Value'),1)
|
---|
| 3539 | set(handles.zoom,'Value',0)
|
---|
| 3540 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3541 | set(handles.edit_vect,'Value',0)
|
---|
| 3542 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3543 | set(handles.edit_object,'Value',0)
|
---|
| 3544 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3545 | % set(handles.cal,'Value',0)
|
---|
| 3546 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
| 3547 | set(handles.edit_vect,'Value',0)
|
---|
| 3548 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3549 | %initiate set_object GUI
|
---|
| 3550 | data.TITLE='VOLUME';
|
---|
| 3551 | if isfield(UvData,'CoordType')
|
---|
| 3552 | data.CoordType=UvData.CoordType;
|
---|
| 3553 | end
|
---|
| 3554 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 3555 | data.RangeY=UvData.Mesh;
|
---|
| 3556 | data.RangeX=UvData.Mesh;
|
---|
| 3557 | data.DX=UvData.Mesh;
|
---|
| 3558 | data.DY=UvData.Mesh;
|
---|
| 3559 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
| 3560 | np=size(UvData.Field.A);
|
---|
| 3561 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 3562 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 3563 | data.RangeY=max(meshx,meshy);
|
---|
| 3564 | data.RangeX=max(meshx,meshy);
|
---|
| 3565 | data.DX=max(meshx,meshy);
|
---|
| 3566 | end
|
---|
| 3567 | data.ParentButton=handles.VOLUME;
|
---|
| 3568 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 3569 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
|
---|
| 3570 | % associate the set_object interface handle to the plotting axes
|
---|
| 3571 | if isfield(UvData.OpenParam,'SetObjectOrigin')
|
---|
| 3572 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3573 | pos_set_object(1:2)=UvData.OpenParam.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 3574 | pos_set_object(3:4)=UvData.OpenParam.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 3575 | set(hset_object,'Position',pos_set_object)
|
---|
| 3576 | end
|
---|
| 3577 | UvData.MouseAction='create_object';
|
---|
| 3578 | else
|
---|
| 3579 | set(handles.VOLUME,'BackgroundColor',[0 1 0])
|
---|
| 3580 | UvData.MouseAction='none';
|
---|
| 3581 | end
|
---|
| 3582 | set(huvmat,'UserData',UvData)
|
---|
| 3583 |
|
---|
| 3584 | %-------------------------------------------------------
|
---|
| 3585 | function edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3586 | %-------------------------------------------------------
|
---|
| 3587 | %
|
---|
| 3588 | % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 3589 | if isequal(get(handles.edit_vect,'Value'),1)
|
---|
| 3590 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
| 3591 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 3592 | if ~test_civ2 && ~test_civ1
|
---|
| 3593 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 3594 | end
|
---|
| 3595 | set(handles.record,'Visible','on')
|
---|
| 3596 | set(handles.edit_vect,'BackgroundColor',[1 1 0])
|
---|
| 3597 | set(handles.edit_object,'Value',0)
|
---|
| 3598 | set(handles.zoom,'Value',0)
|
---|
| 3599 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3600 | % set(handles.create,'Value',0)
|
---|
| 3601 | % set(handles.create,'BackgroundColor',[0 1 0])
|
---|
| 3602 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3603 | set(gcf,'Pointer','arrow')
|
---|
| 3604 | % UvData.MouseAction='edit_vect';
|
---|
| 3605 | else
|
---|
| 3606 | set(handles.record,'Visible','off')
|
---|
| 3607 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3608 | % UvData.MouseAction='none';
|
---|
| 3609 | end
|
---|
| 3610 | % set(handles.uvmat,'UserData',UvData)
|
---|
| 3611 |
|
---|
| 3612 | %----------------------------------------------
|
---|
| 3613 | function save_mask_Callback(hObject, eventdata, handles)
|
---|
| 3614 | %-----------------------------------------------------------------------
|
---|
| 3615 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3616 |
|
---|
| 3617 | flag=1;
|
---|
| 3618 | npx=size(UvData.Field.A,2);
|
---|
| 3619 | npy=size(UvData.Field.A,1);
|
---|
| 3620 | xi=0.5:npx-0.5;
|
---|
| 3621 | yi=0.5:npy-0.5;
|
---|
| 3622 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 3623 | if isfield(UvData,'Object')
|
---|
| 3624 | for iobj=1:length(UvData.Object)
|
---|
| 3625 | ObjectData=UvData.Object{iobj};
|
---|
| 3626 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 3627 | flagobj=1;
|
---|
| 3628 | testphys=0; %coordinates in pixels by default
|
---|
| 3629 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
| 3630 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 3631 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 3632 | testphys=1;
|
---|
| 3633 | end
|
---|
| 3634 | end
|
---|
| 3635 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 3636 | if isequal(ObjectData.Style,'polygon')
|
---|
| 3637 | X=ObjectData.Coord(:,1);
|
---|
| 3638 | Y=ObjectData.Coord(:,2);
|
---|
| 3639 | if testphys
|
---|
| 3640 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 3641 | end
|
---|
| 3642 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
| 3643 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 3644 | if testphys
|
---|
| 3645 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3646 | end
|
---|
| 3647 | RangeX=max(ObjectData.RangeX);
|
---|
| 3648 | RangeY=max(ObjectData.RangeY);
|
---|
| 3649 | X2Max=RangeX*RangeX;
|
---|
| 3650 | Y2Max=RangeY*RangeY;
|
---|
| 3651 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 3652 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 3653 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 3654 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 3655 | if testphys
|
---|
| 3656 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3657 | end
|
---|
| 3658 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 3659 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 3660 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 3661 | end
|
---|
| 3662 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 3663 | flagobj=~flagobj;
|
---|
| 3664 | end
|
---|
| 3665 | flag=flag & flagobj;
|
---|
| 3666 | end
|
---|
| 3667 | end
|
---|
| 3668 | end
|
---|
| 3669 | end
|
---|
| 3670 | % flag=~flag;
|
---|
| 3671 | %mask name
|
---|
| 3672 | RootPath=get(handles.RootPath,'String');
|
---|
| 3673 | RootFile=get(handles.RootFile,'String');
|
---|
| 3674 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 3675 | RootFile(1)=[];
|
---|
| 3676 | end
|
---|
| 3677 | filebase=fullfile(RootPath,RootFile);
|
---|
| 3678 | list=get(handles.masklevel,'String');
|
---|
| 3679 | masknumber=num2str(length(list));
|
---|
| 3680 | maskindex=get(handles.masklevel,'Value');
|
---|
| 3681 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 3682 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 3683 | imflag=flipdim(imflag,1);
|
---|
| 3684 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)
|
---|
| 3685 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved'])
|
---|
| 3686 | imwrite(imflag,mask_name,'BitDepth',8);
|
---|
| 3687 |
|
---|
| 3688 | %display the mask
|
---|
| 3689 | %update_mask(handles,num_i1,num_j1)
|
---|
| 3690 | figure;
|
---|
| 3691 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 3692 | map=[vec' vec' vec'];
|
---|
| 3693 | colormap(map)
|
---|
| 3694 |
|
---|
| 3695 | image(imflag);
|
---|
| 3696 |
|
---|
| 3697 | %-------------------------------------------------------------------
|
---|
| 3698 | %-------------------------------------------------------------------
|
---|
| 3699 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
| 3700 |
|
---|
| 3701 | %------------------------------------------------------------------
|
---|
| 3702 |
|
---|
| 3703 |
|
---|
| 3704 |
|
---|
| 3705 | %------------------------------------------------------------------
|
---|
| 3706 | % --- Executes on selection change in col_vec: choice of the color code.
|
---|
| 3707 | %
|
---|
| 3708 | function col_vec_Callback(hObject, eventdata, handles)
|
---|
| 3709 | %------------------------------------------------------------------
|
---|
| 3710 | % edit the choice for color code
|
---|
| 3711 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 3712 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 3713 | col_code= list_code{index_code(1)}; % selected field
|
---|
| 3714 | if isequal(col_code,'black') || isequal(col_code,'white')
|
---|
| 3715 | set(handles.slider1,'Visible','off')
|
---|
| 3716 | set(handles.slider2,'Visible','off')
|
---|
| 3717 | set(handles.colcode1,'Visible','off')
|
---|
| 3718 | set(handles.colcode2,'Visible','off')
|
---|
| 3719 | set(handles.AutoVecColor,'Visible','off')
|
---|
| 3720 | set_vec_col_bar(handles)
|
---|
| 3721 | else
|
---|
| 3722 | set(handles.slider1,'Visible','on')
|
---|
| 3723 | set(handles.slider2,'Visible','on')
|
---|
| 3724 | set(handles.colcode1,'Visible','on')
|
---|
| 3725 | set(handles.colcode2,'Visible','on')
|
---|
| 3726 | set(handles.AutoVecColor,'Visible','on')
|
---|
| 3727 | if isequal(col_code,'ima_cor')
|
---|
| 3728 | set(handles.AutoVecColor,'Value',0)%fixed scale by default
|
---|
| 3729 | set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
|
---|
| 3730 | set(handles.slider1,'Min',0);
|
---|
| 3731 | set(handles.slider1,'Max',1);
|
---|
| 3732 | set(handles.slider2,'Min',0);
|
---|
| 3733 | set(handles.slider2,'Max',1);
|
---|
| 3734 | % set(handles.min_title_vec,'String','0')
|
---|
| 3735 | set(handles.max_vec,'String','1')
|
---|
| 3736 | set(handles.colcode1,'String','0.333')
|
---|
| 3737 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3738 | set(handles.colcode2,'String','0.666')
|
---|
| 3739 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3740 | else
|
---|
| 3741 | set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
|
---|
| 3742 | set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
|
---|
| 3743 | minval=get(handles.slider1,'Min');
|
---|
| 3744 | maxval=get(handles.slider1,'Max');
|
---|
| 3745 | set(handles.slider1,'Value',minval)
|
---|
| 3746 | set(handles.slider2,'Value',maxval)
|
---|
| 3747 | set_vec_col_bar(handles)
|
---|
| 3748 | end
|
---|
| 3749 | % slider_update(handles)
|
---|
| 3750 | end
|
---|
| 3751 | %replot the current graph
|
---|
| 3752 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3753 |
|
---|
| 3754 |
|
---|
| 3755 | %----------------------------------------------------------------
|
---|
| 3756 | % -- Executes on slider movement to set the color code
|
---|
| 3757 | %
|
---|
| 3758 | function slider1_Callback(hObject, eventdata, handles)
|
---|
| 3759 | %------------------------------------------------------------------
|
---|
| 3760 | slider1=get(handles.slider1,'Value');
|
---|
| 3761 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3762 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3763 | col=min_val+(max_val-min_val)*slider1;
|
---|
| 3764 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3765 | if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
| 3766 | set(handles.slider2,'Value',col)
|
---|
| 3767 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3768 | end
|
---|
| 3769 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3770 |
|
---|
| 3771 | %----------------------------------------------------------------
|
---|
| 3772 | % Executes on slider movement to set the color code
|
---|
| 3773 | %----------------------------------------------------------------
|
---|
| 3774 | function slider2_Callback(hObject, eventdata, handles)
|
---|
| 3775 | slider2=get(handles.slider2,'Value');
|
---|
| 3776 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3777 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3778 | col=min_val+(max_val-min_val)*slider2;
|
---|
| 3779 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3780 | if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
| 3781 | set(handles.slider1,'Value',col)
|
---|
| 3782 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3783 | end
|
---|
| 3784 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3785 |
|
---|
| 3786 | %----------------------------------------------------------------
|
---|
| 3787 | %execute on return carriage on the edit box corresponding to slider 1
|
---|
| 3788 | %----------------------------------------------------------------
|
---|
| 3789 | function colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3790 | % col=str2num(get(handles.colcode1,'String'));
|
---|
| 3791 | % set(handles.slider1,'Value',col)
|
---|
| 3792 | set_vec_col_bar(handles)
|
---|
| 3793 | update_plot(handles);
|
---|
| 3794 |
|
---|
| 3795 | %----------------------------------------------------------------
|
---|
| 3796 | %execute on return carriage on the edit box corresponding to slider 2
|
---|
| 3797 | %----------------------------------------------------------------
|
---|
| 3798 | function colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3799 | % col=str2num(get(handles.colcode2,'String'));
|
---|
| 3800 | % set(handles.slider2,'Value',col)
|
---|
| 3801 | % slider2_Callback(hObject, eventdata, handles)
|
---|
| 3802 | set_vec_col_bar(handles)
|
---|
| 3803 | update_plot(handles);
|
---|
| 3804 | %------------------------------------------------------------
|
---|
| 3805 | %update the slider values after displaying vectors
|
---|
| 3806 | %--------------------------------------------------------
|
---|
| 3807 | % function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
|
---|
| 3808 | % set(handles.slider1,'Min',minC)
|
---|
| 3809 | % set(handles.slider1,'Max',maxC)
|
---|
| 3810 | % set(handles.slider2,'Min',minC)
|
---|
| 3811 | % set(handles.slider2,'Max',maxC)
|
---|
| 3812 | % set(handles.min_title_vec,'String',num2str(minC))
|
---|
| 3813 | % set(handles.max_vec,'String',num2str(maxC))
|
---|
| 3814 | % if auto
|
---|
| 3815 | % set(handles.colcode1,'String',num2str(colcode1,3))%update display
|
---|
| 3816 | % set(handles.colcode2,'String',num2str(colcode2,3))
|
---|
| 3817 | % end
|
---|
| 3818 | % set(handles.slider1,'Value',colcode1)%update slider with constant display
|
---|
| 3819 | % set(handles.slider2,'Value',colcode2)
|
---|
| 3820 | % set_vec_col_bar(handles)
|
---|
| 3821 |
|
---|
| 3822 |
|
---|
| 3823 | %-------------------------------------------------------
|
---|
| 3824 | % --- Executes on button press in AutoVecColor.
|
---|
| 3825 | %-------------------------------------------------------
|
---|
| 3826 | function vec_col_bar_Callback(hObject, eventdata, handles)
|
---|
| 3827 | set_vec_col_bar(handles)
|
---|
| 3828 |
|
---|
| 3829 | %-------------------------------------------------------------
|
---|
| 3830 | % --- Executes on selection change in transform_fct.
|
---|
| 3831 | function transform_fct_Callback(hObject, eventdata, handles)
|
---|
| 3832 | %-------------------------------------------------------------
|
---|
| 3833 |
|
---|
| 3834 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3835 | menu=get(handles.transform_fct,'String');
|
---|
| 3836 | ind_coord=get(handles.transform_fct,'Value');
|
---|
| 3837 | coord_option=menu{ind_coord};
|
---|
| 3838 | list_transform=get(handles.transform_fct,'UserData');
|
---|
| 3839 | ff=functions(list_transform{end});
|
---|
| 3840 | if isequal(coord_option,'more...');
|
---|
| 3841 | coord_fct='';
|
---|
| 3842 | prompt = {'Enter the name of the transform function'};
|
---|
| 3843 | dlg_title = 'user defined transform';
|
---|
| 3844 | num_lines= 1;
|
---|
| 3845 | [FileName, PathName] = uigetfile( ...
|
---|
| 3846 | {'*.m', ' (*.m)';
|
---|
| 3847 | '*.m', '.m files '; ...
|
---|
| 3848 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 3849 | 'Pick a file', ff.file);
|
---|
| 3850 | if isequal(PathName(end),'/')||isequal(PathName(end),'\')
|
---|
| 3851 | PathName(end)=[];
|
---|
| 3852 | end
|
---|
| 3853 | transform_selected =fullfile(PathName,FileName);
|
---|
| 3854 | if ~exist(transform_selected,'file')
|
---|
| 3855 | return
|
---|
| 3856 | end
|
---|
| 3857 | [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m
|
---|
| 3858 | if ~isequal(ext_fct,'.m')
|
---|
| 3859 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
| 3860 | return
|
---|
| 3861 | end
|
---|
| 3862 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
|
---|
| 3863 | ind_coord=get(handles.transform_fct,'Value');
|
---|
| 3864 | addpath(PathName)
|
---|
| 3865 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
|
---|
| 3866 | set(handles.transform_fct,'UserData',list_transform)
|
---|
| 3867 | rmpath(PathName)
|
---|
| 3868 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
| 3869 | dir_perso=prefdir;%personal Matalb directory
|
---|
| 3870 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 3871 | if exist(profil_perso,'file')
|
---|
| 3872 | nb_builtin=UvData.OpenParam.NbBuiltin;
|
---|
| 3873 | for ilist=nb_builtin+1:numel(list_transform)
|
---|
| 3874 | ff=functions(list_transform{ilist});
|
---|
| 3875 | transform_fct{ilist-nb_builtin}=ff.file;
|
---|
| 3876 | end
|
---|
| 3877 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
|
---|
| 3878 | end
|
---|
| 3879 | end
|
---|
| 3880 |
|
---|
| 3881 | %check the current path to the selected function
|
---|
| 3882 | if isa(list_transform{ind_coord},'function_handle')
|
---|
| 3883 | func=functions(list_transform{ind_coord});
|
---|
| 3884 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
|
---|
| 3885 | else
|
---|
| 3886 | set(handles.path_transform,'String','')
|
---|
| 3887 | end
|
---|
| 3888 |
|
---|
| 3889 | set(handles.FixLimits,'Value',0)
|
---|
| 3890 | set(handles.FixLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3891 |
|
---|
| 3892 | %delete drawn objects
|
---|
| 3893 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 3894 | for iobj=1:length(hother)
|
---|
| 3895 | delete_object(hother(iobj))
|
---|
| 3896 | end
|
---|
| 3897 | hother=findobj('Tag','DeformPoint');%find all the proj objects
|
---|
| 3898 | for iobj=1:length(hother)
|
---|
| 3899 | delete_object(hother(iobj))
|
---|
| 3900 | end
|
---|
| 3901 | hh=findobj('Tag','calib_points');
|
---|
| 3902 | if ~isempty(hh)
|
---|
| 3903 | delete(hh)
|
---|
| 3904 | end
|
---|
| 3905 | hhh=findobj('Tag','calib_marker');
|
---|
| 3906 | if ~isempty(hhh)
|
---|
| 3907 | delete(hhh)
|
---|
| 3908 | end
|
---|
| 3909 | if isfield(UvData,'Object')
|
---|
| 3910 | UvData.Object=UvData.Object(1);
|
---|
| 3911 | end
|
---|
| 3912 | list_object=get(handles.list_object_1,'String');
|
---|
| 3913 | set(handles.list_object_1,'Value',1)
|
---|
| 3914 | set(handles.list_object_1,'String',list_object(1))
|
---|
| 3915 | set(handles.list_object_2,'Value',2)
|
---|
| 3916 | set(handles.list_object_2,'String',[list_object(1);{'...'}])
|
---|
| 3917 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 3918 |
|
---|
| 3919 | %delete mask if it is displayed
|
---|
| 3920 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 3921 | UvData=rmfield(UvData,'MaskName'); %will impose mask refresh
|
---|
| 3922 | end
|
---|
| 3923 | set(handles.uvmat,'UserData',UvData)
|
---|
| 3924 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3925 |
|
---|
| 3926 | %--------------------------------------------
|
---|
| 3927 | function histo1_menu_Callback(hObject, eventdata, handles)
|
---|
| 3928 | %--------------------------------------------
|
---|
| 3929 | %plot first histo
|
---|
| 3930 | huvmat=get(handles.histo1_menu,'parent');
|
---|
| 3931 | histo_menu=get(handles.histo1_menu,'String');
|
---|
| 3932 | histo_value=get(handles.histo1_menu,'Value');
|
---|
| 3933 | FieldName=histo_menu{histo_value};
|
---|
| 3934 | update_histo(handles.histo_u,huvmat,FieldName)
|
---|
| 3935 |
|
---|
| 3936 | %----------------------------------------------
|
---|
| 3937 | function histo2_menu_Callback(hObject, eventdata, handles)
|
---|
| 3938 | %----------------------------------------------
|
---|
| 3939 | %plot second histo
|
---|
| 3940 | huvmat=get(handles.histo2_menu,'parent');
|
---|
| 3941 | histo_menu=get(handles.histo2_menu,'String');
|
---|
| 3942 | histo_value=get(handles.histo2_menu,'Value');
|
---|
| 3943 | FieldName=histo_menu{histo_value};
|
---|
| 3944 | update_histo(handles.histo_v,huvmat,FieldName)
|
---|
| 3945 |
|
---|
| 3946 |
|
---|
| 3947 | %--------------------------------------------
|
---|
| 3948 | %read the field .Fieldname stored in UvData and plot its histogram
|
---|
| 3949 | function update_histo(haxes,huvmat,FieldName)
|
---|
| 3950 | UvData=get(huvmat,'UserData');
|
---|
| 3951 | if ~isfield(UvData.Field,FieldName)
|
---|
| 3952 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram'])
|
---|
| 3953 | return
|
---|
| 3954 | end
|
---|
| 3955 | Field=UvData.Field;
|
---|
| 3956 | FieldHisto=eval(['Field.' FieldName]);
|
---|
| 3957 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto))
|
---|
| 3958 | indsel=find(Field.FF==0);%find values marked as false
|
---|
| 3959 | if ~isempty(indsel)
|
---|
| 3960 | FieldHisto=FieldHisto(indsel);
|
---|
| 3961 | end
|
---|
| 3962 | end
|
---|
| 3963 | if isempty(Field)
|
---|
| 3964 | msgbox_uvmat('ERROR',['empty field ' FieldName])
|
---|
| 3965 | else
|
---|
| 3966 | nxy=size(FieldHisto);
|
---|
| 3967 | Amin=double(min(min(min(FieldHisto))));%min of image
|
---|
| 3968 | Amax=double(max(max(max(FieldHisto))));%max of image
|
---|
| 3969 | if isequal(Amin,Amax)
|
---|
| 3970 | msgbox_uvmat('WARNING',['uniform field =' num2str(Amin)]);
|
---|
| 3971 | else
|
---|
| 3972 | Histo.ListVarName={FieldName,'histo'};
|
---|
| 3973 | if isequal(Field.NbDim,3)
|
---|
| 3974 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
| 3975 | else
|
---|
| 3976 | if numel(nxy)==2
|
---|
| 3977 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
| 3978 | else
|
---|
| 3979 | Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
|
---|
| 3980 | end
|
---|
| 3981 | end
|
---|
| 3982 | %unit
|
---|
| 3983 | units=[]; %default
|
---|
| 3984 | for ivar=1:numel(Field.ListVarName)
|
---|
| 3985 | if strcmp(Field.ListVarName{ivar},FieldName)
|
---|
| 3986 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
|
---|
| 3987 | units=Field.VarAttribute{ivar}.units;
|
---|
| 3988 | break
|
---|
| 3989 | end
|
---|
| 3990 | end
|
---|
| 3991 | end
|
---|
| 3992 | if ~isempty(units)
|
---|
| 3993 | Histo.VarAttribute{1}.units=units;
|
---|
| 3994 | end
|
---|
| 3995 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
|
---|
| 3996 | if isequal(Field.NbDim,3)
|
---|
| 3997 | C=reshape(double(FieldHisto),1,[]);% reshape in a vector
|
---|
| 3998 | eval(['Histo.histo(:,1)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
| 3999 | else
|
---|
| 4000 | for col=1:size(FieldHisto,3)
|
---|
| 4001 | B=FieldHisto(:,:,col);
|
---|
| 4002 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
|
---|
| 4003 | eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
| 4004 | end
|
---|
| 4005 | end
|
---|
| 4006 | % set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
|
---|
| 4007 | % set(haxes,'YLimMode','auto')
|
---|
| 4008 | % PlotParam.Auto_xy=1;
|
---|
| 4009 | plot_field(Histo,haxes);
|
---|
| 4010 | end
|
---|
| 4011 | end
|
---|
| 4012 |
|
---|
| 4013 | %------------------------------------------------
|
---|
| 4014 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
| 4015 | %-------------------------------------------------
|
---|
| 4016 |
|
---|
| 4017 | %------------------------------------------------------------------------
|
---|
| 4018 | function MinX_Callback(hObject, eventdata, handles)
|
---|
| 4019 | %------------------------------------------------------------------------
|
---|
| 4020 | set(handles.FixLimits,'Value',1) %suppress auto mode
|
---|
| 4021 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 4022 | update_plot(handles);
|
---|
| 4023 |
|
---|
| 4024 | %------------------------------------------------------------------------
|
---|
| 4025 | function MaxX_Callback(hObject, eventdata, handles)
|
---|
| 4026 | %------------------------------------------------------------------------
|
---|
| 4027 | set(handles.FixLimits,'Value',1) %suppress auto mode
|
---|
| 4028 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 4029 | update_plot(handles);
|
---|
| 4030 |
|
---|
| 4031 | %------------------------------------------------------------------------
|
---|
| 4032 | function MinY_Callback(hObject, eventdata, handles)
|
---|
| 4033 | %------------------------------------------
|
---|
| 4034 | set(handles.FixLimits,'Value',1) %suppress auto mode
|
---|
| 4035 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 4036 | update_plot(handles);
|
---|
| 4037 |
|
---|
| 4038 | %------------------------------------------------------------------------
|
---|
| 4039 | function MaxY_Callback(hObject, eventdata, handles)
|
---|
| 4040 | %------------------------------------------------------------------------
|
---|
| 4041 | set(handles.FixLimits,'Value',1) %suppress auto mode
|
---|
| 4042 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 4043 | update_plot(handles);
|
---|
| 4044 |
|
---|
| 4045 | %------------------------------------------------------------------------
|
---|
| 4046 | function MinA_Callback(hObject, eventdata, handles)
|
---|
| 4047 | %------------------------------------------
|
---|
| 4048 | set(handles.FixScal,'Value',1) %suppress auto mode
|
---|
| 4049 | set(handles.FixScal,'BackgroundColor',[1 1 0])
|
---|
| 4050 | update_plot(handles);
|
---|
| 4051 |
|
---|
| 4052 | %------------------------------------------------------------------------
|
---|
| 4053 | function MaxA_Callback(hObject, eventdata, handles)
|
---|
| 4054 | %------------------------------------------------------------------------
|
---|
| 4055 | set(handles.FixScal,'Value',1) %suppress auto mode
|
---|
| 4056 | set(handles.FixScal,'BackgroundColor',[1 1 0])
|
---|
| 4057 | update_plot(handles);
|
---|
| 4058 |
|
---|
| 4059 | %------------------------------------------------------------------------
|
---|
| 4060 | function FixScal_Callback(hObject, eventdata, handles)
|
---|
| 4061 | %------------------------------------------------------------------------
|
---|
| 4062 | test=get(handles.FixScal,'Value');
|
---|
| 4063 | if test
|
---|
| 4064 | set(handles.FixScal,'BackgroundColor',[1 1 0])
|
---|
| 4065 | else
|
---|
| 4066 | set(handles.FixScal,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4067 | update_plot(handles);
|
---|
| 4068 | end
|
---|
| 4069 |
|
---|
| 4070 | %-------------------------------------------------------------------
|
---|
| 4071 | function BW_Callback(hObject, eventdata, handles)
|
---|
| 4072 | %-------------------------------------------------------------------
|
---|
| 4073 | update_plot(handles);
|
---|
| 4074 |
|
---|
| 4075 | %-------------------------------------------------------------------
|
---|
| 4076 | function Contours_Callback(hObject, eventdata, handles)
|
---|
| 4077 | %-------------------------------------------------------------------
|
---|
| 4078 | val=get(handles.Contours,'Value');
|
---|
| 4079 | if val==2
|
---|
| 4080 | set(handles.interval_txt,'Visible','on')
|
---|
| 4081 | set(handles.IncrA,'Visible','on')
|
---|
| 4082 | else
|
---|
| 4083 | set(handles.interval_txt,'Visible','off')
|
---|
| 4084 | set(handles.IncrA,'Visible','off')
|
---|
| 4085 | end
|
---|
| 4086 | update_plot(handles);
|
---|
| 4087 |
|
---|
| 4088 | %-------------------------------------------------------------------
|
---|
| 4089 | function IncrA_Callback(hObject, eventdata, handles)
|
---|
| 4090 | %-------------------------------------------------------------------
|
---|
| 4091 | update_plot(handles);
|
---|
| 4092 |
|
---|
| 4093 | %-------------------------------------------------------------------
|
---|
| 4094 | function HideWarning_Callback(hObject, eventdata, handles)
|
---|
| 4095 | %-------------------------------------------------------------------
|
---|
| 4096 | update_plot(handles);
|
---|
| 4097 |
|
---|
| 4098 | %-------------------------------------------------------------------
|
---|
| 4099 | function HideFalse_Callback(hObject, eventdata, handles)
|
---|
| 4100 | %-------------------------------------------------------------------
|
---|
| 4101 | update_plot(handles);
|
---|
| 4102 |
|
---|
| 4103 | %-------------------------------------------------------------------
|
---|
| 4104 | function VecScale_Callback(hObject, eventdata, handles)
|
---|
| 4105 | %-------------------------------------------------------------------
|
---|
| 4106 | set(handles.FixVec,'Value',1);
|
---|
| 4107 | set(handles.FixVec,'BackgroundColor',[1 1 0])
|
---|
| 4108 | update_plot(handles);
|
---|
| 4109 |
|
---|
| 4110 | %-------------------------------------------------------------------
|
---|
| 4111 | function FixVec_Callback(hObject, eventdata, handles)
|
---|
| 4112 | %-------------------------------------------------------------------
|
---|
| 4113 | test=get(handles.FixVec,'Value');
|
---|
| 4114 | if test
|
---|
| 4115 | set(handles.FixVec,'BackgroundColor',[1 1 0])
|
---|
| 4116 | else
|
---|
| 4117 | update_plot(handles);
|
---|
| 4118 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4119 | set(handles.FixVec,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4120 | end
|
---|
| 4121 |
|
---|
| 4122 | %------------------------------------------------------------------------
|
---|
| 4123 | % --- Executes on selection change in decimate4 (nb_vec/4).
|
---|
| 4124 | function decimate4_Callback(hObject, eventdata, handles)
|
---|
| 4125 | %------------------------------------------------------------------------
|
---|
| 4126 | update_plot(handles);
|
---|
| 4127 |
|
---|
| 4128 | %------------------------------------------------------------------------
|
---|
| 4129 | % --- Executes on selection change in color_code menu
|
---|
| 4130 | function color_code_Callback(hObject, eventdata, handles)
|
---|
| 4131 | %------------------------------------------------------------------------
|
---|
| 4132 | set_vec_col_bar(handles)
|
---|
| 4133 | update_plot(handles);
|
---|
| 4134 |
|
---|
| 4135 | %------------------------------------------------------------------------
|
---|
| 4136 | % --- Executes on button press in AutoVecColor.
|
---|
| 4137 | function AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4138 | %------------------------------------------------------------------------
|
---|
| 4139 | test=get(handles.AutoVecColor,'Value');
|
---|
| 4140 | if test
|
---|
| 4141 | set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
|
---|
| 4142 | else
|
---|
| 4143 | update_plot(handles);
|
---|
| 4144 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4145 | set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4146 | end
|
---|
| 4147 |
|
---|
| 4148 | %------------------------------------------------------------------------
|
---|
| 4149 | % --- Executes on selection change in max_vec.
|
---|
| 4150 | function min_vec_Callback(hObject, eventdata, handles)
|
---|
| 4151 | %------------------------------------------------------------------------
|
---|
| 4152 | max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4153 |
|
---|
| 4154 | %------------------------------------------------------------------------
|
---|
| 4155 | % --- Executes on selection change in max_vec.
|
---|
| 4156 | function max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4157 | %------------------------------------------------------------------------
|
---|
| 4158 | set(handles.AutoVecColor,'Value',1)
|
---|
| 4159 | AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4160 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 4161 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 4162 | slider1=get(handles.slider1,'Value');
|
---|
| 4163 | slider2=get(handles.slider2,'Value');
|
---|
| 4164 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
| 4165 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
| 4166 | set(handles.colcode1,'String',num2str(colcode1))
|
---|
| 4167 | set(handles.colcode2,'String',num2str(colcode2))
|
---|
| 4168 | update_plot(handles);
|
---|
| 4169 |
|
---|
| 4170 | %------------------------------------------------------------------------
|
---|
| 4171 | % --- update the display of color code for vectors
|
---|
| 4172 | function set_vec_col_bar(handles)
|
---|
| 4173 | %------------------------------------------------------------------------
|
---|
| 4174 | %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 4175 | set(handles.vec_col_bar,'Unit','pixel');
|
---|
| 4176 | pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 4177 | set(handles.vec_col_bar,'Unit','Normalized');
|
---|
| 4178 | width=ceil(pos_vert(3));
|
---|
| 4179 | height=ceil(pos_vert(4));
|
---|
| 4180 |
|
---|
| 4181 | %get slider indications
|
---|
| 4182 | list=get(handles.color_code,'String');
|
---|
| 4183 | ichoice=get(handles.color_code,'Value');
|
---|
| 4184 | colcode.ColorCode=list{ichoice};
|
---|
| 4185 | colcode.MinC=str2num(get(handles.min_vec,'String'));
|
---|
| 4186 | colcode.MaxC=str2num(get(handles.max_vec,'String'));
|
---|
| 4187 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
|
---|
| 4188 | if test3color
|
---|
| 4189 | colcode.colcode1=str2num(get(handles.colcode1,'String'));
|
---|
| 4190 | colcode.colcode2=str2num(get(handles.colcode2,'String'));
|
---|
| 4191 | end
|
---|
| 4192 | colcode.FixedCbounds=0;
|
---|
| 4193 | colcode.FixedCbounds=1;
|
---|
| 4194 | vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*(0.5:width-0.5)/width;%sample of vec_C values from min to max
|
---|
| 4195 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 4196 | oneheight=ones(1,height);
|
---|
| 4197 | A1=colorlist(col_vec,1)*oneheight;
|
---|
| 4198 | A2=colorlist(col_vec,2)*oneheight;
|
---|
| 4199 | A3=colorlist(col_vec,3)*oneheight;
|
---|
| 4200 | A(:,:,1)=A1';
|
---|
| 4201 | A(:,:,2)=A2';
|
---|
| 4202 | A(:,:,3)=A3';
|
---|
| 4203 | set(handles.vec_col_bar,'Cdata',A)
|
---|
| 4204 |
|
---|
| 4205 |
|
---|
| 4206 | %-------------------------------------------------------------------
|
---|
| 4207 | function update_plot(handles)
|
---|
| 4208 | %-------------------------------------------------------------------
|
---|
| 4209 | haxes= handles.axes3;
|
---|
| 4210 | UvData=get(handles.uvmat,'UserData');
|
---|
| 4211 | AxeData=UvData.axes3;
|
---|
| 4212 | PlotParam=read_plot_param(handles);
|
---|
| 4213 | [PP,PlotParamOut]= plot_field(AxeData,haxes,PlotParam);
|
---|
| 4214 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
| 4215 |
|
---|
| 4216 | %-------------------------------------------------------------------
|
---|
| 4217 | % --- Executes on button press in grid.
|
---|
| 4218 | function grid_Callback(hObject, eventdata, handles)
|
---|
| 4219 |
|
---|
| 4220 |
|
---|
| 4221 | %-------------------------------------------------------------------
|
---|
| 4222 | % --- Executes on selection change in edit_object.
|
---|
| 4223 | function edit_object_Callback(hObject, eventdata, handles)
|
---|
| 4224 | %-------------------------------------------------------------------
|
---|
| 4225 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4226 | test=get(handles.edit_object,'Value');
|
---|
| 4227 | if test
|
---|
| 4228 | set(handles.edit_object,'BackgroundColor',[1,1,0])
|
---|
| 4229 | %suppress the other options
|
---|
| 4230 | set(handles.zoom,'Value',0)
|
---|
| 4231 | zoom_Callback(hObject, eventdata, handles)
|
---|
| 4232 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
|
---|
| 4233 | if ishandle(hgeometry_calib)
|
---|
| 4234 | hhgeometry_calib=guidata(hgeometry_calib);
|
---|
| 4235 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
|
---|
| 4236 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4237 | end
|
---|
| 4238 | else
|
---|
| 4239 | UvData.MouseAction='none';
|
---|
| 4240 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4241 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
|
---|
| 4242 | if ~isempty(hset_object)
|
---|
| 4243 | delete(hset_object)% delete the current GUI set_object
|
---|
| 4244 | end
|
---|
| 4245 | end
|
---|
| 4246 | set(handles.uvmat,'UserData',UvData);
|
---|
| 4247 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
| 4248 | if ~isempty(hset_object)
|
---|
| 4249 | hhset_object=guidata(hset_object);
|
---|
| 4250 | if test
|
---|
| 4251 | set(hhset_object.PLOT,'enable','on');
|
---|
| 4252 | else
|
---|
| 4253 | set(hhset_object.PLOT,'enable','off');
|
---|
| 4254 | end
|
---|
| 4255 | end
|
---|
| 4256 |
|
---|
| 4257 | %------------------------------------------------------------------------
|
---|
| 4258 | % --- Executes on selection change in list_object_1.
|
---|
| 4259 | function list_object_1_Callback(hObject, eventdata, handles)
|
---|
| 4260 | %------------------------------------------------------------------------
|
---|
| 4261 | list_str=get(handles.list_object_1,'String');
|
---|
| 4262 | IndexObj=get(handles.list_object_1,'Value');
|
---|
| 4263 | str_1=list_str{IndexObj};
|
---|
| 4264 | val_2=get(handles.list_object_2,'Value');
|
---|
| 4265 | str_2=get(handles.list_object_2,'String');
|
---|
| 4266 | if isequal(val_2,IndexObj)% if the first selection is equal to the second, it will suppress the second
|
---|
| 4267 | set(handles.list_object_2,'Value',numel(str_2))%select the end of the list ('...')
|
---|
| 4268 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4269 | end
|
---|
| 4270 | update_object(handles,IndexObj,1,str_1)
|
---|
| 4271 |
|
---|
| 4272 | %------------------------------------------------------------------------
|
---|
| 4273 | % --- Executes on selection change in list_object_1.
|
---|
| 4274 | function list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4275 | %------------------------------------------------------------------------
|
---|
| 4276 | list_str=get(handles.list_object_2,'String');
|
---|
| 4277 | IndexObj=get(handles.list_object_2,'Value');
|
---|
| 4278 | if ischar(list_str) || strcmp(list_str{IndexObj},'...')
|
---|
| 4279 | hview_field=findobj(allchild(0),'Tag','view_field');
|
---|
| 4280 | if ~isempty(hview_field)
|
---|
| 4281 | delete(hview_field)
|
---|
| 4282 | end
|
---|
| 4283 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
| 4284 | if ~isempty(hset_object)
|
---|
| 4285 | delete(hset_object)
|
---|
| 4286 | end
|
---|
| 4287 | else
|
---|
| 4288 | update_object(handles,IndexObj,2,list_str{IndexObj})
|
---|
| 4289 | end
|
---|
| 4290 |
|
---|
| 4291 | %------------------------------------------------------------------------
|
---|
| 4292 | function update_object(handles,IndexObj,option,ObjectName)
|
---|
| 4293 | %------------------------------------------------------------------------
|
---|
| 4294 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4295 | if numel(UvData.Object)<IndexObj;
|
---|
| 4296 | return
|
---|
| 4297 | end
|
---|
| 4298 | ObjectData=UvData.Object{IndexObj};
|
---|
| 4299 | ObjectData.Name=ObjectName;
|
---|
| 4300 | if isequal(get(handles.edit_object,'Value'),1)
|
---|
| 4301 | ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode
|
---|
| 4302 | end
|
---|
| 4303 | ZBounds=0; % default
|
---|
| 4304 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
|
---|
| 4305 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
|
---|
| 4306 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
|
---|
| 4307 | end
|
---|
| 4308 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
| 4309 | if ~isempty(hset_object)
|
---|
| 4310 | delete(hset_object)% delete existing version of set_object
|
---|
| 4311 | end
|
---|
| 4312 | edit_test=get(handles.edit_object,'Value');
|
---|
| 4313 | if edit_test
|
---|
| 4314 | ObjectData.enable_plot=1;
|
---|
| 4315 | else
|
---|
[210] | 4316 | if isfield(ObjectData,'enable_plot')
|
---|
[199] | 4317 | ObjectData=rmfield(ObjectData,'enable_plot');
|
---|
| 4318 | end
|
---|
| 4319 | end
|
---|
| 4320 | hset_object=set_object(ObjectData,[],ZBounds);% call the set_object interface,
|
---|
| 4321 |
|
---|
| 4322 | % %project the current field on the object and plot it
|
---|
| 4323 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
|
---|
| 4324 | if option==1%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes)
|
---|
| 4325 | PlotHandles=handles;
|
---|
| 4326 | else
|
---|
| 4327 | hview_field=findobj(allchild(0),'tag','view_field');
|
---|
| 4328 | if isempty(hview_field)
|
---|
| 4329 | hview_field=view_field;
|
---|
| 4330 | end
|
---|
| 4331 | PlotHandles=guidata(hview_field);
|
---|
| 4332 | end
|
---|
| 4333 | plot_field(ProjData,PlotHandles.axes3,PlotHandles);
|
---|
| 4334 | set(handles.uvmat,'UserData',UvData)
|
---|
| 4335 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 4336 | for iobj=1:length(hother)
|
---|
| 4337 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch')
|
---|
| 4338 | set(hother(iobj),'EdgeColor','b')
|
---|
| 4339 | if isequal(get(hother(iobj),'FaceColor'),'m')
|
---|
| 4340 | set(hother(iobj),'FaceColor','b')
|
---|
| 4341 | end
|
---|
| 4342 | elseif isequal(get(hother(iobj),'Type'),'image')
|
---|
| 4343 | Acolor=get(hother(iobj),'CData');
|
---|
| 4344 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
|
---|
| 4345 | set(hother(iobj),'CData',Acolor);
|
---|
| 4346 | else
|
---|
| 4347 | set(hother(iobj),'Color','b')
|
---|
| 4348 | end
|
---|
| 4349 | set(hother(iobj),'Selected','off')
|
---|
| 4350 | end
|
---|
| 4351 | hother=findobj('Tag','DeformPoint');
|
---|
| 4352 | set(hother,'Color','b');
|
---|
| 4353 | set(hother,'Selected','off')
|
---|
| 4354 | if isfield(ObjectData,'DisplayHandle_uvmat')
|
---|
| 4355 | if ishandle(ObjectData.DisplayHandle_uvmat)
|
---|
| 4356 | uistack(ObjectData.DisplayHandle_uvmat,'top')
|
---|
| 4357 | linetype=get(ObjectData.DisplayHandle_uvmat,'Type');
|
---|
| 4358 | if isequal(linetype,'line')
|
---|
| 4359 | set(ObjectData.DisplayHandle_uvmat,'Color','m'); %set the selected object to magenta color
|
---|
| 4360 | elseif isequal(linetype,'rectangle')
|
---|
| 4361 | set(ObjectData.DisplayHandle_uvmat,'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4362 | elseif isequal(linetype,'patch')
|
---|
| 4363 | set(ObjectData.DisplayHandle_uvmat,'FaceColor','m'); %set the selected object to magenta color
|
---|
| 4364 | end
|
---|
| 4365 | SubObjectData=get(ObjectData.DisplayHandle_uvmat,'UserData');
|
---|
| 4366 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject)
|
---|
| 4367 | uistack(SubObjectData.SubObject,'top')
|
---|
| 4368 | for iobj=1:length(SubObjectData.SubObject)
|
---|
| 4369 | hsub=SubObjectData.SubObject(iobj);
|
---|
| 4370 | if isequal(get(hsub,'Type'),'rectangle')
|
---|
| 4371 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4372 | elseif isequal(get(hsub,'Type'),'image')
|
---|
| 4373 | Acolor=get(hsub,'CData');
|
---|
| 4374 | Acolor(:,:,1)=Acolor(:,:,3);
|
---|
| 4375 | set(hsub,'CData',Acolor);
|
---|
| 4376 | else
|
---|
| 4377 | set(hsub,'Color','m')
|
---|
| 4378 | end
|
---|
| 4379 | end
|
---|
| 4380 | end
|
---|
| 4381 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint)
|
---|
| 4382 | set(SubObjectData.DeformPoint,'Color','m')
|
---|
| 4383 | end
|
---|
| 4384 | end
|
---|
| 4385 | % end
|
---|
| 4386 | end
|
---|
| 4387 | % pause(0.1)
|
---|
| 4388 | figure(hset_object)%put set_object in front
|
---|
| 4389 |
|
---|
| 4390 | %------------------------------------------------------
|
---|
| 4391 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
| 4392 | %------------------------------------------------------
|
---|
| 4393 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
| 4394 | global Data_uvmat
|
---|
| 4395 | Data_uvmat=get(handles.uvmat,'UserData');
|
---|
| 4396 | evalin('base','global Data_uvmat')%make CurData global in the workspace
|
---|
| 4397 | display('current field :')
|
---|
| 4398 | evalin('base','Data_uvmat') %display CurData in the workspace
|
---|
| 4399 | commandwindow; %brings the Matlab command window to the front
|
---|
| 4400 |
|
---|
| 4401 | %------------------------------------------------------
|
---|
| 4402 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
| 4403 | %------------------------------------------------------
|
---|
| 4404 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
| 4405 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
| 4406 | UvData=get(huvmat,'UserData');
|
---|
| 4407 | hfig=figure;
|
---|
| 4408 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 4409 | map=colormap(handles.axes3);
|
---|
| 4410 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4411 | colorbar
|
---|
| 4412 |
|
---|
| 4413 |
|
---|
| 4414 | % --------------------------------------------------------------------
|
---|
| 4415 | function Insert_Callback(hObject, eventdata, handles)
|
---|
| 4416 |
|
---|
| 4417 |
|
---|
| 4418 | % --------------------------------------------------------------------
|
---|
| 4419 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
| 4420 | % --------------------------------------------------------------------
|
---|
| 4421 | path_to_uvmat=which ('uvmat');% check the path of uvmat
|
---|
| 4422 | pathelp=fileparts(path_to_uvmat);
|
---|
| 4423 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
| 4424 | 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')
|
---|
| 4425 | else
|
---|
| 4426 | addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
| 4427 | web(helpfile);
|
---|
| 4428 | end
|
---|
| 4429 |
|
---|
| 4430 | %------------------------------------------------------------------------
|
---|
| 4431 | % --------------------------------------------------------------------
|
---|
| 4432 | function MenuExportMovie_Callback(hObject, eventdata, handles)
|
---|
| 4433 | % --------------------------------------------------------------------
|
---|
| 4434 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button
|
---|
| 4435 | huvmat=get(handles.run0,'parent');
|
---|
| 4436 | UvData=get(huvmat,'UserData');
|
---|
| 4437 | [xx,xx,FileBase]=read_file_boxes(handles);
|
---|
| 4438 | %read the current input file name
|
---|
| 4439 | 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)'};
|
---|
| 4440 | dlg_title = 'select properties of the output avi movie';
|
---|
| 4441 | num_lines= 1;
|
---|
| 4442 | % nbfield_cell=get(handles.last_i,'String');
|
---|
| 4443 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
|
---|
| 4444 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
|
---|
| 4445 | aviname=answer{1};
|
---|
| 4446 | fps=str2double(answer{2});
|
---|
| 4447 | % check for existing file with output name aviname
|
---|
| 4448 | if exist(aviname,'file')
|
---|
| 4449 | backup=aviname;
|
---|
| 4450 | testexist=2;
|
---|
| 4451 | while testexist==2
|
---|
| 4452 | backup=[backup '~'];
|
---|
| 4453 | testexist=exist(backup,'file');
|
---|
| 4454 | end
|
---|
| 4455 | [success,message]=copyfile(aviname,backup);%make backup of the existing file
|
---|
| 4456 | if isequal(success,1)
|
---|
| 4457 | delete(aviname)%delete existing file
|
---|
| 4458 | else
|
---|
| 4459 | msgbox_uvmat('ERROR',message)
|
---|
| 4460 | return
|
---|
| 4461 | end
|
---|
| 4462 | end
|
---|
| 4463 | %create avi open
|
---|
| 4464 | aviobj=avifile(aviname,'Compression','None','fps',fps);
|
---|
| 4465 |
|
---|
| 4466 | %display first view for tests
|
---|
| 4467 | newfig=figure;
|
---|
| 4468 | newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure
|
---|
| 4469 | set(newaxes,'Tag','movieaxes')
|
---|
| 4470 | nbpix=[512 384]*str2double(answer{3});
|
---|
| 4471 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA
|
---|
| 4472 | set(newaxes,'Position',eval(answer{4}));
|
---|
| 4473 | map=colormap(handles.axes3);
|
---|
| 4474 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4475 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;...
|
---|
| 4476 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']});
|
---|
| 4477 | UvData.Object{1}.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
|
---|
| 4478 | set(huvmat,'UserData',UvData);
|
---|
| 4479 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 4480 | if isnan(increment)
|
---|
| 4481 | set(handles.increment_scan,'String','1')%default value
|
---|
| 4482 | increment=1;
|
---|
| 4483 | end
|
---|
| 4484 | set(handles.STOP,'Visible','on')
|
---|
| 4485 | set(handles.speed,'Visible','on')
|
---|
| 4486 | set(handles.speed_txt,'Visible','on')
|
---|
| 4487 | set(handles.Movie,'BusyAction','queue')
|
---|
| 4488 |
|
---|
| 4489 | %imin=str2double(get(handles.i1,'String'));
|
---|
| 4490 | imax=str2double(answer{5});
|
---|
| 4491 | % if isfield(UvData,'Time')
|
---|
| 4492 | htitle=get(newaxes,'Title');
|
---|
| 4493 | xlim=get(newaxes,'XLim');
|
---|
| 4494 | ylim=get(newaxes,'YLim');
|
---|
| 4495 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0])
|
---|
| 4496 | time_str=get(handles.abs_time,'String');
|
---|
| 4497 | set(htitle,'String',['t=' time_str])
|
---|
| 4498 | set(handles.speed,'Value',1)
|
---|
| 4499 | for i=1:imax
|
---|
| 4500 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
|
---|
| 4501 | runpm(hObject,eventdata,handles,increment)% run plus
|
---|
| 4502 | drawnow
|
---|
| 4503 | time_str=get(handles.abs_time,'String');
|
---|
| 4504 | if ishandle(htitle)
|
---|
| 4505 | set(htitle,'String',['t=' time_str])
|
---|
| 4506 | end
|
---|
| 4507 | mov=getframe(newfig);
|
---|
| 4508 | aviobj=addframe(aviobj,mov);
|
---|
| 4509 | end
|
---|
| 4510 | end
|
---|
| 4511 | close(aviobj);
|
---|
| 4512 | UvData.Object{1}.plotaxes=handles.axes3;
|
---|
| 4513 | set(huvmat,'UserData',UvData);
|
---|
| 4514 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
|
---|
| 4515 |
|
---|
| 4516 | %------------------------------------------------------------------------
|
---|
| 4517 | function MenuCalib_Callback(hObject, eventdata, handles)
|
---|
| 4518 | %------------------------------------------------------------------------
|
---|
| 4519 |
|
---|
| 4520 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4521 |
|
---|
| 4522 | %suppress competing options
|
---|
| 4523 | set(handles.zoom,'Value',0)
|
---|
| 4524 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4525 | set(handles.list_object_1,'Value',1)
|
---|
| 4526 | % initiate display of GUI geometry_calib
|
---|
| 4527 | data=[]; %default
|
---|
| 4528 | if isfield(UvData,'CoordType')
|
---|
| 4529 | data.CoordType=UvData.CoordType;
|
---|
| 4530 | end
|
---|
| 4531 | pos=get(handles.uvmat,'Position');
|
---|
| 4532 | pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
|
---|
| 4533 | pos(2)=pos(2)-0.02;
|
---|
| 4534 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 4535 | set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib
|
---|
| 4536 | if isfield(UvData.OpenParam,'CalOrigin')
|
---|
| 4537 | pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4538 | pos_cal(1)=pos_uvmat(1)+UvData.OpenParam.CalOrigin(1)*pos_uvmat(3);
|
---|
| 4539 | pos_cal(2)=pos_uvmat(2)+UvData.OpenParam.CalOrigin(2)*pos_uvmat(4);
|
---|
| 4540 | pos_cal(3:4)=UvData.OpenParam.CalSize .* pos_uvmat(3:4);
|
---|
| 4541 | end
|
---|
| 4542 | geometry_calib(FileName,pos_cal);% call the geometry_calib interface
|
---|
| 4543 | set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib
|
---|
| 4544 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action
|
---|
| 4545 |
|
---|
| 4546 | %------------------------------------------------------------------------
|
---|
| 4547 | function MenuMask_Callback(hObject, eventdata, handles)
|
---|
| 4548 | %------------------------------------------------------------------------
|
---|
| 4549 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4550 | ListObj=UvData.Object;
|
---|
| 4551 | select=zeros(1,numel(ListObj));
|
---|
| 4552 | for iobj=1:numel(ListObj);
|
---|
| 4553 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside')
|
---|
| 4554 | select(iobj)=1;
|
---|
| 4555 | end
|
---|
| 4556 | end
|
---|
| 4557 | val=find(select);
|
---|
| 4558 | if isempty(val)
|
---|
| 4559 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar');
|
---|
| 4560 | return
|
---|
| 4561 | else
|
---|
| 4562 | set(handles.list_object_1,'Max',2);%allow multiple selection
|
---|
| 4563 | set(handles.list_object_1,'Value',val);
|
---|
| 4564 | flag=1;
|
---|
| 4565 | npx=size(UvData.Field.A,2);
|
---|
| 4566 | npy=size(UvData.Field.A,1);
|
---|
| 4567 | xi=0.5:npx-0.5;
|
---|
| 4568 | yi=0.5:npy-0.5;
|
---|
| 4569 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 4570 | if isfield(UvData,'Object')
|
---|
| 4571 | for iobj=1:length(UvData.Object)
|
---|
| 4572 | ObjectData=UvData.Object{iobj};
|
---|
| 4573 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 4574 | flagobj=1;
|
---|
| 4575 | testphys=0; %coordinates in pixels by default
|
---|
| 4576 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel')
|
---|
| 4577 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 4578 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 4579 | testphys=1;
|
---|
| 4580 | end
|
---|
| 4581 | end
|
---|
| 4582 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 4583 | if isequal(ObjectData.Style,'polygon')
|
---|
| 4584 | X=ObjectData.Coord(:,1);
|
---|
| 4585 | Y=ObjectData.Coord(:,2);
|
---|
| 4586 | if testphys
|
---|
| 4587 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 4588 | end
|
---|
| 4589 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
| 4590 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 4591 | if testphys
|
---|
| 4592 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4593 | end
|
---|
| 4594 | RangeX=max(ObjectData.RangeX);
|
---|
| 4595 | RangeY=max(ObjectData.RangeY);
|
---|
| 4596 | X2Max=RangeX*RangeX;
|
---|
| 4597 | Y2Max=RangeY*RangeY;
|
---|
| 4598 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 4599 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 4600 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 4601 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 4602 | if testphys
|
---|
| 4603 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4604 | end
|
---|
| 4605 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 4606 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 4607 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 4608 | end
|
---|
| 4609 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 4610 | flagobj=~flagobj;
|
---|
| 4611 | end
|
---|
| 4612 | flag=flag & flagobj;
|
---|
| 4613 | end
|
---|
| 4614 | end
|
---|
| 4615 | end
|
---|
| 4616 | end
|
---|
| 4617 |
|
---|
| 4618 | %mask name
|
---|
| 4619 | RootPath=get(handles.RootPath,'String');
|
---|
| 4620 | RootFile=get(handles.RootFile,'String');
|
---|
| 4621 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 4622 | RootFile(1)=[];
|
---|
| 4623 | end
|
---|
| 4624 | filebase=fullfile(RootPath,RootFile);
|
---|
| 4625 | list=get(handles.masklevel,'String');
|
---|
| 4626 | masknumber=num2str(length(list));
|
---|
| 4627 | maskindex=get(handles.masklevel,'Value');
|
---|
| 4628 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 4629 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 4630 | imflag=flipdim(imflag,1);
|
---|
| 4631 |
|
---|
| 4632 | %display the mask
|
---|
| 4633 | figure;
|
---|
| 4634 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 4635 | map=[vec' vec' vec'];
|
---|
| 4636 | colormap(map)
|
---|
| 4637 | image(imflag);
|
---|
| 4638 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name);
|
---|
| 4639 | if ~strcmp(answer,'Cancel')
|
---|
| 4640 | mask_dir=fileparts(answer);
|
---|
| 4641 | if ~exist(mask_dir,'dir')
|
---|
| 4642 | msgbox_uvmat('ERROR',['directory ' mask_dir ' does not exist'])
|
---|
| 4643 | return
|
---|
| 4644 | end
|
---|
| 4645 | imwrite(imflag,answer,'BitDepth',8);
|
---|
| 4646 | end
|
---|
| 4647 | set(handles.list_object_1,'Value',1)
|
---|
| 4648 | set(handles.list_object_1,'Max',1)
|
---|
| 4649 | end
|
---|
| 4650 |
|
---|
| 4651 | %------------------------------------------------------------------------
|
---|
| 4652 | %-- open the GUI set_grid.fig to create grid
|
---|
| 4653 | function MenuGrid_Callback(hObject, eventdata, handles)
|
---|
| 4654 | %------------------------------------------------------------------------
|
---|
| 4655 | %UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4656 |
|
---|
| 4657 | %suppress the other options if grid is chosen
|
---|
| 4658 | set(handles.edit_vect,'Value',0)
|
---|
| 4659 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4660 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4661 | set(handles.list_object_1,'Value',1)
|
---|
| 4662 |
|
---|
| 4663 | %prepare display of the set_grid GUI
|
---|
| 4664 | FileName=read_file_boxes(handles);
|
---|
| 4665 | CoordList=get(handles.transform_fct,'String');
|
---|
| 4666 | val=get(handles.transform_fct,'Value');
|
---|
| 4667 | set_grid(FileName,CoordList{val});% call the set_object interface
|
---|
| 4668 | %set(handles.uvmat,'UserData',UvData);
|
---|
| 4669 |
|
---|
| 4670 | %------------------------------------------------------------------------
|
---|
| 4671 | % open the GUI 'series'
|
---|
| 4672 | function MenuSeries_Callback(hObject, eventdata, handles)
|
---|
| 4673 | %------------------------------------------------------------------------
|
---|
| 4674 | series; %first display of the GUI to fill waiting time
|
---|
| 4675 | [param.FileName]=read_file_boxes(handles);
|
---|
| 4676 | if isequal(get(handles.SubField,'Value'),1)
|
---|
| 4677 | FileName_1=read_file_boxes_1(handles);%
|
---|
| 4678 | if ~isequal(FileName_1,param.FileName)
|
---|
| 4679 | param.FileName_1=FileName_1;
|
---|
| 4680 | end
|
---|
| 4681 | end
|
---|
| 4682 | param.NomType=get(handles.FileIndex,'UserData');
|
---|
| 4683 | param.NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 4684 | param.comp_input=get(handles.fix_pair,'Value');
|
---|
| 4685 | huvmat=get(handles.MenuSeries,'parent');
|
---|
| 4686 | UvData=get(huvmat,'UserData');
|
---|
| 4687 | if isfield(UvData,'Time')
|
---|
| 4688 | param.Time=UvData.XmlData.Time;
|
---|
| 4689 | end
|
---|
| 4690 | if isequal(get(handles.scan_i,'Value'),1)
|
---|
| 4691 | param.incr_i=str2double(get(handles.increment_scan,'String'));
|
---|
| 4692 | elseif isequal(get(handles.scan_j,'Value'),1)
|
---|
| 4693 | param.incr_j=str2double(get(handles.increment_scan,'String'));
|
---|
| 4694 | end
|
---|
| 4695 | param.list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 4696 | param.list_fields(1)=[]; %suppress 'image' option
|
---|
| 4697 | param.index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 4698 | if param.index_fields>1
|
---|
| 4699 | param.index_fields=param.index_fields-1;
|
---|
| 4700 | end
|
---|
| 4701 | param.list_fields_1=get(handles.Fields_1,'String');% list menu fields
|
---|
| 4702 | param.list_fields_1(1)=[]; %suppress 'image' option
|
---|
| 4703 | param.index_fields_1=get(handles.Fields_1,'Value')-1;% selected string index
|
---|
| 4704 | if param.index_fields_1>1
|
---|
| 4705 | param.index_fields_1=param.index_fields_1-1;
|
---|
| 4706 | end
|
---|
| 4707 | param.civ1=get(handles.civ1,'Value');
|
---|
| 4708 | param.civ2=get(handles.civ2,'Value');
|
---|
| 4709 | param.interp1=get(handles.interp1,'Value');
|
---|
| 4710 | param.interp2=get(handles.interp2,'Value');
|
---|
| 4711 | param.filter1=get(handles.filter1,'Value');
|
---|
| 4712 | param.filter2=get(handles.filter2,'Value');
|
---|
| 4713 | param.menu_coord_str=get(handles.transform_fct,'String');
|
---|
| 4714 | param.menu_coord_val=get(handles.transform_fct,'Value');
|
---|
| 4715 |
|
---|
| 4716 | series(param); %run the series interface
|
---|
| 4717 |
|
---|
| 4718 | %------------------------------------------------------------------------
|
---|
| 4719 | % -- open the GUI civ.fig for civx (PIV)
|
---|
| 4720 | function MenuPIV_Callback(hObject, eventdata, handles)
|
---|
| 4721 | %------------------------------------------------------------------------
|
---|
| 4722 |
|
---|
| 4723 | [FileName,RootPath,filebase,FileIndices,ext,SubDir]=read_file_boxes(handles);
|
---|
| 4724 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 4725 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 4726 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 4727 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 4728 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 4729 | ind_opening=1; % default (images): will advice civ1 option by default in the civ interface
|
---|
| 4730 | if isequal(ext,'.nc') || isequal(ext,'.cdf')% netcdf files
|
---|
| 4731 | ind_opening=2;% propose 'fix' as the default option
|
---|
| 4732 | % +read the current netcdf rootfile
|
---|
| 4733 | Data=nc2struct(FileName,'ListGlobalAttribute','fix','patch','civ2','fix2');
|
---|
| 4734 | if isfield(Data,'fix') && isequal(Data.fix,1)
|
---|
| 4735 | ind_opening=3;
|
---|
| 4736 | end
|
---|
| 4737 | if isfield(Data,'patch') && isequal(Data.patch,1)
|
---|
| 4738 | ind_opening=4;
|
---|
| 4739 | end
|
---|
| 4740 | if isfield(Data,'civ2') && isequal(Data.civ2,1)
|
---|
| 4741 | ind_opening=5;
|
---|
| 4742 | end
|
---|
| 4743 | if isfield(Data,'fix2') && isequal(Data.fix2,1)
|
---|
| 4744 | ind_opening=6;
|
---|
| 4745 | end
|
---|
| 4746 | end
|
---|
| 4747 | param.RootName=filebase;
|
---|
| 4748 | param.NomType=NomType;
|
---|
| 4749 | param.num1=num1;
|
---|
| 4750 | param.num2=num2;
|
---|
| 4751 | param.num_a=num_a;
|
---|
| 4752 | param.num_b=num_b;
|
---|
| 4753 | param.SubDir=SubDir;
|
---|
| 4754 | param.IndOpening=ind_opening;% A REVOIR +TRANSMETTRE IMADOC INFO
|
---|
| 4755 | param.ImaExt=ext;
|
---|
| 4756 | civ(param);% interface de civ(not in the uvmat file)
|
---|
| 4757 |
|
---|
| 4758 | %------------------------------------------------------------------------
|
---|
| 4759 | function MenuTools_Callback(hObject, eventdata, handles)
|
---|
| 4760 | %------------------------------------------------------------------------
|
---|
| 4761 |
|
---|
| 4762 | %------------------------------------------------------------------------
|
---|
| 4763 | function MenuEditObject_Callback(hObject, eventdata, handles)
|
---|
| 4764 | %------------------------------------------------------------------------
|
---|
| 4765 | set(handles.edit_object,'Value',1)
|
---|
| 4766 | edit_Callback(hObject, eventdata, handles)
|
---|
| 4767 |
|
---|
| 4768 | %------------------------------------------------------------------------
|
---|
| 4769 | function enable_transform(handles,state)
|
---|
| 4770 | %------------------------------------------------------------------------
|
---|
| 4771 | set(handles.transform_fct,'Visible',state)
|
---|
| 4772 | set(handles.TRANSFORM_txt,'Visible',state)
|
---|
| 4773 | set(handles.transform_fct,'Visible',state)
|
---|
| 4774 | set(handles.path_transform,'Visible',state)
|
---|
| 4775 | set(handles.pxcmx_txt,'Visible',state)
|
---|
| 4776 | set(handles.pxcmy_txt,'Visible',state)
|
---|
| 4777 | set(handles.pxcm,'Visible',state)
|
---|
| 4778 | set(handles.pycm,'Visible',state)
|
---|
| 4779 |
|
---|
| 4780 | %------------------------------------------------------------------------
|
---|
| 4781 | function MenuEditVectors_Callback(hObject, eventdata, handles)
|
---|
| 4782 | %------------------------------------------------------------------------
|
---|
| 4783 | set(handles.edit_vect,'Visible','on')
|
---|
| 4784 | set(handles.edit_vect,'Value',1)
|
---|
| 4785 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4786 |
|
---|
| 4787 | % -----------------------------------------------------------------------
|
---|
| 4788 | function Menupoints_Callback(hObject, eventdata, handles)
|
---|
| 4789 | %------------------------------------------------------------------------
|
---|
| 4790 | data.Style='points';
|
---|
| 4791 | data.ProjMode='projection';%default
|
---|
| 4792 | create_object(data,handles)
|
---|
| 4793 |
|
---|
| 4794 | % -----------------------------------------------------------------------
|
---|
| 4795 | function Menuline_Callback(hObject, eventdata, handles)
|
---|
| 4796 | %------------------------------------------------------------------------
|
---|
| 4797 | data.Style='line';
|
---|
| 4798 | data.ProjMode='projection';%default
|
---|
| 4799 | create_object(data,handles)
|
---|
| 4800 |
|
---|
| 4801 | %------------------------------------------------------------------------
|
---|
| 4802 | function Menupolyline_Callback(hObject, eventdata, handles)
|
---|
| 4803 | %------------------------------------------------------------------------
|
---|
| 4804 | data.Style='polyline';
|
---|
| 4805 | data.ProjMode='projection';%default
|
---|
| 4806 | create_object(data,handles)
|
---|
| 4807 |
|
---|
| 4808 | %------------------------------------------------------------------------
|
---|
| 4809 | function Menupolygon_Callback(hObject, eventdata, handles)
|
---|
| 4810 | %------------------------------------------------------------------------
|
---|
| 4811 | data.Style='polygon';
|
---|
| 4812 | data.ProjMode='inside';%default
|
---|
| 4813 | create_object(data,handles)
|
---|
| 4814 |
|
---|
| 4815 | %------------------------------------------------------------------------
|
---|
| 4816 | function Menurectangle_Callback(hObject, eventdata, handles)
|
---|
| 4817 | %------------------------------------------------------------------------
|
---|
| 4818 | data.Style='rectangle';
|
---|
| 4819 | data.ProjMode='inside';%default
|
---|
| 4820 | create_object(data,handles)
|
---|
| 4821 |
|
---|
| 4822 | %------------------------------------------------------------------------
|
---|
| 4823 | function Menuellipse_Callback(hObject, eventdata, handles)
|
---|
| 4824 | %------------------------------------------------------------------------
|
---|
| 4825 | data.Style='ellipse';
|
---|
| 4826 | data.ProjMode='inside';%default
|
---|
| 4827 | create_object(data,handles)
|
---|
| 4828 |
|
---|
| 4829 | %------------------------------------------------------------------------
|
---|
| 4830 | function MenuMaskObject_Callback(hObject, eventdata, handles)
|
---|
| 4831 | %------------------------------------------------------------------------
|
---|
| 4832 | data.Style='polygon';
|
---|
| 4833 | data.StyleMenu={'polygon'};
|
---|
| 4834 | data.ProjMode='mask_inside';%default
|
---|
| 4835 | data.ProjMenu={'mask_inside';'mask_outside'};
|
---|
| 4836 | create_object(data,handles)
|
---|
| 4837 |
|
---|
| 4838 | %------------------------------------------------------------------------
|
---|
| 4839 | function Menuplane_Callback(hObject, eventdata, handles)
|
---|
| 4840 | %------------------------------------------------------------------------
|
---|
| 4841 | data.Style='plane';
|
---|
| 4842 | data.ProjMode='projection';%default
|
---|
| 4843 |
|
---|
| 4844 | create_object(data,handles)
|
---|
| 4845 |
|
---|
| 4846 | %------------------------------------------------------------------------
|
---|
| 4847 | function Menuvolume_Callback(hObject, eventdata, handles)
|
---|
| 4848 | %------------------------------------------------------------------------
|
---|
| 4849 | data.Style='volume';
|
---|
| 4850 | data.ProjMode='interp';%default
|
---|
| 4851 | % set(handles.create,'Visible','on')
|
---|
| 4852 | % set(handles.create,'Value',1)
|
---|
| 4853 | % VOLUME_Callback(hObject,eventdata,handles)
|
---|
| 4854 | create_object(data,handles)
|
---|
| 4855 |
|
---|
| 4856 | %------------------------------------------------------------------------
|
---|
| 4857 | function MenuBrowseObject_Callback(hObject, eventdata, handles)
|
---|
| 4858 | %------------------------------------------------------------------------
|
---|
| 4859 | %get the object file
|
---|
| 4860 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 4861 | {'*.xml;*.mat', ' (*.xml,*.mat)';
|
---|
| 4862 | '*.xml', '.xml files '; ...
|
---|
| 4863 | '*.mat', '.mat matlab files '}, ...
|
---|
| 4864 | 'Pick an xml Object file',get(handles.RootPath,'String'));
|
---|
| 4865 | fileinput=[PathName FileName];%complete file name
|
---|
| 4866 | % testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 4867 | % if ~isempty(testblank)
|
---|
| 4868 | % msgbox_uvmat('ERROR','forbidden input file name: contain blanks')
|
---|
| 4869 | % return
|
---|
| 4870 | % end
|
---|
| 4871 | sizf=size(fileinput);
|
---|
| 4872 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 4873 |
|
---|
| 4874 | %read the file
|
---|
| 4875 | t=xmltree(fileinput);
|
---|
| 4876 | data=convert(t);
|
---|
| 4877 | data.enable_plot=1;
|
---|
| 4878 | [pp,data.Name]=fileparts(FileName);
|
---|
| 4879 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4880 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
| 4881 | if ~isempty(hset_object)
|
---|
| 4882 | delete(hset_object)% delete existing version of set_object
|
---|
| 4883 | end
|
---|
| 4884 | % UvData=get(handles.uvmat,'UserData');
|
---|
| 4885 | set_object(data);% call the set_object interface
|
---|
| 4886 | % %position the set_object GUI with respect to uvmat
|
---|
| 4887 | % pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4888 | % if isfield(UvData,'SetObjectOrigin')
|
---|
| 4889 | % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 4890 | % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 4891 | % set(hset_object,'Position',pos_set_object)
|
---|
| 4892 | % end
|
---|
| 4893 | set(handles.edit_object,'Value',0); %suppress the object edit mode
|
---|
| 4894 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4895 | set(handles.MenuObject,'checked','on')
|
---|
| 4896 | %UvData.MouseAction='create_object';
|
---|
| 4897 | % set(handles.uvmat,'UserData',UvData)
|
---|
| 4898 | set(handles.delete_object,'Visible','on')
|
---|
| 4899 | set(handles.uvmat_title,'Visible','on')
|
---|
| 4900 | set(handles.view_field_title,'Visible','on')
|
---|
| 4901 |
|
---|
| 4902 | %------------------------------------------------------------------------
|
---|
| 4903 | % --- generic function used for the creation of a projection object
|
---|
| 4904 | function create_object(data,handles)
|
---|
| 4905 | %------------------------------------------------------------------------
|
---|
| 4906 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
| 4907 | if ~isempty(hset_object)
|
---|
| 4908 | delete(hset_object)% delete existing version of set_object
|
---|
| 4909 | end
|
---|
| 4910 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
|
---|
| 4911 | if ishandle(hgeometry_calib)
|
---|
| 4912 | hhgeometry_calib=guidata(hgeometry_calib);
|
---|
| 4913 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
|
---|
| 4914 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4915 | end
|
---|
| 4916 | UvData=get(handles.uvmat,'UserData');
|
---|
| 4917 | set(handles.edit_object,'Value',0); %suppress the object edit mode
|
---|
| 4918 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4919 | data.enable_plot=1;
|
---|
| 4920 | transform_list=get(handles.transform_fct,'String');
|
---|
| 4921 | val=get(handles.transform_fct,'Value');
|
---|
| 4922 | %data.CoordType=transform_list{val};
|
---|
| 4923 | if isfield(UvData,'Field')
|
---|
| 4924 | Field=UvData.Field;
|
---|
| 4925 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
|
---|
| 4926 | data.RangeX=Field.Mesh;
|
---|
| 4927 | data.RangeY=Field.Mesh;
|
---|
| 4928 | data.DX=Field.Mesh;
|
---|
| 4929 | data.DY=Field.Mesh;
|
---|
| 4930 | elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image
|
---|
| 4931 | np=size(Field.A);
|
---|
| 4932 | meshx=(Field.AX(end)-Field.AX(1))/np(2);
|
---|
| 4933 | meshy=abs(Field.AY(end)-Field.AY(1))/np(1);
|
---|
| 4934 | data.RangeY=max(meshx,meshy);
|
---|
| 4935 | data.RangeX=max(meshx,meshy);
|
---|
| 4936 | data.DX=max(meshx,meshy);
|
---|
| 4937 | end
|
---|
| 4938 | if isfield(Field,'NbDim')
|
---|
| 4939 | data.NbDim=Field.NbDim;
|
---|
| 4940 | end
|
---|
| 4941 | if isfield(Field,'CoordUnit')
|
---|
| 4942 | data.CoordUnit=Field.CoordUnit;
|
---|
| 4943 | end
|
---|
| 4944 | end
|
---|
| 4945 | data.Coord=[0 0 0]; %default
|
---|
| 4946 | if isfield(data,'Style') && isequal(data.Style,'line')
|
---|
| 4947 | if isfield(data,'DX')
|
---|
| 4948 | data.Coord=[[0 0 0];[data.DX 0 0]]; %default
|
---|
| 4949 | else
|
---|
| 4950 | data.Coord=[[0 0 0];[1 0 0]]; %default
|
---|
| 4951 | end
|
---|
| 4952 | end
|
---|
| 4953 | if ishandle(handles.UVMAT_title)
|
---|
| 4954 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
|
---|
| 4955 | end
|
---|
| 4956 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4957 | set_object(data,handles);% call the set_object interface
|
---|
| 4958 | set(handles.MenuObject,'checked','on')
|
---|
| 4959 | set(handles.uvmat,'UserData',UvData)
|
---|
| 4960 | set(handles.zoom,'Value',0)
|
---|
| 4961 | zoom_Callback(handles.uvmat, [], handles)
|
---|
| 4962 | set(handles.delete_object,'Visible','on')
|
---|
| 4963 | set(handles.uvmat_title,'Visible','on')
|
---|
| 4964 | set(handles.view_field_title,'Visible','on')
|
---|
| 4965 |
|
---|
| 4966 | %------------------------------------------------------------------------
|
---|
| 4967 | function MenuRuler_Callback(hObject, eventdata, handles)
|
---|
| 4968 | %------------------------------------------------------------------------
|
---|
| 4969 | set(handles.zoom,'Value',0)
|
---|
| 4970 | zoom_Callback(handles.uvmat, [], handles)
|
---|
| 4971 | set(handles.MenuRuler,'checked','on')
|
---|
| 4972 | UvData=get(handles.uvmat,'UserData');
|
---|
| 4973 | UvData.MouseAction='ruler';
|
---|
| 4974 | set(handles.uvmat,'UserData',UvData);
|
---|
| 4975 |
|
---|
| 4976 | %------------------------------------------------------------------------
|
---|
| 4977 | % --- executed when closing: set the parent interface button to value 0
|
---|
| 4978 | function closefcn(gcbo,eventdata)
|
---|
| 4979 | %------------------------------------------------------------------------
|
---|
| 4980 | %delete all the associated figures if exist
|
---|
| 4981 | hh=findobj(allchild(0),'tag','view_field');
|
---|
| 4982 | if ~isempty(hh)
|
---|
| 4983 | delete(hh)
|
---|
| 4984 | end
|
---|
| 4985 | hh=findobj(allchild(0),'tag','geometry_calib');
|
---|
| 4986 | if ~isempty(hh)
|
---|
| 4987 | delete(hh)
|
---|
| 4988 | end
|
---|
| 4989 | hh=findobj(allchild(0),'tag','set_object');
|
---|
| 4990 | if ~isempty(hh)
|
---|
| 4991 | hhh=findobj(hh,'tag','PLOT');
|
---|
| 4992 | set(hhh,'enable','off')
|
---|
| 4993 | end
|
---|
| 4994 |
|
---|
| 4995 | %------------------------------------------------------------------------
|
---|
| 4996 | % --- Executes on button press in delete_object.
|
---|
| 4997 | function delete_object_Callback(hObject, eventdata, handles)
|
---|
| 4998 | %------------------------------------------------------------------------
|
---|
| 4999 | IndexObj=get(handles.list_object_2,'Value');
|
---|
| 5000 | if IndexObj>1
|
---|
| 5001 | delete_object(IndexObj)
|
---|
| 5002 | end
|
---|
| 5003 |
|
---|
| 5004 |
|
---|