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