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