Changeset 714 for trunk/src/series.m
- Timestamp:
- Feb 22, 2014, 5:11:04 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series.m
r711 r714 303 303 %------------------------------------------------------------------------ 304 304 function MenuBrowse_Callback(hObject, eventdata, handles) 305 306 305 %% look for the previously opened file 'oldfile' 307 oldfile=''; %default 308 if get(handles.CheckAppend,'Value') 309 % case 'checkappend': new series appended to the input table 310 InputTable=get(handles.InputTable,'Data'); 311 RootPathCell=InputTable(:,1); 312 SubDirCell=InputTable(:,3); 313 oldfile=''; %default 314 if ~(isempty(RootPathCell) || isequal(RootPathCell,{''}))%loads the previously stored file name and set it as default in the file_input box 315 oldfile=fullfile(RootPathCell{1},SubDirCell{1}); 316 end 317 else 318 % case refresh the input table by a new series 319 SeriesData=get(handles.series,'UserData'); 320 if isfield(SeriesData,'RefFile') 321 oldfile=SeriesData.RefFile{1}; 322 end 323 end 306 InputTable=get(handles.InputTable,'Data'); 307 oldfile=InputTable{1,1}; 308 if isempty(oldfile) 309 % use a file name stored in prefdir 310 dir_perso=prefdir; 311 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 312 if exist(profil_perso,'file') 313 h=load (profil_perso); 314 if isfield(h,'RootPath') && ischar(h.RootPath) 315 oldfile=h.RootPath; 316 end 317 end 318 end 319 %% launch the browser 320 fileinput=uigetfile_uvmat('pick a file to append in the input table',oldfile); 321 if ~isempty(fileinput) 322 display_file_name(handles,fileinput,'one') 323 end 324 325 % -------------------------------------------------------------------- 326 function MenuBrowseAppend_Callback(hObject, eventdata, handles) 327 328 %% look for the previously opened file 'oldfile' 329 InputTable=get(handles.InputTable,'Data'); 330 RootPathCell=InputTable(:,1); 331 if isempty(RootPathCell{1})% no input file in the table 332 MenuBrowse_Callback(hObject, eventdata, handles)%refresh the input table, not append 333 return 334 end 335 SubDirCell=InputTable(:,2); 336 oldfile=fullfile(RootPathCell{1},SubDirCell{1}); 324 337 325 338 %% use a file name stored in prefdir … … 336 349 fileinput=uigetfile_uvmat('pick a file to append in the input table',oldfile); 337 350 if ~isempty(fileinput) 338 % if get(handles.CheckAppend,'Value')339 % display_file_name(handles,fileinput,'append')340 % else341 display_file_name(handles,fileinput,'one')342 % end343 end344 345 % --------------------------------------------------------------------346 function MenuBrowseAppend_Callback(hObject, eventdata, handles)347 348 %% look for the previously opened file 'oldfile'349 InputTable=get(handles.InputTable,'Data');350 RootPathCell=InputTable(:,1);351 if isempty(RootPathCell{1})% no input file in the table352 MenuBrowse_Callback(hObject, eventdata, handles)%refresh the input table, not append353 return354 end355 SubDirCell=InputTable(:,2);356 % oldfile=''; %default357 % if ~(isempty(RootPathCell) || isequal(RootPathCell,{''}))%loads the previously stored file name and set it as default in the file_input box358 oldfile=fullfile(RootPathCell{1},SubDirCell{1});359 % end360 361 %% use a file name stored in prefdir362 dir_perso=prefdir;363 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');364 if exist(profil_perso,'file')365 h=load (profil_perso);366 if isfield(h,'RootPath') && ischar(h.RootPath)367 oldfile=h.RootPath;368 end369 end370 371 %% launch the browser372 fileinput=uigetfile_uvmat('pick a file to append in the input table',oldfile);373 if ~isempty(fileinput)374 351 display_file_name(handles,fileinput,'append') 375 352 end … … 380 357 function MenuFile_Callback(hObject, eventdata, handles) 381 358 382 display_file_name(handles,get(hObject,'Label'),'one') 359 errormsg=display_file_name(handles,get(hObject,'Label'),'one'); 360 if ~isempty(errormsg) 361 set(hObject,'Label','') 362 MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... 363 {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; 364 str_find=strcmp(get(hObject,'Label'),MenuFile); 365 MenuFile(str_find)=[];% suppress the input file to the list 366 for ifile=1:numel(MenuFile) 367 set(handles.(['MenuFile_' num2str(ifile)]),'Label',MenuFile{ifile}); 368 end 369 end 383 370 384 371 %------------------------------------------------------------------------ … … 546 533 if ~exist(RootPath,'dir') 547 534 i1_series=[]; 548 RootPath=fileparts(RootPath); %will try the uppe dfolder549 else 535 RootPath=fileparts(RootPath); %will try the upper folder 536 else %scan the input folder 550 537 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,FileInfo,MovieObject]=... 551 538 find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]); 552 539 end 540 % if no file is found, open a browser 553 541 if isempty(i1_series) 554 542 fileinput=uigetfile_uvmat(['wrong input at line ' num2str(iview) ':pick a new input file'],RootPath); … … 567 555 %------------------------------------------------------------------------ 568 556 % --- Function called when a new file is opened, either by series_OpeningFcn or by the browser 569 function display_file_name(handles,fileinput,iview)557 function errormsg=display_file_name(handles,fileinput,iview) 570 558 %------------------------------------------------------------------------ 571 559 % … … 576 564 % or 'one': refresh the list 577 565 % 'append': add a new line to the input table 578 566 set(handles.REFRESH,'BackgroundColor',[1 1 0])% set REFRESH button to yellow color (indicate activation) 567 drawnow 568 errormsg='';%default 579 569 %% get the input root name, indices, file extension and nomenclature NomType 580 570 if ~exist(fileinput,'file') 581 msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) 571 errormsg=['input file ' fileinput ' does not exist']; 572 msgbox_uvmat('ERROR',errormsg) 573 set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (end of activation) 582 574 return 583 575 end … … 590 582 if isempty(RootFile)&&isempty(i1_series) 591 583 errormsg='no input file in the series'; 584 msgbox_uvmat('ERROR',errormsg) 585 set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (end of activation) 592 586 return 593 587 end 594 588 if strcmp(FileType,'txt') 595 589 edit(fileinput) 590 set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (end of activation) 596 591 return 597 592 elseif strcmp(FileType,'xml') 598 593 editxml(fileinput) 594 set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (end of activation) 599 595 return 600 596 elseif strcmp(FileType,'figure') 601 597 open(fileinput) 598 set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (end of activation) 602 599 return 603 600 end … … 670 667 set(handles.num_ref_j,'String',num2str(ref_j)); 671 668 669 %% update first and last indices if they do not exist 670 Param=read_GUI(handles.series); 671 first_j=[]; 672 if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end 673 last_j=[]; 674 if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end 675 [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,Param.IndexRange.PairString); 676 FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},... 677 Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2); 678 if ~exist(FirstFileName,'file') 679 set(handles.num_first_i,'String',num2str(ref_i)) 680 set(handles.num_first_j,'String',num2str(ref_j)) 681 end 682 [i1,i2,j1,j2] = get_file_index(Param.IndexRange.last_i,last_j,Param.IndexRange.PairString); 683 LastFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},... 684 Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2); 685 if ~exist(LastFileName,'file') 686 set(handles.num_last_i,'String',num2str(ref_i)) 687 set(handles.num_last_j,'String',num2str(ref_j)) 688 end 689 672 690 %% update the list of recent files in the menubar and save it for future opening 673 691 MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... … … 699 717 %% initiate input file series and refresh the current field view: 700 718 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,FileInfo,MovieObject,iview); 719 set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (end of activation) 701 720 702 721 %------------------------------------------------------------------------ … … 722 741 diff_j_max=diff(ref_j); 723 742 diff_i_max=diff(ref_i); 724 725 % pair_max=squeeze(max(i1_series,[],1)); %max on pair index726 % j_max=max(pair_max,[],1);727 % MinIndex_i=find(j_max, 1 )-1;% min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index)728 % MaxIndex_i=find(j_max, 1, 'last' )-1;% max ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index)729 % diff_i_max=diff(j_max);730 743 if ~isempty(diff_i_max) && isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max))) 731 744 set(handles.num_incr_i,'String',num2str(diff_i_max(1)))% detect an increment to dispaly by default 732 745 end 733 % i_max=max(pair_max,[],2);734 % MinIndex_j=min(find(i_max))-1;% min ref index j735 % MaxIndex_j=max(find(i_max))-1;% max ref index j736 % diff_j_max=diff(i_max);737 746 if isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max))) 738 747 set(handles.num_incr_j,'String',num2str(diff_j_max(1))) … … 973 982 ind_select=find(file_indices<=numel(j_max{iview})); 974 983 LineData(ind_select)=j_max{iview}(file_select)~=0; 975 % LineData=zeros(1,range_index);976 % x_index=find(j_max{iview}>0)-MinIndex_i;977 % LineData(x_index)=1;978 % if numel(x)>1979 % LineData980 %LineData=interp1(x,LineData,xI,'nearest');981 984 CData(ind_y,:)=ones(size(ind_y'))*LineData; 982 % end983 985 end 984 986 CData=cat(3,zeros(size(CData)),CData,zeros(size(CData)));%make color images r=0,g,b=0 … … 1088 1090 %------------------------------------------------------------------------ 1089 1091 SeriesData=get(handles.series,'UserData');% 1090 ref_i=[str2num(get(handles.num_first_i,'String')) str2num(get(handles.num_last_i,'String'))]; 1091 ref_j=[str2num(get(handles.num_first_j,'String')) str2num(get(handles.num_last_j,'String'))]; 1092 PairString=get(handles.PairString,'Data'); 1093 ref_i_1=str2num(get(handles.num_first_i,'String'));%first reference index 1094 ref_i_2=str2num(get(handles.num_last_i,'String'));%last reference index 1095 ref_j_1=[];ref_j_2=[]; 1096 if strcmp(get(handles.num_first_j,'Visible'),'on') 1097 ref_j_1=str2num(get(handles.num_first_j,'String')); 1098 ref_j_2=str2num(get(handles.num_last_j,'String')); 1099 end 1100 [i1_1,i2_1,j1_1,j2_1] = get_file_index(ref_i_1,ref_j_1,PairString); 1101 [i1_2,i2_2,j1_2,j2_2] = get_file_index(ref_i_2,ref_j_2,PairString); 1092 1102 TimeTable=get(handles.TimeTable,'Data'); 1093 Pairs=get(handles.PairString,'Data'); 1103 1104 %Pairs=get(handles.PairString,'Data'); 1094 1105 for iview=1:size(TimeTable,1) 1095 1106 if size(SeriesData.Time,1)<iview 1096 1107 break 1097 1108 end 1098 i1=ref_i;1099 j1=ref_j;1100 i2=ref_i;1101 j2=ref_j;1102 % case of pairs1103 if ~isempty(Pairs{iview,1})1104 r=regexp(Pairs{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');1105 if isempty(r)1106 r=regexp(Pairs{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');1107 end1108 switch r.mode1109 case 'Di=' % case 'series(Di)')1110 i1=ref_i-str2num(r.num1);1111 i2=ref_i+str2num(r.num2);1112 case 'Dj=' % case 'series(Dj)'1113 j1=ref_j-str2num(r.num1);1114 j2=ref_j+str2num(r.num2);1115 case '-' % case 'bursts'1116 j1=str2num(r.num1)*ones(size(ref_i));1117 j2=str2num(r.num2)*ones(size(ref_i));1118 end1119 end1120 1109 TimeTable{iview,2}=[]; 1121 1110 TimeTable{iview,3}=[]; 1122 if size(SeriesData.Time{iview},1)>=i2 (2)+1&&size(SeriesData.Time{iview},2)>=j2(2)+11123 if isempty(ref_j )1124 time_first=(SeriesData.Time{iview}(i1 (1)+1)+SeriesData.Time{iview}(i2(1)+1))/2;1125 time_last=(SeriesData.Time{iview}(i1 (2)+1)+SeriesData.Time{iview}(i2(2))+1)/2;1111 if size(SeriesData.Time{iview},1)>=i2_2+1 && (isempty(ref_j_1)||size(SeriesData.Time{iview},2)>=j2_2+1) 1112 if isempty(ref_j_1) 1113 time_first=(SeriesData.Time{iview}(i1_1+1,2)+SeriesData.Time{iview}(i2_1+1,2))/2; 1114 time_last=(SeriesData.Time{iview}(i1_2+1,2)+SeriesData.Time{iview}(i2_2+1,2))/2; 1126 1115 else 1127 time_first=(SeriesData.Time{iview}(i1 (1)+1,j1(1)+1)+SeriesData.Time{iview}(i2(1)+1,j2(1)+1))/2;1128 time_last=(SeriesData.Time{iview}(i1 (2)+1,j1(2)+1)+SeriesData.Time{iview}(i2(2)+1,j2(2)+1))/2;1116 time_first=(SeriesData.Time{iview}(i1_1+1,j1_1+1)+SeriesData.Time{iview}(i2_1+1,j2_1+1))/2; 1117 time_last=(SeriesData.Time{iview}(i1_2+1,j1_2+1)+SeriesData.Time{iview}(i2_2+1,j2_1+1))/2; 1129 1118 end 1130 1119 TimeTable{iview,2}=time_first; %TODO: take into account pairs … … 1137 1126 MinIndex_i=min(get(handles.MinIndex_i,'Data')); 1138 1127 MaxIndex_i=max(get(handles.MaxIndex_i,'Data')); 1139 pos_first=(ref_i (1)-MinIndex_i)/(MaxIndex_i-MinIndex_i+1);1140 pos_last=(ref_i (2)-MinIndex_i+1)/(MaxIndex_i-MinIndex_i+1);1128 pos_first=(ref_i_1-MinIndex_i)/(MaxIndex_i-MinIndex_i+1); 1129 pos_last=(ref_i_2-MinIndex_i+1)/(MaxIndex_i-MinIndex_i+1); 1141 1130 Position=get(handles.Waitbar,'Position');% position of the waitbar:= [ x,y, width, height] 1142 1131 Position_status=get(handles.FileStatus,'Position'); … … 1145 1134 set(handles.Waitbar,'Position',Position) 1146 1135 update_waitbar(handles.Waitbar,0) 1147 1148 % for iview=1:numel(SeriesData.i1_series)1149 % pair_max{iview}=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index1150 % if (strcmp(get(handles.num_first_j,'Visible'),'off')&& size(pair_max{iview},2)~=1)1151 % pair_max{iview}=squeeze(max(pair_max{iview},[],1)); % consider only the i index1152 % end1153 % pair_max{iview}=reshape(pair_max{iview},1,[]);1154 % index_min(iview)=find(pair_max{iview}>0, 1 );1155 % index_max(iview)=find(pair_max{iview}>0, 1, 'last' );1156 % end1157 % [index_min,iview_min]=min(index_min);1158 % [index_max,iview_max]=min(index_max);1159 % if size(SeriesData.i1_series{iview_min},2)==1% movie1160 % index_first=ref_i(1);1161 % index_last=ref_i(2);1162 % else1163 % index_first=(ref_i(1)-1)*(size(SeriesData.i1_series{iview_min},1))+ref_j(1)+1;1164 % index_last=(ref_i(2)-1)*(size(SeriesData.i1_series{iview_max},1))+ref_j(2)+1;1165 % end1166 % range=index_max-index_min+1;1167 % coeff_min=(index_first-index_min)/range;1168 % coeff_max=(index_last-index_min+1)/range;1169 % Position=get(handles.Waitbar,'Position');% position of the waitbar:= [ x,y, width, height]1170 % Position_status=get(handles.FileStatus,'Position');1171 % Position(1)=coeff_min*Position_status(3)+Position_status(1);1172 % Position(3)=Position_status(3)*(coeff_max-coeff_min);1173 % set(handles.Waitbar,'Position',Position)1174 % update_waitbar(handles.Waitbar,0)1175 1136 1176 1137 %------------------------------------------------------------------------ … … 2028 1989 %% Activate the Action fct 2029 1990 Param=read_GUI_series(handles);% read the parameters from the GUI series 2030 ParamOut=h_fun(Param); 1991 ParamOut=h_fun(Param);%run the selected Action function to get the relevant input 2031 1992 2032 1993 %% Put the first line of the selected Action fct as tooltip help … … 2041 2002 SeriesData=get(handles.series,'UserData'); 2042 2003 iview_civ=[];nb_netcdf=0; 2043 if ~isempty(SeriesData) 2004 if ~isempty(SeriesData)&&isfield(SeriesData,'FileType') 2044 2005 iview_civ=find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType)); 2045 2006 nb_netcdf=numel(find(strcmp('netcdf',SeriesData.FileType))); … … 2117 2078 InputFieldsVisible='off';%visibility of the frame Fields 2118 2079 if isfield(ParamOut,'VelType') 2119 if strcmp( ParamOut.VelType,'on e')||strcmp( ParamOut.VelType,'two')2080 if strcmp( ParamOut.VelType,'on')||strcmp(ParamOut.VelType,'one')||strcmp( ParamOut.VelType,'two') 2120 2081 if numel(iview_civ)>=1 2121 2082 VelTypeVisible='on'; … … 2138 2099 FieldName_1Visible='off'; %hidden by default 2139 2100 if isfield(ParamOut,'FieldName') 2140 if strcmp( ParamOut.FieldName,'on e')||strcmp( ParamOut.FieldName,'two')2101 if strcmp( ParamOut.FieldName,'on') || strcmp(ParamOut.FieldName,'one')||strcmp( ParamOut.FieldName,'two') 2141 2102 if (numel(iview_civ)+nb_netcdf)>=1 2142 2103 InputFieldsVisible='on'; … … 2250 2211 function ActionInput_Callback(hObject, eventdata, handles) 2251 2212 %------------------------------------------------------------------------ 2252 if get(handles.ActionInput,'Value')2253 2254 end2213 % if get(handles.ActionInput,'Value') 2214 ActionName_Callback(hObject, eventdata, handles) 2215 % end 2255 2216 2256 2217 %------------------------------------------------------------------------ … … 2307 2268 set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName]) 2308 2269 set(handles.NomType,'String','*') 2309 set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) 2270 set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% A VERIFIER !!!!!! 2310 2271 set(handles.FileIndex,'String','') 2311 2272 ParamIn.TimeVarName=GetFieldData.Time.TimeName; … … 2696 2657 %------------------------------------------------------------------------ 2697 2658 function MenuImportConfig_Callback(hObject, eventdata, handles) 2698 2659 % SeriesData=get(handles.series,'UserData'); 2660 % if isfield(SeriesData,'RefFile') 2661 % oldfile=SeriesData.RefFile{1}; 2662 % end 2663 %% use a strating file name for browserr 2699 2664 InputTable=get(handles.InputTable,'Data'); 2700 filexml=uigetfile_uvmat('pick a xml parameter file',InputTable{1,1},'.xml');% get the xml file containing processing parameters 2665 oldfile=InputTable{1,1}; 2666 if isempty(oldfile) 2667 % use a file name stored in prefdir 2668 dir_perso=prefdir; 2669 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 2670 if exist(profil_perso,'file') 2671 h=load (profil_perso); 2672 if isfield(h,'RootPath') && ischar(h.RootPath) 2673 oldfile=h.RootPath; 2674 end 2675 end 2676 end 2677 filexml=uigetfile_uvmat('pick a xml parameter file',oldfile,'.xml');% get the xml file containing processing parameters 2701 2678 %proceed only if a file has been introduced by the browser 2702 2679 if ~isempty(filexml) … … 2715 2692 SeriesData=get(handles.series,'UserData'); 2716 2693 if isfield(Param,'ActionInput')% introduce parameters specific to an Action fct, for instance PIV parameters 2717 % set(handles.ActionInput,'Visible','on')2718 % set(handles.ActionInput_title,'Visible','on')2719 2694 set(handles.ActionInput,'Visible','on') 2720 2695 set(handles.ActionInput,'Value',0) … … 2737 2712 set(handles.DeleteObject,'Visible','off') 2738 2713 end 2739 % set(handles.REFRESH,'Visible','on')2740 2714 set(handles.REFRESH,'BackgroundColor',[1 0 1]); %paint REFRESH button in magenta to indicate that it should be activated 2741 % REFRESH_Callback([],[],handles)% refresh data relative to the input files2742 2715 end 2743 2716 … … 2802 2775 OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files 2803 2776 OutputDir=fullfile(RootPath,OutputSubDir); 2804 uigetfile_uvmat('status_display',OutputDir) 2777 if exist(OutputDir,'dir') 2778 uigetfile_uvmat('status_display',OutputDir) 2779 else 2780 msgbox_uvmat('ERROR','output folder not created yet: calculation did not start') 2781 set(handles.status,'BackgroundColor',[0 1 0]) 2782 end 2805 2783 else 2806 2784 %% delete current display fig if selection is off
Note: See TracChangeset
for help on using the changeset viewer.