- Timestamp:
- Jun 25, 2012, 12:12:24 AM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/fill_GUI.m
r461 r472 5 5 errormsg=''; 6 6 fields=fieldnames(Param);%list of fields in Param 7 % loop on the elements of the input structure Param 7 8 for ifield=1:numel(fields) 8 if isstruct(Param.(fields{ifield})) 9 if isstruct(Param.(fields{ifield}))% case of sa sub-structure 9 10 if isfield(handles,fields{ifield}) 10 11 set(handles.(fields{ifield}),'Visible','on') … … 13 14 hchild.(get(children(ichild),'tag'))=children(ichild); 14 15 end 15 errormsg=fill_GUI(Param.(fields{ifield}),hchild); 16 errormsg=fill_GUI(Param.(fields{ifield}),hchild);% apply the function to the substructure 16 17 end 17 18 else 18 19 hh=[]; 19 input_data=Param.(fields{ifield}) ;20 input_data=Param.(fields{ifield}) 20 21 check_done=0; 21 22 if isfield(handles,fields{ifield}) 22 hh=handles.(fields{ifield}) ;23 hh=handles.(fields{ifield}) 23 24 if strcmp(get(hh,'Type'),'uitable') 24 25 set(hh,'Visible','on') … … 45 46 end 46 47 set(hh,'String',input_data) 47 case{'Listbox','popupmenu'} 48 case{'listbox','popupmenu'} 49 input_data 48 50 if isnumeric(input_data) 49 51 input_data=num2str(input_data); 50 52 end 51 53 menu=get(hh,'String'); 52 iline=find(strcmp(input_data,menu)); 53 if isempty(iline) 54 iline=numel(menu)+1; 55 set(hh,'String',[menu;{input_data}]) 54 if ischar(input_data) 55 input_data={input_data}; 56 56 end 57 set(hh,'Value',iline) 57 values=zeros(size(input_data)); 58 for idata=1:numel(input_data) 59 iline=find(strcmp(input_data{idata},menu)); 60 if isempty(iline) 61 values(idata)=numel(menu)+1; 62 menu=[menu;input_data(idata)]; 63 else 64 values(idata)=iline; 65 end 66 end 67 set(hh,'String',[menu;input_data(idata)]) 68 set(hh,'Value',values) 58 69 end 59 70 end -
trunk/src/find_file_series.m
r469 r472 15 15 % = 'netcdf' other netcdf files 16 16 % = 'video': movie recognised by VideoReader (e;g. avi) 17 % Object: video object (=[] otherwise)17 % MovieObject: video object (=[] otherwise) 18 18 % 19 19 %INPUT … … 37 37 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 38 38 39 function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType, Object,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput)39 function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput) 40 40 %------------------------------------------------------------------------ 41 41 … … 50 50 j1_series=zeros(1,1,1); 51 51 j2_series=zeros(1,1,1); 52 % ifile_min=1;%default 53 [FileType,FileInfo,Object]=get_file_type(fullfileinput); 54 NbFrame=1; 55 56 switch FileType 57 case 'multimage' 58 NbFrame=FileInfo.NumberOfFrames; 59 case {'video','mmreader'} 60 NomType='*'; 61 NbFrame=FileInfo.NumberOfFrames; 62 end 63 64 RootFile_i=''; 52 [FileType,FileInfo,MovieObject]=get_file_type(fullfileinput); 53 if ~exist(FilePath,'dir') 54 return % don't go further if the dir path does not exist 55 end 56 % NbFrame=1; 57 % switch FileType 58 % case 'multimage' 59 % NbFrame=FileInfo.NumberOfFrames; 60 % case {'video','mmreader'} 61 % NomType='*'; 62 % NbFrame=FileInfo.NumberOfFrames; 63 % end 64 65 % RootFile_i=''; 65 66 NomTypePref=''; 66 67 if strcmp(NomType,'')||strcmp(NomType,'*') … … 70 71 RootFile=''; 71 72 end 72 i1_input=1;% the index now refer to the frame in the movie, choose 1 at opening73 i2_input=[];74 j1_input=[];75 j2_input=[];73 % i1_input=1;% the index now refer to the frame in the movie, choose 1 at opening 74 % i2_input=[]; 75 % j1_input=[]; 76 % j2_input=[]; 76 77 else 77 78 %% possibly include the first index in the root name, if there exists a corresponding xml file … … 101 102 i1_str='(?<i1>)';%will set i1=[]; 102 103 i1_star=''; 103 % r.sep2='';104 104 i2_str='(?<i2>)';%will set i2=[]; 105 105 i2_star=''; 106 % sep3='';107 106 j1_str='(?<j1>)';%will set j1=[]; 108 107 j1_star=''; 109 % sep4='';110 108 j2_str='(?<j2>)';%will set j2=[]; 111 109 j2_star=''; 112 % NomTypeStr=NomType;113 110 %Look for cases with letter indexing for the second index 114 111 r=regexp(NomType,'^(?<sep1>_?)(?<i1>\d+)(?<j1>[a|A])(?<j2>[b|B]?)$','names'); … … 240 237 %% update the file type if the input file does not exist (pb of 0001) 241 238 if isempty(FileType) 242 [FileType,tild, Object]=get_file_type(dirpair(ifile_min).name);239 [FileType,tild,MovieObject]=get_file_type(fullfile(FilePath,dirpair(ifile_min).name)); 243 240 end 244 241 end … … 251 248 252 249 %% introduce the frame index in case of movies or multimage type 253 if NbFrame>1250 if isfield(FileInfo,'NumberOfFrames')>1 && FileInfo.NumberOfFrames >1 254 251 if isempty(i1_series) 255 i1_series=(1: NbFrame)';252 i1_series=(1:FileInfo.NumberOfFrames)'; 256 253 i1_input=1; 257 254 else 258 j1_series=(1: NbFrame)';255 j1_series=(1:FileInfo.NumberOfFrames)'; 259 256 j1_input=1; 260 257 end … … 289 286 end 290 287 291 % %% deals with frame index in movies 292 % switch FileType 293 % case 'multimage' 294 % NomType='*'; 295 % i1_series=(1:FileInfo.NbFrame)'; 296 % case {'video','mmreader'} 297 % NomType='*'; 298 % i1_series=(1:FileInfo.NumberOfFrames)'; 299 % end 300 288 -
trunk/src/get_file_type.m
r469 r472 32 32 FileType='xls'; 33 33 otherwise 34 if ~isempty( imformats(regexprep(FileExt,'^.','')))34 if ~isempty(FileExt) && ~isempty(imformats(regexprep(FileExt,'^.',''))) 35 35 try 36 36 imainfo=imfinfo(fileinput); -
trunk/src/msgbox_uvmat.m
r421 r472 45 45 set(handles.figure1,'Units','pixels') 46 46 FigPos=[100 150 500 50];%default position 47 if exist('Position','var') 47 if exist('Position','var') && numel(Position)>=2 48 48 FigPos(1)=Position(1); 49 49 FigPos(2)=Position(2)-FigPos(4);% upper left corner set by input Position -
trunk/src/read_civxdata.m
r420 r472 53 53 DataTest=nc2struct(filename,'ListGlobalAttribute','Conventions','CivStage'); 54 54 if isfield(DataTest,'Txt') 55 errormsg= DataTest.Txt;55 errormsg=['nc2struct:' DataTest.Txt]; 56 56 return 57 57 elseif isequal(DataTest.Conventions,'uvmat/civdata')%test for new civ format 58 58 [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType,DataTest.CivStage); 59 % if ~isempty(errormsg) 60 % msgbox_uvmat('ERROR',errormsg) 61 % end 59 if ~isempty(errormsg),errormsg=['read_civdata:' errormsg];end 62 60 return 63 61 end … … 79 77 [Field,vardetect,ichoice]=nc2struct(filename,var);%read the variables in the netcdf file 80 78 if isfield(Field,'Txt') 81 errormsg= Field.Txt;79 errormsg=['nc2struct:' Field.Txt]; 82 80 return 83 81 end -
trunk/src/read_field.m
r466 r472 57 57 FieldList=calc_field;%list of possible fields for Civx data 58 58 ParamOut.ColorVar='';%default 59 field_index=strcmp(ParamIn.FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data 59 if ischar(ParamIn.FieldName) 60 FieldName=ParamIn.FieldName; 61 else 62 FieldName=ParamIn.FieldName{1}; 63 end 64 field_index=strcmp(FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data 60 65 if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist 61 66 Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ','CivStage'); … … 66 71 InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}]; 67 72 [Field,ParamOut.VelType,errormsg]=read_civdata(FileName,InputField,ParamIn.VelType,Data.CivStage); 73 if ~isempty(errormsg),errormsg=['read_civdata:' errormsg];return,end 68 74 CivStage=Field.CivStage; 69 75 ParamOut.CivStage=Field.CivStage; … … 74 80 InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}]; 75 81 [Field,ParamOut.VelType]=read_civxdata(FileName,InputField,ParamIn.VelType); 82 if ~isempty(errormsg),errormsg=['read_civxdata:' errormsg];return,end 76 83 CivStage=Field.CivStage; 77 84 ParamOut.CivStage=Field.CivStage; … … 84 91 end 85 92 end 86 else 87 InputField={ParamOut.FieldName}; 93 else 94 InputField=ParamOut.FieldName; 95 if ischar(InputField) 96 InputField={InputField}; 97 end 88 98 if isfield(ParamIn,'ColorVar') 89 99 ParamOut.ColorVar=ParamIn.ColorVar; … … 91 101 end 92 102 [Field,ParamOut.VelType,errormsg]=read_civxdata(FileName,InputField,ParamIn.VelType); 93 if ~isempty(errormsg) 94 return 95 end 103 if ~isempty(errormsg),errormsg=['read_civxdata:' errormsg];return,end 96 104 CivStage=Field.CivStage; 97 105 ParamOut.CivStage=Field.CivStage; … … 123 131 Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; 124 132 if isfield(Field, Field.ListGlobalAttribute{iline}) 125 eval(['val=Field.' Field.ListGlobalAttribute{iline} ';'])133 val=Field.(Field.ListGlobalAttribute{iline}); 126 134 if ischar(val); 127 135 Tabcell{iline,2}=val; … … 160 168 end 161 169 catch ME 162 errormsg= ME.message;170 errormsg=[FileType ' input: ' ME.message]; 163 171 return 164 172 end -
trunk/src/series.m
r471 r472 81 81 for ifile=1:min(length(h.MenuFile),5) 82 82 eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) 83 % eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});'])84 83 end 85 84 end 86 % if isfield(h,'MenuFile')87 % for ifile=1:min(length(h.MenuFile),5)88 % eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});'])89 % eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});'])90 % end91 % end92 93 85 test_profil_perso=1; 94 % if isfield(h,'MenuFile_1') && exist(h.MenuFile_1,'file')95 % set(handles.MenuFile_1,'Label',h.MenuFile_1);96 % set(handles.MenuFile_insert_1,'Label',h.MenuFile_1);97 % end98 % if isfield(h,'MenuFile_2')&& exist(h.MenuFile_2,'file')99 % set(handles.MenuFile_2,'Label',h.MenuFile_2);100 % set(handles.MenuFile_insert_2,'Label',h.MenuFile_2);101 % end102 % if isfield(h,'MenuFile_3')&& exist(h.MenuFile_3,'file')103 % set(handles.MenuFile_3,'Label',h.MenuFile_3);104 % set(handles.MenuFile_insert_3,'Label',h.MenuFile_3);105 % end106 % if isfield(h,'MenuFile_4')&& exist(h.MenuFile_4,'file')107 % set(handles.MenuFile_4,'Label',h.MenuFile_4);108 % set(handles.MenuFile_insert_4,'Label',h.MenuFile_4);109 % end110 % if isfield(h,'MenuFile_5')&& exist(h.MenuFile_5,'file')111 % set(handles.MenuFile_5,'Label',h.MenuFile_5);112 % set(handles.MenuFile_insert_5,'Label',h.MenuFile_5);113 % end114 86 end 115 87 … … 135 107 display_file_name(handles,param.FileName,0) 136 108 end 109 InputTable={'','','','',''}; 110 set(handles.InputTable,'Data',InputTable) 137 111 end 138 112 … … 141 115 set(handles.FieldName,'String',param.list_fields);% list menu fields 142 116 set(handles.FieldName,'Value',param.index_fields);% selected string index 143 FieldCell{1}=param.list_fields{param.index_fields};117 % FieldCell{1}=param.list_fields{param.index_fields}; 144 118 end 145 119 … … 209 183 set(handles.TransformName,'UserData',fct_handle)% store the list of path in UserData of ACTION 210 184 185 %% Adjust the GUI according to the binaries available in PARAM.xml 186 path_uvmat=fileparts(which('uvmat')); %path to civ 187 addpath (path_uvmat) ; %add the path to civ, (useful in case of change of working directory after civ has been s opened in the working directory) 188 errormsg=[];%default error message 189 xmlfile='PARAM.xml'; 190 if exist(xmlfile,'file') 191 try 192 t=xmltree(xmlfile); 193 sparam=convert(t); 194 catch ME 195 errormsg={' Unable to read the file PARAM.xml defining the civx binaries:';ME.message}; 196 end 197 else 198 errormsg=[xmlfile ' not found: path to civx binaries undefined']; 199 end 200 if ~isempty(errormsg) 201 msgbox_uvmat('WARNING',errormsg); 202 end 203 test_batch=0;%default: ,no batch mode available 204 if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') 205 test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod 206 end 207 RUNVal=get(handles.RunMode,'Value'); 208 if test_batch==0 209 if RUNVal>2 210 set(handles.RunMode,'Value',1) 211 end 212 set(handles.RunMode,'String',{'local';'background'}) 213 else 214 set(handles.RunMode,'String',{'local';'background';'cluster'}) 215 end 216 % if isfield(sparam.RunParam,'CivBin') 217 % if ~exist(sparam.RunParam.CivBin,'file') 218 % sparam.RunParam.CivBin=fullfile(path_uvmat,sparam.RunParam.CivBin); 219 % end 220 % else 221 % sparam.RunParam.CivBin=''; 222 % end 211 223 % display the GUI for the default actionname 'check_data_files' 212 ActionName_Callback(hObject, eventdata, handles)224 % ActionName_Callback(hObject, eventdata, handles) 213 225 214 226 %------------------------------------------------------------------------ … … 235 247 %------------------------------------------------------------------------ 236 248 InputTable=get(handles.InputTable,'Data'); 237 RootPathCell=InputTable(:,1); 238 SubDirCell=InputTable(:,2); 239 RootFileCell=InputTable(:,3); 249 if isempty(InputTable) 250 RootPathCell={}; 251 else 252 RootPathCell=InputTable(:,1); 253 end 240 254 oldfile=''; %default 241 255 if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box … … 251 265 end 252 266 end 253 else 267 else 268 SubDirCell=InputTable(:,2); 269 RootFileCell=InputTable(:,3); 254 270 oldfile=fullfile(RootPathCell{1},SubDirCell{1},RootFileCell{1}); 255 271 end … … 265 281 'Pick a file',oldfile); 266 282 fileinput=[PathName FileName];%complete file name 267 sizf=size(fileinput); 268 if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end 283 if isempty(fileinput),return;end %abandon if no file is introduced by the browser 269 284 [path,name,ext]=fileparts(fileinput); 270 SeriesData=[];%dfault271 285 if isequal(ext,'.xml') 272 Param=xml2struct(fileinput); 273 fill_GUI(Param,handles);%fill the GUI with the parameters retrieved from the xml file 274 if isfield(Param,'CheckObject')&& Param.CheckObject 275 set_object(Param.ProjObject) 276 end 277 return 286 [Param,Heading]=xml2struct(fileinput); 287 if ~strcmp(Heading,'Series') 288 msg_box_uvmat('ERROR','xml file heading is not <Series>') 289 else 290 fill_GUI(Param,handles);%fill the GUI with the parameters retrieved from the xml file 291 if isfield(Param,'CheckObject')&& Param.CheckObject 292 set_object(Param.ProjObject) 293 end 294 set(handles.REFRESH,'UserData',[1:size(Param.InputTable,1)]) 295 REFRESH_Callback([],[], handles) 296 return 297 end 278 298 elseif isequal(ext,'.xls') 279 299 msg_box_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer 280 300 else 281 301 display_file_name(handles,fileinput,0) 282 %update list of recent files in the menubar283 % MenuFile_1=fileinput;284 % MenuFile_2=get(handles.MenuFile_1,'Label');285 % MenuFile_3=get(handles.MenuFile_2,'Label');286 % MenuFile_4=get(handles.MenuFile_3,'Label');287 % MenuFile_5=get(handles.MenuFile_4,'Label');288 % set(handles.MenuFile_1,'Label',MenuFile_1)289 % set(handles.MenuFile_2,'Label',MenuFile_2)290 % set(handles.MenuFile_3,'Label',MenuFile_3)291 % set(handles.MenuFile_4,'Label',MenuFile_4)292 % set(handles.MenuFile_5,'Label',MenuFile_5)293 % set(handles.MenuFile_insert_1,'Label',MenuFile_1)294 % set(handles.MenuFile_insert_2,'Label',MenuFile_2)295 % set(handles.MenuFile_insert_3,'Label',MenuFile_3)296 % set(handles.MenuFile_insert_4,'Label',MenuFile_4)297 % set(handles.MenuFile_insert_5,'Label',MenuFile_5)298 % dir_perso=prefdir;299 % profil_perso=fullfile(dir_perso,'uvmat_perso.mat');300 % if exist(profil_perso,'file')301 % save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat302 % else303 % txt=ver('MATLAB');304 % Release=txt.Release;305 % relnumb=str2num(Release(3:4));306 % if relnumb >= 14307 % save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat308 % else309 % save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat310 % end311 % end312 302 end 313 303 … … 377 367 msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer 378 368 else 379 display_file_name(handles,fileinput, 1)369 display_file_name(handles,fileinput,'append') 380 370 end 381 371 … … 384 374 % -------------------------------------------------------------------- 385 375 fileinput=get(handles.MenuFile_insert_1,'Label'); 386 display_file_name(handles,fileinput, 1)376 display_file_name(handles,fileinput,'append') 387 377 388 378 % -------------------------------------------------------------------- … … 390 380 % -------------------------------------------------------------------- 391 381 fileinput=get(handles.MenuFile_insert_2,'Label'); 392 display_file_name(handles,fileinput, 1)382 display_file_name(handles,fileinput,'append') 393 383 394 384 % -------------------------------------------------------------------- … … 396 386 % -------------------------------------------------------------------- 397 387 fileinput=get(handles.MenuFile_insert_3,'Label'); 398 display_file_name( handles,fileinput, 1)388 display_file_name( handles,fileinput,'append') 399 389 400 390 % -------------------------------------------------------------------- … … 402 392 % -------------------------------------------------------------------- 403 393 fileinput=get(handles.MenuFile_insert_4,'Label'); 404 display_file_name( handles,fileinput, 1)394 display_file_name( handles,fileinput,'append') 405 395 406 396 % -------------------------------------------------------------------- … … 408 398 % -------------------------------------------------------------------- 409 399 fileinput=get(handles.MenuFile_insert_5,'Label'); 410 display_file_name(handles,fileinput, 1)400 display_file_name(handles,fileinput,'append') 411 401 412 402 %------------------------------------------------------------------------ … … 414 404 function InputTable_CellEditCallback(hObject, eventdata, handles) 415 405 %------------------------------------------------------------------------ 406 set(handles.REFRESH,'Visible','on') 416 407 iview=eventdata.Indices(1); 408 view_set=get(handles.REFRESH,'UserData'); 409 if isempty(find(view_set==iview)) 410 set(handles.REFRESH,'UserData',[view_set iview]) 411 end 412 %% enable other menus and uicontrols 413 set(handles.MenuOpen_insert,'Enable','on') 414 set(handles.MenuFile_insert_1,'Enable','on') 415 set(handles.MenuFile_insert_2,'Enable','on') 416 set(handles.MenuFile_insert_3,'Enable','on') 417 set(handles.MenuFile_insert_4,'Enable','on') 418 set(handles.MenuFile_insert_5,'Enable','on') 419 set(handles.RUN, 'Enable','On') 420 set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red 421 422 %update the output dir 423 % SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order 424 % SubDirOut=SubDir{1}; 425 % if numel(SubDir)>1 426 % for ilist=2:numel(SubDir) 427 % SubDirOut=[SubDirOut '-' SubDir{ilist}]; 428 % end 429 % end 430 % set(handles.OutputSubDir,'String',SubDirOut) 431 432 %------------------------------------------------------------------------ 433 % --- Executes on button press in REFRESH. 434 function REFRESH_Callback(hObject, eventdata, handles) 435 %------------------------------------------------------------------------ 417 436 InputTable=get(handles.InputTable,'Data'); 418 fileinput=fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]); 419 display_file_name(handles,fileinput,0) 420 %update the output dir 421 SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order 422 SubDirOut=SubDir{1}; 423 if numel(SubDir)>1 424 for ilist=2:numel(SubDir) 425 SubDirOut=[SubDirOut '-' SubDir{ilist}]; 426 end 427 end 428 set(handles.OutputSubDir,'String',SubDirOut) 429 430 %------------------------------------------------------------------------ 431 % --- refresh the GUI data after introduction of a new file 437 view_set=get(handles.REFRESH,'UserData'); 438 set(handles.REFRESH,'BackgroundColor',[0.7 0.7 0.7])% set REFRESH button to grey color 439 drawnow 440 for iview=view_set 441 RootPath=fullfile(InputTable{iview,1},InputTable{iview,2}); 442 if ~exist(RootPath,'dir') 443 i1_series=[]; 444 RootPath=fileparts(RootPath); %will try the upped forldr 445 else 446 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=... 447 find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]); 448 end 449 if isempty(i1_series) 450 [FileName, PathName, filterindex] = uigetfile( ... 451 {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)'; 452 '*.xml', '.xml files '; ... 453 '*.xls', '.xls files '; ... 454 '*.png','.png image files'; ... 455 '*.tif','.tif image files'; ... 456 '*.avi;*.AVI','.avi movie files'; ... 457 '*.nc','.netcdf files'; ... 458 '*.*', 'All Files (*.*)'}, ... 459 ['unvalid entry at line ' num2str(iview) ', pick a file'],RootPath); 460 fileinput=[PathName FileName];%complete file name 461 if isempty(fileinput),return;end %abandon if the operation has been cancelled: no input from browser 462 [path,name,ext]=fileparts(fileinput); 463 display_file_name(handles,fileinput,iview) 464 else 465 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,iview) 466 end 467 end 468 set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to grey color 469 set(handles.REFRESH,'Visible','off') 470 set(handles.REFRESH,'UserData',[]) 471 472 %------------------------------------------------------------------------ 473 % --- Function called when a new file is opened, either by series_OpeningFcn or by the browser 474 function display_file_name(handles,fileinput,iview) 475 %------------------------------------------------------------------------ 476 % 432 477 % INPUT: 433 % handles: handles of the elements in the GUI series 434 % fileinput: name of the input file 435 % append: =0 to refresh the list of file series, =1 to append a new series to the list (from the menu bar option 'Open_insert') 436 function display_file_name(handles,fileinput,append) 437 %------------------------------------------------------------------------ 478 % handles: handles of elements in the GUI 479 % fielinput: input file name, including path 480 % append =0 (refresh the Input table with the new file), ='append' append a new line in the table 438 481 439 482 %% get the input root name, indices, file extension and nomenclature NomType … … 467 510 %% fill the list of file series 468 511 InputTable=get(handles.InputTable,'Data'); 469 if append % display the input data as a new line in the table 470 lastview=size(InputTable,1)+1; 471 InputTable(lastview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; 472 set(handles.ListView,'String',[get(handles.ListView,'String');{num2str(lastview)}]) 473 set(handles.ListView,'Value',lastview) 474 475 else % or re-initialise the list of input file series 476 lastview=1; 477 InputTable=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; 512 if strcmp(iview,'append') % display the input data as a new line in the table 513 iview=size(InputTable,1); 514 InputTable(iview+1,:)={'','','','',''}; 515 InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; 516 elseif iview==0 % or re-initialise the list of input file series 517 iview=1; 518 InputTable=[{'','','','',''};{'','','','',''}]; 519 InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; 478 520 set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}]) 479 521 set(handles.MinIndex,'Data',[{[]},{[]}]) … … 482 524 set(handles.ListView,'String',{'1'}) 483 525 end 526 nbview=size(InputTable,1); 527 set(handles.ListView,'String',mat2cell((1:nbview)',ones(nbview,1))) 528 set(handles.ListView,'Value',iview) 484 529 set(handles.InputTable,'Data',InputTable) 530 531 %% determine the selected reference field indices for pair display 532 ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV 533 if ~isempty(i1) 534 ref_i=i1; 535 if ~isempty(i2) 536 ref_i=floor((ref_i+i2)/2);% reference image number corresponding to the file 537 end 538 end 539 set(handles.num_ref_i,'String',num2str(ref_i)); 540 ref_j=1; %default ref_j is a reference frame index used to find existing pairs from PIV 541 if ~isempty(j1) 542 ref_j=j1; 543 if ~isempty(j2) 544 ref_j=floor((j1+j2)/2); 545 end 546 end 547 set(handles.num_ref_j,'String',num2str(ref_j)); 548 549 %% update the list of recent files in the menubar and save it for future opening 550 MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... 551 {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; 552 str_find=strcmp(fileinput,MenuFile); 553 if isempty(find(str_find,1)) 554 MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list 555 end 556 for ifile=1:min(length(MenuFile),5) 557 eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});']) 558 eval(['set(handles.MenuFile_insert_' num2str(ifile) ',''Label'',MenuFile{ifile});']) 559 end 560 dir_perso=prefdir; 561 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 562 if exist(profil_perso,'file') 563 save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat 564 else 565 save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat 566 end 567 568 set(handles.InputTable,'BackgroundColor',[1 1 1]) 569 570 %% initiate input file series and refresh the current field view: 571 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,iview); 572 573 %------------------------------------------------------------------------ 574 % --- Update information about a new field series (indices to scan, timing, 575 % calibration from an xml file 576 function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,iview) 577 %------------------------------------------------------------------------ 578 %% update the output dir 579 InputTable=get(handles.InputTable,'Data'); 580 SubDir=sort(InputTable(1:end-1,2)); %set of subdirectories sorted in alphabetical order 581 SubDirOut=SubDir{1}; 582 if numel(SubDir)>1 583 for ilist=2:numel(SubDir) 584 SubDirOut=[SubDirOut '-' SubDir{ilist}]; 585 end 586 end 587 set(handles.OutputSubDir,'String',SubDirOut) 485 588 486 589 %% display the min and max indices for all the file series 487 590 i_sum=sum(sum(i1_series,2),3);%sum of i1_series on the last index 488 MaxIndex_i=max(find(i_sum>0))-1; 489 MinIndex_i=min(find(i_sum>0))-1; 591 MaxIndex_i=max(find(i_sum>0))-1;% max ref index i 592 MinIndex_i=min(find(i_sum>0))-1;% min ref index i 490 593 i2_min=[]; 491 594 if ~isempty(i2_series) … … 500 603 j2_min=j2_series(1,2); 501 604 end 502 if isequal(MinIndex_i,1) && exist (fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,0,i2_min, j1_min,j2_min),'file') 605 if isequal(MinIndex_i,1) &&... 606 exist (fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},0,i2_min, j1_min,j2_min),'file') 503 607 MinIndex_i=0; 504 608 end … … 508 612 MinIndex=get(handles.MinIndex,'Data');%retrieve the min indices in the table MinIndex 509 613 MaxIndex=get(handles.MaxIndex,'Data');%retrieve the max indices in the table MaxIndex 510 MinIndex{ lastview,1}=MinIndex_i;511 MinIndex{ lastview,2}=MinIndex_j;512 MaxIndex{ lastview,1}=MaxIndex_i;513 MaxIndex{ lastview,2}=MaxIndex_j;614 MinIndex{iview,1}=MinIndex_i; 615 MinIndex{iview,2}=MinIndex_j; 616 MaxIndex{iview,1}=MaxIndex_i; 617 MaxIndex{iview,2}=MaxIndex_j; 514 618 515 619 set(handles.MinIndex,'Data',MinIndex)%display the min indices in the table MinIndex … … 547 651 set(handles.num_last_i,'String',num2str(last_i)); 548 652 set(handles.num_last_j,'String',num2str(last_j)); 549 550 551 %% update the output dir552 SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order553 SubDirOut=SubDir{1};554 if numel(SubDir)>1555 for ilist=2:numel(SubDir)556 SubDirOut=[SubDirOut '-' SubDir{ilist}];557 end558 end559 set(handles.OutputSubDir,'String',SubDirOut)560 561 %% determine the selected reference field indices for pair display562 ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV563 if ~isempty(i1)564 ref_i=i1;565 if ~isempty(i2)566 ref_i=floor((ref_i+i2)/2);% reference image number corresponding to the file567 end568 end569 set(handles.num_ref_i,'String',num2str(ref_i));570 ref_j=1; %default ref_j is a reference frame index used to find existing pairs from PIV571 if ~isempty(j1)572 ref_j=j1;573 if ~isempty(j2)574 ref_j=floor((j1+j2)/2);575 end576 end577 set(handles.num_ref_j,'String',num2str(ref_j));578 579 %% update the list of recent files in the menubar and save it for future opening580 MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...581 {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];582 str_find=strcmp(fileinput,MenuFile);583 if isempty(find(str_find,1))584 MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list585 end586 for ifile=1:min(length(MenuFile),5)587 eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});'])588 eval(['set(handles.MenuFile_insert_' num2str(ifile) ',''Label'',MenuFile{ifile});'])589 end590 dir_perso=prefdir;591 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');592 if exist(profil_perso,'file')593 save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat594 else595 save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat596 end597 598 set(handles.InputTable,'BackgroundColor',[1 1 1])599 600 %% initiate input file series and refresh the current field view:601 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,lastview);602 603 %------------------------------------------------------------------------604 % --- Update information about a new field series (indices to scan, timing,605 % calibration from an xml file, then refresh current plots606 function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,iview)607 %------------------------------------------------------------------------608 609 %% enable j index visibility610 if isempty(j1_series)611 state='off';612 else613 state='on';614 end615 enable_j(handles,state)616 653 617 654 %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file … … 726 763 ListView=get(handles.ListView,'String'); 727 764 ListView{iview}=num2str(iview); 728 set(handles.ListView,'String' );765 set(handles.ListView,'String',ListView); 729 766 set(handles.ListView,'Value',iview) 730 767 update_mode(handles,i1_series,i2_series,j1_series,j2_series,time) … … 755 792 set(handles.waitbar_frame,'Units','normalized') 756 793 757 %% enable field and veltype menus 794 795 %% update the series info in 'UserData' 758 796 SeriesData=get(handles.series,'UserData'); 759 SeriesData.FileType{iview}=FileType;760 check_civ=0;761 check_netcdf=0;762 for iview=1:length(SeriesData.FileType)763 switch SeriesData.FileType{iview}764 case {'civx','civdata'}765 check_civ=check_civ+1;766 case 'netcdf'767 check_netcdf=check_netcdf+1;768 end769 end770 if check_civ771 enable='on';772 else773 enable='off';774 end775 set(handles.VelType,'Visible',enable)776 set(handles.VelType_text,'Visible',enable)777 if check_civ>=2778 enable='on';779 else780 enable='off';781 end782 set(handles.VelType_1,'Visible',enable)783 set(handles.VelType_text_1,'Visible',enable)784 if check_civ || check_netcdf785 enable='on';786 else787 enable='off';788 end789 set(handles.FieldName,'Visible',enable)790 set(handles.Field_text,'Visible',enable)791 if check_civ+ check_netcdf>=2792 enable='on';793 else794 enable='off';795 end796 set(handles.FieldName_1,'Visible',enable)797 set(handles.Field_text_1,'Visible',enable)798 FieldString={''};799 if check_civ800 FieldString=[calc_field;{'get_field...'}];801 elseif check_netcdf802 FieldString={'get_field...'};803 end804 set(handles.FieldName,'String',FieldString)805 FieldString={''};806 if check_civ>=2807 FieldString=[calc_field;{'get_field...'}];808 elseif check_civ+check_netcdf>=2809 FieldString={'get_field...'};810 end811 set(handles.FieldName_1,'String',{'get_field...'})812 813 814 %% store the series info in 'UserData'815 797 SeriesData.i1_series{iview}=i1_series; 816 798 SeriesData.i2_series{iview}=i2_series; … … 820 802 SeriesData.Time{iview}=time; 821 803 set(handles.series,'UserData',SeriesData) 804 805 %% enable j index visibility 806 state='off'; 807 check_jindex=~cellfun(@isempty,SeriesData.j1_series); %look for non empty j indices 808 if isempty(find(check_jindex)) 809 enable_j(handles,'off') % no j index needed 810 else 811 enable_j(handles,'on') 812 end 813 814 %% enable field and veltype menus, in accordance with the current action 815 ActionName_Callback([],[], handles) 822 816 823 817 %% check for pair display … … 902 896 % mode_Callback(hObject, eventdata, handles) 903 897 % 904 % set(handles.REFRESH _INDICES,'BackgroundColor',[0.7 0.7 0.7])898 % set(handles.REFRESH,'BackgroundColor',[0.7 0.7 0.7]) 905 899 % InputTable=get(handles.InputTable,'Data'); 906 % check_lines=get(handles.REFRESH _INDICES,'UserData');900 % check_lines=get(handles.REFRESH,'UserData'); 907 901 % 908 902 % %% check the indices and FileTypes for each series (limited to the new ones to save time) … … 1171 1165 mode=mode_list{get(handles.mode,'Value')}; 1172 1166 ref_i=str2num(get(handles.num_ref_i,'String')); 1173 ref_j=str2num(get(handles.num_ref_j,'String'));1174 1167 if isempty(ref_i) 1175 1168 ref_i=1; 1176 1169 end 1177 if isempty(ref_j) 1170 if strcmp(get(handles.num_ref_j,'Visible'),'on') 1171 ref_j=str2num(get(handles.num_ref_j,'String')); 1172 if isempty(ref_j) 1173 ref_j=1; 1174 end 1175 else 1178 1176 ref_j=1; 1179 1177 end … … 1198 1196 pair_string=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; 1199 1197 if ~isempty(time) 1198 if ref_i<=floor(ipair/2) 1199 ref_i=floor(ipair/2)+1;% shift ref_i to get the first pair 1200 end 1200 1201 Dt=time(ref_i+ceil(ipair/2),ref_j)-time(ref_i-floor(ipair/2),ref_j); 1201 1202 pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; … … 1219 1220 pair_string=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; 1220 1221 if ~isempty(time) 1222 if ref_j<=floor(ipair/2) 1223 ref_j=floor(ipair/2)+1;% shift ref_i to get the first pair 1224 end 1221 1225 Dt=time(ref_i,ref_j+ceil(ipair/2))-time(ref_i,ref_j-floor(ipair/2)); 1222 1226 pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; … … 1249 1253 end 1250 1254 end 1255 set(handles.num_ref_i,'String',num2str(ref_i)) % update ref_i and ref_j 1256 set(handles.num_ref_j,'String',num2str(ref_j)) 1251 1257 1252 1258 %% display list of pairstring … … 1286 1292 1287 1293 %----------------------------------- 1288 function view_FieldMenu(handles,state)1289 % set(handles.FieldName,'Visible',state)1290 % set(handles.Field_text,'Visible',state)1291 set(handles.InputFields,'Visible',state)1292 1293 % -----------------------------------1294 function view_FieldMenu_1(handles,state)1295 set(handles.FieldName_1,'Visible',state)1296 set(handles.Field_text_1,'Visible',state)1294 % function view_FieldMenu(handles,state) 1295 % % set(handles.FieldName,'Visible',state) 1296 % % set(handles.Field_text,'Visible',state) 1297 % set(handles.InputFields,'Visible',state) 1298 1299 % %----------------------------------- 1300 % function view_FieldMenu_1(handles,state) 1301 % set(handles.FieldName_1,'Visible',state) 1302 % set(handles.Field_text_1,'Visible',state) 1297 1303 1298 1304 … … 1312 1318 if ~isempty(errormsg) 1313 1319 msgbox_uvmat('ERROR',errormsg) 1314 else 1315 %Series.Specific=h_fun(Series); 1316 Series=h_fun(Series); 1317 if ~isempty(filexml) 1318 t=struct2xml(Series); 1319 t=set(t,1,'name','Series'); 1320 save(t,filexml); 1321 end 1322 % h_fun(Series); 1323 end 1320 return 1321 end 1322 RunModeList=get(handles.RunMode,'String'); 1323 RunMode=RunModeList{get(handles.RunMode,'Value')}; 1324 1325 switch RunMode 1326 case 'local' 1327 Series=h_fun(Series); 1328 if ~isempty(filexml) 1329 t=struct2xml(Series); 1330 t=set(t,1,'name','Series'); 1331 save(t,filexml); 1332 end 1333 case 'background' 1334 if isempty(filexml) 1335 Series=h_fun(Series);% no background in the absence of output file 1336 else 1337 % update the xml file after interactive input with the function 1338 Series.Specific='?'; 1339 Series=h_fun(Series); 1340 t=struct2xml(Series); 1341 t=set(t,1,'name','Series'); 1342 save(t,filexml); 1343 path_uvmat=fileparts(which('uvmat')); 1344 1345 filename_bat=regexprep(filexml,'.xml$','.bat'); 1346 [fid,message]=fopen(filename_bat,'w'); 1347 if isequal(fid,-1) 1348 msgbox_uvmat('ERROR', ['creation of .bat file: ' message]); 1349 return 1350 end 1351 path_fct=get(handles.ActionPath,'String'); 1352 filelog=regexprep(filexml,'.xml$','.log'); 1353 text_matlabscript=[... 1354 '#!/bin/bash \n'... 1355 '. /etc/sysprofile \n'... 1356 'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'... 1357 'addpath(''' path_uvmat '''); \n'... 1358 'addpath(''' Series.Action.ActionPath '''); \n'... 1359 '' Series.Action.ActionName '( ''' filexml '''); \n'... 1360 'exit \n'... 1361 'END_MATLAB \n']; 1362 fprintf(fid,text_matlabscript); 1363 fclose(fid); 1364 if isunix 1365 system(['chmod +x ' filename_bat]);% set the file to executable 1366 system(['. ' filename_bat ' &']);%execute fct 1367 else 1368 system(filename_bat); 1369 end 1370 end 1371 end 1372 1324 1373 set(handles.RUN, 'Enable','On') 1325 1374 set(handles.RUN,'BackgroundColor',[1 0 0]) … … 1331 1380 set(handles.RUN,'BackgroundColor',[1 0 0]) 1332 1381 set(handles.RUN,'enable','on') 1333 set(handles.BATCH,'BackgroundColor',[1 0 0])1334 set(handles.BATCH,'enable','on')1382 % set(handles.BATCH,'BackgroundColor',[1 0 0]) 1383 % set(handles.BATCH,'enable','on') 1335 1384 1336 1385 %------------------------------------------------------------------------ … … 1338 1387 function BATCH_Callback(hObject, eventdata, handles) 1339 1388 %------------------------------------------------------------------------ 1340 set(handles.BATCH, 'Enable','Off') 1341 set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) 1342 [h_fun,Series,filexml,errormsg]=prepare_jobs(handles); 1343 if ~isempty(errormsg) 1344 msgbox_uvmat('ERROR',errormsg) 1345 return 1346 end 1347 % update the xml file after interactive input with the function 1348 Series.Specific='?'; 1349 Series=h_fun(Series); 1350 t=struct2xml(Series); 1351 t=set(t,1,'name','Series'); 1352 save(t,filexml); 1353 path_series=fileparts(which('series')); 1354 filename_xml=fullfile(Series.OutputDir,[Series.OutputRootFile '.xml']); 1355 filename_bat=fullfile(Series.OutputDir,[Series.OutputRootFile '.bat']); 1356 [fid,message]=fopen(filename_bat,'w'); 1357 if isequal(fid,-1) 1358 msgbox_uvmat('ERROR', ['creation of .bat file: ' message]); 1359 return 1360 end 1361 path_fct=get(handles.ActionPath,'String'); 1362 text_matlabscript=[... 1363 '#!/bin/bash \n'... 1364 '. /etc/sysprofile \n'... 1365 'matlab -nodisplay -nosplash -nojvm <<END_MATLAB \n'... 1366 'cd(''' path_series '''); \n'... 1367 'addpath(''' path_fct '''); \n'... 1368 '' Series.Action '( ''' filename_xml '''); \n'... 1369 'exit \n'... 1370 'END_MATLAB \n']; 1371 fprintf(fid,text_matlabscript); 1372 fclose(fid); 1373 if isunix 1374 system(['chmod +x ' filename_bat]);% set the file to executable 1375 system(['. ' filename_bat ' &']);%execute fct 1376 else 1377 system(filename_bat); 1378 end 1379 set(handles.BATCH, 'Enable','On') 1380 set(handles.BATCH,'BackgroundColor',[1 0 0]) 1381 1382 %------------------------------------------------------------------------ 1383 % --- Executes on button press in BIN. 1384 function BIN_Callback(hObject, eventdata, handles) 1385 %------------------------------------------------------------------------ 1386 cmd=['#!/bin/bash \n '... 1387 '#$ -cwd \n '... 1388 'hostname && date \n '... 1389 'umask 002 \n'... 1390 Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' OutputFile '.nc']; 1391 1389 1390 1391 % %------------------------------------------------------------------------ 1392 % % --- Executes on button press in BIN. 1393 % function BIN_Callback(hObject, eventdata, handles) 1394 % %------------------------------------------------------------------------ 1395 % cmd=['#!/bin/bash \n '... 1396 % '#$ -cwd \n '... 1397 % 'hostname && date \n '... 1398 % 'umask 002 \n'... 1399 % Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' OutputFile '.nc']; 1400 % 1392 1401 %------------------------------------------------------------------------ 1393 1402 % --- Main launch command, called by RUN and BATCH 1394 1403 function [h_fun,Series,filexml,errormsg]=prepare_jobs(handles,run) 1404 %INPUT: 1405 % handles: handles of graphic objects on the GUI series 1406 % run=0, just to display parameters for MenuExport/GUI config 1407 % run=1 (default) prepare the computation 1408 1395 1409 %------------------------------------------------------------------------ 1396 1410 h_fun=[]; … … 1512 1526 end 1513 1527 Series.OutputDirExt=regexprep(SubDirOutNew,Series.OutputSubDir,''); 1514 Series.OutputSubDir=SubDirOutNew;1515 Series.OutputDir=fullfile(Series.InputTable{1,1},Series.OutputSubDir);%directory set for output results1528 % Series.OutputSubDir=SubDirOutNew; 1529 % Series.OutputDir=fullfile(Series.InputTable{1,1},Series.OutputSubDir);%directory set for output results 1516 1530 Series.OutputRootFile=Series.InputTable{1,3};% the first sorted RootFile taken for output 1517 1531 set(handles.OutputDirExt,'String',Series.OutputDirExt) 1518 %removes redondant information1519 Series=rmfield(Series,'OutputDirExt');1520 Series.IndexRange=rmfield(Series.IndexRange,'TimeTable');1521 Series.IndexRange=rmfield(Series.IndexRange,'MinIndex');1522 Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex');1523 1532 % create output directory 1533 OutputDir=fullfile(Series.InputTable{1,1},[Series.OutputSubDir Series.OutputDirExt]); 1524 1534 if check_create 1525 [tild,msg1]=mkdir( Series.OutputDir);1535 [tild,msg1]=mkdir(OutputDir); 1526 1536 if ~strcmp(msg1,'') 1527 errormsg=['cannot create ' Series.OutputDir ': ' msg1];%error message for directory creation1537 errormsg=['cannot create ' OutputDir ': ' msg1];%error message for directory creation 1528 1538 return 1529 1539 end 1530 1540 end 1531 filexml=fullfile(Series.OutputDir,[Series.InputTable{1,3} '.xml']);% name of the parameter xml file set in this directory 1532 % t=struct2xml(Series); 1533 % t=set(t,1,'name','Series'); 1534 % save(t,filexml); 1535 end 1541 filexml=fullfile(OutputDir,[Series.InputTable{1,3} '.xml']);% name of the parameter xml file set in this directory 1542 end 1543 %removes redondant information 1544 Series.IndexRange=rmfield(Series.IndexRange,'TimeTable'); 1545 Series.IndexRange=rmfield(Series.IndexRange,'MinIndex'); 1546 Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex'); 1547 %removes empty lines of InputTable 1548 empty_line=zeros(size(Series.InputTable,1),1); 1549 for iline=1:size(Series.InputTable,1) 1550 empty_line(iline)=isequal(Series.InputTable(iline,1:3),{'','',''}); 1551 end 1552 Series.InputTable(find(empty_line),:)=[]; 1536 1553 1537 1554 %------------------------------------------------------------------------ … … 1612 1629 set(handles.VelType_1,'Visible','off'); 1613 1630 set(handles.VelType_text_1,'Visible','off'); 1614 view_FieldMenu(handles,'off') 1615 view_FieldMenu_1(handles,'off') 1631 set(handles.InputFields,'Visible','off') 1632 set(handles.FieldName_1,'Visible','off') 1633 %view_FieldMenu_1(handles,'off') 1616 1634 set(handles.FieldTransform,'Visible','off') 1617 1635 set(handles.CheckObject,'Visible','off'); … … 1619 1637 set(handles.CheckMask,'Visible','off') 1620 1638 set(handles.Mask,'Visible','off') 1621 % set(handles.OutputDirExt,'Visible','off');1622 % set(handles.ParamKey,'Visible','off')1623 % set(handles.ParamVal,'Visible','off')1624 ParamKey={};1625 set(handles.FieldName,'Enable','off')1626 set(handles.VelType,'Enable','off')1627 set(handles.FieldName_1,'Enable','off')1628 set(handles.VelType_1,'Enable','off')1629 set(handles.TransformName,'Enable','off')1630 1639 set(handles.OutputDirExt,'Visible','off') 1631 1640 set(handles.OutputSubDir,'Visible','off') … … 1649 1658 1650 1659 InputTable=get(handles.InputTable,'Data'); 1651 nb_series=size(InputTable,1); 1652 testima_series=1; %test for a list of images only 1653 testima=1; 1654 testima_1=1; 1655 testciv_series=1; 1656 for iview=1:nb_series 1657 ext=InputTable{iview,5}; 1658 if length(ext)<2 1659 ext='.none'; 1660 end 1661 testimaview=~isempty(imformats(ext(2:end))) || isequal(lower(ext),'.avi'); 1662 if ~testimaview 1663 if iview==1 1664 testima=0; 1665 end 1666 if iview==2 1667 testima_1=0; 1668 end 1669 testima_series=0; 1670 end 1671 end 1660 nbview=size(InputTable,1); 1661 SeriesData=get(handles.series,'UserData'); 1662 nb_civ=numel(find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType))); 1663 nb_netcdf=numel(find(strcmp('netcdf',SeriesData.FileType))); 1672 1664 for ilist=1:length(varargout)-1 1673 1665 switch varargout{ilist} 1674 case 'NbViewMax'1675 if ~isempty (varargout{ilist+1})1676 if size(InputTable,1)>varargout{ilist+1}1677 InputTable=InputTable(1:varargout{ilist+1},:);1678 set(handles.InputTable,'Data',InputTable)1679 end1680 end1681 1666 case 'AllowInputSort' 1682 1667 if isequal(lower(varargout{ilist+1}),'on')% sort the input table by alphabetical order of the SubDir 1683 SeriesData=get(handles.series,'UserData');1684 1668 SeriesData.AllowInputSort=1; 1685 1669 set(handles.series,'UserData',SeriesData) 1686 1670 end 1687 1671 case 'WholeIndexRange' 1688 if isequal(lower(varargout{ilist+1}),'on')% s ort the input table by alphabetical order of the SubDir1672 if isequal(lower(varargout{ilist+1}),'on')% set by default the input index range from min to max 1689 1673 MinIndex=get(handles.MinIndex,'Data'); 1690 1674 MaxIndex=get(handles.MaxIndex,'Data'); … … 1707 1691 case 'VelType' %hidden by default 1708 1692 if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two') 1709 set(handles.VelType,'Enable','on') 1710 if nb_series >=1 && ~testima_series 1693 if nb_civ>=1 1711 1694 set(handles.VelType,'Visible','on') 1712 1695 set(handles.VelType_text,'Visible','on'); … … 1714 1697 end 1715 1698 if isequal(lower(varargout{ilist+1}),'two') 1716 set(handles.VelType_1,'Enable','on') 1717 if nb_series >=2 && ~testima_series 1699 if nb_civ>=2 1718 1700 set(handles.VelType_1,'Visible','on') 1719 1701 set(handles.VelType_text_1,'Visible','on'); … … 1722 1704 case 'FieldName' %hidden by default 1723 1705 if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two') 1724 set(handles.FieldName,'Enable','on') % test for MenuBorser1725 if nb_series >=1 && ~testima_series1726 view_FieldMenu(handles,'on')1706 if (nb_civ+nb_netcdf)>=1 1707 set(handles.FieldName,'Visible','on') % test for MenuBorser 1708 set(handles.InputFields,'Visible','on') 1727 1709 end 1728 1710 end 1729 1711 if isequal(lower(varargout{ilist+1}),'two') 1730 set(handles.FieldName_1,'Enable','on') 1731 if nb_series >=2 && ~testima_1 1732 view_FieldMenu_1(handles,'on') 1712 if (nb_civ+nb_netcdf)>=1 1713 set(handles.FieldName_1,'Visible','on') 1733 1714 end 1734 1715 end … … 1747 1728 set(handles.Mask,'Visible','on') 1748 1729 set(handles.CheckMask,'Visible','on'); 1749 end 1750 case 'PARAMETER' % NOT USED 1751 set(handles.PARAMETERS_frame,'Visible','on') 1752 set(handles.PARAMETERS_title,'Visible','on') 1753 set(handles.ParamKey,'Visible','on') 1754 %set(handles.ParamVal,'Visible','on') 1755 Param_str=varargout{ilist+1}; 1756 Param_list=[Param_list; {Param_str}]; 1730 end 1757 1731 case 'OutputDirExt' 1758 1732 if ~isempty(varargout{ilist+1}) … … 2023 1997 2024 1998 % %------------------------------------------------------------------------ 2025 % % --- Executes on button press in REFRESH _INDICES.1999 % % --- Executes on button press in REFRESH. 2026 2000 % function REFRESH_INDICES_Callback(hObject, eventdata, handles) 2027 2001 % %------------------------------------------------------------------------ 2028 % % hObject handle to REFRESH _INDICES(see GCBO)2002 % % hObject handle to REFRESH (see GCBO) 2029 2003 % % eventdata reserved - to be defined in a future version of MATLAB 2030 2004 % % handles structure with handles and user data (see GUIDATA) 2031 % set(handles.REFRESH _INDICES,'BackgroundColor',[0.7 0.7 0.7])2005 % set(handles.REFRESH,'BackgroundColor',[0.7 0.7 0.7]) 2032 2006 % InputTable=get(handles.InputTable,'Data'); 2033 % check_lines=get(handles.REFRESH _INDICES,'UserData');2007 % check_lines=get(handles.REFRESH,'UserData'); 2034 2008 % 2035 2009 % %% check the indices and FileTypes for each series (limited to the new ones to save time) … … 2086 2060 % set(handles.PairString,'Visible',state_Pairs) 2087 2061 % enable_j(handles,state_j) 2088 % set(handles.REFRESH _INDICES,'BackgroundColor',[1 0 0])2089 % set(handles.REFRESH _INDICES,'visible','off')2062 % set(handles.REFRESH,'BackgroundColor',[1 0 0]) 2063 % set(handles.REFRESH,'visible','off') 2090 2064 2091 2065 % ----------------------------------------------------------------------- … … 2162 2136 2163 2137 %% enable field and veltype menus 2164 testfield=isequal(get(handles.FieldName,'enable'),'on');2165 testfield_1=isequal(get(handles.FieldName_1,'enable'),'on');2166 testveltype=isequal(get(handles.VelType,'enable'),'on');2167 testveltype_1=isequal(get(handles.VelType_1,'enable'),'on');2168 testtransform=isequal(get(handles.TransformName,'Enable'),'on');2138 % testfield=isequal(get(handles.FieldName,'enable'),'on'); 2139 % testfield_1=isequal(get(handles.FieldName_1,'enable'),'on'); 2140 % testveltype=isequal(get(handles.VelType,'enable'),'on'); 2141 % testveltype_1=isequal(get(handles.VelType_1,'enable'),'on'); 2142 % testtransform=isequal(get(handles.TransformName,'Enable'),'on'); 2169 2143 % testnc=0; 2170 2144 % testnc_1=0; … … 2197 2171 switch FileType 2198 2172 case {'civx','civdata'} 2199 view_FieldMenu(handles,'on')2173 %view_FieldMenu(handles,'on') 2200 2174 menustr=get(handles.FieldName,'String'); 2201 2175 if isequal(menustr,{'get_field...'}) … … 2220 2194 % view_FieldMenu_1(handles,'off') 2221 2195 case 'netcdf' 2222 view_FieldMenu(handles,'on')2196 % view_FieldMenu(handles,'on') 2223 2197 set(handles.FieldName,'Value',1) 2224 2198 set(handles.FieldName,'String',{'get_field...'}) … … 2226 2200 % view_TRANSFORM(handles,'off') 2227 2201 case {'image','multimage','video'} 2228 view_FieldMenu(handles,'off')2229 view_FieldMenu_1(handles,'off')2202 % view_FieldMenu(handles,'off') 2203 % view_FieldMenu_1(handles,'off') 2230 2204 set(handles.VelType,'Visible','off') 2231 2205 set(handles.VelType_text,'Visible','off'); … … 2327 2301 evalin('base','Series') %display CurData in the workspace 2328 2302 commandwindow; %brings the Matlab command window to the front 2303 2304 2305 % --- Executes on selection change in RunMode. 2306 function RunMode_Callback(hObject, eventdata, handles) -
trunk/src/xml2struct.m
r471 r472 9 9 % filename: name of the xml file 10 10 11 function s=xml2struct(filename)11 function [s,Heading]=xml2struct(filename) 12 12 t=xmltree(filename); 13 Heading=get(t,1,'name'); 13 14 ss=convert(t); 14 15 s=convert_string(ss); … … 40 41 case 'cell' 41 42 out=[];%default 42 for ilist=1:numel(ss) 43 if ~isempty(str2num(ss{ilist})) 44 out(ilist,:)=str2num(ss{ilist}); 43 if isequal(cellfun(@isnumeric,ss),ones(size(ss)))% if the all the cell content is numeric 44 out=cell2mat(ss); 45 else 46 for ilist=1:numel(ss) 47 sep_ind=regexp(ss{ilist},'\s&\s');% check for separator ' & ' which indicates column separation in tables 48 if ~isempty(sep_ind) 49 sep_ind=[-2 sep_ind length(ss{ilist})+1]; 50 for icolumn=1:length(sep_ind)-1 51 out{ilist,icolumn}=ss{ilist}(sep_ind(icolumn)+3:sep_ind(icolumn+1)-1); 52 end 53 else 54 out{ilist,1}=ss{ilist}; %reproduce the input string 55 end 45 56 end 46 57 end 58 % for ilist=1:numel(ss) 59 % if ~isempty(str2num(ss{ilist})) 60 % out(ilist,:)=str2num(ss{ilist});% convert to numeric 61 % end 62 % end 47 63 otherwise 48 64 out=ss;
Note: See TracChangeset
for help on using the changeset viewer.