Changeset 609 for trunk/src/series.m
- Timestamp:
- Apr 9, 2013, 8:20:00 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series.m
r606 r609 67 67 68 68 %% initial settings 69 drawnow 70 set(hObject,'Units','pixels') 69 set(0,'Unit','points') 70 ScreenSize=get(0,'ScreenSize');%size of the current screen 71 Width=750;% prefered width of the GUI in points (1/72 inch) 72 Height=520; 73 %adjust to screen size (reduced by a min margin) 74 RescaleFactor=min((ScreenSize(3)-80)/Width,(ScreenSize(4)-80)/Height); 75 if RescaleFactor>1 76 %RescaleFactor=RescaleFactor/2+1/2; %reduce the rescale factor to provide an increased margin for a big screen 77 RescaleFactor=min(RescaleFactor,1); 78 end 79 Width=Width*RescaleFactor; 80 Height=Height*RescaleFactor; 81 LeftX=80*RescaleFactor;%position of the left fig side, in pixels (put to the left side, with some margin) 82 LowY=round(ScreenSize(4)/2-Height/2); % put at the middle height on the screen 83 set(hObject,'Units','points') 84 set(hObject,'Position',[LeftX LowY Width Height]) 71 85 set(handles.PairString,'ColumnName',{'pairs'}) 72 86 set(handles.PairString,'ColumnEditable',false) … … 78 92 if ~exist('Param','var') 79 93 Param=[]; %default 80 end 81 82 %% default list offunctions in the mebu ActionName94 end 95 96 %% list of builtin functions in the mebu ActionName 83 97 ActionList={'check_data_files';'aver_stat';'time_series';'merge_proj'};% WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback 98 NbBuiltinAction=numel(ActionList); 84 99 [path_series,name,ext]=fileparts(which('series'));% path to the GUI series 85 100 path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series' 86 %path_bin=fullfile(path_series,'bin');%path of the binary functions (compiled) 87 ActionPathList=regexprep(ActionList,'^.+$',path_series_fct);% set path=path_series to each function in the list ('^.+$'=any non empty nbre of char form beginning to end of char string) 88 ActionPathList=[ActionPathList ActionPathList];% set path to .sh commands for compiled functions 89 ActionExtList={'.m';'.sh'};% default choice of extensions (Matlab fct .m or compiled version .sh) 101 ActionExtList={'.m';'.sh'};% default choice of extensions (Matlab fct .m or compiled version .sh 102 ActionPathList=cell(NbBuiltinAction,numel(ActionExtList));%initiate the cell matrix of Action fct paths 103 ActionPathList(:)={path_series_fct}; %set the default path to series fcts to all list members 90 104 RunModeList={'local';'background'};% default choice of extensions (Matlab fct .m or compiled version .sh) 91 105 [s,w]=system('oarstat');% look for cluster system 'oar' … … 99 113 set(handles.RunMode,'String',RunModeList) 100 114 101 %% default list offunctions in the mebu TransformName115 %% list of builtin transform functions in the mebu TransformName 102 116 TransformList={'';'sub_field';'phys';'phys_polar'};% WARNING: must fit with the corresponding menu in uvmat and nb_builtin_transform=4 in TransformName_callback 117 NbBuiltinTransform=numel(TransformList); 103 118 path_transform_fct=fullfile(path_series,'transform_field'); 104 TransformPathList=regexprep(TransformList,'^.+$',path_transform_fct);% set path=path_transform_fct to each function in the list ('^.+$'=any non empty nbre of char form beginning to end of char string) 105 106 %% load the personal file uvmat_perso.mat 119 TransformPathList=cell(NbBuiltinTransform,1);%initiate the cell matrix of Action fct paths 120 TransformPathList(:)={path_transform_fct}; %set the default path to series fcts to all list members 121 122 %% get the user defined functions stored in the personal file uvmat_perso.mat 107 123 dir_perso=prefdir; 108 124 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); … … 131 147 132 148 %% selection of the input Action fct 133 ActionCheckExist= false(size(ActionList));134 for ilist= 1:numel(ActionList)149 ActionCheckExist=true(size(ActionList));%initiate the check of the path to the listed action fct 150 for ilist=NbBuiltinAction+1:numel(ActionList)%check the validity of the path of the user defined Action fct 135 151 ActionCheckExist(ilist)=exist(fullfile(ActionPathList{ilist},[ActionList{ilist} '.m']),'file'); 136 152 end 137 ActionPathList=ActionPathList(ActionCheckExist,:); 153 ActionPathList=ActionPathList(ActionCheckExist,:);% suppress the menu options which are not valid anymore 138 154 ActionList=ActionList(ActionCheckExist); 139 155 set(handles.ActionName,'String',[ActionList;{'more...'}]) … … 152 168 153 169 %% selection of the input transform fct 154 TransformCheckExist=false(size(TransformList)); 155 TransformCheckExist(1)=1;%the first option is blank: no transform, always allowed 156 for ilist=2:numel(TransformList) 170 TransformCheckExist=true(size(TransformList)); 171 for ilist=NbBuiltinTransform+1:numel(TransformList) 157 172 TransformCheckExist(ilist)=exist(fullfile(TransformPathList{ilist},[TransformList{ilist} '.m']),'file'); 158 173 end … … 260 275 %get the previous input file in the Input Table 261 276 oldfile=''; %default 262 InputTable=get(handles.InputTable,'Data'); 263 if isequal(InputTable(:,1),[{''};{''};{''};{''}])%open the personal file for empty previous input 277 SeriesData=get(handles.series,'UserData'); 278 if isfield(SeriesData,'RefFile') 279 oldfile=SeriesData.RefFile{1}; 280 end 281 if ~exist(oldfile,'file') 264 282 dir_perso=prefdir; 265 283 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); … … 270 288 end 271 289 end 272 else% select the previous file as the first line of the input table 273 oldfile=fullfile(InputTable{1,1},InputTable{1,2},InputTable{1,3}); 274 end 275 hfig=uigetfile_uvmat('file browser',fileparts(fileparts(oldfile))); 276 uiwait(hfig); 277 if ishandle(hfig) % stop if browser closed without selection 278 fileinput=get(hfig,'UserData');% retrieve the input file selection 279 delete(hfig) 280 display_file_name(handles,fileinput,0) 290 end 291 fileinput=uigetfile_uvmat('file browser',oldfile); 292 if ~isempty(fileinput) 293 display_file_name(handles,fileinput,0) 281 294 end 282 295 % … … 481 494 % INPUT: 482 495 % handles: handles of elements in the GUI 483 % fi elinput: input file name, including path484 % append =0 (refresh the Input table with the new file), ='append' append a new line in thetable496 % fileinput: input file name, including path 497 % iview: line index in the input table 485 498 486 499 %% get the input root name, indices, file extension and nomenclature NomType … … 542 555 ref_i=floor((i1+i2)/2);% reference image number corresponding to the file 543 556 set(handles.num_ref_i,'String',num2str(ref_i)); 544 set(handles.num_ref_i,'UserData',[i1 i2]) 557 % set(handles.num_ref_i,'UserData',[i1 i2])%store the indices for future opening 545 558 if isempty(j1) 546 559 j1=1; … … 551 564 ref_j=floor((j1+j2)/2);% reference image number corresponding to the file 552 565 set(handles.num_ref_j,'String',num2str(ref_j)); 553 set(handles.num_ref_j,'UserData',[j1 j2]) 566 % set(handles.num_ref_j,'UserData',[j1 j2]);%store the indices for future opening 554 567 555 568 %% update the list of recent files in the menubar and save it for future opening … … 571 584 save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat 572 585 end 586 % save the opened file to initiate future opening 587 SeriesData=get(handles.series,'UserData'); 588 SeriesData.RefFile{iview}=fileinput; 589 set(handles.series,'UserData',SeriesData) 573 590 574 591 set(handles.InputTable,'BackgroundColor',[1 1 1]) … … 595 612 %% display the min and max indices for the file series 596 613 if size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0 597 MinIndex_j=1; 614 MinIndex_j=1;% index j set to 1 by default 598 615 MaxIndex_j=1; 599 616 MinIndex_i=find(i1_series(:,2,:), 1 )-1; … … 602 619 pair_max=squeeze(max(i1_series,[],1)); %max on pair index 603 620 j_max=max(pair_max,[],1); 604 %i_sum=sum(sum(i1_series,2),1);%sum of i1_series on the last index605 621 MaxIndex_i=find(j_max, 1, 'last' )-1;% max ref index i 606 622 MinIndex_i=find(j_max, 1 )-1;% min ref index i 607 623 diff_i_max=diff(j_max); 608 if isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max)))609 set(handles.num_incr_i,'String',num2str(diff_i_max(1))) 624 if ~isempty(diff_i_max) && isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max))) 625 set(handles.num_incr_i,'String',num2str(diff_i_max(1)))% detect an increment to dispaly by default 610 626 end 611 627 i_max=max(pair_max,[],2); … … 633 649 set(handles.MaxIndex,'Data',MaxIndex)%display the max indices in the table MaxIndex 634 650 635 %% adjust the first and last indices if requested by the bounds636 first_i=str2num(get(handles.num_first_i,'String')); 637 ref_i=str2num(get(handles.num_ref_i,'String')); 638 ref_ j=str2num(get(handles.num_ref_j,'String'));651 %% adjust the first and last indices, only if requested by the bounds 652 % i index, compare input to min index i 653 first_i=str2num(get(handles.num_first_i,'String'));%retrieve previous first i 654 ref_i=str2num(get(handles.num_ref_i,'String'));%index i given by the input field 639 655 if isempty(first_i) 640 first_i=ref_i; 656 first_i=ref_i;% first_i updated by the input value 641 657 elseif first_i < MinIndex_i 642 first_i=MinIndex_i; 658 first_i=MinIndex_i; % first_i set to the min i index (restricted by oter input lines) 643 659 elseif first_i >MaxIndex_i 644 first_i=MinIndex_i; 645 end 660 first_i=MaxIndex_i;% first_i set to the max i index (restricted by oter input lines) 661 end 662 % j index, compare input to min index j 646 663 first_j=str2num(get(handles.num_first_j,'String')); 664 ref_j=str2num(get(handles.num_ref_j,'String'));%index j given by the input field 647 665 if isempty(first_j) 648 first_j=ref_j; 666 first_j=ref_j;% first_j updated by the input value 649 667 elseif first_j<MinIndex_j 650 first_j=MinIndex_j; 668 first_j=MinIndex_j; % first_j set to the min j index (restricted by oter input lines) 651 669 elseif first_j >MaxIndex_j 652 first_j=MinIndex_j; 653 end 670 first_j=MaxIndex_j; % first_j set to the max j index (restricted by oter input lines) 671 end 672 % i index, compare input to max index i 654 673 last_i=str2num(get(handles.num_last_i,'String')); 655 674 if isempty(last_i) … … 660 679 last_i=first_i; 661 680 end 662 last_j=str2num(get(handles.num_first_j,'String')); 681 % j index, compare input to max index j 682 last_j=str2num(get(handles.num_last_j,'String')); 663 683 if isempty(last_j) 664 684 last_j=ref_j; 665 685 elseif last_j>MaxIndex_j 666 686 last_j=MaxIndex_j; 667 elseif last_ i<first_i668 last_ i=first_i;687 elseif last_j<first_j 688 last_j=first_j; 669 689 end 670 690 set(handles.num_first_i,'String',num2str(first_i)); … … 677 697 FileBase=fullfile(InputTable{iview,1},InputTable{iview,3}); 678 698 time=[];%default 699 TimeSource=''; 679 700 % case of movies 680 701 if strcmp(InputTable{iview,4},'*') 681 702 if ~isempty(VideoObject) 682 703 imainfo=get(VideoObject); 683 time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)'; 684 % set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec 704 time=zeros(imainfo.NumberOfFrames+1,2); 705 time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)'; 706 TimeSource='video'; 707 % set(han:dles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec 685 708 ColorType='truecolor'; 686 709 elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image … … 698 721 end 699 722 700 %% read image documentation file if found %%%%%%%%%%%%%%%%%%%%%%%%%%%723 %% read image documentation file if found 701 724 XmlData=[]; 702 725 NbSlice_calib={}; … … 710 733 if isfield(XmlData,'Time') 711 734 time=XmlData.Time; 735 TimeSource='xml'; 712 736 end 713 737 if isfield(XmlData,'Camera') … … 742 766 if isempty(MinIndex_j)% only i index 743 767 if MinIndex_i>0 744 TimeTable{iview,1}=time(MinIndex_i );745 end 746 TimeTable{iview,2}=time(first_i );747 TimeTable{iview,3}=time(last_i );748 TimeTable{iview,4}=time(MaxIndex_i );768 TimeTable{iview,1}=time(MinIndex_i+1); 769 end 770 TimeTable{iview,2}=time(first_i+1); 771 TimeTable{iview,3}=time(last_i+1); 772 TimeTable{iview,4}=time(MaxIndex_i+1); 749 773 elseif ~isempty(time) 750 774 if MinIndex_i>0 751 775 TimeTable{iview,1}=time(MinIndex_i,MinIndex_j); 752 776 end 753 if size(time)>=[last_i last_j]754 TimeTable{iview,2}=time(first_i ,first_j);755 TimeTable{iview,3}=time(last_i ,last_j);756 end 757 if size(time)>=[MaxIndex_i MaxIndex_j];758 TimeTable{iview,4}=time(MaxIndex_i ,MaxIndex_j);777 if size(time)>=[last_i+1 last_j+1] 778 TimeTable{iview,2}=time(first_i+1,first_j+1); 779 TimeTable{iview,3}=time(last_i+1,last_j+1); 780 end 781 if size(time)>=[MaxIndex_i+1 MaxIndex_j+1]; 782 TimeTable{iview,4}=time(MaxIndex_i+1,MaxIndex_j+1); 759 783 end 760 784 end … … 787 811 %% update the series info in 'UserData' 788 812 SeriesData=get(handles.series,'UserData'); 789 SeriesData.Ref_i{iview}=get(handles.num_ref_i,'UserData');790 SeriesData.Ref_j{iview}=get(handles.num_ref_j,'UserData');791 813 SeriesData.i1_series{iview}=i1_series; 792 814 SeriesData.i2_series{iview}=i2_series; … … 796 818 SeriesData.FileInfo{iview}=FileInfo; 797 819 SeriesData.Time{iview}=time; 820 if ~isempty(TimeSource) 821 SeriesData.TimeSource=TimeSource; 822 end 798 823 if ~isempty(TimeUnit) 799 824 SeriesData.TimeUnit=TimeUnit; … … 992 1017 if size(SeriesData.Time{iview},1)>=i2(2)&&size(SeriesData.Time{iview},1)>=j2(2) 993 1018 if isempty(ref_j) 994 time_first=(SeriesData.Time{iview}(i1(1) )+SeriesData.Time{iview}(i2(1)))/2;995 time_last=(SeriesData.Time{iview}(i1(2) )+SeriesData.Time{iview}(i2(2)))/2;1019 time_first=(SeriesData.Time{iview}(i1(1)+1)+SeriesData.Time{iview}(i2(1)+1))/2; 1020 time_last=(SeriesData.Time{iview}(i1(2)+1)+SeriesData.Time{iview}(i2(2))+1)/2; 996 1021 else 997 time_first=(SeriesData.Time{iview}(i1(1) ,j1(1))+SeriesData.Time{iview}(i2(1),j2(1)))/2;998 time_last=(SeriesData.Time{iview}(i1(2) ,j1(2))+SeriesData.Time{iview}(i2(2),j2(2)))/2;1022 time_first=(SeriesData.Time{iview}(i1(1)+1,j1(1)+1)+SeriesData.Time{iview}(i2(1)+1,j2(1)+1))/2; 1023 time_last=(SeriesData.Time{iview}(i1(2)+1,j1(2)+1)+SeriesData.Time{iview}(i2(2)+1,j2(2)+1))/2; 999 1024 end 1000 1025 TimeTable{iview,2}=time_first; %TODO: take into account pairs … … 1429 1454 1430 1455 %% read index ranges 1431 first_i=1; 1432 last_i=1; 1433 incr_i=1; 1434 first_j=1; 1435 last_j=1; 1436 incr_j=1; 1437 if isfield(Series.IndexRange,'first_i') 1438 first_i=Series.IndexRange.first_i; 1439 incr_i=Series.IndexRange.incr_i; 1440 last_i=Series.IndexRange.last_i; 1441 end 1442 if isfield(Series.IndexRange,'first_j') 1443 first_j=Series.IndexRange.first_j; 1444 last_j=Series.IndexRange.last_j; 1445 incr_j=Series.IndexRange.incr_j; 1446 end 1447 if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... 1448 set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return 1456 [first_i,incr_i,last_i,first_j,incr_j,last_j,errormsg]=get_index_range(Series.IndexRange); 1457 if ~isempty(errormsg) 1458 msgbox_uvmat('ERROR',['series/Run_Callback/get_index_range' errormsg]) 1459 set(handles.RUN, 'Enable','On'), 1460 set(handles.RUN,'BackgroundColor',[1 0 0]) 1461 return 1449 1462 else 1450 1463 BlockLength=ceil(numel(first_i:incr_i:last_i)/NbProcess); … … 1457 1470 switch StatusData.OutputFileMode 1458 1471 case 'NbInput' 1459 StatusData.NbOutputFile=numel(first_i ,incr_i:last_i)*numel(first_j,incr_j:last_j);1472 StatusData.NbOutputFile=numel(first_i:incr_i:last_i)*numel(first_j:incr_j:last_j); 1460 1473 case 'NbInput_i' 1461 StatusData.NbOutputFile=numel(first_i ,incr_i:last_i);1474 StatusData.NbOutputFile=numel(first_i:incr_i:last_i); 1462 1475 case 'NbSlice' 1463 1476 StatusData.NbOutputFile=str2num(get(handles.num_NbSlice,'String')); … … 1479 1492 Series.IndexRange.last_i=min(first_i+(iprocess)*BlockLength*incr_i-1,last_i); 1480 1493 else 1481 Series.IndexRange.first_i= first_i+i process-1;1494 Series.IndexRange.first_i= first_i+incr_i*(iprocess-1); 1482 1495 Series.IndexRange.incr_i=incr_i*Series.IndexRange.NbSlice; 1483 1496 end
Note: See TracChangeset
for help on using the changeset viewer.