Changeset 675 for trunk/src/uvmat.m


Ignore:
Timestamp:
Aug 27, 2013, 11:25:21 PM (11 years ago)
Author:
sommeria
Message:

various bugs corrected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r674 r675  
    587587%------------------------------------------------------------------------
    588588%refresh the menu of input fieldname
    589 Fields_Callback(hObject, eventdata, handles);
     589FieldName_Callback(hObject, eventdata, handles);
    590590% refresh the current field view
    591591run0_Callback(hObject, eventdata, handles);
     
    874874ColorType='falsecolor'; %default
    875875UvData.MovieObject{index}=VideoObject;
    876 if ~isempty(VideoObject)
     876if ~isempty(VideoObject)% case of video data
    877877    imainfo=get(VideoObject);
    878878    TimeUnit='s';
     
    883883        XmlData.Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
    884884    end
    885     set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
     885    %set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
    886886    TimeName='video';
    887887    ColorType='truecolor';
     
    963963        (strcmp(FileType,'image')|| strcmp(FileType,'multimage')||strcmp(FileType,'civdata')||strcmp(FileType,'civx'))
    964964    TimeName='xml';
     965elseif strcmp(FileType,'civdata')
     966    TimeName='civdata';
     967elseif strcmp(FileType,'civx')
     968    TimeName='civx';
    965969end
    966970if index==1
     
    10411045
    10421046%% update the data attached to the uvmat interface
    1043 UvData.TimeUnit=TimeUnit;
     1047if ~isempty(TimeUnit)
     1048    if index==2 && isfield(UvData,'TimeUnit') && ~strcmp(UvData.TimeUnit,TimeUnit)
     1049        msgbox_uvmat('WARNING',['time unit for second file series ' TimeUnit ' inconsistent with first series'])
     1050    else
     1051        UvData.TimeUnit=TimeUnit;
     1052    end
     1053end
    10441054UvData.XmlData{index}=XmlData;
    10451055UvData.NewSeries=1;
     
    11941204%------------------------------------------------------------------------
    11951205%--- update the index display after action on edit boxes i1, i2, j1 or j2
     1206%------------------------------------------------------------------------
    11961207function update_ij(handles,index_rank)
     1208   
    11971209NomType=get(handles.NomType,'String');
    11981210indices=get(handles.FileIndex,'String');
     
    13101322        ListFiles=ListFiles(~check_dir);%list of file names (excluding dir)
    13111323        if ~isempty(ListFiles)
    1312             [tild,tild,MaskExt]=fileparts(ListFiles{1});
    1313             [tild,tild,MaskFile,i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{1},0);
    1314             if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series)
    1315                 mdetect=1;
    1316             end
    1317         end
     1324            for ifile=1:numel(ListFiles)
     1325                [tild,tild,MaskExt]=fileparts(ListFiles{1});
     1326                [tild,tild,MaskFile{ifile},i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{ifile},0);
     1327                if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series)
     1328                    mdetect=1;
     1329                end
     1330                if ~strcmp(MaskFile{ifile},MaskFile{1})
     1331                    mdetect=0;% cancel detection test in case of multiple masks, use the brower for selection
     1332                    break
     1333                end
     1334            end
     1335        end
     1336        RootPath=MaskPath;
    13181337    end
    13191338    if mdetect==0
     
    15361555set(handles.MovieBackward,'BusyAction','Cancel')
    15371556set(handles.MenuExportMovie,'BusyAction','Cancel')
    1538 set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red
     1557%set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red
    15391558set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
    15401559set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
     
    15561575InputFile.SubDir=regexprep(InputFile.SubDir,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string
    15571576FileExt=InputFile.FileExt;
    1558 NomType=get(handles.NomType,'String');
    1559 i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
    1560 i2=[];%default
    1561 if strcmp(get(handles.i2,'Visible'),'on')
    1562     i2=str2num(get(handles.i2,'String'));
    1563 end
    1564 j1=[];
    1565 if strcmp(get(handles.j1,'Visible'),'on')
    1566     j1=stra2num(get(handles.j1,'String'));
    1567 end
    1568 j2=j1;
    1569 if strcmp(get(handles.j2,'Visible'),'on')
    1570     j2=stra2num(get(handles.j2,'String'));
    1571 end
     1577NomType=InputFile.NomType;
     1578%NomType=get(handles.NomType,'String');
     1579% i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
     1580% i2=[];%default
     1581% if strcmp(get(handles.i2,'Visible'),'on')
     1582%     i2=str2num(get(handles.i2,'String'));
     1583% end
     1584% j1=[];
     1585% if strcmp(get(handles.j1,'Visible'),'on')
     1586%     j1=stra2num(get(handles.j1,'String'));
     1587% end
     1588% j2=j1;
     1589% if strcmp(get(handles.j2,'Visible'),'on')
     1590%     j2=stra2num(get(handles.j2,'String'));
     1591% end
     1592[tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used
     1593
    15721594sub_value= get(handles.SubField,'Value');
    15731595if sub_value % a second input file has been entered
     
    15841606CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2));
    15851607
    1586 %         i1_1=i1;
    1587 %         i2_1=i2;
    1588 %         j1_1=j1;
    1589 %         j2_1=j2;
    15901608% the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected)
    15911609if CheckFixPair && isnumeric(increment)
     
    15961614            i1_1=i1_1+increment;
    15971615            i2_1=i2_1+increment;
    1598         end       
     1616        end
    15991617    else % case of scanning along index j (burst numbers)
    16001618        j1=j1+increment;
     
    16061624    end
    16071625   
    1608 % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used
     1626    % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used
    16091627else
    16101628    UvData=get(handles.uvmat,'UserData');
     
    16771695    end
    16781696   
    1679     % case of a second file series 
     1697    % case of a second file series
    16801698    if sub_value
    16811699        ref_i_1=i1_1;
     
    16981716        else % free increment, synchronise the ref indices with the first series
    16991717            ref_i_1=ref_i;
    1700             ref_j_1=ref_j; 
     1718            ref_j_1=ref_j;
    17011719        end
    17021720        if numel(UvData.i1_series)==1
     
    17341752        if ~isempty(UvData.j2_series{2})
    17351753            j2_1=UvData.j2_series{1}(ref_indices(end));
    1736         end   
     1754        end
    17371755    else% the second series (if needed) is the same file as the first
    17381756        i1_1=i1;
     
    17431761end
    17441762filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2);
     1763
     1764%% refresh plots
    17451765if sub_value
    17461766    filename_1=fullfile_uvmat(InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileExt_1,InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1);
     1767    errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1);
     1768else
     1769    errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2);
    17471770end
    17481771
    17491772%% refresh plots
    1750 errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1);
     1773% errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1);
    17511774
    17521775%% update the index counters if the index move is successfull
     
    17731796        set(handles.movie_pair,'Value',1)
    17741797        movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
    1775     end
     1798    else
     1799        if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used
     1800        if isempty(j2), set(handles.j2,'String',''); end
     1801    end
     1802    set(handles.i1,'BackgroundColor',[1 1 1])
     1803    set(handles.i2,'BackgroundColor',[1 1 1])
     1804    set(handles.j1,'BackgroundColor',[1 1 1])
     1805    set(handles.j2,'BackgroundColor',[1 1 1])
     1806    set(handles.FileIndex,'BackgroundColor',[1 1 1])
     1807    set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
    17761808end
    17771809
     
    17861818    set(handles.i2,'String','')
    17871819    set(handles.j2,'String','')
     1820    set(handles.Dt_txt,'String','')
    17881821    return
    17891822else
     
    18611894end
    18621895
     1896%% display time interval for the image pair
     1897if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'Time')
     1898    dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1));
     1899    if  isfield(UvData,'TimeUnit')
     1900        set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  m' UvData.TimeUnit] )
     1901    else
     1902        set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  10^(-3)'] )
     1903    end
     1904else
     1905    set(handles.Dt_txt,'String','')
     1906end
     1907
    18631908%% get the first image
    18641909%Field.AName='image';
     
    18751920end
    18761921[Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},MovieObject,num_frame);
    1877 % Field_b.AX=Field_a.AX;
    1878 % Field_b.AY=Field_a.AY;
    1879 % % z index
    1880 % nbslice=str2double(get(handles.num_NbSlice,'String'));
    1881 % if ~isempty(nbslice)
    1882 %     Field_b.ZIndex=mod(num_i2-1,nbslice)+1;
    1883 % end
    1884 % Field_b.CoordUnit='pixel';
    1885 %
    1886 % %% determine the input file type
    1887 % if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1}))
    1888 %     FileType='movie';
    1889 % elseif isequal(lower(Ext),'.avi')
    1890 %     FileType='avi';
    1891 % elseif isequal(lower(Ext),'.vol')
    1892 %     FileType='vol';
    1893 % else
    1894 %    form=imformats(Ext(2:end));
    1895 %    if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    1896 %        if isequal(NomType,'*');
    1897 %            FileType='multimage';
    1898 %        else
    1899 %            FileType='image';
    1900 %        end
    1901 %    end
    1902 % end
    1903 % switch FileType
    1904 %         case 'movie'
    1905 %             if test_1
    1906 %                 Field_b.A=read(UvData.MovieObject{2},num_i2);
    1907 %             else
    1908 %                 Field_b.A=read(UvData.MovieObject{1},num_i2);
    1909 %             end
    1910 %         case 'avi'
    1911 %             mov=aviread(imaname_1,num_i2);
    1912 %             Field_b.A=frame2im(mov(1));
    1913 %         case 'vol'
    1914 %             Field_b.A=imread(imaname_1);
    1915 %         case 'multimage'
    1916 %             Field_b.A=imread(imaname_1,num_i2);
    1917 %         case 'image'
    1918 %             Field_b.A=imread(imaname_1);
    1919 % end
    1920 % if get(handles.slices,'Value')
    1921 %     Field.ZIndex=str2double(get(handles.z_index,'String'));
    1922 % end
    19231922
    19241923%px to phys or other transform on field
     
    19331932end
    19341933
    1935  % make movie until movie speed is set to 0 or STOP is activated
     1934% make movie until movie speed is set to 0 or STOP is activated
    19361935hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER)
    19371936set(handles.STOP,'Visible','on')
    19381937set(handles.speed,'Visible','on')
    19391938set(handles.speed_txt,'Visible','on')
     1939set(handles.i2,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input
     1940set(handles.j2,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input
     1941set(handles.FileIndex,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input
    19401942while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
    19411943    % read and plot the series of images in non erase mode
     
    19461948end
    19471949set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
    1948  set(handles.movie_pair,'Value',0)
     1950set(handles.movie_pair,'Value',0)
     1951set(handles.Dt_txt,'String','')
    19491952
    19501953%------------------------------------------------------------------------
     
    19551958drawnow
    19561959[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     1960[tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(FileIndex);% check back the indices used
     1961if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used
     1962if isempty(j2), set(handles.j2,'String',''); end
    19571963filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
    19581964filename_1='';%default
     
    19811987    set(handles.j2,'BackgroundColor',[1 1 1])
    19821988    set(handles.FileIndex,'BackgroundColor',[1 1 1])
    1983     set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
     1989    set(handles.FileIndex_1,'BackgroundColor',[1 1 1])   
    19841990end   
    19851991set(handles.run0,'BackgroundColor',[1 0 0])
     
    19911997%  errormsg: error message char string  =[] by default
    19921998% INPUT:
    1993 % filename: first input file (=[] in the absence of input file)
    1994 % filename_1: second input file (=[] in the asbsenc of secodn input file)
     1999% FileName: first input file (=[] in the absence of input file)
     2000% FileName_1: second input file (=[] in the asbsence of second input file)
    19952001% num_i1,num_i2,num_j1,num_j2; frame indices
    1996 % Field: structure describing an optional input field (then replace the input file)
    1997 
     2002% i1_1,i2_1,j1_1,j2_1: frame indices for the second input file  (needed if FileName_1 is not empty)
     2003%------------------------------------------------------------------------
    19982004function errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1)
    19992005%------------------------------------------------------------------------
     
    23202326% get time in the input file, not defined in a xml file or movie
    23212327if isempty(abstime)
    2322     if ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^dim:'))||~isempty(regexp(TimeName,'^var:'))
     2328    if strcmp(TimeName,'civdata')||strcmp(TimeName,'civx')
     2329        abstime=Field{1}.Time;
     2330    elseif ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^dim:'))||~isempty(regexp(TimeName,'^var:'))
    23232331        abstime=Field{1}.(TimeName(5:end));%the time is an attribute or variale selected by get_file
    23242332    end
     
    23622370   
    23632371    % get time in the input file of the second series, not defined in a xml file or movie
    2364     if isempty(abstime_1) && numel(Field)==2 &&...
    2365             ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:'))
     2372    if isempty(abstime_1) && numel(Field)==2
     2373         if strcmp(TimeName_1,'civdata')||strcmp(TimeName_1,'civx')
     2374        abstime_1=Field{2}.Time;
     2375         elseif  ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:'))
    23662376        abstime_1=Field{2}.(TimeName_1(5:end));%the time is an attribute or variale selected by get_file
     2377         end
    23672378    end
    23682379    set(handles.TimeValue_1,'String',num2str(abstime_1,5))
     
    28062817
    28072818if ~get(handles.CheckFixLimits,'Value')
    2808     update_plot(handles);
     2819    update_plot(handles)
     2820    set(handles.CheckZoom,'Value',0)
    28092821end
    28102822
     
    30693081                YName={GetFieldData.Coordinates.Coord_y};
    30703082                CName=GetFieldData.PanelVectors.vec_color;
    3071                 [FieldList,VecColorList]=set_field_list(UName,VName,CName);
     3083                FieldList={['vec(' UName ',' VName ')'];...
     3084                    ['norm(' UName ',' VName ')'];...
     3085                    UName;VName};
     3086                VecColorList={['norm(' UName ',' VName ')'];...
     3087                    UName;VName};
     3088                if ~isempty(CName)
     3089                    VecColorList=[{CName};VecColorList];
     3090                end
    30723091            case 'scalar'
    30733092                AName=GetFieldData.PanelScalar.scalar;
Note: See TracChangeset for help on using the changeset viewer.