Changeset 29
- Timestamp:
- Mar 3, 2010, 10:48:08 AM (15 years ago)
- Location:
- trunk/src
- Files:
-
- 2 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/imadoc2struct.m
r19 r29 21 21 s.TimeUnit=[]; %default 22 22 s.GeometryCalib=[]; 23 nom_type_ima=[];%default24 ext_ima=[];%default23 % nom_type_ima=[];%default 24 % ext_ima=[];%default 25 25 % abs_time=[];%initiation 26 26 % GeometryCalib.CoordUnit='cm';%default 27 mode=[]; %default28 NbSlice=1;%default29 npx=[];%default30 npy=[];%default27 % mode=[]; %default 28 % NbSlice=1;%default 29 % npx=[];%default 30 % npy=[];%default 31 31 % GeometryCalib.Pxcmx=1; 32 32 % GeometryCalib.Pxcmy=1; 33 33 % GeometryCalib=[]; 34 NbDtj=1;34 % NbDtj=1; 35 35 tsai=[];%default 36 36 % if ~exist('testime','var') … … 64 64 end 65 65 s.Heading.ImageName=get(t,children(t,uid_FirstImage),'value'); 66 FirstImage=s.Heading.ImageName;67 if ~isempty(FirstImage)68 [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type_ima]=name2display(FirstImage);69 end66 % FirstImage=s.Heading.ImageName; 67 % if ~isempty(FirstImage) 68 % [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type_ima]=name2display(FirstImage); 69 % end 70 70 end 71 71 … … 78 78 xindex=findstr(ImageSize,'x'); 79 79 if length(xindex)>=2 80 npx=str2num(ImageSize(1:xindex(1)-1));81 npy=str2num(ImageSize(xindex(1)+1:xindex(2)-1));82 end 83 end 84 uid_NbSlice=find(t,'/ImaDoc/Camera/NbSlice');85 if ~isempty(uid_NbSlice)86 NbSlice=str2num(get(t,children(t,uid_NbSlice),'value'));87 if isempty(NbSlice),NbSlice=1;end; %default88 end80 % npx=str2num(ImageSize(1:xindex(1)-1)); 81 % npy=str2num(ImageSize(xindex(1)+1:xindex(2)-1)); 82 end 83 end 84 % uid_NbSlice=find(t,'/ImaDoc/Camera/NbSlice'); 85 % if ~isempty(uid_NbSlice) 86 % NbSlice=str2num(get(t,children(t,uid_NbSlice),'value')); 87 % % if isempty(NbSlice),NbSlice=1;end; %default 88 % end 89 89 uid_TimeUnit=find(t,'/ImaDoc/Camera/TimeUnit'); 90 90 if ~isempty(uid_TimeUnit) … … 94 94 if ~isempty(uid_BurstTiming) 95 95 for k=1:length(uid_BurstTiming) 96 Dtj=[];%default97 NbDtj=1;%default96 % Dtj=[];%default 97 % NbDtj=1;%default 98 98 subt=branch(t,uid_BurstTiming(k));%subtree under BurstTiming 99 99 % reading Dtk … … 121 121 % reading Dtk 122 122 Dtk=get_value(subt,'/BurstTiming/Dtk',[]); 123 NbDtk=get_value(subt,'/BurstTiming/NbDtk',1) 123 NbDtk=get_value(subt,'/BurstTiming/NbDtk',1); 124 124 if isempty(Dtk) 125 125 s.Time=[s.Time;Time_val]; … … 141 141 if ~isempty(uid_GeometryCalib) 142 142 if length(uid_GeometryCalib)>1 143 error =['More than one GeometryCalib in ' filecivxml];143 errormsg=['More than one GeometryCalib in ' filecivxml]; 144 144 return 145 145 end … … 149 149 uid_pixcmx=find(subt,'/GeometryCalib/Pxcmx'); 150 150 uid_pixcmy=find(subt,'/GeometryCalib/Pxcmy'); 151 if ~isempty(uid_pixcmx) & ~isempty(uid_pixcmy)%NON UTILISE151 if ~isempty(uid_pixcmx) && ~isempty(uid_pixcmy)%NON UTILISE 152 152 pixcmx=str2num(get(subt,children(subt,uid_pixcmx),'value')); 153 153 if isempty(pixcmx),pixcmx=1;end; %default … … 180 180 uid_Tx_Ty_Tz=find(subt,'/GeometryCalib/Tx_Ty_Tz'); 181 181 uid_R=find(subt,'/GeometryCalib/R'); 182 if ~isempty(uid_focal) & ~isempty(uid_dpx_dpy)& ~isempty(uid_Cx_Cy)182 if ~isempty(uid_focal) && ~isempty(uid_dpx_dpy) && ~isempty(uid_Cx_Cy) 183 183 tsai.f=str2num(get(subt,children(subt,uid_focal),'value')); 184 184 dpx_dpy=str2num(get(subt,children(subt,uid_dpx_dpy),'value')); -
trunk/src/nomtype2pair.m
r19 r29 30 30 % Dtj: ~=0 if i index pairs are used 31 31 32 function [nom_type_pair]=nomtype2pair(nom_type,Dti,Dtj) ;32 function [nom_type_pair]=nomtype2pair(nom_type,Dti,Dtj) 33 33 34 34 %determine nom_type_nc: 35 nom_type_ nc=[];%default35 nom_type_pair=[];%default 36 36 switch nom_type 37 37 case {'_i_j'} -
trunk/src/series.m
r26 r29 55 55 %-------------------------------------------------------------------------- 56 56 function series_OpeningFcn(hObject, eventdata, handles,param) 57 57 global nb_builtin 58 58 % Choose default command line output for series 59 59 handles.output = hObject; … … 129 129 set(handles.filter2,'Value',param.filter2); 130 130 end 131 %set(hObject,'UserData', SeriesData)132 131 set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles}) 133 132 NomType_Callback(hObject, eventdata, handles) 134 %mode_Callback(hObject, eventdata, handles)135 133 136 134 %loads the information stored in prefdir to initiate the browser and the list of functions 137 135 menu_str={'check_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'}; 136 nb_builtin=numel(menu_str); %number of functions 138 137 139 % menu_str=get(handles.ACTION,'String');%list of functions included in 'series.m'140 141 138 %remove from the list the last option 'more...' 142 139 [path_series,name,ext]=fileparts(which('series')); … … 292 289 function MenuBrowse_insert_Callback(hObject, eventdata, handles) 293 290 294 %hseries=get(handles.browse_root,'parent'); 295 RootPathCell=get(handles.RootPath,'String'); 296 % SubDirCell=get(handles.SubDir,'String'); 291 RootPathCell=get(handles.RootPath,'String'); 297 292 RootFileCell=get(handles.RootFile,'String'); 298 293 oldfile=''; %default … … 398 393 % refresh the GUI data after introduction of a new file series 399 394 function update_file(hObject, eventdata, handles,fileinput,addtest) 400 hseries=get(handles.RootPath,'parent'); 395 %hseries=get(handles.RootPath,'parent'); 396 if ~exist(fileinput,'file') 397 msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) 398 return 399 end 400 hseries=handles.figure1; 401 401 % refresh input root name, indices, file extension and nomenclature 402 402 [RootPath,RootFile,field_count,str2,str_a,str_b,FileExt,NomType,SubDir]=name2display(fileinput); 403 403 %check for movie image files 404 if ~isempty(FileExt) 404 405 if ~isempty(imformats(FileExt(2:end))) 405 406 imainfo=imfinfo(fileinput); … … 408 409 [RootPath,RootFile]=fileparts(fileinput); 409 410 end 411 end 410 412 end 411 413 NcType='none';%default … … 492 494 drawnow 493 495 494 % hseries=get(handles.RootFile,'parent');495 % SeriesData=get(hseries,'UserData');%read information set by the browser496 % ext_ima_read=[];497 % field_count=1;%default498 % pxcmx=1;499 % pxcmy=1;500 496 TimeUnit=''; %default 501 % CoordUnit='';%default502 497 time=[];%default 503 498 GeometryCalib=[];%default 504 499 nb_field=[];%default 505 500 nb_field2=[];%default 506 % Heading=[];507 % [PD,Device]=fileparts(RootPathCell{1});508 501 SeriesData.PathCampaign=get(handles.PathCampaign,'String'); 509 502 510 503 % read timing and total frame number from the current file (movie files) !! may be overrid by xml file 511 %icell=length(RootPathCell);512 504 FileBase=fullfile(RootPath,RootFile); 513 505 … … 890 882 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 891 883 function mode_Callback(hObject, eventdata, handles) 892 hseries=get(handles.mode,'parent'); 884 %hseries=get(handles.mode,'parent'); 885 hseries=handles.figure1; 893 886 SeriesData=get(hseries,'UserData'); 894 887 mode_list=get(handles.mode,'String'); … … 991 984 %---------------------------------------------------------------- 992 985 function find_netcpair_civ(hObject, eventdata, handles,Val) 993 hseries=get(handles.list_pair_civ,'parent');994 SeriesData=get(h series,'UserData');986 %hseries=get(handles.list_pair_civ,'parent'); 987 SeriesData=get(handles.figure1,'UserData'); 995 988 % NomTypeCell=get(handles.NomType,'String'); 996 989 NomTypeCell=SeriesData.NomType; … … 1173 1166 SeriesData.displ_num(iview,:)=(displ_num(:,val))'; 1174 1167 SeriesData.ref_time=ref_time; 1175 set(h series,'UserData',SeriesData)1168 set(handles.figure1,'UserData',SeriesData) 1176 1169 list_pair_civ_Callback(hObject, eventdata, handles) 1177 1170 … … 1185 1178 Val=get(handles.RootPath,'Value'); 1186 1179 IndexCell=get(handles.NomType,'String'); 1187 hseries=get(handles.list_pair_civ,'parent');1188 SeriesData=get(h series,'UserData');1180 %hseries=get(handles.list_pair_civ,'parent'); 1181 SeriesData=get(handles.figure1,'UserData'); 1189 1182 NomType=SeriesData.NomType{Val}; 1190 1183 list_pair=get(handles.list_pair_civ,'String');%get the menu of image pairs … … 1247 1240 set(handles.NomType,'String',IndexCell) 1248 1241 SeriesData.displ_num(Val,:)=displ_num; 1249 set(h series,'UserData',SeriesData)1242 set(handles.figure1,'UserData',SeriesData) 1250 1243 % set(handles.NomType,'Value',Val) 1251 1244 … … 1296 1289 %read root name and field type 1297 1290 set(handles.RUN,'BusyAction','queue'); 1298 hseries=get(handles.RUN,'parent');1299 set(0,'CurrentFigure',h series)1291 %hseries=get(handles.RUN,'parent'); 1292 set(0,'CurrentFigure',handles.figure1) 1300 1293 if isequal(get(handles.GetObject,'Value'),1) 1301 1294 Series.GetObject=1; … … 1304 1297 Series.GetObject=0; 1305 1298 end 1306 SeriesData=get(h series,'UserData');1299 SeriesData=get(handles.figure1,'UserData'); 1307 1300 if isfield(SeriesData,'sethandles') 1308 1301 if iscell(SeriesData.sethandles) … … 1488 1481 end 1489 1482 % fct_path 1490 eval(['h_fun=@' action])1483 eval(['h_fun=@' action ';']) 1491 1484 if ~isequal(fct_path,path_series) 1492 1485 rmpath(fct_path)% add the prescribed path if not the current one … … 1532 1525 %---------------------------------------------- 1533 1526 function last_i_Callback(hObject, eventdata, handles) 1534 hseries=get(handles.last_i,'parent');1527 % hseries=get(handles.last_i,'parent'); 1535 1528 first_i=str2num(get(handles.first_i,'String')); 1536 1529 last_i=str2num(get(handles.last_i,'String')); … … 1538 1531 set(handles.ref_i,'String', num2str(ref_i)) 1539 1532 ref_i_Callback(hObject, eventdata, handles) 1540 SeriesData=get(h series,'UserData');1533 SeriesData=get(handles.figure1,'UserData'); 1541 1534 if ~isfield(SeriesData,'Time') 1542 1535 SeriesData.Time{1}=[]; … … 1550 1543 %------------------------------------------------------- 1551 1544 function last_j_Callback(hObject, eventdata, handles) 1552 hseries=get(handles.last_i,'parent');1545 % hseries=get(handles.last_i,'parent'); 1553 1546 first_j=str2num(get(handles.first_j,'String')); 1554 1547 last_j=str2num(get(handles.last_j,'String')); … … 1557 1550 1558 1551 ref_j_Callback(hObject, eventdata, handles) 1559 SeriesData=get(h series,'UserData');1552 SeriesData=get(handles.figure1,'UserData'); 1560 1553 if ~isfield(SeriesData,'Time') 1561 1554 SeriesData.Time{1}=[]; … … 1571 1564 mode_value=get(handles.mode,'Value'); 1572 1565 mode=mode_list{mode_value}; 1573 hseries=get(handles.ref_i,'parent');1574 SeriesData=get(h series,'UserData');1566 %hseries=get(handles.ref_i,'parent'); 1567 SeriesData=get(handles.figure1,'UserData'); 1575 1568 %NomTypeCell=get(handles.NomType,'String'); 1576 1569 NomTypeCell=SeriesData.NomType; … … 1592 1585 mode_value=get(handles.mode,'Value'); 1593 1586 mode=mode_list{mode_value}; 1594 hseries=get(handles.ref_i,'parent'); 1595 SeriesData=get(hseries,'UserData'); 1596 %NomTypeCell=get(handles.NomType,'String'); 1587 %hseries=get(handles.ref_i,'parent'); 1588 SeriesData=get(handles.figure1,'UserData'); 1597 1589 NomTypeCell=SeriesData.NomType; 1598 1590 if ~isempty(NomTypeCell) 1599 Val=get(handles.NomType,'Value'); 1600 NomType=NomTypeCell{Val}; 1601 % NomType=get(handles.NomType,'String'); 1591 Val=get(handles.NomType,'Value'); 1592 NomType=NomTypeCell{Val}; 1602 1593 if isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')|| isequal(NomType,'_i1-i2') 1603 1594 if isequal(mode,'series(Dj)') 1604 1595 find_netcpair_civ(hObject, eventdata, handles,Val);% update the menu of pairs depending on the available netcdf files 1605 % break1606 1596 end 1607 1597 end … … 1611 1601 % --- Executes on selection change in ACTION. 1612 1602 function ACTION_Callback(hObject, eventdata, handles) 1603 global nb_builtin 1613 1604 list_ACTION=get(handles.ACTION,'String');% list menu fields 1614 1605 index_ACTION=get(handles.ACTION,'Value');% selected string index … … 1616 1607 path_series=which('series');%path to series.m 1617 1608 list_path=get(handles.ACTION,'UserData');%list of recorded paths to functions of the list ACTION 1618 nb_builtin=0; 1619 for ilist=1:length(list_path) 1620 if isequal(list_path{ilist},path_series) 1621 nb_builtin=nb_builtin+1; 1622 else 1623 break 1624 end 1625 end 1626 if nb_builtin==0% the path of series has been changed, reinitialize 1627 % series_OpeningFcn(hObject, eventdata, handles) 1628 return 1629 end 1630 1631 % add a new function to the menu 1609 1610 % add a new function to the menu if the selected item is 'more...' 1632 1611 if isequal(ACTION,'more...') 1633 1612 pathfct=fileparts(path_series); 1634 browse_name=fullfile(path_series,'series');%go to UVMAT/SERIES_FCTby default1635 if length(list_path)>nb_builtin1636 browse_name=list_path{end};% initialize browser with the path of the last introduced function1637 end1613 % browse_name=fullfile(path_series,'series');%go to UVMAT/series by default 1614 % if length(list_path)>nb_builtin 1615 % browse_name=list_path{end};% initialize browser with the path of the last introduced function 1616 % end 1638 1617 [FileName, PathName, filterindex] = uigetfile( ... 1639 1618 {'*.m', ' (*.m)'; 1640 1619 '*.m', '.m files '; ... 1641 1620 '*.*', 'All Files (*.*)'}, ... 1642 'Pick a file', browse_name);1621 'Pick a file',list_path{end}); 1643 1622 if length(FileName)<2 1644 1623 return 1645 end 1646 1647 1648 1649 ext_fct=FileName(end-1:end);% to be replaced by fileparts 1624 end 1625 [pp,ACTION,ext_fct]=fileparts(FileName);%(end-1:end); 1650 1626 if ~isequal(ext_fct,'.m') 1651 1627 msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); 1652 1628 return 1653 1629 end 1654 ACTION=FileName(1:end-2);% ACTION choice updated by the selected item1655 1656 addpath(PathName)1657 eval(['h_function=@' ACTION]);1658 if ~isequal(path_series,PathName)1659 rmpath(PathName)1660 end1661 functions(h_function)1662 1630 1663 1631 % insert the choice in the action menu … … 1665 1633 index_ACTION=get(handles.ACTION,'Value');% currently selected index in the list 1666 1634 list_path{index_ACTION}=PathName; 1667 if length(menu_str)>nb_builtin+5; 1635 if length(menu_str)>nb_builtin+5; %nb_builtin=nbre of functions always remaining in the initial menu 1668 1636 nbremove=length(menu_str)-nb_builtin-5; 1669 1637 menu_str(nb_builtin+1:end-5)=[]; … … 1699 1667 %check the current path to the selected function 1700 1668 PathName=list_path{index_ACTION};%current recorded path 1701 if ~isequal(path_series,PathName)1702 CurrentPath=fileparts(which(ACTION));1703 if ~isequal(CurrentPath,PathName)&&~isequal(CurrentPath,fullfile(PathName,'private'))1704 addpath(PathName)1705 errormsg=check_functions;1706 msgbox_uvmat('CONFIRMATION',[['path ' PathName ' added to the current Matlab pathes'];errormsg])1707 end1708 end1669 % if ~isequal(path_series,PathName) 1670 % CurrentPath=fileparts(which(ACTION)); 1671 % if ~isequal(CurrentPath,PathName) 1672 % addpath(PathName) 1673 % errormsg=check_functions; 1674 % msgbox_uvmat('CONFIRMATION',[['path ' PathName ' added to the current Matlab pathes'];errormsg]) 1675 % end 1676 % end 1709 1677 set(handles.path,'String',PathName); %show the path to the senlected function 1710 1678 … … 1743 1711 %set the displayed GUI item needed for input parameters 1744 1712 %list_input=feval(ACTION);% input list asked by the selected function 1745 varargout=feval(ACTION);% input list asked by the selected function 1713 if ~isequal(path_series,PathName) 1714 addpath(PathName) 1715 end 1716 eval(['h_function=@' ACTION ';']); 1717 if ~isequal(path_series,PathName) 1718 rmpath(PathName) 1719 end 1720 1721 varargout=h_function(); 1722 %varargout=feval(ACTION);% input list asked by the selected function 1746 1723 Param_list={}; 1747 1724 % RootPath=get(handles.RootPath,'String'); … … 1875 1852 delete(hget_field)%delete opened versions of get_field 1876 1853 end 1877 hseries=get(handles.FieldMenu,'parent');1878 SeriesData=get(h series,'UserData');1854 %hseries=get(handles.FieldMenu,'parent'); 1855 SeriesData=get(handles.figure1,'UserData'); 1879 1856 filename=SeriesData.CurrentInputFile; 1880 1857 if exist(filename,'file') … … 1903 1880 delete(hget_field) 1904 1881 end 1905 hseries=get(handles.FieldMenu,'parent');1906 SeriesData=get(h series,'UserData');1882 %hseries=get(handles.FieldMenu,'parent'); 1883 SeriesData=get(handles.figure1,'UserData'); 1907 1884 filename=SeriesData.CurrentInputFile_1; 1908 1885 if exist(filename,'file') … … 1919 1896 update_menu(handles.FieldMenu_1,scalar) 1920 1897 end 1921 % %---------------------------------------------------------------------- 1922 % % --makes a time averaged velocity field 1923 % %---------------------------------------------------------------------- 1924 % function aver_vel(num_i1,num_i2,num_j1,num_j2,Series) 1925 % %handles of the GUI series 1926 % 1927 % hseries=guidata(Series.hseries);%handles of the GUI series 1928 % WaitbarPos=get(hseries.waitbar_frame,'Position'); 1929 % Field_list=get(hseries.FieldMenu,'String'); 1930 % val=get(hseries.FieldMenu,'Value'); 1931 % FieldName=Field_list{val(1)}; 1932 % set(hseries.FieldMenu,'Value',val(1))% select only one input field 1933 % if isequal(FieldName,'get_field...') 1934 % hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI 1935 % end 1936 % %root input file and type 1937 % RootPath=get(hseries.RootPath,'String'); 1938 % SubDir=get(hseries.SubDir,'String'); 1939 % RootFile=get(hseries.RootFile,'String'); 1940 % %NomType=get(hseries.NomType,'String'); 1941 % NomType=Series.NomType; 1942 % FileExt=get(hseries.FileExt,'String'); 1943 % ext=FileExt{1}; 1944 % VelType_str=get(hseries.VelTypeMenu,'String'); 1945 % VelType_val=get(hseries.VelTypeMenu,'Value'); 1946 % VelType{1}=VelType_str{VelType_val}; 1947 % 1948 % time=0; %default 1949 % % number of slices 1950 % NbSlice=str2num(get(hseries.NbSlice,'String')); 1951 % if isempty(NbSlice) 1952 % NbSlice=1; 1953 % end 1954 % NbSlice_name=num2str(NbSlice); 1955 % filebase=fullfile(RootPath{1},RootFile{1}); 1956 % Calib=[]; 1957 % if exist([filebase '.xml'],'file') 1958 % %[error,Heading,nom_type_read,ext_ima_read,time_imadoc,TimeUnit,mode,NbSlice,npx,npy,Calib]=read_imadoc([filebase '.xml']); 1959 % [XmlData,warntext]=imadoc2struct([filebase '.xml']); 1960 % end 1961 % if NbSlice==1 1962 % filebase_mean=[filebase '_mean']; %root name for the result 1963 % else 1964 % filebase_mean=[filebase '_' NbSlice_name 'mean']; %root name for the results 1965 % answeryes=questdlg({['will make average in ' num2str(NbSlice) ' slices'];['results stored as files ' filebase_mean ' ...']}); 1966 % if ~isequal(answeryes,'Yes') 1967 % return 1898 1899 1900 % %group the variables (fields of 'FieldData') in cells of variables with the same dimensions 1901 % %%%%%%%%%%%%%%%%%%%%%%% Function independante maintenant 1902 % %----------------------------------------------------------------- 1903 % [CellVarIndex,NbDim,VarTypeCell]=find_field_indices(Data{1}); 1904 % %LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS 1905 % % CellVarIndex=cells of variable index arrays 1906 % ivar_new=0; % index of the current variable in the projected field 1907 % icoord=0; 1908 % for icell=1:length(CellVarIndex) 1909 % if NbDim(icell)==1 1910 % continue 1911 % end 1912 % VarIndex=CellVarIndex{icell};% indices of the selected variables in the list FieldData.ListVarName 1913 % VarType=VarTypeCell{icell}; 1914 % ivar_X=VarType.coord_x; 1915 % ivar_Y=VarType.coord_y; 1916 % ivar_FF=VarType.errorflag; 1917 % if isempty(ivar_X) 1918 % test_grid=1;%test for input data on regular grid (e.g. image)coordinates 1919 % else 1920 % if length(ivar_Y)~=1 1921 % warndlg_uvmat('y coordinate missing in proj_field.m','ERROR') 1922 % return 1923 % end 1924 % test_grid=0; 1925 % end 1926 % % DimIndices=Data{1}.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell) 1927 % %case of input fields with unstructured coordinates 1928 % if ~test_grid 1929 % for ivar=VarIndex 1930 % VarName=MergeData.ListVarName{ivar}; 1931 % for iview=1:nbview 1932 % eval(['MergeData.' VarName '=[MergeData.' VarName '; Data{iview}.' VarName ';']) 1933 % end 1934 % end 1935 % %case of fields defined on a structured grid 1936 % else 1937 % % DimValue=MergeData.DimValue(DimIndices);%set of dimension values 1938 % testFF=0; 1939 % for iview=2:nbview 1940 % % if ~isequal(DimValue,Data{iview}.DimValue(DimIndices)) 1941 % % MergeData.Txt='ERROR: attempt at merging structured fields with different sizes'; 1942 % % return 1943 % % end 1944 % for ivar=VarIndex 1945 % VarName=MergeData.ListVarName{ivar}; 1946 % if isfield(MergeData,'VarAttribute') 1947 % if length(MergeData.VarAttribute)>=ivar && isfield(MergeData.VarAttribute{ivar},'Role') && isequal(MergeData.VarAttribute{ivar}.Role,'errorflag') 1948 % testFF=1; 1949 % end 1950 % end 1951 % eval(['MergeData.' VarName '=MergeData.' VarName '+ Data{iview}.' VarName ';']) 1952 % end 1953 % end 1954 % if testFF 1955 % nbaver=nbview-MergeData.FF; 1956 % indgood=find(nbaver>0); 1957 % for ivar=VarIndex 1958 % VarName=MergeData.ListVarName{ivar}; 1959 % eval(['MergeData.' VarName '(indgood)=double(MergeData.' VarName '(indgood))./nbaver(indgood);']) 1960 % end 1961 % else 1962 % for ivar=VarIndex 1963 % VarName=MergeData.ListVarName{ivar}; 1964 % eval(['MergeData.' VarName '=double(MergeData.' VarName ')./nbview;']) 1965 % end 1966 % end 1968 1967 % end 1969 1968 % end 1970 % siz=size(num_i1); 1971 % nbfield2=siz(1); %nb of consecutive fields at each level(burst) 1972 % lengthtot=siz(1)*siz(2); 1973 % nbfield=floor(lengthtot/(nbfield2*NbSlice));%total number of i indexes (adjusted to an integer number of slices) 1974 % nbfield_slice=nbfield*nbfield2;% number of fields per slice 1975 % %projection object 1976 % GridX=[]; 1977 % GridY=[]; 1978 % if isfield(Series,'sethandles') 1979 % Series.ProjObject=read_set_object(Series.sethandles); 1980 % if isfield(Series.ProjObject,'Style') 1981 % answeryes=questdlg({['statistics on field series projected on ' Series.ProjObject.Style]}); 1982 % if ~isequal(answeryes,'Yes') 1983 % return 1984 % end 1985 % end 1986 % end 1987 % 1988 % %LOOP ON SLICES 1989 % for i_slice=1:NbSlice 1990 % %select the series of image indices at the level islice 1991 % for ifield=1:nbfield 1992 % indselect(:,ifield)=((ifield-1)*NbSlice+(i_slice-1))*nbfield2+[1:nbfield2]';%selected indices on the list of files of a slice 1993 % end 1994 % %name of result file 1995 % [filemean,idetect]=... 1996 % name_generator(filebase_mean,num_i1(i_slice),num_j1(1),Series.FileExt{1},'_i1-i2_j1-j2',1,num_i2(i_slice+nbfield_slice*NbSlice-1),num_j2(end),Series.SubDir{1}); 1997 % 1998 % % field=get(handles.civ1,'UserData');%read current selected field type (civ1,civ2...) 1999 % itime=0; 2000 % dt=[]; 2001 % %LOOP ON FIELDS IN A SLICE 2002 % test_interpolate=0;%default 2003 % for index=1:nbfield*nbfield2 2004 % ifile=indselect(index); 2005 % stopstate=get(hseries.RUN,'BusyAction'); 2006 % if isequal(stopstate,'queue')% enable STOP command 2007 % update_waitbar(hseries.waitbar,WaitbarPos,ifile/(nbfield*nbfield2)) 2008 % %name of the current file 2009 % [filename,idetect]=name_generator(filebase,num_i1(ifile),num_j1(ifile),Series.FileExt{1},Series.NomType{1},1,num_i2(ifile),num_j2(ifile),Series.SubDir{1}); 2010 % %read input file 2011 % itime=itime+1; 2012 % if isequal(FieldName,'get_field...') 2013 % hhget_field=guidata(hget_field);%handles of GUI elements in get_field 2014 % hObject=0; 2015 % eventdata=0; 2016 % SubField=get_field('read_var_names',hObject,eventdata,hhget_field); %read the names of the variables to plot in the get_field GUI 2017 % [Data,var_detect]=nc2struct(filename,SubField.ListVarName); %read input data 2018 % time(itime)=itime; 2019 % dt=1; 2020 % Calib_read=[]; 2021 % else 2022 % [nb_coord,nb_dim,Civ,CivStage,timeread,Data,VelTypeOut,Calib_read]=read_ncfield(filename,VelType{1});%reading the first file 2023 % time(itime)=timeread; 2024 % if isequal(Civ,1) 2025 % Data.CoordType='px';%test for pixel coordinates 2026 % if isequal(itime,1) 2027 % dt=Data.dt; 2028 % elseif ~isequal(Data.dt,dt) 2029 % warndlg_uvmat('series with non constant dt, need phys coordinates','ERROR') 2030 % return 2031 % end 2032 % end 2033 % end 2034 % %increment the detected fields, skip the others 2035 % if idetect==0 2036 % warndlg_uvmat(['input file ' filename ' not found'],'ERROR') 2037 % %A FAIRE STOCKER LE RESULT ACTUEL S'IL EXISTE 2038 % end 2039 % % itime=itime+1; 2040 % % time(itime)=timeread; 2041 % 2042 % %coordinate transform 2043 % if isempty(Calib) 2044 % Calib=Calib_read;%use Calib from xml file in priority, then Calib from the current file 2045 % end 2046 % if ~isequal(Series.CoordType,'') 2047 % Data=feval(Series.CoordType,Data,Calib); 2048 % end 2049 % %projection on object if defined 2050 % if isfield(Series,'ProjObject'); 2051 % Data=proj_field(Data,Series.ProjObject); 2052 % if isequal(itime,1)%use the positions on the first field for the whole series, ou utiliser grille 2053 % if isfield(Data,'Txt')%display error message 2054 % warndlg(Data.Txt,'ERROR') 2055 % return 2056 % end 2057 % end 2058 % else%remove false vectors and interpolate on the positions of the first field 2059 % Data=document_field(Data); 2060 % Data.Style='plane'; 2061 % end 2062 % %%%%%%%%% initiate the average at the first iteration: check list and structure of variables 2063 % if ifile==i_slice%first field in the slice 2064 % testfalse=0; 2065 % ListIndex={}; 2066 % testnewcell=1; 2067 % %group the variables (fields of 'Data') in cells of variables with the same dimensions 2068 % [DimVarIndex,CellVarIndex]=find_field_indices(Data); 2069 % VarIndex=CellVarIndex{1}; % ONLY THE FIRST VAR GROUP IS AVERAGED 2070 % DimIndex=Data.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell) 2071 % MeanData=Data;%transfer heading 2072 % MeanData.Time=[time(1) time(end)]; 2073 % MeanData.Action=Series.Action;%name of the processing programme 2074 % MeanData.ListDimName=Data.ListDimName(DimIndex);%name of dimension 2075 % MeanData.DimValue=Data.DimValue(DimIndex);%values of dimension (nbre of vectors) 2076 % MeanData.ListVarName=Data.ListVarName; 2077 % MeanData.VarDimIndex=Data.VarDimIndex; 2078 % MeanData.ListVarAttribute={'Role'};%list of variable attribute names A FAIRE: transferer les autres attributs 2079 % testsum=ones(size(VarIndex)); 2080 % indexfalse=0; 2081 % CoordName={}; 2082 % indexremove=[]; 2083 % if isfield(Data,'Role') % look for coordinate and flag variables 2084 % for ivar=1:length(VarIndex) 2085 % VarName=Data.ListVarName{VarIndex(ivar)}; 2086 % var_role=Data.Role{VarIndex(ivar)};%'role' of the variable 2087 % MeanData.Role{ivar}=var_role; 2088 % if isequal(var_role,'falseflag') 2089 % indexfalse=ivar; %test for false flag 2090 % indexremove=ivar; 2091 % FFName=VarName; 2092 % testsum(ivar)=0; 2093 % eval(['MeanData=rmfield(MeanData,''' VarName ''');']);%remove variable 2094 % end 2095 % if isequal(var_role,'warnflag') 2096 % testsum(ivar)=0; %do not sum warn flag 2097 % eval(['MeanData=rmfield(MeanData,''' VarName ''');']);%remove variable 2098 % indexremove=[indexremove ivar]; 2099 % end 2100 % if isequal(var_role,'coord_x')| isequal(var_role,'coord_y')|isequal(var_role,'coord_z') 2101 % eval(['MeanData.' VarName '=Data.' VarName ';']); 2102 % testsum(ivar)=0; 2103 % eval(['CoordName=[CoordName ''' VarName '''];']); 2104 % end 2105 % if testsum(ivar)~=0 2106 % eval(['MeanData.' VarName '=zeros(size(Data.' VarName '));']);%initialise sum 2107 % end 2108 % end 2109 % end 2110 % findsum=find(testsum); 2111 % VarIndexSum=VarIndex(findsum);%indices of variables to sum (not coordinates nor flags) 2112 % if length(CoordName)==0 2113 % if isempty(DimVarIndex)|isequal(DimVarIndex,0)% no coordinate variable for structured coordinates, prepare histograms 2114 % for ilist=1:length(VarIndexSum) 2115 % VarName=Data.ListVarName{VarIndexSum(ilist)}; 2116 % eval(['MeanData=rmfield(MeanData,''' VarName ''');']);%remove variable 2117 % indexremove=[indexremove ilist]; 2118 % eval(['[MeanData.' VarName 'hist,MeanData.' VarName 'val]=hist(Data.' VarName ',100);']);%make histo 2119 % eval(['sizhist=size(MeanData.' VarName 'hist);']) 2120 % if sizhist(1)==1 2121 % eval(['MeanData.' VarName 'hist=MeanData.' VarName 'hist'';']) 2122 % end 2123 % eval(['maxval=max(MeanData.' VarName 'val);']); 2124 % eval(['minval=min(MeanData.' VarName 'val);']); 2125 % dC(ilist)=(maxval-minval)/100;%size of the histogram bin 2126 % end 2127 % else 2128 % % icoord=0; 2129 % % for ilist=1:length(DimVarIndex) 2130 % % VarDim=Data.ListVarName{DimVarIndex(ilist)}; 2131 % % icoord=icoord+1; 2132 % % % eval(['Coord{' num2str(icord) '}=[' CoordName ''' VarName ''']']); 2133 % % %eval(['Data.' CoordName{icoord} '=Data.' CoordName{icoord} '(indsel);']); 2134 % % end 2135 % end 2136 % end 2137 % if ~isempty(indexremove) 2138 % MeanData.ListVarName(VarIndex(indexremove))=[]; 2139 % MeanData.VarDimIndex(VarIndex(indexremove))=[]; 2140 % if isfield(MeanData,'Role')%generaliser aus autres attributs 2141 % MeanData.Role(VarIndex(indexremove))=[]; 2142 % end 2143 % end 2144 % % END OF INITIALISATION 2145 % 2146 % end 2147 % 2148 % % A FAIRE: regular grid if coord_x undefined 2149 % if indexfalse~=0 %suppress false data 2150 % eval(['testexist=isfield(Data,''' FFName ''');']) 2151 % if testexist 2152 % eval(['indsel=find(Data.' FFName '==0);']); 2153 % for icoord=1:length(CoordName) 2154 % eval(['Data.' CoordName{icoord} '=Data.' CoordName{icoord} '(indsel);']); 2155 % end 2156 % end 2157 % end 2158 % for ilist=1:length(VarIndexSum) 2159 % VarName=Data.ListVarName{VarIndexSum(ilist)}; 2160 % if indexfalse~=0 & testexist 2161 % eval(['Data.' VarName '=Data.' VarName '(indsel);']); 2162 % end 2163 % if length(CoordName)==0%no variable use dfor unstructured coordinates 2164 % if isempty(DimVarIndex)|isequal(DimVarIndex,0)% no coordinate variable for structured coordinates 2165 % % %update histogram with the current field #ifile 2166 % str_left=['[MeanData.' VarName 'val,MeanData.' VarName 'hist]=']; 2167 % str_right=['hist_update(MeanData.' VarName 'val,MeanData.' VarName 'hist,Data.' VarName ',dC(ilist));']; 2168 % eval([str_left str_right]);%update global histo 2169 % else 2170 % %INTERPOLER 2171 % 2172 % eval(['MeanData.' VarName '=MeanData.' VarName '+Data.' VarName ';']);%increment sum%CAS x,y change 2173 % end 2174 % else 2175 % if length(CoordName)==2 2176 % eval(['test_interp= ~isequal(Data.' CoordName{1} ',MeanData.' CoordName{1} ... 2177 % ')|~isequal(Data.' CoordName{2} ',MeanData.' CoordName{2} ');']) 2178 % if test_interp 2179 % eval(['Data.' VarName '=griddata_uvmat(Data.' CoordName{1} ',Data.' CoordName{2}... 2180 % ',Data.' VarName ',MeanData.' CoordName{1} ',MeanData.' CoordName{2} ');']); 2181 % test_interpolate=1; 2182 % end 2183 % end 2184 % eval(['MeanData.' VarName '=MeanData.' VarName '+Data.' VarName ';']);%increment sum 2185 % end 2186 % end 2187 % end 2188 % end 2189 % if length(CoordName)~=0 | ~isequal(DimVarIndex,0)% no coordinate variable for structured coordinates 2190 % for ilist=1:length(VarIndexSum) 2191 % VarName=Data.ListVarName{VarIndexSum(ilist)}; 2192 % eval(['MeanData.' VarName '=MeanData.' VarName '/itime;']);%normalize sum by the number of fields 2193 % end 2194 % else 2195 % MeanData.NbDim=1; 2196 % MeanData.ListDimName={}; 2197 % MeanData.DimValue=[]; 2198 % for ilist=1:length(VarIndexSum) 2199 % VarName=Data.ListVarName{VarIndexSum(ilist)}; 2200 % MeanData.ListVarName=[MeanData.ListVarName {[VarName 'val']} {[VarName 'hist']}]; 2201 % MeanData.VarDimIndex=[MeanData.VarDimIndex {[ilist]} {[ilist]}]; 2202 % MeanData.ListDimName=[MeanData.ListDimName {[VarName 'val']}]; 2203 % eval(['MeanData.DimValue=[MeanData.DimValue length(MeanData.' VarName 'val)];']); 2204 % end 2205 % end 2206 % figure 2207 % haxes=axes; 2208 % plot_field(MeanData,haxes)%plot the resulting average 2209 % % change variable names for consitency with civ1 data (need to generalize these programs) 2210 % if length(MeanData.ListVarName) >= 4 & isequal(MeanData.ListVarName(1:4), {'X' 'Y' 'U' 'V'}) 2211 % MeanData.ListGlobalAttribute={'nb_coord','nb_dim','dt','absolut_time_T0','pixcmx','pixcmy','hart','civ','fix'}; 2212 % MeanData.nb_coord=2; 2213 % MeanData.nb_dim=2; 2214 % MeanData.dt=1; 2215 % MeanData.absolut_time_T0=0; 2216 % MeanData.pixcmx=1; %pix per cm (1 by default) 2217 % MeanData.pixcmy=1; %pix per cm (1 by default) 2218 % MeanData.hart=0; 2219 % if isequal(Data.CoordType,'px') 2220 % MeanData.civ=1; 2221 % else 2222 % MeanData.civ=0; 2223 % end 2224 % MeanData.fix=0; 2225 % MeanData.ListVarName(1:4)={'vec_X' 'vec_Y' 'vec_U' 'vec_V'}; 2226 % MeanData.vec_X=MeanData.X; 2227 % MeanData.vec_Y=MeanData.Y; 2228 % MeanData.vec_U=MeanData.U; 2229 % MeanData.vec_V=MeanData.V; 2230 % end 2231 % error=struct2nc(filemean,MeanData); %save result file 2232 % if isequal(error,0) 2233 % if test_interpolate 2234 % 'fields interpolated to the positions of the first one' 2235 % end 2236 % [filemean ' written'] 2237 % else 2238 % warndlg_uvmat(error,'ERROR') 2239 % end 2240 % end 2241 2242 %---------------------------------------------------------------------- 2243 % --project fields on a projection object (e. g. a regular grid), possibly 2244 % merge several fields 2245 %---------------------------------------------------------------------- 2246 %INPUT: 2247 %num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) 2248 %num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) 2249 %num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ ) 2250 %num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ) 2251 %OTHER INPUTS given by the structure Series 2252 function GUI_input=merge_proj(num_i1,num_i2,num_j1,num_j2,Series); 2253 2254 %requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION) 2255 if ~exist('num_i1','var') 2256 GUI_input={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one') 2257 'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default) 2258 'RootFile';'on';... %root input file name ('on' by default) 2259 'FileExt';'on';... %input file extension ('on' by default) 2260 'NomType';'on';...%type of file indexing ('on' by default) 2261 'NbSlice';'on'; ...%nbre of slices ('off' by default) 2262 'VelTypeMenu';'one';...% menu for selecting the velocity type (civ1,..) options 'off'/'one'/'two', 'off' by default) 2263 'FieldMenu';'one';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) 2264 'CoordType';'on';...%can use a transform function 'off' by default 2265 'GetObject';'on';...%can use projection object ,'off' by default 2266 %'GetMask';'on'...%can use mask option ,'off' by default 2267 %'PARAMETER'; options: name of the user defined parameter',repeat a line for each parameter 2268 ''}; 2269 return %exit the function 2270 end 2271 2272 %------------------------------------------------- 2273 hseries=guidata(Series.hseries);%handles of the GUI series 2274 WaitbarPos=get(hseries.waitbar_frame,'Position'); %positiopn of waitbar frame 2275 %------------------------------------------------- 2276 2277 %numbers of view fields (nbre of inputs in RootPath) 2278 testcell=iscell(Series.RootFile); 2279 if ~testcell 2280 Series.RootPath={Series.RootPath}; 2281 Series.RootFile={Series.RootFile}; 2282 Series.SubDir={Series.SubDir}; 2283 Series.FileExt={Series.FileExt}; 2284 Series.NomType={Series.NomType}; 2285 num_i1={num_i1}; 2286 num_i2={num_i2}; 2287 num_j1={num_j1}; 2288 num_j2={num_j2}; 2289 end 2290 nbview=length(Series.RootFile);%number of views (file series to merge) 2291 nbfield=size(num_i1{1},1)*size(num_i1{1},2);%number of fields in the time series 2292 transform=Series.CoordType; % field transform function 2293 hhh=which('mmreader'); 2294 for iview=1:nbview 2295 test_movie(iview)=0; 2296 if ~isequal(hhh,'')&& mmreader.isPlatformSupported() 2297 if isequal(lower(FileExt{iview}),'.avi') 2298 MovieObject{iview}=mmreader(fullfile(RootPath{iview},[RootFile{iview} FileExt{iview}])); 2299 test_movie(iview)=1; 2300 end 2301 end 2302 end 2303 2304 %Calibration data and timing: read the ImaDoc files 2305 mode=''; %default 2306 timecell={}; 2307 itime=0; 2308 NbSlice_calib={}; %test for z index 2309 for iview=1:nbview%Loop on views 2310 XmlData{iview}=[];%default 2311 filebase{iview}=fullfile(Series.RootPath{iview},Series.RootFile{iview}); 2312 if exist([filebase{iview} '.xml'],'file') 2313 [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']); 2314 if isfield(XmlData{iview},'Time') 2315 itime=itime+1; 2316 timecell{itime}=XmlData{iview}.Time; 2317 end 2318 if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') 2319 NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1); 2320 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) 2321 msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); 2322 end 2323 end 2324 elseif exist([filebase{iview} '.civ'],'file') 2325 [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']); 2326 itime=itime+1; 2327 timecell{itime}=time; 2328 XmlData{iview}.Time=time; 2329 GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0]; 2330 GeometryCalib.Tx=0; 2331 GeometryCalib.Ty=0; 2332 GeometryCalib.Tz=1; 2333 GeometryCalib.dpx=1; 2334 GeometryCalib.dpy=1; 2335 GeometryCalib.sx=1; 2336 GeometryCalib.Cx=0; 2337 GeometryCalib.Cy=0; 2338 GeometryCalib.f=1; 2339 GeometryCalib.kappa1=0; 2340 GeometryCalib.CoordUnit='cm'; 2341 XmlData{iview}.GeometryCalib=GeometryCalib; 2342 if error==1 2343 msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); 2344 end 2345 end 2346 end 2347 2348 %check coincidence in time 2349 multitime=0; 2350 if length(timecell)==0 2351 time=[]; 2352 elseif length(timecell)==1 2353 time=timecell{1}; 2354 elseif length(timecell)>1 2355 multitime=1; 2356 for icell=1:length(timecell) 2357 if ~isequal(size(timecell{icell}),size(timecell{1})) 2358 msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used') 2359 time=timecell{1}; 2360 multitime=0; 2361 break 2362 end 2363 end 2364 end 2365 if multitime 2366 for icell=1:length(timecell) 2367 time(icell,:,:)=timecell{icell}; 2368 end 2369 diff_time=max(max(diff(time))); 2370 if diff_time>0 2371 msgbox_uvmat('WARNING',['times of series differ by more than ' num2str(diff_time)]) 2372 end 2373 end 2374 if size(time,2) < num_i2{1}(end) || size(time,3) < num_j2{1}(end)% ime array absent or too short in ImaDoc xml file' 2375 time=[]; 2376 end 2377 2378 % Field and velocity type (the same for all views) 2379 Field_str=get(hseries.FieldMenu,'String'); 2380 val=get(hseries.FieldMenu,'Value'); 2381 FieldName=Field_str(val);%the same set of fields for all views 2382 VelType_str=get(hseries.VelTypeMenu,'String'); 2383 VelType_val=get(hseries.VelTypeMenu,'Value'); 2384 VelType=VelType_str{VelType_val}; %the same for all views 2385 if isequal(FieldName,'get_field...') 2386 hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI 2387 % hhget_field=guidata(hget_field);%handles of GUI elements in get_field 2388 SubField=get_field('read_get_field',hObject,eventdata,hget_field); %read the names of the variables to plot in the get_field GUI 2389 % if isequal(get(hhget_field.menu_coord,'Visible'),'on') 2390 % list_transform=get(hhget_field.menu_coord,'String'); 2391 % val_list=get(hhget_field.menu_coord,'Value'); 2392 % transform=list_transform{val_list}; 2393 % end 2394 end 2395 %detect whether all the files are 'images' or 'netcdf' 2396 testima=0; 2397 testvol=0; 2398 testcivx=0; 2399 testnc=0; 2400 FileExt=get(hseries.FileExt,'String'); 2401 for iview=1:nbview 2402 ext=FileExt{iview}; 2403 form=imformats(ext([2:end])); 2404 if isequal(lower(ext),'.vol') 2405 testvol=testvol+1; 2406 elseif ~isempty(form)||isequal(lower(ext),'.avi')% if the extension corresponds to an image format recognized by Matlab 2407 testima=testima+1; 2408 elseif isequal(ext,'.nc') 2409 testnc=testnc+1; 2410 end 2411 end 2412 if testvol 2413 msgbox_uvmat('ERROR','volume images not implemented yet') 2414 return 2415 end 2416 if testnc~=nbview && testima~=nbview && testvol~=nbview 2417 msgbox_uvmat('ERROR','need a set of images or a set of netcdf files with the same fields as input') 2418 return 2419 end 2420 if ~isequal(FieldName,'get_field...') 2421 testcivx=testnc; 2422 end 2423 %name of output files and directory: 2424 % res_subdir=fullfile(Series.RootPath{1},[Series.SubDir{1} '_STAT']); 2425 ProjectDir=fileparts(fileparts(Series.RootPath{1}));% preoject directory (GERK) 2426 prompt={['result directory (in' ProjectDir ')']}; 2427 RootPath=get(hseries.RootPath,'String'); 2428 SubDir=get(hseries.SubDir,'String'); 2429 if isequal(length(RootPath),1) 2430 fulldir=RootPath{1}; 2431 subdir='GRID'; 2432 res_subdir=fullfile(fulldir,subdir); 2433 else 2434 def={fullfile(ProjectDir,'0_RESULTS')}; 2435 dlgTitle='result directory'; 2436 lineNo=1; 2437 answer=msgbox_uvmat('INPUT_TXT',dlgTitle,def); 2438 fulldir=answer{1}; 2439 subdir=[]; 2440 dirlist=sort(Series.RootFile); 2441 for iview=1:nbview 2442 if ~isempty(subdir) 2443 subdir=[subdir '-']; 2444 end 2445 subdir=[subdir dirlist{iview}]; 2446 end 2447 res_subdir=fullfile(fulldir,subdir); 2448 end 2449 ext=FileExt{1}; 2450 if ~exist(fulldir,'dir') 2451 msgbox_uvmat('ERROR',['directory ' fulldir ' needs to be created']) 2452 return 2453 end 2454 if ~exist(res_subdir,'dir') 2455 dircur=pwd; 2456 cd(fulldir) 2457 error=mkdir(subdir); 2458 cd(dircur) 2459 end 2460 filebasesub=fullfile(res_subdir,Series.RootFile{1}); 2461 filebase_merge=fullfile(res_subdir,'merged');%root name for the merged files 2462 2463 %projection object 2464 if isfield(Series,'sethandles') 2465 if ishandle(Series.sethandles.set_object) 2466 Series.ProjObject=read_set_object(Series.sethandles); 2467 if ~isfield(Series.ProjObject,'Style') 2468 msgbox_uvmat('ERROR','Undefined projection object style') 2469 return 2470 end 2471 if ~isequal(Series.ProjObject.Style,'plane') 2472 msgbox_uvmat('ERROR','The projection object must be a plane') 2473 return 2474 end 2475 end 2476 end 2477 2478 %MAIN LOOP 2479 for ifile=1:nbfield 2480 stopstate=get(hseries.RUN,'BusyAction'); 2481 if isequal(stopstate,'queue')% enable STOP command from the 'series' interface 2482 update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield) 2483 Amerge=0; 2484 2485 %----------LOOP ON VIEWS---------------------- 2486 nbtime=0; 2487 for iview=1:nbview 2488 %name of the current file 2489 filename=name_generator(filebase{iview},num_i1{iview}(ifile),num_j1{iview}(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile),SubDir{iview}); 2490 if ~exist(filename,'file') 2491 msgbox_uvmat('ERROR',['missing input file' filename]) 2492 break 2493 end 2494 2495 %reading the current file 2496 if testima 2497 if test_movie(iview) 2498 Field{iview}.A=read(MovieObject{iview},num_i1{iview}(ifile)); 2499 else 2500 Field{iview}.A=read_image(filename,Series.NomType{iview},num_i1{iview}(ifile)); 2501 end % TODO: introduce ListVarName 2502 npxy=size(Field{iview}.A); 2503 Field{iview}.AX=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers 2504 Field{iview}.AY=[npxy(1)-0.5 0.5]; 2505 Field{iview}.CoordType='px'; 2506 Field{iview}.AName='image'; 2507 else 2508 if testcivx 2509 [Field{iview},VelTypeOut]=read_civxdata(filename,FieldName,VelType); 2510 else 2511 [Field{iview},var_detect]=nc2struct(filename,SubField.ListVarName); %read the corresponding input data 2512 Field{iview}.VarAttribute=SubField.VarAttribute; 2513 end 2514 if isfield(Field{iview},'Time') 2515 timeread(iview)=Field{iview}.Time; 2516 nbtime=nbtime+1; 2517 end 2518 end 2519 % coord transform 2520 % z index 2521 if ~isempty(NbSlice_calib) 2522 Field{iview}.ZIndex=mod(num_i1{iview}(ifile)-1,NbSlice_calib{1})+1; 2523 end 2524 if ~isequal(transform,'') 2525 Field{iview}=feval(Series.CoordType,Field{iview},XmlData{iview});%transform to phys if requested 2526 end 2527 if testcivx 2528 Field{iview}=calc_field(FieldName,Field{iview}); 2529 end 2530 2531 %projection on object (gridded plane) 2532 if isfield(Series,'ProjObject') 2533 Field{iview}=proj_field(Field{iview},Series.ProjObject); 2534 end 2535 end 2536 2537 %----------END LOOP ON VIEWS---------------------- 2538 2539 %merge the nbview fields 2540 MergeData=merge_field(Field); 2541 if isfield(MergeData,'Txt') 2542 msgbox_uvmat('ERROR',MergeData.Txt) 2543 return 2544 end 2545 2546 % generating the name of the merged field 2547 mergename=name_generator(filebase_merge,num_i1{iview}(ifile),num_j1{iview}(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile)); 2548 2549 % time: 2550 time_i=0;%default 2551 if isempty(time)% time from ImaDoc prevails 2552 time_i=sum(timeread)/nbtime; 2553 else 2554 time_i=(time(iview,num_i1{iview}(ifile),num_j1{iview}(ifile))+time(iview,num_i2{iview}(ifile),num_j2{iview}(ifile)))/2; 2555 end 2556 2557 % recording the merged field 2558 if testima %in case of input images an image is produced 2559 if isa(MergeData.A,'uint8') 2560 bitdepth=8; 2561 elseif isa(MergeData.A,'uint16') 2562 bitdepth=16; 2563 end 2564 imwrite(MergeData.A,mergename,'BitDepth',bitdepth); 2565 %write xml calibration file 2566 siz=size(MergeData.A); 2567 npy=siz(1); 2568 npx=siz(2); 2569 if isfield(MergeData,'VarAttribute')&&isfield(MergeData.VarAttribute{1},'Coord_2')&&isfield(MergeData.VarAttribute{1},'Coord_1') 2570 Rangx=MergeData.VarAttribute{1}.Coord_2; 2571 Rangy=MergeData.VarAttribute{1}.Coord_1; 2572 elseif isfield(MergeData,'AX')&& isfield(MergeData,'AY') 2573 Rangx=[MergeData.AX(1) MergeData.AX(end)]; 2574 Rangy=[MergeData.AY(1) MergeData.AY(end)]; 2575 else 2576 Rangx=[0.5 npx-0.5]; 2577 Rangy=[npy-0.5 0.5];%default 2578 end 2579 pxcmx=(npx-1)/(Rangx(2)-Rangx(1)); 2580 pxcmy=(npy-1)/(Rangy(1)-Rangy(2)); 2581 T_x=-pxcmx*Rangx(1)+0.5; 2582 T_y=-pxcmy*Rangy(2)+0.5; 2583 GeometryCal.focal=1; 2584 GeometryCal.R=[pxcmx,0,0;0,pxcmy,0;0,0,1]; 2585 GeometryCal.Tx_Ty_Tz=[T_x T_y 1]; 2586 ImaDoc.GeometryCalib=GeometryCal; 2587 t=struct2xml(ImaDoc); 2588 t=set(t,1,'name','ImaDoc'); 2589 save(t,[filebase_merge '.xml']) 2590 display([filebase_merge '.xml saved']) 2591 else 2592 MergeData.ListGlobalAttribute={'Project','InputFile_1','InputFile_end','nb_coord','nb_dim','dt','Time','civ'}; 2593 MergeData.nb_coord=2; 2594 MergeData.nb_dim=2; 2595 MergeData.dt=1; 2596 MergeData.Time=time_i; 2597 error=struct2nc(mergename,MergeData); %save result file 2598 if isempty(error) 2599 display(['output file ' mergename ' written']) 2600 else 2601 display(error) 2602 end 2603 end 2604 end 2605 end 2606 2607 %-------------------------------------------------------------------------- 2608 function MergeData=merge_field(Data) 2609 % initiate Matlab structure for physical field 2610 if isempty(Data)||~iscell(Data) 2611 MergeData=[]; 2612 return 2613 end 2614 MergeData=Data{1};%default 2615 error=0; 2616 nbview=length(Data); 2617 if nbview==1 2618 return 2619 end 2620 for iview=1:nbview 2621 if ~isequal(MergeData.ListDimName,Data{iview}.ListDimName) 2622 error=1; 2623 end 2624 if ~isequal(MergeData.ListVarName,Data{iview}.ListVarName) 2625 error=1; 2626 end 2627 % if ~isequal(MergeData.VarDimIndex,Data{iview}.VarDimIndex) 2628 % error=1; 2629 % end 2630 end 2631 if error 2632 MergeData.Txt='ERROR: attempt at merging fields of incompatible type'; 2633 return 2634 end 2635 %group the variables (fields of 'FieldData') in cells of variables with the same dimensions 2636 %----------------------------------------------------------------- 2637 [CellVarIndex,NbDim,VarTypeCell]=find_field_indices(Data{1}); 2638 %LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS 2639 % CellVarIndex=cells of variable index arrays 2640 ivar_new=0; % index of the current variable in the projected field 2641 icoord=0; 2642 for icell=1:length(CellVarIndex) 2643 if NbDim(icell)==1 2644 continue 2645 end 2646 VarIndex=CellVarIndex{icell};% indices of the selected variables in the list FieldData.ListVarName 2647 VarType=VarTypeCell{icell}; 2648 ivar_X=VarType.coord_x; 2649 ivar_Y=VarType.coord_y; 2650 ivar_FF=VarType.errorflag; 2651 if isempty(ivar_X) 2652 test_grid=1;%test for input data on regular grid (e.g. image)coordinates 2653 else 2654 if length(ivar_Y)~=1 2655 warndlg_uvmat('y coordinate missing in proj_field.m','ERROR') 2656 return 2657 end 2658 test_grid=0; 2659 end 2660 % DimIndices=Data{1}.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell) 2661 %case of input fields with unstructured coordinates 2662 if ~test_grid 2663 for ivar=VarIndex 2664 VarName=MergeData.ListVarName{ivar}; 2665 for iview=1:nbview 2666 eval(['MergeData.' VarName '=[MergeData.' VarName '; Data{iview}.' VarName ';']) 2667 end 2668 end 2669 %case of fields defined on a structured grid 2670 else 2671 % DimValue=MergeData.DimValue(DimIndices);%set of dimension values 2672 testFF=0; 2673 for iview=2:nbview 2674 % if ~isequal(DimValue,Data{iview}.DimValue(DimIndices)) 2675 % MergeData.Txt='ERROR: attempt at merging structured fields with different sizes'; 2676 % return 2677 % end 2678 for ivar=VarIndex 2679 VarName=MergeData.ListVarName{ivar}; 2680 if isfield(MergeData,'VarAttribute') 2681 if length(MergeData.VarAttribute)>=ivar && isfield(MergeData.VarAttribute{ivar},'Role') && isequal(MergeData.VarAttribute{ivar}.Role,'errorflag') 2682 testFF=1; 2683 end 2684 end 2685 eval(['MergeData.' VarName '=MergeData.' VarName '+ Data{iview}.' VarName ';']) 2686 end 2687 end 2688 if testFF 2689 nbaver=nbview-MergeData.FF; 2690 indgood=find(nbaver>0); 2691 for ivar=VarIndex 2692 VarName=MergeData.ListVarName{ivar}; 2693 eval(['MergeData.' VarName '(indgood)=double(MergeData.' VarName '(indgood))./nbaver(indgood);']) 2694 end 2695 else 2696 for ivar=VarIndex 2697 VarName=MergeData.ListVarName{ivar}; 2698 eval(['MergeData.' VarName '=double(MergeData.' VarName ')./nbview;']) 2699 end 2700 end 2701 end 2702 end 2703 2704 2705 1969 % 2706 1970 2707 1971 %----------------------------- -
trunk/src/series/aver_stat.m
r27 r29 32 32 WaitbarPos=get(hseries.waitbar_frame,'Position'); 33 33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34 35 34 %root input file and type 36 35 if ~iscell(Series.RootPath)% case of a single input field series … … 235 234 236 235 % Root name of output files (TO GENERALISE FOR TWO INPUT SERIES) 237 filebasesub=fullfile(RootPath{1},SubDir{1},RootFile{1}); 238 if isempty(SubDir{1}) % create a subdirectory '/mean' 239 subdir_result='mean'; 236 subdir_result='aver_stat'; 237 % filebasesub=fullfile(RootPath{1},subdir_result,RootFile{1}); 238 % if isempty(SubDir{1}) % create a subdirectory '/aver_stat' 239 % subdir_result='aver_stat'; 240 240 % filebasemean=fullfile(RootPath{1},subdir_result); 241 242 243 244 245 246 247 248 249 250 251 else252 subdir_result=SubDir{1};253 filebase_out=[filebase{1} '_mean'];% output root name obtained by adding the suffix _mean to the input254 end241 if ~exist(fullfile(RootPath{1},subdir_result),'dir') 242 dircur=pwd; %record current working directory 243 cd(RootPath{1})% goes to the iamge directory 244 [m1,m2,m3]=mkdir(subdir_result); 245 if ~isequal(m2,'') 246 msgbox_uvmat('CONFIRMATION',m2);%error message for directory creation 247 end 248 cd(dircur) %back to the initial working directory 249 end 250 filebase_out=filebase{1}; 251 % else 252 % subdir_result=SubDir{1}; 253 % filebase_out=[filebase{1} '_mean'];% output root name obtained by adding the suffix _mean to the input 254 % end 255 255 %output nomtype (to generalise) 256 256 NomTypeOut=nomtype2pair(NomType{1},num_i2{end}(end)-num_i1{1}(1),num_j2{end}(end)-num_j1{1}(1)); 257 257 258 if NbSlice==1259 filebase_out=[filebasesub '_mean'];260 else261 filebase_out=[filebasesub '_' NbSlice_name 'mean'];262 answeryes=questdlg({['will make average in ' num2str(NbSlice) ' slices'];['results stored as files ' filebase_out ' ...']});263 if ~isequal(answeryes,'Yes')264 return265 end266 end258 % if NbSlice==1 259 % filebase_out=[filebasesub '_mean']; 260 % else 261 % filebase_out=[filebasesub '_' NbSlice_name 'mean']; 262 % answeryes=questdlg({['will make average in ' num2str(NbSlice) ' slices'];['results stored as files ' filebase_out ' ...']}); 263 % if ~isequal(answeryes,'Yes') 264 % return 265 % end 266 % end 267 267 268 268 % coordinate transform or other user defined transform … … 394 394 %writing the result file 395 395 if testima 396 if NbSlice==1397 [filemean]=name_generator(filebase_out,num_i1{1}(1),num_j1{1}(1),'.png',NomTypeOut,1,num_i2{end}(end),num_j2{end}(end) );398 else % label the file number by the slice # for simplicity399 [filemean]=name_generator(filebase_out,i_slice,1,'.png','_i');400 end396 % if NbSlice==1 397 [filemean]=name_generator(filebase_out,num_i1{1}(1),num_j1{1}(1),'.png',NomTypeOut,1,num_i2{end}(end),num_j2{end}(end),subdir_result); 398 % else % label the file number by the slice # for simplicity 399 % [filemean]=name_generator(filebase_out,i_slice,1,'.png','_i'); 400 % end 401 401 if exist(filemean,'file') 402 402 backupfile=filemean; … … 429 429 DataMean.ListGlobalAttribute=[DataMean.ListGlobalAttribute {'Time','Time_end'}]; 430 430 end 431 if NbSlice==1432 filemean=name_generator(filebase_out,num_i1{1}(1),num_j1{1}(1),'.nc',NomTypeOut,1,num_i2{end}(end),num_j2{end}(end) );433 else % label the file number by the slice # for simplicity434 [filemean]=name_generator(filebase_out,i_slice,1,'.nc','_i');435 end431 % if NbSlice==1 432 filemean=name_generator(filebase_out,num_i1{1}(1),num_j1{1}(1),'.nc',NomTypeOut,1,num_i2{end}(end),num_j2{end}(end),subdir_result); 433 % else % label the file number by the slice # for simplicity 434 % [filemean]=name_generator(filebase_out,i_slice,1,'.nc','_i'); 435 % end 436 436 if exist(filemean,'file') 437 437 backupfile=filemean; … … 459 459 hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI 460 460 delete(hget_field) 461 'TEST'462 461 uvmat(filemean) -
trunk/src/update_imadoc.m
r17 r29 10 10 testappend=0; 11 11 if exist(outputfile,'file');%=1 if the output file already exists, 0 else 12 testappend=1; 12 13 t=xmltree(outputfile); %read the file 13 14 backupfile=outputfile; … … 28 29 [t,uid_calib]=add(t,1,'element','GeometryCalib'); 29 30 else %if GeometryCalib already exists, delete its content 30 % backupfile=outputfile;31 % testexist=2;32 % while testexist==233 % backupfile=[backupfile '~'];34 % testexist=exist(backupfile,'file');35 % end36 % [success,message]=copyfile(outputfile,backupfile);%make backup37 31 if isequal(success,1) 38 32 delete(outputfile) … … 42 36 uid_child=children(t,uid_calib); 43 37 t=delete(t,uid_child); 44 testappend=1;45 38 end 46 39 end … … 49 42 t=set(t,1,'name','ImaDoc'); 50 43 [t,uid_calib]=add(t,1,'element','GeometryCalib'); 51 % t=struct2xml(GeometryCalib,t,uid_calib);52 44 end 53 45 t=struct2xml(GeometryCalib,t,uid_calib); -
trunk/src/uvmat.m
r17 r29 470 470 %---------------------------------------------------------------- 471 471 function display_file_name(hObject, eventdata, handles,fileinput) 472 if ~exist(fileinput,'file') 473 msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) 474 return 475 end 472 476 [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput); 473 form=imformats(ext(2:end));%test valid Matlab image formats 474 if ~isempty(form) 475 ext_test='.image'; 476 imainfo=imfinfo(fileinput); 477 if length(imainfo) >1 %case of image with multiple frames 477 ext_test=''; %default 478 if ~isempty(ext) 479 form=imformats(ext(2:end));%test valid Matlab image formats 480 if ~isempty(form) 481 ext_test='.image'; 482 imainfo=imfinfo(fileinput); 483 if length(imainfo) >1 %case of image with multiple frames 484 i1='1'; % set the frame counter to 1 by default 485 i2=''; 486 str_a=''; 487 str_b=''; 488 NomType='*'; %indicate a set of indexed frames within a single file 489 [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file 490 end 491 elseif isequal(lower(ext),'.avi') 492 ext_test='.image'; 478 493 i1='1'; % set the frame counter to 1 by default 479 494 i2=''; … … 482 497 NomType='*'; %indicate a set of indexed frames within a single file 483 498 [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file 484 end 485 elseif isequal(lower(ext),'.avi') 486 ext_test='.image'; 487 i1='1'; % set the frame counter to 1 by default 488 i2=''; 489 str_a=''; 490 str_b=''; 491 NomType='*'; %indicate a set of indexed frames within a single file 492 [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file 493 else 494 ext_test=lower(ext); 499 else 500 ext_test=lower(ext); 501 end 495 502 end 496 503 switch ext_test
Note: See TracChangeset
for help on using the changeset viewer.