Changeset 1155 for trunk/src/series/civ_input.m
- Timestamp:
- Jul 8, 2024, 9:45:18 AM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/civ_input.m
r1154 r1155 110 110 ind_opening=SeriesData.FileInfo{1}.CivStage; 111 111 if isempty(regexp(NomTypeInput,'[ab|AB|-]', 'once')) 112 set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomenc alture does not involve index pairs112 set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomenclature does not involve index pairs 113 113 else 114 114 set(handles.ListCompareMode,'Value',1) 115 115 end 116 [Data, tild,tild,errormsg]=nc2struct(SeriesData.FileInfo{1}.FileName,[]);116 [Data,~,~,errormsg]=nc2struct(SeriesData.FileInfo{1}.FileName,[]); 117 117 if ~isempty(errormsg) 118 118 msgbox_uvmat('ERROR',['error in netcdf input file: ' errormsg]) … … 120 120 end 121 121 if isfield(Data,'.Civ1_ImageA') 122 [PathCiv1_ImageA,Civ1_ImageA,FileExtA]=fileparts(Data.Civ1_ImageA);%look for the source image A123 [PathCiv1_ImageB,Civ1_ImageB,FileExtA]=fileparts(Data.Civ1_ImageB);%look for the source image B122 %[PathCiv1_ImageA,Civ1_ImageA,FileExtA]=fileparts(Data.Civ1_ImageA);%look for the source image A 123 %[PathCiv1_ImageB,Civ1_ImageB,FileExtA]=fileparts(Data.Civ1_ImageB);%look for the source image B 124 124 end 125 125 if isfield(Data,'Civ2_ImageA') 126 [PathCiv2_ImageA,Civ2_ImageA,FileExtA]=fileparts(Data.Civ2_ImageA);127 [PathCiv2_ImageB,Civ2_ImageB,FileExtA]=fileparts(Data.Civ2_ImageB);126 %[PathCiv2_ImageA,Civ2_ImageA,FileExtA]=fileparts(Data.Civ2_ImageA); 127 %[PathCiv2_ImageB,Civ2_ImageB,FileExtA]=fileparts(Data.Civ2_ImageB); 128 128 end 129 129 if size(Param.InputTable,1)==1 130 130 if isfield(Data,'.Civ1_ImageA') 131 131 series('display_file_name',hhseries,Data.Civ1_ImageA,'append');%append the image series to the input list 132 [ RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaA]=fileparts_uvmat(Data.Civ1_ImageA);133 [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaB]=fileparts_uvmat(Data.Civ1_ImageB);132 [~,~,~,~,~,~,~,~,NomTypeImaA]=fileparts_uvmat(Data.Civ1_ImageA); 133 % [~,~,~,~,~,~,~,~,NomTypeImaB]=fileparts_uvmat(Data.Civ1_ImageB); 134 134 else 135 135 series('display_file_name',hhseries,Data.Civ2_ImageA,'append');%append the image series to the input list 136 [ RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaA]=fileparts_uvmat(Data.Civ2_ImageA);137 [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaB]=fileparts_uvmat(Data.Civ2_ImageB);136 [~,~,~,~,~,~,~,~,NomTypeImaA]=fileparts_uvmat(Data.Civ2_ImageA); 137 %[RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaB]=fileparts_uvmat(Data.Civ2_ImageB); 138 138 end 139 139 end … … 1629 1629 % -------------------------------------------------------------------- 1630 1630 function TestPatch1_Callback(hObject, eventdata, handles) 1631 msgbox_uvmat('WARNING','open the civ file and run "series/test_patch_tps" ') 1632 1633 % if get(handles.TestPatch1,'Value')% if TestPatch1 is activated 1634 % hseries=findobj(allchild(0),'Tag','series'); 1635 % Param=read_GUI(hseries); 1636 % CivDir=fullfile(Param.OutputPath,Param.Experiment,Param.Device,[Param.OutputSubDir Param.OutputDirExt]); 1637 % % ListXml=dir(CivXmlDir); 1638 % if exist(CivDir,'dir') 1639 % CivFile=uigetfile_uvmat('pick .nc file with civ1-fix1 data',CivDir,'.nc'); 1640 % [Field,VelTypeOut,errormsg]=read_civdata(CivFile) 1641 % for ilist=1:numel(Field.ListGlobalAttribute) 1642 % r=regexp(Field.ListGlobalAttribute{ilist},'Civ1_(?<field>.+)','names');% \D = not a digit, \d =digi 1643 % if ~isempty(r) 1644 % ParamTest.Civ1.(r.field)=(Field.(['Civ1_' r.field])); 1645 % end 1646 % r=regexp(Field.ListGlobalAttribute{ilist},'Fix1_(?<field>.+)','names');% \D = not a digit, \d =digi 1647 % if ~isempty(r) 1648 % ParamTest.Fix1.(r.field)=(Field.(['Fix1_' r.field])); 1649 % end 1650 % end 1651 % fill_GUI(ParamTest,handles.civ_input)% fill the elements of the GUI series with the input parameters 1652 % drawnow 1653 % update_CivOptions(handles,0) 1654 % 1655 % set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to indicate activation 1656 % % set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is performed 1657 % Param.Action.RUN=1; 1658 % Param.ActionInput=read_GUI(handles.civ_input); 1659 % Param.ActionInput.CheckCiv1=0;% do not repeat Civ1 computation 1660 % if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1 1661 % Param.ActionInput=rmfield(Param.ActionInput,'Civ2'); 1662 % end 1663 % if isfield(Param.ActionInput,'Fix2') 1664 % Param.ActionInput=rmfield(Param.ActionInput,'Fix2'); 1665 % end 1666 % if isfield(Param.ActionInput,'Patch2') 1667 % Param.ActionInput=rmfield(Param.ActionInput,'Patch2'); 1668 % end 1669 % if isfield(Param,'OutputSubDir') 1670 % Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series 1671 % end 1672 % ParamPatch1=Param.ActionInput.Patch1; %store the patch1 parameters 1673 % Param.ActionInput=rmfield(Param.ActionInput,'Patch1');% does not execute Patch 1674 % Param.IndexRange.first_i=str2num(get(handles.ref_i,'String')); 1675 % Param.IndexRange.last_i=Param.IndexRange.first_i; 1676 % if strcmp(get(handles.ref_j,'Visible'),'on') 1677 % Param.IndexRange.first_j=str2num(get(handles.ref_j,'String')); 1678 % Param.IndexRange.last_j=Param.IndexRange.first_j; 1679 % else 1680 % Param.IndexRange.first_j=1; 1681 % Param.IndexRange.last_j=1; 1682 % end 1683 % [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results 1684 % bckcolor=get(handles.civ_input,'Color'); 1685 % set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished 1686 % 1687 % %% prepare Param for iterative Patch processing without input file reading 1688 % Param.Civ1_X=Data.Civ1_X; 1689 % Param.Civ1_Y=Data.Civ1_Y; 1690 % Param.Civ1_U=Data.Civ1_U; 1691 % Param.Civ1_V=Data.Civ1_V; 1692 % Param.Civ1_FF=Data.Civ1_FF; 1693 % Param=rmfield(Param,'InputTable');%desactivate input file reading 1694 % if isfield(Param.ActionInput,'Civ1') 1695 % Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant 1696 % end 1697 % if isfield(Param.ActionInput,'Fix1') 1698 % Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant 1699 % end 1700 % SmoothingParam=(ParamPatch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value 1701 % NbGood=numel(find(Data.Civ1_FF==0)); 1702 % NbExclude=zeros(1,7);% initialize the set of smoothing parameters 1703 % DiffVel=zeros(1,7);% initialize the rms difference between patch and civ 1704 % Param.ActionInput.Patch1=ParamPatch1;% retrieve Patch1 parameters 1705 % for irho=1:7 1706 % Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho); 1707 % [Data,errormsg]= civ_series(Param);%apply the processing fct 1708 % if ~isempty(errormsg) 1709 % msgbox_uvmat('ERROR',errormsg) 1710 % return 1711 % end 1712 % ind_good=find(Data.Civ1_FF==0); 1713 % Civ1_U_Diff=Data.Civ1_U(ind_good)-Data.Civ1_U_smooth(ind_good); 1714 % Civ1_V_Diff=Data.Civ1_V(ind_good)-Data.Civ1_V_smooth(ind_good); 1715 % DiffVel(irho)=sqrt(mean(Civ1_U_Diff.*Civ1_U_Diff+Civ1_V_Diff.*Civ1_V_Diff)); 1716 % NbExclude(irho)=(NbGood-numel(ind_good))/NbGood; 1717 % end 1718 % figure(1) 1719 % semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r',SmoothingParam,0.2*ones(size(SmoothingParam)),'m') 1720 % grid on 1721 % legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)','recommended diff Patch1-Civ1') 1722 % xlabel('smoothing parameter') 1723 % ylabel('smoothing effect') 1724 % set(handles.TestPatch1,'BackgroundColor',[0 1 0]) 1725 % else 1726 % corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display 1727 % if ~isempty(corrfig) 1728 % delete(corrfig) 1729 % end 1730 % hview_field=findobj(allchild(0),'tag','view_field');% look for view_field 1731 % if ~isempty(hview_field) 1732 % delete(hview_field) 1733 % end 1734 % end 1735 % else 1736 % msgbox_uvmat('ERROR','no output file: first perform a civ1-fix1 computation') 1737 % return 1738 % end 1739 1740 %------------------------------------------------------------------------ 1741 % --- Executes on button press in TestCiv2. 1742 %------------------------------------------------------------------------ 1743 function TestCiv2_Callback(hObject, eventdata, handles) 1744 drawnow 1745 if get(handles.TestCiv2,'Value') 1746 set(handles.TestCiv2,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch 1747 set(handles.CheckFix2,'value',0)% desactivate next step 1748 set(handles.CheckPatch2,'value',0)% desactivate next step 1749 update_CivOptions(handles,0) 1750 hseries=findobj(allchild(0),'Tag','series'); 1751 Param=read_GUI(hseries); 1752 Param.Action.RUN=1; 1753 Param.ActionInput=read_GUI(handles.civ_input); 1754 if isfield(Param,'OutputSubDir') 1755 Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series 1756 end 1757 Param.ActionInput.Civ2.CorrSmooth=0;% launch Civ2 with no data point (to get the image names for A and B) 1758 set(handles.Civ1,'BackgroundColor',[1 1 0]) 1759 set(handles.Fix1,'BackgroundColor',[1 1 0]) 1760 set(handles.Patch1,'BackgroundColor',[1 1 0]) 1761 Param.IndexRange.first_i=str2num(get(handles.ref_i,'String')); 1762 Param.IndexRange.last_i=Param.IndexRange.first_i; 1763 if strcmp(get(handles.ref_j,'Visible'),'on') 1764 Param.IndexRange.first_j=str2num(get(handles.ref_j,'String')); 1765 Param.IndexRange.last_j=Param.IndexRange.first_j; 1766 else 1767 Param.IndexRange.first_j=1; 1768 Param.IndexRange.last_j=1; 1769 end 1770 [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results 1771 1772 %% create image data ImageData for display 1773 ImageData.ListVarName={'ny','nx','A'}; 1774 ImageData.VarDimName= {'ny','nx',{'ny','nx'}}; 1775 ImageData.A=imread(Data.Civ2_ImageA); % read the first image 1776 if ndims(ImageData.A)==3 %case of color image 1777 ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; 1778 end 1779 ImageData.ny=[size(ImageData.A,1) 1]; 1780 ImageData.nx=[1 size(ImageData.A,2)]; 1781 ImageData.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly 1782 1783 %% create the figure view_field for image visualization 1784 hview_field=view_field(ImageData); %view the image in the GUI view_field 1785 set(0,'CurrentFigure',hview_field) 1786 % plot the boundaries of the subdomains used for patch 1787 for isub=1:size(Data.Civ1_SubRange,3); 1788 pos_x=Data.Civ1_SubRange(1,1,isub); 1789 pos_y=Data.Civ1_SubRange(2,1,isub); 1790 width=Data.Civ1_SubRange(1,2,isub)-Data.Civ1_SubRange(1,1,isub); 1791 height=Data.Civ1_SubRange(2,2,isub)-Data.Civ1_SubRange(2,1,isub); 1792 rectangle('Position',[pos_x pos_y width height],'EdgeColor',[0 0 1]) 1793 end 1794 hhview_field=guihandles(hview_field);% 1795 set(hview_field,'CurrentAxes',hhview_field.PlotAxes) 1796 ViewData=get(hview_field,'UserData'); % get the currently plotted field (the image A) 1797 % store info in the UserData of view-field 1798 ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field 1799 ViewData.PlotAxes.B=imread(Data.Civ2_ImageB);%store the second image in the UserData of the GUI view_field 1800 ViewData.PlotAxes.X=Data.Civ2_X'; 1801 ViewData.PlotAxes.Y=Data.Civ2_Y'; 1802 ViewData.PlotAxes.ShiftX=Data.Civ2_U';% shift at each point (from patch1) estimated by the preliminary run of civ2 1803 ViewData.PlotAxes.ShiftY=Data.Civ2_V'; 1804 ViewData.PlotAxes.Civ1_SubRange=Data.Civ1_SubRange; 1805 ViewData.PlotAxes.Civ1_NbCentres=Data.Civ1_NbCentres; 1806 ViewData.PlotAxes.Civ1_Coord_tps=Data.Civ1_Coord_tps; 1807 ViewData.PlotAxes.Civ1_U_tps=Data.Civ1_U_tps; 1808 ViewData.PlotAxes.Civ1_V_tps=Data.Civ1_V_tps; 1809 ViewData.PlotAxes.Civ1_Dt=Data.Civ1_Dt; 1810 ViewData.PlotAxes.Civ2_Dt=Data.Civ2_Dt; 1811 set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field 1812 bckcolor=get(handles.civ_input,'Color'); 1813 set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calmculation is finished 1814 set(handles.Fix1,'BackgroundColor',bckcolor) 1815 set(handles.Patch1,'BackgroundColor',bckcolor) 1816 drawnow 1817 1818 %% look for a current figure for image correlation display 1819 corrfig=findobj(allchild(0),'tag','corrfig'); 1820 if isempty(corrfig) 1821 corrfig=figure; 1822 set(corrfig,'tag','corrfig') 1823 set(corrfig,'name','image correlation') 1824 set(corrfig,'DeleteFcn',{@closeview_field})% 1825 set(handles.TestCiv1,'BackgroundColor',[1 0 0]) 1826 else 1827 set(handles.TestCiv1,'BackgroundColor',[1 0 0])% paint button to red 1828 corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display 1829 if ~isempty(corrfig) 1830 delete(corrfig) 1831 end 1832 hview_field=findobj(allchild(0),'tag','view_field');% look for view_field 1833 if ~isempty(hview_field) 1834 delete(hview_field) 1835 end 1836 end 1837 else 1838 hview_field=findobj(allchild(0),'Tag','view_field'); %view the image in the GUI view_field 1839 if ~isempty(hview_field) 1840 delete(hview_field) 1841 end 1842 end 1843 1844 1845 % --- Executes on button press in TestPatch2. 1846 function TestPatch2_Callback(hObject, eventdata, handles) 1847 if get(handles.TestPatch2,'Value')% if TestPatch2 is activated 1848 msgbox_uvmat('WARNING','open the civ file and run "series/test_patch_tps" ') 1849 end 1850 % set(handles.TestPatch2,'BackgroundColor',[1 1 0])%paint TestPatch2 button in yellow to indicate activation 1851 % set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is activated 1852 % set(handles.Fix1,'BackgroundColor',[1 1 0])% indicate fix1 calculation is activated 1853 % set(handles.Patch1,'BackgroundColor',[1 1 0])% indicate Patch1 calculation is activated 1854 % set(handles.Civ2,'BackgroundColor',[1 1 0])% indicate civ2 calculation is activated 1855 % set(handles.Fix2,'BackgroundColor',[1 1 0])% indicate fix2 calculation is activated 1856 % hseries=findobj(allchild(0),'Tag','series'); 1857 % Param=read_GUI(hseries); 1858 % Param.Action.RUN=1; 1859 % Param.ActionInput=read_GUI(handles.civ_input); 1860 % if isfield(Param,'OutputSubDir') 1861 % Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series 1862 % end 1863 % ParamPatch2=Param.ActionInput.Patch2; %store the patch1 parameters 1864 % Param.ActionInput=rmfield(Param.ActionInput,'Patch2');% does not execute Patch 1865 % Param.IndexRange.first_i=str2num(get(handles.ref_i,'String')); 1866 % Param.IndexRange.last_i=Param.IndexRange.first_i; 1867 % if strcmp(get(handles.ref_j,'Visible'),'on') 1868 % Param.IndexRange.first_j=str2num(get(handles.ref_j,'String')); 1869 % Param.IndexRange.last_j=Param.IndexRange.first_j; 1870 % else 1871 % Param.IndexRange.first_j=1; 1872 % Param.IndexRange.last_j=1; 1873 % end 1874 % [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results 1875 % bckcolor=get(handles.civ_input,'Color'); 1876 % set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished 1877 % set(handles.Fix1,'BackgroundColor',bckcolor)% indicate fix1 calculation is finished 1878 % set(handles.Patch1,'BackgroundColor',bckcolor)% indicate Patch1 calculation is finished 1879 % set(handles.Civ2,'BackgroundColor',bckcolor)% indicate civ2 calculation is finished 1880 % set(handles.Fix2,'BackgroundColor',bckcolor)% indicate fix2 calculation is finished 1881 % 1882 % %% prepare Param for iterative Patch processing without input file reading 1883 % Param.Civ2_X=Data.Civ2_X; 1884 % Param.Civ2_Y=Data.Civ2_Y; 1885 % Param.Civ2_U=Data.Civ2_U; 1886 % Param.Civ2_V=Data.Civ2_V; 1887 % Param.Civ2_FF=Data.Civ2_FF; 1888 % Param=rmfield(Param,'InputTable');%desactivate input file reading 1889 % if isfield(Param.ActionInput,'Civ1') 1890 % Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant 1891 % end 1892 % if isfield(Param.ActionInput,'Fix1') 1893 % Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant 1894 % end 1895 % if isfield(Param.ActionInput,'Patch1') 1896 % Param.ActionInput=rmfield(Param.ActionInput,'Patch1');%desactivate fix1:remove fix1 input param if relevant 1897 % end 1898 % if isfield(Param.ActionInput,'Civ2') 1899 % Param.ActionInput=rmfield(Param.ActionInput,'Civ2');%desactivate civ2: remove civ2 input param if relevant 1900 % end 1901 % if isfield(Param.ActionInput,'Fix2') 1902 % Param.ActionInput=rmfield(Param.ActionInput,'Fix2');%desactivate fix1:remove fix1 input param if relevant 1903 % end 1904 % SmoothingParam=(ParamPatch2.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value 1905 % NbGood=numel(find(Data.Civ2_FF==0)); 1906 % NbExclude=zeros(1,7);% initialize the set of smoothing parameters 1907 % DiffVel=zeros(1,7);% initialize the rms difference between patch and civ 1908 % Param.ActionInput.Patch2=ParamPatch2;% retrieve Patch2 parameters 1909 % for irho=1:7 1910 % Param.ActionInput.Patch2.FieldSmooth=SmoothingParam(irho); 1911 % [Data,errormsg]= civ_series(Param);%apply the processing fct 1912 % if ~isempty(errormsg) 1913 % msgbox_uvmat('ERROR',errormsg) 1914 % return 1915 % end 1916 % ind_good=find(Data.Civ2_FF==0); 1917 % Civ2_U_Diff=Data.Civ2_U(ind_good)-Data.Civ2_U_smooth(ind_good); 1918 % Civ2_V_Diff=Data.Civ2_V(ind_good)-Data.Civ2_V_smooth(ind_good); 1919 % DiffVel(irho)=sqrt(mean(Civ2_U_Diff.*Civ2_U_Diff+Civ2_V_Diff.*Civ2_V_Diff)); 1920 % NbExclude(irho)=(NbGood-numel(ind_good))/NbGood; 1921 % end 1922 % figure(1) 1923 % semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r',SmoothingParam,0.1*ones(size(SmoothingParam)),'m') 1924 % grid on 1925 % legend('rms velocity diff. Patch2-Civ2 (pixels)','proportion of excluded vectors (between 0 to 1)','recommended value diff. Patch2-Civ2') 1926 % xlabel('smoothing parameter') 1927 % ylabel('smoothing effect') 1928 % set(handles.TestPatch2,'BackgroundColor',[0 1 0]) 1929 % else 1930 % corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display 1931 % if ~isempty(corrfig) 1932 % delete(corrfig) 1933 % end 1934 % hview_field=findobj(allchild(0),'tag','view_field');% look for view_field 1935 % if ~isempty(hview_field) 1936 % delete(hview_field) 1937 % end 1938 % end 1939 % 1631 msgbox_uvmat('WARNING','open the civ file and run "series/test_filter_tps" ') 1632 1940 1633 1941 1634 %'nomtype2pair': creates nomenclature for index pairs knowing the image nomenclature
Note: See TracChangeset
for help on using the changeset viewer.