Changeset 764 for trunk/src/uvmat.m
- Timestamp:
- May 2, 2014, 2:03:44 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uvmat.m
r760 r764 610 610 %------------------------------------------------------------------------ 611 611 [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); 612 set(handles.i1,'String',num2str(i1)); 612 set(handles.i1,'String',num2str(i1));%update the counters 613 613 set(handles.i2,'String',num2str(i2)); 614 614 set(handles.j1,'String',num2str(j1)); … … 626 626 FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2); 627 627 set(handles.FileIndex,'String',FileIndex) 628 % inputfilerefresh the current settings and inputfilerefresh the field view628 % refresh the current settings and refresh the field view 629 629 RootPath_Callback(hObject,eventdata,handles) 630 630 … … 1260 1260 case 1 1261 1261 indices=fullfile_uvmat('','','','',NomType,stra2num(get(handles.i1,'String')),i2,j1,j2); 1262 set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation1262 % set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation 1263 1263 case 2 1264 1264 indices=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.i2,'String')),j1,j2); 1265 set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation1265 % set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation 1266 1266 case 3 1267 1267 indices=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.j1,'String')),j2); 1268 set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation1268 % set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation 1269 1269 case 4 1270 1270 indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.j2,'String'))); 1271 set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation1271 % set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation 1272 1272 end 1273 1273 set(handles.FileIndex,'String',indices) 1274 set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation1274 %set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation 1275 1275 % update the second index if relevant 1276 1276 if strcmp(get(handles.FileIndex_1,'Visible'),'on') … … 1518 1518 msgbox_uvmat('ERROR',errormsg); 1519 1519 end 1520 set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red1521 1520 1522 1521 %------------------------------------------------------------------------ … … 1537 1536 msgbox_uvmat('ERROR',errormsg); 1538 1537 end 1539 set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red1540 1538 1541 1539 %------------------------------------------------------------------------ … … 1619 1617 %% check for movie pair status 1620 1618 movie_status=get(handles.movie_pair,'Value'); 1621 if isequal(movie_status,1)1619 if movie_status 1622 1620 STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active 1623 1621 end … … 1635 1633 j1=str2num(get(handles.j1,'String'));%case of indexed movie 1636 1634 end 1635 if movie_status% we read the second index from the edit box 1636 i2=str2num(get(handles.i2,'String'));%read the field indices (for movie, it is not given by the file name) 1637 if strcmp(get(handles.j2,'Visible'),'on') 1638 j2=str2num(get(handles.j2,'String'));% 1639 end 1640 end 1637 1641 sub_value= get(handles.SubField,'Value'); 1638 1642 if sub_value % a second input file has been entered … … 1672 1676 end 1673 1677 1674 1678 % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used 1675 1679 else 1676 1680 UvData=get(handles.uvmat,'UserData'); … … 1818 1822 end 1819 1823 set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0]) 1824 set(handles.runplus,'BackgroundColor',[1 0 0]) 1825 set(handles.runmin,'BackgroundColor',[1 0 0]) 1820 1826 1821 1827 %% update the index counters if the index move is successfull 1828 1822 1829 if isempty(errormsg) 1823 1830 set(handles.i1,'String',num2stra(i1,NomType,1)); … … 1846 1853 if isempty(j2), set(handles.j2,'String',''); end 1847 1854 end 1848 set(handles.i1,'BackgroundColor',[1 1 1])1849 set(handles.i2,'BackgroundColor',[1 1 1])1850 set(handles.j1,'BackgroundColor',[1 1 1])1851 set(handles.j2,'BackgroundColor',[1 1 1])1852 set(handles.FileIndex,'BackgroundColor',[1 1 1])1853 set(handles.FileIndex_1,'BackgroundColor',[1 1 1])1854 1855 end 1855 1856 … … 1862 1863 if ~get(handles.movie_pair,'value') 1863 1864 set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off' 1864 set(handles.i2,'String','') 1865 set(handles.j2,'String','') 1866 set(handles.Dt_txt,'String','') 1865 set(handles.i2,'String','')% the second i index display is suppressed 1866 set(handles.j2,'String','')% the second j index display is suppressed 1867 set(handles.Dt_txt,'String','')% the time interval indication is suppressed 1867 1868 return 1868 else 1869 set(handles.movie_pair,'BusyAction','queue') 1870 set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0]) 1871 end 1872 1873 %% initialisation 1874 set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow 1869 end 1870 1871 %% check the input file indexing: 1872 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); 1873 NomType=get(handles.NomType,'String'); 1874 if ~isempty(find(regexp(NomType,'-'))) 1875 msgbox_uvmat('ERROR','The movie pair requires file series with a single index on the first input line') 1876 return 1877 end 1878 filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line) 1879 1880 set(handles.movie_pair,'BusyAction','queue')% 1881 set(handles.CheckFixPair,'Value',1)% impose fixed pair (needed for function runpm) 1882 set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity 1883 set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity 1875 1884 drawnow 1876 list_fields=get(handles.FieldName,'String');% list menu fields1877 index_fields=get(handles.FieldName,'Value');% selected string index1878 FieldName=list_fields{index_fields}; % selected field1879 UvData=get(handles.uvmat,'UserData'); 1880 if isequal(FieldName,'image') 1881 index=1; 1882 [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles);1883 NomType=get(handles.NomType,'String'); 1884 else1885 list_fields=get(handles.FieldName_1,'String');% list menu fields1886 index_fields=get(handles.FieldName_1,'Value');% selected string index1887 FieldName=list_fields{index_fields}; % selected field1888 if isequal(FieldName,'image')1889 index=2;1890 [RootPath,SubDir,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles);% get info from the second input line1891 else1892 msgbox_uvmat('ERROR','an image or movie must be first introduced as input')1893 set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red1894 set(handles.movie_pair,'Value',0)1895 return1896 end1897 end1885 % list_fields=get(handles.FieldName,'String');% list menu fields 1886 % index_fields=get(handles.FieldName,'Value');% selected string index 1887 % FieldName=list_fields{index_fields}; % selected field 1888 1889 1890 % if isequal(FieldName,'image') 1891 % index=1; 1892 1893 % else 1894 % list_fields=get(handles.FieldName_1,'String');% list menu fields 1895 % index_fields=get(handles.FieldName_1,'Value');% selected string index 1896 % FieldName=list_fields{index_fields}; % selected field 1897 % if isequal(FieldName,'image') 1898 % index=2; 1899 % [RootPath,SubDir,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles);% get info from the second input line 1900 % else 1901 % msgbox_uvmat('ERROR','an image or movie must be first introduced as input') 1902 % set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red 1903 % set(handles.movie_pair,'Value',0) 1904 % return 1905 % end 1906 % end 1898 1907 num_i1=str2num(get(handles.i1,'String')); 1899 1908 num_j1=stra2num(get(handles.j1,'String')); 1900 1909 num_i2=str2num(get(handles.i2,'String')); 1901 1910 num_j2=stra2num(get(handles.j2,'String')); 1911 1912 %% determine the name 'imaname_1' of the second file in the pair 1902 1913 imaname_1=''; 1903 if isempty(num_j2) 1914 if isempty(num_j2)% no second j index indicated 1904 1915 if isempty(num_i2) 1905 1916 if strcmp(get(handles.j2,'Visible'),'on') %if the j box is visible 1906 imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile, Ext,NomType,num_i1,[],num_j1+1);1917 imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1,[],num_j1+1); 1907 1918 end 1908 1919 if exist(imaname_1,'file') … … 1910 1921 set(handles.j2,'String',num2stra(num_j2,NomType)); 1911 1922 else 1912 imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile, Ext,NomType,num_i1+1,[],num_j1);1923 imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1+1,[],num_j1); 1913 1924 if exist(imaname_1,'file') 1914 1925 num_i2=num_i1+1; … … 1934 1945 num_j2=num_j1;%repeat the index i1 by default 1935 1946 end 1936 imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile, Ext,NomType,num_i2,[],num_j2);1947 imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i2,[],num_j2); 1937 1948 if strcmp(NomType,'*') 1938 1949 num_frame=num_i2; … … 1946 1957 return 1947 1958 end 1959 1960 %% display the first field in the pair (including possibly a background field from second line input filename_1) 1961 filename_1='';%default 1962 FileIndex_1=''; 1963 if get(handles.SubField,'Value') 1964 [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); 1965 filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; 1966 end 1967 % num_i1=stra2num(get(handles.i1,'String')); 1968 % num_i2=stra2num(get(handles.i2,'String')); 1969 % num_j1=stra2num(get(handles.j1,'String')); 1970 % num_j2=stra2num(get(handles.j2,'String')); 1971 [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);% get the indices of the second series from the string FileIndex_1 1972 if isempty(j1_1)% case of movies, the index is not given by file index 1973 j1_1=num_j1; 1974 end 1975 1976 errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); 1977 1978 if isempty(errormsg) 1979 set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull 1980 else 1981 msgbox_uvmat('ERROR',errormsg); 1982 set(handles.REFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull 1983 end 1984 UvData=get(handles.uvmat,'UserData'); 1985 Field_a=UvData.Field;% movie on the field defined by the second input line 1948 1986 1949 1987 %% display time interval for the image pair … … 1960 1998 end 1961 1999 1962 %% get the first image 1963 %Field.AName='image'; 1964 if index==1 1965 Field_a=UvData.Field;% movie on the second field 1966 else 1967 Field_a=UvData.Field_1;% movie on the first field 1968 end 1969 1970 %% read the second image 1971 MovieObject=[]; 1972 if numel(UvData.MovieObject)>=index 1973 MovieObject=UvData.MovieObject{index}; 1974 end 1975 [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},MovieObject,num_frame); 1976 1977 %px to phys or other transform on field 2000 %% read the second field 2001 if isempty(UvData.MovieObject) 2002 [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},[],num_frame); 2003 else 2004 [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{1},UvData.MovieObject{1},num_frame); 2005 end 2006 if ~isempty(errormsg) 2007 msgbox_uvmat('ERROR',['Error in reading second image: ' errormsg]) 2008 return 2009 end 2010 2011 %% apply phys or other transform on the two input fields 1978 2012 transform=get(handles.TransformPath,'UserData'); 1979 2013 if ~isempty(transform) 1980 if isfield(UvData,'XmlData') && numel(UvData.XmlData)>=index %use geometry calib recorded from the ImaDoc xml file as first priority 1981 if index==2 1982 Field_a=transform(Field_a,UvData.XmlData{index});%the first field has been stored without transform 1983 end 2014 if isfield(UvData,'XmlData') && ~isempty(UvData.XmlData) %use geometry calib recorded from the ImaDoc xml file as first priority 1984 2015 if nargin(transform)>=2 1985 Field_b=transform(Field_b,UvData.XmlData{index});2016 Field_b=transform(Field_b,UvData.XmlData{1}); 1986 2017 else 1987 Field_b=transform(Field_b);1988 end 1989 end 1990 end 1991 1992 % make movie until movie speed is set to 0 or STOP is activated2018 Field_b=transform(Field_b); 2019 end 2020 end 2021 end 2022 2023 %% make movie until movie speed is set to 0 or STOP is activated 1993 2024 hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER) 1994 2025 set(handles.STOP,'Visible','on') 1995 2026 set(handles.speed,'Visible','on') 1996 2027 set(handles.speed_txt,'Visible','on') 1997 set(handles.i2,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input1998 set(handles.j2,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input1999 set(handles.FileIndex,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input2000 2028 while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue') % enable STOP command 2001 2029 % read and plot the series of images in non erase mode 2002 set(hima,'CData',Field_b.A); 2030 set(hima,'CData',Field_b.A); %TODO: generalise to other kinds of fields 2003 2031 pause(1.02-get(handles.speed,'Value'));% wait for next image 2004 2032 set(hima,'CData',Field_a.A); … … 2013 2041 function REFRESH_Callback(hObject, eventdata, handles) 2014 2042 %------------------------------------------------------------------------ 2015 set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the command button in yellow2043 set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the REFRESH button in yellow to indicate its activity 2016 2044 drawnow 2017 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); 2045 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);%read the features of the input file name (first line) 2018 2046 [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(FileIndex);% check back the indices used 2019 if isempty(i2), set(handles.i2,'String',''); end % suppress the second i ndex display if not used2020 if isempty(j2), set(handles.j2,'String',''); end 2021 filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; 2022 filename_1='';%default 2047 if isempty(i2), set(handles.i2,'String',''); end % suppress the second i index display if not used 2048 if isempty(j2), set(handles.j2,'String',''); end % suppress the second j index display if not used 2049 filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line) 2050 filename_1='';%default second file name 2023 2051 FileIndex_1=''; 2024 if get(handles.SubField,'Value') 2025 [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); 2026 filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; 2052 if get(handles.SubField,'Value')% if a second file is introduced 2053 [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);%read the features of the input file name (second line) 2054 filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; %build the input file name (second line) 2027 2055 end 2028 2056 num_i1=stra2num(get(handles.i1,'String')); … … 2034 2062 j1_1=num_j1; 2035 2063 end 2036 2064 % in case of movies the index is set by edit boxes i1 or j1 (case of movies indexed by index i) 2037 2065 errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); 2038 2066 2039 if ~isempty(errormsg) 2040 msgbox_uvmat('ERROR',errormsg); 2041 set(handles.InputFileREFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull 2042 else 2043 set(handles.i1,'BackgroundColor',[1 1 1]) 2044 set(handles.i2,'BackgroundColor',[1 1 1]) 2045 set(handles.j1,'BackgroundColor',[1 1 1]) 2046 set(handles.j2,'BackgroundColor',[1 1 1]) 2047 set(handles.FileIndex,'BackgroundColor',[1 1 1]) 2048 set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) 2067 if isempty(errormsg) 2049 2068 set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull 2050 end 2069 else 2070 msgbox_uvmat('ERROR',errormsg); 2071 set(handles.REFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull 2072 end 2051 2073 2052 2074 %------------------------------------------------------------------------ … … 3554 3576 msgbox_uvmat('ERROR',errormsg); 3555 3577 else 3556 set(handles.i1,'BackgroundColor',[1 1 1])3557 set(handles.i2,'BackgroundColor',[1 1 1])3558 set(handles.j1,'BackgroundColor',[1 1 1])3559 set(handles.j2,'BackgroundColor',[1 1 1])3560 set(handles.FileIndex,'BackgroundColor',[1 1 1])3561 set(handles.FileIndex_1,'BackgroundColor',[1 1 1])3578 % set(handles.i1,'BackgroundColor',[1 1 1]) 3579 % set(handles.i2,'BackgroundColor',[1 1 1]) 3580 % set(handles.j1,'BackgroundColor',[1 1 1]) 3581 % set(handles.j2,'BackgroundColor',[1 1 1]) 3582 % set(handles.FileIndex,'BackgroundColor',[1 1 1]) 3583 % set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) 3562 3584 end 3563 3585 set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0]) … … 4235 4257 [tild,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam); 4236 4258 errormsg=fill_GUI(PlotParamOut,handles.uvmat); 4237 if ~isempty(errormsg) 4259 if isempty(errormsg) 4260 set(handles.REFRESH,'BackgroundColor',[1 0 0]);% operation finished, back to red color 4261 else 4238 4262 msgbox_uvmat('ERROR',errormsg) 4239 return4240 end 4241 set(handles.REFRESH,'BackgroundColor',[1 0 0]); 4263 set(handles.REFRESH,'BackgroundColor',[1 0 1]);% magenta color: graph still needs to be updated 4264 end 4265 4242 4266 4243 4267 %------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.