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