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