Changeset 512 for trunk/src/uvmat.m
- Timestamp:
- Aug 3, 2012, 2:50:24 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uvmat.m
r511 r512 51 51 % 52 52 % 1) Input filenames are determined by MenuBrowse (first field), MenuBrowse_1 53 % (second field), or by the stored file names under Browse, or as an input of uvmat. 54 % 2) These functions call 'display_file_name.m' which detects the file series, and fills the file index boxes 55 % 3) Then 'update_rootinfo.m' Updates information about a new field series (indices to scan, timing, calibration from an xml file) 56 % 4) Then fields are opened and visualised by the main sub-function 'refresh_field.m' 57 % The function first reads the name of the input file from the edit boxes of the GUI 58 % A second input file can be introduced for file comparison 59 % It then reads the input file(s) with the appropriate function, read for 60 % images, read_civxdata.m for CIVx PIV data, nc2struct for other netcdf 61 % files. 62 % Main input open second input open(_1) second image (pair animation) 63 % | | 64 % | | 65 % Field{1} Field{2} 66 % | 67 % coord transform (phys.m) or other user defined fct acting on Field{i} | 68 % Field{i} 69 % | 70 % calc_field.m: calculate scalar or other derived fields (vort, div..). 53 % (second field), or by the stored file name .FileName_1, or as an input of uvmat. 54 % 2) These functions call 'uvmat/display_file_name.m' which detects the file series, and fills the file index boxes 55 % 3) Then 'uvmat/update_rootinfo.m' Updates information about a new field series (indices to scan, timing, calibration from an xml file) 56 % 4) Then fields are opened and visualised by the main sub-function 'uvmat/refresh_field.m' 57 % The function first reads the name of the input file(s) (one or two) from the edit boxes of the GUI 58 % It then reads the input file(s) with the function read_field.m and perform the following list of operations: 71 59 % 72 % sub_field.m: combine the input Field{i} in a single set of fields (vector + scalar): 73 % Field{i=1->3}.X --> UvData.X | 74 % | 75 % UvData 76 % | 77 % plot histograms of the whole field 78 % proj_field.m: project the set of fields on the current projection objects defined by UvData.Object 79 % | | 80 % ObjectData 81 % | 82 % plot_field.m: plot the projected fields and store them as | 83 % UvData.PlotAxes | 84 % | 85 % AxeData 60 % %%%%%%%% structure of uvmat/refresh_field.m %%%%%%%% 61 % 62 % Main input open second input open_1 63 % | | 64 % read_field.m read_field.m 65 % | | 66 % Field{1} Field{2} 67 % | | 68 % --->transform fct<--- transform (e.g. phys.m) and combine input fields 69 % | 70 % (calc_tps.m) calculate tps coefficients (for filter projection or spatial derivatives). 71 % | 72 % (calc_field.m) calculate field 73 % | 74 % UvData.Field-------------->histogram 75 % _____________|____________ 76 % | | 77 % proj_field.m proj_field.m project the field on the projection objects 78 % | | 79 % UvData.PlotAxes ViewData.PlotAxes (on view_field) 80 % | | 81 % plot_field.m (uvmat) plot_field.m (view_field) plot the projected fields 82 % 83 % rmq: calc_field can be performed instead at the level of proj_field when needed 84 % 86 85 % 87 86 %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%% … … 357 356 function MenuBrowse_Callback(hObject, eventdata, handles) 358 357 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 359 oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 358 %oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 359 oldfile=fullfile(RootPath,SubDir); 360 360 if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box 361 361 dir_perso=prefdir; … … 371 371 fileinput=[PathName FileName];%complete file name 372 372 if ~exist(fileinput,'file') 373 return %abandon of the browser is cancelled373 return %abandon if the browser is cancelled 374 374 end 375 375 … … 1014 1014 end 1015 1015 end 1016 [ref_ i,ref_j]=find(i1_series);1016 [ref_j,ref_i]=find(i1_series); 1017 1017 if ~isempty(j1_series) 1018 1018 state_j='on'; … … 1583 1583 if get(handles.scan_i,'Value')==1% case of scanning along index i 1584 1584 ref_i=ref_i+step; 1585 while ref_i>=0 && size(UvData.i1_series{1}, 1)>=ref_i+1 && UvData.i1_series{1}(ref_i+1,ref_j+1,1)==01585 while ref_i>=0 && size(UvData.i1_series{1},3)>=ref_i+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0 1586 1586 ref_i=ref_i+step; 1587 1587 end 1588 1588 else % case of scanning along index j (burst numbers) 1589 1589 ref_j=ref_j+step; 1590 while ref_j>=0 && size(UvData.i1_series{1},2)>=ref_j+1 && UvData.i1_series{1}( ref_i+1,ref_j+1,1)==01590 while ref_j>=0 && size(UvData.i1_series{1},2)>=ref_j+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0 1591 1591 ref_j=ref_j+step; 1592 1592 end … … 1597 1597 elseif ref_j<0 1598 1598 errormsg='minimum j index reached'; 1599 elseif ref_i+1>size(UvData.i1_series{1}, 1)1599 elseif ref_i+1>size(UvData.i1_series{1},3) 1600 1600 errormsg='maximum i index reached (reload the input file to update the index bound)'; 1601 1601 elseif ref_j+1>size(UvData.i1_series{1},2) … … 1603 1603 end 1604 1604 if ~isempty(errormsg),return,end 1605 i1_subseries=UvData.i1_series{1}(ref_i+1,ref_j+1,:); 1606 i1_subseries=i1_subseries(i1_subseries>0); 1607 if isempty(i1_subseries)% case of pairs 1608 i1_subseries=UvData.i1_series{1}(ref_i+1,:,:); 1609 end 1610 if isempty(i1_subseries),errormsg='no next frame: set num_IndexIncrement =''*'' to reach the next existing file';return 1611 else 1612 i1=i1_subseries(end); 1613 end 1605 siz=size(UvData.i1_series{1}); 1606 ref_indices=ref_i*siz(1)*siz(2)+ref_j*siz(1)+1:ref_i*siz(1)*siz(2)+(ref_j+1)*siz(1); 1607 i1_subseries=UvData.i1_series{1}(ref_indices); 1608 ref_indices=ref_indices(i1_subseries>0); 1609 if isempty(ref_indices)% case of pairs (free index i) 1610 ref_indices=ref_i*siz(1)*siz(2)+1:(ref_i+1)*siz(1)*siz(2); 1611 i1_subseries=UvData.i1_series{1}(ref_indices); 1612 ref_indices=ref_indices(i1_subseries>0); 1613 end 1614 if isempty(ref_indices),errormsg='no next frame: set num_IndexIncrement =''*'' to reach the next existing file';return 1615 end 1616 i1=UvData.i1_series{1}(ref_indices(end)); 1614 1617 if ~isempty(UvData.i2_series{1}) 1615 i2_subseries=UvData.i2_series{1}(ref_i+1,ref_j+1,:); 1616 i2_subseries=i2_subseries(i2_subseries>0); 1617 i2=i2_subseries(end); 1618 i2=UvData.i2_series{1}(ref_indices(end)); 1618 1619 end 1619 1620 if ~isempty(UvData.j1_series{1}) 1620 j1_subseries=UvData.j1_series{1}(ref_i+1,ref_j+1,:); 1621 j1_subseries=j1_subseries(j1_subseries>0); 1622 j1=j1_subseries(end); 1621 j1=UvData.j1_series{1}(ref_indices(end)); 1623 1622 end 1624 1623 if ~isempty(UvData.j2_series{1}) 1625 j2_subseries=UvData.j2_series{1}(ref_i+1,ref_j+1,:); 1626 j2_subseries=j2_subseries(j2_subseries>0); 1627 j2=j2_subseries(end); 1624 j2=UvData.j2_series{1}(ref_indices(end)); 1628 1625 end 1629 % case of a second file series 1626 % case of a second file series (TODO:revise) 1630 1627 if numel(UvData.i1_series)>=2 1631 1628 i1_subseries=UvData.i1_series{2}(ref_i+1,ref_j+1,:); … … 1705 1702 UvData=get(handles.uvmat,'UserData'); 1706 1703 if isequal(FieldName,'image') 1707 test_1=0;1704 index=1; 1708 1705 [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles); 1709 1706 NomType=get(handles.NomType,'String'); … … 1713 1710 FieldName=list_fields{index_fields}; % selected field 1714 1711 if isequal(FieldName,'image') 1715 test_1=1;1712 index=2; 1716 1713 [RootPath,tild,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles); 1717 1714 else … … 1739 1736 num_i2=num_i1;%repeat the index i1 by default 1740 1737 end 1741 % imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);1742 1738 imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i2,[],num_j2); 1739 if strcmp(NomType,'*') 1740 num_frame=num_i2; 1741 else 1742 num_frame=num_j2; 1743 end 1743 1744 if ~exist(imaname_1,'file') 1744 1745 msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']); … … 1748 1749 end 1749 1750 1751 %% get the first image 1752 %Field.AName='image'; 1753 if index==1 1754 Field_a=UvData.Field;% movie on the second field 1755 else 1756 Field_a=UvData.Field_1;% movie on the first field 1757 end 1758 1750 1759 %% read the second image 1751 Field.AName='image'; 1752 if test_1 1753 Field_a=UvData.Field_1; 1754 else 1755 Field_a=UvData.Field; 1756 end 1757 Field_b.AX=Field_a.AX; 1758 Field_b.AY=Field_a.AY; 1759 % z index 1760 nbslice=str2double(get(handles.num_NbSlice,'String')); 1761 if ~isempty(nbslice) 1762 Field_b.ZIndex=mod(num_i2-1,nbslice)+1; 1763 end 1764 Field_b.CoordUnit='pixel'; 1765 1766 %% determine the input file type 1767 if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1})) 1768 FileType='movie'; 1769 elseif isequal(lower(Ext),'.avi') 1770 FileType='avi'; 1771 elseif isequal(lower(Ext),'.vol') 1772 FileType='vol'; 1773 else 1774 form=imformats(Ext(2:end)); 1775 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 1776 if isequal(NomType,'*'); 1777 FileType='multimage'; 1778 else 1779 FileType='image'; 1780 end 1781 end 1782 end 1783 switch FileType 1784 case 'movie' 1785 if test_1 1786 Field_b.A=read(UvData.MovieObject{2},num_i2); 1787 else 1788 Field_b.A=read(UvData.MovieObject{1},num_i2); 1789 end 1790 case 'avi' 1791 mov=aviread(imaname_1,num_i2); 1792 Field_b.A=frame2im(mov(1)); 1793 case 'vol' 1794 Field_b.A=imread(imaname_1); 1795 case 'multimage' 1796 Field_b.A=imread(imaname_1,num_i2); 1797 case 'image' 1798 Field_b.A=imread(imaname_1); 1799 end 1800 if get(handles.slices,'Value') 1801 Field.ZIndex=str2double(get(handles.z_index,'String')); 1802 end 1760 MovieObject=[]; 1761 if numel(UvData.MovieObject)>=index 1762 MovieObject=UvData.MovieObject{index}; 1763 end 1764 [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},MovieObject,num_frame) 1765 % Field_b.AX=Field_a.AX; 1766 % Field_b.AY=Field_a.AY; 1767 % % z index 1768 % nbslice=str2double(get(handles.num_NbSlice,'String')); 1769 % if ~isempty(nbslice) 1770 % Field_b.ZIndex=mod(num_i2-1,nbslice)+1; 1771 % end 1772 % Field_b.CoordUnit='pixel'; 1773 % 1774 % %% determine the input file type 1775 % if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1})) 1776 % FileType='movie'; 1777 % elseif isequal(lower(Ext),'.avi') 1778 % FileType='avi'; 1779 % elseif isequal(lower(Ext),'.vol') 1780 % FileType='vol'; 1781 % else 1782 % form=imformats(Ext(2:end)); 1783 % if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 1784 % if isequal(NomType,'*'); 1785 % FileType='multimage'; 1786 % else 1787 % FileType='image'; 1788 % end 1789 % end 1790 % end 1791 % switch FileType 1792 % case 'movie' 1793 % if test_1 1794 % Field_b.A=read(UvData.MovieObject{2},num_i2); 1795 % else 1796 % Field_b.A=read(UvData.MovieObject{1},num_i2); 1797 % end 1798 % case 'avi' 1799 % mov=aviread(imaname_1,num_i2); 1800 % Field_b.A=frame2im(mov(1)); 1801 % case 'vol' 1802 % Field_b.A=imread(imaname_1); 1803 % case 'multimage' 1804 % Field_b.A=imread(imaname_1,num_i2); 1805 % case 'image' 1806 % Field_b.A=imread(imaname_1); 1807 % end 1808 % if get(handles.slices,'Value') 1809 % Field.ZIndex=str2double(get(handles.z_index,'String')); 1810 % end 1803 1811 1804 1812 %px to phys or other transform on field 1805 menu_transform=get(handles.transform_fct,'String');1806 choice_value=get(handles.transform_fct,'Value');1807 transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'1808 transform_list=get(handles.transform_fct,'UserData');1809 transform= transform_list{choice_value};1810 if ~ise qual(transform_name,'') && ~isequal(transform_name,'px')1811 if test_1 && isfield(UvData,'XmlData') && numel(UvData.XmlData)==2 && isfield(UvData.XmlData{2},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority1812 Field_a=transform(Field_a,UvData.XmlData{2});%the first field has been stored without transform1813 Field_ b=transform(Field_b,UvData.XmlData{2});1814 elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib1815 Field_b=transform(Field_b,UvData.XmlData{ 1});1813 % menu_transform=get(handles.transform_fct,'String'); 1814 % choice_value=get(handles.transform_fct,'Value'); 1815 % transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' 1816 % transform_list=get(handles.transform_fct,'UserData'); 1817 transform=get(handles.path_transform,'UserData'); 1818 if ~isempty(transform) 1819 if isfield(UvData,'XmlData') && numel(UvData.XmlData)>=index %use geometry calib recorded from the ImaDoc xml file as first priority 1820 if index==2 1821 Field_a=transform(Field_a,UvData.XmlData{index});%the first field has been stored without transform 1822 end 1823 Field_b=transform(Field_b,UvData.XmlData{index}); 1816 1824 end 1817 1825 end … … 2249 2257 %% store the current open names, fields and vel types in uvmat interface 2250 2258 UvData.FileName_1=FileName_1; 2259 UvData.ParamOut_1=ParamOut_1; 2260 if numel(Field)==2 2261 UvData.Field_1=Field{2}; %store the second field for possible use at next RUN 2262 end 2251 2263 2252 2264 %% apply coordinate transform or other user fct … … 2262 2274 end 2263 2275 transform=get(handles.path_transform,'UserData'); 2264 nbre_arg=nargin(transform); 2265 if length(Field)==2 2266 if nbre_arg==4 2267 [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1); 2268 else 2269 Field{1}=transform(Field{1},XmlData); 2270 Field(2)=[]; 2271 end 2272 else 2273 if nbre_arg==1 2274 Field{1}=transform(Field{1});%transform which does not need input parameter 2275 else 2276 Field{1}=transform(Field{1},XmlData); 2277 end 2276 switch nargin(transform) 2277 case 4 2278 if length(Field)==2 2279 UvData.Field=transform(Field{1},XmlData,Field{2},XmlData_1); 2280 else 2281 UvData.Field=transform(Field{1},XmlData); 2282 end 2283 case 3 2284 if length(Field)==2 2285 UvData.Field=transform(Field{1},XmlData,Field{2}); 2286 else 2287 UvData.Field=transform(Field{1},XmlData); 2288 end 2289 case 2 2290 UvData.Field=transform(Field{1},XmlData); 2291 case 1 2292 UvData.Field=transform(Field{1}); 2278 2293 end 2279 2294 end … … 2293 2308 check_tps=1;%tps needed to get the requested field 2294 2309 end 2295 if (check_tps ||check_proj_tps)&&~isfield( Field{1},'Coord_tps')2296 Field{1}=calc_tps(Field{1});2297 end 2298 Field{1}.FieldList=[{ParamOut.FieldName} {ParamOut.ColorVar}];2310 if (check_tps ||check_proj_tps)&&~isfield(UvData.Field,'Coord_tps') 2311 UvData.Field=calc_tps(UvData.Field); 2312 end 2313 UvData.Field.FieldList=[{ParamOut.FieldName} {ParamOut.ColorVar}]; 2299 2314 2300 2315 %% calculate scalar … … 2302 2317 &&~strcmp(ParamOut.FieldName,'velocity') && ~strcmp(ParamOut.FieldName,'get_field...') 2303 2318 if ~check_proj_tps 2304 Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1});2319 UvData.Field=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],UvData.Field); 2305 2320 end 2306 2321 end … … 2314 2329 end 2315 2330 2316 %% combine the two input fields (e.g. substract velocity fields)2317 if numel(Field)==22318 [UvData.Field,errormsg]=sub_field(Field{1},Field{2});2319 UvData.Field_1=Field{2}; %store the second field for possible use at next RUN2320 UvData.ParamOut_1=ParamOut_1;2321 else2322 UvData.Field=Field{1};2323 end2324 if ~isempty(errormsg)2325 errormsg=['error in uvmat/refresh_field/sub_field:' errormsg];2326 return2327 end2328 %UvData.Field.FieldList={FieldName}; % TODO: to generalise, used for proj_field with tps interpolation2329 2331 2330 2332 %% analyse input field … … 2336 2338 return 2337 2339 end 2338 [CellVarIndex,NbDim,VarType,errormsg]=find_field_ indices(UvData.Field);% analyse the input field structure2340 [CellVarIndex,NbDim,VarType,errormsg]=find_field_cells(UvData.Field);% analyse the input field structure 2339 2341 if ~isempty(errormsg) 2340 errormsg=['error in uvmat/refresh_field/find_field_ indices: ' errormsg];% display error2342 errormsg=['error in uvmat/refresh_field/find_field_cells: ' errormsg];% display error 2341 2343 return 2342 2344 end … … 3513 3515 3514 3516 %% create the function handle of the selected fct 3517 3515 3518 if isempty(list_path{ichoice})% case of no selected fct 3516 3519 transform_handle=[]; … … 3527 3530 set(handles.path_transform,'String',list_path{ichoice}) 3528 3531 set(handles.path_transform,'UserData',transform_handle) 3532 set(handles.transform_fct,'UserData',list_path) 3529 3533 3530 3534 %% update the ToolTip string of the menu transform_fct with the first line of the selected fct file … … 4806 4810 ProjectDir = uigetdir(fileparts(fileparts(RootPath)), 'select the project source directory'); 4807 4811 datatree_browser(ProjectDir) 4812 4813 4814 % -------------------------------------------------------------------- 4815 function MenuBrowseProject_Callback(hObject, eventdata, handles) 4816 RootPath=get(handles.RootPath,'String'); 4817 ProjectDir = uigetdir(fileparts(fileparts(RootPath)), 'select the project directory'); 4818 datatree_browser(ProjectDir)
Note: See TracChangeset
for help on using the changeset viewer.