Changeset 526 for trunk/src/series.m


Ignore:
Timestamp:
Aug 20, 2012, 12:32:31 PM (12 years ago)
Author:
sommeria
Message:

bugs corrected; Posiibility of usual 1D plots introduced with the new way of using get_field. time_series and aver_stat updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r525 r526  
    6868drawnow
    6969set(hObject,'Units','pixels')
     70set(handles.PairString,'ColumnName',{'pairs'})
    7071set(handles.PairString,'ColumnEditable',logical(0))
    7172set(handles.PairString,'ColumnFormat',{'char'})
    72 set(handles.PairString,'ColumnWidth',{60})
    7373set(handles.PairString,'Data',{''})
     74series_ResizeFcn(hObject, eventdata, handles)%resize table according to series GUI size
    7475set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display)
    7576dir_perso=prefdir;
     
    9293
    9394%% file name and browser initialisation
    94 if isfield(param,'menu_coord_str')
    95     set(handles.TransformName,'String',param.menu_coord_str)
    96 end
    97 if isfield(param,'menu_coord_val')
    98     set(handles.TransformName,'Value',param.menu_coord_val);
     95if isfield(param,'transform_str')
     96    set(handles.TransformName,'String',param.transform_str)
     97end
     98if isfield(param,'transform_val')
     99    set(handles.TransformName,'Value',param.transform_val);
    99100else
    100101     set(handles.TransformName,'Value',1);%default
     
    121122    set(handles.FieldName,'String',param.list_fields);% list menu fields
    122123    set(handles.FieldName,'Value',param.index_fields);% selected string index
    123 %     FieldCell{1}=param.list_fields{param.index_fields};
     124end
     125if isfield(param,'Coord_x_str')&& isfield(param,'Coord_x_val')
     126        set(handles.Coord_x,'String',param.Coord_x_str);% list menu fields
     127    set(handles.Coord_x,'Value',param.Coord_x_val);% selected string index
     128end
     129if isfield(param,'Coord_y_str')&& isfield(param,'Coord_y_val')
     130        set(handles.Coord_y,'String',param.Coord_y_str);% list menu fields
     131    set(handles.Coord_y,'Value',param.Coord_y_val);% selected string index
    124132end
    125133
     
    585593
    586594%% display the min and max indices for the file series
     595if size(i1_series,2)==1
     596    MinIndex_j=1;
     597    MaxIndex_j=1;
     598    MinIndex_i=min(find(i1_series));
     599    MaxIndex_i=max(find(i1_series));
     600else
    587601pair_max=squeeze(max(i1_series,[],1)); %max on pair index
    588602j_max=max(pair_max,[],1);
     
    590604MaxIndex_i=max(find(j_max))-1;% max ref index i
    591605MinIndex_i=min(find(j_max))-1;% min ref index i
     606diff_i_max=diff(j_max);
     607    if isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max)))
     608        set(handles.num_incr_i,'String',num2str(diff_i_max(1)))
     609    end
    592610i_max=max(pair_max,[],2);
    593611MaxIndex_j=max(find(i_max))-1;% max ref index i
    594612MinIndex_j=min(find(i_max))-1;% min ref index i
     613diff_j_max=diff(i_max);
     614    if isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max)))
     615        set(handles.num_incr_j,'String',num2str(diff_j_max(1)))
     616    end
     617end
    595618MinIndex=get(handles.MinIndex,'Data');%retrieve the min indices in the table MinIndex
    596619MaxIndex=get(handles.MaxIndex,'Data');%retrieve the max indices in the table MaxIndex
     
    611634elseif first_i < MinIndex_i
    612635    first_i=MinIndex_i;
     636elseif first_i >MaxIndex_i
     637    first_i=MinIndex_i;
    613638end
    614639first_j=str2num(get(handles.num_first_j,'String'));
     
    617642elseif first_j<MinIndex_j
    618643    first_j=MinIndex_j;
     644elseif first_j >MaxIndex_j
     645    first_j=MinIndex_j;
    619646end
    620647last_i=str2num(get(handles.num_last_i,'String'));
     
    623650elseif last_i > MaxIndex_i
    624651    last_i=MaxIndex_i;
     652elseif last_i<first_i
     653    last_i=first_i;
    625654end
    626655last_j=str2num(get(handles.num_first_j,'String'));
     
    629658elseif last_j>MaxIndex_j
    630659    last_j=MaxIndex_j;
     660elseif last_i<first_i
     661    last_i=first_i;
    631662end
    632663set(handles.num_first_i,'String',num2str(first_i));
     
    635666set(handles.num_last_j,'String',num2str(last_j));
    636667
    637 %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file
     668%% read timing and total frame number from the current file (movie files) may be overrid by xml file
    638669InputTable=get(handles.InputTable,'Data');
    639670FileBase=fullfile(InputTable{iview,1},InputTable{iview,3});
     
    644675        imainfo=get(VideoObject);
    645676        time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)';
    646         set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
     677       % set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
    647678        ColorType='truecolor';
    648679    elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image
     
    771802for iview=1:nbview
    772803    pair_max{iview}=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index
    773     if strcmp(get(handles.num_first_j,'Visible'),'off')
     804    if (strcmp(get(handles.num_first_j,'Visible'),'off')&& size(pair_max{iview},2)~=1)
    774805        pair_max{iview}=squeeze(max(pair_max{iview},[],1)); % consider only the i index
    775806    end
     
    831862        set(handles.Coord_y,'String',{'Y'});
    832863    case 'netcdf'
    833         set(handles_Fields,'Value',1)
    834         set(handles_Fields,'String',{'get_field...'})
     864        set(handles.FieldName,'Value',1)
     865        set(handles.FieldName,'String',{'get_field...'})
     866        if isempty(i2_series)
     867            i2=[];
     868        else
     869            i2=i2_series(1,ref_j+1,ref_i+1);
     870        end
     871        if isempty(j1_series)
     872            j1=[];j2=[];
     873        else
     874            j1=j1_series(1,ref_j+1,ref_i+1);
     875            if isempty(j2_series)
     876                j2=[];
     877            else
     878                j2=j2_series(1,ref_j+1,ref_i+1);
     879            end
     880        end
     881        FileName=fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1_series(1,ref_j+1,ref_i+1),i2,j1,j2);
    835882        hget_field=get_field(FileName);
    836883        hhget_field=guidata(hget_field);
    837884        get_field('RUN_Callback',hhget_field.RUN,[],hhget_field);
    838885    otherwise
    839         set(handles_Fields,'Value',1) % set menu to 'image'
    840         set(handles_Fields,'String',{'image'})
     886        set(handles.FieldName,'Value',1) % set menu to 'image'
     887        set(handles.FieldName,'String',{'image'})
    841888        set(handles.Coord_x,'Value',1);
    842889        set(handles.Coord_x,'String',{'AX'});
     
    844891        set(handles.Coord_y,'String',{'AY'});
    845892end
    846 % %% set default options in menu 'Fields'%% TODO: check VelType
    847 % if ~testima
    848 %     testcivx=0;
    849 %     if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field)
    850 %         set(handles_Fields,'Value',1)
    851 %         set(handles_Fields,'String',{'get_field...'})
    852 %         UvData=rmfield(UvData,'FieldsString');
    853 %     else
    854 %         Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ');
    855 %         if strcmp(Data.Conventions,'uvmat/civdata') ||( ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0))%if the new input is Civx
    856 %             FieldList=calc_field;
    857 %             set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
    858 %             set(handles_Fields,'Value',2) % set menu to 'velocity'
    859 %             col_vec=FieldList;
    860 %             col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar)
    861 %             testcivx=1;
    862 %         end
    863 %         if ~testcivx
    864 %             set(handles_Fields,'Value',1) % set menu to 'get_field...
    865 %             set(handles_Fields,'String',{'get_field...'})
    866 %             col_vec={'get_field...'};
    867 %         end
    868 %         set(handles.ColorScalar,'String',col_vec)
    869 %     end
    870 % end
    871 % set(handles.uvmat,'UserData',UvData)
    872 %
    873 % %% set index navigation options and refresh plots
    874 % scan_option='i';%default
    875 % state_j='off'; %default
    876 % if index==2
    877 %     if get(handles.scan_j,'Value')
    878 %         scan_option='j'; %keep the scan option for the second fiel series
    879 %     end
    880 %     if strcmp(get(handles.j1,'Visible'),'on')
    881 %         state_j='on';
    882 %     end
    883 % end
    884 % if ~isempty(j1_series)
    885 %         state_j='on';
    886 %         if isequal(nbfield,1) &&index==1
    887 %             scan_option='j'; %scan j index by default if nbfield=1               
    888 %         end
    889 % end
    890 % if isequal(scan_option,'i')
    891 %      set(handles.scan_i,'Value',1)
    892 %      scan_i_Callback([],[], handles);
    893 % else
    894 %      set(handles.scan_j,'Value',1)
    895 %      scan_j_Callback([],[], handles);
    896 % end
    897 % set(handles.scan_j,'Visible',state_j)
    898 % set(handles.j1,'Visible',state_j)
    899 % set(handles.j2,'Visible',state_j)
    900 % set(handles.last_j,'Visible',state_j);
    901 % set(handles.frame_j,'Visible',state_j);
    902 % set(handles.j_text,'Visible',state_j);
    903 % if ~isempty(i2_series)||~isempty(j2_series)
    904 %     set(handles.CheckFixPair,'Visible','on')
    905 % elseif index==1
    906 %     set(handles.CheckFixPair,'Visible','off')
    907 % end
    908 %
    909 %
    910 % mode_Callback(hObject, eventdata, handles)
    911 %
    912 % set(handles.REFRESH,'BackgroundColor',[0.7 0.7 0.7])
    913 % InputTable=get(handles.InputTable,'Data');
    914 % check_lines=get(handles.REFRESH,'UserData');
    915 %
    916 % %% check the indices and FileTypes for each series (limited to the new ones to save time)
    917 % for ind_list=1:length(check_lines)
    918 %     if  check_lines(ind_list)
    919 %         InputLine=InputTable(ind_list,:);
    920 %         detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data)
    921 %         detect_idem=detect_idem(detect_idem>0);
    922 %         if ~isempty (detect_idem)
    923 %             InputLine(detect_idem)=InputTable(ind_list-1,detect_idem);
    924 %             set(handles.InputTable,'Data',InputTable)
    925 %         end
    926 %         fileinput=fullfile_uvmat(InputLine{1},InputLine{2},InputLine{3},InputLine{5},InputLine{4},1,2,1,2);
    927 %         %fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2})
    928 %         %update file series defined by the selected line
    929 %         [InputTable{ind_list,3},InputTable{(ind_list),4},errormsg]=update_indices(handles,fileinput,ind_list);
    930 %         if ~isempty(errormsg)
    931 %                 msgbox_uvmat('ERROR',errormsg)
    932 %                 return
    933 %         end
    934 %     end
    935 % end
    936 % set(handles.InputTable,'Data',InputTable)
    937 % SeriesData=get(handles.series,'UserData');
    938 %
    939 % state_j='off';
    940 % state_Pairs='off';
    941 % state_InputFields='off';
    942 % val=get(handles.ListView,'Value');
    943 % ListViewString={''};
    944 % if ~isempty(SeriesData)
    945 % %     ListViewString={};
    946 %     for iview=1:size(InputTable,1)
    947 %         if ~isempty(SeriesData.j1_series{iview})
    948 %             state_j='on';
    949 %         end
    950 %         if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview})
    951 %             state_Pairs='on';
    952 %             ListViewString{iview}=num2str(iview);
    953 %             if check_lines(iview)
    954 %                 val=iview;%select the last pair if it is a new entry
    955 %             end
    956 %         end
    957 %         if strcmp(SeriesData.FileType{iview},'civx')||strcmp(SeriesData.FileType{iview},'civdata')
    958 %             state_InputFields='on';
    959 %         end
    960 %     end
    961 % end
    962 % set(handles.ListView,'Value',val)
    963 % set(handles.ListView,'String',ListViewString)
    964 % if strcmp(state_Pairs,'on')
    965 %     ListView_Callback(hObject,eventdata,handles)
    966 % end
    967 % set(handles.PairString,'Visible',state_Pairs)
    968 % enable_j(handles,state_j)
    969893
    970894%------------------------------------------------------------------------
     
    1059983% end
    1060984for iview=1:numel(SeriesData.i1_series)
    1061     index_min(iview)=min(find(SeriesData.i1_series{iview}(1,2:end,2:end)>0));
    1062     index_max(iview)=max(find(SeriesData.i1_series{iview}(1,2:end,2:end)>0));
     985    pair_max{iview}=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index
     986    if (strcmp(get(handles.num_first_j,'Visible'),'off')&& size(pair_max{iview},2)~=1)
     987        pair_max{iview}=squeeze(max(pair_max{iview},[],1)); % consider only the i index
     988    end
     989    pair_max{iview}=reshape(pair_max{iview},1,[]);
     990    index_min(iview)=find(pair_max{iview}>0, 1 );
     991    index_max(iview)=find(pair_max{iview}>0, 1, 'last' );
    1063992end
    1064993[index_min,iview_min]=min(index_min);
    1065994[index_max,iview_max]=min(index_max);
    1066 index_first=(ref_i(1)-1)*(size(SeriesData.i1_series{iview_min},2)-1)+ref_j(1);
    1067 index_last=(ref_i(2)-1)*(size(SeriesData.i1_series{iview_max},2)-1)+ref_j(2);
     995if size(SeriesData.i1_series{iview_min},2)==1% movie
     996  index_first=ref_i(1);
     997  index_last=ref_i(2);
     998else
     999%index_first=(ref_i(1)-1)*(size(SeriesData.i1_series{iview_min},2)-1)+ref_j(1);
     1000%index_last=(ref_i(2)-1)*(size(SeriesData.i1_series{iview_max},2)-1)+ref_j(2);
     1001index_first=(ref_i(1))*(size(SeriesData.i1_series{iview_min},2))+ref_j(1)+1;
     1002index_last=(ref_i(2))*(size(SeriesData.i1_series{iview_max},2))+ref_j(2)+1;
     1003end
    10681004range=index_max-index_min+1;
    10691005coeff_min=(index_first-index_min)/range;
     
    13341270function enable_j(handles,state)
    13351271set(handles.j_txt,'Visible',state)
    1336 % set(handles.num_MinIndex_j,'Visible',state)
    13371272set(handles.num_first_j,'Visible',state)
    13381273set(handles.num_last_j,'Visible',state)
    13391274set(handles.num_incr_j,'Visible',state)
    1340 % set(handles.num_MaxIndex_j,'Visible',state)
    13411275set(handles.num_ref_j,'Visible',state)
    13421276set(handles.ref_j_text,'Visible',state)
     1277% if strcmp(state,'off')
     1278%     set(handles.MinIndex,'ColumnName',{'imax'})
     1279% set(handles.MinIndex,'ColumnEditable',logical(0))
     1280% else
     1281%         set(handles.MinIndex,'ColumnName',{'imax','jmax'})
     1282% end
    13431283
    13441284
     
    20672007function RunMode_Callback(hObject, eventdata, handles)
    20682008
    2069 
    2070 % --- Executes on selection change in popupmenu14.
    2071 function popupmenu14_Callback(hObject, eventdata, handles)
    2072 % hObject    handle to popupmenu14 (see GCBO)
    2073 % eventdata  reserved - to be defined in a future version of MATLAB
    2074 % handles    structure with handles and user data (see GUIDATA)
    2075 
    2076 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu14 contents as cell array
    2077 %        contents{get(hObject,'Value')} returns selected item from popupmenu14
    2078 
    2079 
    2080 % --- Executes during object creation, after setting all properties.
    2081 function popupmenu14_CreateFcn(hObject, eventdata, handles)
    2082 % hObject    handle to popupmenu14 (see GCBO)
    2083 % eventdata  reserved - to be defined in a future version of MATLAB
    2084 % handles    empty - handles not created until after all CreateFcns called
    2085 
    2086 % Hint: popupmenu controls usually have a white background on Windows.
    2087 %       See ISPC and COMPUTER.
    2088 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    2089     set(hObject,'BackgroundColor','white');
    2090 end
     2009% --- Executes on selection change in Coord_x.
     2010function Coord_x_Callback(hObject, eventdata, handles)
     2011
     2012
     2013% --- Executes on selection change in Coord_y.
     2014function Coord_y_Callback(hObject, eventdata, handles)
     2015
     2016
     2017
     2018% --- Executes when series is resized.
     2019function series_ResizeFcn(hObject, eventdata, handles)
     2020%% input table
     2021set(handles.InputTable,'Unit','pixel')
     2022Pos=get(handles.InputTable,'Position');
     2023set(handles.InputTable,'Unit','normalized')
     2024ColumnWidth=round([0.5 0.14 0.14 0.14 0.08]*(Pos(3)-52));
     2025ColumnWidth=num2cell(ColumnWidth);
     2026set(handles.InputTable,'ColumnWidth',ColumnWidth)
     2027
     2028%% MinIndex and MaxIndex
     2029set(handles.MinIndex,'Unit','pixel')
     2030Pos=get(handles.MinIndex,'Position');
     2031set(handles.MinIndex,'Unit','normalized')
     2032ColumnWidth=get(handles.MinIndex,'ColumnWidth');
     2033if numel(ColumnWidth)==2
     2034    ColumnWidth=num2cell(floor([0.5 0.5]*(Pos(3)-20)));
     2035else
     2036    ColumnWidth={Pos(3)-5};
     2037end   
     2038set(handles.MinIndex,'ColumnWidth',ColumnWidth)
     2039set(handles.MaxIndex,'ColumnWidth',ColumnWidth)
     2040
     2041%% TimeTable
     2042set(handles.TimeTable,'Unit','pixel')
     2043Pos=get(handles.TimeTable,'Position');
     2044set(handles.TimeTable,'Unit','normalized')
     2045ColumnWidth=get(handles.TimeTable,'ColumnWidth');
     2046ColumnWidth=num2cell(floor([0.25 0.25 0.25 0.25]*(Pos(3)-20)));
     2047set(handles.TimeTable,'ColumnWidth',ColumnWidth)
     2048
     2049
     2050%% PairString
     2051set(handles.PairString,'Unit','pixel')
     2052Pos=get(handles.PairString,'Position');
     2053set(handles.PairString,'Unit','normalized')
     2054set(handles.PairString,'ColumnWidth',{Pos(3)-5})
Note: See TracChangeset for help on using the changeset viewer.