Changeset 133


Ignore:
Timestamp:
Nov 25, 2010, 12:21:39 PM (13 years ago)
Author:
gostiaux
Message:

Code cleaning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r130 r133  
    457457if isfield(browse,'nom_type_ima')
    458458    nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name
     459end
     460if isfield(browse,'ext_ima')
    459461    ext_ima=browse.ext_ima;
    460462end
     
    15461548end
    15471549
    1548 %------------------------------------------------------------------------
    1549 % --- Executes on button press in RUN.
    1550 
    1551 
    1552 
    1553 % compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3)
    1554 % %check the list of operations:
    1555 % operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'};
    1556 % run_flag=1;
    1557 % box_test(1)=get(handles.CIV1,'Value');
    1558 % box_test(2)=get(handles.FIX1,'Value');
    1559 % box_test(3)=get(handles.PATCH1,'Value');
    1560 % box_test(4)=get(handles.CIV2,'Value');
    1561 % box_test(5)=get(handles.FIX2,'Value');
    1562 % box_test(6)=get(handles.PATCH2,'Value');
    1563 % index=find(box_test==1);
    1564 % if isempty(index)
    1565 %     msgbox_uvmat('ERROR','no selected operation')
    1566 %     return
    1567 % end
    1568 % index_first=min(index);
    1569 % index_last=max(index);
    1570 % box_used=box_test([index_first : index_last]);
    1571 % [box_missing,ind_missing]=min(box_used);
    1572 % if isequal(box_missing,0)
    1573 %     msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]);
    1574 %     return
    1575 % end
    1576 %
    1577 % %root name
    1578 % filebase=get(handles.RootName,'String');
    1579 % if isempty(filebase)||isequal(filebase,'')
    1580 %     msgbox_uvmat('ERROR','no input files')
    1581 %     return
    1582 % end
    1583 % %check mask if selecetd
    1584 % if isequal(get(handles.get_mask_civ1,'Value'),1)
    1585 %     maskname=get(handles.mask_civ1,'String');
    1586 %     if ~exist(maskname,'file')
    1587 %         get_mask_civ1_Callback(hObject, eventdata, handles);
    1588 %     end
    1589 % end
    1590 % if isequal(get(handles.get_mask_fix1,'Value'),1)
    1591 %     maskname=get(handles.mask_fix1,'String');
    1592 %     if ~exist(maskname,'file')
    1593 %      get_mask_fix1_Callback(hObject, eventdata, handles);
    1594 %     end
    1595 % end
    1596 % if isequal(get(handles.get_mask_civ2,'Value'),1)
    1597 %     maskname=get(handles.mask_civ2,'String');
    1598 %     if ~exist(maskname,'file')
    1599 %      get_mask_civ2_Callback(hObject, eventdata, handles);
    1600 %     end
    1601 % end
    1602 % if isequal(get(handles.get_mask_fix2,'Value'),1)
    1603 %     maskname=get(handles.mask_fix2,'String');
    1604 %     if ~exist(maskname,'file')
    1605 %      get_mask_fix2_Callback(hObject, eventdata, handles);
    1606 %     end
    1607 % end
    1608 %
    1609 % %read names of the .exe file
    1610 % if box_test(1)==1 || box_test(3)==1 || box_test(4)==1 || box_test(6)==1
    1611 %     path_uvmat=which('uvmat');% check the path detected for source file uvmat
    1612 %     path_UVMAT=fileparts(path_uvmat); %path to UVMAT
    1613 %     %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ binary names
    1614 %     xmlfile=fullfile(path_UVMAT,'PARAM.xml');
    1615 %     if exist(xmlfile,'file')
    1616 %         t=xmltree(xmlfile);
    1617 %         sparam=convert(t);
    1618 %     end
    1619 %     if isfield(sparam,'Civ1Bin')
    1620 %         civ1Bin=sparam.Civ1Bin;
    1621 %         if ~exist(civ1Bin,'file')
    1622 %             civ1Bin=fullfile(path_UVMAT,civ1Bin);
    1623 %         end
    1624 %     end
    1625 %     if isfield(sparam,'Civ2Bin')
    1626 %         civ2Bin=sparam.Civ2Bin;
    1627 %         if ~exist(civ2_exe,'file')%the binary is defined in /bin, default setting
    1628 %             civ2_exe=fullfile(path_UVMAT,civ2_exe);
    1629 %         end
    1630 %     end
    1631 %     if isfield(sparam,'Patch_exe')
    1632 %         patch_exe=sparam.Patch_exe;
    1633 %         if ~exist(patch_exe,'file')%the binary is defined in /bin, default setting
    1634 %             patch_exe=fullfile(path_UVMAT,patch_exe);
    1635 %         end
    1636 %     end
    1637 %     if isfield(sparam,'Stinterp_exe')
    1638 %         stinterp_exe=sparam.Stinterp_exe;
    1639 %     end
    1640 %     if isfield(sparam,'SGE')
    1641 %         sge=str2double(sparam.SGE);
    1642 %     end
    1643 %     if ~isunix % for windows system, check whether the Matlab working dir is a UBC name
    1644 %         dircur=pwd;
    1645 %         if ~isequal(dircur([2 3]),':\')
    1646 %             msgbox_uvmat('ERROR','move to a Matlab current working directory with a Windows name, e.g. m:/...')
    1647 %             return;
    1648 %         end
    1649 %     end
    1650 % end
    1651 %
    1652 % %initialize the waitbars
    1653 % set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001])
    1654 % set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001])
    1655 % set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001])
    1656 % set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001])
    1657 % set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
    1658 % set(handles.RUN, 'Enable','Off')
    1659 % drawnow
    1660 %
    1661 % % get the list of file names and check the files
    1662 % display('checking the files...')
    1663 % [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
    1664 %        set_civ_filenames(handles,compare,box_test);
    1665 % nbfield=numel(num1_civ1);
    1666 % nbslice=size(num_a_civ1);
    1667 %
    1668 % if isempty(filecell)
    1669 %    set(handles.RUN, 'Enable','On')
    1670 %     set(handles.RUN,'BackgroundColor',[1 0 0])
    1671 %     set(handles.BATCH, 'Enable','On')
    1672 %     set(handles.BATCH,'BackgroundColor',[1 0 0])
    1673 %    return
    1674 % end
    1675 % display('files OK, processing...')
    1676 % nbfield=size(num1_civ1,2);
    1677 % nbslice=size(num1_civ1,1);
    1678 %
    1679 % %RUN CIV1
    1680 % if box_test(1)==1
    1681 %       RUN_CIV1(handles,filecell.ima1.civ1,filecell.ima2.civ1,filecell.nc.civ1,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,nom_type_nc)
    1682 %       if compare==3
    1683 %             RUN_CIV1(handles,filecell.imaA1.civ1,filecell.imaA2.civ1,filecell.ncA.civ1,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,nom_type_nc)
    1684 %      end
    1685 % end
    1686 %
    1687 % %RUN FIX1
    1688 % if box_test(2)==1
    1689 %     filebase=get(handles.RootName,'String');
    1690 %     %names of the civ1 fields
    1691 %     field1.vel_type='civ1';
    1692 %     field1.nb='nb_vectors';
    1693 % %     field1.X='vec_X';
    1694 % %     field1.Y='vec_Y';
    1695 % %     field1.U='vec_U';
    1696 % %     field1.V='vec_V';
    1697 %     field1.fixflag='vec_FixFlag';
    1698 %     flagindex(1)=get(handles.vec_Fmin2, 'Value');
    1699 %     flagindex(2)=get(handles.vec_F3, 'Value');
    1700 %     flagindex(3)=get(handles.vec_F2, 'Value');
    1701 %     thresh_vecC=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C
    1702 %     thresh_vel=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus
    1703 %     inf_sup=get(handles.inf_sup1,'Value');
    1704 %     menu=get(handles.field_ref1,'String');
    1705 %     index=get(handles.field_ref1,'Value');
    1706 %     if isempty(menu)
    1707 %         fieldchoice='';
    1708 %     else
    1709 %         fieldchoice=menu{index};
    1710 %     end
    1711 %     h = waitbar(0,'removing velocity vectors, fix1');% display a wait bar
    1712 %     test_mask=get(handles.get_mask_fix1,'Value');
    1713 %     if test_mask
    1714 %         maskdispl=get(handles.mask_fix1,'String');
    1715 %         if exist(maskdispl,'file')
    1716 %             test_mask=2;
    1717 %             maskname=maskdispl;
    1718 %         else
    1719 %             maskbase=[get(handles.RootName,'String') '_' maskdispl]; % mask root name
    1720 %         end
    1721 %     end
    1722 %     for ifile=1:nbfield
    1723 %         waitbar(ifile/nbfield); %update the waitbar
    1724 %         for j=1:nbslice
    1725 %             if test_mask==0
    1726 %                 maskname='noFile use default';
    1727 %                 maskflag=0;
    1728 %             elseif test_mask==1
    1729 %                 nbslice_mask=str2double(maskdispl(1:end-4)); %
    1730 %                 num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1;
    1731 %                 maskname=name_generator(maskbase,num1_mask,1,'.png','_i');% mask corresponding to the first image of the pair
    1732 %                 maskflag= exist(maskname,'file')==2;
    1733 %                 if ~maskflag;
    1734 %                     maskname='noFile use default';
    1735 %                 end
    1736 %             end
    1737 %             if ~isempty(file_ref_fix1)
    1738 %                 file_ref=file_ref_fix1{ifile,j};
    1739 %             else
    1740 %                 file_ref='';
    1741 %             end
    1742 %             error=RUN_FIX(filecell.nc.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,...
    1743 %                                     thresh_vel,inf_sup,file_ref,fieldchoice);
    1744 %
    1745 %             if compare==3 &&(isequal(mode,'pair j1-j2') || isequal(mode,'series(Dj)') || isequal(mode,'series(Di)'))
    1746 %                  if test_mask==0
    1747 %                       maskname='noFile use default';
    1748 %                       maskflag=0;
    1749 %                  else
    1750 %                      maskbase=[get(handles.RootName2,'String') '_' maskdispl]; % mask root name
    1751 %                      nbslice_mask=str2num(maskdispl(1:end-4)); %
    1752 %                      num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1;
    1753 %                      maskname=name_generator(maskbase,num1_mask,1,'.png','_i');
    1754 %                      maskflag= exist(maskname,'file')==2;
    1755 %                      if ~maskflag;
    1756 %                         maskname='noFile use default';
    1757 %                      end
    1758 %                  end
    1759 %                  error=RUN_FIX(filecell.ncA.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,...
    1760 %                                     thresh_vel,inf_sup,file_ref,fieldchoice);
    1761 %                  if ~isempty(error)
    1762 %                     msgbox_uvmat('ERROR',error)
    1763 %                     return
    1764 %                  end
    1765 %             end
    1766 %         end
    1767 %     end
    1768 %     close(h)
    1769 % end
    1770 %
    1771 % % RUN PATCH1
    1772 % if box_test(3)==1
    1773 %     rho_patch1=str2num(get(handles.rho_patch1,'String'));
    1774 %     if isempty(rho_patch1)
    1775 %         rho_patch1='1000';
    1776 %         set(handles.rho_patch1,'String','1')
    1777 %     else
    1778 %         rho_patch1=num2str(1000*rho_patch1);
    1779 %     end
    1780 %     nx_patch1=get(handles.nx_patch1,'String');
    1781 %     if isequal(str2num(nx_patch1),[])
    1782 %          nx_patch1='50' ;%default
    1783 %          set(handles.nx_patch1,'String','50');
    1784 %     end
    1785 %     ny_patch1=get(handles.ny_patch1,'String');
    1786 %     if isequal(str2num(ny_patch1),[])
    1787 %          ny_patch1='50' ;%default
    1788 %          set(handles.ny_patch1,'String','50');
    1789 %     end
    1790 %     subdomain_patch1=get(handles.subdomain_patch1,'String');
    1791 %     thresh_patch1=get(handles.thresh_patch1,'String');
    1792 %     test_interp=get(handles.test_interp,'Value');
    1793 %     icount=0;
    1794 %     for ifile=1:nbfield
    1795 %         for j=1:nbslice
    1796 %             icount=icount+1;
    1797 %             barlength=0.188*icount/(nbfield*nbslice);
    1798 %             set(handles.waitbar_patch1,'Position',[0.946 0.627-barlength 0.03 barlength])
    1799 %             drawnow
    1800 %             if  isequal(get(handles.test_stereo1,'Value'),0)
    1801 %                 cmd=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp);
    1802 %                 s=-1;
    1803 %                 if sge
    1804 %                     [s,w]=unix(['qrsh -q -fast.q ' cmd]);
    1805 %                 end
    1806 %                 if s~=0
    1807 %                     display(['!' cmd])
    1808 %                     eval(['!' cmd]);
    1809 %                 end
    1810 %
    1811 %                 %stereo case:
    1812 %             elseif  isequal(get(handles.test_stereo1,'Value'),1)
    1813 %                 if exist('stinterp_exe','var')%Prog Gauthier
    1814 %                     cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},filecell.st{ifile,j},...
    1815 %                           nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,[filebase_A '.xml'],[filebase_B '.xml']);
    1816 %                     display(['!' cmd])
    1817 %                     eval(['!' cmd]);
    1818 %                 else
    1819 %                     RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},...
    1820 %                         str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']);
    1821 %                 end
    1822 %             end
    1823 %             if compare==3 && isequal(get(handles.test_stereo1,'Value'),0)
    1824 %                 cmd=RUN_PATCH(filecell.ncA.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp);
    1825 %                 s=-1;
    1826 %                 if sge
    1827 %                     [s,w]=unix(['qrsh -q -fast.q ' cmd]);
    1828 %                 end
    1829 %                 if s~=0
    1830 %                    display(['!' cmd])
    1831 %                    eval(['!' cmd]);
    1832 %                 end
    1833 %             end
    1834 %         end
    1835 %     end
    1836 % end
    1837 %
    1838 % % CIV2
    1839 % if box_test(4)==1
    1840 %     RUN_CIV2(handles,filecell.ima1.civ2,filecell.ima2.civ2,filecell.nc.civ1,filecell.nc.civ2,num1_civ2,num2_civ2,...
    1841 %         num_a_civ2,num_b_civ2,nom_type_nc)
    1842 % end
    1843 %
    1844 % % FIX2
    1845 % if box_test(5)==1
    1846 %     %names of the civ2 fields
    1847 %     field2.vel_type='civ2';
    1848 %     field2.nb='nb_vectors2';
    1849 %     field2.X='vec2_X';
    1850 %     field2.Y='vec2_Y';
    1851 %     field2.U='vec2_U';
    1852 %     field2.V='vec2_V';
    1853 %     field2.fixflag='vec2_FixFlag';
    1854 %     flagindex(1)=get(handles.vec_Fmin2_2, 'Value');
    1855 %     flagindex(2)=get(handles.vec_F3_2, 'Value');
    1856 %     flagindex(3)=get(handles.vec_F4, 'Value');
    1857 %     thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C
    1858 %     thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus
    1859 %     inf_sup=get(handles.inf_sup2,'Value');
    1860 %     menu=get(handles.field_ref2,'String');
    1861 %     index=get(handles.field_ref2,'Value');
    1862 %     if isempty(menu)
    1863 %         fieldchoice='';
    1864 %     else
    1865 %         fieldchoice=menu{index};
    1866 %     end
    1867 %     h = waitbar(0,['removing velocity vectors, fix2']);% display a wait bar
    1868 %     test_mask=get(handles.get_mask_fix2,'Value');
    1869 %     if test_mask
    1870 %         maskdispl=get(handles.mask_fix2,'String');
    1871 %         if exist(maskdispl,'file')
    1872 %             test_mask=2;
    1873 %             maskname=maskdispl;
    1874 %         else
    1875 %             maskbase=[get(handles.RootName,'String') '_' maskdispl]; % mask root name
    1876 %         end
    1877 %     end
    1878 %     for ifile=1:nbfield
    1879 %         waitbar(ifile/nbfield); %update the waitbar
    1880 %         for j=1:nbslice
    1881 %            if test_mask==0
    1882 %                 maskname='noFile use default';
    1883 %                 maskflag=0;
    1884 %            elseif test_mask==1
    1885 %                 nbslice_mask=str2num(maskdispl(1:end-4)); %
    1886 %                 num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1;
    1887 %                 maskname=name_generator(maskbase,num1_mask,1,'.png','_i');
    1888 %                 maskflag= exist(maskname,'file')==2;
    1889 %                 if ~maskflag;
    1890 %                       maskname='noFile use default';
    1891 %                 end
    1892 %             end
    1893 %             if ~isempty(file_ref_fix2)
    1894 %                 file_ref=file_ref_fix2{ifile,j};
    1895 %             else
    1896 %                 file_ref='';
    1897 %             end
    1898 %             error=RUN_FIX(filecell.nc.civ2{ifile,j},field2,flagindex,2,thresh_vec2C,maskflag,maskname,...
    1899 %                                     thresh_vel2,inf_sup,file_ref,fieldchoice);
    1900 %             if ~isempty(error)
    1901 %                 msgbox_uvmat('ERROR',error)
    1902 %                 return
    1903 %             end
    1904 %             if compare==3
    1905 %                  if test_mask==0
    1906 %                       maskname='noFile use default';
    1907 %                       maskflag=0;
    1908 %                  else
    1909 %                       maskbase=[get(handles.RootName2,'String') '_' maskdispl]; % mask root name
    1910 %                       nbslice_mask=str2num(maskdispl(1:end-4)); %
    1911 %                       num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1;
    1912 %                       maskname=name_generator(maskbase,num1_mask,1,'.png','_i');
    1913 %                       maskflag= exist(maskname,'file')==2;
    1914 %                       if ~maskflag;
    1915 %                          maskname='noFile use default';
    1916 %                       end
    1917 %                  end
    1918 %                  error=RUN_FIX(filecell.ncA.civ2{ifile,j},field2,flagindex,1,thresh_vec2C,maskflag,maskname,...
    1919 %                                     thresh_vel2,inf_sup,file_ref,fieldchoice);
    1920 %                  if ~isempty(error)
    1921 %                     msgbox_uvmat('ERROR',error)
    1922 %                     return
    1923 %                  end
    1924 %             end
    1925 %         end
    1926 %     end
    1927 %     close(h)
    1928 % end
    1929 %
    1930 % %PATCH 2
    1931 % if box_test(6)==1
    1932 %     rho_patch2=str2num(get(handles.rho_patch2,'String'));
    1933 %     if isempty(rho_patch2)
    1934 %         rho_patch2='1000';
    1935 %         set(handles.rho_patch2,'String','1')
    1936 %     else
    1937 %         rho_patch2=num2str(1000*rho_patch2);
    1938 %     end
    1939 %     nx_patch2=get(handles.nx_patch2,'String');
    1940 %     ny_patch2=get(handles.ny_patch2,'String');
    1941 %     thresh_patch2=get(handles.thresh_patch2,'String');
    1942 %     if isequal(str2num(nx_patch2),[])
    1943 %          nx_patch2='50' ;%default
    1944 %          set(handles.nx_patch2,'String','50');
    1945 %     end
    1946 %     if isequal(str2num(ny_patch2),[])
    1947 %          ny_patch2='50' ;%default
    1948 %          set(handles.ny_patch2,'String','50');
    1949 %     end
    1950 %     subdomain_patch2=get(handles.subdomain_patch2,'String');
    1951 %     icount=0;
    1952 %     for ifile=1:nbfield
    1953 %         for j=1:nbslice
    1954 %             icount=icount+1;
    1955 %             barlength=0.188*icount/(nbfield*nbslice);
    1956 %             set(handles.waitbar_patch2,'Position',[0.946 0.188-barlength 0.03 barlength])
    1957 %             drawnow
    1958 %             if compare~=3 | isequal(get(handles.test_stereo2,'Value'),0)
    1959 %                 cmd=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0);
    1960 %                 s=-1;
    1961 %                 if sge
    1962 %                     [s,w]=unix(['qrsh -q -fast.q ' cmd]);
    1963 %                 end
    1964 %                 if s~=0
    1965 %                     display(['!' cmd])
    1966 %                     eval(['!' cmd]);
    1967 %                 end
    1968 %             elseif compare==3 &&  isequal(get(handles.test_stereo2,'Value'),1)
    1969 %                if exist('stinterp_exe','var')%Prog Gauthier
    1970 %                    cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},filecell.st{ifile,j},...
    1971 %                    nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,[filebase_A '.xml'],[filebase_B '.xml']);
    1972 %                    display(['!' cmd])
    1973 %                    eval(['!' cmd])
    1974 %                else
    1975 %                    RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},...
    1976 %                    str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml'])
    1977 %                end
    1978 %             end
    1979 %             if compare==3 && isequal(get(handles.test_stereo2,'Value'),0)
    1980 %                 cmd=RUN_PATCH(filecell.ncA.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0);
    1981 %                 s=-1;
    1982 %                 if sge
    1983 %                     [s,w]=unix(['qrsh -q -fast.q ' cmd]);
    1984 %                 end
    1985 %                 if s~=0
    1986 %                     display(['!' cmd])
    1987 %                     eval(['!' cmd]);
    1988 %                 end
    1989 %             end
    1990 %         end
    1991 %     end
    1992 % end
    1993 %
    1994 % set(handles.RUN, 'Enable','On')
    1995 % set(handles.RUN,'BackgroundColor',[1 0 0])
    1996 %
    1997 % %save the current interface setting as figure namefig, append .0 to the name if it already exists
    1998 % if isfield(filecell,'st')
    1999 %     fileresu=filecell.st{1,1};
    2000 % elseif isfield(filecell,'nc')
    2001 %     if isfield(filecell.nc,'civ2')
    2002 %         fileresu=filecell.nc.civ2{1,1};
    2003 %     else
    2004 %         fileresu=filecell.nc.civ1{1,1};
    2005 %     end
    2006 % end
    2007 % [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu);
    2008 % namedoc=fullfile(RootPath,subdir,RootFile);
    2009 % detect=1;
    2010 % while detect==1
    2011 %     namefigfull=[namedoc '.fig'];
    2012 %     hh=dir(namefigfull);
    2013 %     if ~isempty(hh)
    2014 %         detect=1;
    2015 %         namedoc=[namedoc '.0'];
    2016 %     else
    2017 %         detect=0;
    2018 %     end
    2019 % end
    2020 % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER  .xml)
    2021 
    20221550function RUN_Callback(hObject, eventdata, handles)
    20231551%------------------------------------------------------------------------
     
    20331561% --- Executes on button press in BATCH: remote processing
    20341562function BATCH_Callback(hObject, eventdata, handles)
    2035 %------------------------------------------------------------------------
     1563%% -----------------------------------------------------------------------
    20361564%global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe % probabely to remove
    20371565set(handles.BATCH, 'Enable','Off')
     
    20431571
    20441572%------------------------------------------------------------------------
    2045 % --- Executes on button press in BATCH: remote processing
     1573% --- Lauch command called by RUN and BATCH: remote processing
    20461574function launch_jobs(hObject, eventdata, handles, batch)
    20471575%-----------------------------------------------------------------------
    2048 compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3)
    2049 
    2050 %check the list of operations:
     1576%% check the selected list of operations:
    20511577operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'};
    2052 % run_flag=1;
    20531578box_test(1)=get(handles.CIV1,'Value');
    20541579box_test(2)=get(handles.FIX1,'Value');
     
    20711596end
    20721597
    2073 %root name
     1598%% get the root names
    20741599filebase=get(handles.RootName,'String');
    20751600if isempty(filebase)||isequal(filebase,'')
     
    21041629end
    21051630
    2106 %read names of the .exe file
    2107 path_uvmat=which('uvmat');% check the path detected for source file uvmat
    2108 path_UVMAT=fileparts(path_uvmat); %path to UVMAT
    2109 xmlfile='PARAM.xml';
    2110 if exist(xmlfile,'file')
    2111     t=xmltree(xmlfile);
    2112     s=convert(t);
    2113 end
    2114 test_interp=0;
    2115 if batch
    2116     if isfield(s,'BatchParam')
    2117         sparam=s.BatchParam;
    2118         if ~ismember(sparam.BatchMode,{'sge'})
    2119             msgbox_uvmat('ERROR',['batch mode ' sparam.BatchMode ' not supported by UVMAT'])
    2120         end
    2121     else
    2122         msgbox_uvmat('ERROR','no batch mode defined in PARAM.xml')
    2123         return
    2124     end
    2125 else
    2126     if isfield(s,'RunParam')
    2127         sparam=s.RunParam;
    2128     else
    2129         msgbox_uvmat('ERROR','no civ binaries defined in PARAM.xml')
    2130         return
    2131     end
    2132     if isfield(sparam,'CivBin')
    2133         if ~exist(sparam.CivBin,'file')
    2134             sparam.CivBin=fullfile(path_UVMAT,sparam.CivBin);
    2135         end
    2136     end
    2137     if isfield(sparam,'Civ1Bin')
    2138         if ~exist(sparam.Civ1Bin,'file')
    2139             sparam.Civ1Bin=fullfile(path_UVMAT,sparam.Civ1Bin);
    2140         end
    2141     end
    2142     if isfield(sparam,'Civ2Bin')
    2143         if ~exist(sparam.Civ2Bin,'file')
    2144             sparam.Civ2Bin=fullfile(path_UVMAT,sparam.Civ2Bin);
    2145         end
    2146     end
    2147     %test_interp=get(handles.test_interp,'Value');
    2148 
    2149     if  isfield(sparam,'PatchBin')
    2150         if ~exist(sparam.PatchBin,'file')
    2151             sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin);
    2152         end
    2153     end
    2154     % if test_interp && isfield(sparam,'PatchNewBin')
    2155     %     if ~exist(sparam.PatchNewBin,'file')
    2156     %          sparam.PatchNewBin=fullfile(path_UVMAT,sparam.PatchNewBin);
    2157     %     end
    2158     % end
    2159     if isfield(sparam,'FixBin')
    2160         if ~exist(sparam.FixBin,'file')
    2161             sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin);
    2162         end
    2163     end
    2164 end
    2165 if batch
    2166     if isfield(sparam,'BatchMode')
    2167         batch_mode=sparam.BatchMode;
    2168     end
    2169 else
    2170     MaxCivProcesses=50;
    2171     if isfield(sparam,'MaxCivProcesses')
    2172         MaxCivProcesses=str2double(sparam.MaxCivProcesses);
    2173     end
    2174 end
    2175 
    2176 %initialize the waitbars
     1631%% initialize the waitbars
    21771632set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001])
    21781633set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001])
     
    21811636drawnow
    21821637
    2183 % set the list of files and check them
     1638%% set the list of files and check them
    21841639display('checking the files...')
    2185 [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
     1640compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3)
     1641[filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=...
    21861642    set_civ_filenames(handles,compare,box_test);
    21871643if isempty(filecell)
    21881644    return
    21891645end
    2190 %choice of batch priority
     1646nbfield=numel(num1_civ1);
     1647nbslice=numel(num_a_civ1);
     1648
     1649%% choice of batch priority
    21911650ind_answer=2;
    21921651if batch
     
    22101669        [xx,w]=unix('ps faux |grep civ|wc -l');
    22111670        w(end)=[];
    2212         if str2double(w)+numel(num1_civ1)> MaxCivProcesses
     1671        if str2double(w)+numel(num1_civ1)> 50
    22131672            msgbox_uvmat('ERROR',{['There are already ' w ' civ processes running locally'];'Use BATCH or submit RUN later'})
    22141673            return
     
    22161675    end
    22171676end
     1677
     1678
     1679%% read names of the .exe files for PIV and patch
     1680path_UVMAT=fileparts(which('uvmat')); %path to the source directory of uvmat
     1681xmlfile='PARAM.xml';
     1682if exist(xmlfile,'file')% search parameter xml file in the whole matlab path
     1683    t=xmltree(xmlfile);
     1684    s=convert(t);
     1685end
     1686test_interp=0;
     1687if batch
     1688    if isfield(s,'BatchParam')
     1689        sparam=s.BatchParam;
     1690        if ~ismember(sparam.BatchMode,{'sge'})
     1691            msgbox_uvmat('ERROR',['batch mode ' sparam.BatchMode ' not supported by UVMAT'])
     1692        end
     1693    else
     1694        msgbox_uvmat('ERROR','no batch mode defined in PARAM.xml')
     1695        return
     1696    end
     1697else
     1698    if isfield(s,'RunParam')
     1699        sparam=s.RunParam;
     1700    else
     1701        msgbox_uvmat('ERROR','no civ binaries defined in PARAM.xml')
     1702        return
     1703    end
     1704    if isfield(sparam,'CivBin')
     1705        if ~exist(sparam.CivBin,'file')
     1706            sparam.CivBin=fullfile(path_UVMAT,sparam.CivBin);
     1707        end
     1708    end
     1709    if isfield(sparam,'Civ1Bin')
     1710        if ~exist(sparam.Civ1Bin,'file')
     1711            sparam.Civ1Bin=fullfile(path_UVMAT,sparam.Civ1Bin);
     1712        end
     1713    end
     1714    if isfield(sparam,'Civ2Bin')
     1715        if ~exist(sparam.Civ2Bin,'file')
     1716            sparam.Civ2Bin=fullfile(path_UVMAT,sparam.Civ2Bin);
     1717        end
     1718    end
     1719    %test_interp=get(handles.test_interp,'Value');
     1720
     1721    if  isfield(sparam,'PatchBin')
     1722        if ~exist(sparam.PatchBin,'file')
     1723            sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin);
     1724        end
     1725    end
     1726    % if test_interp && isfield(sparam,'PatchNewBin')
     1727    %     if ~exist(sparam.PatchNewBin,'file')
     1728    %          sparam.PatchNewBin=fullfile(path_UVMAT,sparam.PatchNewBin);
     1729    %     end
     1730    % end
     1731    if isfield(sparam,'FixBin')
     1732        if ~exist(sparam.FixBin,'file')
     1733            sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin);
     1734        end
     1735    end
     1736end
     1737if batch
     1738    if isfield(sparam,'BatchMode')
     1739        batch_mode=sparam.BatchMode;
     1740    end
     1741else
     1742%     MaxCivProcesses=50;
     1743%     if isfield(sparam,'MaxCivProcesses')
     1744%         MaxCivProcesses=str2double(sparam.MaxCivProcesses);
     1745%     end
     1746end
     1747
     1748
     1749%% get civ1 parameters:
    22181750display('files OK, processing...')
    2219 nbfield=numel(num1_civ1);
    2220 nbslice=numel(num_a_civ1);
    2221 
    2222 %GET PARAMETERS:
    22231751%get civ parameters
    22241752if box_test(1)==1
     
    22261754end
    22271755
    2228 %get fix1 parameters
     1756%% get fix1 parameters
    22291757if box_test(2)==1
    22301758    flagindex1(1)=get(handles.vec_Fmin2, 'Value');
     
    22501778end
    22511779
    2252 %get patch1 parameters
     1780%% get patch1 parameters
    22531781if box_test(3)==1
    22541782    rho_patch1=str2double(get(handles.rho_patch1,'String'));
     
    22731801end
    22741802
    2275 %get civ2 parameters
     1803%% get civ2 parameters:
    22761804if box_test(4)==1
    22771805    par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1)));
    22781806end
    22791807
    2280 %get fix2 parameters
     1808%% get fix2 parameters
    22811809if box_test(5)==1
    22821810    flagindex2(1)=get(handles.vec_Fmin2_2, 'Value');
     
    22941822end
    22951823
    2296 %get patch2 parameters
     1824%% get patch2 parameters
    22971825if box_test(6)==1
    22981826    rho_patch2=str2double(get(handles.rho_patch2,'String'));
     
    23181846end
    23191847
    2320 %MAIN LOOP
    2321 % for ifile=1:nbfield
    2322 % p1text=[];%initiate command text
     1848%% MAIN LOOP
    23231849time=get(handles.RootName,'UserData'); %get the set of times
    23241850civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method
     1851super_cmd='#!/bin/bash \n';
     1852super_cmd=[super_cmd '#$ -cwd \n'];
     1853super_cmd=[super_cmd 'hostname && date \n'];
    23251854for ifile=1:nbfield
    23261855    for j=1:nbslice
     
    26972226                case 'sge'
    26982227                    pvalue=num2str((1-ind_answer)*500);
    2699                     namelog=[filename_bat '.patch.log'];
     2228                    %namelog=[filename_bat '.patch.log'];
    27002229                    display(['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]);
    27012230                    eval(  ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]);
     
    27042233            %% to lauch the jobs locally :
    27052234            if(isunix)
    2706                 cmd_str=['!. ' filename_bat ' &'];
    2707 %                 cmd_str=['!at -qb now -f ' filename_bat ' &']; %ou at -qb now -f bad idea...
    2708                 eval(cmd_str);
    2709                 display(cmd_str);
    2710             else
    2711                 cmd_str=['!' filename_bat ' &'];
    2712                 eval(cmd_str);
    2713                 display(cmd_str);
    2714             end
    2715         end
    2716     end
    2717 end
    2718 % set(handles.BATCH, 'Enable','On')
    2719 % set(handles.BATCH,'BackgroundColor',[1 0 0])
     2235        %       cmd_str=['!. ' filename_bat ' &'];
     2236                cmd_str=['!. ' filename_bat];
     2237                display(cmd_str)
     2238         %       super_cmd=[super_cmd filename_bat]
     2239     %            cmd_str=['!at -qb now -f ' filename_bat ' &']; %ou at -qb now -f bad idea...
     2240            else %case of Windows
     2241               cmd_str=['!' filename_bat ' &'];
     2242            end
     2243            eval(cmd_str);
     2244            display(cmd_str);
     2245        end
     2246    end
     2247end
     2248if ~batch%TODO: a revoir, cas 'run as background task'
     2249    eval(['!.' super_cmd])
     2250end
    27202251
    27212252%save interface state
     
    27422273saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER  .xml)
    27432274
    2744 %------------------------------------------------------------------------
    2745 %OUTPUT:
    2746 % filecell: structure of input and output files
    2747 %         .ima1.civ1{i,j}, .ima1.civ2{i,j}; set of first image names for  correlations, for civ1 and civ2
    2748 %         .ima2.civ1{i,j}, .ima2.civ2{i,j} ; set of second image names for correlations
    2749 %         .imaA1.civ1{i,j}, .ima1.civ2{i,j}; set of first image names for correlations, for civ1 and civ2, with camA in stereo case (then .ima1 corresponds to camB)
    2750 %         .imaA2.civ1{i,j}, .ima2.civ2{i,j} ; set of second image names for  correlations, with camA in stereo case (then .ima1 corresponds to camB)
    2751 %         .nc.civ1{i,j}, .nc.civ2{i,j}; set of nc files for PIV results
    2752 %         .ncA.civ1{i,j}, .ncA.civ2{i,j}; set of nc files for PIV results with camA (then .nc corresponds to camB)
    2753 %         .st{i,j};   set of nc files for the combined stereo fields
    2754 % num1_civ1(i),num2_civ1(i): lists of first and last i indices for civ1
    2755 % num_a_civ1(j),num_b_civ1(j): lists of first and last j indices for civ1
    2756 % num1_civ2(i),num2_civ2(i): lists of first and last i indices for civ2
    2757 % num_a_civ2(j),num_b_civ2(j): lists of first and last j indices for civ2
    2758 % nom_type_nc: nomenclature type for velocity files
    2759 % file_ref_fix1,file_ref_fix2: reference files possibly used by Fix1 and 2
    27602275function [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
    27612276    set_civ_filenames(handles,compare,box_test)
     
    33772892    type_ima1='none';%default
    33782893    movieobject1=[];%default
    3379     if isequal(lower(ext_ima),'.avi')
     2894    if strcmpi(ext_ima,'.avi')
    33802895        hhh=which('mmreader');
    33812896        if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab)
     
    33852900            type_ima1='avi';
    33862901        end
    3387     else
     2902    elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))
    33882903        form=imformats(ext_ima(2:end));
    33892904        if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
     
    33972912    type_ima2='none';%default
    33982913    movieobject2=[];
    3399     if isequal(lower(ext_ima),'.avi')
     2914    if strcmpi(ext_ima,'.avi')
    34002915        hhh=which('mmreader');
    34012916        if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab)
     
    34052920            type_ima2='avi';
    34062921        end
    3407     else
     2922    elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))
    34082923        form=imformats(ext_ima(2:end));
    34092924        if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
     
    34672982    end
    34682983end
    3469 
    34702984
    34712985%------------------------------------------------------------------------
     
    36463160
    36473161%------------------------------------------------------------------------
    3648 % --- Executes on button press in get_mask_civ1.
     3162% --- Executes on button press in get_mask_civ1: select box for mask option
    36493163function get_mask_civ1_Callback(hObject, eventdata, handles)
    36503164%------------------------------------------------------------------------
     
    36913205    set(handles.mask_fix2,'String',mask_displ)
    36923206end
    3693 set(handles.mask_civ2,'Value',maskval)
     3207set(handles.get_mask_civ2,'Value',maskval)%update the civ2 mask with the same option as civ1
    36943208
    36953209%------------------------------------------------------------------------
     
    37383252
    37393253%------------------------------------------------------------------------
    3740 % --- Executes on button press in get_mask_civ2.
     3254% --- Executes on button press in get_mask_civ2: select box for mask option
    37413255function get_mask_civ2_Callback(hObject, eventdata, handles)
    37423256%------------------------------------------------------------------------
     
    50104524set(handles.thresh_vel2,'String','0');
    50114525
    5012 % %------------------------------------------------------------------------
    5013 % % transform letters to numbers
    5014 % function numres=stra2num(str)
    5015 % %------------------------------------------------------------------------
    5016 % numres=double(str)-96;
    5017 % if double(str) >= 48 & double(str) <= 57 % = 1 for numbers
    5018 %     numres=str2num(str);
    5019 % end
    5020 
    50214526%------------------------------------------------------------------------
    50224527% --- Executes on button press in test_stereo1.
Note: See TracChangeset for help on using the changeset viewer.