Changeset 667 for trunk/src/series.m


Ignore:
Timestamp:
Jul 15, 2013, 2:50:08 PM (11 years ago)
Author:
sommeria
Message:

a few bugs corrected.
multimask introduced in series
displ_uvmat transformed into disp_uvmat

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r664 r667  
    7575RescaleFactor=min((ScreenSize(3)-80)/Width,(ScreenSize(4)-80)/Height);
    7676if RescaleFactor>1
    77     %RescaleFactor=RescaleFactor/2+1/2; %reduce the rescale factor to provide an increased margin for a big screen
    7877    RescaleFactor=min(RescaleFactor,1);
    7978end
     
    8988set(handles.MinIndex_i,'ColumnEditable',false)
    9089set(handles.MinIndex_i,'ColumnName',{'i min'})
     90set(handles.MinIndex_i,'Data',[])% initiate Data to double (not cell)
    9191
    9292% settings of table MinIndex_j
     
    9494set(handles.MinIndex_j,'ColumnEditable',false)
    9595set(handles.MinIndex_j,'ColumnName',{'j min'})
     96set(handles.MinIndex_j,'Data',[])% initiate Data to double (not cell)
    9697
    9798% settings of table MaxIndex_i
     
    99100set(handles.MaxIndex_i,'ColumnEditable',false)
    100101set(handles.MaxIndex_i,'ColumnName',{'i max'})
     102set(handles.MaxIndex_i,'Data',[])% initiate Data to double (not cell)
    101103
    102104% settings of table MaxIndex_j
     
    104106set(handles.MaxIndex_j,'ColumnEditable',false)
    105107set(handles.MaxIndex_j,'ColumnName',{'j max'})
     108set(handles.MaxIndex_j,'Data',[])% initiate Data to double (not cell)
    106109
    107110% settings of table PairString
    108111set(handles.PairString,'ColumnName',{'pairs'})
     112set(handles.PairString,'ColumnEditable',false)
     113set(handles.PairString,'ColumnFormat',{'char'})
     114set(handles.PairString,'Data',{''})
     115
     116% settings of table MaskTable
     117set(handles.MaskTable,'ColumnName',{'mask name'})
    109118set(handles.PairString,'ColumnEditable',false)
    110119set(handles.PairString,'ColumnFormat',{'char'})
     
    154163        for ifile=1:min(length(h.MenuFile),5)
    155164            set(handles.(['MenuFile_' num2str(ifile)]),'Label',h.MenuFile{ifile});
     165            set(handles.(['MenuFile_' num2str(ifile+5)]),'Label',h.MenuFile{ifile});
    156166        end
    157167    end
     
    306316fileinput=uigetfile_uvmat('pick a file to append in the input table',oldfile);
    307317if ~isempty(fileinput)
    308     if get(handles.CheckAppend,'Value')
     318%     if get(handles.CheckAppend,'Value')
     319%         display_file_name(handles,fileinput,'append')
     320%     else
     321        display_file_name(handles,fileinput,'one')
     322%     end
     323end
     324
     325% --------------------------------------------------------------------
     326function MenuBrowseAppend_Callback(hObject, eventdata, handles)
     327
     328%% look for the previously opened file 'oldfile'
     329InputTable=get(handles.InputTable,'Data');
     330RootPathCell=InputTable(:,1);
     331if isempty(RootPathCell{1})% no input file in the table
     332     MenuBrowse_Callback(hObject, eventdata, handles)%refresh the input table, not append
     333     return
     334end
     335SubDirCell=InputTable(:,2);
     336% oldfile=''; %default
     337% if ~(isempty(RootPathCell) || isequal(RootPathCell,{''}))%loads the previously stored file name and set it as default in the file_input box
     338    oldfile=fullfile(RootPathCell{1},SubDirCell{1});
     339% end
     340
     341%% use a file name stored in prefdir
     342dir_perso=prefdir;
     343profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     344if exist(profil_perso,'file')
     345    h=load (profil_perso);
     346    if isfield(h,'RootPath') && ischar(h.RootPath)
     347        oldfile=h.RootPath;
     348    end
     349end
     350
     351%% launch the browser
     352fileinput=uigetfile_uvmat('pick a file to append in the input table',oldfile);
     353if ~isempty(fileinput)
    309354        display_file_name(handles,fileinput,'append')
    310     else
    311         display_file_name(handles,fileinput,'one')
    312     end
    313355end
    314356
     
    318360function MenuFile_Callback(hObject, eventdata, handles)
    319361
    320 fileinput=get(hObject,'Label');
    321 if get(handles.CheckAppend,'Value')
    322     display_file_name(handles,fileinput,'append')
     362display_file_name(handles,get(hObject,'Label'),'one')
     363
     364%------------------------------------------------------------------------
     365% --- fct activated by selecting a previous file under the menu Open/append
     366%------------------------------------------------------------------------
     367function MenuFile_append_Callback(hObject, eventdata, handles)
     368
     369InputTable=get(handles.InputTable,'Data');
     370if isempty(InputTable{1,1})% no input file in the table
     371    display_file_name(handles,get(hObject,'Label'),'one') %refresh the input table, not append
    323372else
    324     display_file_name(handles,fileinput,'one')
     373    display_file_name(handles,get(hObject,'Label'),'append')% append the selected file to the current list of InputTable
    325374end
    326375
     
    424473%------------------------------------------------------------------------
    425474set(handles.REFRESH,'Visible','on')
    426 set(handles.REFRESH_title,'Visible','on')
     475% set(handles.REFRESH_title,'Visible','on')
    427476iview=eventdata.Indices(1);
    428477view_set=get(handles.REFRESH,'UserData');
     
    489538% iview: line index in the input table
    490539%       or 'one': refresh the list
    491 %       'checkappend': add a new line to the list
     540%         'append': add a new line to the input table
    492541
    493542%% get the input root name, indices, file extension and nomenclature NomType
     
    581630ref_j=floor((j1+j2)/2);% reference image number corresponding to the file
    582631set(handles.num_ref_j,'String',num2str(ref_j));
    583 % set(handles.num_ref_j,'UserData',[j1 j2]);%store the indices for future opening
    584632
    585633%% update the list of recent files in the menubar and save it for future opening
     
    629677    ref_i=squeeze(max(i1_series(1,:,:),[],2));% select ref_j index for each ref_i
    630678    ref_j=squeeze(max(j1_series(1,:,:),[],3));% select ref_i index for each ref_j
    631 %     [ref_j,ref_i]=find(squeeze(i1_series(1,:,:)));
    632 %     [ref_j,ref_i]=find(squeeze(i1_series(1,:,:)))
    633679     MinIndex_i=min(find(ref_i))-1;
    634680     MaxIndex_i=max(find(ref_i))-1;
    635 %         MinIndex_j=min(ref_j)-1;
    636681     MaxIndex_j=max(find(ref_j))-1;
    637 %     MinIndex_j=min(find(j1_series_j))-1;
    638 %     MaxIndex_j=max(find(j1_series_j))-1;
    639 %     MaxIndex_i=max(i1_series_i)-1;
    640 %     MinIndex_j=min(i1_series_j)-1;
    641 %     MaxIndex_j=max(i1_series_j)-1;
    642 %     MaxIndex_i=max(ref_i)-1;
    643682     MinIndex_j=min(find(ref_j))-1;
    644 %     MaxIndex_j=max(ref_j)-1;
    645683    diff_j_max=diff(ref_j);
    646684    diff_i_max=diff(ref_i);
     
    668706    MinIndex_j=0;
    669707end
    670 MinIndex_i_cell=get(handles.MinIndex_i,'Data');%retrieve the min indices in the table MinIndex
    671 MinIndex_j_cell=get(handles.MinIndex_j,'Data');%retrieve the min indices in the table MinIndex
    672 MaxIndex_i_cell=get(handles.MaxIndex_i,'Data');%retrieve the min indices in the table MinIndex
    673 MaxIndex_j_cell=get(handles.MaxIndex_j,'Data');%retrieve the min indices in the table MinIndex
    674 MinIndex_i_cell(iview,1)=MinIndex_i;
    675 MinIndex_j_cell(iview,1)=MinIndex_j;
    676 MaxIndex_i_cell(iview,1)=MaxIndex_i;
    677 MaxIndex_j_cell(iview,1)=MaxIndex_j;
    678 set(handles.MinIndex_i,'Data',MinIndex_i_cell)%display the min indices in the table MinIndex
    679 set(handles.MinIndex_j,'Data',MinIndex_j_cell)%display the max indices in the table MaxIndex
    680 set(handles.MaxIndex_i,'Data',MaxIndex_i_cell)%display the min indices in the table MinIndex
    681 set(handles.MaxIndex_j,'Data',MaxIndex_j_cell)%display the max indices in the table MaxIndex
     708MinIndex_i_table=get(handles.MinIndex_i,'Data');%retrieve the min indices in the table MinIndex
     709MinIndex_j_table=get(handles.MinIndex_j,'Data');%retrieve the min indices in the table MinIndex
     710MaxIndex_i_table=get(handles.MaxIndex_i,'Data');%retrieve the min indices in the table MinIndex
     711MaxIndex_j_table=get(handles.MaxIndex_j,'Data');%retrieve the min indices in the table MinIndex
     712MinIndex_i_table(iview,1)=MinIndex_i;
     713MinIndex_j_table(iview,1)=MinIndex_j;
     714MaxIndex_i_table(iview,1)=MaxIndex_i;
     715MaxIndex_j_table(iview,1)=MaxIndex_j;
     716set(handles.MinIndex_i,'Data',MinIndex_i_table)%display the min indices in the table MinIndex
     717set(handles.MinIndex_j,'Data',MinIndex_j_table)%display the max indices in the table MaxIndex
     718set(handles.MaxIndex_i,'Data',MaxIndex_i_table)%display the min indices in the table MinIndex
     719set(handles.MaxIndex_j,'Data',MaxIndex_j_table)%display the max indices in the table MaxIndex
    682720
    683721%% adjust the first and last indices for the selected series, only if requested by the bounds
     
    787825%% read timing and total frame number from the current file (movie files) if not already set by the xml file (prioritary)
    788826InputTable=get(handles.InputTable,'Data');
    789 % FileBase=fullfile(InputTable{iview,1},InputTable{iview,3});
    790827
    791828% case of movies
    792 % if strcmp(InputTable{iview,4},'*')
    793829if isempty(Time)
    794830    if ~isempty(VideoObject)
     
    801837        end
    802838        TimeSource='video';
    803         % set(han:dles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
    804         %     ColorType='truecolor';
    805 %     elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image
    806 %         if ~isempty(InputTable{iview,2})
    807 %             imainfo=imfinfo(fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,5}]));
    808 %         else
    809 %             imainfo=imfinfo([FileBase InputTable{iview,5}]);
    810 %         end
    811 %         %     ColorType=imainfo.ColorType;%='truecolor' for color images
    812 % %         if length(imainfo) >1 %case of image with multiple frames
    813 % %             nbfield=length(imainfo);
    814 % %             nbfield_j=1;
    815 % %         end
    816839    end
    817840end
     
    820843if ~isempty(Time)
    821844    TimeTable=get(handles.TimeTable,'Data');
    822     %     first_i=str2num(get(handles.num_first_i,'String'));
    823     %     last_i=str2num(get(handles.num_last_i,'String'));
    824     %     first_j=str2num(get(handles.num_first_j,'String'));
    825     %     last_j=str2num(get(handles.num_last_j,'String'));
    826     %     MinIndex_i=get(handles.MinIndex_i,'Data');
    827     %     MinIndex_j=get(handles.MinIndex_j,'Data');
    828     %     MaxIndex_i=get(handles.MaxIndex_i,'Data');
    829     %     MaxIndex_j=get(handles.MaxIndex_j,'Data');
    830845    TimeTable{iview,1}=Time(MinIndex_i+1,MinIndex_j+1);
    831846    if size(Time)>=[first_i+1 first_j+1]
     
    840855    set(handles.TimeTable,'Data',TimeTable)
    841856end
    842    
    843857
    844858%% update the series info in 'UserData'
     
    19862000%% Detect the types of input files
    19872001SeriesData=get(handles.series,'UserData');
    1988 nb_civ=0;nb_netcdf=0;
     2002iview_civ=[];nb_netcdf=0;
    19892003if ~isempty(SeriesData)
    1990     nb_civ=numel(find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType)));
     2004    iview_civ=find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType));
    19912005    nb_netcdf=numel(find(strcmp('netcdf',SeriesData.FileType)));
    19922006end
    1993 if nb_civ>=1
    1994     menu=set_veltype_display(SeriesData.FileInfo{1}.CivStage,SeriesData.FileType{1});
     2007%menu={''};
     2008if numel(iview_civ)>=1
     2009    menu=set_veltype_display(SeriesData.FileInfo{iview_civ(1)}.CivStage,SeriesData.FileType{iview_civ(1)});
    19952010    set(handles.VelType,'String',[{'*'};menu])
    1996     if nb_civ>=2
    1997         menu=set_veltype_display(SeriesData.FileInfo{2}.CivStage,SeriesData.FileType{2});
     2011    if numel(iview_civ)>=2
     2012        menu=set_veltype_display(SeriesData.FileInfo{iview_civ(2)}.CivStage,SeriesData.FileType{iview_civ(2)});
    19982013        set(handles.VelType_1,'String',[{'*'};menu])
    19992014    end
    2000 end
    2001        
    2002    
     2015end       
    20032016
    20042017%% Check whether alphabetical sorting of input Subdir is alowed by the Action fct  (for multiples series entries)
     
    20652078if isfield(ParamOut,'VelType')
    20662079    if strcmp( ParamOut.VelType,'one')||strcmp( ParamOut.VelType,'two')
    2067         if nb_civ>=1
     2080        if numel(iview_civ)>=1
    20682081            VelTypeVisible='on';
    20692082            InputFieldsVisible='on';
     
    20712084    end
    20722085    if strcmp( ParamOut.VelType,'two')
    2073         if nb_civ>=2
     2086        if numel(iview_civ)>=2
    20742087            VelType_1Visible='on';
    20752088        end
     
    20862099if isfield(ParamOut,'FieldName')
    20872100    if strcmp( ParamOut.FieldName,'one')||strcmp( ParamOut.FieldName,'two')
    2088         if (nb_civ+nb_netcdf)>=1
     2101        if (numel(iview_civ)+nb_netcdf)>=1
    20892102            InputFieldsVisible='on';
    20902103            FieldNameVisible='on';
     
    20922105    end
    20932106    if strcmp( ParamOut.FieldName,'two')
    2094         if (nb_civ+nb_netcdf)>=1
     2107        if (numel(iview_civ)+nb_netcdf)>=1
    20952108            FieldName_1Visible='on';
    20962109        end
     
    23602373                defaultname={''};
    23612374            end
    2362             [FileName, PathName] = uigetfile( ...
    2363                 {'*.xml;*.mat', ' (*.xml,*.mat)';
    2364                 '*.xml',  '.xml files '; ...
    2365                 '*.mat',  '.mat matlab files '}, ...
    2366                 'Pick an xml object file (or use uvmat to create it)',defaultname);
    2367             fileinput=[PathName FileName];%complete file name
    2368             sizf=size(fileinput);
    2369             if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
     2375            fileinput=uigetfile_uvmat('pick a xml object file (or use uvmat to create it)',defaultname,'.xml');
     2376%             [FileName, PathName] = uigetfile( ...
     2377%                 {'*.xml;*.mat', ' (*.xml,*.mat)';
     2378%                 '*.xml',  '.xml files '; ...
     2379%                 '*.mat',  '.mat matlab files '}, ...
     2380%                 'Pick an xml object file (or use uvmat to create it)',defaultname);
     2381%             fileinput=[PathName FileName];%complete file name
     2382%             sizf=size(fileinput);
     2383            if isempty(fileinput),return;end
    23702384            %read the file
    23712385            data=xml2struct(fileinput);
     
    24042418function ViewObject_Callback(hObject, eventdata, handles)
    24052419
    2406 if get(handles.ViewObject,'Value')
    2407     set(handles.EditObject,'Value',0)
     2420% if get(handles.ViewObject,'Value')
     2421   % set(handles.EditObject,'Value',0)
    24082422        UserData=get(handles.series,'UserData');
     2423    hset_object=findobj(allchild(0),'Tag','set_object');
     2424    if ~isempty(hset_object)
     2425        delete(hset_object)% refresh set_object if already opened
     2426    end
    24092427    hset_object=set_object(UserData.ProjObject);
    24102428    set(hset_object,'Name','view_object_series')
    2411 else
    2412     hset_object=findobj(allchild(0),'Tag','set_object');
    2413     if ~isempty(hset_object)
    2414         delete(hset_object)
    2415     end
    2416 end
     2429% else
     2430%     hset_object=findobj(allchild(0),'Tag','set_object');
     2431%     if ~isempty(hset_object)
     2432%         delete(hset_object)
     2433%     end
     2434% end
    24172435
    24182436%------------------------------------------------------------------------
     
    24282446    set(get(hset_object,'Children'),'Enable','on')
    24292447else
    2430     hset_object=findobj(allchild(0),'Tag','set_object');
     2448    hset_object=findobj(allchild(0),'Tag','set_object'); 
    24312449    if ~isempty(hset_object)
    2432         delete(hset_object)
     2450        set(get(hset_object,'Children'),'Enable','off')
    24332451    end
    24342452end
     
    24392457function DeleteObject_Callback(hObject, eventdata, handles)
    24402458
    2441 if get(handles.DeleteObject,'Value')
     2459% if get(handles.DeleteObject,'Value')
    24422460        SeriesData=get(handles.series,'UserData');
    24432461    SeriesData.ProjObject=[];
     
    24452463    set(handles.ProjObject,'String','')
    24462464    set(handles.CheckObject,'Value',0)
     2465    set(handles.ViewObject,'Visible','off')
     2466    set(handles.EditObject,'Visible','off')
     2467    hset_object=findobj(allchild(0),'Tag','set_object');
     2468    if ~isempty(hset_object)
     2469        delete(hset_object)
     2470    end
    24472471    set(handles.DeleteObject,'Visible','off')
    2448     set(handles.ViewObject,'Visible','off')
    2449     set(handles.DeleteObject,'Value',0)
    2450 end
    2451 
    2452 %--------------------------------------------------------------
     2472%     set(handles.DeleteObject,'Value',0)
     2473% end
     2474
     2475%------------------------------------------------------------------------
     2476% --- Executed when CheckMask is activated
     2477%------------------------------------------------------------------------
    24532478function CheckMask_Callback(hObject, eventdata, handles)
     2479
    24542480if get(handles.CheckMask,'Value')
     2481    MaskData=get(handles.MaskTable,'Data');
    24552482    InputTable=get(handles.InputTable,'Data');
    2456     for iview=1:size(InputTable,1)
     2483    nbview=size(InputTable,1);
     2484    %     MaskTable=cell(nbview,1);
     2485    for iview=1:nbview
    24572486        RootPath=InputTable{iview,1};
    2458         SubDir=InputTable{iview,2};
    2459         MaskSubDir=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
    2460         MaskName=fullfile(RootPath,[MaskSubDir '.mask'],'mask_1.png');
    2461         if ~exist(MaskName,'file')
    2462             msgbox_uvmat('WARNING',['mask file '  MaskName ' not found'])
    2463             return
    2464         end
    2465     end
    2466 end
    2467 %--------------------------------------------------------------
     2487        if ~isempty(RootPath)
     2488            if isempty(MaskData{iview})
     2489                SubDir=InputTable{iview,2};
     2490                MaskSubDir=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
     2491                MaskName=fullfile(RootPath,[MaskSubDir '.mask'],'mask_1.png');
     2492                if ~exist(MaskName,'file')
     2493                    MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image');
     2494                end
     2495                MaskTable{iview,1}=MaskName ;
     2496                ListMask{iview,1}=num2str(iview);
     2497            end
     2498        end
     2499    end
     2500    nbview=size(MaskTable,1);
     2501    set(handles.MaskTable,'Data',MaskTable)
     2502    %     set(handles.MaskTable,'ColumnFormat',{MaskTable'})
     2503    set(handles.MaskTable,'Visible','on')
     2504    set(handles.MaskBrowse,'Visible','on')
     2505    set(handles.ListMask,'Visible','on')
     2506    set(handles.ListMask,'String',ListMask)
     2507    set(handles.ListMask,'Value',numel(ListMask))
     2508else
     2509    set(handles.MaskTable,'Visible','off')
     2510    set(handles.MaskBrowse,'Visible','off')
     2511    set(handles.ListMask,'Visible','off')
     2512end
     2513
     2514%------------------------------------------------------------------------
     2515% --- Executes on button press in MaskBrowse.
     2516%------------------------------------------------------------------------
     2517function MaskBrowse_Callback(hObject, eventdata, handles)
     2518InputTable=get(handles.InputTable,'Data');
     2519iview=get(handles.ListMask,'Value');
     2520%     MaskTable=cell(nbview,1);
     2521
     2522RootPath=InputTable{iview,1};
     2523%         if ~isempty(RootPath)
     2524%         SubDir=InputTable{iview,2};
     2525%         MaskSubDir=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
     2526%         MaskName=fullfile(RootPath,[MaskSubDir '.mask'],'mask_1.png');
     2527%         if ~exist(MaskName,'file')
     2528MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image');
     2529%         end
     2530if ~isempty(MaskName)
     2531    MaskTable=get(handles.MaskTable,'Data');
     2532MaskTable{iview,1}=MaskName ;
     2533%         end
     2534set(handles.MaskTable,'Data',MaskTable)
     2535end
     2536   % set(handles.MaskTable,'ColumnFormat',{MaskTable'})
     2537
     2538%------------------------------------------------------------------------
     2539% --- Executes when selected cell(s) is changed in MaskTable.
     2540%------------------------------------------------------------------------
     2541function MaskTable_CellSelectionCallback(hObject, eventdata, handles)
     2542
     2543if numel(eventdata.Indices)>=1
     2544set(handles.ListMask,'Value',eventdata.Indices(1))
     2545end
    24682546
    24692547%-------------------------------------------------------------------
    2470 %'uv_ncbrowser': interactively calls the netcdf file browser 'get_field.m'
    2471 function ncbrowser_uvmat(hObject, eventdata)
    2472 %-------------------------------------------------------------------
    2473      bla=get(gcbo,'String');
    2474      ind=get(gcbo,'Value');
    2475      filename=cell2mat(bla(ind));
    2476       blank=find(filename==' ');
    2477       filename=filename(1:blank-1);
    2478      get_field(filename)
    2479 
    2480 % ------------------------------------------------------------------
    24812548function MenuHelp_Callback(hObject, eventdata, handles)
    24822549%-------------------------------------------------------------------
     
    26242691set(handles.PairString,'Unit','normalized')
    26252692set(handles.PairString,'ColumnWidth',{Pos(3)-5})
     2693
     2694%% MaskTable
     2695set(handles.MaskTable,'Unit','pixel')
     2696Pos=get(handles.MaskTable,'Position');
     2697set(handles.MaskTable,'Unit','normalized')
     2698set(handles.MaskTable,'ColumnWidth',{Pos(3)-5})
    26262699
    26272700%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.