| 1 | %'series': master function associated to the GUI series.m for analysis field series
|
---|
| 2 | %------------------------------------------------------------------------
|
---|
| 3 | % function varargout = series(varargin)
|
---|
| 4 | % associated with the GUI series.fig
|
---|
| 5 | %
|
---|
| 6 | %INPUT
|
---|
| 7 | % param: structure with input parameters (link with the GUI uvmat)
|
---|
| 8 | % .menu_coord_str: string for the TransformName (menu for coordinate transforms)
|
---|
| 9 | % .menu_coord_val: value for TransformName (menu for coordinate transforms)
|
---|
| 10 | % .FileName: input file name
|
---|
| 11 | % .FileName_1: second input file name
|
---|
| 12 | % .list_field: menu of input fields
|
---|
| 13 | % .index_fields: chosen index
|
---|
| 14 | % .civ1=0 or 1, .interp1, ... : input civ field type
|
---|
| 15 | %
|
---|
| 16 |
|
---|
| 17 | %=======================================================================
|
---|
| 18 | % Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
|
---|
| 19 | % http://www.legi.grenoble-inp.fr
|
---|
| 20 | % Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr
|
---|
| 21 | %
|
---|
| 22 | % This file is part of the toolbox UVMAT.
|
---|
| 23 | %
|
---|
| 24 | % UVMAT is free software; you can redistribute it and/or modify
|
---|
| 25 | % it under the terms of the GNU General Public License as published
|
---|
| 26 | % by the Free Software Foundation; either version 2 of the license,
|
---|
| 27 | % or (at your option) any later version.
|
---|
| 28 | %
|
---|
| 29 | % UVMAT is distributed in the hope that it will be useful,
|
---|
| 30 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 31 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 32 | % GNU General Public License (see LICENSE.txt) for more details.
|
---|
| 33 | %=======================================================================
|
---|
| 34 |
|
---|
| 35 | %------------------------------------------------------------------------
|
---|
| 36 | %------------------------------------------------------------------------
|
---|
| 37 | % I - MAIN FUNCTION series
|
---|
| 38 | %------------------------------------------------------------------------
|
---|
| 39 | %------------------------------------------------------------------------
|
---|
| 40 | function varargout = series(varargin)
|
---|
| 41 |
|
---|
| 42 | % Begin initialization code - DO NOT EDIT
|
---|
| 43 | gui_Singleton = 1;
|
---|
| 44 | gui_State = struct('gui_Name', mfilename, ...
|
---|
| 45 | 'gui_Singleton', gui_Singleton, ...
|
---|
| 46 | 'gui_OpeningFcn', @series_OpeningFcn, ...
|
---|
| 47 | 'gui_OutputFcn', @series_OutputFcn, ...
|
---|
| 48 | 'gui_LayoutFcn', [] , ...
|
---|
| 49 | 'gui_Callback', []);
|
---|
| 50 | if nargin && ischar(varargin{1})
|
---|
| 51 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
| 52 | end
|
---|
| 53 |
|
---|
| 54 | if nargout
|
---|
| 55 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
---|
| 56 | else
|
---|
| 57 | gui_mainfcn(gui_State, varargin{:});
|
---|
| 58 | end
|
---|
| 59 | % End initialization code - DO NOT EDIT
|
---|
| 60 |
|
---|
| 61 | %--------------------------------------------------------------------------
|
---|
| 62 | % --- Executes just before series is made visible.
|
---|
| 63 | %--------------------------------------------------------------------------
|
---|
| 64 | function series_OpeningFcn(hObject, eventdata, handles,Param)
|
---|
| 65 |
|
---|
| 66 | % Choose default command line output for series
|
---|
| 67 | handles.output = hObject;
|
---|
| 68 | % Update handles structure
|
---|
| 69 | guidata(hObject, handles);
|
---|
| 70 |
|
---|
| 71 | %% initial settings
|
---|
| 72 | % position and size of the GUI at opening
|
---|
| 73 | set(0,'Unit','points')
|
---|
| 74 | ScreenSize=get(0,'ScreenSize'); % size of the current screen, in points (1/72 inch)
|
---|
| 75 | Width=900; % prefered width of the GUI in points (1/72 inch)
|
---|
| 76 | Height=624; % prefered height of the GUI in points (1/72 inch)
|
---|
| 77 | %adjust to screen size (reduced by a min margin)
|
---|
| 78 | RescaleFactor=min((ScreenSize(3)-80)/Width,(ScreenSize(4)-80)/Height);
|
---|
| 79 | if RescaleFactor>1
|
---|
| 80 | RescaleFactor=min(RescaleFactor,1);
|
---|
| 81 | end
|
---|
| 82 | Width=Width*RescaleFactor;
|
---|
| 83 | Height=Height*RescaleFactor;
|
---|
| 84 | LeftX=80*RescaleFactor; % position of the left fig side, in pixels (put to the left side, with some margin)
|
---|
| 85 | LowY=round(ScreenSize(4)/2-Height/2); % put at the middle height on the screen
|
---|
| 86 | set(hObject,'Units','points')
|
---|
| 87 | set(hObject,'Position',[LeftX LowY Width Height])% position and size of the GUI at opening
|
---|
| 88 |
|
---|
| 89 | % settings of table MinIndex_j
|
---|
| 90 | set(handles.MinIndex_i,'ColumnFormat',{'numeric'})
|
---|
| 91 | set(handles.MinIndex_i,'ColumnEditable',false)
|
---|
| 92 | set(handles.MinIndex_i,'ColumnName',{'i min'})
|
---|
| 93 | set(handles.MinIndex_i,'Data',[])% initiate Data to double (not cell)
|
---|
| 94 |
|
---|
| 95 | % settings of table MinIndex_j
|
---|
| 96 | set(handles.MinIndex_j,'ColumnFormat',{'numeric'})
|
---|
| 97 | set(handles.MinIndex_j,'ColumnEditable',false)
|
---|
| 98 | set(handles.MinIndex_j,'ColumnName',{'j min'})
|
---|
| 99 | set(handles.MinIndex_j,'Data',[])% initiate Data to double (not cell)
|
---|
| 100 |
|
---|
| 101 | % settings of table MaxIndex_i
|
---|
| 102 | set(handles.MaxIndex_i,'ColumnFormat',{'numeric'})
|
---|
| 103 | set(handles.MaxIndex_i,'ColumnEditable',false)
|
---|
| 104 | set(handles.MaxIndex_i,'ColumnName',{'i max'})
|
---|
| 105 | set(handles.MaxIndex_i,'Data',[])% initiate Data to double (not cell)
|
---|
| 106 |
|
---|
| 107 | % settings of table MaxIndex_j
|
---|
| 108 | set(handles.MaxIndex_j,'ColumnFormat',{'numeric'})
|
---|
| 109 | set(handles.MaxIndex_j,'ColumnEditable',false)
|
---|
| 110 | set(handles.MaxIndex_j,'ColumnName',{'j max'})
|
---|
| 111 | set(handles.MaxIndex_j,'Data',[])% initiate Data to double (not cell)
|
---|
| 112 |
|
---|
| 113 | % settings of table PairString
|
---|
| 114 | set(handles.PairString,'ColumnName',{'pairs'})
|
---|
| 115 | set(handles.PairString,'ColumnEditable',false)
|
---|
| 116 | set(handles.PairString,'ColumnFormat',{'char'})
|
---|
| 117 | set(handles.PairString,'Data',{''})
|
---|
| 118 |
|
---|
| 119 | % settings of table MaskTable
|
---|
| 120 | %set(handles.MaskTable,'ColumnName',{'mask name'})
|
---|
| 121 | set(handles.PairString,'ColumnEditable',false)
|
---|
| 122 | set(handles.PairString,'ColumnFormat',{'char'})
|
---|
| 123 | set(handles.PairString,'Data',{''})
|
---|
| 124 |
|
---|
| 125 | series_ResizeFcn(hObject, eventdata, handles)%resize table according to series GUI size
|
---|
| 126 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display)
|
---|
| 127 | set(hObject,'DeleteFcn',{@closefcn})%
|
---|
| 128 |
|
---|
| 129 | % check default input data
|
---|
| 130 | if ~exist('Param','var')
|
---|
| 131 | Param=[]; % default
|
---|
| 132 | end
|
---|
| 133 |
|
---|
| 134 | %% Read the parameter file series.xml, or created from series.xml.default if it does not exist
|
---|
| 135 | SeriesData=[];
|
---|
| 136 | [path_series,name,ext]=fileparts(which('series'));% path to the GUI series
|
---|
| 137 | xmlfile=fullfile(path_series,'series.xml');
|
---|
| 138 | if ~exist(xmlfile,'file')
|
---|
| 139 | [success,message]=copyfile(fullfile(path_series,'series.xml.default'),xmlfile);
|
---|
| 140 | end
|
---|
| 141 | if exist(xmlfile,'file')
|
---|
| 142 | SeriesData.SeriesParam=xml2struct(xmlfile);
|
---|
| 143 | if ~(isfield(SeriesData.SeriesParam,'ClusterParam')&& isfield(SeriesData.SeriesParam.ClusterParam,'LaunchCmdFcn'))
|
---|
| 144 | [success,message]=copyfile(xmlfile,fullfile(path_series,'series_old.xml'));% update the file series.xml inot correctly documented
|
---|
| 145 | delete(xmlfile);
|
---|
| 146 | [success,message]=copyfile(fullfile(path_series,'series.xml.default'),xmlfile);
|
---|
| 147 | end
|
---|
| 148 | SeriesData.SeriesParam=xml2struct(xmlfile);
|
---|
| 149 | end
|
---|
| 150 |
|
---|
| 151 | %% list of builtin functions in the menu ActionName
|
---|
| 152 | ActionList={'check_data_files';'aver_stat';'time_series';'civ_series';'merge_proj'}; % WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback
|
---|
| 153 | NbBuiltinAction=numel(ActionList);
|
---|
| 154 | set(handles.Action,'UserData',NbBuiltinAction)
|
---|
| 155 | path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series'
|
---|
| 156 | [path_series,name,ext]=fileparts(which('series')); % path to the GUI series
|
---|
| 157 | path_series_fct=fullfile(path_series,'series'); % path of the functions in subdirectroy 'series'
|
---|
| 158 | command = ['LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | pyp "l = x.split('':''); l = [s for s in l if ''matlab'' not in s]; print('':''.join(l))") ' ...
|
---|
| 159 | 'python -c "import fluidimage"'];
|
---|
| 160 | [code, ~] = system(command);
|
---|
| 161 | if code==0
|
---|
| 162 | ActionExtList={'.m';'.sh';'.py (in dev.)'}; % default choice of extensions (Matlab fct .m or compiled version .sh
|
---|
| 163 | else
|
---|
| 164 | ActionExtList={'.m';'.sh'}; % python options not installed
|
---|
| 165 | end
|
---|
| 166 | ActionPathList=cell(NbBuiltinAction,1); % initiate the cell matrix of Action fct paths
|
---|
| 167 | ActionPathList(:)={path_series_fct}; % set the default path to series fcts to all list members
|
---|
| 168 | RunModeList={'local';'background'}; % default choice of extensions (Matlab fct .m or compiled version .sh)
|
---|
| 169 | [s,w]=system(SeriesData.SeriesParam.ClusterParam.ExistenceTest); % look for cluster system presence
|
---|
| 170 | if isequal(s,0)
|
---|
| 171 | RunModeList=[RunModeList;{'cluster'}];
|
---|
| 172 | set(handles.MonitorCluster,'Visible','on'); % make visible button for access to Monika
|
---|
| 173 | set(handles.num_CPUTime,'Visible','on'); % make visible button for CPU time estimate for one ref index
|
---|
| 174 | set(handles.num_CPUTime,'String','')% default CPU time undefined
|
---|
| 175 | set(handles.CPUTime_txt,'Visible','on'); % make visible button for CPU time title
|
---|
| 176 | end
|
---|
| 177 | set(handles.RunMode,'String',RunModeList)% display the menu of available run modes, local, background or cluster manager
|
---|
| 178 |
|
---|
| 179 | %% list of builtin transform functions in the menu TransformName
|
---|
| 180 | TransformList={'';'sub_field';'phys';'phys_polar'}; % WARNING: must fit with the corresponding menu in uvmat and nb_builtin_transform=4 in TransformName_callback
|
---|
| 181 | NbBuiltinTransform=numel(TransformList);
|
---|
| 182 | path_transform_fct=fullfile(path_series,'transform_field');
|
---|
| 183 | TransformPathList=cell(NbBuiltinTransform,1); % initiate the cell matrix of Action fct paths
|
---|
| 184 | TransformPathList(:)={path_transform_fct}; % set the default path to series fcts to all list members
|
---|
| 185 | SeriesData.TransformPath=path_transform_fct;% store the standard path for trqnsform functions (needed for compilation)
|
---|
| 186 |
|
---|
| 187 | %% get the user defined functions stored in the personal file uvmat_perso.mat
|
---|
| 188 | dir_perso=prefdir;
|
---|
| 189 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 190 | if exist(profil_perso,'file')
|
---|
| 191 | h=load (profil_perso);
|
---|
| 192 | %get the list of previous input files in the upper bar menu Open
|
---|
| 193 | if isfield(h,'MenuFile')
|
---|
| 194 | for ifile=1:min(length(h.MenuFile),5)
|
---|
| 195 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',h.MenuFile{ifile});
|
---|
| 196 | set(handles.(['MenuFile_' num2str(ifile+5)]),'Label',h.MenuFile{ifile});
|
---|
| 197 | end
|
---|
| 198 | end
|
---|
| 199 | %get the menu of actions
|
---|
| 200 | if isfield(h,'ActionListUser') && iscell(h.ActionListUser) && isfield(h,'ActionPathListUser') && iscell(h.ActionPathListUser)
|
---|
| 201 | ActionList=[ActionList;h.ActionListUser];
|
---|
| 202 | ActionPathList=[ActionPathList;h.ActionPathListUser(:,1)];
|
---|
| 203 | end
|
---|
| 204 | %get the menu of transform fct
|
---|
| 205 | if isfield(h,'TransformListUser') && iscell(h.TransformListUser) && isfield(h,'TransformPathListUser') && iscell(h.TransformPathListUser)
|
---|
| 206 | TransformList=[TransformList;h.TransformListUser];
|
---|
| 207 | TransformPathList=[TransformPathList;h.TransformPathListUser];
|
---|
| 208 | end
|
---|
| 209 | end
|
---|
| 210 |
|
---|
| 211 | %% selection of the input Action fct
|
---|
| 212 | ActionCheckExist=true(size(ActionList)); % initiate the check of the path to the listed action fct
|
---|
| 213 | for ilist=NbBuiltinAction+1:numel(ActionList)%check the validity of the path of the user defined Action fct
|
---|
| 214 | ActionCheckExist(ilist)=exist(fullfile(ActionPathList{ilist},[ActionList{ilist} '.m']),'file');
|
---|
| 215 | end
|
---|
| 216 | ActionPathList=ActionPathList(ActionCheckExist,:); % suppress the menu options which are not valid anymore
|
---|
| 217 | ActionList=ActionList(ActionCheckExist);
|
---|
| 218 | set(handles.ActionName,'String',[ActionList;{'more...'}])
|
---|
| 219 | set(handles.ActionName,'UserData',ActionPathList)
|
---|
| 220 | ActionIndex=[];
|
---|
| 221 | if isfield(Param,'ActionName')% copy the selected menu index transferred in Param from uvmat
|
---|
| 222 | ActionIndex=find(strcmp(Param.ActionName,ActionList),1);
|
---|
| 223 | end
|
---|
| 224 | if isempty(ActionIndex)
|
---|
| 225 | ActionIndex=1;
|
---|
| 226 | end
|
---|
| 227 | set(handles.ActionName,'Value',ActionIndex)
|
---|
| 228 | set(handles.ActionPath,'String',ActionPathList{ActionIndex})
|
---|
| 229 | set(handles.ActionExt,'Value',1)
|
---|
| 230 | set(handles.ActionExt,'String',ActionExtList)
|
---|
| 231 |
|
---|
| 232 | %% selection of the input transform fct
|
---|
| 233 | TransformCheckExist=true(size(TransformList));
|
---|
| 234 | for ilist=NbBuiltinTransform+1:numel(TransformList)
|
---|
| 235 | TransformCheckExist(ilist)=exist(fullfile(TransformPathList{ilist},[TransformList{ilist} '.m']),'file');
|
---|
| 236 | end
|
---|
| 237 | TransformPathList=TransformPathList(TransformCheckExist);
|
---|
| 238 | TransformList=TransformList(TransformCheckExist);
|
---|
| 239 | set(handles.TransformName,'String',[TransformList;{'more...'}])
|
---|
| 240 | set(handles.TransformName,'UserData',TransformPathList)
|
---|
| 241 | TransformIndex=[];
|
---|
| 242 | if isfield(Param,'TransformName')% copy the selected menu index transferred in Param from uvmat
|
---|
| 243 | TransformIndex=find(strcmp(Param.TransformName,TransformList),1);
|
---|
| 244 | end
|
---|
| 245 | if isempty(TransformIndex)
|
---|
| 246 | TransformIndex=1;
|
---|
| 247 | end
|
---|
| 248 | set(handles.TransformName,'Value',TransformIndex)
|
---|
| 249 | set(handles.TransformPath,'String',TransformPathList{TransformIndex})
|
---|
| 250 |
|
---|
| 251 | %% fields input initialisation
|
---|
| 252 | if isfield(Param,'list_fields')&& isfield(Param,'index_fields') &&~isempty(Param.list_fields) &&~isempty(Param.index_fields)
|
---|
| 253 | set(handles.FieldName,'String',Param.list_fields); % list menu fields
|
---|
| 254 | set(handles.FieldName,'Value',Param.index_fields); % selected string index
|
---|
| 255 | end
|
---|
| 256 | if isfield(Param,'Coordinates')
|
---|
| 257 | if isfield(Param.Coordinates,'Coord_x')
|
---|
| 258 | set(handles.Coord_x,'String',Param.Coordinates.Coord_x)
|
---|
| 259 | end
|
---|
| 260 | if isfield(Param.Coordinates,'Coord_y')
|
---|
| 261 | set(handles.Coord_y,'String',Param.Coordinates.Coord_y)
|
---|
| 262 | end
|
---|
| 263 | if isfield(Param.Coordinates,'Coord_z')
|
---|
| 264 | set(handles.Coord_z,'String',Param.Coordinates.Coord_z)
|
---|
| 265 | end
|
---|
| 266 | end
|
---|
| 267 |
|
---|
| 268 | %% introduce the input file name(s) if defined from input Param,
|
---|
| 269 | set(handles.series,'UserData',SeriesData)% initiate Userdata
|
---|
| 270 | if isfield(Param,'InputFile')
|
---|
| 271 |
|
---|
| 272 | %% fill the list of input file series
|
---|
| 273 | InputTable=[{Param.InputFile.RootPath},{Param.InputFile.SubDir},{Param.InputFile.RootFile},{Param.InputFile.NomType},{Param.InputFile.FileExt}];
|
---|
| 274 | if isempty(find(cellfun('isempty',InputTable)==0)) % if there is no input file, do not introduce input info
|
---|
| 275 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed
|
---|
| 276 | return
|
---|
| 277 | end
|
---|
| 278 | TimeTable=[{Param.InputFile.TimeName},{[]},{[]},{[]},{[]}];
|
---|
| 279 | if isfield(Param.InputFile,'RootPath_1')
|
---|
| 280 | InputTable=[InputTable;[{Param.InputFile.RootPath_1},{Param.InputFile.SubDir_1},{Param.InputFile.RootFile_1},{Param.InputFile.NomType_1},{Param.InputFile.FileExt_1}]];
|
---|
| 281 | TimeTable=[TimeTable; [{Param.InputFile.TimeName_1},{[]},{[]},{[]},{[]}]];
|
---|
| 282 | end
|
---|
| 283 | set(handles.InputTable,'Data',InputTable)
|
---|
| 284 |
|
---|
| 285 | %% define the default path for the output files
|
---|
| 286 | [InputPath,Device,DeviceExt]=fileparts(InputTable{1,1});
|
---|
| 287 | [InputPath,Experiment,ExperimentExt]=fileparts(InputPath);
|
---|
| 288 | set(handles.Device,'String',[Device DeviceExt])
|
---|
| 289 | set(handles.Experiment,'String',[Experiment ExperimentExt])
|
---|
| 290 | if ~isempty(regexp(InputTable{1,1},'(^http://)|(^https://)'))
|
---|
| 291 | set(handles.OutputPathBrowse,'Value',1)% an output folder needs to be specified for OpenDAP data
|
---|
| 292 | end
|
---|
| 293 |
|
---|
| 294 | %update the output path if needed
|
---|
| 295 | if ~(isfield(SeriesData,'InputPath') && strcmp(SeriesData.InputPath,InputPath))
|
---|
| 296 | if get(handles.OutputPathBrowse,'Value')==1 % fix the output path in manual mode
|
---|
| 297 | OutputPathOld=get(handles.OutputPath,'String');
|
---|
| 298 | OutputPath=uigetdir(OutputPathOld,'pick a root folder for output data');
|
---|
| 299 | set(handles.OutputPath,'String',OutputPath)
|
---|
| 300 | else %reproduce the input path for output
|
---|
| 301 | set(handles.OutputPath,'String',InputPath)
|
---|
| 302 | end
|
---|
| 303 | end
|
---|
| 304 |
|
---|
| 305 | %% determine the selected reference field indices for pair display
|
---|
| 306 |
|
---|
| 307 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(Param.InputFile.FileIndex);
|
---|
| 308 | if isempty(i1)
|
---|
| 309 | i1=1;
|
---|
| 310 | end
|
---|
| 311 | if isempty(i2)
|
---|
| 312 | i2=i1;
|
---|
| 313 | end
|
---|
| 314 | ref_i=floor((i1+i2)/2); % reference image number corresponding to the file
|
---|
| 315 | % set(handles.num_ref_i,'String',num2str(ref_i));
|
---|
| 316 | if isempty(j1)
|
---|
| 317 | j1=1;
|
---|
| 318 | end
|
---|
| 319 | if isempty(j2)
|
---|
| 320 | j2=j1;
|
---|
| 321 | end
|
---|
| 322 | ref_j=floor((j1+j2)/2); % reference image number corresponding to the file
|
---|
| 323 | SeriesData.ref_i=ref_i;
|
---|
| 324 | SeriesData.ref_j=ref_j;
|
---|
| 325 | set(handles.series,'UserData',SeriesData)
|
---|
| 326 | update_rootinfo(handles,Param.HiddenData.i1_series{1},Param.HiddenData.i2_series{1},Param.HiddenData.j1_series{1},Param.HiddenData.j2_series{1},...
|
---|
| 327 | Param.HiddenData.FileInfo{1},Param.HiddenData.MovieObject{1},1)
|
---|
| 328 | if isfield(Param,'FileName_1')
|
---|
| 329 | % display_file_name(handles,Param,2)
|
---|
| 330 | update_rootinfo(handles,Param.HiddenData.i1_series{2},Param.HiddenData.i2_series{2},Param.HiddenData.j1_series{2},Param.HiddenData.j2_series{2},...
|
---|
| 331 | Param.HiddenData.FileInfo{2},Param.HiddenData.MovieObject{2},2)
|
---|
| 332 | end
|
---|
| 333 | %% enable field and veltype menus, in accordance with the current action
|
---|
| 334 | ActionName_Callback([],[], handles)
|
---|
| 335 |
|
---|
| 336 | %% set length of waitbar
|
---|
| 337 | displ_time(handles)
|
---|
| 338 |
|
---|
| 339 | else
|
---|
| 340 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed
|
---|
| 341 | end
|
---|
| 342 | if isfield(Param,'incr_i')
|
---|
| 343 | set(handles.num_incr_i,'String',num2str(Param.incr_i))
|
---|
| 344 | else
|
---|
| 345 | set(handles.num_incr_i,'String','1')
|
---|
| 346 | end
|
---|
| 347 | if isfield(Param,'incr_j')
|
---|
| 348 | set(handles.num_incr_j,'String',num2str(Param.incr_j))
|
---|
| 349 | else
|
---|
| 350 | set(handles.num_incr_j,'String','1')
|
---|
| 351 | end
|
---|
| 352 |
|
---|
| 353 | %------------------------------------------------------------------------
|
---|
| 354 | % --- Outputs from this function are returned to the command line.
|
---|
| 355 | function varargout = series_OutputFcn(hObject, eventdata, handles)
|
---|
| 356 | %------------------------------------------------------------------------
|
---|
| 357 | varargout{1} = handles.output;
|
---|
| 358 |
|
---|
| 359 | %------------------------------------------------------------------------
|
---|
| 360 | % --- executed when closing uvmat: delete or desactivate the associated figures if exist
|
---|
| 361 | function closefcn(gcbo,eventdata)
|
---|
| 362 | %------------------------------------------------------------------------
|
---|
| 363 |
|
---|
| 364 | % delete set_object_series if detected
|
---|
| 365 | hh=findobj(allchild(0),'name','view_object_series');
|
---|
| 366 | if ~isempty(hh)
|
---|
| 367 | delete(hh)
|
---|
| 368 | end
|
---|
| 369 | hh=findobj(allchild(0),'name','edit_object_series');
|
---|
| 370 | if ~isempty(hh)
|
---|
| 371 | delete(hh)
|
---|
| 372 | end
|
---|
| 373 |
|
---|
| 374 | %delete the bowser if detected
|
---|
| 375 | hh=findobj(allchild(0),'tag','browser');
|
---|
| 376 | if ~isempty(hh)
|
---|
| 377 | delete(hh)
|
---|
| 378 | end
|
---|
| 379 |
|
---|
| 380 |
|
---|
| 381 | %------------------------------------------------------------------------
|
---|
| 382 | %------------------------------------------------------------------------
|
---|
| 383 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
| 384 | % automatically sets the global properties when the rootfile name is introduced
|
---|
| 385 | % then activate the view-field actionname if selected
|
---|
| 386 | % it is activated either by clicking on the RootPath window or by the
|
---|
| 387 | % browser
|
---|
| 388 | %------------------------------------------------------------------------
|
---|
| 389 | %------------------------------------------------------------------------
|
---|
| 390 | % --- fct activated by the browser under 'Open'
|
---|
| 391 | %------------------------------------------------------------------------
|
---|
| 392 | function MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 393 | %% look for the previously opened file 'oldfile'
|
---|
| 394 | InputTable=get(handles.InputTable,'Data');
|
---|
| 395 | oldfile=InputTable{1,1};
|
---|
| 396 | if isempty(oldfile)
|
---|
| 397 | % use a file name stored in prefdir
|
---|
| 398 | dir_perso=prefdir;
|
---|
| 399 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 400 | if exist(profil_perso,'file')
|
---|
| 401 | h=load (profil_perso);
|
---|
| 402 | if isfield(h,'RootPath') && ischar(h.RootPath)
|
---|
| 403 | oldfile=h.RootPath;
|
---|
| 404 | end
|
---|
| 405 | end
|
---|
| 406 | end
|
---|
| 407 | %% launch the browser
|
---|
| 408 | fileinput=uigetfile_uvmat('pick an input file in the series',oldfile);
|
---|
| 409 | hh=dir(fileinput);
|
---|
| 410 | if numel(hh)>1
|
---|
| 411 | msgbox_uvmat('ERROR','invalid input, probably a broken link');
|
---|
| 412 | else
|
---|
| 413 | if ~isempty(fileinput)
|
---|
| 414 | display_file_name(handles,fileinput,'one')
|
---|
| 415 | end
|
---|
| 416 | end
|
---|
| 417 |
|
---|
| 418 | % --------------------------------------------------------------------
|
---|
| 419 | function MenuBrowseAppend_Callback(hObject, eventdata, handles)
|
---|
| 420 |
|
---|
| 421 | %% look for the previously opened file 'oldfile'
|
---|
| 422 | InputTable=get(handles.InputTable,'Data');
|
---|
| 423 | RootPathCell=InputTable(:,1);
|
---|
| 424 | if isempty(RootPathCell{1})% no input file in the table
|
---|
| 425 | MenuBrowse_Callback(hObject, eventdata, handles)%refresh the input table, not append
|
---|
| 426 | return
|
---|
| 427 | end
|
---|
| 428 | SubDirCell=InputTable(:,2);
|
---|
| 429 | oldfile=fullfile(RootPathCell{1},SubDirCell{1});
|
---|
| 430 |
|
---|
| 431 | %% use a file name stored in prefdir
|
---|
| 432 | dir_perso=prefdir;
|
---|
| 433 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 434 | if exist(profil_perso,'file')
|
---|
| 435 | h=load (profil_perso);
|
---|
| 436 | if isfield(h,'RootPath') && ischar(h.RootPath)
|
---|
| 437 | oldfile=h.RootPath;
|
---|
| 438 | end
|
---|
| 439 | end
|
---|
| 440 |
|
---|
| 441 | %% launch the browser
|
---|
| 442 | fileinput=uigetfile_uvmat('pick a file to append in the input table',oldfile);
|
---|
| 443 | hh=dir(fileinput);
|
---|
| 444 | if numel(hh)>1
|
---|
| 445 | msgbox_uvmat('ERROR','invalid input, probably a broken link');
|
---|
| 446 | else
|
---|
| 447 | if ~isempty(fileinput)
|
---|
| 448 | display_file_name(handles,fileinput,'append')
|
---|
| 449 | end
|
---|
| 450 | end
|
---|
| 451 |
|
---|
| 452 | %------------------------------------------------------------------------
|
---|
| 453 | % --- fct activated by selecting a previous file under the menu Open
|
---|
| 454 | %------------------------------------------------------------------------
|
---|
| 455 | function MenuFile_Callback(hObject, eventdata, handles)
|
---|
| 456 |
|
---|
| 457 | errormsg=display_file_name(handles,get(hObject,'Label'),'one');
|
---|
| 458 | if ~isempty(errormsg)
|
---|
| 459 | set(hObject,'Label','')
|
---|
| 460 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...
|
---|
| 461 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];
|
---|
| 462 | str_find=strcmp(get(hObject,'Label'),MenuFile);
|
---|
| 463 | MenuFile(str_find)=[]; % suppress the input file to the list
|
---|
| 464 | for ifile=1:numel(MenuFile)
|
---|
| 465 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',MenuFile{ifile});
|
---|
| 466 | end
|
---|
| 467 | end
|
---|
| 468 |
|
---|
| 469 | %------------------------------------------------------------------------
|
---|
| 470 | % --- fct activated by selecting a previous file under the menu Open/append
|
---|
| 471 | %------------------------------------------------------------------------
|
---|
| 472 | function MenuFile_append_Callback(hObject, eventdata, handles)
|
---|
| 473 |
|
---|
| 474 | InputTable=get(handles.InputTable,'Data');
|
---|
| 475 | if isempty(InputTable{1,1})% no input file in the table
|
---|
| 476 | display_file_name(handles,get(hObject,'Label'),'one') %refresh the input table, not append
|
---|
| 477 | else
|
---|
| 478 | display_file_name(handles,get(hObject,'Label'),'append')% append the selected file to the current list of InputTable
|
---|
| 479 | end
|
---|
| 480 |
|
---|
| 481 | %------------------------------------------------------------------------
|
---|
| 482 | % --- fct activated by the browser under 'Open campaign/Browse...'
|
---|
| 483 | %------------------------------------------------------------------------
|
---|
| 484 | function MenuBrowseCampaign_Callback(hObject, eventdata, handles)
|
---|
| 485 |
|
---|
| 486 | %% look for the previously opened file 'oldfile'
|
---|
| 487 | InputTable=get(handles.InputTable,'Data');
|
---|
| 488 | if ~isempty(InputTable)
|
---|
| 489 | oldfile=[InputTable{1,1} InputTable{1,2}];
|
---|
| 490 | else
|
---|
| 491 | % use a file name stored in prefdir
|
---|
| 492 | dir_perso=prefdir;
|
---|
| 493 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 494 | if exist(profil_perso,'file')
|
---|
| 495 | h=load (profil_perso);
|
---|
| 496 | if isfield(h,'MenuCampaign') && ~isempty(h.MenuCampaign)&& ischar(h.MenuCampaign{1})
|
---|
| 497 | oldfile=h.MenuCampaign{1};
|
---|
| 498 | end
|
---|
| 499 | end
|
---|
| 500 | end
|
---|
| 501 | InputTable{1,1}='...';
|
---|
| 502 | set(handles.InputTable,'Data',InputTable)
|
---|
| 503 | browse_data(oldfile,'on','on'); % open the GUI browse_data to get select a campaign dir, experiment and device
|
---|
| 504 | % NbLines=numel(OutPut.Experiment)*numel(OutPut.DataSeries);
|
---|
| 505 | % icount=0;
|
---|
| 506 | % for iexp=1:numel(OutPut.Experiment)
|
---|
| 507 | % for idevice=1:numel(OutPut.DataSeries)
|
---|
| 508 | % icount=icount+1;
|
---|
| 509 | % InputTable{icount,1}=fullfile(OutPut.Campaign,OutPut.Experiment{iexp});
|
---|
| 510 | % InputTable{icount,2}=OutPut.DataSeries{idevice};
|
---|
| 511 | % if isempty(InputTable{icount,3})
|
---|
| 512 | % if icount>1
|
---|
| 513 | % InputTable{icount,3}=InputTable{icount-1,3};
|
---|
| 514 | % else
|
---|
| 515 | % InputTable{icount,3}='';
|
---|
| 516 | % end
|
---|
| 517 | % end
|
---|
| 518 | % if isempty(InputTable{icount,4})
|
---|
| 519 | % if icount>1
|
---|
| 520 | % InputTable{icount,4}=InputTable{icount-1,4};
|
---|
| 521 | % else
|
---|
| 522 | % InputTable{icount,4}='';
|
---|
| 523 | % end
|
---|
| 524 | % end
|
---|
| 525 | % if isempty(InputTable{icount,5})
|
---|
| 526 | % if icount>1
|
---|
| 527 | % InputTable{icount,5}=InputTable{icount-1,5};
|
---|
| 528 | % else
|
---|
| 529 | % InputTable{icount,5}='';
|
---|
| 530 | % end
|
---|
| 531 | % end
|
---|
| 532 | % end
|
---|
| 533 | % end
|
---|
| 534 | % if size(InputTable,1)>icount
|
---|
| 535 | % InputTable(icount+1:size(InputTable,1),:)=[];
|
---|
| 536 | % end
|
---|
| 537 | %REFRESH_Callback(hObject, eventdata, handles)
|
---|
| 538 |
|
---|
| 539 | % --------------------------------------------------------------------
|
---|
| 540 | % function MenuCampaign_Callback(hObject, eventdata, handles)
|
---|
| 541 | % % --------------------------------------------------------------------
|
---|
| 542 | %
|
---|
| 543 | % OutPut=browse_data(get(hObject,'Label'),'on','on'); % open the GUI browse_data to get select a campaign dir, experiment and device
|
---|
| 544 | % if ~isfield(OutPut,'Campaign')
|
---|
| 545 | % return
|
---|
| 546 | % end
|
---|
| 547 | % NbLines=numel(OutPut.Experiment)*numel(OutPut.DataSeries);
|
---|
| 548 | % icount=0;
|
---|
| 549 | % InputTable=get(handles.InputTable,'Data');
|
---|
| 550 | % for iexp=1:numel(OutPut.Experiment)
|
---|
| 551 | % for idevice=1:numel(OutPut.DataSeries)
|
---|
| 552 | % icount=icount+1;
|
---|
| 553 | % InputTable{icount,1}=fullfile(OutPut.Campaign,OutPut.Experiment{iexp});
|
---|
| 554 | % InputTable{icount,2}=OutPut.DataSeries{idevice};
|
---|
| 555 | % if isempty(InputTable{icount,3})
|
---|
| 556 | % if icount>1
|
---|
| 557 | % InputTable{icount,3}=InputTable{icount-1,3};
|
---|
| 558 | % else
|
---|
| 559 | % InputTable{icount,3}='';
|
---|
| 560 | % end
|
---|
| 561 | % end
|
---|
| 562 | % if isempty(InputTable{icount,4})
|
---|
| 563 | % if icount>1
|
---|
| 564 | % InputTable{icount,4}=InputTable{icount-1,4};
|
---|
| 565 | % else
|
---|
| 566 | % InputTable{icount,4}='';
|
---|
| 567 | % end
|
---|
| 568 | % end
|
---|
| 569 | % if isempty(InputTable{icount,5})
|
---|
| 570 | % if icount>1
|
---|
| 571 | % InputTable{icount,5}=InputTable{icount-1,5};
|
---|
| 572 | % else
|
---|
| 573 | % InputTable{icount,5}='';
|
---|
| 574 | % end
|
---|
| 575 | % end
|
---|
| 576 | % end
|
---|
| 577 | % end
|
---|
| 578 | % if size(InputTable,1)>icount
|
---|
| 579 | % InputTable(icount+1:size(InputTable,1),:)=[];
|
---|
| 580 | % end
|
---|
| 581 | % set(handles.InputTable,'Data',InputTable)
|
---|
| 582 | % REFRESH_Callback(hObject, eventdata, handles)
|
---|
| 583 |
|
---|
| 584 |
|
---|
| 585 | % --- Executes when selected cell(s) is changed in InputTable.
|
---|
| 586 | function InputTable_CellSelectionCallback(hObject, eventdata, handles)
|
---|
| 587 | iline=[];
|
---|
| 588 | if ~isempty(eventdata.Indices)
|
---|
| 589 | iline=eventdata.Indices(1);
|
---|
| 590 | end
|
---|
| 591 | set(handles.InputLine,'String',num2str(iline));
|
---|
| 592 |
|
---|
| 593 | %------------------------------------------------------------------------
|
---|
| 594 | % --- 'key_press_fcn:' function activated when a key is pressed on the keyboard
|
---|
| 595 | %------------------------------------------------------------------------
|
---|
| 596 | function InputTable_KeyPressFcn(hObject, eventdata, handles)
|
---|
| 597 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed
|
---|
| 598 | set(handles.OutputSubDir,'BackgroundColor',[1 0 1])% set edit box OutputSubDir to magenta color to indicate that refresh may be needed
|
---|
| 599 | xx=double(get(handles.series,'CurrentCharacter')); % get the keyboard character
|
---|
| 600 | if ~isempty(xx)
|
---|
| 601 | switch xx
|
---|
| 602 | case 31 %downward arrow
|
---|
| 603 | InputTable=get(handles.InputTable,'Data');
|
---|
| 604 | iline=str2double(get(handles.InputLine,'String'));
|
---|
| 605 | if isequal(iline,size(InputTable,1))% arrow downward
|
---|
| 606 | InputTable=[InputTable;InputTable(iline,:)]; % create a new line as a copy of the last one
|
---|
| 607 | set(handles.InputTable,'Data',InputTable);
|
---|
| 608 | end
|
---|
| 609 | case 127 %key 'Suppress'
|
---|
| 610 | ClearLine_Callback(hObject, eventdata, handles)
|
---|
| 611 | end
|
---|
| 612 | end
|
---|
| 613 |
|
---|
| 614 | %------------------------------------------------------------------------
|
---|
| 615 | % --- Executes on button press in REFRESH.
|
---|
| 616 | function REFRESH_Callback(hObject, eventdata, handles)
|
---|
| 617 | %------------------------------------------------------------------------
|
---|
| 618 | check_input_file_series(handles)
|
---|
| 619 |
|
---|
| 620 | %% enable field and veltype menus, in accordance with the current action
|
---|
| 621 | ActionInput_Callback([],[], handles)
|
---|
| 622 |
|
---|
| 623 | %------------------------------------------------------------------------
|
---|
| 624 | % --- check the input file series.
|
---|
| 625 | function check_input_file_series(handles)
|
---|
| 626 | %------------------------------------------------------------------------
|
---|
| 627 | InputTable=get(handles.InputTable,'Data');
|
---|
| 628 | set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch'
|
---|
| 629 | set(handles.REFRESH,'BackgroundColor',[1 1 0])% set REFRESH button to yellow color (indicate activation)
|
---|
| 630 | drawnow
|
---|
| 631 | empty_line=false(size(InputTable,1),1);
|
---|
| 632 | for iline=1:size(InputTable,1)
|
---|
| 633 | empty_line(iline)= isempty(cell2mat(InputTable(iline,1:3)));%check the empty lines in the input table
|
---|
| 634 | end
|
---|
| 635 | if ~isempty(find(empty_line,1))
|
---|
| 636 | InputTable(empty_line,:)=[]; % remove empty lines
|
---|
| 637 | set(handles.InputTable,'Data',InputTable)
|
---|
| 638 | ListTable={'MinIndex_i','MaxIndex_i','MinIndex_j','MaxIndex_j','PairString','TimeTable'};
|
---|
| 639 | for ilist=1:numel(ListTable)
|
---|
| 640 | Table=get(handles.(ListTable{ilist}),'Data');
|
---|
| 641 | Table(empty_line,:)=[]; % remove empty lines
|
---|
| 642 | set(handles.(ListTable{ilist}),'Data',Table);
|
---|
| 643 | end
|
---|
| 644 | set(handles.series,'UserData',[])%refresh the stored info
|
---|
| 645 | end
|
---|
| 646 | nbview=size(InputTable,1);
|
---|
| 647 | for iview=1:nbview
|
---|
| 648 | RootPath=fullfile(InputTable{iview,1},InputTable{iview,2});
|
---|
| 649 | if ~exist(RootPath,'dir')
|
---|
| 650 | i1_series=[];
|
---|
| 651 | RootFile='';
|
---|
| 652 | else %scan the input folder
|
---|
| 653 | InputTable{iview,3}=regexprep(InputTable{iview,3},'^/','');%suppress '/' at the beginning of the input name
|
---|
| 654 | i1=str2num(get(handles.num_first_i,'String'));
|
---|
| 655 | j1=str2num(get(handles.num_first_j,'String'));
|
---|
| 656 | InputFile=fullfile_uvmat('','',InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,[],j1,[])
|
---|
| 657 | [RootPath,~,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=...
|
---|
| 658 | find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),InputFile);
|
---|
| 659 | end
|
---|
| 660 | % if no file is found, open a browser
|
---|
| 661 | if isempty(RootFile)&& isempty(i1_series)
|
---|
| 662 | fileinput=uigetfile_uvmat(['wrong input at line ' num2str(iview) ':pick a new input file'],RootPath);
|
---|
| 663 | if isempty(fileinput)
|
---|
| 664 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH back to red color
|
---|
| 665 | return
|
---|
| 666 | else
|
---|
| 667 | display_file_name(handles,fileinput,iview)
|
---|
| 668 | end
|
---|
| 669 | else
|
---|
| 670 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,iview)
|
---|
| 671 | end
|
---|
| 672 | end
|
---|
| 673 |
|
---|
| 674 | %% update MinIndex_i and MaxIndex_i if the input table content has been reduced in line nbre
|
---|
| 675 | MinIndex_i_table=get(handles.MinIndex_i,'Data'); % retrieve the min indices in the table MinIndex
|
---|
| 676 | set(handles.MinIndex_i,'Data',MinIndex_i_table(1:nbview,:));
|
---|
| 677 | MinIndex_j_table=get(handles.MinIndex_j,'Data'); % retrieve the min indices in the table MinIndex
|
---|
| 678 | set(handles.MinIndex_j,'Data',MinIndex_j_table(1:nbview,:));
|
---|
| 679 | MaxIndex_i_table=get(handles.MaxIndex_i,'Data'); % retrieve the min indices in the table MinIndex
|
---|
| 680 |
|
---|
| 681 | set(handles.MaxIndex_i,'Data',MaxIndex_i_table(1:nbview,:));
|
---|
| 682 | MaxIndex_j_table=get(handles.MaxIndex_j,'Data'); % retrieve the min indices in the table MinIndex
|
---|
| 683 | set(handles.MaxIndex_j,'Data',MaxIndex_j_table(1:nbview,:));
|
---|
| 684 | PairString=get(handles.PairString,'Data'); % retrieve the min indices in the table MinIndex
|
---|
| 685 | set(handles.PairString,'Data',PairString(1:nbview,:));
|
---|
| 686 | TimeTable=get(handles.TimeTable,'Data'); % retrieve the min indices in the table MinIndex
|
---|
| 687 | set(handles.TimeTable,'Data',TimeTable(1:nbview,:));
|
---|
| 688 |
|
---|
| 689 | %% set length of waitbar
|
---|
| 690 | displ_time(handles)
|
---|
| 691 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (indicate activation finished)
|
---|
| 692 | set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch'
|
---|
| 693 |
|
---|
| 694 |
|
---|
| 695 |
|
---|
| 696 | %------------------------------------------------------------------------
|
---|
| 697 | % --- Function called when a new file is opened, either by series_OpeningFcn or by the browser
|
---|
| 698 | %------------------------------------------------------------------------
|
---|
| 699 | % INPUT:
|
---|
| 700 | % handles: handles of elements in the GUI
|
---|
| 701 | % Param: structure of input parameters, including input file name and path
|
---|
| 702 | % iview: line index in the input table
|
---|
| 703 | % or 'one': refresh the list
|
---|
| 704 | % 'append': add a new line to the input table
|
---|
| 705 | function errormsg=display_file_name(handles,Param,iview)
|
---|
| 706 |
|
---|
| 707 | set(handles.REFRESH,'BackgroundColor',[1 1 0])% set REFRESH button to yellow color (indicate activation)
|
---|
| 708 | drawnow
|
---|
| 709 | errormsg=''; % default
|
---|
| 710 | if ischar(Param)
|
---|
| 711 | fileinput=Param;
|
---|
| 712 | else% input set when series is opened (called by the GUI uvmat)
|
---|
| 713 | fileinput=Param.FileName;
|
---|
| 714 | end
|
---|
| 715 |
|
---|
| 716 | %% get the input root name, indices, file extension and nomenclature NomType
|
---|
| 717 | if isempty(regexp(fileinput,'^http')) && ~exist(fileinput,'file')
|
---|
| 718 | errormsg=['input file ' fileinput ' does not exist'];
|
---|
| 719 | msgbox_uvmat('ERROR',errormsg)
|
---|
| 720 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (refresh still needed)
|
---|
| 721 | return
|
---|
| 722 | end
|
---|
| 723 |
|
---|
| 724 | %% detect root name, nomenclature and indices in the input file name:
|
---|
| 725 | [FilePath,FileName,FileExt]=fileparts(fileinput);
|
---|
| 726 | %%%%%%%%%%%%%%%%%%
|
---|
| 727 | %TODO: case of input by uvmat: do not check agai the input seies %%%%%%%
|
---|
| 728 | %%%%%%%%%%%%%%%%%%%
|
---|
| 729 | % detect the file type, get the movie object if relevant, and look for the corresponding file series:
|
---|
| 730 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
|
---|
| 731 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);
|
---|
| 732 | FileType=FileInfo.FileType;
|
---|
| 733 | if isempty(RootFile)&&isempty(i1_series)
|
---|
| 734 | errormsg='no input file in the series';
|
---|
| 735 | msgbox_uvmat('ERROR',errormsg)
|
---|
| 736 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation)
|
---|
| 737 | return
|
---|
| 738 | end
|
---|
| 739 | if strcmp(FileType,'txt')
|
---|
| 740 | edit(fileinput)
|
---|
| 741 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation)
|
---|
| 742 | return
|
---|
| 743 | elseif strcmp(FileType,'xml')
|
---|
| 744 | editxml(fileinput)
|
---|
| 745 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation)
|
---|
| 746 | return
|
---|
| 747 | elseif strcmp(FileType,'figure')
|
---|
| 748 | open(fileinput)
|
---|
| 749 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation)
|
---|
| 750 | return
|
---|
| 751 | end
|
---|
| 752 |
|
---|
| 753 | %% enable other menus and uicontrols
|
---|
| 754 | set(handles.RUN, 'Enable','On')
|
---|
| 755 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red
|
---|
| 756 | set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow
|
---|
| 757 | drawnow
|
---|
| 758 |
|
---|
| 759 |
|
---|
| 760 | %% fill the list of file series
|
---|
| 761 | InputTable=get(handles.InputTable,'Data');
|
---|
| 762 | SeriesData=get(handles.series,'UserData');
|
---|
| 763 |
|
---|
| 764 | if strcmp(iview,'append') % display the input data as a new line in the table
|
---|
| 765 | iview=size(InputTable,1)+1; % the next line in InputTable becomes the current line
|
---|
| 766 | elseif strcmp(iview,'one') % refresh the list of input file series
|
---|
| 767 | iview=1; % the first line in InputTable becomes the current line
|
---|
| 768 | InputTable={'','','','',''};
|
---|
| 769 | set(handles.TimeTable,'Data',[{''},{[]},{[]},{[]},{[]}])
|
---|
| 770 | set(handles.MinIndex_i,'Data',[])
|
---|
| 771 | set(handles.MaxIndex_i,'Data',[])
|
---|
| 772 | set(handles.MinIndex_j,'Data',[])
|
---|
| 773 | set(handles.MaxIndex_j,'Data',[])
|
---|
| 774 | set(handles.PairString,'Data',{''})
|
---|
| 775 | SeriesData.CheckPair=0; % reset the list of input lines with pairs
|
---|
| 776 | SeriesData.i1_series={};
|
---|
| 777 | SeriesData.i2_series={};
|
---|
| 778 | SeriesData.j1_series={};
|
---|
| 779 | SeriesData.j2_series={};
|
---|
| 780 | SeriesData.FileType={};
|
---|
| 781 | SeriesData.FileInfo={};
|
---|
| 782 | SeriesData.Time={};
|
---|
| 783 | end
|
---|
| 784 | if isfield(SeriesData,'i1_series')
|
---|
| 785 | SeriesData.i1_series(iview+1:end)=[];
|
---|
| 786 | SeriesData.i2_series(iview+1:end)=[];
|
---|
| 787 | SeriesData.j1_series(iview+1:end)=[];
|
---|
| 788 | SeriesData.j2_series(iview+1:end)=[];
|
---|
| 789 | SeriesData.FileType(iview+1:end)=[];
|
---|
| 790 | SeriesData.FileInfo(iview+1:end)=[];
|
---|
| 791 | SeriesData.Time(iview+1:end)=[];
|
---|
| 792 | end
|
---|
| 793 | InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
|
---|
| 794 | if iview >1
|
---|
| 795 | set(handles.InputLine,'String',num2str(iview))
|
---|
| 796 | end
|
---|
| 797 | set(handles.InputTable,'Data',InputTable)
|
---|
| 798 |
|
---|
| 799 | %% determine the selected reference field indices for pair display
|
---|
| 800 | if isempty(i1)
|
---|
| 801 | i1=1;
|
---|
| 802 | end
|
---|
| 803 | if isempty(i2)
|
---|
| 804 | i2=i1;
|
---|
| 805 | end
|
---|
| 806 | ref_i=floor((i1+i2)/2); % reference image number corresponding to the file
|
---|
| 807 | % set(handles.num_ref_i,'String',num2str(ref_i));
|
---|
| 808 | if isempty(j1)
|
---|
| 809 | j1=1;
|
---|
| 810 | end
|
---|
| 811 | if isempty(j2)
|
---|
| 812 | j2=j1;
|
---|
| 813 | end
|
---|
| 814 | ref_j=floor((j1+j2)/2); % reference image number corresponding to the file
|
---|
| 815 | SeriesData.ref_i=ref_i;
|
---|
| 816 | SeriesData.ref_j=ref_j;
|
---|
| 817 |
|
---|
| 818 | %% update first and last indices if they do not exist
|
---|
| 819 | Param=read_GUI(handles.series);
|
---|
| 820 | first_j=[];
|
---|
| 821 | if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
|
---|
| 822 | last_j=[];
|
---|
| 823 | if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end
|
---|
| 824 | PairString='';
|
---|
| 825 | if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
|
---|
| 826 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
|
---|
| 827 | FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
|
---|
| 828 | Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
|
---|
| 829 | if ~exist(FirstFileName,'file')
|
---|
| 830 | set(handles.num_first_i,'String',num2str(ref_i))
|
---|
| 831 | set(handles.num_first_j,'String',num2str(ref_j))
|
---|
| 832 | end
|
---|
| 833 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.last_i,last_j,PairString);
|
---|
| 834 | LastFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
|
---|
| 835 | Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
|
---|
| 836 | if ~exist(LastFileName,'file')
|
---|
| 837 | set(handles.num_last_i,'String',num2str(ref_i))
|
---|
| 838 | set(handles.num_last_j,'String',num2str(ref_j))
|
---|
| 839 | end
|
---|
| 840 |
|
---|
| 841 | %% update the list of recent files in the menubar and save it for future opening
|
---|
| 842 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...
|
---|
| 843 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];
|
---|
| 844 | str_find=strcmp(fileinput,MenuFile);
|
---|
| 845 | if isempty(find(str_find,1))
|
---|
| 846 | MenuFile=[{fileinput};MenuFile]; % insert the current file if not already in the list
|
---|
| 847 | end
|
---|
| 848 | for ifile=1:min(length(MenuFile),5)
|
---|
| 849 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
|
---|
| 850 | end
|
---|
| 851 | dir_perso=prefdir;
|
---|
| 852 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 853 | if exist(profil_perso,'file')
|
---|
| 854 | save (profil_perso,'MenuFile','-append'); % store the file names for future opening of uvmat
|
---|
| 855 | else
|
---|
| 856 | save (profil_perso,'MenuFile','-V6'); % store the file names for future opening of uvmat
|
---|
| 857 | end
|
---|
| 858 | % save the opened file to initiate future opening
|
---|
| 859 | SeriesData.RefFile{iview}=fileinput; % reference opening file for line iview
|
---|
| 860 | SeriesData.Ref_i1=i1;
|
---|
| 861 | SeriesData.Ref_i2=i2;
|
---|
| 862 | SeriesData.Ref_j1=j1;
|
---|
| 863 | SeriesData.Ref_j2=j2;
|
---|
| 864 |
|
---|
| 865 | %% define the path for the output files
|
---|
| 866 | [InputPath,Device,DeviceExt]=fileparts(InputTable{1,1});
|
---|
| 867 | [InputPath,Experiment,ExperimentExt]=fileparts(InputPath);
|
---|
| 868 | set(handles.Device,'String',[Device DeviceExt])
|
---|
| 869 | set(handles.Experiment,'String',[Experiment ExperimentExt])
|
---|
| 870 | if ~isempty(regexp(InputTable{1,1},'(^http://)|(^https://)'))
|
---|
| 871 | set(handles.OutputPathBrowse,'Value',1)% an output folder needs to be specified for OpenDAP data
|
---|
| 872 | end
|
---|
| 873 |
|
---|
| 874 | %update the output path if needed
|
---|
| 875 | if ~(isfield(SeriesData,'InputPath') && strcmp(SeriesData.InputPath,InputPath))
|
---|
| 876 | if get(handles.OutputPathBrowse,'Value')==1 % fix the output path in manual mode
|
---|
| 877 | OutputPathOld=get(handles.OutputPath,'String');
|
---|
| 878 | OutputPath=uigetdir(OutputPathOld,'pick a root folder for output data');
|
---|
| 879 | set(handles.OutputPath,'String',OutputPath)
|
---|
| 880 | else %reproduce the input path for output
|
---|
| 881 | set(handles.OutputPath,'String',InputPath)
|
---|
| 882 | end
|
---|
| 883 | SeriesData.InputPath=InputPath;
|
---|
| 884 | end
|
---|
| 885 |
|
---|
| 886 | set(handles.series,'UserData',SeriesData)
|
---|
| 887 |
|
---|
| 888 | set(handles.InputTable,'BackgroundColor',[1 1 1])
|
---|
| 889 |
|
---|
| 890 | %% initiate input file series and refresh the current field view:
|
---|
| 891 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,iview);
|
---|
| 892 | %% enable field and veltype menus, in accordance with the current action
|
---|
| 893 | ActionName_Callback([],[], handles)
|
---|
| 894 |
|
---|
| 895 | %% set length of waitbar
|
---|
| 896 | displ_time(handles)
|
---|
| 897 |
|
---|
| 898 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (end of activation)
|
---|
| 899 |
|
---|
| 900 | %------------------------------------------------------------------------
|
---|
| 901 | % --- Update information about a new field series (indices to scan, timing,
|
---|
| 902 | % calibration from an xml file
|
---|
| 903 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,VideoObject,iview)
|
---|
| 904 | %------------------------------------------------------------------------
|
---|
| 905 | InputTable=get(handles.InputTable,'Data');
|
---|
| 906 |
|
---|
| 907 | %% display the min and max indices for the whole file series
|
---|
| 908 | if size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0
|
---|
| 909 | MinIndex_j=1; % index j set to 1 by default
|
---|
| 910 | MaxIndex_j=1;
|
---|
| 911 | MinIndex_i=find(i1_series(1,2,:), 1 )-1; % min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index)
|
---|
| 912 | MaxIndex_i=find(i1_series(1,2,:),1,'last' )-1; % max ref index i detected in the series (corresponding to the last non-zero value of i1_series)
|
---|
| 913 | else
|
---|
| 914 | ref_i=squeeze(max(i1_series(1,:,:),[],2)); % select ref_j index for each ref_i
|
---|
| 915 | ref_j=squeeze(max(j1_series(1,:,:),[],3)); % select ref_i index for each ref_j
|
---|
| 916 | MinIndex_i=min(find(ref_i))-1;
|
---|
| 917 | MaxIndex_i=max(find(ref_i))-1;
|
---|
| 918 | MaxIndex_j=max(find(ref_j))-1;
|
---|
| 919 | MinIndex_j=min(find(ref_j))-1;
|
---|
| 920 | diff_j_max=diff(ref_j);
|
---|
| 921 | diff_i_max=diff(ref_i);
|
---|
| 922 | if ~isempty(diff_i_max) && isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max)))
|
---|
| 923 | set(handles.num_incr_i,'String',num2str(diff_i_max(1)))% detect an increment to dispaly by default
|
---|
| 924 | end
|
---|
| 925 | if ~isempty(diff_j_max) && isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max)))
|
---|
| 926 | set(handles.num_incr_j,'String',num2str(diff_j_max(1)))
|
---|
| 927 | end
|
---|
| 928 | end
|
---|
| 929 | if isequal(MinIndex_i,-1)
|
---|
| 930 | MinIndex_i=0;
|
---|
| 931 | end
|
---|
| 932 | if isequal(MinIndex_j,-1)
|
---|
| 933 | MinIndex_j=0;
|
---|
| 934 | end
|
---|
| 935 | MinIndex_i_table=get(handles.MinIndex_i,'Data'); % retrieve the min indices in the table MinIndex
|
---|
| 936 | MinIndex_j_table=get(handles.MinIndex_j,'Data'); % retrieve the min indices in the table MinIndex
|
---|
| 937 | MaxIndex_i_table=get(handles.MaxIndex_i,'Data'); % retrieve the min indices in the table MinIndex
|
---|
| 938 | MaxIndex_j_table=get(handles.MaxIndex_j,'Data'); % retrieve the min indices in the table MinIndex
|
---|
| 939 | if ~isempty(MinIndex_i)&&~isempty(MaxIndex_i)
|
---|
| 940 | MinIndex_i_table(iview,1)=MinIndex_i;
|
---|
| 941 | MaxIndex_i_table(iview,1)=MaxIndex_i;
|
---|
| 942 | end
|
---|
| 943 | if ~isempty(MinIndex_j)&&~isempty(MaxIndex_j)
|
---|
| 944 | MinIndex_j_table(iview,1)=MinIndex_j;
|
---|
| 945 | MaxIndex_j_table(iview,1)=MaxIndex_j;
|
---|
| 946 | end
|
---|
| 947 | set(handles.MinIndex_i,'Data',MinIndex_i_table)%display the min indices in the table MinIndex
|
---|
| 948 | set(handles.MinIndex_j,'Data',MinIndex_j_table)%display the max indices in the table MaxIndex
|
---|
| 949 | set(handles.MaxIndex_i,'Data',MaxIndex_i_table)%display the min indices in the table MinIndex
|
---|
| 950 | set(handles.MaxIndex_j,'Data',MaxIndex_j_table)%display the max indices in the table MaxIndex
|
---|
| 951 | SeriesData=get(handles.series,'UserData');
|
---|
| 952 |
|
---|
| 953 | %% adjust the first and last indices for the selected series, only if requested by the bounds
|
---|
| 954 | % i index, compare input to min index i
|
---|
| 955 | first_i=str2num(get(handles.num_first_i,'String')); % retrieve previous first i
|
---|
| 956 | % ref_i=str2num(get(handles.num_ref_i,'String')); % index i given by the input field
|
---|
| 957 | ref_i=1;
|
---|
| 958 | if isfield(SeriesData,'ref_i')
|
---|
| 959 | ref_i=SeriesData.ref_i;
|
---|
| 960 | end
|
---|
| 961 | if isempty(first_i)
|
---|
| 962 | first_i=ref_i; % first_i updated by the input value
|
---|
| 963 | elseif first_i < MinIndex_i
|
---|
| 964 | first_i=MinIndex_i; % first_i set to the min i index (restricted by oter input lines)
|
---|
| 965 | elseif first_i >MaxIndex_i
|
---|
| 966 | first_i=MaxIndex_i; % first_i set to the max i index (restricted by oter input lines)
|
---|
| 967 | end
|
---|
| 968 | % j index, compare input to min index j
|
---|
| 969 | first_j=str2num(get(handles.num_first_j,'String'));
|
---|
| 970 | ref_j=1;
|
---|
| 971 | if isfield(SeriesData,'ref_j')
|
---|
| 972 | ref_j=SeriesData.ref_j;
|
---|
| 973 | end
|
---|
| 974 | if isempty(first_j)
|
---|
| 975 | first_j=ref_j; % first_j updated by the input value
|
---|
| 976 | elseif first_j<MinIndex_j
|
---|
| 977 | first_j=MinIndex_j; % first_j set to the min j index (restricted by oter input lines)
|
---|
| 978 | elseif first_j >MaxIndex_j
|
---|
| 979 | first_j=MaxIndex_j; % first_j set to the max j index (restricted by oter input lines)
|
---|
| 980 | end
|
---|
| 981 | % i index, compare input to max index i
|
---|
| 982 | last_i=str2num(get(handles.num_last_i,'String'));
|
---|
| 983 | if isempty(last_i)
|
---|
| 984 | last_i=ref_i;
|
---|
| 985 | elseif last_i > MaxIndex_i
|
---|
| 986 | last_i=MaxIndex_i;
|
---|
| 987 | elseif last_i<first_i
|
---|
| 988 | last_i=first_i;
|
---|
| 989 | end
|
---|
| 990 | % j index, compare input to max index j
|
---|
| 991 | last_j=str2num(get(handles.num_last_j,'String'));
|
---|
| 992 | if isempty(last_j)
|
---|
| 993 | last_j=ref_j;
|
---|
| 994 | elseif last_j>MaxIndex_j
|
---|
| 995 | last_j=MaxIndex_j;
|
---|
| 996 | elseif last_j<first_j
|
---|
| 997 | last_j=first_j;
|
---|
| 998 | end
|
---|
| 999 | set(handles.num_first_i,'String',num2str(first_i));
|
---|
| 1000 | set(handles.num_first_j,'String',num2str(first_j));
|
---|
| 1001 | set(handles.num_last_i,'String',num2str(last_i));
|
---|
| 1002 | set(handles.num_last_j,'String',num2str(last_j));
|
---|
| 1003 |
|
---|
| 1004 | %% number of slices set by default
|
---|
| 1005 | NbSlice=[]; % default
|
---|
| 1006 | % read value set by the first series for the append mode (iwiew >1)
|
---|
| 1007 | if iview>1 && strcmp(get(handles.num_NbSlice,'Visible'),'on')
|
---|
| 1008 | NbSlice=str2double(get(handles.num_NbSlice,'String'));
|
---|
| 1009 | end
|
---|
| 1010 |
|
---|
| 1011 | %% default time settings
|
---|
| 1012 | TimeUnit='';
|
---|
| 1013 | % read value set by the first series for the append mode (iwiew >1)
|
---|
| 1014 | if iview>1
|
---|
| 1015 | TimeUnit=get(handles.TimeUnit,'String');
|
---|
| 1016 | end
|
---|
| 1017 | TimeName='';
|
---|
| 1018 | Time=[]; % default
|
---|
| 1019 | TimeMin=[];
|
---|
| 1020 | TimeFirst=[];
|
---|
| 1021 | TimeLast=[];
|
---|
| 1022 | TimeMax=[];
|
---|
| 1023 |
|
---|
| 1024 | %% read image documentation file if found
|
---|
| 1025 | XmlData=[];
|
---|
| 1026 | check_calib=0;
|
---|
| 1027 | XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5});
|
---|
| 1028 | if ~isempty(XmlFileName)
|
---|
| 1029 | [XmlData,errormsg]=imadoc2struct(XmlFileName);
|
---|
| 1030 | if ~isempty(errormsg)
|
---|
| 1031 | msgbox_uvmat('WARNING',['error in reading ' XmlFileName ': ' errormsg]);
|
---|
| 1032 | end
|
---|
| 1033 | % read time if available
|
---|
| 1034 | if isfield(XmlData,'Time')
|
---|
| 1035 | Time=XmlData.Time;
|
---|
| 1036 | TimeName='xml';
|
---|
| 1037 | end
|
---|
| 1038 | if isfield(XmlData,'Camera')
|
---|
| 1039 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
|
---|
| 1040 | if iview>1 && ~isempty(TimeUnit) && ~strcmp(TimeUnit,XmlData.Camera.TimeUnit)
|
---|
| 1041 | msgbox_uvmat('WARNING','inconsistent time unit with the first field series');
|
---|
| 1042 | end
|
---|
| 1043 | TimeUnit=XmlData.Camera.TimeUnit;
|
---|
| 1044 | end
|
---|
| 1045 | end
|
---|
| 1046 | % number of slices
|
---|
| 1047 | if isfield(XmlData,'TranslationMotor')&& isfield(XmlData.TranslationMotor,'NbSlice')
|
---|
| 1048 | NbSlice_motor=XmlData.TranslationMotor.NbSlice;
|
---|
| 1049 | if ~isempty(NbSlice) && ~isequal(NbSlice_motor,NbSlice)
|
---|
| 1050 | msgbox_uvmat('WARNING','inconsistent Z numbers of Z indices');
|
---|
| 1051 | else
|
---|
| 1052 | NbSlice=NbSlice_motor;
|
---|
| 1053 | end
|
---|
| 1054 | end
|
---|
| 1055 | end
|
---|
| 1056 | if ~isempty(NbSlice)
|
---|
| 1057 | set(handles.num_NbSlice,'String',num2str(NbSlice))
|
---|
| 1058 | set(handles.num_NbSlice,'Visible','on')
|
---|
| 1059 | end
|
---|
| 1060 |
|
---|
| 1061 | %% read timing from the current file (prioritary)
|
---|
| 1062 | if ~isempty(VideoObject)% case of movies
|
---|
| 1063 | imainfo=get(VideoObject);
|
---|
| 1064 | if isfield(imainfo,'NumFrames')
|
---|
| 1065 | imainfo.NumberOfFrames=imainfo.NumFrames;
|
---|
| 1066 | end
|
---|
| 1067 | if isempty(j1_series) % frame index along i
|
---|
| 1068 | Time=zeros(imainfo.NumberOfFrames+1,2);
|
---|
| 1069 | Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
|
---|
| 1070 | else
|
---|
| 1071 | Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
|
---|
| 1072 | end
|
---|
| 1073 | TimeName='video';
|
---|
| 1074 | end
|
---|
| 1075 |
|
---|
| 1076 |
|
---|
| 1077 | %% determine the min and max times: case of Netcdf files will be treated later in FieldName_Callback
|
---|
| 1078 | if ~isempty(TimeName)
|
---|
| 1079 | TimeMin=Time(MinIndex_i+1,MinIndex_j+1);
|
---|
| 1080 | if size(Time)>=[first_i+1 first_j+1]
|
---|
| 1081 | TimeFirst=Time(first_i+1,first_j+1);
|
---|
| 1082 | end
|
---|
| 1083 | if size(Time)>=[last_i+1 last_j+1]
|
---|
| 1084 | TimeLast=Time(last_i+1,last_j+1);
|
---|
| 1085 | end
|
---|
| 1086 | if size(Time)>=[MaxIndex_i+1 MaxIndex_j+1]
|
---|
| 1087 | TimeMax=Time(MaxIndex_i+1,MaxIndex_j+1);
|
---|
| 1088 | end
|
---|
| 1089 | end
|
---|
| 1090 |
|
---|
| 1091 | %% update the time table
|
---|
| 1092 | TimeTable=get(handles.TimeTable,'Data');
|
---|
| 1093 | TimeTable{iview,1}=TimeName;
|
---|
| 1094 | TimeTable{iview,2}=TimeMin;
|
---|
| 1095 | TimeTable{iview,3}=TimeFirst;
|
---|
| 1096 | TimeTable{iview,4}=TimeLast;
|
---|
| 1097 | TimeTable{iview,5}=TimeMax;
|
---|
| 1098 | set(handles.TimeTable,'Data',TimeTable)
|
---|
| 1099 |
|
---|
| 1100 | %% update the series info in 'UserData'
|
---|
| 1101 | SeriesData.i1_series{iview}=i1_series;
|
---|
| 1102 | SeriesData.i2_series{iview}=i2_series;
|
---|
| 1103 | SeriesData.j1_series{iview}=j1_series;
|
---|
| 1104 | SeriesData.j2_series{iview}=j2_series;
|
---|
| 1105 | SeriesData.FileType{iview}=FileInfo.FileType;
|
---|
| 1106 | SeriesData.FileInfo{iview}=FileInfo;
|
---|
| 1107 | SeriesData.Time{iview}=Time;
|
---|
| 1108 |
|
---|
| 1109 | SeriesData.TimeName=TimeName;
|
---|
| 1110 |
|
---|
| 1111 | if check_calib
|
---|
| 1112 | SeriesData.GeometryCalib{iview}=XmlData.GeometryCalib;
|
---|
| 1113 | end
|
---|
| 1114 | set(handles.series,'UserData',SeriesData)
|
---|
| 1115 |
|
---|
| 1116 | %% update pair menus
|
---|
| 1117 | hset_pair=findobj(allchild(0),'Tag','set_pairs');
|
---|
| 1118 | if ~isempty(hset_pair), delete(hset_pair); end % delete the GUI set_pair if opened
|
---|
| 1119 | CheckPair= ~isempty(i2_series)||~isempty(j2_series); % check whether index pairs need to be defined
|
---|
| 1120 | PairString=get(handles.PairString,'Data');
|
---|
| 1121 | if CheckPair% if pairs need to be display for line iview
|
---|
| 1122 | [ModeMenu,ModeValue]=update_mode(i1_series,i2_series,j2_series);
|
---|
| 1123 | Menu=update_listpair(i1_series,i2_series,j1_series,j2_series,ModeMenu{ModeValue},Time,TimeUnit,ref_i,ref_j,TimeName,InputTable(iview,:),FileInfo);
|
---|
| 1124 | PairString{iview,1}=Menu{1};
|
---|
| 1125 | else
|
---|
| 1126 | PairString{iview,1}=''; % no pair for #iview
|
---|
| 1127 | end
|
---|
| 1128 | set(handles.PairString,'Data',PairString)
|
---|
| 1129 | if isempty(find(cellfun('isempty',get(handles.PairString,'Data'))==0, 1))% if all lines of pairs are empty
|
---|
| 1130 | set(handles.PairString,'Visible','off')
|
---|
| 1131 | set(handles.SetPairs,'Visible','off')
|
---|
| 1132 | else
|
---|
| 1133 | set(handles.PairString,'Visible','on')
|
---|
| 1134 | set(handles.SetPairs,'Visible','on')
|
---|
| 1135 | end
|
---|
| 1136 |
|
---|
| 1137 |
|
---|
| 1138 | %% display the set of existing files as an image
|
---|
| 1139 | set(handles.FileStatus,'Units','pixels')
|
---|
| 1140 | Position=get(handles.FileStatus,'Position');
|
---|
| 1141 | set(handles.FileStatus,'Units','normalized')
|
---|
| 1142 | %xI=0.5:Position(3)-0.5;
|
---|
| 1143 | nbview=numel(SeriesData.i1_series);
|
---|
| 1144 | j_max=cell(1,nbview);
|
---|
| 1145 | MaxIndex_i=ones(1,nbview); % default
|
---|
| 1146 | MinIndex_i=ones(1,nbview); % default
|
---|
| 1147 | for iline=1:nbview
|
---|
| 1148 | pair_max=squeeze(max(SeriesData.i1_series{iline},[],1)); % max on pair index
|
---|
| 1149 | j_max{iline}=max(pair_max,[],1); % max on j index
|
---|
| 1150 | if ~isempty(j_max{iline})
|
---|
| 1151 | MaxIndex_i(iline)=find(j_max{iline}, 1, 'last' )-1; % max ref index i
|
---|
| 1152 | MinIndex_i(iline)=find(j_max{iline}, 1 )-1; % min ref index i
|
---|
| 1153 | end
|
---|
| 1154 | end
|
---|
| 1155 | MinIndex_i=min(MinIndex_i);
|
---|
| 1156 | MaxIndex_i=max(MaxIndex_i);
|
---|
| 1157 | range_index=MaxIndex_i-MinIndex_i+1;
|
---|
| 1158 | range_y=max(1,floor(Position(4)/nbview));
|
---|
| 1159 | npx=floor(Position(3));
|
---|
| 1160 | file_indices=MinIndex_i+floor(((0.5:npx-0.5)/npx)*range_index)+1;
|
---|
| 1161 | CData=zeros(nbview*range_y,npx); % initiate the image representing the existing files
|
---|
| 1162 | for iline=1:nbview
|
---|
| 1163 | ind_y=1+(iline-1)*range_y:iline*range_y;
|
---|
| 1164 | LineData=zeros(size(file_indices));
|
---|
| 1165 | file_select=file_indices(file_indices<=numel(j_max{iline}));
|
---|
| 1166 | ind_select=file_indices<=numel(j_max{iline});
|
---|
| 1167 | LineData(ind_select)=j_max{iline}(file_select)~=0;
|
---|
| 1168 | CData(ind_y,:)=ones(size(ind_y'))*LineData;
|
---|
| 1169 | end
|
---|
| 1170 | CData=cat(3,zeros(size(CData)),CData,zeros(size(CData))); % make color images r=0,g,b=0
|
---|
| 1171 | set(handles.FileStatus,'CData',CData);
|
---|
| 1172 |
|
---|
| 1173 | %-----------------------------------------------------------guide -------------
|
---|
| 1174 | %------------------------------------------------------------------------
|
---|
| 1175 | % III - FUNCTIONS ASSOCIATED TO THE FRAME IndexRange
|
---|
| 1176 | %------------------------------------------------------------------------
|
---|
| 1177 |
|
---|
| 1178 |
|
---|
| 1179 | % ---- determine the menu to put in mode and advice a default choice
|
---|
| 1180 | %------------------------------------------------------------------------
|
---|
| 1181 | function [ModeMenu,ModeValue]=update_mode(i1_series,i2_series,j2_series)
|
---|
| 1182 | %------------------------------------------------------------------------
|
---|
| 1183 | ModeMenu={''};
|
---|
| 1184 | if isempty(j2_series)% no j pair
|
---|
| 1185 | ModeValue=1;
|
---|
| 1186 | if ~isempty(i2_series)
|
---|
| 1187 | ModeMenu={'series(Di)'}; % pair menu with only option Di
|
---|
| 1188 | end
|
---|
| 1189 | else %existence of j pairs
|
---|
| 1190 | pair_max=squeeze(max(i1_series,[],1)); % max on pair index
|
---|
| 1191 | j_max=max(pair_max,[],1);
|
---|
| 1192 | MaxIndex_i=find(j_max, 1, 'last' )-1; % max ref index i
|
---|
| 1193 | MinIndex_i=find(j_max, 1 )-1; % min ref index i
|
---|
| 1194 | i_max=max(pair_max,[],2);
|
---|
| 1195 | MaxIndex_j=find(i_max, 1, 'last' )-1; % max ref index i
|
---|
| 1196 | MinIndex_j=find(i_max, 1 )-1; % min ref index i
|
---|
| 1197 | if MaxIndex_j==MinIndex_j
|
---|
| 1198 | ModeValue=1;
|
---|
| 1199 | ModeMenu={'bursts'};
|
---|
| 1200 | elseif MaxIndex_i==MinIndex_i
|
---|
| 1201 | ModeValue=1;
|
---|
| 1202 | ModeMenu={'series(Dj)'};
|
---|
| 1203 | else
|
---|
| 1204 | ModeMenu={'bursts';'series(Dj)'};
|
---|
| 1205 | if (MaxIndex_j-MinIndex_j)>10
|
---|
| 1206 | ModeValue=2; % set mode to series(Dj) if more than 10 j values
|
---|
| 1207 | else
|
---|
| 1208 | ModeValue=1;
|
---|
| 1209 | end
|
---|
| 1210 | end
|
---|
| 1211 | end
|
---|
| 1212 |
|
---|
| 1213 |
|
---|
| 1214 | %------------------------------------------------------------------------
|
---|
| 1215 | %fill the menu of possible pairs as input
|
---|
| 1216 | function displ_pair=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,time,TimeUnit,ref_i,ref_j,TimeName,InputTable,FileInfo)
|
---|
| 1217 | %------------------------------------------------------------------------
|
---|
| 1218 | displ_pair={};
|
---|
| 1219 | if isempty(TimeUnit)
|
---|
| 1220 | dtunit='e-03';
|
---|
| 1221 | else
|
---|
| 1222 | dtunit=['m' TimeUnit];
|
---|
| 1223 | end
|
---|
| 1224 | switch mode
|
---|
| 1225 | case 'series(Di)'
|
---|
| 1226 | diff_i=i2_series-i1_series;
|
---|
| 1227 | min_diff=min(diff_i(diff_i>0));
|
---|
| 1228 | max_diff=max(diff_i(diff_i>0));
|
---|
| 1229 | for ipair=min_diff:max_diff
|
---|
| 1230 | if ~isempty(find(diff_i==ipair,1))% if the considered difference exists as input
|
---|
| 1231 | pair_string=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
|
---|
| 1232 | if size(time,1)>=ref_i+ceil(ipair/2)
|
---|
| 1233 | if ref_i<=floor(ipair/2)
|
---|
| 1234 | ref_i=floor(ipair/2)+1; % shift ref_i to get the first pair
|
---|
| 1235 | end
|
---|
| 1236 | Dt=time(ref_i+ceil(ipair/2),ref_j)-time(ref_i-floor(ipair/2),ref_j);
|
---|
| 1237 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit];
|
---|
| 1238 | end
|
---|
| 1239 | displ_pair=[displ_pair;{pair_string}];
|
---|
| 1240 | end
|
---|
| 1241 | end
|
---|
| 1242 | if ~isempty(displ_pair)
|
---|
| 1243 | displ_pair=[displ_pair;{'Di=*|*'}];
|
---|
| 1244 | end
|
---|
| 1245 | case 'series(Dj)'
|
---|
| 1246 | if isempty(j2_series)
|
---|
| 1247 | msgbox_uvmat('ERROR','no j1-j2 pair available')
|
---|
| 1248 | return
|
---|
| 1249 | end
|
---|
| 1250 | diff_j=j2_series-j1_series;
|
---|
| 1251 | min_diff=min(diff_j(diff_j>0));
|
---|
| 1252 | max_diff=max(diff_j(diff_j>0));
|
---|
| 1253 | for ipair=min_diff:max_diff
|
---|
| 1254 | if numel(diff_j(diff_j==ipair))>0
|
---|
| 1255 | pair_string=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
|
---|
| 1256 | if ~isempty(time)
|
---|
| 1257 | if ref_j<=floor(ipair/2)
|
---|
| 1258 | ref_j=floor(ipair/2)+1; % shift ref_i to get the first pair
|
---|
| 1259 | end
|
---|
| 1260 | Dt=time(ref_i,ref_j+ceil(ipair/2))-time(ref_i,ref_j-floor(ipair/2));
|
---|
| 1261 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit];
|
---|
| 1262 | end
|
---|
| 1263 | displ_pair=[displ_pair;{pair_string}];
|
---|
| 1264 | end
|
---|
| 1265 | end
|
---|
| 1266 | if ~isempty(displ_pair)
|
---|
| 1267 | displ_pair=[displ_pair;{'Dj=*|*'}];
|
---|
| 1268 | end
|
---|
| 1269 | case 'bursts'
|
---|
| 1270 | if isempty(j2_series)
|
---|
| 1271 | msgbox_uvmat('ERROR','no j1-j2 pair available')
|
---|
| 1272 | return
|
---|
| 1273 | end
|
---|
| 1274 | %diff_j=j2_series-j1_series;
|
---|
| 1275 | min_j1=min(j1_series(j1_series>0));
|
---|
| 1276 | max_j1=max(j1_series(j1_series>0));
|
---|
| 1277 | min_j2=min(j2_series(j2_series>0));
|
---|
| 1278 | max_j2=max(j2_series(j2_series>0));
|
---|
| 1279 | for pair1=min_j1:min(max_j1,min_j1+20)
|
---|
| 1280 | for pair2=min_j2:min(max_j2,min_j2+20)
|
---|
| 1281 | if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0
|
---|
| 1282 | pair_string=['j= ' num2str(pair1) '-' num2str(pair2)];
|
---|
| 1283 | [TimeValue,DtValue]=get_time(ref_i,[],pair_string,InputTable,FileInfo,TimeName,'Dt');
|
---|
| 1284 | %Dt=time(ref_i,pair2+1)-time(ref_i,pair1+1);
|
---|
| 1285 | pair_string=[pair_string ', Dt=' num2str(DtValue) ' ' dtunit];
|
---|
| 1286 | displ_pair=[displ_pair;{pair_string}];
|
---|
| 1287 | end
|
---|
| 1288 | end
|
---|
| 1289 | end
|
---|
| 1290 | if ~isempty(displ_pair)
|
---|
| 1291 | displ_pair=[displ_pair;{'j=*-*'}];
|
---|
| 1292 | end
|
---|
| 1293 | end
|
---|
| 1294 |
|
---|
| 1295 | %------------------------------------------------------------------------
|
---|
| 1296 | function num_first_i_Callback(hObject, eventdata, handles)
|
---|
| 1297 | %------------------------------------------------------------------------
|
---|
| 1298 | num_last_i_Callback(hObject, eventdata, handles)
|
---|
| 1299 |
|
---|
| 1300 | %------------------------------------------------------------------------
|
---|
| 1301 | function num_last_i_Callback(hObject, eventdata, handles)
|
---|
| 1302 | %------------------------------------------------------------------------
|
---|
| 1303 | SeriesData=get(handles.series,'UserData');
|
---|
| 1304 | if ~isfield(SeriesData,'Time')
|
---|
| 1305 | SeriesData.Time{1}=[];
|
---|
| 1306 | end
|
---|
| 1307 | displ_time(handles);
|
---|
| 1308 |
|
---|
| 1309 | %------------------------------------------------------------------------
|
---|
| 1310 | function num_first_j_Callback(hObject, eventdata, handles)
|
---|
| 1311 | %------------------------------------------------------------------------
|
---|
| 1312 | num_last_j_Callback(hObject, eventdata, handles)
|
---|
| 1313 |
|
---|
| 1314 | %------------------------------------------------------------------------
|
---|
| 1315 | function num_last_j_Callback(hObject, eventdata, handles)
|
---|
| 1316 | %------------------------------------------------------------------------
|
---|
| 1317 | % first_j=str2num(get(handles.num_first_j,'String'));
|
---|
| 1318 | % last_j=str2num(get(handles.num_last_j,'String'));
|
---|
| 1319 | % ref_j=ceil((first_j+last_j)/2);
|
---|
| 1320 | % set(handles.num_ref_j,'String', num2str(ref_j))
|
---|
| 1321 | % num_ref_j_Callback(hObject, eventdata, handles)
|
---|
| 1322 | SeriesData=get(handles.series,'UserData');
|
---|
| 1323 | if ~isfield(SeriesData,'Time')
|
---|
| 1324 | SeriesData.Time{1}=[];
|
---|
| 1325 | end
|
---|
| 1326 | displ_time(handles);
|
---|
| 1327 |
|
---|
| 1328 | %------------------------------------------------------------------------
|
---|
| 1329 | % ---- find the times corresponding to the first and last indices of a series
|
---|
| 1330 | function displ_time(handles)
|
---|
| 1331 | %------------------------------------------------------------------------
|
---|
| 1332 | SeriesData=get(handles.series,'UserData'); %
|
---|
| 1333 | if ~isfield(SeriesData,'Time')
|
---|
| 1334 | return
|
---|
| 1335 | end
|
---|
| 1336 | PairString=get(handles.PairString,'Data');
|
---|
| 1337 | ref_i_1=str2num(get(handles.num_first_i,'String')); % first reference index
|
---|
| 1338 | ref_i_2=str2num(get(handles.num_last_i,'String')); % last reference index
|
---|
| 1339 | ref_j_1=[];ref_j_2=[];
|
---|
| 1340 | if strcmp(get(handles.num_first_j,'Visible'),'on')
|
---|
| 1341 | ref_j_1=str2num(get(handles.num_first_j,'String'));
|
---|
| 1342 | ref_j_2=str2num(get(handles.num_last_j,'String'));
|
---|
| 1343 | end
|
---|
| 1344 | [i1_1,i2_1,j1_1,j2_1] = get_file_index(ref_i_1,ref_j_1,PairString);
|
---|
| 1345 | [i1_2,i2_2,j1_2,j2_2] = get_file_index(ref_i_2,ref_j_2,PairString);
|
---|
| 1346 | TimeTable=get(handles.TimeTable,'Data');
|
---|
| 1347 | %%%%%%
|
---|
| 1348 | %TODO: read time in netcdf file, see ActionName_Callback
|
---|
| 1349 | %%%%%%%
|
---|
| 1350 | %Pairs=get(handles.PairString,'Data');
|
---|
| 1351 | for iview=1:size(TimeTable,1)
|
---|
| 1352 | if size(SeriesData.Time,1)<iview
|
---|
| 1353 | break
|
---|
| 1354 | end
|
---|
| 1355 | TimeTable{iview,3}=[];
|
---|
| 1356 | TimeTable{iview,4}=[];
|
---|
| 1357 | if size(SeriesData.Time{iview},1)>=i2_2+1 && (isempty(ref_j_1)||size(SeriesData.Time{iview},2)>=j2_2+1)
|
---|
| 1358 | if isempty(ref_j_1)
|
---|
| 1359 | time_first=(SeriesData.Time{iview}(i1_1+1,2)+SeriesData.Time{iview}(i2_1+1,2))/2;
|
---|
| 1360 | time_last=(SeriesData.Time{iview}(i1_2+1,2)+SeriesData.Time{iview}(i2_2+1,2))/2;
|
---|
| 1361 | else
|
---|
| 1362 | time_first=(SeriesData.Time{iview}(i1_1+1,j1_1+1)+SeriesData.Time{iview}(i2_1+1,j2_1+1))/2;
|
---|
| 1363 | time_last=(SeriesData.Time{iview}(i1_2+1,j1_2+1)+SeriesData.Time{iview}(i2_2+1,j2_1+1))/2;
|
---|
| 1364 | end
|
---|
| 1365 | TimeTable{iview,3}=time_first; % TODO: take into account pairs
|
---|
| 1366 | TimeTable{iview,4}=time_last; % TODO: take into account pairs
|
---|
| 1367 | end
|
---|
| 1368 | end
|
---|
| 1369 | set(handles.TimeTable,'Data',TimeTable)
|
---|
| 1370 |
|
---|
| 1371 | %% set the waitbar position with respect to the min and max in the series
|
---|
| 1372 | MinIndex_i=min(get(handles.MinIndex_i,'Data'));
|
---|
| 1373 | MaxIndex_i=max(get(handles.MaxIndex_i,'Data'));
|
---|
| 1374 | pos_first=(ref_i_1-MinIndex_i)/(MaxIndex_i-MinIndex_i+1);
|
---|
| 1375 | pos_last=(ref_i_2-MinIndex_i+1)/(MaxIndex_i-MinIndex_i+1);
|
---|
| 1376 | if isempty(pos_first), pos_first=0; end
|
---|
| 1377 | if isempty(pos_last), pos_last=1; end
|
---|
| 1378 | Position=get(handles.Waitbar,'Position'); % position of the waitbar:= [ x,y, width, height]
|
---|
| 1379 | Position_status=get(handles.FileStatus,'Position');
|
---|
| 1380 | Position(1)=Position_status(1)+Position_status(3)*pos_first;
|
---|
| 1381 | Position(3)=max(Position_status(3)*(pos_last-pos_first),0.001); % width must remain positive
|
---|
| 1382 | set(handles.Waitbar,'Position',Position)
|
---|
| 1383 | update_waitbar(handles.Waitbar,0)
|
---|
| 1384 |
|
---|
| 1385 | %------------------------------------------------------------------------
|
---|
| 1386 | % --- Executes when selected cell(s) is changed in PairString.
|
---|
| 1387 | function PairString_CellSelectionCallback(hObject, eventdata, handles)
|
---|
| 1388 | %------------------------------------------------------------------------
|
---|
| 1389 | if numel(eventdata.Indices)>=1
|
---|
| 1390 | PairString=get(hObject,'Data');
|
---|
| 1391 | if ~isempty(PairString{eventdata.Indices(1)})
|
---|
| 1392 | SetPairs_Callback(hObject, eventdata.Indices(1), handles)
|
---|
| 1393 | end
|
---|
| 1394 | end
|
---|
| 1395 |
|
---|
| 1396 | %-------------------------------------
|
---|
| 1397 | function enable_i(handles,state)
|
---|
| 1398 | set(handles.i_txt,'Visible',state)
|
---|
| 1399 | set(handles.num_first_i,'Visible',state)
|
---|
| 1400 | set(handles.num_last_i,'Visible',state)
|
---|
| 1401 | set(handles.num_incr_i,'Visible',state)
|
---|
| 1402 |
|
---|
| 1403 | %-----------------------------------
|
---|
| 1404 | function enable_j(handles,state)
|
---|
| 1405 | set(handles.j_txt,'Visible',state)
|
---|
| 1406 | set(handles.num_first_j,'Visible',state)
|
---|
| 1407 | set(handles.num_last_j,'Visible',state)
|
---|
| 1408 | set(handles.num_incr_j,'Visible',state)
|
---|
| 1409 | set(handles.MinIndex_j,'Visible',state)
|
---|
| 1410 | set(handles.MaxIndex_j,'Visible',state)
|
---|
| 1411 |
|
---|
| 1412 |
|
---|
| 1413 | %%%%%%%%%%%%%%%%%%%%
|
---|
| 1414 | %% MAIN ActionName FUNCTIONS
|
---|
| 1415 | %%%%%%%%%%%%%%%%%%%%
|
---|
| 1416 | %------------------------------------------------------------------------
|
---|
| 1417 | % --- Executes on button press in RUN.
|
---|
| 1418 | %------------------------------------------------------------------------
|
---|
| 1419 | function RUN_Callback(hObject, eventdata, handles)
|
---|
| 1420 |
|
---|
| 1421 | %% settings of the button RUN
|
---|
| 1422 | if ~isequal(get(handles.ActionInput,'BackgroundColor'),[1 0 0])
|
---|
| 1423 | msgbox_uvmat('ERROR','first activate the button ActionInput')
|
---|
| 1424 | return
|
---|
| 1425 | end
|
---|
| 1426 | set(handles.RUN,'BusyAction','queue'); % activation of STOP button will set BusyAction to 'cancel'
|
---|
| 1427 | set(handles.RUN, 'Enable','Off')% avoid further RUN action until the current one is finished
|
---|
| 1428 | set(handles.RUN,'BackgroundColor',[1 1 0])%show activation of RUN by yellow color
|
---|
| 1429 | drawnow
|
---|
| 1430 | set(handles.status,'Value',0)% desable status display if relevant
|
---|
| 1431 | status_Callback([], eventdata, handles)
|
---|
| 1432 |
|
---|
| 1433 | %% launch action
|
---|
| 1434 | errormsg=launch_action(handles);
|
---|
| 1435 | if ~isempty(errormsg)
|
---|
| 1436 | msgbox_uvmat('ERROR',errormsg)
|
---|
| 1437 | end
|
---|
| 1438 |
|
---|
| 1439 | %% reset the GUI series
|
---|
| 1440 | update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate launching is finished
|
---|
| 1441 | set(handles.RUN, 'Enable','On')
|
---|
| 1442 | set(handles.RUN,'BackgroundColor',[1 0 0])
|
---|
| 1443 | set(handles.RUN, 'Value',0)
|
---|
| 1444 |
|
---|
| 1445 | %------------------------------------------------------------------------
|
---|
| 1446 | % --- called by RUN_Callback
|
---|
| 1447 | %------------------------------------------------------------------------
|
---|
| 1448 | % The calculations are launched in three different ways:
|
---|
| 1449 | % RunMode='local': calculation on the local Matlab session, will prevent other actions during that time.
|
---|
| 1450 | % RunMode='background': calculation on the local computer, but in a new Matlab session (with no graphic output).
|
---|
| 1451 | % RunMode='cluster': calculations dispatched in a cluster, using a managing system, 'oar, 'sge, or 'sgb'.
|
---|
| 1452 | % In the latter case, the calculation is split in 'packets' of i index (all j indices are contained in a single packet).
|
---|
| 1453 | % This splitting is possible only if the different calculations in the series are independent. Otherwise the action
|
---|
| 1454 | % function imposes a number of processes NbSlice in input, for instance NbSlice=1 for a time series.
|
---|
| 1455 | % If NbSlice is not imposed, the splitting in packets (jobs) is determined
|
---|
| 1456 | % so that a job is optimum length AdvisedJobCPUTime), and the total job number in any case smaller
|
---|
| 1457 | % than MaxJobNumber (these parameters are defined in the file series.xml in
|
---|
| 1458 | % accordance with the management strategy for the cluster). The jobs are
|
---|
| 1459 | % dispatched in parallel into NbCore processors by the cluster managing system.
|
---|
| 1460 |
|
---|
| 1461 | function errormsg=launch_action(handles)
|
---|
| 1462 | errormsg=''; % default
|
---|
| 1463 |
|
---|
| 1464 | %% read the data on the GUI series
|
---|
| 1465 | Param=read_GUI_series(handles); % displayed parameters
|
---|
| 1466 | SeriesData=get(handles.series,'UserData'); % hidden parameters
|
---|
| 1467 | if isfield(SeriesData,'TransformInput')
|
---|
| 1468 | Param.TransformInput=SeriesData.TransformInput;
|
---|
| 1469 | end
|
---|
| 1470 | if isfield(SeriesData,'ProjObject')
|
---|
| 1471 | Param.ProjObject=SeriesData.ProjObject;
|
---|
| 1472 | end
|
---|
| 1473 | if ~isfield(SeriesData,'i1_series')
|
---|
| 1474 | errormsg='The input field series needs to be refreshed: press REFRESH';
|
---|
| 1475 | return
|
---|
| 1476 | end
|
---|
| 1477 | if isfield(Param,'InputFields')&& isfield(Param.InputFields,'FieldName')&& isequal(Param.InputFields.FieldName,'add_field...')
|
---|
| 1478 | errormsg='input field name(s) not defined, select add_field...';
|
---|
| 1479 | return
|
---|
| 1480 | end
|
---|
| 1481 |
|
---|
| 1482 | %% select the Action mode, 'local', 'background' or 'cluster' (if available)
|
---|
| 1483 | RunMode='local'; % default (needed for first opening of the GUI series)
|
---|
| 1484 | if isfield(Param.Action,'RunMode')
|
---|
| 1485 | RunMode=Param.Action.RunMode;
|
---|
| 1486 | Param.Action=rmfield(Param.Action,'RunMode'); % remove from the recorded xml file to avoid interference during ImportConfig
|
---|
| 1487 | Param.RunMode=RunMode; % keep track of the mode
|
---|
| 1488 | end
|
---|
| 1489 | ActionExt='.m'; % default
|
---|
| 1490 | if isfield(Param.Action,'ActionExt')
|
---|
| 1491 | ActionExt=Param.Action.ActionExt; % '.m', '.sh' (compiled) or '.py' (Python)
|
---|
| 1492 | Param.Action=rmfield(Param.Action,'ActionExt'); % remove from the recorded xml file to avoid interference during ImportConfig
|
---|
| 1493 | end
|
---|
| 1494 | ActionName=Param.Action.ActionName;
|
---|
| 1495 | ActionPath=Param.Action.ActionPath;
|
---|
| 1496 | path_series=fileparts(which('series'));
|
---|
| 1497 |
|
---|
| 1498 | %% create the Action fct handle if RunMode option = 'local'
|
---|
| 1499 | if strcmp(RunMode,'local')
|
---|
| 1500 | if ~isequal(ActionPath,path_series)
|
---|
| 1501 | eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION
|
---|
| 1502 | if ~exist(ActionPath,'dir')
|
---|
| 1503 | errormsg=['The prescribed function path ' ActionPath ' does not exist'];
|
---|
| 1504 | return
|
---|
| 1505 | end
|
---|
| 1506 | if ~isequal(spath,ActionPath)
|
---|
| 1507 | addpath(ActionPath)% add the prescribed path if not the current one
|
---|
| 1508 | end
|
---|
| 1509 | end
|
---|
| 1510 | eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION
|
---|
| 1511 | if ~isequal(ActionPath,path_series)
|
---|
| 1512 | rmpath(ActionPath)% add the prescribed path if not the current one
|
---|
| 1513 | end
|
---|
| 1514 | end
|
---|
| 1515 |
|
---|
| 1516 | %% Get parameters from series.xml
|
---|
| 1517 | errormsg=''; % default error message
|
---|
| 1518 | ActionFullName=fullfile(get(handles.ActionPath,'String'),ActionName);
|
---|
| 1519 |
|
---|
| 1520 | %% If a compiled version has been selected (ext .sh) check wether it needs to be recompiled
|
---|
| 1521 | if strcmp(ActionExt,'.sh')
|
---|
| 1522 | TransformPath='';
|
---|
| 1523 | if isfield(SeriesData,'TransformPath')
|
---|
| 1524 | TransformPath=SeriesData.TransformPath;
|
---|
| 1525 | if isfield(SeriesData,'TransformList')
|
---|
| 1526 | TransformList=get(handles.TransformName,'String');
|
---|
| 1527 | TransformIndex=get(handles.TransformName,'Value');
|
---|
| 1528 | TransformName=TransformList{TransformIndex};
|
---|
| 1529 | if ~ismember(TransformName,SeriesData.TransformList)
|
---|
| 1530 | TransformPath='';
|
---|
| 1531 | end
|
---|
| 1532 | end
|
---|
| 1533 | end
|
---|
| 1534 | if ~isempty(TransformPath)&&...
|
---|
| 1535 | ~strcmp(TransformPath,get(handles.TransformPath,'String'))% if the transform is not in paths set for compilation
|
---|
| 1536 | msgbox_uvmat('ERROR', 'compilation not available for this transform function, select .m')
|
---|
| 1537 | return
|
---|
| 1538 | end
|
---|
| 1539 | set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch'
|
---|
| 1540 | set(handles.ActionExt,'BackgroundColor',[1 1 0])
|
---|
| 1541 | [mcrmajor, mcrminor] = mcrversion;
|
---|
| 1542 | MCRROOT = ['MCRROOT',int2str(mcrmajor),int2str(mcrminor)];
|
---|
| 1543 | RunTime = getenv('MCRROOT'); % Just variable MCRROOT with no version in it's name
|
---|
| 1544 | if strcmp(RunTime,'')
|
---|
| 1545 | RunTime = getenv(MCRROOT); % Use specialize MCRROOT with version
|
---|
| 1546 | end
|
---|
| 1547 | ActionNameVersion=[ActionName '_' MCRROOT];
|
---|
| 1548 | ActionFullName=fullfile(get(handles.ActionPath,'String'),[ActionNameVersion '.sh']);
|
---|
| 1549 | % compile the .m file if the .sh file does not exist yet
|
---|
| 1550 | if ~exist(ActionFullName,'file')
|
---|
| 1551 | answer=msgbox_uvmat('INPUT_Y-N','compiled version has not been created: compile now?');
|
---|
| 1552 | if strcmp(answer,'Yes')
|
---|
| 1553 | set(handles.ActionExt,'BackgroundColor',[1 1 0])
|
---|
| 1554 | path_uvmat=fileparts(which('series'));
|
---|
| 1555 | currentdir=pwd;
|
---|
| 1556 | cd(get(handles.ActionPath,'String'))% go to the directory of Action
|
---|
| 1557 | addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'
|
---|
| 1558 | compile(ActionName,TransformPath)
|
---|
| 1559 | cd(currentdir)
|
---|
| 1560 | else
|
---|
| 1561 | errormsg='Action launch interrupted';
|
---|
| 1562 | return
|
---|
| 1563 | end
|
---|
| 1564 | else
|
---|
| 1565 | sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionNameVersion '.sh']));
|
---|
| 1566 | m_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.m']));
|
---|
| 1567 | if isfield(m_file_info,'datenum') && m_file_info.datenum>sh_file_info.datenum
|
---|
| 1568 | set(handles.ActionExt,'BackgroundColor',[1 1 0])
|
---|
| 1569 | drawnow
|
---|
| 1570 | answer=msgbox_uvmat('INPUT_Y-N',[ActionNameVersion '.sh needs to be updated: recompile now?']);
|
---|
| 1571 | if strcmp(answer,'Yes')
|
---|
| 1572 | path_uvmat=fileparts(which('series'));
|
---|
| 1573 | currentdir=pwd;
|
---|
| 1574 | cd(get(handles.ActionPath,'String'))% go to the directory of Action
|
---|
| 1575 | addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'
|
---|
| 1576 | addpath(fullfile(path_uvmat,'transform_field'))% add the path to transform functions to run the fct 'compile'
|
---|
| 1577 | compile(ActionName,TransformPath)
|
---|
| 1578 | cd(currentdir)
|
---|
| 1579 | end
|
---|
| 1580 | end
|
---|
| 1581 | end
|
---|
| 1582 |
|
---|
| 1583 | set(handles.ActionExt,'BackgroundColor',[1 1 1])
|
---|
| 1584 | set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch
|
---|
| 1585 | end
|
---|
| 1586 |
|
---|
| 1587 | %% set nbre of cluster cores and processes:
|
---|
| 1588 | % NbCore is the number of computer processors used
|
---|
| 1589 | % NbProcess is the number of independent processes in which the required calculation is split.
|
---|
| 1590 | % switch RunMode
|
---|
| 1591 | % case {'local','background'}
|
---|
| 1592 | % NbCore=1; % no need to split the calculation
|
---|
| 1593 | % case 'cluster'
|
---|
| 1594 | % %proposed number of cores to reserve in the cluster
|
---|
| 1595 | % NbCoreAdvised=SeriesData.SeriesParam.ClusterParam.NbCoreAdvised;
|
---|
| 1596 | % NbCoreMax=min(NbProcess,SeriesData.SeriesParam.ClusterParam.NbCoreMax);
|
---|
| 1597 | % if NbCoreMax~=1
|
---|
| 1598 | % if strcmp(ActionExt,'.m')% case of Matlab function (uncompiled)
|
---|
| 1599 | % warning_string=', preferably use .sh option to save Matlab licences';
|
---|
| 1600 | % else
|
---|
| 1601 | % warning_string=')';
|
---|
| 1602 | % end
|
---|
| 1603 | % answer=msgbox_uvmat('INPUT_TXT',['Number of cores (max ' num2str(NbCoreMax) ', ' warning_string],num2str(NbCoreAdvised));
|
---|
| 1604 | % if isempty(answer)
|
---|
| 1605 | % errormsg='Action launch interrupted by user';
|
---|
| 1606 | % return
|
---|
| 1607 | % end
|
---|
| 1608 | % NbCore=str2double(answer);
|
---|
| 1609 | % if NbCore > NbCoreMax
|
---|
| 1610 | % NbCore=NbCoreMax;
|
---|
| 1611 | % end
|
---|
| 1612 | % else
|
---|
| 1613 | % NbCore=1;
|
---|
| 1614 | % end
|
---|
| 1615 | % end
|
---|
| 1616 | if ~isfield(Param.IndexRange,'NbSlice')
|
---|
| 1617 | Param.IndexRange.NbSlice=[];
|
---|
| 1618 | end
|
---|
| 1619 | OutputPath=get(handles.OutputPath,'String');
|
---|
| 1620 |
|
---|
| 1621 | %% Look for processing on multiple experiments set by the GUI browse_data
|
---|
| 1622 | NbExp=1;% initiate the number of experiments set by the GUI browse_data, =1 otherwise
|
---|
| 1623 | if get(handles.Replicate,'Value')
|
---|
| 1624 | hh=findobj(allchild(0),'Tag','browse_data');
|
---|
| 1625 | if isempty(hh)
|
---|
| 1626 | set(handles.Replicate,'Value',0)
|
---|
| 1627 | else
|
---|
| 1628 | set(handles.Replicate,'BackgroundColor',[1 1 0])%paint Relicate button in yellow
|
---|
| 1629 | BrowseData=guidata(hh);
|
---|
| 1630 | SourceDir=get(BrowseData.SourceDir,'String');
|
---|
| 1631 | ListExp=get(BrowseData.ListExperiments,'String');
|
---|
| 1632 | ExpIndices=get(BrowseData.ListExperiments,'Value');
|
---|
| 1633 | ListExp=ListExp(ExpIndices);
|
---|
| 1634 | ListDevices=get(BrowseData.ListDevices,'String');
|
---|
| 1635 | DeviceIndices=get(BrowseData.ListDevices,'Value');
|
---|
| 1636 | ListDevices=ListDevices(DeviceIndices);
|
---|
| 1637 | ListDataSeries=get(BrowseData.DataSeries,'String');
|
---|
| 1638 | DataSeriesIndices=get(BrowseData.DataSeries,'Value');
|
---|
| 1639 | ListDataSeries=ListDataSeries(DataSeriesIndices);
|
---|
| 1640 | NbExp=0; % counter of the number of experiments set by the GUI browse_data
|
---|
| 1641 | for iexp=1:numel(ListExp)
|
---|
| 1642 | if ~isempty(regexp(ListExp{iexp},'^\+/'))% if it is a folder
|
---|
| 1643 | %if strcmp(get(BrowseData.DataSeries,'enable'),'off') %case of a multiple input line for series
|
---|
| 1644 | % NbExp=NbExp+1;
|
---|
| 1645 | % ExpIndex{NbExp}=iexp;
|
---|
| 1646 | % for idevice=1:numel(ListDevices)
|
---|
| 1647 | % lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),...
|
---|
| 1648 | % regexprep(ListDevices{idevice},'^\+/',''));
|
---|
| 1649 | % lpathout=fullfile(OutputPath,regexprep(ListExp{iexp},'^\+/',''),...
|
---|
| 1650 | % regexprep(ListDevices{idevice},'^\+/',''));
|
---|
| 1651 | % ldir=regexprep(ListDataSeries{idevice},'^\+/','');
|
---|
| 1652 | % ListPath{idevice,NbExp}=lpath;
|
---|
| 1653 | % ListPathOut{idevice,NbExp}=lpathout;
|
---|
| 1654 | % ListSubdir{idevice,NbExp}=ldir;
|
---|
| 1655 | % end
|
---|
| 1656 | %else
|
---|
| 1657 | for idevice=1:numel(ListDevices)
|
---|
| 1658 | if ~isempty(regexp(ListDevices{idevice},'^\+/'))% if it is a folder
|
---|
| 1659 | for isubdir=1:numel(ListDataSeries)
|
---|
| 1660 | if ~isempty(regexp(ListDataSeries{isubdir},'^\+/'))% if it is a folder
|
---|
| 1661 | lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),...
|
---|
| 1662 | regexprep(ListDevices{idevice},'^\+/',''));
|
---|
| 1663 | lpathout= fullfile(OutputPath,regexprep(ListExp{iexp},'^\+/',''),...
|
---|
| 1664 | regexprep(ListDevices{idevice},'^\+/',''));
|
---|
| 1665 | ldir= regexprep(ListDataSeries{isubdir},'^\+/','');
|
---|
| 1666 | if exist(fullfile(lpath,ldir),'dir')
|
---|
| 1667 | NbExp=NbExp+1;
|
---|
| 1668 | ExpIndex(NbExp)=ExpIndices(iexp);
|
---|
| 1669 | DeviceIndex(NbExp)=DeviceIndices(idevice);
|
---|
| 1670 | ListPath{NbExp}=lpath;
|
---|
| 1671 | ListPathOut{NbExp}=lpathout;
|
---|
| 1672 | ListDeviceOut{NbExp}=regexprep(ListDevices{idevice},'^\+/','');
|
---|
| 1673 | ListExpOut{NbExp}=regexprep(ListExp{iexp},'^\+/','');
|
---|
| 1674 | ListSubdir{NbExp}=ldir;
|
---|
| 1675 | end
|
---|
| 1676 | end
|
---|
| 1677 | end
|
---|
| 1678 | end
|
---|
| 1679 | end
|
---|
| 1680 | % end
|
---|
| 1681 | end
|
---|
| 1682 | end
|
---|
| 1683 | answer=msgbox_uvmat('INPUT_Y-N-Cancel',['replicate the processing on ' num2str(NbExp) ' data series']);
|
---|
| 1684 | if strcmp(answer,'Cancel')||strcmp(answer,'No')
|
---|
| 1685 | return
|
---|
| 1686 | end
|
---|
| 1687 | end
|
---|
| 1688 | end
|
---|
| 1689 |
|
---|
| 1690 | %%%%%%%%%%%%%%%%%%% LOOP ON EXPERIMENTS POSSIBLY SET BY THE GUI browse_data, NbExp=1 otherwise %%%%%%%%%
|
---|
| 1691 |
|
---|
| 1692 | for iexp=1:NbExp
|
---|
| 1693 | if get(handles.Replicate,'Value')
|
---|
| 1694 | if ~strcmp(get(handles.RUN,'BusyAction'),'queue')% allow for STOP action
|
---|
| 1695 | disp('program stopped by user')
|
---|
| 1696 | return
|
---|
| 1697 | end
|
---|
| 1698 | set(BrowseData.ListExperiments,'Value',ExpIndex(iexp))
|
---|
| 1699 | set(BrowseData.ListDevices,'Value',DeviceIndex(iexp))
|
---|
| 1700 | Param.InputTable(:,1)=ListPath(:,iexp);
|
---|
| 1701 | Param.InputTable(:,2)=ListSubdir(:,iexp);
|
---|
| 1702 | OutputSubDir=unique(ListSubdir(:,iexp));
|
---|
| 1703 | Param.OutputSubDir=OutputSubDir{1};
|
---|
| 1704 | if numel(OutputSubDir)>1% case
|
---|
| 1705 | for iout=2:numel(OutputSubDir)
|
---|
| 1706 | Param.OutputSubDir=[Param.OutputSubDir '-' OutputSubDir{iout}];
|
---|
| 1707 | end
|
---|
| 1708 | end
|
---|
| 1709 | end
|
---|
| 1710 | [xx,ExpName]=fileparts(Param.InputTable{1,1});
|
---|
| 1711 | Param.IndexRange.first_i=str2num(get(handles.num_first_i,'String'));%reset the firrst_i and last_i for multiple experiments, modified by the splitting into NbProcess
|
---|
| 1712 | Param.IndexRange.last_i=str2num(get(handles.num_last_i,'String'));
|
---|
| 1713 |
|
---|
| 1714 | %% create the output data directory if needed, after checking its existence
|
---|
| 1715 | OutputDir='';
|
---|
| 1716 | answer='';
|
---|
| 1717 | if isfield(Param,'OutputSubDir')&& isfield(Param,'OutputDirExt')% possibly update the output dir if it already exists
|
---|
| 1718 | PathOut=get(handles.OutputPath,'String');
|
---|
| 1719 | if ~exist(PathOut,'dir') % test if the dir already exist
|
---|
| 1720 | PathOut=uigetdir(PathOut,'pick the output root path');
|
---|
| 1721 | set(handles.OutputPath,'String',PathOut);
|
---|
| 1722 | end
|
---|
| 1723 | if get(handles.Replicate,'Value')
|
---|
| 1724 | PathExpOut=fileparts(ListPath{iexp});
|
---|
| 1725 | PathExpDeviceOut=ListPath{iexp};
|
---|
| 1726 | else
|
---|
| 1727 | PathExpOut=fullfile(PathOut,get(handles.Experiment,'String'));
|
---|
| 1728 | PathExpDeviceOut=fullfile(PathExpOut,get(handles.Device,'String'))
|
---|
| 1729 | end
|
---|
| 1730 | if ~exist(PathExpOut,'dir')
|
---|
| 1731 | [tild,msg1]=mkdir(PathExpOut);
|
---|
| 1732 | if ~strcmp(msg1,'')
|
---|
| 1733 | errormsg=['cannot create ' PathExpOut ': ' msg1]; % error message for directory creation
|
---|
| 1734 | return
|
---|
| 1735 | end
|
---|
| 1736 | end
|
---|
| 1737 | if ~exist(PathExpDeviceOut,'dir')
|
---|
| 1738 | [tild,msg1]=mkdir(PathExpDeviceOut);
|
---|
| 1739 | if ~strcmp(msg1,'')
|
---|
| 1740 | errormsg=['cannot create ' PathExpDeviceOut ': ' msg1]; % error message for directory creation
|
---|
| 1741 | return
|
---|
| 1742 | end
|
---|
| 1743 | end
|
---|
| 1744 |
|
---|
| 1745 | SubDirOut=[Param.OutputSubDir Param.OutputDirExt];
|
---|
| 1746 | SubDirOutNew=SubDirOut;
|
---|
| 1747 | detect=exist(fullfile(PathExpDeviceOut,SubDirOutNew),'dir'); % test if the dir already exist
|
---|
| 1748 | check_create=1; % need to create the result directory by default
|
---|
| 1749 | CheckOverwrite=1;
|
---|
| 1750 | if isfield(Param,'CheckOverwrite')
|
---|
| 1751 | CheckOverwrite=Param.CheckOverwrite;% will overwrite previous data if it is equal to 1
|
---|
| 1752 | end
|
---|
| 1753 | while detect
|
---|
| 1754 | if CheckOverwrite
|
---|
| 1755 | comment=', possibly overwrite previous data';
|
---|
| 1756 | else
|
---|
| 1757 | comment=', will complement existing result files (no overwriting)';
|
---|
| 1758 | end
|
---|
| 1759 | answer=msgbox_uvmat('INPUT_Y-N-Cancel',['use existing ouput directory: ' fullfile(PathExpDeviceOut,SubDirOutNew) comment]);
|
---|
| 1760 | if strcmp(answer,'Cancel')
|
---|
| 1761 | break
|
---|
| 1762 | elseif strcmp(answer,'Yes')
|
---|
| 1763 | detect=0;
|
---|
| 1764 | check_create=0;
|
---|
| 1765 | else
|
---|
| 1766 | r=regexp(SubDirOutNew,'(?<root>.*\D)(?<num1>\d+)$','names'); % detect whether name ends by a number
|
---|
| 1767 | if isempty(r)
|
---|
| 1768 | r(1).root=[SubDirOutNew '_'];
|
---|
| 1769 | r(1).num1='0';
|
---|
| 1770 | end
|
---|
| 1771 | SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)]; % increment the index by 1 or put 1
|
---|
| 1772 | detect=exist(fullfile(PathExpDeviceOut,SubDirOutNew),'dir'); % test if the dir already exists
|
---|
| 1773 | check_create=1;
|
---|
| 1774 | end
|
---|
| 1775 | end
|
---|
| 1776 | if strcmp(answer,'Cancel')
|
---|
| 1777 | continue
|
---|
| 1778 | end
|
---|
| 1779 | Param.OutputDirExt=regexprep(SubDirOutNew,['^' Param.OutputSubDir],'');
|
---|
| 1780 | Param.OutputRootFile=Param.InputTable{1,3}; % the first sorted RootFile taken for output
|
---|
| 1781 | OutputDir=fullfile(PathExpDeviceOut,[Param.OutputSubDir Param.OutputDirExt]); % full name (with path) of output directory
|
---|
| 1782 | if check_create % create output directory if it does not exist
|
---|
| 1783 | [tild,msg1]=mkdir(OutputDir);
|
---|
| 1784 | if ~strcmp(msg1,'')
|
---|
| 1785 | errormsg=['cannot create ' OutputDir ': ' msg1]; % error message for directory creation
|
---|
| 1786 | return
|
---|
| 1787 | end
|
---|
| 1788 | end
|
---|
| 1789 |
|
---|
| 1790 | elseif isfield(Param,'ActionInput')&&isfield(Param.ActionInput,'LogPath')% custom definition of the output dir
|
---|
| 1791 | OutputDir=Param.ActionInput.LogPath;
|
---|
| 1792 | end
|
---|
| 1793 | if isfield(Param,'OutputSubDir')&& isfield(Param,'OutputDirExt')
|
---|
| 1794 | set(handles.OutputSubDir,'String',Param.OutputSubDir)
|
---|
| 1795 | set(handles.OutputDirExt,'String',Param.OutputDirExt)
|
---|
| 1796 | drawnow
|
---|
| 1797 | end
|
---|
| 1798 | if get(handles.Replicate,'Value')
|
---|
| 1799 | set(handles.InputTable,'Data',Param.InputTable)
|
---|
| 1800 | set(handles.OutputPath,'String',OutputPath)
|
---|
| 1801 | set(handles.Experiment,'String',ListExpOut{iexp})
|
---|
| 1802 | set(handles.Device,'String',ListDeviceOut{iexp})
|
---|
| 1803 | Param.Experiment=ListExpOut{iexp};
|
---|
| 1804 | Param.Device=ListDeviceOut{iexp};
|
---|
| 1805 | check_input_file_series(handles)
|
---|
| 1806 | end
|
---|
| 1807 | DirXml=fullfile(OutputDir,'0_XML');
|
---|
| 1808 | if ~exist(DirXml,'dir')
|
---|
| 1809 | [~,msg1]=mkdir(DirXml);
|
---|
| 1810 | if ~strcmp(msg1,'')
|
---|
| 1811 | errormsg=['cannot create ' DirXml ': ' msg1]; % error message for directory creation
|
---|
| 1812 | return
|
---|
| 1813 | end
|
---|
| 1814 | [success,msg] = fileattrib(DirXml,'+w','g','s'); % allow writing access for the group of users, recursively in the folder
|
---|
| 1815 | if success==0
|
---|
| 1816 | msgbox_uvmat('WARNING',{['unable to set group write access to ' DirXml ':']; msg}); % error message for directory creation
|
---|
| 1817 | end
|
---|
| 1818 | end
|
---|
| 1819 | OutputNomType=nomtype2pair(Param.InputTable{1,4}); % nomenclature for output files
|
---|
| 1820 |
|
---|
| 1821 | %% get the set of reference input field indices
|
---|
| 1822 | first_i=1; % first i index to process
|
---|
| 1823 | last_i=1; % last i index to process
|
---|
| 1824 | incr_i=1; % increment step in i index
|
---|
| 1825 | first_j=1; % first j index to process
|
---|
| 1826 | last_j=1; % last j index to process
|
---|
| 1827 | incr_j=1; % increment step in j index
|
---|
| 1828 | if isfield(Param.IndexRange,'first_i')
|
---|
| 1829 | first_i=Param.IndexRange.first_i;
|
---|
| 1830 | incr_i=Param.IndexRange.incr_i;
|
---|
| 1831 | last_i=Param.IndexRange.last_i;
|
---|
| 1832 | end
|
---|
| 1833 | if isfield(Param.IndexRange,'incr_j')
|
---|
| 1834 | first_j=Param.IndexRange.first_j;
|
---|
| 1835 | last_j=Param.IndexRange.last_j;
|
---|
| 1836 | incr_j=Param.IndexRange.incr_j;
|
---|
| 1837 | end
|
---|
| 1838 | if last_i < first_i || last_j < first_j
|
---|
| 1839 | errormsg= 'series/Run_Callback:last field index must be larger or equal to the first one';
|
---|
| 1840 | return
|
---|
| 1841 | end
|
---|
| 1842 | %incr_i must be defined, =1 by default, if NbSlice is active
|
---|
| 1843 | if isempty(incr_i)&& ~isempty(Param.IndexRange.NbSlice)
|
---|
| 1844 | incr_i=1;
|
---|
| 1845 | set(handles.num_incr_i,'String','1')
|
---|
| 1846 | end
|
---|
| 1847 | % case of no increment i defined: processing is done on the available files found in i1_series
|
---|
| 1848 | if isempty(incr_i)
|
---|
| 1849 | if isempty(incr_j)
|
---|
| 1850 | [ref_j,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
|
---|
| 1851 | ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
|
---|
| 1852 | ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
|
---|
| 1853 | ref_j=ref_j-1;
|
---|
| 1854 | ref_i=ref_i-1;
|
---|
| 1855 | else
|
---|
| 1856 | ref_j=first_j:incr_j:last_j;
|
---|
| 1857 | [tild,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
|
---|
| 1858 | ref_i=ref_i-1;
|
---|
| 1859 | ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
|
---|
| 1860 | end
|
---|
| 1861 | % increment i is defined: processing is done on first_i:incr_i:last_i;
|
---|
| 1862 | else
|
---|
| 1863 | ref_i=first_i:incr_i:last_i;
|
---|
| 1864 | if isempty(incr_j)% automatic finding of the existing j indices
|
---|
| 1865 | [ref_j,tild]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
|
---|
| 1866 | ref_j=ref_j-1;
|
---|
| 1867 | ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
|
---|
| 1868 | else
|
---|
| 1869 | ref_j=first_j:incr_j:last_j;
|
---|
| 1870 | end
|
---|
| 1871 | end
|
---|
| 1872 | nbfield_j=numel(ref_j); % number of j indices
|
---|
| 1873 | BlockLength=numel(ref_i); % by default, job involves the full set of i field indicesNbProcess
|
---|
| 1874 | NbProcess=1;
|
---|
| 1875 | NbCore=1;
|
---|
| 1876 | switch RunMode
|
---|
| 1877 | case 'cluster'
|
---|
| 1878 | if (isfield(Param.Action, 'CPUTime') && ~isempty(Param.Action.CPUTime) && isnumeric(Param.Action.CPUTime))
|
---|
| 1879 | CPUTime=Param.Action.CPUTime; % Note: CpUTime for one iteration ref_i has to be multiplied by the number of j indices nbfield_j
|
---|
| 1880 | else
|
---|
| 1881 | answer=msgbox_uvmat('INPUT_TXT','estimate the CPU time(in minutes) for each value of index i:' ,'');
|
---|
| 1882 | CPUTime=str2num(answer);
|
---|
| 1883 | set(handles.num_CPUTime,'String',answer)
|
---|
| 1884 | Param.Action.CPUTime=CPUTime;
|
---|
| 1885 | end
|
---|
| 1886 | JobNumberMax=SeriesData.SeriesParam.ClusterParam.JobNumberMax;
|
---|
| 1887 | JobCPUTimeAdvised=SeriesData.SeriesParam.ClusterParam.JobCPUTimeAdvised;
|
---|
| 1888 | if isempty(Param.IndexRange.NbSlice)% if NbSlice is not defined
|
---|
| 1889 | BlockLength= ceil(JobCPUTimeAdvised/(CPUTime*nbfield_j)); % iterations are grouped in sets with length BlockLength such that the typical CPU time of a job is JobCPUTimeAdvised.
|
---|
| 1890 | BlockLength=max(BlockLength,ceil(numel(ref_i)*NbExp/JobNumberMax)); % possibly increase the BlockLength to have less than MaxJobNumber jobs
|
---|
| 1891 | NbProcess=ceil(numel(ref_i)/BlockLength) ; % nbre of processes sent to oar
|
---|
| 1892 | else
|
---|
| 1893 | NbProcess=Param.IndexRange.NbSlice; % the parameter NbSlice sets the nbre of run processes
|
---|
| 1894 | end
|
---|
| 1895 |
|
---|
| 1896 | % %proposed number of cores to reserve in the cluster
|
---|
| 1897 | NbCoreAdvised=SeriesData.SeriesParam.ClusterParam.NbCoreAdvised;
|
---|
| 1898 | NbCoreMax=min(NbProcess,SeriesData.SeriesParam.ClusterParam.NbCoreMax);% reduces the number of cores if it exceeds the number of processes
|
---|
| 1899 | if NbCoreMax~=1
|
---|
| 1900 | if strcmp(ActionExt,'.m')% case of Matlab function (uncompiled)
|
---|
| 1901 | warning_string=', preferably use .sh option to save Matlab licences';
|
---|
| 1902 | else
|
---|
| 1903 | warning_string=')';
|
---|
| 1904 | end
|
---|
| 1905 | answer=msgbox_uvmat('INPUT_TXT',['Number of cores (max ' num2str(NbCoreMax) ', ' warning_string],num2str(NbCoreAdvised));
|
---|
| 1906 | if isempty(answer)
|
---|
| 1907 | errormsg='Action launch interrupted by user';
|
---|
| 1908 | return
|
---|
| 1909 | end
|
---|
| 1910 | NbCore=str2double(answer);
|
---|
| 1911 | if NbCore > NbCoreMax
|
---|
| 1912 | NbCore=NbCoreMax;
|
---|
| 1913 | end
|
---|
| 1914 | end
|
---|
| 1915 | otherwise
|
---|
| 1916 | if ~isempty(Param.IndexRange.NbSlice)
|
---|
| 1917 | NbProcess=Param.IndexRange.NbSlice; % the parameter NbSlice sets the nbre of run processes
|
---|
| 1918 | end
|
---|
| 1919 | end
|
---|
| 1920 |
|
---|
| 1921 | %% record nbre of output files and starting time for computation for status
|
---|
| 1922 | StatusData=get(handles.status,'UserData');
|
---|
| 1923 | if isfield(StatusData,'OutputFileMode')
|
---|
| 1924 | switch StatusData.OutputFileMode
|
---|
| 1925 | case 'NbInput'
|
---|
| 1926 | StatusData.NbOutputFile=numel(ref_i)*nbfield_j;
|
---|
| 1927 | case 'NbInput_i'
|
---|
| 1928 | StatusData.NbOutputFile=numel(ref_i);
|
---|
| 1929 | case 'NbSlice'
|
---|
| 1930 | StatusData.NbOutputFile=str2num(get(handles.num_NbSlice,'String'));
|
---|
| 1931 | end
|
---|
| 1932 | end
|
---|
| 1933 | StatusData.TimeStart=now;
|
---|
| 1934 | set(handles.status,'UserData',StatusData)
|
---|
| 1935 |
|
---|
| 1936 | %% case of a function in Python
|
---|
| 1937 | if strcmp(ActionExt, '.py (in dev.)')
|
---|
| 1938 | fprintf([
|
---|
| 1939 | '\n' ...
|
---|
| 1940 | '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n' ...
|
---|
| 1941 | 'The option .py is used. It is still in development.\n' ...
|
---|
| 1942 | 'To try it, first install pyper and the most recent version of fluidimage\n' ...
|
---|
| 1943 | '(see https://bitbucket.org/fluiddyn/fluidimage).\n' ...
|
---|
| 1944 | 'Warning: there is no direct correspondance between UVMAT and fluidimage parameters\n' ...
|
---|
| 1945 | '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n'])
|
---|
| 1946 | RunMode = 'python';
|
---|
| 1947 | end
|
---|
| 1948 |
|
---|
| 1949 |
|
---|
| 1950 | %% direct processing on the current Matlab session or creation of command files
|
---|
| 1951 | filexml=cell(1,NbProcess); % initialisation of the names of the files containing the processing parameters
|
---|
| 1952 | extxml=cell(1,NbProcess); % initialisation of the set of labels used for the files documenting each process
|
---|
| 1953 | for iprocess=1:NbProcess
|
---|
| 1954 | extxml{iprocess}='.xml';
|
---|
| 1955 | end
|
---|
| 1956 | for iprocess=1:NbProcess
|
---|
| 1957 | if ~strcmp(get(handles.RUN,'BusyAction'),'queue')% allow for STOP action
|
---|
| 1958 | disp('program stopped by user')
|
---|
| 1959 | return
|
---|
| 1960 | end
|
---|
| 1961 | Param.IndexRange.incr_slice=incr_i;
|
---|
| 1962 | if isempty(Param.IndexRange.NbSlice)
|
---|
| 1963 | Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i;
|
---|
| 1964 | if Param.IndexRange.first_i>last_i
|
---|
| 1965 | NbProcess=iprocess-1; % leave the loop, we are at the end of the calculation
|
---|
| 1966 | break
|
---|
| 1967 | end
|
---|
| 1968 | Param.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength*incr_i-1);
|
---|
| 1969 | else %multislices (then incr_i is not empty)
|
---|
| 1970 | Param.IndexRange.first_i= first_i+iprocess-1;
|
---|
| 1971 | Param.IndexRange.incr_slice=incr_i*Param.IndexRange.NbSlice;
|
---|
| 1972 | end
|
---|
| 1973 | for ilist=1:size(Param.InputTable,1)
|
---|
| 1974 | Param.InputTable{ilist,1}=regexprep(Param.InputTable{ilist,1},'\','/'); % correct path name for PCWIN system
|
---|
| 1975 | end
|
---|
| 1976 |
|
---|
| 1977 | if isfield(Param,'OutputSubDir')
|
---|
| 1978 | t=struct2xml(Param);
|
---|
| 1979 | t=set(t,1,'name','Series');
|
---|
| 1980 | extxml{iprocess}=fullfile_uvmat('','',Param.InputTable{1,3},'.xml',OutputNomType,...
|
---|
| 1981 | Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j);
|
---|
| 1982 | filexml{iprocess}=fullfile(OutputDir,'0_XML',extxml{iprocess});
|
---|
| 1983 | try
|
---|
| 1984 | save(t, filexml{iprocess}); % save the xml file containing the processing parameters
|
---|
| 1985 | catch ME
|
---|
| 1986 | if ~strcmp (RunMode,'local')
|
---|
| 1987 | errormsg=['error writting ' filexml{iprocess} ': ' ME.message];
|
---|
| 1988 | return
|
---|
| 1989 | end
|
---|
| 1990 | end
|
---|
| 1991 | end
|
---|
| 1992 | if strcmp (RunMode,'local')
|
---|
| 1993 | switch ActionExt
|
---|
| 1994 | case '.m'
|
---|
| 1995 | h_fun(Param); % direct launching
|
---|
| 1996 |
|
---|
| 1997 | case '.sh'
|
---|
| 1998 | switch computer
|
---|
| 1999 | case {'PCWIN','PCWIN64'} %Windows system
|
---|
| 2000 | filexml=regexprep(filexml,'\\','\\\\'); % add '\' so that '\' are left as characters
|
---|
| 2001 | system([ActionFullName ' ' RunTime ' ' filexml{iprocess}]); % TODO: adapt to DOS system
|
---|
| 2002 | case {'GLNX86','GLNXA64','MACI64'}%Linux system
|
---|
| 2003 | system([ActionFullName ' ' RunTime ' ' filexml{iprocess}]);
|
---|
| 2004 | end
|
---|
| 2005 | end
|
---|
| 2006 | end
|
---|
| 2007 | end
|
---|
| 2008 |
|
---|
| 2009 | if ~strcmp (RunMode,'local') && ~strcmp(RunMode,'python')
|
---|
| 2010 | %% processing on a different session of the same computer (background) or cluster, create executable files
|
---|
| 2011 | batch_file_list=cell(NbProcess,1); % initiate the list of executable files
|
---|
| 2012 | DirExe=fullfile(OutputDir,'0_EXE'); % directory name for executable files
|
---|
| 2013 | switch computer
|
---|
| 2014 | case {'PCWIN','PCWIN64'} %Windows system
|
---|
| 2015 | ExeExt='.bat';
|
---|
| 2016 | case {'GLNX86','GLNXA64','MACI64'}%Linux system
|
---|
| 2017 | ExeExt='.sh';
|
---|
| 2018 | end
|
---|
| 2019 | %create subdirectory for executable files
|
---|
| 2020 | if ~exist(DirExe,'dir')
|
---|
| 2021 | [tild,msg1]=mkdir(DirExe);
|
---|
| 2022 | if ~strcmp(msg1,'')
|
---|
| 2023 | errormsg=['cannot create ' DirExe ': ' msg1]; % error message for directory creation
|
---|
| 2024 | return
|
---|
| 2025 | end
|
---|
| 2026 | [success,msg] = fileattrib(DirExe,'+w','g','s'); % allow writing access for the group of users, recursively in the folder
|
---|
| 2027 | if success==0
|
---|
| 2028 | msgbox_uvmat('WARNING',{['unable to set group write access to ' DirExe ':']; msg}); % error message for directory creation
|
---|
| 2029 | end
|
---|
| 2030 | end
|
---|
| 2031 | %create subdirectory for log files
|
---|
| 2032 | DirLog=fullfile(OutputDir,'0_LOG');
|
---|
| 2033 | if ~exist(DirLog,'dir')
|
---|
| 2034 | [tild,msg1]=mkdir(DirLog);
|
---|
| 2035 | if ~strcmp(msg1,'')
|
---|
| 2036 | errormsg=['cannot create ' DirLog ': ' msg1]; % error message for directory creation
|
---|
| 2037 | return
|
---|
| 2038 | end
|
---|
| 2039 | [success,msg] = fileattrib(DirLog,'+w','g','s'); % allow writing access for the group of users, recursively in the folder
|
---|
| 2040 | if success==0
|
---|
| 2041 | msgbox_uvmat('WARNING',{['unable to set group write access to ' DirLog ':']; msg}); % error message for directory creation
|
---|
| 2042 | end
|
---|
| 2043 | end
|
---|
| 2044 |
|
---|
| 2045 | %create the executable file
|
---|
| 2046 | file_exe_global=fullfile_uvmat('','',Param.InputTable{1,3},ExeExt,OutputNomType,...
|
---|
| 2047 | first_i,last_i,first_j,last_j);
|
---|
| 2048 | file_exe_global=fullfile(OutputDir,'0_EXE',file_exe_global);
|
---|
| 2049 | filelog_global=fullfile_uvmat('','',Param.InputTable{1,3},'.log',OutputNomType,...
|
---|
| 2050 | first_i,last_i,first_j,last_j);
|
---|
| 2051 | filelog_global=fullfile(OutputDir,'0_LOG',filelog_global);
|
---|
| 2052 |
|
---|
| 2053 | for iprocess=1:NbProcess
|
---|
| 2054 | %create the executable file
|
---|
| 2055 | batch_file_list{iprocess}=fullfile(OutputDir,'0_EXE',regexprep(extxml{iprocess},'.xml$',ExeExt));
|
---|
| 2056 |
|
---|
| 2057 | % set the log file name
|
---|
| 2058 | filelog{iprocess}=fullfile(OutputDir,'0_LOG',regexprep(extxml{iprocess},'.xml$','.log'));
|
---|
| 2059 | end
|
---|
| 2060 | end
|
---|
| 2061 |
|
---|
| 2062 | %% launch the executable files for background or cluster processing
|
---|
| 2063 |
|
---|
| 2064 | switch RunMode
|
---|
| 2065 |
|
---|
| 2066 | case 'background'
|
---|
| 2067 | [fid,message]=fopen(file_exe_global,'w');
|
---|
| 2068 | if isequal(fid,-1)
|
---|
| 2069 | errormsg=['creation of ' file_exe_global ':' message];
|
---|
| 2070 | return
|
---|
| 2071 | end
|
---|
| 2072 | switch ActionExt
|
---|
| 2073 | case '.m'% Matlab function
|
---|
| 2074 | switch computer
|
---|
| 2075 | case {'GLNX86','GLNXA64','MACI64'}
|
---|
| 2076 | matlab_ver = ver('MATLAB');
|
---|
| 2077 | matlab_version = matlab_ver.Version;
|
---|
| 2078 | cmd=[...
|
---|
| 2079 | '#!/bin/bash\n'...
|
---|
| 2080 | 'source /etc/profile\n'...
|
---|
| 2081 | 'module load matlab/' matlab_version '\n'...% CHOICE OF MATLAB VERSION
|
---|
| 2082 | 'time_start=$(date +%%s)\n'...
|
---|
| 2083 | 'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog_global ''' <<END_MATLAB\n'...
|
---|
| 2084 | 'addpath(''' path_series ''');\n'...
|
---|
| 2085 | 'addpath(''' Param.Action.ActionPath ''');\n'];
|
---|
| 2086 | for iprocess=1:NbProcess
|
---|
| 2087 | cmd=[cmd '' Param.Action.ActionName '(''' filexml{iprocess} ''');\n'];
|
---|
| 2088 | end
|
---|
| 2089 | cmd=[cmd 'exit\n' 'END_MATLAB\n'...
|
---|
| 2090 | 'time_end=$(date +%%s)\n'...
|
---|
| 2091 | 'echo "global time = " $(($time_end - $time_start)) >> ''' filelog_global '''\n'];
|
---|
| 2092 | fprintf(fid,cmd); % fill the executable file with the char string cmd
|
---|
| 2093 | fclose(fid); % close the executable filefilelog_global
|
---|
| 2094 | system(['chmod +x ' file_exe_global]); % set the file to executable
|
---|
| 2095 | case {'PCWIN','PCWIN64'}
|
---|
| 2096 | cmd=['matlab -automation -logfile ' regexprep(filelog{iprocess},'\\','\\\\')...
|
---|
| 2097 | ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'...
|
---|
| 2098 | 'addpath(''' regexprep(Param.Action.ActionPath,'\\','\\\\') ''');'];
|
---|
| 2099 | for iprocess=1:NbProcess
|
---|
| 2100 | cmd=[cmd '' Param.Action.ActionName '( ''' regexprep(filexml{iprocess},'\\','\\\\') ''');']
|
---|
| 2101 | end
|
---|
| 2102 | cmd=[cmd ';exit"'];
|
---|
| 2103 | fprintf(fid,cmd); % fill the executable file with the char string cmd
|
---|
| 2104 | fclose(fid); % close the executable file
|
---|
| 2105 | end
|
---|
| 2106 | system([file_exe_global ' &'])% directly execute the command file
|
---|
| 2107 | case '.sh' % compiled Matlab function
|
---|
| 2108 | for iprocess=1:NbProcess
|
---|
| 2109 | switch computer
|
---|
| 2110 | case {'GLNX86','GLNXA64','MACI64'}
|
---|
| 2111 | [fid,message]=fopen(batch_file_list{iprocess},'w'); % create the executable file
|
---|
| 2112 | if isequal(fid,-1)
|
---|
| 2113 | errormsg=['creation of .bat file: ' message];
|
---|
| 2114 | return
|
---|
| 2115 | end
|
---|
| 2116 | cmd=['#!/bin/bash \n '...
|
---|
| 2117 | '#$ -cwd \n '...
|
---|
| 2118 | 'hostname && date \n '...
|
---|
| 2119 | 'umask 002 \n'...
|
---|
| 2120 | ActionFullName ' ' RunTime ' ' filexml{iprocess}]; % allow writting access to created files for user group
|
---|
| 2121 | fprintf(fid,cmd); % fill the executable file with the char string cmd
|
---|
| 2122 | fclose(fid); % close the executable file
|
---|
| 2123 | system(['chmod +x ' batch_file_list{iprocess}]); % set the file to executable
|
---|
| 2124 | system([batch_file_list{iprocess} ' &'])% directly execute the command file
|
---|
| 2125 | case {'PCWIN','PCWIN64'}
|
---|
| 2126 | msgbox_uvmat('ERROR','option for compiled Matlab functions not implemented for Windows system')
|
---|
| 2127 | return
|
---|
| 2128 | end
|
---|
| 2129 | end
|
---|
| 2130 | msgbox_uvmat('CONFIRMATION',[ActionFullName ' launched in background for ' ExpName ': press STATUS to see results'])
|
---|
| 2131 | end
|
---|
| 2132 |
|
---|
| 2133 | case 'cluster' % option 'oar-parexec' used
|
---|
| 2134 | %create subdirectory for oar commands
|
---|
| 2135 | for iprocess=1:NbProcess
|
---|
| 2136 | [fid,message]=fopen(batch_file_list{iprocess},'w'); % create the executable file
|
---|
| 2137 | if isequal(fid,-1)
|
---|
| 2138 | errormsg=['creation of .bat file: ' message];
|
---|
| 2139 | return
|
---|
| 2140 | end
|
---|
| 2141 | if strcmp(ActionExt,'.sh')
|
---|
| 2142 | cmd=['#!/bin/bash \n '...
|
---|
| 2143 | '#$ -cwd \n '...
|
---|
| 2144 | 'hostname && date \n '...
|
---|
| 2145 | 'umask 002 \n'...
|
---|
| 2146 | ActionFullName ' ' RunTime ' ' filexml{iprocess}]; % allow writting access to created files for user group
|
---|
| 2147 | else
|
---|
| 2148 | matlab_ver = ver('MATLAB');
|
---|
| 2149 | matlab_version = matlab_ver.Version;
|
---|
| 2150 | cmd=[...
|
---|
| 2151 | '#!/bin/bash\n'...
|
---|
| 2152 | 'source /etc/profile\n'...
|
---|
| 2153 | 'module load matlab/' matlab_version '\n'...% CHOICE OF MATLAB VERSION
|
---|
| 2154 | 'matlab -nodisplay -nosplash -nojvm -singleCompThread -logfile ''' filelog{iprocess} ''' <<END_MATLAB\n'...
|
---|
| 2155 | 'addpath(''' path_series ''');\n'...
|
---|
| 2156 | 'addpath(''' Param.Action.ActionPath ''');\n'...
|
---|
| 2157 | '' Param.Action.ActionName '(''' filexml{iprocess} ''');\n'...
|
---|
| 2158 | 'exit\n'...
|
---|
| 2159 | 'END_MATLAB\n'];
|
---|
| 2160 | end
|
---|
| 2161 | fprintf(fid,cmd); % fill the executable file with the char string cmd
|
---|
| 2162 | fclose(fid); % close the executable file
|
---|
| 2163 | system(['chmod +x ' batch_file_list{iprocess}]); % set the file to executable
|
---|
| 2164 | end
|
---|
| 2165 | DIR_CLUSTER=fullfile(OutputDir,'0_CLUSTER');
|
---|
| 2166 | if exist(DIR_CLUSTER,'dir')% delete the content of the dir 0_LOG to allow new input
|
---|
| 2167 | curdir=pwd;
|
---|
| 2168 | cd(DIR_CLUSTER)
|
---|
| 2169 | delete('*')
|
---|
| 2170 | cd(curdir)
|
---|
| 2171 | else
|
---|
| 2172 | [tild,msg1]=mkdir(DIR_CLUSTER);
|
---|
| 2173 | if ~strcmp(msg1,'')
|
---|
| 2174 | errormsg=['cannot create ' DIR_CLUSTER ': ' msg1]; % error message for directory creation
|
---|
| 2175 | return
|
---|
| 2176 | end
|
---|
| 2177 | end
|
---|
| 2178 | % create file containing the list of jobs
|
---|
| 2179 | ListProcess=fullfile(DIR_CLUSTER,'job_list.txt'); % name of the file containing the list of executables
|
---|
| 2180 | [fid,errormsg]=fopen(ListProcess,'w'); % open it for writting
|
---|
| 2181 | if isempty(errormsg)
|
---|
| 2182 | for iprocess=1:length(batch_file_list)
|
---|
| 2183 | fprintf(fid,[batch_file_list{iprocess} '\n']); % write list of exe files
|
---|
| 2184 | end
|
---|
| 2185 | fclose(fid);
|
---|
| 2186 | system(['chmod +x ' ListProcess]); % set the file to executable
|
---|
| 2187 | else
|
---|
| 2188 | errormsg=['error for writting the executable file:' errormsg];
|
---|
| 2189 | end
|
---|
| 2190 | CPUTimeProcess=CPUTime*BlockLength*nbfield_j; % estimated CPU time for one individual process (in minutes)
|
---|
| 2191 | LaunchCmdFcn=SeriesData.SeriesParam.ClusterParam.LaunchCmdFcn;
|
---|
| 2192 | oar_command=feval(LaunchCmdFcn,ListProcess,ActionFullName,DirLog,NbProcess, NbCore,CPUTimeProcess)
|
---|
| 2193 | [status,result]=system(oar_command)% execute system command and show the result (ID number of the launched job) on the Matlab command window
|
---|
| 2194 | filename_oarcommand=fullfile(DIR_CLUSTER,'0_cluster_command'); % keep track of the command in file '0-OAR/0_cluster_command'
|
---|
| 2195 | [fid,errormsg]=fopen(filename_oarcommand,'w');
|
---|
| 2196 | if ~isempty(errormsg)
|
---|
| 2197 | msgbox_uvmat('ERROR',['cannot create ' filename_oarcommand ': ' errormsg])
|
---|
| 2198 | return
|
---|
| 2199 | end
|
---|
| 2200 | fprintf(fid,oar_command); % store the command
|
---|
| 2201 | fprintf(fid,result); % store the result (job ID number)
|
---|
| 2202 | fclose(fid);
|
---|
| 2203 | if status==0
|
---|
| 2204 | msgbox_uvmat('CONFIRMATION',[ActionFullName ' launched for ' ExpName ' as ' num2str(NbProcess) ' processes in cluster: press STATUS to see results'])
|
---|
| 2205 | else
|
---|
| 2206 | msgbox_uvmat('ERROR',result)
|
---|
| 2207 | end
|
---|
| 2208 | % case 'cluster_pbs' % for LMFA Kepler machine: trqnsferred to fct
|
---|
| 2209 |
|
---|
| 2210 | % %create subdirectory for pbs command and log files
|
---|
| 2211 | % DirPBS=fullfile(OutputDir,'0_PBS'); % todo : common name OAR/PBS
|
---|
| 2212 | % if exist(DirPBS,'dir')% delete the content of the dir 0_LOG to allow new input
|
---|
| 2213 | % curdir=pwd;
|
---|
| 2214 | % cd(DirPBS)
|
---|
| 2215 | % delete('*')
|
---|
| 2216 | % cd(curdir)
|
---|
| 2217 | % else
|
---|
| 2218 | % [tild,msg1]=mkdir(DirPBS);
|
---|
| 2219 | % if ~strcmp(msg1,'')
|
---|
| 2220 | % errormsg=['cannot create ' DirPBS ': ' msg1]; % error message for directory creation
|
---|
| 2221 | % return
|
---|
| 2222 | % end
|
---|
| 2223 | % end
|
---|
| 2224 | % max_walltime=3600*20; % 20h max total calculation (cannot exceed 24 h)
|
---|
| 2225 | % walltime_onejob=1800; % seconds, max estimated time for asingle file index value
|
---|
| 2226 | % ListProcess=fullfile(DirPBS,'job_list.txt'); % create name of the global executable file
|
---|
| 2227 | % fid=fopen(ListProcess,'w');
|
---|
| 2228 | % for iprocess=1:length(batch_file_list)
|
---|
| 2229 | % fprintf(fid,[batch_file_list{iprocess} '\n']); % list of exe files
|
---|
| 2230 | % end
|
---|
| 2231 | % fclose(fid);
|
---|
| 2232 | % system(['chmod +x ' ListProcess]); % set the file to executable
|
---|
| 2233 | % pbs_command=['qsub -n CIVX '...
|
---|
| 2234 | % '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '...
|
---|
| 2235 | % '-l /core=' num2str(NbCore) ','...
|
---|
| 2236 | % 'walltime=' datestr(min(1.05*walltime_onejob/86400*max(NbProcess*BlockLength*nbfield_j,NbCore)/NbCore,max_walltime/86400),13) ' '...
|
---|
| 2237 | % '-E ' regexprep(ListProcess,'\.txt\>','.stderr') ' '...
|
---|
| 2238 | % '-O ' regexprep(ListProcess,'\.txt\>','.log') ' '...
|
---|
| 2239 | % extra_qstat ' '...
|
---|
| 2240 | % '"oar-parexec -s -f ' ListProcess ' '...
|
---|
| 2241 | % '-l ' ListProcess '.log"'];
|
---|
| 2242 | % filename_oarcommand=fullfile(DirPBS,'pbs_command');
|
---|
| 2243 | % fid=fopen(filename_oarcommand,'w');
|
---|
| 2244 | % fprintf(fid,pbs_command);
|
---|
| 2245 | % fclose(fid);
|
---|
| 2246 | % fprintf(pbs_command); % display in command line
|
---|
| 2247 | % %system(pbs_command);
|
---|
| 2248 | % msgbox_uvmat('CONFIRMATION',[ActionFullName ' command ready to be launched in cluster'])
|
---|
| 2249 |
|
---|
| 2250 | case 'cluster_sge' % for PSMN % TODO: use the standard 'cluster' config with an external fct
|
---|
| 2251 | % Au PSMN, on ne cr??e pas 1 job avec plusieurs c??urs, mais N jobs de 1 c??urs
|
---|
| 2252 | % o?? N < 1000.
|
---|
| 2253 | %create subdirectory for pbs command and log files
|
---|
| 2254 |
|
---|
| 2255 | DirSGE=fullfile(OutputDir,'0_SGE');
|
---|
| 2256 | if exist(DirSGE,'dir')% delete the content of the dir 0_LOG to allow new input
|
---|
| 2257 | curdir=pwd;
|
---|
| 2258 | cd(DirSGE)
|
---|
| 2259 | delete('*')
|
---|
| 2260 | cd(curdir)
|
---|
| 2261 | else
|
---|
| 2262 | [tild,msg1]=mkdir(DirSGE);
|
---|
| 2263 | if ~strcmp(msg1,'')
|
---|
| 2264 | errormsg=['cannot create ' DirSGE ': ' msg1]; % error message for directory creation
|
---|
| 2265 | return
|
---|
| 2266 | end
|
---|
| 2267 | end
|
---|
| 2268 | maxImgsPerJob = ceil(length(batch_file_list)/NbCore);
|
---|
| 2269 | disp(['Max number of jobs: ' num2str(NbCore)])
|
---|
| 2270 | disp(['Images per job: ' num2str(maxImgsPerJob)])
|
---|
| 2271 |
|
---|
| 2272 | iprocess = 1;
|
---|
| 2273 | imgsInJob = [];
|
---|
| 2274 | currJobIndex = 1;
|
---|
| 2275 | done = 0;
|
---|
| 2276 | while(~done)
|
---|
| 2277 | if(iprocess <= length(batch_file_list))
|
---|
| 2278 | imgsInJob = [imgsInJob, iprocess];
|
---|
| 2279 | end
|
---|
| 2280 | if((numel(imgsInJob) >= maxImgsPerJob) || (iprocess == length(batch_file_list)))
|
---|
| 2281 | cmd=['#!/bin/sh \n'...
|
---|
| 2282 | '#$ -cwd \n'...
|
---|
| 2283 | 'hostname && date\n']
|
---|
| 2284 | for ii=1:numel(imgsInJob)
|
---|
| 2285 | cmd=[cmd ActionFullName ' /softs/matlab ' filexml{imgsInJob(ii)} '\n'];
|
---|
| 2286 | end
|
---|
| 2287 | [fid, message] = fopen([DirSGE '/job' num2str(currJobIndex) '.sh'], 'w');
|
---|
| 2288 | fprintf(fid, cmd);
|
---|
| 2289 | fclose(fid);
|
---|
| 2290 | system(['chmod +x ' DirSGE '/job' num2str(currJobIndex) '.sh'])
|
---|
| 2291 | sge_command=['qsub -N civ_' num2str(currJobIndex) ' '...
|
---|
| 2292 | '-q ' qstat_Queue ' '...
|
---|
| 2293 | '-e ' fullfile([DirSGE '/job' num2str(currJobIndex) '.out']) ' '...
|
---|
| 2294 | '-o ' fullfile([DirSGE '/job' num2str(currJobIndex) '.out']) ' '...
|
---|
| 2295 | fullfile([DirSGE '/job' num2str(currJobIndex) '.sh'])];
|
---|
| 2296 | fprintf(sge_command); % display in command line
|
---|
| 2297 | [status, result] = system(sge_command);
|
---|
| 2298 | fprintf(result);
|
---|
| 2299 | currJobIndex = currJobIndex + 1;
|
---|
| 2300 | imgsInJob = [];
|
---|
| 2301 | end
|
---|
| 2302 | if(iprocess == length(batch_file_list))
|
---|
| 2303 | done = 1;
|
---|
| 2304 | end
|
---|
| 2305 | iprocess = iprocess + 1;
|
---|
| 2306 | end
|
---|
| 2307 | msgbox_uvmat('CONFIRMATION',[num2str(currJobIndex-1) ' jobs launched on queue ' qstat_Queue '.'])
|
---|
| 2308 | case 'python'
|
---|
| 2309 | command = ['LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | pyp "l = x.split('':''); l = [s for s in l if ''matlab'' not in s]; print('':''.join(l))") ' ...
|
---|
| 2310 | 'python -m fluidimage.run_from_xml ' filexml{iprocess}];
|
---|
| 2311 | fprintf(['command:\n' command '\n\n'])
|
---|
| 2312 | system(command, '-echo');
|
---|
| 2313 | end
|
---|
| 2314 | if exist(OutputDir,'dir')
|
---|
| 2315 | [SUCCESS,MESSAGE,MESSAGEID] = fileattrib (OutputDir);
|
---|
| 2316 | if MESSAGE.GroupWrite~=1
|
---|
| 2317 | [success,msg] = fileattrib(OutputDir,'+w','g','s'); % allow writing access for the group of users, recursively in the folder
|
---|
| 2318 | if success==0
|
---|
| 2319 | msgbox_uvmat('WARNING',{['unable to set group write access to ' OutputDir ':']; msg}); % error message for directory creation
|
---|
| 2320 | end
|
---|
| 2321 | end
|
---|
| 2322 | end
|
---|
| 2323 | end
|
---|
| 2324 | set(handles.Replicate,'BackgroundColor',[0 1 0])
|
---|
| 2325 |
|
---|
| 2326 | %------------------------------------------------------------------------
|
---|
| 2327 | function STOP_Callback(hObject, eventdata, handles)
|
---|
| 2328 | %------------------------------------------------------------------------
|
---|
| 2329 | set(handles.RUN, 'BusyAction','cancel')
|
---|
| 2330 | set(handles.RUN,'BackgroundColor',[1 0 0])
|
---|
| 2331 | set(handles.RUN,'enable','on')
|
---|
| 2332 | set(handles.RUN, 'Value',0)
|
---|
| 2333 |
|
---|
| 2334 | %------------------------------------------------------------------------
|
---|
| 2335 | % --- read parameters from the GUI series
|
---|
| 2336 | %------------------------------------------------------------------------
|
---|
| 2337 | function Param=read_GUI_series(handles)
|
---|
| 2338 |
|
---|
| 2339 | %% read raw parameters from the GUI series
|
---|
| 2340 | Param=read_GUI(handles.series);
|
---|
| 2341 |
|
---|
| 2342 | %% clean the output structure by removing unused information
|
---|
| 2343 | if isfield(Param,'Pairs')
|
---|
| 2344 | Param=rmfield(Param,'Pairs'); % info Pairs not needed for output
|
---|
| 2345 | end
|
---|
| 2346 | if isfield(Param,'InputLine')
|
---|
| 2347 | Param=rmfield(Param,'InputLine');
|
---|
| 2348 | end
|
---|
| 2349 | if isfield(Param,'EditObject')
|
---|
| 2350 | Param=rmfield(Param,'EditObject');
|
---|
| 2351 | end
|
---|
| 2352 | Param.IndexRange.TimeSource=Param.IndexRange.TimeTable{end,1};
|
---|
| 2353 | Param.IndexRange=rmfield(Param.IndexRange,'TimeTable');
|
---|
| 2354 | empty_line=false(size(Param.InputTable,1),1);
|
---|
| 2355 | for iline=1:size(Param.InputTable,1)
|
---|
| 2356 | empty_line(iline)=isempty(cell2mat(Param.InputTable(iline,1:3)));
|
---|
| 2357 | end
|
---|
| 2358 | Param.InputTable(empty_line,:)=[];
|
---|
| 2359 |
|
---|
| 2360 | %------------------------------------------------------------------------
|
---|
| 2361 | % --- Executes on selection change in ActionName.
|
---|
| 2362 | function ActionName_Callback(hObject, ActionPath, handles)
|
---|
| 2363 | %------------------------------------------------------------------------
|
---|
| 2364 |
|
---|
| 2365 | %% stop any ongoing series processing
|
---|
| 2366 | if isequal(get(handles.RUN,'Value'),1)
|
---|
| 2367 | answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?');
|
---|
| 2368 | if strcmp(answer,'Yes')
|
---|
| 2369 | STOP_Callback(hObject, [], handles)
|
---|
| 2370 | else
|
---|
| 2371 | return
|
---|
| 2372 | end
|
---|
| 2373 | end
|
---|
| 2374 | set(handles.ActionName,'BackgroundColor',[1 1 0])
|
---|
| 2375 | huigetfile=findobj(allchild(0),'tag','status_display');
|
---|
| 2376 | if ~isempty(huigetfile)
|
---|
| 2377 | delete(huigetfile)
|
---|
| 2378 | end
|
---|
| 2379 | drawnow
|
---|
| 2380 |
|
---|
| 2381 | %% get Action name and path
|
---|
| 2382 | NbBuiltinAction=get(handles.Action,'UserData'); % nbre of functions initially proposed in the menu ActionName (as defined in the Opening fct of series)
|
---|
| 2383 | ActionList=get(handles.ActionName,'String'); % list menu fields
|
---|
| 2384 | ActionIndex=get(handles.ActionName,'Value');
|
---|
| 2385 | if ~isequal(ActionIndex,1)% if we are not just opening series
|
---|
| 2386 | InputTable=get(handles.InputTable,'Data');
|
---|
| 2387 | if isempty(InputTable{1,4})
|
---|
| 2388 | msgbox_uvmat('ERROR','no input file available: use Open in the menu bar')
|
---|
| 2389 | return
|
---|
| 2390 | end
|
---|
| 2391 | end
|
---|
| 2392 | ActionName= ActionList{get(handles.ActionName,'Value')}; % selected function name
|
---|
| 2393 | ActionPathList=get(handles.ActionName,'UserData'); % list of recorded paths to functions of the list ActionName
|
---|
| 2394 |
|
---|
| 2395 | %% add a new function to the menu if 'more...' has been selected in the menu ActionName
|
---|
| 2396 | if isequal(ActionName,'more...')
|
---|
| 2397 | if ~ischar(ActionPath)
|
---|
| 2398 | ActionPath=get(handles.ActionPath,'String');
|
---|
| 2399 | end
|
---|
| 2400 | [FileName, PathName] = uigetfile( ...
|
---|
| 2401 | {'*.m', ' (*.m)';
|
---|
| 2402 | '*.m', '.m files '; ...
|
---|
| 2403 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 2404 | 'Pick a series processing function ',ActionPath);
|
---|
| 2405 | if length(FileName)<2
|
---|
| 2406 | return
|
---|
| 2407 | end
|
---|
| 2408 | [tild,ActionName,ActionExt]=fileparts(FileName);
|
---|
| 2409 |
|
---|
| 2410 | % insert the choice in the menu ActionName
|
---|
| 2411 | ActionIndex=find(strcmp(ActionName,ActionList),1); % look for the selected function in the menu Action
|
---|
| 2412 | PathName=regexprep(PathName,'/$','');
|
---|
| 2413 | if ~isempty(ActionIndex) && ~strcmp(ActionPathList{ActionIndex},PathName)%compare the path to the existing fct
|
---|
| 2414 | ActionIndex=[]; % the selected path is different than the recorded one
|
---|
| 2415 | end
|
---|
| 2416 | if isempty(ActionIndex)%the qselected fct (with selected path) does not exist in the menu
|
---|
| 2417 | ActionIndex= length(ActionList);
|
---|
| 2418 | ActionList=[ActionList(1:end-1);{ActionName};ActionList(end)]; % the selected function is appended in the menu, before the last item 'more...'
|
---|
| 2419 | ActionPathList=[ActionPathList; PathName];
|
---|
| 2420 | end
|
---|
| 2421 |
|
---|
| 2422 | % record the file extension and extend the path list if it is a new extension
|
---|
| 2423 | ActionExtList=get(handles.ActionExt,'String');
|
---|
| 2424 | ActionExtIndex=find(strcmp(ActionExt,ActionExtList), 1);
|
---|
| 2425 | if isempty(ActionExtIndex)
|
---|
| 2426 | set(handles.ActionExt,'String',[ActionExtList;{ActionExt}])
|
---|
| 2427 | end
|
---|
| 2428 |
|
---|
| 2429 | % remove old Action options in the menu (keeping a menu length <nb_builtin_ACTION+5)
|
---|
| 2430 | if length(ActionList)>NbBuiltinAction+5; % nb_builtin_ACTION=nbre of functions always remaining in the initial menu
|
---|
| 2431 | nbremove=length(ActionList)-NbBuiltinAction-5;
|
---|
| 2432 | ActionList(NbBuiltinAction+1:end-5)=[];
|
---|
| 2433 | ActionPathList(NbBuiltinAction+1:end-4,:)=[];
|
---|
| 2434 | ActionIndex=ActionIndex-nbremove;
|
---|
| 2435 | end
|
---|
| 2436 |
|
---|
| 2437 | % record action menu, choice and path
|
---|
| 2438 | set(handles.ActionName,'Value',ActionIndex)
|
---|
| 2439 | set(handles.ActionName,'String',ActionList)
|
---|
| 2440 | set(handles.ActionName,'UserData',ActionPathList);
|
---|
| 2441 | set(handles.ActionExt,'Value',ActionExtIndex)
|
---|
| 2442 |
|
---|
| 2443 | %record the user defined menu additions in personal file profil_perso
|
---|
| 2444 | dir_perso=prefdir;
|
---|
| 2445 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 2446 | if NbBuiltinAction+1<=numel(ActionList)-1
|
---|
| 2447 | ActionListUser=ActionList(NbBuiltinAction+1:numel(ActionList)-1);
|
---|
| 2448 | ActionPathListUser=ActionPathList(NbBuiltinAction+1:numel(ActionList)-1);
|
---|
| 2449 | ActionExtListUser={};
|
---|
| 2450 | if numel(ActionExtList)>2
|
---|
| 2451 | ActionExtListUser=ActionExtList(3:end);
|
---|
| 2452 | end
|
---|
| 2453 | if exist(profil_perso,'file')
|
---|
| 2454 | save(profil_perso,'ActionListUser','ActionPathListUser','ActionExtListUser','-append')
|
---|
| 2455 | else
|
---|
| 2456 | save(profil_perso,'ActionListUser','ActionPathListUser','ActionExtListUser','-V6')
|
---|
| 2457 | end
|
---|
| 2458 | end
|
---|
| 2459 | end
|
---|
| 2460 |
|
---|
| 2461 | %% check the current ActionPath to the selected function
|
---|
| 2462 | ActionPath=ActionPathList{ActionIndex}; % current recorded path
|
---|
| 2463 | set(handles.ActionPath,'String',ActionPath); % show the path to the senlected function
|
---|
| 2464 |
|
---|
| 2465 | %% reinitialise the waitbar
|
---|
| 2466 | update_waitbar(handles.Waitbar,0)
|
---|
| 2467 |
|
---|
| 2468 | %% Put the first line of the selected Action fct as tooltip help
|
---|
| 2469 | try
|
---|
| 2470 | [fid,errormsg] =fopen([ActionName '.m']);
|
---|
| 2471 | InputText=textscan(fid,'%s',1,'delimiter','\n');
|
---|
| 2472 | fclose(fid);
|
---|
| 2473 | set(handles.ActionName,'ToolTipString',InputText{1}{1})% put the first line of the selected function as tooltip help
|
---|
| 2474 | end
|
---|
| 2475 | set(handles.ActionName,'BackgroundColor',[1 1 1])
|
---|
| 2476 | set(handles.ActionInput,'BackgroundColor',[1 0 1])% set ActionInput button to magenta color to indicate that input refr
|
---|
| 2477 | set(handles.num_CPUTime,'String','')
|
---|
| 2478 |
|
---|
| 2479 | % --- Executes on button press in ActionInput.
|
---|
| 2480 | function ActionInput_Callback(hObject, eventdata, handles)
|
---|
| 2481 |
|
---|
| 2482 | set(handles.ActionInput,'BackgroundColor',[1 1 0])
|
---|
| 2483 | SeriesData=get(handles.series,'UserData'); % info on the input file series
|
---|
| 2484 |
|
---|
| 2485 | %% create the function handle for Action
|
---|
| 2486 | ActionPath=get(handles.ActionPath,'String');
|
---|
| 2487 | ActionList=get(handles.ActionName,'String');
|
---|
| 2488 | ActionName= ActionList{get(handles.ActionName,'Value')}; % selected function name
|
---|
| 2489 | if ~exist(ActionPath,'dir')
|
---|
| 2490 | ActionName_Callback(handles.ActionName, ActionPath, handles)% update the function
|
---|
| 2491 | return
|
---|
| 2492 | end
|
---|
| 2493 | current_dir=pwd; % current working dir
|
---|
| 2494 | cd(ActionPath)
|
---|
| 2495 | h_fun=str2func(ActionName);% create the function handle for the function ActionName
|
---|
| 2496 | cd(current_dir)
|
---|
| 2497 |
|
---|
| 2498 | %% Activate the Action fct to adapt the configuration of the GUI series and bring specific parameters in SeriesData
|
---|
| 2499 | Param=read_GUI_series(handles); % read the parameters from the GUI series
|
---|
| 2500 | Param.Action.RUN=0;
|
---|
| 2501 | Param.SeriesData=SeriesData;
|
---|
| 2502 | ParamOut=h_fun(Param); % run the selected Action function to get the relevant input
|
---|
| 2503 |
|
---|
| 2504 |
|
---|
| 2505 | %% Visibility of VelType and VelType_1 menus asked by ActionName
|
---|
| 2506 | VelTypeRequest=1; % VelType requested by default
|
---|
| 2507 | VelTypeRequest_1=1; % VelType requested by default
|
---|
| 2508 | if isfield(ParamOut,'VelType')
|
---|
| 2509 | VelTypeRequest=ismember(ParamOut.VelType,{'on','one','two'});
|
---|
| 2510 | VelTypeRequest_1=strcmp( ParamOut.VelType,'two');
|
---|
| 2511 | end
|
---|
| 2512 | FieldNameRequest=0; %hidden by default
|
---|
| 2513 | FieldNameRequest_1=0; %hidden by default
|
---|
| 2514 | if isfield(ParamOut,'FieldName')
|
---|
| 2515 | FieldNameRequest=ismember(ParamOut.FieldName,{'on','one','two'});
|
---|
| 2516 | FieldNameRequest_1=strcmp( ParamOut.FieldName,'two');
|
---|
| 2517 | end
|
---|
| 2518 |
|
---|
| 2519 | %% Detect the types of input files and set menus and default options in 'VelType'
|
---|
| 2520 | if ~isfield(SeriesData,'FileType')
|
---|
| 2521 | SeriesData.FileType={'none'};
|
---|
| 2522 | end
|
---|
| 2523 | iview_civ=find( strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType));
|
---|
| 2524 | iview_netcdf=find(strcmp('netcdf',SeriesData.FileType)|strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType)); % all nc files, icluding civ
|
---|
| 2525 | FieldList=get(handles.FieldName,'String'); % previous list as default
|
---|
| 2526 | if ~iscell(FieldList),FieldList={FieldList};end
|
---|
| 2527 | FieldList_1=get(handles.FieldName_1,'String'); % previous list as default
|
---|
| 2528 | if ~iscell(FieldList_1),FieldList_1={FieldList_1};end
|
---|
| 2529 | CheckPivData_1=0; % indicate whether FieldName_1 has been updated with civ data, 0 by default
|
---|
| 2530 | handles_coord=[handles.Coord_x handles.Coord_y handles.Coord_z handles.Coord_x_title handles.Coord_y_title handles.Coord_z_title];
|
---|
| 2531 | if VelTypeRequest && numel(iview_civ)>=1
|
---|
| 2532 | menu=set_veltype_display(SeriesData.FileInfo{iview_civ(1)}.CivStage,SeriesData.FileType{iview_civ(1)});
|
---|
| 2533 | set(handles.VelType,'Value',1)% set first choice by default
|
---|
| 2534 | set(handles.VelType,'String',[{'*'};menu])
|
---|
| 2535 | set(handles.VelType,'Visible','on')
|
---|
| 2536 | set(handles.VelType_title,'Visible','on')
|
---|
| 2537 | FieldList=set_field_list('U','V'); % standard menu for civx data
|
---|
| 2538 | if max(get(handles.FieldName,'Value'))>numel(FieldList)
|
---|
| 2539 | set(handles.FieldName,'Value',1); % velocity vector choice by default
|
---|
| 2540 | end
|
---|
| 2541 | if VelTypeRequest_1 && numel(iview_civ)>=2
|
---|
| 2542 | menu=set_veltype_display(SeriesData.FileInfo{iview_civ(2)}.CivStage,SeriesData.FileType{iview_civ(2)});
|
---|
| 2543 | set(handles.VelType_1,'Value',1)% set first choice by default
|
---|
| 2544 | set(handles.VelType_1,'String',[{'*'};menu])
|
---|
| 2545 | set(handles.VelType_1,'Visible','on')
|
---|
| 2546 | set(handles.VelType_title_1,'Visible','on')
|
---|
| 2547 | FieldList_1=[set_field_list('U','V');{'C'};{'add_field...'}]; % standard menu for civx data
|
---|
| 2548 | CheckPivData_1=1;
|
---|
| 2549 | set(handles.FieldName_1,'Value',1); % velocity vector choice by default
|
---|
| 2550 | else
|
---|
| 2551 | set(handles.VelType_1,'Visible','off')
|
---|
| 2552 | set(handles.VelType_title_1,'Visible','off')
|
---|
| 2553 | end
|
---|
| 2554 | else
|
---|
| 2555 | set(handles.VelType,'Visible','off')
|
---|
| 2556 | set(handles.VelType_title,'Visible','off')
|
---|
| 2557 | end
|
---|
| 2558 |
|
---|
| 2559 | %% Detect the types of input files and set menus and default options in 'FieldName'
|
---|
| 2560 | if (FieldNameRequest || VelTypeRequest) && numel(iview_netcdf)>=1
|
---|
| 2561 | set(handles.InputFields,'Visible','on')% set the frame InputFields visible
|
---|
| 2562 | if FieldNameRequest && isfield(SeriesData.FileInfo{iview_netcdf(1)},'ListVarName')
|
---|
| 2563 | set(handles.FieldName,'Visible','on')
|
---|
| 2564 | set(handles.Field_text,'Visible','on')
|
---|
| 2565 | ListVarName=SeriesData.FileInfo{iview_netcdf(1)}.ListVarName;
|
---|
| 2566 | ind_var=get(handles.FieldName,'Value'); % indices of previously selected variables
|
---|
| 2567 | for ilist=1:numel(ind_var)
|
---|
| 2568 | if isempty(find(strcmp(FieldList{ind_var(ilist)},ListVarName)))
|
---|
| 2569 | FieldList={}; % previous choice not consistent with new input field
|
---|
| 2570 | set(handles.FieldName,'Value',1)
|
---|
| 2571 | break
|
---|
| 2572 | end
|
---|
| 2573 | end
|
---|
| 2574 | if ~isempty(FieldList)iview_netcdf
|
---|
| 2575 | if isempty(find(strcmp(get(handles.Coord_x,'String'),ListVarName)))||...
|
---|
| 2576 | isempty(find(strcmp(get(handles.Coord_y,'String'),ListVarName)))
|
---|
| 2577 | FieldList={};
|
---|
| 2578 | set(handles.Coord_x,'String','')
|
---|
| 2579 | set(handles.Coord_y,'String','')
|
---|
| 2580 | end
|
---|
| 2581 | Coord_z=get(handles.Coord_z,'String');
|
---|
| 2582 | if ~isempty(Coord_z) && isempty(find(strcmp(Coord_z,ListVarName)))REFRESH
|
---|
| 2583 | FieldList={};
|
---|
| 2584 | set(handles.Coord_z,'String','')
|
---|
| 2585 | end
|
---|
| 2586 | end
|
---|
| 2587 | else
|
---|
| 2588 | set(handles.FieldName,'Visible','off')
|
---|
| 2589 | set(handles.Field_text,'Visible','off')
|
---|
| 2590 | end
|
---|
| 2591 | set(handles_coord,'Visible','on')
|
---|
| 2592 | if isempty(find(strcmp('add_field...',FieldList)))
|
---|
| 2593 | FieldList=[FieldList;{'add_field...'}];%add 'add_field...' to the menu FieldName if it is not already
|
---|
| 2594 | end
|
---|
| 2595 | if FieldNameRequest_1 && numel(iview_netcdf)>=2
|
---|
| 2596 | set(handles.FieldName_1,'Visible','on')
|
---|
| 2597 | set(handles.Field_text_1,'Visible','on')
|
---|
| 2598 | if CheckPivData_1==0 % not civ input made
|
---|
| 2599 | FieldList_1={'add_field...'}
|
---|
| 2600 | ListVarName=SeriesData.FileInfo{iview_netcdf(2)}.ListVarName;
|
---|
| 2601 | ind_var=get(handles.FieldName,'Value'); % indices of previously selected variables
|
---|
| 2602 | for ilist=1:numel(ind_var)
|
---|
| 2603 | if isempty(find(strcmp(FieldList{ind_var(ilist)},ListVarName)))
|
---|
| 2604 | %FieldList_1={}; % previous choice not consistent with new input field
|
---|
| 2605 | set(handles.FieldName_1,'Value',1)
|
---|
| 2606 | break
|
---|
| 2607 | end
|
---|
| 2608 | end
|
---|
| 2609 | warn_coord=0;
|
---|
| 2610 | if isempty(find(strcmp(get(handles.Coord_x,'String'),ListVarName)))||...
|
---|
| 2611 | isempty(find(strcmp(get(handles.Coord_y,'String'),ListVarName)))
|
---|
| 2612 | warn_coord=1;
|
---|
| 2613 | end
|
---|
| 2614 | if ~isempty(Coord_z) && isempty(find(strcmp(Coord_z,ListVarName)))
|
---|
| 2615 | FieldList_1={'add_field...'};
|
---|
| 2616 | warn_coord=1;
|
---|
| 2617 | end
|
---|
| 2618 | if warn_coord
|
---|
| 2619 | msgbox_uvmat('WARNING','coordinate names do not exist in the second netcdf input file')
|
---|
| 2620 | end
|
---|
| 2621 |
|
---|
| 2622 | set(handles.FieldName_1,'Visible','on')
|
---|
| 2623 | set(handles.FieldName_1,'Value',1)
|
---|
| 2624 | set(handles.FieldName_1,'String',FieldList_1)
|
---|
| 2625 | end
|
---|
| 2626 | else
|
---|
| 2627 | set(handles.FieldName_1,'Visible','off')
|
---|
| 2628 | end
|
---|
| 2629 | if isempty(FieldList)
|
---|
| 2630 | set(handles.Field_text,'Visible','off')
|
---|
| 2631 | set(handles.FieldName,'Visible','off')
|
---|
| 2632 | else
|
---|
| 2633 | set(handles.Field_text,'Visible','on')
|
---|
| 2634 | set(handles.FieldName,'Visible','on')
|
---|
| 2635 | set(handles.FieldName,'String',FieldList)
|
---|
| 2636 | end
|
---|
| 2637 | else
|
---|
| 2638 | set(handles.InputFields,'Visible','off')
|
---|
| 2639 | end
|
---|
| 2640 |
|
---|
| 2641 | %% Introduce visibility of file overwrite option
|
---|
| 2642 | if isfield(ParamOut,'CheckOverwriteVisible')&& strcmp(ParamOut.CheckOverwriteVisible,'on')
|
---|
| 2643 | set(handles.CheckOverwrite,'Visible','on')
|
---|
| 2644 | else
|
---|
| 2645 | set(handles.CheckOverwrite,'Visible','off')
|
---|
| 2646 | end
|
---|
| 2647 |
|
---|
| 2648 | %% Check whether alphabetical sorting of input Subdir is allowed by the Action fct (for multiples series entries)
|
---|
| 2649 | if isfield(ParamOut,'AllowInputSort')&&isequal(ParamOut.AllowInputSort,'on')&& size(Param.InputTable,1)>1
|
---|
| 2650 | [tild,iview]=sort(Param.InputTable(:,2)); % subdirectories sorted in alphabetical order
|
---|
| 2651 | set(handles.InputTable,'Data',Param.InputTable(iview,:));
|
---|
| 2652 | MinIndex_i=get(handles.MinIndex_i,'Data');
|
---|
| 2653 | MinIndex_j=get(handles.MinIndex_j,'Data');
|
---|
| 2654 | MaxIndex_i=get(handles.MaxIndex_i,'Data');
|
---|
| 2655 | MaxIndex_j=get(handles.MaxIndex_j,'Data');
|
---|
| 2656 | set(handles.MinIndex_i,'Data',MinIndex_i(iview,:));
|
---|
| 2657 | set(handles.MinIndex_j,'Data',MinIndex_j(iview,:));
|
---|
| 2658 | set(handles.MaxIndex_i,'Data',MaxIndex_i(iview,:));
|
---|
| 2659 | set(handles.MaxIndex_j,'Data',MaxIndex_j(iview,:));
|
---|
| 2660 | TimeTable=get(handles.TimeTable,'Data');
|
---|
| 2661 | if size(TimeTable,1)<size(Param.InputTable,1)%if the time table is not complete, copy the missing lines from the previous ones
|
---|
| 2662 | for iline=size(TimeTable,1)+1:size(Param.InputTable,1)
|
---|
| 2663 | TimeTable(iline,:)=TimeTable(iline-1,:);
|
---|
| 2664 | end
|
---|
| 2665 | end
|
---|
| 2666 | set(handles.TimeTable,'Data',TimeTable(iview,:));% sort the time tables
|
---|
| 2667 | PairString=get(handles.PairString,'Data');
|
---|
| 2668 | set(handles.PairString,'Data',PairString(iview,:));
|
---|
| 2669 | end
|
---|
| 2670 |
|
---|
| 2671 | %% Impose the whole input file index range if requested
|
---|
| 2672 | if isfield(ParamOut,'WholeIndexRange')&&isequal(ParamOut.WholeIndexRange,'on')
|
---|
| 2673 | MinIndex_i=get(handles.MinIndex_i,'Data');
|
---|
| 2674 | MinIndex_j=get(handles.MinIndex_j,'Data');
|
---|
| 2675 | MaxIndex_i=get(handles.MaxIndex_i,'Data');
|
---|
| 2676 | MaxIndex_j=get(handles.MaxIndex_j,'Data');
|
---|
| 2677 | set(handles.num_first_i,'String',num2str(MinIndex_i(1)))% set first as the min index (for the first line)
|
---|
| 2678 | set(handles.num_last_i,'String',num2str(MaxIndex_i(1)))% set last as the max index (for the first line)
|
---|
| 2679 | set(handles.num_incr_i,'String','1')
|
---|
| 2680 | set(handles.num_first_j,'String',num2str(MinIndex_j(1)))% set first as the min index (for the first line)
|
---|
| 2681 | set(handles.num_last_j,'String',num2str(MaxIndex_j(1)))% set last as the max index (for the first line)
|
---|
| 2682 | set(handles.num_incr_j,'String','1')
|
---|
| 2683 | else % check index ranges
|
---|
| 2684 | first_i=1;last_i=1;first_j=1;last_j=1;
|
---|
| 2685 | if isfield(Param.IndexRange,'first_i')
|
---|
| 2686 | first_i=Param.IndexRange.first_i;
|
---|
| 2687 | last_i=Param.IndexRange.last_i;
|
---|
| 2688 | end
|
---|
| 2689 | if isfield(Param.IndexRange,'first_j')
|
---|
| 2690 | first_j=Param.IndexRange.first_j;
|
---|
| 2691 | last_j=Param.IndexRange.last_j;
|
---|
| 2692 | end
|
---|
| 2693 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
|
---|
| 2694 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end
|
---|
| 2695 | end
|
---|
| 2696 |
|
---|
| 2697 | %% enable or desable j index visibility
|
---|
| 2698 | status_j='on'; % default
|
---|
| 2699 | if isfield(SeriesData,'j1_series') && isempty(find(~cellfun(@isempty,SeriesData.j1_series), 1)) % case of empty j indices
|
---|
| 2700 | status_j='off'; % no j index needed
|
---|
| 2701 | elseif strcmp(get(handles.PairString,'Visible'),'on')
|
---|
| 2702 | check_burst=cellfun(@isempty,regexp(get(handles.PairString,'Data'),'^j')); % =0 for burst case, 1 otherwise
|
---|
| 2703 | if isempty(find(check_burst, 1))% if all pair string begins by j (burst)
|
---|
| 2704 | status_j='off'; % no j index needed for bust case
|
---|
| 2705 | end
|
---|
| 2706 | end
|
---|
| 2707 | enable_j(handles,status_j) % no j index needed
|
---|
| 2708 | if isfield(ParamOut,'j_index_1')&& isfield(ParamOut,'j_index_2')%strcmp(ParamOut.Desable_j_index,'on')
|
---|
| 2709 | %status_j='off';
|
---|
| 2710 | set(handles.num_first_j,'String',num2str(ParamOut.j_index_1))
|
---|
| 2711 | set(handles.num_last_j,'String',num2str(ParamOut.j_index_2))
|
---|
| 2712 | set(handles.num_first_j,'enable','off')
|
---|
| 2713 | set(handles.num_last_j,'enable','off')
|
---|
| 2714 | set(handles.num_incr_j,'visible','off')
|
---|
| 2715 | else
|
---|
| 2716 | set(handles.num_first_j,'enable','on')
|
---|
| 2717 | set(handles.num_last_j,'enable','on')
|
---|
| 2718 | set(handles.num_incr_j,'visible',status_j)
|
---|
| 2719 | end
|
---|
| 2720 |
|
---|
| 2721 | %% NbSlice visibility
|
---|
| 2722 | if isfield(ParamOut,'OutputFileMode')&& strcmp(ParamOut.OutputFileMode,'NbSlice')
|
---|
| 2723 | ParamOut.NbSlice='on';
|
---|
| 2724 | end
|
---|
| 2725 | if isfield(ParamOut,'NbSlice') && (strcmp(ParamOut.NbSlice,'on')||isnumeric(ParamOut.NbSlice))
|
---|
| 2726 | set(handles.num_NbSlice,'Visible','on')
|
---|
| 2727 | set(handles.NbSlice_title,'Visible','on')
|
---|
| 2728 | else
|
---|
| 2729 | set(handles.num_NbSlice,'Visible','off')
|
---|
| 2730 | set(handles.NbSlice_title,'Visible','off')
|
---|
| 2731 | end
|
---|
| 2732 | if isfield(ParamOut,'NbSlice') && isnumeric(ParamOut.NbSlice)
|
---|
| 2733 | set(handles.num_NbSlice,'String',num2str(ParamOut.NbSlice))
|
---|
| 2734 | set(handles.num_NbSlice,'Enable','off'); % NbSlice set by the activation of the Action function
|
---|
| 2735 | else
|
---|
| 2736 | set(handles.num_NbSlice,'Enable','on'); % NbSlice can be modified on the GUI series
|
---|
| 2737 | end
|
---|
| 2738 |
|
---|
| 2739 | %% Visibility of FieldTransform menu
|
---|
| 2740 | FieldTransformVisible='off'; %hidden by default
|
---|
| 2741 | if isfield(ParamOut,'FieldTransform')
|
---|
| 2742 | if ~strcmp(ParamOut.FieldTransform,'off')
|
---|
| 2743 | FieldTransformVisible='on';
|
---|
| 2744 | end
|
---|
| 2745 | if iscell(ParamOut.FieldTransform)
|
---|
| 2746 | SeriesData.TransformList=ParamOut.FieldTransform;
|
---|
| 2747 | end
|
---|
| 2748 | TransformName_Callback([],[], handles)
|
---|
| 2749 | end
|
---|
| 2750 | set(handles.FieldTransform,'Visible',FieldTransformVisible)
|
---|
| 2751 | if isfield(ParamOut,'TransformPath')% record the path of transform function requested for compilation
|
---|
| 2752 | set(handles.TransformPath,'UserData',ParamOut.TransformPath)
|
---|
| 2753 | else
|
---|
| 2754 | set(handles.TransformPath,'UserData',[])
|
---|
| 2755 | end
|
---|
| 2756 |
|
---|
| 2757 | %% Visibility of projection object
|
---|
| 2758 | ProjObjectVisible='off'; %hidden by default
|
---|
| 2759 | if isfield(ParamOut,'ProjObject')
|
---|
| 2760 | ProjObjectVisible=ParamOut.ProjObject;
|
---|
| 2761 | end
|
---|
| 2762 | set(handles.CheckObject,'Visible',ProjObjectVisible)
|
---|
| 2763 | if ~get(handles.CheckObject,'Value')
|
---|
| 2764 | ProjObjectVisible='off';
|
---|
| 2765 | end
|
---|
| 2766 | set(handles.ProjObjectName,'Visible',ProjObjectVisible)
|
---|
| 2767 | set(handles.DeleteObject,'Visible',ProjObjectVisible)
|
---|
| 2768 | set(handles.ViewObject,'Visible',ProjObjectVisible)
|
---|
| 2769 | set(handles.EditObject,'Visible',ProjObjectVisible)
|
---|
| 2770 |
|
---|
| 2771 | %% Visibility of mask input
|
---|
| 2772 | MaskVisible='off'; %hidden by default
|
---|
| 2773 | if isfield(ParamOut,'Mask')
|
---|
| 2774 | MaskVisible=ParamOut.Mask;
|
---|
| 2775 | end
|
---|
| 2776 | set(handles.CheckMask,'Visible',MaskVisible);
|
---|
| 2777 | %% Setting of expected iteration time
|
---|
| 2778 | if isfield(ParamOut,'CPUTime')
|
---|
| 2779 | set(handles.num_CPUTime,'String',num2str(ParamOut.CPUTime));
|
---|
| 2780 | end
|
---|
| 2781 |
|
---|
| 2782 | %% definition of the path for the output files
|
---|
| 2783 | InputTable=get(handles.InputTable,'Data');
|
---|
| 2784 | [OutputPath,Device,DeviceExt]=fileparts(InputTable{1,1});
|
---|
| 2785 | [OutputPath,Experiment,ExperimentExt]=fileparts(OutputPath);
|
---|
| 2786 | set(handles.Device,'String',[Device DeviceExt])
|
---|
| 2787 | set(handles.Device,'Visible','on')
|
---|
| 2788 | set(handles.Device_title,'Visible','on')
|
---|
| 2789 | set(handles.Experiment,'String',[Experiment ExperimentExt])
|
---|
| 2790 | set(handles.Experiment,'Visible','on')
|
---|
| 2791 | set(handles.Experiment_title,'Visible','on')
|
---|
| 2792 | set(handles.Experiment_title,'Visible','on')
|
---|
| 2793 | set(handles.OutputPath,'Visible','on')
|
---|
| 2794 | set(handles.OutputPathBrowse,'Visible','on')
|
---|
| 2795 |
|
---|
| 2796 | %% definition of the subdirectory containing the output files
|
---|
| 2797 |
|
---|
| 2798 | if ~(isfield(SeriesData,'ActionName') && strcmp(ActionName,SeriesData.ActionName))
|
---|
| 2799 | OutputDirExt='.series'; % default
|
---|
| 2800 | if isfield(ParamOut,'OutputDirExt')&&~isempty(ParamOut.OutputDirExt)
|
---|
| 2801 | OutputDirExt=ParamOut.OutputDirExt;
|
---|
| 2802 | end
|
---|
| 2803 | set(handles.OutputDirExt,'String',OutputDirExt)
|
---|
| 2804 | end
|
---|
| 2805 | OutputDirVisible='off';
|
---|
| 2806 | OutputSubDirMode='auto'; % default
|
---|
| 2807 | SubDirOut='';
|
---|
| 2808 | if isfield(ParamOut,'OutputSubDirMode')
|
---|
| 2809 | OutputSubDirMode=ParamOut.OutputSubDirMode;
|
---|
| 2810 | end
|
---|
| 2811 | switch OutputSubDirMode
|
---|
| 2812 | case 'auto' % default
|
---|
| 2813 | OutputDirVisible='on';
|
---|
| 2814 | SubDir=InputTable(1:end,2); % set of subdirectories
|
---|
| 2815 | SubDirOut=SubDir{1};
|
---|
| 2816 | if numel(SubDir)>1
|
---|
| 2817 | for ilist=2:numel(SubDir)
|
---|
| 2818 | SubDirOut=[SubDirOut '-' regexprep(SubDir{ilist},'^/','')];
|
---|
| 2819 | end
|
---|
| 2820 | end
|
---|
| 2821 | case 'one'
|
---|
| 2822 | OutputDirVisible='on';
|
---|
| 2823 | SubDirOut=InputTable{1,2}; % use the first subdir name (+OutputDirExt) as output subdirectory
|
---|
| 2824 | case 'two'
|
---|
| 2825 | OutputDirVisible='on';
|
---|
| 2826 | SubDir=InputTable(1:2,2); % set of subdirectories
|
---|
| 2827 | SubDirOut=SubDir{1};
|
---|
| 2828 | if numel(SubDir)>1
|
---|
| 2829 | SubDirOut=[SubDirOut '-' regexprep(SubDir{2},'^/','')];
|
---|
| 2830 | end
|
---|
| 2831 | case 'last'
|
---|
| 2832 | OutputDirVisible='on';
|
---|
| 2833 | SubDirOut=InputTable{end,2}; % use the last subdir name (+OutputDirExt) as output subdirectory
|
---|
| 2834 | end
|
---|
| 2835 | set(handles.OutputSubDir,'String',SubDirOut)
|
---|
| 2836 | set(handles.OutputSubDir,'BackgroundColor',[1 1 1])% set edit box to white color to indicate refreshment
|
---|
| 2837 | set(handles.OutputDirExt,'Visible',OutputDirVisible)
|
---|
| 2838 | set(handles.OutputSubDir,'Visible',OutputDirVisible)
|
---|
| 2839 | % set(handles.OutputDir_title,'Visible',OutputDirVisible)
|
---|
| 2840 | SeriesData.ActionName=ActionName; % record ActionName for next use
|
---|
| 2841 |
|
---|
| 2842 |
|
---|
| 2843 | %% visibility of the run mode (local or background or cluster)
|
---|
| 2844 | if strcmp(OutputSubDirMode,'none')
|
---|
| 2845 | RunModeVisible='off'; % only local mode available if no output file is produced
|
---|
| 2846 | else
|
---|
| 2847 | RunModeVisible='on';
|
---|
| 2848 | end
|
---|
| 2849 | set(handles.RunMode,'Visible',RunModeVisible)
|
---|
| 2850 | set(handles.ActionExt,'Visible',RunModeVisible)
|
---|
| 2851 | set(handles.RunMode_title,'Visible',RunModeVisible)
|
---|
| 2852 | set(handles.ActionExt_title,'Visible',RunModeVisible)
|
---|
| 2853 |
|
---|
| 2854 |
|
---|
| 2855 | %% Expected nbre of output files
|
---|
| 2856 | if isfield(ParamOut,'OutputFileMode')
|
---|
| 2857 | StatusData.OutputFileMode=ParamOut.OutputFileMode;
|
---|
| 2858 | set(handles.status,'UserData',StatusData)
|
---|
| 2859 | end
|
---|
| 2860 |
|
---|
| 2861 | %% definition of an additional parameter set, determined by an ancillary GUI
|
---|
| 2862 | if isfield(ParamOut,'ActionInput')
|
---|
| 2863 | % set(handles.ActionInput,'Visible','on')
|
---|
| 2864 | ParamOut.ActionInput.Program=ActionName; % record the program in ActionInput
|
---|
| 2865 | SeriesData.ActionInput=ParamOut.ActionInput;
|
---|
| 2866 | else
|
---|
| 2867 | % set(handles.ActionInput,'Visible','off')
|
---|
| 2868 | if isfield(SeriesData,'ActionInput')
|
---|
| 2869 | SeriesData=rmfield(SeriesData,'ActionInput');
|
---|
| 2870 | end
|
---|
| 2871 | end
|
---|
| 2872 | set(handles.series,'UserData',SeriesData)
|
---|
| 2873 | set(handles.ActionInput,'BackgroundColor',[1 0 0])
|
---|
| 2874 |
|
---|
| 2875 |
|
---|
| 2876 | %------------------------------------------------------------------------
|
---|
| 2877 | % --- Executes on button press in RefreshField.
|
---|
| 2878 | function RefreshField_Callback(hObject, eventdata, handles)
|
---|
| 2879 | %------------------------------------------------------------------------
|
---|
| 2880 | set(handles.FieldName,'String',{'add_field...'});
|
---|
| 2881 | set(handles.FieldName,'Value',1);
|
---|
| 2882 | FieldName_Callback(hObject, eventdata, handles)
|
---|
| 2883 |
|
---|
| 2884 |
|
---|
| 2885 | %------------------------------------------------------------------------
|
---|
| 2886 | % --- Executes on selection change in FieldName.
|
---|
| 2887 | function FieldName_Callback(hObject, eventdata, handles)
|
---|
| 2888 | %------------------------------------------------------------------------
|
---|
| 2889 | FieldListInit=get(handles.FieldName,'String');
|
---|
| 2890 | field_index=get(handles.FieldName,'Value');
|
---|
| 2891 | field=FieldListInit{field_index(1)};
|
---|
| 2892 | if isequal(field,'add_field...')
|
---|
| 2893 | FieldListInit(field_index(1))=[];
|
---|
| 2894 | SeriesData=get(handles.series,'UserData');
|
---|
| 2895 | % input line for which the field choice is relevant
|
---|
| 2896 | iview=find(ismember(SeriesData.FileType,{'netcdf','civx','civdata'})); % all nc files, icluding civ
|
---|
| 2897 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 2898 | if ~isempty(hget_field)
|
---|
| 2899 | delete(hget_field)%delete opened versions of get_field
|
---|
| 2900 | end
|
---|
| 2901 | Param=read_GUI(handles.series);
|
---|
| 2902 | InputTable=Param.InputTable(iview,:);
|
---|
| 2903 | % check the existence of the first file in the series
|
---|
| 2904 | first_j=[];last_j=[];MinIndex_j=1;MaxIndex_j=1; % default setting for index j
|
---|
| 2905 | if isfield(Param.IndexRange,'first_j') % if index j is used
|
---|
| 2906 | first_j=Param.IndexRange.first_j;
|
---|
| 2907 | last_j=Param.IndexRange.last_j;
|
---|
| 2908 | MinIndex_j=Param.IndexRange.MinIndex_j(iview);
|
---|
| 2909 | MaxIndex_j=Param.IndexRange.MaxIndex_j(iview);
|
---|
| 2910 | end
|
---|
| 2911 | PairString='';
|
---|
| 2912 | if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString{iview}; end
|
---|
| 2913 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
|
---|
| 2914 | LineIndex=iview(1);
|
---|
| 2915 | if numel(iview)>1
|
---|
| 2916 | answer=msgbox_uvmat('INPUT_TXT',['select the line of the input table:' num2str(iview)] ,num2str(iview(1)));
|
---|
| 2917 | LineIndex=str2num(answer);
|
---|
| 2918 | end
|
---|
| 2919 | FirstFileName=fullfile_uvmat(InputTable{LineIndex,1},InputTable{LineIndex,2},InputTable{LineIndex,3},...
|
---|
| 2920 | InputTable{LineIndex,5},InputTable{LineIndex,4},i1,i2,j1,j2);
|
---|
| 2921 | if exist(FirstFileName,'file') || ~isempty(regexp(InputTable{LineIndex,1},'^http'))
|
---|
| 2922 | ParamIn.Title='get_field: pick input variables and coordinates for series processing';
|
---|
| 2923 | ParamIn.SeriesInput=1;
|
---|
| 2924 | GetFieldData=get_field(FirstFileName,ParamIn);
|
---|
| 2925 | FieldList={};
|
---|
| 2926 | if isfield(GetFieldData,'FieldOption')% if a field has been selected
|
---|
| 2927 | switch GetFieldData.FieldOption
|
---|
| 2928 | case 'vectors'
|
---|
| 2929 | UName=GetFieldData.PanelVectors.vector_x;
|
---|
| 2930 | VName=GetFieldData.PanelVectors.vector_y;
|
---|
| 2931 | YName={GetFieldData.Coordinates.Coord_y};
|
---|
| 2932 | FieldList={['vec(' UName ',' VName ')'];...
|
---|
| 2933 | ['norm(' UName ',' VName ')'];...
|
---|
| 2934 | UName;VName};
|
---|
| 2935 | set(handles.VelType,'Visible','off')
|
---|
| 2936 | case {'scalar'}
|
---|
| 2937 | FieldList=GetFieldData.PanelScalar.scalar;
|
---|
| 2938 | YName={GetFieldData.Coordinates.Coord_y};
|
---|
| 2939 | if ischar(FieldList)
|
---|
| 2940 | FieldList={FieldList};
|
---|
| 2941 | end
|
---|
| 2942 | set(handles.VelType,'Visible','off')
|
---|
| 2943 | case 'civdata...'
|
---|
| 2944 | FieldList=[set_field_list('U','V') ;{'C'}];
|
---|
| 2945 | set(handles.FieldName,'Value',1) % set menu to 'velocity
|
---|
| 2946 | XName='X';
|
---|
| 2947 | YName='y';
|
---|
| 2948 | set(handles.VelType,'Visible','on')
|
---|
| 2949 | end
|
---|
| 2950 | set(handles.FieldName,'Value',1)
|
---|
| 2951 | set(handles.FieldName,'String',[FieldListInit; FieldList; {'add_field...'}]);
|
---|
| 2952 | if ~strcmp(GetFieldData.FieldOption,'civdata...')
|
---|
| 2953 | if ~isempty(regexp(FieldList{1},'^vec'))
|
---|
| 2954 | set(handles.FieldName,'Value',1)
|
---|
| 2955 | else
|
---|
| 2956 | set(handles.FieldName,'Value',1:numel(FieldList))%select all input fields by default
|
---|
| 2957 | end
|
---|
| 2958 | XName=GetFieldData.Coordinates.Coord_x;
|
---|
| 2959 | YName=GetFieldData.Coordinates.Coord_y;
|
---|
| 2960 | TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
|
---|
| 2961 | % get the time info
|
---|
| 2962 | TimeTable=get(handles.TimeTable,'Data');
|
---|
| 2963 | switch TimeNameStr
|
---|
| 2964 | case 'file index'
|
---|
| 2965 | TimeName='';
|
---|
| 2966 | case 'attribute'
|
---|
| 2967 | TimeName=['att:' GetFieldData.Time.TimeName];
|
---|
| 2968 | % update the time table
|
---|
| 2969 | TimeTable{LineIndex,2}=get_time(Param.IndexRange.MinIndex_i(LineIndex),MinIndex_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName); % Min time
|
---|
| 2970 | TimeTable{LineIndex,3}=get_time(Param.IndexRange.first_i,first_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName); % first time
|
---|
| 2971 | TimeTable{LineIndex,4}=get_time(Param.IndexRange.last_i,last_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName); % last time
|
---|
| 2972 | TimeTable{LineIndex,5}=get_time(Param.IndexRange.MaxIndex_i(LineIndex),MaxIndex_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName); % Max time
|
---|
| 2973 | case 'variable'
|
---|
| 2974 | set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName])
|
---|
| 2975 | set(handles.NomType,'String','*')
|
---|
| 2976 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% A VERIFIER !!!!!!
|
---|
| 2977 | set(handles.FileIndex,'String','')
|
---|
| 2978 | ParamIn.TimeVarName=GetFieldData.Time.TimeName;
|
---|
| 2979 | case 'matrix_index'
|
---|
| 2980 | TimeName=['dim:' GetFieldData.Time.TimeName];
|
---|
| 2981 | set(handles.NomType,'String','*')
|
---|
| 2982 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])
|
---|
| 2983 | set(handles.FileIndex,'String','')
|
---|
| 2984 | ParamIn.TimeDimName=GetFieldData.Time.TimeName;
|
---|
| 2985 | end
|
---|
| 2986 | TimeTable{LineIndex,1}=TimeName;
|
---|
| 2987 | set(handles.TimeTable,'Data',TimeTable);
|
---|
| 2988 | end
|
---|
| 2989 | set(handles.Coord_x,'String',XName)
|
---|
| 2990 | set(handles.Coord_y,'String',YName)
|
---|
| 2991 | set(handles.Coord_x,'Visible','on')
|
---|
| 2992 | set(handles.Coord_y,'Visible','on')
|
---|
| 2993 | end
|
---|
| 2994 | else
|
---|
| 2995 | msgbox_uvmat('ERROR',[FirstFileName ' does not exist'])
|
---|
| 2996 | end
|
---|
| 2997 | end
|
---|
| 2998 |
|
---|
| 2999 |
|
---|
| 3000 | function [TimeValue,DtValue]=get_time(ref_i,ref_j,PairString,InputTable,FileInfo,TimeName,DtName)
|
---|
| 3001 | [i1,i2,j1,j2] = get_file_index(ref_i,ref_j,PairString);
|
---|
| 3002 | FileName=fullfile_uvmat(InputTable{1},InputTable{2},InputTable{3},InputTable{5},InputTable{4},i1,i2,j1,j2);
|
---|
| 3003 | Data=nc2struct(FileName,[]);
|
---|
| 3004 | TimeValue=[];
|
---|
| 3005 | DtValue=[];
|
---|
| 3006 | if isequal(FileInfo.FileType,'civdata')
|
---|
| 3007 | if ismember(TimeName,{'civ1','filter1'})
|
---|
| 3008 | if isfield(Data,'Civ1_Time')
|
---|
| 3009 | TimeValue=Data.Civ1_Time;
|
---|
| 3010 | end
|
---|
| 3011 | if isfield(Data,'Civ1_Dt')
|
---|
| 3012 | DtValue=Data.Civ1_Dt;
|
---|
| 3013 | end
|
---|
| 3014 | else
|
---|
| 3015 | if isfield(Data,'Civ2_Time')
|
---|
| 3016 | TimeValue=Data.Civ2_Time;
|
---|
| 3017 | end
|
---|
| 3018 | if isfield(Data,'Civ2_Dt')
|
---|
| 3019 | DtValue=Data.Civ2_Dt;
|
---|
| 3020 | end
|
---|
| 3021 | end
|
---|
| 3022 | else
|
---|
| 3023 | if ~isempty(TimeName)&& isfield(Data,TimeName)
|
---|
| 3024 | TimeValue=Data.(TimeName);
|
---|
| 3025 | end
|
---|
| 3026 | if exist('DtName','var') && isfield(Data,DtName)
|
---|
| 3027 | DtValue=Data.(DtName);
|
---|
| 3028 | end
|
---|
| 3029 | end
|
---|
| 3030 |
|
---|
| 3031 | %------------------------------------------------------------------------
|
---|
| 3032 | % --- Executes on selection change in FieldName_1.
|
---|
| 3033 | function FieldName_1_Callback(hObject, eventdata, handles)
|
---|
| 3034 | %------------------------------------------------------------------------
|
---|
| 3035 | field_str=get(handles.FieldName_1,'String');
|
---|
| 3036 | field_index=get(handles.FieldName_1,'Value');
|
---|
| 3037 | field=field_str{field_index(1)};
|
---|
| 3038 | if strcmp(field,'add_field...')
|
---|
| 3039 | %iview=find(ismember(SeriesData.FileType,{'netcdf','civx','civdata'})); % all nc files, icluding civ
|
---|
| 3040 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 3041 | if ~isempty(hget_field)
|
---|
| 3042 | delete(hget_field)%delete opened versions of get_field
|
---|
| 3043 | end
|
---|
| 3044 | Param=read_GUI(handles.series);
|
---|
| 3045 | InputTable=Param.InputTable(2,:);
|
---|
| 3046 | % check the existence of the first file in the series
|
---|
| 3047 | first_j=[];
|
---|
| 3048 | if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
|
---|
| 3049 | if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end
|
---|
| 3050 | PairString='';
|
---|
| 3051 | if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
|
---|
| 3052 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
|
---|
| 3053 | FirstFileName=fullfile_uvmat(Param.InputTable{2,1},Param.InputTable{2,2},Param.InputTable{2,3},...
|
---|
| 3054 | Param.InputTable{2,5},Param.InputTable{2,4},i1,i2,j1,j2);
|
---|
| 3055 | if exist(FirstFileName,'file')
|
---|
| 3056 | ParamIn.SeriesInput=1;
|
---|
| 3057 | GetFieldData=get_field(FirstFileName,ParamIn);
|
---|
| 3058 | FieldList={};
|
---|
| 3059 | switch GetFieldData.FieldOption
|
---|
| 3060 | case 'vectors'
|
---|
| 3061 | UName=GetFieldData.PanelVectors.vector_x;
|
---|
| 3062 | VName=GetFieldData.PanelVectors.vector_y;
|
---|
| 3063 | FieldList={['vec(' UName ',' VName ')'];...
|
---|
| 3064 | ['norm(' UName ',' VName ')'];...
|
---|
| 3065 | UName;VName};
|
---|
| 3066 | case {'scalar','pick variables'}
|
---|
| 3067 | FieldList=GetFieldData.PanelScalar.scalar;
|
---|
| 3068 | if ischar(FieldList)
|
---|
| 3069 | FieldList={FieldList};
|
---|
| 3070 | end
|
---|
| 3071 | case '1D plot'
|
---|
| 3072 |
|
---|
| 3073 | case 'civdata...'
|
---|
| 3074 | FieldList=set_field_list('U','V','C');
|
---|
| 3075 | set(handles.FieldName,'Value',2) % set menu to 'velocity
|
---|
| 3076 | end
|
---|
| 3077 | % if ~strcmp(GetFieldData.FieldOption,'civdata...')
|
---|
| 3078 | % TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
|
---|
| 3079 | % switch TimeNameStr
|
---|
| 3080 | % case 'file index'
|
---|
| 3081 | % set(handles.TimeName,'String','');
|
---|
| 3082 | % case 'attribute'
|
---|
| 3083 | % set(handles.TimeName,'String',['att:' GetFieldData.Time.TimeName]);
|
---|
| 3084 | % case 'variable'
|
---|
| 3085 | % set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName])
|
---|
| 3086 | % set(handles.NomType,'String','*')
|
---|
| 3087 | % set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% A VERIFIER !!!!!!
|
---|
| 3088 | % set(handles.FileIndex,'String','')
|
---|
| 3089 | % ParamIn.TimeVarName=GetFieldData.Time.TimeName;
|
---|
| 3090 | % case 'matrix_index'
|
---|
| 3091 | % set(handles.TimeName,'String',['dim:' GetFieldData.Time.TimeName]);
|
---|
| 3092 | % set(handles.NomType,'String','*')
|
---|
| 3093 | % set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])
|
---|
| 3094 | % set(handles.FileIndex,'String','')
|
---|
| 3095 | % ParamIn.TimeDimName=GetFieldData.Time.TimeName;
|
---|
| 3096 | % end
|
---|
| 3097 | % end
|
---|
| 3098 | set(handles.FieldName_1,'Value',1)
|
---|
| 3099 | set(handles.FieldName_1,'String',[FieldList; {'add_field...'}]);
|
---|
| 3100 | end
|
---|
| 3101 | end
|
---|
| 3102 |
|
---|
| 3103 |
|
---|
| 3104 | %%%%%%%%%%%%%
|
---|
| 3105 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i)
|
---|
| 3106 | indsel=ind_i;
|
---|
| 3107 | indiff=diff(ind_i); % test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series
|
---|
| 3108 | indiff=[1 indiff last_i-ind_i(end)+1]; % for testing gaps with the imposed bounds
|
---|
| 3109 | if ~isempty(indiff)
|
---|
| 3110 | indiff2=diff(indiff);
|
---|
| 3111 | indiffp=[indiff2 1];
|
---|
| 3112 | indiffm=[1 indiff2];
|
---|
| 3113 | ind_multi_m=find((indiff==0)&(indiffm<0))-1; % indices of first members of multiplets
|
---|
| 3114 | ind_multi_p=find((indiff==0)&(indiffp>0)); % indices of last members of multiplets
|
---|
| 3115 | %for each multiplet, select the most recent file
|
---|
| 3116 | ind_remove=[];
|
---|
| 3117 | for i=1:length(ind_multi_m)
|
---|
| 3118 | ind_pairs=ind_multi_m(i):ind_multi_p(i);
|
---|
| 3119 | for imulti=1:length(ind_pairs)
|
---|
| 3120 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date); % dates of creation
|
---|
| 3121 | end
|
---|
| 3122 | [datenew,indsort2]=sort(datepair); % sort the multiplet by creation date
|
---|
| 3123 | ind_s=indsort2(1:end-1); %
|
---|
| 3124 | ind_remove=[ind_remove ind_pairs(ind_s)]; % remove these indices, leave the last one
|
---|
| 3125 | end
|
---|
| 3126 | end
|
---|
| 3127 |
|
---|
| 3128 | %------------------------------------------------------------------------
|
---|
| 3129 | % --- determine the list of index pairstring of processing file
|
---|
| 3130 | function [num_i1,num_i2,num_j1,num_j2,num_i_out,num_j_out]=find_file_indices(num_i,num_j,ind_shift,NomType,mode)
|
---|
| 3131 | %------------------------------------------------------------------------
|
---|
| 3132 | num_i1=num_i; % set of first image numbers by default
|
---|
| 3133 | num_i2=num_i;
|
---|
| 3134 | num_j1=num_j;
|
---|
| 3135 | num_j2=num_j;
|
---|
| 3136 | num_i_out=num_i;
|
---|
| 3137 | num_j_out=num_j;
|
---|
| 3138 | % if isequal (NomType,'_1-2_1') || isequal (NomType,'_1-2')
|
---|
| 3139 | if isequal(mode,'series(Di)')
|
---|
| 3140 | num_i1_line=num_i+ind_shift(3); % set of first image numbers
|
---|
| 3141 | num_i2_line=num_i+ind_shift(4);
|
---|
| 3142 | % adjust the first and last field number
|
---|
| 3143 | indsel=find(num_i1_line >= 1);
|
---|
| 3144 | num_i_out=num_i(indsel);
|
---|
| 3145 | num_i1_line=num_i1_line(indsel);
|
---|
| 3146 | num_i2_line=num_i2_line(indsel);
|
---|
| 3147 | num_j1=meshgrid(num_j,ones(size(num_i1_line)));
|
---|
| 3148 | num_j2=meshgrid(num_j,ones(size(num_i1_line)));
|
---|
| 3149 | [xx,num_i1]=meshgrid(num_j,num_i1_line);
|
---|
| 3150 | [xx,num_i2]=meshgrid(num_j,num_i2_line);
|
---|
| 3151 | elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts')
|
---|
| 3152 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D)
|
---|
| 3153 | num_j1=ind_shift(1)*ones(size(num_i));
|
---|
| 3154 | num_j2=ind_shift(2)*ones(size(num_i));
|
---|
| 3155 | else
|
---|
| 3156 | num_j1_col=num_j+ind_shift(1); % set of first image numbers
|
---|
| 3157 | num_j2_col=num_j+ind_shift(2);
|
---|
| 3158 | % adjust the first field number
|
---|
| 3159 | indsel=find((num_j1_col >= 1));
|
---|
| 3160 | num_j_out=num_j(indsel);
|
---|
| 3161 | num_j1_col=num_j1_col(indsel);
|
---|
| 3162 | num_j2_col=num_j2_col(indsel);
|
---|
| 3163 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col);
|
---|
| 3164 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col);
|
---|
| 3165 | end
|
---|
| 3166 | end
|
---|
| 3167 |
|
---|
| 3168 | %------------------------------------------------------------------------
|
---|
| 3169 | % --- Executes on button press in CheckObject.
|
---|
| 3170 | function CheckObject_Callback(hObject, eventdata, handles)
|
---|
| 3171 | %------------------------------------------------------------------------
|
---|
| 3172 | hset_object=findobj(allchild(0),'tag','set_object'); % find the set_object interface handle
|
---|
| 3173 | if get(handles.CheckObject,'Value')
|
---|
| 3174 | SeriesData=get(handles.series,'UserData');
|
---|
| 3175 | if isfield(SeriesData,'ProjObject') && ~isempty(SeriesData.ProjObject)% a projection object is already loaded in the GUI series
|
---|
| 3176 | set(handles.ViewObject,'Value',1)
|
---|
| 3177 | ViewObject_Callback(hObject, eventdata, handles)
|
---|
| 3178 | else
|
---|
| 3179 | if ishandle(hset_object)% a projection object is already displayed in a GUI set_object
|
---|
| 3180 | uistack(hset_object,'top')% show the GUI set_object if opened
|
---|
| 3181 | else
|
---|
| 3182 | %get the object file
|
---|
| 3183 | InputTable=get(handles.InputTable,'Data');
|
---|
| 3184 | defaultname=InputTable{1,1};
|
---|
| 3185 | if isempty(defaultname)
|
---|
| 3186 | defaultname={''};
|
---|
| 3187 | end
|
---|
| 3188 | fileinput=uigetfile_uvmat('pick a xml object file (or use uvmat to create it)',defaultname,'.xml');
|
---|
| 3189 | if isempty(fileinput)% exit if no object file is selected
|
---|
| 3190 | set(handles.CheckObject,'Value',0)
|
---|
| 3191 | return
|
---|
| 3192 | end
|
---|
| 3193 | %read the file
|
---|
| 3194 | data=xml2struct(fileinput);
|
---|
| 3195 | if ~isfield(data,'Type')
|
---|
| 3196 | msgbox_uvmat('ERROR',[fileinput ' is not an object xml file'])
|
---|
| 3197 | set(handles.CheckObject,'Value',0)
|
---|
| 3198 | return
|
---|
| 3199 | end
|
---|
| 3200 | if ~isfield(data,'ProjMode')
|
---|
| 3201 | data.ProjMode='none';
|
---|
| 3202 | end
|
---|
| 3203 | hset_object=set_object(data); % call the set_object interface
|
---|
| 3204 | set(hset_object,'Name','set_object_series')% name to distinguish from set_object used with uvmat
|
---|
| 3205 | end
|
---|
| 3206 | ProjObject=read_GUI(hset_object);
|
---|
| 3207 | set(handles.ProjObjectName,'String',ProjObject.Name); % display the object name
|
---|
| 3208 | SeriesData=get(handles.series,'UserData');
|
---|
| 3209 | SeriesData.ProjObject=ProjObject;
|
---|
| 3210 | set(handles.series,'UserData',SeriesData);
|
---|
| 3211 | end
|
---|
| 3212 | set(handles.EditObject,'Visible','on');
|
---|
| 3213 | set(handles.DeleteObject,'Visible','on');
|
---|
| 3214 | set(handles.ViewObject,'Visible','on');
|
---|
| 3215 | set(handles.ProjObjectName,'Visible','on');
|
---|
| 3216 | else
|
---|
| 3217 | set(handles.EditObject,'Visible','off');
|
---|
| 3218 | set(handles.DeleteObject,'Visible','off');
|
---|
| 3219 | set(handles.ViewObject,'Visible','off');
|
---|
| 3220 | if ~ishandle(hset_object)
|
---|
| 3221 | set(handles.ViewObject,'Value',0);
|
---|
| 3222 | end
|
---|
| 3223 | set(handles.ProjObjectName,'Visible','off');
|
---|
| 3224 | end
|
---|
| 3225 |
|
---|
| 3226 | %------------------------------------------------------------------------
|
---|
| 3227 | % --- Executes on button press in ViewObject.
|
---|
| 3228 | %------------------------------------------------------------------------
|
---|
| 3229 | function ViewObject_Callback(hObject, eventdata, handles)
|
---|
| 3230 |
|
---|
| 3231 | UserData=get(handles.series,'UserData');
|
---|
| 3232 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
| 3233 | if ~isempty(hset_object)
|
---|
| 3234 | delete(hset_object)% refresh set_object if already opened
|
---|
| 3235 | end
|
---|
| 3236 | hset_object=set_object(UserData.ProjObject);
|
---|
| 3237 | set(hset_object,'Name','view_object_series')
|
---|
| 3238 |
|
---|
| 3239 |
|
---|
| 3240 | %------------------------------------------------------------------------
|
---|
| 3241 | % --- Executes on button press in EditObject.
|
---|
| 3242 | function EditObject_Callback(hObject, eventdata, handles)
|
---|
| 3243 | %------------------------------------------------------------------------
|
---|
| 3244 | if get(handles.EditObject,'Value')
|
---|
| 3245 | set(handles.ViewObject,'Value',0)
|
---|
| 3246 | UserData=get(handles.series,'UserData');
|
---|
| 3247 | if isfield(UserData,'ProjObject')
|
---|
| 3248 | hset_object=set_object(UserData.ProjObject);
|
---|
| 3249 | set(hset_object,'Name','edit_object_series')
|
---|
| 3250 | set(get(hset_object,'Children'),'Enable','on')
|
---|
| 3251 | else
|
---|
| 3252 | msgbox_uvmat('ERROR','no projection object available');
|
---|
| 3253 | end
|
---|
| 3254 | else
|
---|
| 3255 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
| 3256 | if ~isempty(hset_object)
|
---|
| 3257 | set(get(hset_object,'Children'),'Enable','off')
|
---|
| 3258 | end
|
---|
| 3259 | end
|
---|
| 3260 |
|
---|
| 3261 | %------------------------------------------------------------------------
|
---|
| 3262 | % --- Executes on button press in DeleteObject.
|
---|
| 3263 | function DeleteObject_Callback(hObject, eventdata, handles)
|
---|
| 3264 | %------------------------------------------------------------------------
|
---|
| 3265 | SeriesData=get(handles.series,'UserData');
|
---|
| 3266 | SeriesData.ProjObject=[];
|
---|
| 3267 | set(handles.series,'UserData',SeriesData)
|
---|
| 3268 | set(handles.ProjObjectName,'String','')
|
---|
| 3269 | set(handles.ProjObjectName,'Visible','off')
|
---|
| 3270 | set(handles.CheckObject,'Value',0)
|
---|
| 3271 | set(handles.ViewObject,'Visible','off')
|
---|
| 3272 | set(handles.EditObject,'Visible','off')
|
---|
| 3273 | hset_object=findobj(allchild(0),'name','set_object_series');
|
---|
| 3274 | if ~isempty(hset_object)
|
---|
| 3275 | delete(hset_object)
|
---|
| 3276 | end
|
---|
| 3277 | set(handles.DeleteObject,'Visible','off')
|
---|
| 3278 |
|
---|
| 3279 | %------------------------------------------------------------------------
|
---|
| 3280 | % --- Executed when CheckMask is activated
|
---|
| 3281 | %------------------------------------------------------------------------
|
---|
| 3282 | function CheckMask_Callback(hObject, eventdata, handles)
|
---|
| 3283 |
|
---|
| 3284 | if get(handles.CheckMask,'Value')
|
---|
| 3285 | InputTable=get(handles.InputTable,'Data');
|
---|
| 3286 | nbview=size(InputTable,1);
|
---|
| 3287 | MaskTable=cell(nbview,1); % default
|
---|
| 3288 | ListMask=cell(nbview,1); % default
|
---|
| 3289 | MaskData=get(handles.MaskTable,'Data');
|
---|
| 3290 | MaskData(size(MaskData,1):nbview,1)=cell(size(MaskData,1):nbview,1); % complement if undefined lines
|
---|
| 3291 | for iview=1:nbview
|
---|
| 3292 | ListMask{iview,1}=num2str(iview);
|
---|
| 3293 | RootPath=InputTable{iview,1};
|
---|
| 3294 | if ~isempty(RootPath)
|
---|
| 3295 | if isempty(MaskData{iview})
|
---|
| 3296 | SubDir=InputTable{iview,2};
|
---|
| 3297 | MaskPath=fullfile(RootPath,[regexprep(SubDir,'\..*','') '.mask']); % take the root part of SubDir, before the first dot '.'
|
---|
| 3298 | if exist(MaskPath,'dir')
|
---|
| 3299 | ListStruct=dir(MaskPath); % look for a mask file
|
---|
| 3300 | ListCells=struct2cell(ListStruct); % transform dir struct to a cell arrray
|
---|
| 3301 | check_dir=cell2mat(ListCells(4,:)); % =1 for directories, =0 for files
|
---|
| 3302 | ListFiles=ListCells(1,:); % list of file and dri names
|
---|
| 3303 | ListFiles=ListFiles(~check_dir); % list of file names (excluding dir)
|
---|
| 3304 | mdetect=0;
|
---|
| 3305 | if ~isempty(ListFiles)
|
---|
| 3306 | for ifile=1:numel(ListFiles)
|
---|
| 3307 | [tild,tild,MaskFile{ifile},i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{ifile},0);
|
---|
| 3308 | if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series)
|
---|
| 3309 | mdetect=1;
|
---|
| 3310 | MaskName=ListFiles{ifile};
|
---|
| 3311 | end
|
---|
| 3312 | if ~strcmp(MaskFile{ifile},MaskFile{1})
|
---|
| 3313 | mdetect=0; % cancel detection test in case of multiple masks, use the brower for selection
|
---|
| 3314 | break
|
---|
| 3315 | end
|
---|
| 3316 | end
|
---|
| 3317 | end
|
---|
| 3318 | if mdetect==1
|
---|
| 3319 | MaskName=fullfile(MaskPath,'mask_1.png');
|
---|
| 3320 | else
|
---|
| 3321 | MaskName=uigetfile_uvmat('select a mask file:',MaskPath,'image');
|
---|
| 3322 | end
|
---|
| 3323 | else
|
---|
| 3324 | MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image');
|
---|
| 3325 | end
|
---|
| 3326 | MaskTable{iview,1}=MaskName ;
|
---|
| 3327 | ListMask{iview,1}=num2str(iview);
|
---|
| 3328 | end
|
---|
| 3329 | end
|
---|
| 3330 | end
|
---|
| 3331 | set(handles.MaskTable,'Data',MaskTable)
|
---|
| 3332 | set(handles.MaskTable,'Visible','on')
|
---|
| 3333 | set(handles.MaskBrowse,'Visible','on')
|
---|
| 3334 | set(handles.ListMask,'Visible','on')
|
---|
| 3335 | set(handles.ListMask,'String',ListMask)
|
---|
| 3336 | set(handles.ListMask,'Value',1)
|
---|
| 3337 | else
|
---|
| 3338 | set(handles.MaskTable,'Visible','off')
|
---|
| 3339 | set(handles.MaskBrowse,'Visible','off')
|
---|
| 3340 | set(handles.ListMask,'Visible','off')
|
---|
| 3341 | end
|
---|
| 3342 |
|
---|
| 3343 | %------------------------------------------------------------------------
|
---|
| 3344 | % --- Executes on button press in MaskBrowse.
|
---|
| 3345 | %------------------------------------------------------------------------
|
---|
| 3346 | function MaskBrowse_Callback(hObject, eventdata, handles)
|
---|
| 3347 |
|
---|
| 3348 | InputTable=get(handles.InputTable,'Data');
|
---|
| 3349 | iview=get(handles.ListMask,'Value');
|
---|
| 3350 | RootPath=InputTable{iview,1};
|
---|
| 3351 | MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image');
|
---|
| 3352 | if ~isempty(MaskName)
|
---|
| 3353 | MaskTable=get(handles.MaskTable,'Data');
|
---|
| 3354 | MaskTable{iview,1}=MaskName ;
|
---|
| 3355 | set(handles.MaskTable,'Data',MaskTable)
|
---|
| 3356 | end
|
---|
| 3357 |
|
---|
| 3358 | %------------------------------------------------------------------------
|
---|
| 3359 | % --- Executes when selected cell(s) is changed in MaskTable.
|
---|
| 3360 | %------------------------------------------------------------------------
|
---|
| 3361 | function MaskTable_CellSelectionCallback(hObject, eventdata, handles)
|
---|
| 3362 |
|
---|
| 3363 | if numel(eventdata.Indices)>=1
|
---|
| 3364 | set(handles.ListMask,'Value',eventdata.Indices(1))
|
---|
| 3365 | end
|
---|
| 3366 |
|
---|
| 3367 | %-------------------------------------------------------------------
|
---|
| 3368 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
| 3369 | %-------------------------------------------------------------------
|
---|
| 3370 |
|
---|
| 3371 |
|
---|
| 3372 | % path_to_uvmat=which ('uvmat'); % check the path of uvmat
|
---|
| 3373 | % pathelp=fileparts(path_to_uvmat);
|
---|
| 3374 | % helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
| 3375 | % 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')
|
---|
| 3376 | % else
|
---|
| 3377 | % addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
| 3378 | % web([helpfile '#series'])
|
---|
| 3379 | % end
|
---|
| 3380 |
|
---|
| 3381 | %-------------------------------------------------------------------
|
---|
| 3382 | % --- Executes on selection change in TransformName.
|
---|
| 3383 | function TransformName_Callback(hObject, eventdata, handles)
|
---|
| 3384 | %----------------------------------------------------------------------
|
---|
| 3385 | TransformList=get(handles.TransformName,'String');
|
---|
| 3386 | TransformIndex=get(handles.TransformName,'Value');
|
---|
| 3387 | TransformName=TransformList{TransformIndex};
|
---|
| 3388 | TransformPathList=get(handles.TransformName,'UserData');
|
---|
| 3389 | nb_builtin_transform=4;
|
---|
| 3390 |
|
---|
| 3391 | %% browse transform functions with the input menu option more...
|
---|
| 3392 | if isequal(TransformName,'more...')% browse transform functions
|
---|
| 3393 | FileName=uigetfile_uvmat('Pick a transform function',get(handles.TransformPath,'String'),'.m');
|
---|
| 3394 | if isempty(FileName)
|
---|
| 3395 | return %browser closed without choice
|
---|
| 3396 | end
|
---|
| 3397 | [TransformPath,TransformName,TransformExt]=fileparts(FileName); % removes extension .m
|
---|
| 3398 | if ~strcmp(TransformExt,'.m')
|
---|
| 3399 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
| 3400 | return
|
---|
| 3401 | end
|
---|
| 3402 | % insert the choice in the menu
|
---|
| 3403 | TransformIndex=find(strcmp(TransformName,TransformList),1); % look for the selected function in the menu Action
|
---|
| 3404 | if isempty(TransformIndex)%the input string does not exist in the menu
|
---|
| 3405 | TransformIndex= length(TransformList);
|
---|
| 3406 | TransformList=[TransformList(1:end-1);{TransformName};TransformList(end)]; % the selected function is appended in the menu, before the last item 'more...'
|
---|
| 3407 | set(handles.TransformName,'String',TransformList)
|
---|
| 3408 | TransformPathList=[TransformPathList;{TransformPath}];
|
---|
| 3409 | else% the input function already exist, we update its path (possibly new)
|
---|
| 3410 | TransformPathList{TransformIndex}=TransformPath; %
|
---|
| 3411 | set(handles.TransformName,'Value',TransformIndex)
|
---|
| 3412 | end
|
---|
| 3413 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
| 3414 | dir_perso=prefdir; % personal Matalb directory
|
---|
| 3415 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 3416 | if exist(profil_perso,'file')
|
---|
| 3417 | for ilist=nb_builtin_transform+1:numel(TransformPathList)
|
---|
| 3418 | TransformListUser{ilist-nb_builtin_transform}=TransformList{ilist};
|
---|
| 3419 | TransformPathListUser{ilist-nb_builtin_transform}=TransformPathList{ilist};
|
---|
| 3420 | end
|
---|
| 3421 | TransformPathListUser=TransformPathListUser';
|
---|
| 3422 | TransformListUser=TransformListUser';
|
---|
| 3423 | save (profil_perso,'TransformPathListUser','TransformListUser','-append'); % store the root name for future opening of uvmat
|
---|
| 3424 | end
|
---|
| 3425 | end
|
---|
| 3426 |
|
---|
| 3427 | %% display the current function path
|
---|
| 3428 | set(handles.TransformPath,'String',TransformPathList{TransformIndex}); % show the path to the senlected function
|
---|
| 3429 | set(handles.TransformName,'UserData',TransformPathList);
|
---|
| 3430 |
|
---|
| 3431 | %% create the function handle of the selected fct
|
---|
| 3432 | if ~isempty(TransformName)
|
---|
| 3433 | if ~exist(TransformPathList{TransformIndex},'dir')
|
---|
| 3434 | msgbox_uvmat('ERROR',['The prescribed transform function path ' TransformPathList{TransformIndex} ' does not exist']);
|
---|
| 3435 | return
|
---|
| 3436 | end
|
---|
| 3437 | current_dir=pwd; % current working dir
|
---|
| 3438 | cd(TransformPathList{TransformIndex})
|
---|
| 3439 | transform_handle=str2func(TransformName);
|
---|
| 3440 | cd(current_dir)
|
---|
| 3441 | Field.Action.RUN=0;% indicate that the transform fct is called only to get input param
|
---|
| 3442 | SeriesData=get(handles.series,'UserData');
|
---|
| 3443 | ParamIn=[];
|
---|
| 3444 | if isfield(SeriesData,'TransformInput')
|
---|
| 3445 | ParamIn.TransformInput=SeriesData.TransformInput;
|
---|
| 3446 | end
|
---|
| 3447 | DataOut=feval(transform_handle,Field,ParamIn);% execute the transform fct to get its input parameters
|
---|
| 3448 | if isfield(DataOut,'TransformInput')% used to add transform parameters at selection of the transform fct
|
---|
| 3449 | SeriesData.TransformInput=DataOut.TransformInput;
|
---|
| 3450 | set(handles.series,'UserData',SeriesData)
|
---|
| 3451 | end
|
---|
| 3452 | end
|
---|
| 3453 |
|
---|
| 3454 | %------------------------------------------------------------------------
|
---|
| 3455 | % --- fct activated by the upper bar menu ExportConfig
|
---|
| 3456 | %------------------------------------------------------------------------
|
---|
| 3457 | function MenuDisplayConfig_Callback(hObject, eventdata, handles)
|
---|
| 3458 |
|
---|
| 3459 | global Param
|
---|
| 3460 | Param=read_GUI_series(handles);
|
---|
| 3461 | evalin('base','global Param')%make CurData global in the workspace
|
---|
| 3462 | display('current series config :')
|
---|
| 3463 | evalin('base','Param') %display CurData in the workspace
|
---|
| 3464 | commandwindow; % brings the Matlab command window to the front
|
---|
| 3465 |
|
---|
| 3466 | %------------------------------------------------------------------------
|
---|
| 3467 | % --- fct activated by the upper bar menu InportConfig: import
|
---|
| 3468 | % menu settings from an xml file (stored in /0_XML for each run)
|
---|
| 3469 | %------------------------------------------------------------------------
|
---|
| 3470 | function MenuImportConfig_Callback(hObject, eventdata, handles)
|
---|
| 3471 |
|
---|
| 3472 | %% use a browser to choose the xml file containing the processing config
|
---|
| 3473 | InputTable=get(handles.InputTable,'Data');
|
---|
| 3474 | oldfile=InputTable{1,1}; % current path in InputTable
|
---|
| 3475 | if isempty(oldfile)
|
---|
| 3476 | % use a file name stored in prefdir
|
---|
| 3477 | dir_perso=prefdir;
|
---|
| 3478 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 3479 | if exist(profil_perso,'file')
|
---|
| 3480 | h=load (profil_perso);
|
---|
| 3481 | if isfield(h,'RootPath') && ischar(h.RootPath)
|
---|
| 3482 | oldfile=h.RootPath;
|
---|
| 3483 | end
|
---|
| 3484 | end
|
---|
| 3485 | end
|
---|
| 3486 | filexml=uigetfile_uvmat('pick a xml parameter file',oldfile,'.xml'); % get the xml file containing processing parameters
|
---|
| 3487 | if isempty(filexml), return, end % quit function if an xml file has not been opened
|
---|
| 3488 |
|
---|
| 3489 | %% fill the GUI series with the content of the xml file
|
---|
| 3490 | [Param,RootTag,errormsg]=xml2struct(filexml); % read the input xml file as a Matlab structure
|
---|
| 3491 | if ~isempty(errormsg)
|
---|
| 3492 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 3493 | return
|
---|
| 3494 | end
|
---|
| 3495 | % ask to stop current Action if button RUN is in action (another process is already running)
|
---|
| 3496 | if isequal(get(handles.RUN,'Value'),1)
|
---|
| 3497 | answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?');
|
---|
| 3498 | if strcmp(answer,'Yes')
|
---|
| 3499 | STOP_Callback(hObject, eventdata, handles)
|
---|
| 3500 | else
|
---|
| 3501 | return
|
---|
| 3502 | end
|
---|
| 3503 | end
|
---|
| 3504 | Param.Action.RUN=0; % desactivate the input RUN=1
|
---|
| 3505 |
|
---|
| 3506 | fill_GUI(Param,handles.series)% fill the elements of the GUI series with the input parameters
|
---|
| 3507 | SeriesData=get(handles.series,'UserData');
|
---|
| 3508 | if isfield(Param,'InputFields')
|
---|
| 3509 | ListField=Param.InputFields.FieldName;
|
---|
| 3510 | if ischar(ListField),ListField={ListField}; end
|
---|
| 3511 | set(handles.FieldName,'String',[ListField;{'add_field...'}])
|
---|
| 3512 | set(handles.FieldName,'Value',1:numel(ListField))
|
---|
| 3513 | set(handles.FieldName,'Visible','on')
|
---|
| 3514 | end
|
---|
| 3515 | if isfield(Param,'ActionInput')% introduce parameters specific to an Action fct, for instance PIV parameters
|
---|
| 3516 | % set(handles.ActionInput,'Visible','on')
|
---|
| 3517 | % set(handles.ActionInput,'Value',0)
|
---|
| 3518 | Param.ActionInput.ConfigSource=filexml; % record the source of config for future info
|
---|
| 3519 | SeriesData.ActionInput=Param.ActionInput;
|
---|
| 3520 | end
|
---|
| 3521 | if isfield(Param,'TransformInput')% introduce parameters specific to a transform fct
|
---|
| 3522 | SeriesData.TransformInput=Param.TransformInput;
|
---|
| 3523 | end
|
---|
| 3524 | if isfield(Param,'ProjObject') %introduce projection object if relevant
|
---|
| 3525 | SeriesData.ProjObject=Param.ProjObject;
|
---|
| 3526 | end
|
---|
| 3527 | set(handles.series,'UserData',SeriesData)
|
---|
| 3528 | if isfield(Param,'CheckObject') && isequal(Param.CheckObject,1)
|
---|
| 3529 | set(handles.ProjObjectName,'String',Param.ProjObject.Name)
|
---|
| 3530 | set(handles.ViewObject,'Visible','on')
|
---|
| 3531 | set(handles.EditObject,'Visible','on')
|
---|
| 3532 | set(handles.DeleteObject,'Visible','on')
|
---|
| 3533 | else
|
---|
| 3534 | set(handles.ProjObjectName,'String','')
|
---|
| 3535 | set(handles.ProjObjectName,'Visible','off')
|
---|
| 3536 | set(handles.ViewObject,'Visible','off')
|
---|
| 3537 | set(handles.EditObject,'Visible','off')
|
---|
| 3538 | set(handles.DeleteObject,'Visible','off')
|
---|
| 3539 | end
|
---|
| 3540 | set(handles.REFRESH,'BackgroundColor',[1 0 1]); % paint REFRESH button in magenta to indicate that it should be activated
|
---|
| 3541 |
|
---|
| 3542 |
|
---|
| 3543 | %------------------------------------------------------------------------
|
---|
| 3544 | % --- Executes when the GUI series is resized.
|
---|
| 3545 | %------------------------------------------------------------------------
|
---|
| 3546 | function series_ResizeFcn(hObject, eventdata, handles)
|
---|
| 3547 |
|
---|
| 3548 | %% input table
|
---|
| 3549 | set(handles.InputTable,'Unit','pixel')
|
---|
| 3550 | Pos=get(handles.InputTable,'Position');
|
---|
| 3551 | set(handles.InputTable,'Unit','normalized')
|
---|
| 3552 | ColumnWidth=round([0.5 0.14 0.14 0.14 0.08]*(Pos(3)-52));
|
---|
| 3553 | ColumnWidth=num2cell(ColumnWidth);
|
---|
| 3554 | set(handles.InputTable,'ColumnWidth',ColumnWidth)
|
---|
| 3555 |
|
---|
| 3556 | %% MinIndex_j and MaxIndex_i
|
---|
| 3557 | unit=get(handles.MinIndex_i,'Unit');
|
---|
| 3558 | set(handles.MinIndex_i,'Unit','pixel')
|
---|
| 3559 | Pos=get(handles.MinIndex_i,'Position');
|
---|
| 3560 | set(handles.MinIndex_i,'Unit',unit)
|
---|
| 3561 | set(handles.MinIndex_i,'ColumnWidth',{Pos(3)-18})
|
---|
| 3562 | set(handles.MaxIndex_i,'ColumnWidth',{Pos(3)-18})
|
---|
| 3563 | set(handles.MinIndex_j,'ColumnWidth',{Pos(3)-18})
|
---|
| 3564 | set(handles.MaxIndex_j,'ColumnWidth',{Pos(3)-18})
|
---|
| 3565 |
|
---|
| 3566 | %% TimeTable
|
---|
| 3567 | set(handles.TimeTable,'Unit','pixel')
|
---|
| 3568 | Pos=get(handles.TimeTable,'Position');
|
---|
| 3569 | set(handles.TimeTable,'Unit','normalized')
|
---|
| 3570 | % ColumnWidth=get(handles.TimeTable,'ColumnWidth');
|
---|
| 3571 | ColumnWidth=num2cell(floor([0.2 0.2 0.2 0.2 0.2]*(Pos(3)-20)));
|
---|
| 3572 | set(handles.TimeTable,'ColumnWidth',ColumnWidth)
|
---|
| 3573 |
|
---|
| 3574 |
|
---|
| 3575 | %% PairString
|
---|
| 3576 | set(handles.PairString,'Unit','pixel')
|
---|
| 3577 | Pos=get(handles.PairString,'Position');
|
---|
| 3578 | set(handles.PairString,'Unit','normalized')
|
---|
| 3579 | set(handles.PairString,'ColumnWidth',{Pos(3)-5})
|
---|
| 3580 |
|
---|
| 3581 | %% MaskTable
|
---|
| 3582 | % % set(handles.MaskTable,'Unit','pixel')
|
---|
| 3583 | % % Pos=get(handles.MaskTable,'Position');
|
---|
| 3584 | % % set(handles.MaskTable,'Unit','normalized')
|
---|
| 3585 | % % set(handles.MaskTable,'ColumnWidth',{Pos(3)-5})
|
---|
| 3586 |
|
---|
| 3587 | %------------------------------------------------------------------------
|
---|
| 3588 | % --- Executes on button press in status.
|
---|
| 3589 | %------------------------------------------------------------------------
|
---|
| 3590 | function status_Callback(hObject, eventdata, handles)
|
---|
| 3591 |
|
---|
| 3592 | if get(handles.status,'Value')
|
---|
| 3593 | set(handles.status,'BackgroundColor',[1 1 0])
|
---|
| 3594 | drawnow
|
---|
| 3595 | Param=read_GUI(handles.series);
|
---|
| 3596 | RootPath=fullfile(Param.OutputPath,Param.Experiment,Param.Device);
|
---|
| 3597 | if ~isfield(Param,'OutputSubDir')
|
---|
| 3598 | msgbox_uvmat('ERROR','no standard sub-directory definition for output files, use a browser to check the output')
|
---|
| 3599 | set(handles.status,'BackgroundColor',[0 1 0])
|
---|
| 3600 | return
|
---|
| 3601 | end
|
---|
| 3602 | OutputSubDir=[Param.OutputSubDir Param.OutputDirExt]; % subdirectory for output files
|
---|
| 3603 | OutputDir=fullfile(RootPath,OutputSubDir);
|
---|
| 3604 | if exist(OutputDir,'dir')
|
---|
| 3605 | uigetfile_uvmat('status_display',OutputDir)
|
---|
| 3606 | else
|
---|
| 3607 | msgbox_uvmat('ERROR','output folder not created yet: calculation did not start')
|
---|
| 3608 | set(handles.status,'BackgroundColor',[0 1 0])
|
---|
| 3609 | end
|
---|
| 3610 | else
|
---|
| 3611 | %% delete current display fig if selection is off
|
---|
| 3612 | set(handles.status,'BackgroundColor',[0 1 0])
|
---|
| 3613 | hfig=findobj(allchild(0),'name','status_display');
|
---|
| 3614 | if ~isempty(hfig)
|
---|
| 3615 | delete(hfig)
|
---|
| 3616 | end
|
---|
| 3617 | return
|
---|
| 3618 | end
|
---|
| 3619 |
|
---|
| 3620 |
|
---|
| 3621 | %------------------------------------------------------------------------
|
---|
| 3622 | % launched by selecting a file on the list
|
---|
| 3623 | %------------------------------------------------------------------------
|
---|
| 3624 | function view_file(hObject, eventdata)
|
---|
| 3625 |
|
---|
| 3626 | list=get(hObject,'String');
|
---|
| 3627 | index=get(hObject,'Value');
|
---|
| 3628 | rootroot=get(hObject,'UserData');
|
---|
| 3629 | selectname=list{index};
|
---|
| 3630 | ind_dot=regexp(selectname,'\.\.\.');
|
---|
| 3631 | if ~isempty(ind_dot)
|
---|
| 3632 | selectname=selectname(1:ind_dot-1);
|
---|
| 3633 | end
|
---|
| 3634 | FullSelectName=fullfile(rootroot,selectname);
|
---|
| 3635 | if exist(FullSelectName,'dir')% a directory has been selected
|
---|
| 3636 | ListFiles=dir(FullSelectName);
|
---|
| 3637 | ListDisplay=cell(numel(ListFiles),1);
|
---|
| 3638 | for ilist=2:numel(ListDisplay)% suppress the first line '.'
|
---|
| 3639 | ListDisplay{ilist-1}=ListFiles(ilist).name;
|
---|
| 3640 | end
|
---|
| 3641 | set(hObject,'Value',1)
|
---|
| 3642 | set(hObject,'String',ListDisplay)
|
---|
| 3643 | if strcmp(selectname,'..')
|
---|
| 3644 | FullSelectName=fileparts(fileparts(FullSelectName));
|
---|
| 3645 | end
|
---|
| 3646 | set(hObject,'UserData',FullSelectName)
|
---|
| 3647 | hfig=get(hObject,'parent');
|
---|
| 3648 | htitlebox=findobj(hfig,'tag','titlebox');
|
---|
| 3649 | set(htitlebox,'String',FullSelectName)
|
---|
| 3650 | elseif exist(FullSelectName,'file')%visualise the vel field if it exists
|
---|
| 3651 | FileInfo=get_file_info(FullSelectName);
|
---|
| 3652 | if strcmp(FileInfo.FileType,'txt')
|
---|
| 3653 | edit(FullSelectName)
|
---|
| 3654 | elseif strcmp(FileInfo.FileType,'xml')
|
---|
| 3655 | editxml(FullSelectName)
|
---|
| 3656 | else
|
---|
| 3657 | uvmat(FullSelectName)
|
---|
| 3658 | end
|
---|
| 3659 | set(gcbo,'Value',1)
|
---|
| 3660 | end
|
---|
| 3661 |
|
---|
| 3662 |
|
---|
| 3663 | %------------------------------------------------------------------------
|
---|
| 3664 | % launched by refreshing the status figure
|
---|
| 3665 | %------------------------------------------------------------------------
|
---|
| 3666 | function refresh_GUI(hfig)
|
---|
| 3667 |
|
---|
| 3668 | htitlebox=findobj(hfig,'tag','titlebox');
|
---|
| 3669 | hlist=findobj(hfig,'tag','list');
|
---|
| 3670 | hseries=findobj(allchild(0),'tag','series');
|
---|
| 3671 | hstatus=findobj(hseries,'tag','status');
|
---|
| 3672 | StatusData=get(hstatus,'UserData');
|
---|
| 3673 | OutputDir=get(htitlebox,'String');
|
---|
| 3674 | if ischar(OutputDir),OutputDir={OutputDir};end
|
---|
| 3675 | ListFiles=dir(OutputDir{1});
|
---|
| 3676 | if numel(ListFiles)<1
|
---|
| 3677 | return
|
---|
| 3678 | end
|
---|
| 3679 | ListFiles(1)=[]; % removes the first line ='.'
|
---|
| 3680 | ListDisplay=cell(numel(ListFiles),1);
|
---|
| 3681 | testrecent=0;
|
---|
| 3682 | datnum=zeros(numel(ListDisplay),1);
|
---|
| 3683 | for ilist=1:numel(ListDisplay)
|
---|
| 3684 | ListDisplay{ilist}=ListFiles(ilist).name;
|
---|
| 3685 | if ~ListFiles(ilist).isdir && isfield(ListFiles(ilist),'datenum')
|
---|
| 3686 | datnum(ilist)=ListFiles(ilist).datenum; % only available in recent matlab versions
|
---|
| 3687 | testrecent=1;
|
---|
| 3688 | end
|
---|
| 3689 | end
|
---|
| 3690 | set(hlist,'String',ListDisplay)
|
---|
| 3691 |
|
---|
| 3692 | %% Look at date of creation
|
---|
| 3693 | ListDisplay=ListDisplay(datnum~=0);
|
---|
| 3694 | datnum=datnum(datnum~=0); % keep the non zero values corresponding to existing files
|
---|
| 3695 | NbOutputFile=[];
|
---|
| 3696 | if isempty(datnum)
|
---|
| 3697 | if testrecent
|
---|
| 3698 | message='no civ result created yet';
|
---|
| 3699 | else
|
---|
| 3700 | message='';
|
---|
| 3701 | end
|
---|
| 3702 | else
|
---|
| 3703 | [first,indfirst]=min(datnum);
|
---|
| 3704 | [last,indlast]=max(datnum);
|
---|
| 3705 | NbOutputFile_str='?';
|
---|
| 3706 | NbOutputFile=[];
|
---|
| 3707 | if isfield(StatusData,'NbOutputFile')
|
---|
| 3708 | NbOutputFile=StatusData.NbOutputFile;
|
---|
| 3709 | NbOutputFile_str=num2str(NbOutputFile);
|
---|
| 3710 | end
|
---|
| 3711 | message={[num2str(numel(datnum)) ' file(s) done over ' NbOutputFile_str] ;['oldest modification: ' ListDisplay{indfirst} ' : ' datestr(first)];...
|
---|
| 3712 | ['latest modification: ' ListDisplay{indlast} ' : ' datestr(last)]};
|
---|
| 3713 | end
|
---|
| 3714 | set(htitlebox,'String', [OutputDir{1};message])
|
---|
| 3715 |
|
---|
| 3716 | %% update the waitbar
|
---|
| 3717 | hwaitbar=findobj(hfig,'tag','waitbar');
|
---|
| 3718 | if ~isempty(NbOutputFile)
|
---|
| 3719 | BarPosition=get(hwaitbar,'Position');
|
---|
| 3720 | BarPosition(3)=0.9*numel(datnum)/NbOutputFile;
|
---|
| 3721 | set(hwaitbar,'Position',BarPosition)
|
---|
| 3722 | end
|
---|
| 3723 |
|
---|
| 3724 | %------------------------------------------------------------------------
|
---|
| 3725 | % --- Executes on selection change in ActionExt.
|
---|
| 3726 | %------------------------------------------------------------------------
|
---|
| 3727 | function ActionExt_Callback(hObject, eventdata, handles)
|
---|
| 3728 |
|
---|
| 3729 | ActionExtList=get(handles.ActionExt,'String');
|
---|
| 3730 | ActionExt=ActionExtList{get(handles.ActionExt,'Value')};
|
---|
| 3731 | if strcmp(ActionExt,'.py (in dev.)')
|
---|
| 3732 | set(handles.RunMode,'Value',2)
|
---|
| 3733 | end
|
---|
| 3734 |
|
---|
| 3735 |
|
---|
| 3736 | function num_NbSlice_Callback(hObject, eventdata, handles)
|
---|
| 3737 | NbSlice=str2num(get(handles.num_NbSlice,'String'));
|
---|
| 3738 |
|
---|
| 3739 | %------------------------------------------------------------------------
|
---|
| 3740 | % --- set the visibility of relevant velocity type menus:
|
---|
| 3741 | function menu=set_veltype_display(Civ,FileType)
|
---|
| 3742 | %------------------------------------------------------------------------
|
---|
| 3743 | if ~exist('FileType','var')
|
---|
| 3744 | FileType='civx';
|
---|
| 3745 | end
|
---|
| 3746 | switch FileType
|
---|
| 3747 | case 'civx'
|
---|
| 3748 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'};
|
---|
| 3749 | if isequal(Civ,0)
|
---|
| 3750 | imax=0;
|
---|
| 3751 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
| 3752 | imax=1;
|
---|
| 3753 | elseif isequal(Civ,3)
|
---|
| 3754 | imax=3;
|
---|
| 3755 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
| 3756 | imax=4;
|
---|
| 3757 | elseif isequal(Civ,6) %patch2
|
---|
| 3758 | imax=6;
|
---|
| 3759 | end
|
---|
| 3760 | case 'civdata'
|
---|
| 3761 | menu={'civ1';'filter1';'civ2';'filter2'};
|
---|
| 3762 | if isequal(Civ,0)
|
---|
| 3763 | imax=0;
|
---|
| 3764 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
| 3765 | imax=1;
|
---|
| 3766 | elseif isequal(Civ,3)
|
---|
| 3767 | imax=2;
|
---|
| 3768 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
| 3769 | imax=3;
|
---|
| 3770 | else%if isequal(Civ,6) %patch2
|
---|
| 3771 | imax=4;
|
---|
| 3772 | end
|
---|
| 3773 | end
|
---|
| 3774 | menu=menu(1:imax);
|
---|
| 3775 |
|
---|
| 3776 |
|
---|
| 3777 | % --- Executes on mouse motion over figure - except title and menu.
|
---|
| 3778 | % function series_WindowButtonMotionFcn(hObject, eventdata, handles)
|
---|
| 3779 | % set(hObject,'Pointer','arrow');
|
---|
| 3780 |
|
---|
| 3781 |
|
---|
| 3782 | % --- Executes on button press in SetPairs.
|
---|
| 3783 | function SetPairs_Callback(hObject, eventdata, handles)
|
---|
| 3784 |
|
---|
| 3785 | %% delete previous occurrence of 'set_pairs'
|
---|
| 3786 | hfig=findobj(allchild(0),'Tag','set_pairs');
|
---|
| 3787 | if ~isempty(hfig)
|
---|
| 3788 | delete(hfig)
|
---|
| 3789 | end
|
---|
| 3790 |
|
---|
| 3791 | %% create the GUI set_pairs
|
---|
| 3792 | set(0,'Unit','points')
|
---|
| 3793 | ScreenSize=get(0,'ScreenSize'); % get the size of the screen, to put the fig on the upper right
|
---|
| 3794 | Width=220; % fig width in points (1/72 inch)
|
---|
| 3795 | Height=min(0.8*ScreenSize(4),300);
|
---|
| 3796 | Left=ScreenSize(3)- Width-40; % right edge close to the right, with margin=40
|
---|
| 3797 | Bottom=ScreenSize(4)-Height-40; % put fig at top right
|
---|
| 3798 | hfig=findobj(allchild(0),'Tag','set_slice');
|
---|
| 3799 | if ~isempty(hfig),delete(hfig), end; % delete existing version of the GUI
|
---|
| 3800 | hfig=figure('name','set_pairs','tag','set_pairs','MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height]);
|
---|
| 3801 | BackgroundColor=get(hfig,'Color');
|
---|
| 3802 | SeriesData=get(handles.series,'UserData');
|
---|
| 3803 | TimeUnit=get(handles.TimeUnit,'String');
|
---|
| 3804 | PairString=get(handles.PairString,'Data');
|
---|
| 3805 | ListViewLines=find(cellfun('isempty',PairString)==0); % find list of non empty pairs
|
---|
| 3806 | ListViewMenu=cell(numel(ListViewLines),1);
|
---|
| 3807 | %iview=get(handles.PairString,'Value');
|
---|
| 3808 | iview=[];
|
---|
| 3809 | for ilist=1:numel(ListViewLines)
|
---|
| 3810 | ListViewMenu{ilist}=num2str(ListViewLines(ilist));
|
---|
| 3811 | end
|
---|
| 3812 | if isempty(iview)
|
---|
| 3813 | ListViewValue=numel(ListViewLines); % we work by default on the pair option for the last line which requires pairs
|
---|
| 3814 | iview=ListViewLines(end);
|
---|
| 3815 | else
|
---|
| 3816 | ListViewValue=find(ListViewLines==iview);
|
---|
| 3817 | end
|
---|
| 3818 | ref_i=str2num(get(handles.num_first_i,'String'));
|
---|
| 3819 | ref_j=1; % default
|
---|
| 3820 | if strcmp(get(handles.num_first_j,'String'),'Visible')
|
---|
| 3821 | ref_j=str2num(get(handles.num_first_j,'String'));
|
---|
| 3822 | end
|
---|
| 3823 | [ModeMenu,ModeValue]=update_mode(SeriesData.i1_series{1},SeriesData.i2_series{1},SeriesData.j2_series{1});
|
---|
| 3824 | InputTable=get(handles.InputTable,'Data');
|
---|
| 3825 | displ_pair=update_listpair(SeriesData.i1_series{1},SeriesData.i2_series{1},SeriesData.j1_series{1},SeriesData.j2_series{1},ModeMenu{ModeValue},...
|
---|
| 3826 | SeriesData.Time{1},TimeUnit,ref_i,ref_j,SeriesData.TimeName,InputTable,SeriesData.FileInfo{1});
|
---|
| 3827 | for iline=1:size(InputTable,1)
|
---|
| 3828 | viewcell{iline}=num2str(iline);
|
---|
| 3829 | end
|
---|
| 3830 | viewcell=viewcell';
|
---|
| 3831 | ModeMenu={'bursts';'series(Dj)'};
|
---|
| 3832 | ModeValue=1;
|
---|
| 3833 | %i1_series,i2_series,j1_series,j2_series,mode,time,TimeUnit,ref_i,ref_j,TimeName,InputTable,FileInfo
|
---|
| 3834 | % first raw of the GUI
|
---|
| 3835 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.88 0.5 0.1],'BackgroundColor',BackgroundColor,...
|
---|
| 3836 | 'String','row to edit #','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right'); % title
|
---|
| 3837 | uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.54 0.8 0.3 0.2],'BackgroundColor',[1 1 1],...
|
---|
| 3838 | 'Callback',@(hObject,eventdata)ListView_Callback(hObject,eventdata),'String',viewcell,'Value',1,'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
| 3839 | 'Tag','ListView','TooltipString','''ListView'':choice of the file series w for pair display');
|
---|
| 3840 | % second raw of the GUI
|
---|
| 3841 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.79 0.7 0.1],'BackgroundColor',BackgroundColor,...
|
---|
| 3842 | 'String','mode of index pairing:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left'); % title
|
---|
| 3843 | uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.05 0.62 0.9 0.2],'BackgroundColor',[1 1 1],...
|
---|
| 3844 | 'Callback',@(hObject,eventdata)Mode_Callback(hObject,eventdata),'String',ModeMenu,'Value',ModeValue,'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
| 3845 | 'Tag','Mode','TooltipString','''Mode'': choice of the image pair mode');
|
---|
| 3846 | % third raw
|
---|
| 3847 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.6 0.7 0.1],'BackgroundColor',BackgroundColor,...
|
---|
| 3848 | 'String','pair choice:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left'); % title
|
---|
| 3849 | uicontrol('Style','listbox','Units','normalized', 'Position', [0.05 0.42 0.9 0.2],'BackgroundColor',[1 1 1],...
|
---|
| 3850 | 'Callback',@(hObject,eventdata)ListPair_Callback(hObject,eventdata),'String',displ_pair,'Value',1,'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
| 3851 | 'Tag','ListPair','TooltipString','''ListPair'': menu for selecting the image pair');
|
---|
| 3852 | uicontrol('Style','text','Units','normalized', 'Position', [0.1 0.22 0.8 0.1],'BackgroundColor',BackgroundColor,...
|
---|
| 3853 | 'String','ref_i ref_j','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center'); % title
|
---|
| 3854 | uicontrol('Style','edit','Units','normalized', 'Position', [0.15 0.17 0.3 0.08],'BackgroundColor',[1 1 1],...
|
---|
| 3855 | 'Callback',@(hObject,eventdata)num_ref_i_Callback(hObject,eventdata),'String',num2str(ref_i),'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
| 3856 | 'Tag','num_ref_i','TooltipString','''num_ref_i'': reference field index i used to display dt in ''list_pair_civ''');
|
---|
| 3857 | uicontrol('Style','edit','Units','normalized', 'Position', [0.55 0.17 0.3 0.08],'BackgroundColor',[1 1 1],...
|
---|
| 3858 | 'Callback',@(hObject,eventdata)num_ref_j_Callback(hObject,eventdata),'String',num2str(ref_j),'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
| 3859 | 'Tag','num_ref_j','TooltipString','''num_ref_j'': reference field index i used to display dt in ''list_pair_civ''');
|
---|
| 3860 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.01 0.01 0.3 0.12],'BackgroundColor',[0 1 0],...
|
---|
| 3861 | 'Callback',@(hObject,eventdata)OK_Callback(hObject,eventdata),'String','OK','FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
| 3862 | 'Tag','OK','TooltipString','''OK'': validate the choice');
|
---|
| 3863 | % last raw of the GUI: pushbuttons
|
---|
| 3864 | % uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.35 0.01 0.3 0.15],'BackgroundColor',[0 1 0],'String','OK','Callback',@(hObject,eventdata)OK_Callback(hObject,eventdata),...
|
---|
| 3865 | % 'FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''OK'': apply the output to the current field series in uvmat');
|
---|
| 3866 | drawnow
|
---|
| 3867 |
|
---|
| 3868 | %------------------------------------------------------------------------
|
---|
| 3869 | function ListView_Callback(hObject,eventdata)
|
---|
| 3870 | Mode_Callback(hObject,eventdata)
|
---|
| 3871 |
|
---|
| 3872 | %------------------------------------------------------------------------
|
---|
| 3873 | function Mode_Callback(hObject,eventdata)
|
---|
| 3874 | %% get input info
|
---|
| 3875 | hseries=findobj(allchild(0),'tag','series'); % handles of the GUI series
|
---|
| 3876 | hhseries=guidata(hseries); % handles of the elements in the GUI series
|
---|
| 3877 | TimeUnit=get(hhseries.TimeUnit,'String');
|
---|
| 3878 | SeriesData=get(hseries,'UserData');
|
---|
| 3879 | mode_list=get(hObject,'String');
|
---|
| 3880 | mode=mode_list{get(hObject,'Value')};
|
---|
| 3881 | hListView=findobj(get(hObject,'parent'),'Tag','ListView');
|
---|
| 3882 | iview=get(hListView,'Value');
|
---|
| 3883 | i1_series=SeriesData.i1_series{iview};
|
---|
| 3884 | i2_series=SeriesData.i2_series{iview};
|
---|
| 3885 | j1_series=SeriesData.j1_series{iview};
|
---|
| 3886 | j2_series=SeriesData.j2_series{iview};
|
---|
| 3887 |
|
---|
| 3888 | %% enable j index visibility after the new choice
|
---|
| 3889 |
|
---|
| 3890 | if strcmp(mode,'series(Dj)')
|
---|
| 3891 | status_j='on'; % default
|
---|
| 3892 | else
|
---|
| 3893 | status_j='off'; % no j index needed for bust case
|
---|
| 3894 | end
|
---|
| 3895 | enable_j(hhseries,status_j) % no j index needed
|
---|
| 3896 |
|
---|
| 3897 | %% get the reference indices for the time interval Dt
|
---|
| 3898 | href_i=findobj(get(hObject,'parent'),'Tag','ref_i');
|
---|
| 3899 | ref_i=[];ref_j=[];
|
---|
| 3900 | if strcmp(get(href_i,'Visible'),'on')
|
---|
| 3901 | ref_i=str2num(get(href_i,'String'));
|
---|
| 3902 | end
|
---|
| 3903 | if isempty(ref_i)
|
---|
| 3904 | ref_i=1;
|
---|
| 3905 | end
|
---|
| 3906 | if isempty(ref_j)
|
---|
| 3907 | ref_j=1;
|
---|
| 3908 | end
|
---|
| 3909 |
|
---|
| 3910 | %% update the menu ListPair
|
---|
| 3911 | Menu=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,SeriesData.Time{iview},TimeUnit,ref_i,ref_j,SeriesData.FileInfo);
|
---|
| 3912 | hlist_pairs=findobj(get(hObject,'parent'),'Tag','ListPair');
|
---|
| 3913 | set(hlist_pairs,'Value',1)% set the first choice by default in ListPair
|
---|
| 3914 | set(hlist_pairs,'String',Menu)% set the menu in ListPair
|
---|
| 3915 | ListPair_Callback(hlist_pairs,[])% apply the default choice in ListPair
|
---|
| 3916 |
|
---|
| 3917 | %-------------------------------------------------------------
|
---|
| 3918 | % --- Executes on selection in ListPair.
|
---|
| 3919 | function ListPair_Callback(hObject,eventdata)
|
---|
| 3920 | %------------------------------------------------------------
|
---|
| 3921 | list_pair=get(hObject,'String'); % get the menu of image pairs
|
---|
| 3922 | if isempty(list_pair)
|
---|
| 3923 | string='';
|
---|
| 3924 | else
|
---|
| 3925 | string=list_pair{get(hObject,'Value')};
|
---|
| 3926 | % string=regexprep(string,',.*',''); % removes time indication (after ',')
|
---|
| 3927 | end
|
---|
| 3928 | hseries=findobj(allchild(0),'tag','series');
|
---|
| 3929 | hPairString=findobj(hseries,'tag','PairString');
|
---|
| 3930 | PairString=get(hPairString,'Data');
|
---|
| 3931 | hListView=findobj(get(hObject,'parent'),'Tag','ListView');
|
---|
| 3932 | iview=get(hListView,'Value');
|
---|
| 3933 | PairString{iview,1}=string;
|
---|
| 3934 | % report the selected pair string to the table PairString
|
---|
| 3935 | set(hPairString,'Data',PairString)
|
---|
| 3936 |
|
---|
| 3937 |
|
---|
| 3938 | %------------------------------------------------------------------------
|
---|
| 3939 | function num_ref_i_Callback(hObject, eventdata)
|
---|
| 3940 | %------------------------------------------------------------------------
|
---|
| 3941 | Mode_Callback([],[])
|
---|
| 3942 |
|
---|
| 3943 | %------------------------------------------------------------------------
|
---|
| 3944 | function num_ref_j_Callback(hObject, eventdata)
|
---|
| 3945 | %------------------------------------------------------------------------
|
---|
| 3946 | Mode_Callback([],[])
|
---|
| 3947 |
|
---|
| 3948 | %------------------------------------------------------------------------
|
---|
| 3949 | function OK_Callback(hObject, eventdata)
|
---|
| 3950 | %------------------------------------------------------------------------
|
---|
| 3951 | delete(get(hObject,'parent'))
|
---|
| 3952 |
|
---|
| 3953 |
|
---|
| 3954 | %------------------------------------------------------------------------
|
---|
| 3955 | % --- Executes on button press in ClearLine.
|
---|
| 3956 | %------------------------------------------------------------------------
|
---|
| 3957 | function ClearLine_Callback(hObject, eventdata, handles)
|
---|
| 3958 | InputTable=get(handles.InputTable,'Data');
|
---|
| 3959 | iline=str2double(get(handles.InputLine,'String'));
|
---|
| 3960 | if size(InputTable,1)>1
|
---|
| 3961 | InputTable(iline,:)=[]; % suppress the current line if not the first
|
---|
| 3962 | set(handles.InputTable,'Data',InputTable);
|
---|
| 3963 | end
|
---|
| 3964 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refr
|
---|
| 3965 |
|
---|
| 3966 |
|
---|
| 3967 | % --- Executes on button press in MonitorCluster.
|
---|
| 3968 | function MonitorCluster_Callback(hObject, eventdata, handles)
|
---|
| 3969 |
|
---|
| 3970 | [rr,ss]=system('oarstat |grep N=UVmat');% check the list of jobs launched with uvmat
|
---|
| 3971 | if isempty(ss)
|
---|
| 3972 | disp( 'no job presently submitted with uvmat')
|
---|
| 3973 | else
|
---|
| 3974 | disp('format: R/W=run/wait, time lapsed, R=nbre of cores,W=walltime')
|
---|
| 3975 | disp(ss)
|
---|
| 3976 | end
|
---|
| 3977 |
|
---|
| 3978 |
|
---|
| 3979 | function OutputSubDir_Callback(hObject, eventdata, handles)
|
---|
| 3980 | set(handles.OutputSubDir,'BackgroundColor',[1 1 1])
|
---|
| 3981 |
|
---|
| 3982 |
|
---|
| 3983 | % --- Executes on button press in CheckOverwrite.
|
---|
| 3984 | function CheckOverwrite_Callback(hObject, eventdata, handles)
|
---|
| 3985 |
|
---|
| 3986 | % --- Executes on button press in TestCPUTime.
|
---|
| 3987 | function TestCPUTime_Callback(hObject, eventdata, handles)
|
---|
| 3988 | % hObject handle to TestCPUTime (see GCBO)
|
---|
| 3989 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 3990 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 3991 |
|
---|
| 3992 |
|
---|
| 3993 | % --- Executes on button press in DiskQuota.
|
---|
| 3994 | function DiskQuota_Callback(hObject, eventdata, handles)
|
---|
| 3995 | SeriesData=get(handles.series,'UserData');
|
---|
| 3996 | system(SeriesData.SeriesParam.DiskQuotaCmd)
|
---|
| 3997 |
|
---|
| 3998 |
|
---|
| 3999 | % --- Executes on button press in Replicate.
|
---|
| 4000 | function Replicate_Callback(hObject, eventdata, handles)
|
---|
| 4001 | if get(handles.Replicate,'Value')
|
---|
| 4002 | InputTable=get(handles.InputTable,'Data');
|
---|
| 4003 | for ilist=1:size(InputTable,1)
|
---|
| 4004 | InputDir{ilist}=fullfile(InputTable{ilist,1},InputTable{ilist,2});
|
---|
| 4005 | end
|
---|
| 4006 | browse_data(InputDir)
|
---|
| 4007 | else
|
---|
| 4008 | hh=findobj(allchild(0),'Tag','browse_data');
|
---|
| 4009 | if ~isempty(hh)
|
---|
| 4010 | delete(hh)
|
---|
| 4011 | end
|
---|
| 4012 | end
|
---|
| 4013 |
|
---|
| 4014 |
|
---|
| 4015 |
|
---|
| 4016 |
|
---|
| 4017 | function OutputPath_Callback(hObject, eventdata, handles)
|
---|
| 4018 |
|
---|
| 4019 |
|
---|
| 4020 | function Experiment_Callback(hObject, eventdata, handles)
|
---|
| 4021 |
|
---|
| 4022 |
|
---|
| 4023 | function Device_Callback(hObject, eventdata, handles)
|
---|
| 4024 |
|
---|
| 4025 |
|
---|
| 4026 | % --- Executes on button press in OutputPathBrowse.
|
---|
| 4027 | function OutputPathBrowse_Callback(hObject, eventdata, handles)
|
---|
| 4028 | CheckValue=get(handles.OutputPathBrowse,'Value');
|
---|
| 4029 | if CheckValue
|
---|
| 4030 | OutputPath=uigetdir(get(handles.OutputPath,'String'));
|
---|
| 4031 | set(handles.OutputPath,'String',OutputPath)
|
---|
| 4032 | else
|
---|
| 4033 | InputTable=get(handles.InputTable,'Data');
|
---|
| 4034 | set(handles.OutputPath,'String',InputTable{1,1})
|
---|
| 4035 | end
|
---|
| 4036 |
|
---|
| 4037 |
|
---|
| 4038 |
|
---|
| 4039 | function Mask_Callback(hObject, eventdata, handles)
|
---|
| 4040 | % hObject handle to Mask (see GCBO)
|
---|
| 4041 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 4042 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 4043 |
|
---|
| 4044 | % Hints: get(hObject,'String') returns contents of Mask as text
|
---|
| 4045 | % str2double(get(hObject,'String')) returns contents of Mask as a double
|
---|