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