- Timestamp:
- Mar 30, 2020, 3:48:19 PM (5 years ago)
- Location:
- trunk/src
- Files:
-
- 3 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/calc_field_interp.m
r1071 r1078 54 54 if isempty(ivar)% the requested variable does not exist 55 55 check_skipped(ilist)=1; %variable not found 56 elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1)) ;% the variable exists and has not been already selected56 elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1))% the variable exists and has not been already selected 57 57 if exist('XI','var')&& isfield(Data.VarAttribute{ivar},'Role') &&... 58 58 (strcmp(Data.VarAttribute{ivar}.Role,'ancillary')||strcmp(Data.VarAttribute{ivar}.Role,'warnflag')||strcmp(Data.VarAttribute{ivar}.Role,'errorflag')) … … 86 86 UName{ilist}=r.UName; 87 87 VName{ilist}=r.VName; 88 if isempty(find(strcmp(r.UName,InputVarList))) ;88 if isempty(find(strcmp(r.UName,InputVarList))) 89 89 InputVarList=[InputVarList UName{ilist}]; %the variable is added to the list if it is not already in the list 90 90 end 91 if isempty(find(strcmp(r.VName,InputVarList), 1)) ;91 if isempty(find(strcmp(r.VName,InputVarList), 1)) 92 92 InputVarList=[InputVarList VName{ilist}]; %the variable is added to the list if it is not already in the list 93 93 end … … 162 162 end 163 163 164 %% put an error flag to indicate NaN data165 % if exist('XI','var')&&~isempty(VarVal)166 % nbvar=numel(VarVal);167 % ListVarName{nbvar+1}='FF';168 % VarVal{nbvar+1}=isnan(VarVal{nbvar});169 % VarAttribute{nbvar+1}.Role='errorflag';170 % end171 164 172 165 -
trunk/src/find_field_bounds.m
r1071 r1078 134 134 end 135 135 % adjust the mesh to a value 1, 2 , 5 *10^n 136 ord=10^(floor(log10(Mesh)));%order of magnitude 137 if Mesh/ord>=5 138 FieldOut.CoordMesh=5*ord; 139 elseif Mesh/ord>=2 140 FieldOut.CoordMesh=2*ord; 141 else 142 FieldOut.CoordMesh=ord; 143 end 136 FieldOut.CoordMesh = round_uvmat(Mesh); 137 138 -
trunk/src/find_field_cells.m
r1071 r1078 294 294 end 295 295 else 296 if isfield(CellInfo{icell},'XName') ;% only one coordinate x, switch vector field to 1D plot296 if isfield(CellInfo{icell},'XName') % only one coordinate x, switch vector field to 1D plot 297 297 for ind=1:numel(CellInfo{icell}.VarIndex) 298 298 Role{CellInfo{icell}.VarIndex(ind)}='coord_y'; … … 502 502 for icell=1:numel(CellInfo) 503 503 if isfield(CellInfo{icell},'VarIndex') 504 check_fieldname=0; 504 505 VarIndex=CellInfo{icell}.VarIndex; 505 506 for ivar=VarIndex … … 514 515 if ~isempty(FieldName{ivar}) 515 516 CellInfo{icell}.FieldName=FieldName{ivar}; 517 check_fieldname=1; 516 518 end 517 519 if CheckSub(ivar)==1 518 520 CellInfo{icell}.CheckSub=1; 521 end 522 end 523 if ~check_fieldname% default FieldName 524 if isfield(CellInfo{icell},'VarIndex_vector_x')&& isfield(CellInfo{icell},'VarIndex_vector_y') 525 UName=Data.ListVarName{CellInfo{icell}.VarIndex_vector_x}; 526 VName=Data.ListVarName{CellInfo{icell}.VarIndex_vector_y}; 527 CellInfo{icell}.FieldName=['vec(' UName ',' VName ')']; 519 528 end 520 529 end -
trunk/src/mouse_down.m
r1072 r1078 390 390 IndexObj=IndexObj+1;%start new object 391 391 ObjectData.Coord=[]; 392 ObjectName New=ObjectData.Name;393 if isempty(ObjectName New)394 ObjectName New=ObjectData.Type;392 ObjectName=ObjectData.Name; 393 if isempty(ObjectName) 394 ObjectName=ObjectData.Type; 395 395 end 396 396 % add an index to the object name if the proposed name already exists 397 vers=0;% index of the name397 %vers=0;% index of the name 398 398 ListObject=get(hhuvmat.ListObject,'String'); 399 detectname=1; 400 while ~isempty(detectname) 401 detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list 402 if detectname% if the object name already exists 403 indstr=regexp(ObjectNameNew,'\D'); 404 if indstr(end)<length(ObjectNameNew) %object name ends by a number 405 vers=str2double(ObjectNameNew(indstr(end)+1:end))+1; 406 ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)]; 407 else 408 vers=vers+1; 409 ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)]; 410 end 411 end 412 end 413 ObjectName=ObjectNameNew; 399 ObjectName=rename_indexing(ObjectName,ListObject);% add an index or upgrade it if the object naem already exists 414 400 set(sethandles.Name,'String',ObjectName)% display the default name in set_object 415 401 ListObject=[ListObject;{ObjectName}]; -
trunk/src/mouse_motion.m
r1077 r1078 220 220 pos=[xy(1,1) xy(1,2) 0];%coordinates on the graph 221 221 if isfield(Field,'ProjObjectAngle')&&~isequal(Field.ProjObjectAngle,[0 0 0]) 222 om=norm(Field.ProjObjectAngle);%norm of rotation angle in radians 223 OmAxis=Field.ProjObjectAngle/om; %unit vector marking the rotation axis 224 cos_om=cos(pi*om/180); 225 sin_om=sin(pi*om/180); 226 pos=[xy(1,1) xy(1,2) 0]; 227 %pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis; 228 coeff=OmAxis(3)*(1-cos_om); 229 norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om; 230 norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om; 231 norm_plane(3)=OmAxis(3)*coeff+cos_om; 232 %Z0=norm_plane*Field.ProjObjectCoord'/norm_plane(3); 233 pos(3)=-(norm_plane(1)*pos(1)+norm_plane(2)*pos(2))/norm_plane(3); 234 end 235 pos=pos+Field.ProjObjectCoord; 222 norm_plane=angle2normal(Field.ProjObjectAngle); 223 pos(3)=-(norm_plane(1)*(pos(1)-Field.ProjObjectCoord(1))+norm_plane(2)*(pos(2)-Field.ProjObjectCoord(2)))/norm_plane(3); 224 end 225 pos(3)=pos(3)+Field.ProjObjectCoord(3); 236 226 text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)]; 237 227 end -
trunk/src/phys_XYZ.m
r1071 r1078 1 1 %------------------------------------------------------------------------ 2 2 %'phys_XYZ':transforms image (px) to real world (phys) coordinates using geometric calibration parameters 3 % function [Xphys,Yphys ]=phys_XYZ(Calib,X,Y,Z)3 % function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Zindex) 4 4 % 5 5 %OUTPUT: … … 30 30 testangle=0; 31 31 test_refraction=0; 32 Zphys=0; %default output 32 33 if exist('Zindex','var')&& isequal(Zindex,round(Zindex))&& Zindex>0 && isfield(Calib,'SliceCoord')&&size(Calib.SliceCoord,1)>=Zindex 33 if isfield(Calib, 'SliceAngle') && ~isequal(Calib.SliceAngle,[0 0 0])&& ~isequal(Calib.SliceAngle(Zindex,:),[0 0 0])34 if isfield(Calib, 'SliceAngle') && size(Calib.SliceAngle,1)>=Zindex && ~isequal(Calib.SliceAngle(Zindex,:),[0 0 0]) 34 35 testangle=1; 35 om=norm(Calib.SliceAngle(Zindex,:));%norm of rotation angle in radians 36 OmAxis=Calib.SliceAngle(Zindex,:)/om; %unit vector marking the rotation axis 37 cos_om=cos(pi*om/180); 38 sin_om=sin(pi*om/180); 39 coeff=OmAxis(3)*(1-cos_om); 40 norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om; 41 norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om; 42 norm_plane(3)=OmAxis(3)*coeff+cos_om; 43 % Z0=norm_plane*Calib.SliceCoord(Zindex,:)'/norm_plane(3); 36 norm_plane=angle2normal(Calib.SliceAngle(Zindex,:)); 44 37 end 45 38 Z0=Calib.SliceCoord(Zindex,3);%horizontal plane z=cte 46 % end47 39 Z0virt=Z0; 48 40 if isfield(Calib,'InterfaceCoord') && isfield(Calib,'RefractionIndex') … … 134 126 end 135 127 136 %'px_XYZ': transform phys coordinates to image coordinates (px)137 %138 % OUTPUT:139 % X,Y: array of coordinates in the image cooresponding to the input physical positions140 % (origin at lower leftcorner, unit=pixel)141 142 % INPUT:143 % Calib: structure containing the calibration parameters (read from the ImaDoc .xml file)144 % Xphys, Yphys: array of x,y physical coordinates145 % [Z0]: corresponding array of z physical coordinates (0 by default) -
trunk/src/phys_ima.m
r972 r1078 22 22 XmlData={XmlData}; 23 23 end 24 24 25 for icell=1:numel(A) 25 26 siz=size(A{icell}); … … 27 28 npy=[npy siz(1)]; 28 29 Calib=XmlData{icell}.GeometryCalib; 29 xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];%image coordinates of corners 30 yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5]; 31 [xcorner_new,ycorner_new]=phys_XYZ(Calib,xima,yima,ZIndex);%corresponding physical coordinates 30 coord_x=[0.5 siz(2)-0.5]; 31 coord_y=[0.5 siz(1)-0.5]; 32 x_edge=[linspace(coord_x(1),coord_x(end),npx(icell)) coord_x(end)*ones(1,npy(icell))... 33 linspace(coord_x(end),coord_x(1),npx(icell)) coord_x(1)*ones(1,npy(icell))];%x coordinates of the image edge(four sides) 34 y_edge=[coord_y(1)*ones(1,npx(icell)) linspace(coord_y(1),coord_y(end),npy(icell))... 35 coord_y(end)*ones(1,npx(icell)) linspace(coord_y(end),coord_y(1),npy(icell))];%y coordinates of the image edge(four sides) 36 [xcorner_new,ycorner_new]=phys_XYZ(Calib,x_edge,y_edge,ZIndex);%corresponding physical coordinates 32 37 dx(icell)=(max(xcorner_new)-min(xcorner_new))/(siz(2)-1); 33 38 dy(icell)=(max(ycorner_new)-min(ycorner_new))/(siz(1)-1); … … 40 45 Rangy(1)=max(ycorner); 41 46 test_multi=(max(npx)~=min(npx)) || (max(npy)~=min(npy)); %different image lengths 42 % npX=1+round((Rangx(2)-Rangx(1))/min(dx));% nbre of pixels in the new image (use the finest resolution min(dx) in the set of images)43 % npY=1+round((Rangy(1)-Rangy(2))/min(dy));44 47 45 48 npX=1+round((Rangx(2)-Rangx(1))/max(dx));% nbre of pixels in the new image (use the largest resolution max(dx) in the set of images) 46 49 npY=1+round((Rangy(1)-Rangy(2))/max(dy)); 47 50 48 49 51 x=linspace(Rangx(1),Rangx(2),npX); 50 52 y=linspace(Rangy(1),Rangy(2),npY); 51 [X,Y]=meshgrid(x,y);%grid in physical coordiantes 52 %vec_B=[]; 53 [X,Y]=meshgrid(x,y);%grid in physical coordinates 53 54 A_out=cell(1,numel(A)); 54 for icell=1:length(A) 55 56 for icell=1:length(A) 55 57 Calib=XmlData{icell}.GeometryCalib; 56 58 % rescaling of the image coordinates without change of the image array … … 60 62 Rangy=[npy-0.5 0.5]; 61 63 [Rangx]=phys_XYZ(Calib,Rangx,[0.5 0.5],ZIndex);%case of translations without rotation and quadratic deformation 62 [ xx,Rangy]=phys_XYZ(Calib,[0.5 0.5],Rangy,ZIndex);64 [~,Rangy]=phys_XYZ(Calib,[0.5 0.5],Rangy,ZIndex); 63 65 else 64 66 % the image needs to be interpolated to the new coordinates 65 zphys=0; %default67 Z=0; %default 66 68 if isfield(Calib,'SliceCoord') %.Z= index of plane 67 69 SliceCoord=Calib.SliceCoord(ZIndex,:); 68 zphys=SliceCoord(3); %to generalize for non-parallel planes 69 if isfield(Calib, 'SliceAngle') && ~isequal(Calib.SliceAngle,[0 0 0]) && ~isequal(Calib.SliceAngle(ZIndex,:),[0 0 0]) 70 testangle=1; 71 om=norm(Calib.SliceAngle(ZIndex,:));%norm of rotation angle in radians 72 OmAxis=Calib.SliceAngle(ZIndex,:)/om; %unit vector marking the rotation axis 73 cos_om=cos(pi*om/180); 74 sin_om=sin(pi*om/180); 75 coeff=OmAxis(3)*(1-cos_om); 76 norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om; 77 norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om; 78 norm_plane(3)=OmAxis(3)*coeff+cos_om; 79 %Z0=norm_plane*Calib.SliceCoord(ZIndex,:)'/norm_plane(3); 80 Z0=Calib.SliceCoord(ZIndex,3); 81 zphys=Z0-(norm_plane(1)*X-norm_plane(2)*Y)/norm_plane(3); 70 Z=SliceCoord(3); 71 if isfield(Calib, 'SliceAngle') && size(Calib.SliceAngle,1)>=ZIndex && ~isequal(Calib.SliceAngle(ZIndex,:),[0 0 0]) 72 norm_plane=angle2normal(Calib.SliceAngle(ZIndex,:)); 73 Z=Z-(norm_plane(1)*(X-SliceCoord(1))+norm_plane(2)*(Y-SliceCoord(2)))/norm_plane(3); 82 74 end 83 % if isfield(Calib,'InterfaceCoord') && isfield(Calib,'RefractionIndex')84 % H=Calib.InterfaceCoord(3);85 % if H>zphys86 % zphys=H-(H-zphys)/Calib.RefractionIndex; %corrected z (virtual object)87 % end88 % end89 75 end 90 76 xima=0.5:npx(icell)-0.5;%image coordinates of corners 91 77 yima=npy(icell)-0.5:-1:0.5; 92 78 [XIMA_init,YIMA_init]=meshgrid(xima,yima);%grid of initial image in px coordinates 93 [XIMA,YIMA]=px_XYZ(XmlData{icell}.GeometryCalib,X,Y, zphys);% image coordinates for each point in the real79 [XIMA,YIMA]=px_XYZ(XmlData{icell}.GeometryCalib,X,Y,Z);% image coordinates for each point in the real 94 80 testuint8=isa(A{icell},'uint8'); 95 81 testuint16=isa(A{icell},'uint16'); 96 if ndims(A{icell})==2%(B/W images)97 A_out{icell}=interp2(XIMA_init,YIMA_init,double(A{icell}),XIMA,YIMA);98 elseif ndims(A{icell})==399 100 101 102 103 82 if ismatrix(A{icell}) %(B/W images) 83 A_out{icell}=interp2(XIMA_init,YIMA_init,double(A{icell}),XIMA,YIMA); 84 elseif ndims(A{icell})==3 85 for icolor=1:size(A{icell},3) 86 A{icell}=double(A{icell}); 87 A_out{icell}(:,:,icolor)=interp2(XIMA_init,YIMA_init,A{icell}(:,:,icolor),XIMA,YIMA); 88 end 89 end 104 90 if testuint8 105 91 A_out{icell}=uint8(A_out{icell}); … … 107 93 if testuint16 108 94 A_out{icell}=uint16(A_out{icell}); 109 end 95 end 110 96 end 111 97 end -
trunk/src/proj_field.m
r1077 r1078 985 985 986 986 %----------------------------------------------------------------- 987 %project on a plane 988 % AJOUTER flux,circul,error 987 % proj_plane: project on a plane defined by the structure ObjectData containing: 988 % .Type : = 'plane' 989 % .ProjMode (mode of projection) = 'projection'|'interp_lin'|'interp_tps' ; 990 % .CoordUnit: (for instance 'px','cm') units for the coordinates defining the plane (the program checks that it fits with the unit of the input Field) 991 % .Angle : angles of rotation of the plane expressed in degrees. The first element 992 % ObjectData.Angle(1) represents a rotation in the plane (x,y) (around the 993 % vertical axis), which can be followed by a rotation with angle ObjectData.Angle(2) around the new (rotated) x axis. 994 % .Coord(1,3): coordinates (x,y,z) of the origin of the new coordinates in the projection plane; 995 % .DX,.DY,.DZ : increments along each coordinate for the projected data (for 'interp_lin' and 'interp_tps') 996 % .RangeX,RangeY: vectors with two elements defining the lower and upper bounds of the respectively X and Y coordinates in the projection plane 997 % .RangeInterp: maximum distance of interpolation from the known data. Interpolation yields NaN beyond this distance. 998 999 % TODO: AJOUTER flux,circul,error 989 1000 function [ProjData,errormsg] = proj_plane(FieldData, ObjectData) 990 1001 %----------------------------------------------------------------- 991 1002 992 %% rotation angles1003 %% rotation matrix 993 1004 PlaneAngle=[0 0]; 994 1005 norm_plane=[0 0 1]; 995 %cos_om=1;996 %sin_om=0;997 1006 test90x=0;%=1 for 90 degree rotation alround x axis 998 1007 test90y=0;%=1 for 90 degree rotation alround y axis 999 % if strcmp(ObjectData.Type,'plane_z') 1000 % Delta_x=ObjectData.Coord(2,1)-ObjectData.Coord(1,1); 1001 % Delta_y=ObjectData.Coord(2,2)-ObjectData.Coord(1,2); 1002 % Delta_mod=sqrt(Delta_x*Delta_x+Delta_y*Delta_y); 1003 % ObjectData.Angle=[0 0 0]; 1004 % ObjectData.Angle(1)=90*Delta_x/Delta_mod; 1005 % ObjectData.0(2)=90*Delta_y/Delta_mod; 1006 % end 1008 1007 1009 if isfield(ObjectData,'Angle') 1008 1010 checkM2=0; … … 1014 1016 if PlaneAngle==0 1015 1017 PlaneAngle=[0 0]; 1016 end 1017 % om=norm(PlaneAngle);%norm of rotation angle in radians 1018 % OmAxis=PlaneAngle/om; %unit vector marking the rotation axis 1019 % cos_om=cos(om); 1020 % sin_om=sin(om); 1021 % coeff=OmAxis(3)*(1-cos_om); 1022 % %components of the unity vector norm_plane normal to the projection plane 1023 % norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om; 1024 % norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om; 1025 % norm_plane(3)=OmAxis(3)*coeff+cos_om; 1026 1018 end 1027 1019 M1=[cos(PlaneAngle(1)) -sin(PlaneAngle(1)) 0;sin(PlaneAngle(1)) cos(PlaneAngle(1)) 0;0 0 1]; 1028 1020 M=M1; … … 1031 1023 M=M1*M2;% first rotate in the x,y plane with angle PlaneAngle(1), then slant around the new x axis0 with angle PlaneAngle(2) 1032 1024 end 1033 norm_plane=M*[0 0 1]'; 1034 1025 norm_plane=M*[0 0 1]'; 1035 1026 end 1036 1027 testangle=~isequal(PlaneAngle,[0 0])||~isequal(ObjectData.Coord(1:2),[0 0 ]) ;% && ~test90y && ~test90x;%=1 for slanted plane … … 1425 1416 %rotate coordinates if needed: coord_X,coord_Y= = coordinates in the new plane 1426 1417 Phi=PlaneAngle(1); 1427 if testangle && ~test90y && ~test90x ;%=1 for slanted plane1418 if testangle && ~test90y && ~test90x %=1 for slanted plane 1428 1419 new_XI=XI *cos(Phi) - YI* sin(Phi)+ObjectData.Coord(1); 1429 1420 YI=XI *sin(Phi) + YI *cos(Phi)+ObjectData.Coord(2); -
trunk/src/series.m
r1072 r1078 1459 1459 return 1460 1460 end 1461 if isfield(Param,'InputFields')&& isfield(Param.InputFields,'FieldName')&& isequal(Param.InputFields.FieldName,' get_field...')1462 errormsg='input field name(s) not defined, select get_field...';1461 if isfield(Param,'InputFields')&& isfield(Param.InputFields,'FieldName')&& isequal(Param.InputFields.FieldName,'add_field...') 1462 errormsg='input field name(s) not defined, select add_field...'; 1463 1463 return 1464 1464 end … … 2450 2450 set(handles.VelType_1,'Visible','on') 2451 2451 set(handles.VelType_title_1,'Visible','on') 2452 FieldList_1=[set_field_list('U','V');{'C'};{' get_field...'}]; % standard menu for civx data2452 FieldList_1=[set_field_list('U','V');{'C'};{'add_field...'}]; % standard menu for civx data 2453 2453 CheckList_1=1; 2454 2454 set(handles.FieldName_1,'Value',1); % velocity vector choice by default … … 2467 2467 if FieldNameRequest && isfield(SeriesData.FileInfo{iview_netcdf(1)},'ListVarName') 2468 2468 set(handles.FieldName,'Visible','on') 2469 set(handles.Field_text,'Visible','on') 2469 2470 ListVarName=SeriesData.FileInfo{iview_netcdf(1)}.ListVarName; 2470 2471 ind_var=get(handles.FieldName,'Value'); % indices of previously selected variables … … 2491 2492 else 2492 2493 set(handles.FieldName,'Visible','off') 2494 set(handles.Field_text,'Visible','off') 2493 2495 end 2494 2496 2495 2497 set(handles_coord,'Visible','on') 2496 if isempty(find(strcmp(' get_field...',FieldList)))2497 FieldList=[FieldList;{' get_field...'}];%add 'get_field...' to the menu FieldName if it is not already2498 if isempty(find(strcmp('add_field...',FieldList))) 2499 FieldList=[FieldList;{'add_field...'}];%add 'add_field...' to the menu FieldName if it is not already 2498 2500 end 2499 2501 if FieldNameRequest_1 && numel(iview_netcdf)>=2 … … 2530 2532 end 2531 2533 if isempty(FieldList) 2534 set(handles.Field_text,'Visible','off') 2532 2535 set(handles.FieldName,'Visible','off') 2533 2536 else 2537 set(handles.Field_text,'Visible','on') 2534 2538 set(handles.FieldName,'Visible','on') 2535 2539 set(handles.FieldName,'String',FieldList) … … 2757 2761 set(handles.ActionInput,'BackgroundColor',[1 0 0]) 2758 2762 2763 2764 %------------------------------------------------------------------------ 2765 % --- Executes on button press in RefreshField. 2766 function RefreshField_Callback(hObject, eventdata, handles) 2767 %------------------------------------------------------------------------ 2768 set(handles.FieldName,'String',{'add_field...'}); 2769 set(handles.FieldName,'Value',1); 2770 FieldName_Callback(hObject, eventdata, handles) 2771 2772 2759 2773 %------------------------------------------------------------------------ 2760 2774 % --- Executes on selection change in FieldName. 2761 2775 function FieldName_Callback(hObject, eventdata, handles) 2762 2776 %------------------------------------------------------------------------ 2763 field_str=get(handles.FieldName,'String');2777 FieldListInit=get(handles.FieldName,'String'); 2764 2778 field_index=get(handles.FieldName,'Value'); 2765 field=field_str{field_index(1)}; 2766 if isequal(field,'get_field...') 2779 field=FieldListInit{field_index(1)}; 2780 if isequal(field,'add_field...') 2781 FieldListInit(field_index(1))=[]; 2767 2782 SeriesData=get(handles.series,'UserData'); 2768 2783 % input line for which the field choice is relevant … … 2776 2791 % check the existence of the first file in the series 2777 2792 first_j=[];last_j=[];MinIndex_j=1;MaxIndex_j=1; % default setting for index j 2778 if isfield(Param.IndexRange,'first_j') ;% if index j is used2793 if isfield(Param.IndexRange,'first_j') % if index j is used 2779 2794 first_j=Param.IndexRange.first_j; 2780 2795 last_j=Param.IndexRange.last_j; … … 2789 2804 answer=msgbox_uvmat('INPUT_TXT',['select the line of the input table:' num2str(iview)] ,num2str(iview(1))); 2790 2805 LineIndex=str2num(answer); 2791 % InputLine=str2num(get(handles.InputLine,'String'));2792 % if ismember(InputLine,iview)2793 % LineIndex=InputLine;2794 % end2795 2806 end 2796 2807 FirstFileName=fullfile_uvmat(InputTable{LineIndex,1},InputTable{LineIndex,2},InputTable{LineIndex,3},... … … 2826 2837 end 2827 2838 set(handles.FieldName,'Value',1) 2828 set(handles.FieldName,'String',[FieldList ; {'get_field...'}]);2839 set(handles.FieldName,'String',[FieldListInit; FieldList; {'add_field...'}]); 2829 2840 if ~strcmp(GetFieldData.FieldOption,'civdata...') 2830 2841 if ~isempty(regexp(FieldList{1},'^vec')) … … 2913 2924 field_index=get(handles.FieldName_1,'Value'); 2914 2925 field=field_str{field_index(1)}; 2915 if isequal(field,' get_field...')2926 if isequal(field,'add_field...') 2916 2927 hget_field=findobj(allchild(0),'name','get_field'); 2917 2928 if ~isempty(hget_field) … … 2973 2984 end 2974 2985 set(handles.FieldName_1,'Value',1) 2975 set(handles.FieldName_1,'String',[FieldList; {' get_field...'}]);2986 set(handles.FieldName_1,'String',[FieldList; {'add_field...'}]); 2976 2987 end 2977 2988 end … … 3378 3389 ListField=Param.InputFields.FieldName; 3379 3390 if ischar(ListField),ListField={ListField}; end 3380 set(handles.FieldName,'String',[ListField;{' get-field...'}])3391 set(handles.FieldName,'String',[ListField;{'add_field...'}]) 3381 3392 set(handles.FieldName,'Value',1:numel(ListField)) 3382 3393 set(handles.FieldName,'Visible','on') … … 3866 3877 3867 3878 3868 3869 3879 % --- Executes on button press in Replicate. 3870 3880 function Replicate_Callback(hObject, eventdata, handles) … … 3882 3892 end 3883 3893 3884 3885 -
trunk/src/series/merge_proj.m
r1071 r1078 320 320 check_proj_tps= strcmp(FileType{iview},'civdata') && isfield(Param,'ProjObject')&&~isempty(Param.ProjObject)... 321 321 && strcmp(Param.ProjObject.ProjMode,'interp_tps')&&~isfield(Data{iview},'Coord_tps'); 322 if check_proj_tps 322 323 Data{iview}=tps_coeff_field(Data{iview},check_proj_tps); 324 end 323 325 324 326 %% projection on object (gridded plane) -
trunk/src/transform_field/phys_polar.m
r1071 r1078 3 3 %%%% Use the general syntax for transform fields %%%% 4 4 % OUTPUT: 5 % Data Out: output field structure5 % Data: output field structure 6 6 % .X=radius, .Y=azimuth angle, .U, .V are radial and azimuthal velocity components 7 7 % … … 14 14 % .GeometryCalib: substructure of the calibration parameters 15 15 % transform image coordinates (px) to polar physical coordinates 16 %[Data Out,DataOut_1]=phys_polar(varargin)16 %[Data,Data_1]=phys_polar(varargin) 17 17 % 18 18 % OUTPUT: 19 % Data Out: structure of modified data field: .X=radius, .Y=azimuth angle, .U, .V are radial and azimuthal velocity components20 % Data Out_1: second data field (if two fields are in input)19 % Data: structure of modified data field: .X=radius, .Y=azimuth angle, .U, .V are radial and azimuthal velocity components 20 % Data_1: second data field (if two fields are in input) 21 21 % 22 22 %INPUT: … … 44 44 %======================================================================= 45 45 46 function Data Out=phys_polar(DataIn,XmlData,DataIn_1,XmlData_1)46 function Data=phys_polar(DataIn,XmlData,DataIn_1,XmlData_1) 47 47 %------------------------------------------------------------------------ 48 48 49 %% request input parameters 49 50 if isfield(DataIn,'Action') && isfield(DataIn.Action,'RUN') && isequal(DataIn.Action.RUN,0) … … 64 65 end 65 66 answer = inputdlg(prompt,dlg_title,num_lines,def); 66 Data Out.TransformInput.PolarCentre=str2num(answer{1});67 Data Out.TransformInput.PolarReferenceRadius=str2num(answer{2});68 Data Out.TransformInput.PolarReferenceAngle=str2num(answer{3});69 if isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit')70 DataOut.CoordUnit=XmlData.GeometryCalib.CoordUnit;% states that the output is in unit defined by GeometryCalib, then erased all projection objects with different units71 end67 Data.TransformInput.PolarCentre=str2num(answer{1}); 68 Data.TransformInput.PolarReferenceRadius=str2num(answer{2}); 69 Data.TransformInput.PolarReferenceAngle=str2num(answer{3}); 70 % if isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit') 71 % Data.CoordUnit=XmlData.GeometryCalib.CoordUnit;% states that the output is in unit defined by GeometryCalib, then erased all projection objects with different units 72 % end 72 73 return 73 74 end 74 75 76 %% default outputs 77 Data=DataIn; %default output 78 if isfield(Data,'CoordUnit') 79 Data=rmfield(Data,'CoordUnit'); 80 end 81 Data.ListVarName = {}; 82 Data.VarDimName={}; 83 Data.VarAttribute={}; 84 DataCell{1}=DataIn; 75 85 Calib{1}=[]; 86 DataCell{2}=[];%default 87 checkpixel(1)=0; 88 if isfield(DataCell{1},'CoorUnit')&& strcmp(DataCell{1}.CoorUnit,'px') 89 checkpixel(1)=1; 90 end 76 91 if nargin==2||nargin==4 77 DataOut=DataIn;%default 78 DataOut_1=[];%default 79 if isfield(XmlData,'GeometryCalib') 92 if isfield(XmlData,'GeometryCalib') && ~isempty(XmlData.GeometryCalib)&& checkpixel(1) 80 93 Calib{1}=XmlData.GeometryCalib; 81 94 end 82 95 Calib{2}=Calib{1}; 83 96 else 84 Data Out.Txt='wrong input: need two or four structures';85 end 86 test_1=0;97 Data.Txt='wrong input: need two or four structures'; 98 end 99 nbinput=1; 87 100 if nargin==4% case of two input fields 88 test_1=1; 89 DataOut_1=DataIn_1;%default 90 if isfield(XmlData_1,'GeometryCalib') 101 checkpixel(2)=0; 102 if isfield(DataCell{2},'CoorUnit')&& strcmp(DataCell{2}.CoorUnit,'px') 103 checkpixel(2)=1; 104 end 105 DataCell{2}=DataIn_1;%default 106 if isfield(XmlData_1,'GeometryCalib')&& ~isempty(XmlData_1.GeometryCalib) && checkpixel(2) 91 107 Calib{2}=XmlData_1.GeometryCalib; 92 108 end 93 end 94 95 %parameters for polar coordinates (taken from the calibration data of the first field) 109 nbinput=2; 110 end 111 112 %% parameters for polar coordinates (taken from the calibration data of the first field) 96 113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 97 XmlData.PolarReferenceRadius=0;%450;98 XmlData.PolarReferenceAngle=0;%450*pi/2;99 114 origin_xy=[0 0];%center for the polar coordinates in the original x,y coordinates 100 115 radius_offset=0;%reference radius used to offset the radial coordinate r 101 116 angle_offset=0; %reference angle used as new origin of the polar angle (= axis Ox by default) 102 angle_scale=180/pi; 117 angle_scale=180/pi; 118 check_degree=1;%angle expressed in degrees by default 103 119 if isfield(XmlData,'TransformInput') 104 120 if isfield(XmlData.TransformInput,'PolarCentre') && isnumeric(XmlData.TransformInput.PolarCentre) 105 if isequal(length(XmlData.TransformInput.PolarCentre),2) ;121 if isequal(length(XmlData.TransformInput.PolarCentre),2) 106 122 origin_xy= XmlData.TransformInput.PolarCentre; 107 123 end … … 112 128 if radius_offset > 0 113 129 angle_scale=radius_offset; %the azimuth is rescale in terms of the length along the reference radius 130 check_degree=0; %the output has the same unit asthe input 114 131 else 115 132 angle_scale=180/pi; %polar angle in degrees 133 check_degree=1;%angle expressed in degrees 116 134 end 117 135 if isfield(XmlData.TransformInput,'PolarReferenceAngle') && isnumeric(XmlData.TransformInput.PolarReferenceAngle) … … 121 139 122 140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 123 124 iscalar=0; 125 %transform first field to cartesian phys coordiantes 126 if ~isempty(Calib{1}) 127 DataOut=phys_1(DataIn,Calib{1},origin_xy,radius_offset,angle_offset,angle_scale); 128 %case of images or scalar 129 if isfield(DataIn,'A')&isfield(DataIn,'Coord_x')&~isempty(DataIn.Coord_x) & isfield(DataIn,'Coord_y')&... 130 ~isempty(DataIn.Coord_y)&length(DataIn.A)>1 131 iscalar=1; 132 A{1}=DataIn.A; 133 end 141 %% get fields 142 check_scalar=0; 143 check_vector=0; 144 nbvar=0;%counter for the number of output variables 145 nbcoord=0;%counter for the number of variables for radial coordiantes (case of multiple field inputs) 146 nbgrid=0;%counter for the number of gridded fields (all linearly interpolated on the same output polar grid) 147 nbscattered=0;%counter of scattered fields 148 radius_name='radius'; 149 theta_name='theta'; 150 U_r_name='U_r'; 151 U_theta_name='U_theta'; 152 for ifield=1:nbinput %1 or 2 input fields 153 [CellInfo,NbDim,errormsg]=find_field_cells(DataCell{ifield}); 154 if ~isempty(errormsg) 155 Data.Txt=['bad input to phys_polar: ' errormsg]; 156 return 157 end 158 % end 134 159 %transform of X,Y coordinates for vector fields 135 if isfield(Data In,'ZIndex')&~isempty(DataIn.ZIndex)136 ZIndex=Data In.ZIndex;160 if isfield(DataCell{ifield},'ZIndex')&& ~isempty(DataCell{ifield}.ZIndex) 161 ZIndex=DataCell{ifield}.ZIndex; 137 162 else 138 163 ZIndex=0; 139 164 end 140 end 141 142 %transform second field (if exists) to cartesian phys coordiantes 143 if test_1 144 DataOut_1=phys_1(Data_1,Calib{2},origin_xy,radius_offset,angle_offset,angle_scale); 145 if isfield(Data_1,'A')&isfield(Data_1,'Coord_x')&~isempty(Data_1.Coord_x) & isfield(Data_1,'Coord_y')&... 146 ~isempty(Data_1.Coord_y)&length(Data_1.A)>1 147 iscalar=iscalar+1; 148 Calib{iscalar}=Calib{2}; 149 A{iscalar}=Data_1.A; 150 if isfield(Data_1,'ZIndex')&~isequal(Data_1.ZIndex,ZIndex) 151 DataOut.Txt='inconsistent plane indexes in the two input fields'; 152 end 153 if iscalar==1% case for which only the second field is a scalar 154 [A,Coord_x,Coord_y]=phys_Ima_polar(A,Calib,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale); 155 DataOut_1.A=A{1}; 156 DataOut_1.Coord_x=Coord_x; 157 DataOut_1.Coord_y=Coord_y; 158 return 159 end 160 end 161 end 162 if iscalar~=0 163 [A,Coord_x,Coord_y]=phys_Ima_polar(A,Calib,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale);% 164 DataOut.A=A{1}; 165 DataOut.Coord_x=Coord_x; 166 DataOut.Coord_y=Coord_y; 167 if iscalar==2 168 DataOut_1.A=A{2}; 169 DataOut_1.Coord_x=Coord_x; 170 DataOut_1.Coord_y=Coord_y; 171 end 172 end 173 174 165 for icell=1:numel(CellInfo) 166 if NbDim(icell)==2 167 % case of input field with scattered coordinates 168 if strcmp(CellInfo{icell}.CoordType,'scattered') 169 nbscattered=nbscattered+1; 170 nbcoord=nbcoord+1; 171 radius_name = rename_indexing(radius_name,Data.ListVarName); 172 theta_name = rename_indexing(theta_name,Data.ListVarName); 173 Data.ListVarName = [Data.ListVarName {radius_name} {theta_name}]; 174 dim_name = rename_indexing('nb_point',Data.VarDimName); 175 Data.VarDimName=[Data.VarDimName {dim_name} {dim_name}]; 176 nbvar=nbvar+2; 177 Data.VarAttribute{nbvar-1}.Role='coord_x'; 178 check_unit=1; 179 if isfield(DataCell{ifield},'CoordUnit') 180 Data=rmfield(Data,'CoordUnit'); 181 Data.VarAttribute{nbvar-1}.unit=DataCell{ifield}.CoordUnit; 182 elseif isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit') 183 Data.VarAttribute{nbvar-1}.unit=XmlData.GeometryCalib.CoordUnit;% states that the output is in unit defined by GeometryCalib, then erased all projection objects with different units 184 else 185 check_unit=0; 186 end 187 Data.VarAttribute{nbvar}.Role='coord_y'; 188 if check_degree 189 Data.VarAttribute{nbvar}.unit='degree'; 190 elseif check_unit 191 Data.VarAttribute{nbvar}.unit=Data.VarAttribute{nbvar-1}.unit; 192 end 193 194 %transform u,v into polar coordinates 195 X=DataCell{ifield}.(CellInfo{icell}.XName); 196 Y=DataCell{ifield}.(CellInfo{icell}.YName); 197 if isfield(CellInfo{icell},'VarIndex_vector_x')&& isfield(CellInfo{icell},'VarIndex_vector_y') 198 UName=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_vector_x}; 199 VName=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_vector_y}; 200 if ~isempty(Calib{ifield}) 201 [X,Y,Z,DataCell{ifield}.(UName),DataCell{ifield}.(VName)]=... 202 phys_XYUV(DataCell{ifield},Calib{ifield},ZIndex); 203 end 204 end 205 [Theta,Radius] = cart2pol(X-origin_xy(1),Y-origin_xy(2)); 206 Data.(radius_name)=Radius-radius_offset; 207 Data.(theta_name)=Theta*angle_scale-angle_offset; 208 if Z~=0 209 Data.Z=Z; 210 nbvar=nbvar+1; 211 Data.ListVarName = [Data.ListVarName {'Z'}]; 212 Data.VarDimName=[Data.VarDimName {dim_name}]; 213 Data.VarAttribute{nbvar}.Role='coord_z'; 214 end 215 if isfield(CellInfo{icell},'VarIndex_scalar') 216 ScalarName=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_scalar}; 217 ScalarName=rename_indexing(ScalarName,Data.ListVarName); 218 Data.(ScalarName)=DataCell{ifield}.(ScalarName); 219 nbvar=nbvar+1; 220 Data.ListVarName = [Data.ListVarName {ScalarName}]; 221 Data.VarDimName=[Data.VarDimName {dim_name}]; 222 Data.VarAttribute{nbvar}.Role='scalar'; 223 end 224 if isfield(CellInfo{icell},'VarIndex_vector_x')&& isfield(CellInfo{icell},'VarIndex_vector_y') 225 U_r_name= rename_indexing(U_r_name,Data.ListVarName); 226 U_theta_name= rename_indexing(U_theta_name,Data.ListVarName); 227 Data.(U_r_name)=DataCell{ifield}.(UName).*cos(Theta)+DataCell{ifield}.(VName).*sin(Theta);%radial velocity 228 Data.(U_theta_name)=(-DataCell{ifield}.(UName).*sin(Theta)+DataCell{ifield}.(VName).*cos(Theta));%./(Data.X)%+radius_ref);% azimuthal velocity component 229 Data.ListVarName = [Data.ListVarName {U_r_name} {U_theta_name}]; 230 Data.VarDimName=[Data.VarDimName {dim_name} {dim_name}]; 231 Data.VarAttribute{nbvar+1}.Role='vector_x'; 232 Data.VarAttribute{nbvar+2}.Role='vector_y'; 233 nbvar=nbvar+2; 234 end 235 if isfield(CellInfo{icell},'VarIndex_errorflag') 236 error_flag_name=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_errorflag}; 237 error_flag_newname= rename_indexing(error_flag_name,Data.ListVarName); 238 Data.(error_flag_newname)=DataCell{ifield}.(error_flag_name); 239 Data.ListVarName = [Data.ListVarName {error_flag_newname}]; 240 Data.VarDimName=[Data.VarDimName {dim_name}]; 241 nbvar=nbvar+1; 242 Data.VarAttribute{nbvar}.Role='errorflag'; 243 end 244 245 %caseof input fields on gridded coordinates (matrix) 246 elseif strcmp(CellInfo{icell}.CoordType,'grid') 247 if nbgrid==0% no gridded data yet, introduce the coordinate variables common to all gridded data 248 nbcoord=nbcoord+1;%add new radial coordinates for the first gridded field 249 radius_name = rename_indexing(radius_name,Data.ListVarName); 250 theta_name = rename_indexing(theta_name,Data.ListVarName); 251 Data.ListVarName = [Data.ListVarName {radius_name} {theta_name}]; 252 Data.VarDimName=[Data.VarDimName {radius_name} {theta_name}]; 253 nbvar=nbvar+2; 254 Data.VarAttribute{nbvar-1}.Role='coord_x'; 255 Data.VarAttribute{nbvar}.Role='coord_y'; 256 check_unit=1; 257 if isfield(DataCell{ifield},'CoordUnit') 258 Data.VarAttribute{nbvar-1}.unit=DataCell{ifield}.CoordUnit; 259 elseif isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit') 260 Data.VarAttribute{nbvar-1}.unit=XmlData.GeometryCalib.CoordUnit;% states that the output is in unit defined by GeometryCalib, then erased all projection objects with different units 261 else 262 check_unit=0; 263 end 264 if check_degree 265 Data.VarAttribute{nbvar}.unit='degree'; 266 elseif check_unit 267 Data.VarAttribute{nbvar}.unit=Data.VarAttribute{nbvar-1}.unit; 268 end 269 end 270 if isfield(CellInfo{icell},'VarIndex_scalar') 271 nbgrid=nbgrid+1; 272 nbvar=nbvar+1; 273 Data.VarAttribute{nbvar}.Role='scalar'; 274 FieldName{nbgrid}=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_scalar}; 275 A{nbgrid}=DataCell{ifield}.(FieldName{nbgrid}); 276 % Data.ListVarName=[Data.ListVarName {FieldName{nbgrid}}]; 277 % Data.VarDimName=[Data.VarDimName {{theta_name,radius_name}}]; 278 nbpoint(nbgrid)=numel(A{nbgrid}); 279 check_scalar(nbgrid)=1; 280 coord_x{nbgrid}=DataCell{ifield}.(DataCell{ifield}.ListVarName{CellInfo{icell}.XIndex}); 281 coord_y{nbgrid}=DataCell{ifield}.(DataCell{ifield}.ListVarName{CellInfo{icell}.YIndex}); 282 ZInd(nbgrid)=ZIndex; 283 Calib_new{nbgrid}=Calib{ifield}; 284 end 285 if isfield(CellInfo{icell},'VarIndex_vector_x')&& isfield(CellInfo{icell},'VarIndex_vector_y') 286 FieldName{nbgrid+1}=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_vector_x}; 287 FieldName{nbgrid+2}=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_vector_y}; 288 A{nbgrid+1}=DataCell{ifield}.(FieldName{nbgrid+1}); 289 A{nbgrid+2}=DataCell{ifield}.(FieldName{nbgrid+2}); 290 % Data.ListVarName=[Data.ListVarName {'U_r','U_theta'}]; 291 %Data.VarDimName=[Data.VarDimName {{theta_name,radius_name}} {{theta_name,radius_name}}]; 292 Data.VarAttribute{nbvar+1}.Role='vector_x'; 293 Data.VarAttribute{nbvar+2}.Role='vector_y'; 294 nbpoint([nbgrid+1 nbgrid+2])=numel(A{nbgrid+1}); 295 check_vector(nbgrid+1)=1; 296 check_vector(nbgrid+2)=1; 297 coord_x{nbgrid+1}=DataCell{ifield}.(DataCell{ifield}.ListVarName{CellInfo{icell}.XIndex}); 298 coord_y{nbgrid+1}=DataCell{ifield}.(DataCell{ifield}.ListVarName{CellInfo{icell}.YIndex}); 299 coord_x{nbgrid+2}=DataCell{ifield}.(DataCell{ifield}.ListVarName{CellInfo{icell}.XIndex}); 300 coord_y{nbgrid+2}=DataCell{ifield}.(DataCell{ifield}.ListVarName{CellInfo{icell}.YIndex}); 301 ZInd(nbgrid+1)=ZIndex; 302 ZInd(nbgrid+2)=ZIndex; 303 Calib_new{nbgrid+1}=Calib{ifield}; 304 Calib_new{nbgrid+2}=Calib{ifield}; 305 nbgrid=nbgrid+2; 306 nbvar=nbvar+2; 307 end 308 end 309 end 310 end 311 end 312 313 %% tranform cartesian to polar coordinates for gridded data 314 if nbgrid~=0 315 [A,Data.radius,Data.theta]=phys_Ima_polar(A,coord_x,coord_y,Calib_new,ZInd,origin_xy,radius_offset,angle_offset,angle_scale); 316 for icell=1:numel(A) 317 if icell<=numel(A)-1 && check_vector(icell)==1 && check_vector(icell+1)==1 %transform u,v into polar coordiantes 318 theta=Data.theta/angle_scale-angle_offset; 319 [~,Theta]=meshgrid(Data.radius,theta);%grid in physical coordinates 320 U_r_name= rename_indexing(U_r_name,Data.ListVarName); 321 U_theta_name= rename_indexing(U_theta_name,Data.ListVarName); 322 Data.ListVarName=[Data.ListVarName {U_r_name,U_theta_name}]; 323 Data.VarDimName=[Data.VarDimName {{theta_name,radius_name}} {{theta_name,radius_name}}]; 324 Data.(U_r_name)=A{icell}.*cos(Theta)+A{icell+1}.*sin(Theta);%radial velocity 325 Data.(U_theta_name)=(-A{icell}.*sin(Theta)+A{icell+1}.*cos(Theta));%./(Data.X)%+radius_ref);% azimuthal velocity component 326 elseif ~check_vector(icell)% for scalar fields 327 FieldName{icell}= rename_indexing(FieldName{icell},Data.ListVarName); 328 Data.ListVarName=[Data.ListVarName {FieldName{icell}}]; 329 Data.VarDimName=[Data.VarDimName {{theta_name,radius_name}}]; 330 Data.(FieldName{icell})=A{icell}; 331 end 332 end 333 end 175 334 176 335 177 336 %------------------------------------------------ 178 function DataOut=phys_1(Data,Calib,origin_xy,radius_offset,angle_offset,angle_scale) 179 180 DataOut=Data; 181 % DataOut.CoordUnit=Calib.CoordUnit; %put flag for physical coordinates 182 if isfield(Calib,'SliceCoord') 183 DataOut.PlaneCoord=Calib.SliceCoord;%to generalise for any plane 184 end 185 186 if isfield(Data,'CoordUnit')%&& isequal(Data.CoordType,'px')&& ~isempty(Calib) 187 if isfield(Calib,'CoordUnit') 188 DataOut.CoordUnit=Calib.CoordUnit; 189 else 190 DataOut.CoordUnit='cm'; %default 191 end 192 DataOut.TimeUnit='s'; 193 %transform of X,Y coordinates for vector fields 194 if isfield(Data,'ZIndex') && ~isempty(Data.ZIndex)&&~isnan(Data.ZIndex) 195 Z=Data.ZIndex; 196 else 197 Z=0; 198 end 199 if isfield(Data,'X') &isfield(Data,'Y')&~isempty(Data.X) & ~isempty(Data.Y) 200 [DataOut.X,DataOut.Y,DataOut.Z]=phys_XYZ(Calib,Data.X,Data.Y,Z); %transform from pixels to physical 201 DataOut.X=DataOut.X-origin_xy(1);%origin of coordinates at the tank center 202 DataOut.Y=DataOut.Y-origin_xy(2);%origin of coordinates at the tank center 203 [theta,DataOut.X] = cart2pol(DataOut.X,DataOut.Y);%theta and X are the polar coordinates angle and radius 204 %shift and renormalize the polar coordinates 205 DataOut.X=DataOut.X-radius_offset;%shift the origin of radius, taken as the new X coordinate 206 DataOut.Y=(theta-angle_offset)*angle_scale;% normalized angle: distance along reference radius,taken as the new Y coordinate 207 %transform velocity field if exists 208 if isfield(Data,'U') & isfield(Data,'V') & ~isempty(Data.U) & ~isempty(Data.V)& isfield(Data,'Dt') 209 if ~isempty(Data.Dt) 210 [XOut_1,YOut_1]=phys_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,Z);% X,Y positions of the vector origin in phys 211 [XOut_2,YOut_2]=phys_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,Z);% X,Y positions of the vector end in phys 212 UX=(XOut_2-XOut_1)/Data.Dt;% phys velocity u component 213 VY=(YOut_2-YOut_1)/Data.Dt; % phys velocity v component 214 %transform u,v into polar coordiantes 215 DataOut.U=UX.*cos(theta)+VY.*sin(theta);%radial velocity 216 DataOut.V=(-UX.*sin(theta)+VY.*cos(theta));%./(DataOut.X)%+radius_ref);% azimuthal velocity component 217 %shift and renormalize the angular velocity 218 end 219 end 220 %transform of spatial derivatives 221 if isfield(Data,'X') && ~isempty(Data.X) && isfield(Data,'DjUi') && ~isempty(Data.DjUi)... 222 && isfield(Data,'Dt') 223 if ~isempty(Data.Dt) 224 % estimate the Jacobian matrix DXpx/DXphys 225 for ip=1:length(Data.X) 226 [Xp1,Yp1]=phys_XYZ(Calib,Data.X(ip)+0.5,Data.Y(ip),Z); 227 [Xm1,Ym1]=phys_XYZ(Calib,Data.X(ip)-0.5,Data.Y(ip),Z); 228 [Xp2,Yp2]=phys_XYZ(Calib,Data.X(ip),Data.Y(ip)+0.5,Z); 229 [Xm2,Ym2]=phys_XYZ(Calib,Data.X(ip),Data.Y(ip)-0.5,Z); 230 %Jacobian matrix DXpphys/DXpx 231 DjXi(1,1)=(Xp1-Xm1); 232 DjXi(2,1)=(Yp1-Ym1); 233 DjXi(1,2)=(Xp2-Xm2); 234 DjXi(2,2)=(Yp2-Ym2); 235 DjUi(:,:)=Data.DjUi(ip,:,:); 236 DjUi=(DjXi*DjUi')/DjXi;% =J-1*M*J , curvature effects (derivatives of J) neglected 237 DataOut.DjUi(ip,:,:)=DjUi'; 238 end 239 DataOut.DjUi = DataOut.DjUi/Data.Dt; % min(Data.DjUi(:,1,1))=DUDX 240 end 241 end 242 end 243 end 244 337 %--- transform a single field into phys coordiantes 338 function [X,Y,Z,U,V]=phys_XYUV(Data,Calib,ZIndex) 339 %------------------------------------------------ 340 %% set default output 341 %DataOut=Data;%default 342 %DataOut.CoordUnit=Calib.CoordUnit;% the output coord unit is set by the calibration parameters 343 X=[];%default output 344 Y=[]; 345 Z=0; 346 U=[]; 347 V=[]; 348 %% transform X,Y coordinates for velocity fields (transform of an image or scalar done in phys_ima) 349 if isfield(Data,'X') &&isfield(Data,'Y')&&~isempty(Data.X) && ~isempty(Data.Y) 350 [X,Y,Z]=phys_XYZ(Calib,Data.X,Data.Y,ZIndex); 351 Dt=1; %default 352 if isfield(Data,'dt')&&~isempty(Data.dt) 353 Dt=Data.dt; 354 end 355 if isfield(Data,'Dt')&&~isempty(Data.Dt) 356 Dt=Data.Dt; 357 end 358 if isfield(Data,'U')&&isfield(Data,'V')&&~isempty(Data.U) && ~isempty(Data.V) 359 [XOut_1,YOut_1]=phys_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,ZIndex); 360 [XOut_2,YOut_2]=phys_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,ZIndex); 361 U=(XOut_2-XOut_1)/Dt; 362 V=(YOut_2-YOut_1)/Dt; 363 end 364 end 245 365 246 366 %%%%%%%%%%%%%%%%%%%% 247 function [A_out,Rangx,Rangy]=phys_Ima_polar(A,CalibIn,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale) 248 xcorner=[]; 249 ycorner=[]; 367 % tranform gridded field into polar coordiantes on a regular polar grid, 368 % transform to phys coordiantes if requested by calibration input 369 function [A_out,radius,theta]=phys_Ima_polar(A,coord_x,coord_y,CalibIn,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale) 370 rcorner=[]; 371 thetacorner=[]; 250 372 npx=[]; 251 373 npy=[]; 252 NbPoints=20; % nbre of points used to determine the image edge253 374 for icell=1:length(A) 254 375 siz=size(A{icell}); 255 npx=[npx siz(2)]; 256 npy=[npy siz(1)]; 257 zphys=0; %default 258 if isfield(CalibIn{icell},'SliceCoord') %.Z= index of plane 259 if ZIndex==0 260 ZIndex=1; 261 end 262 SliceCoord=CalibIn{icell}.SliceCoord(ZIndex,:); 263 zphys=SliceCoord(3); %to generalize for non-parallel planes 264 end 265 % xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];%image coordinates of corners 266 % yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5]; 267 edge_x=linspace(0.5,siz(1)-0.5,NbPoints); 268 edge_y=linspace(0.5,siz(2)-0.5,NbPoints); 269 xima=[edge_y (siz(2)-0.5)*ones(1,NbPoints) edge_y 0.5*ones(1,NbPoints)];%image coordinates of corners 270 yima=[0.5*ones(1,NbPoints) edge_x (siz(1)-0.5)*ones(1,NbPoints) edge_x];%image coordinates of corners 271 [xcorner_new,ycorner_new]=phys_XYZ(CalibIn{icell},xima,yima,ZIndex);%corresponding physical coordinates 272 %transform the corner coordinates into polar ones 273 xcorner_new=xcorner_new-origin_xy(1);%shift to the origin of the polar coordinates 274 ycorner_new=ycorner_new-origin_xy(2);%shift to the origin of the polar coordinates 275 [theta,xcorner_new] = cart2pol(xcorner_new,ycorner_new);%theta and X are the polar coordinates angle and radius 276 if (max(theta)-min(theta))>pi %if the polar origin is inside the image 277 xcorner_new=[0 max(xcorner_new)]; 278 theta=[-pi pi]; 279 end 280 %shift and renormalize the polar coordinates 281 xcorner_new=xcorner_new-radius_offset;% 282 ycorner_new=theta*angle_scale-angle_offset;% normalized angle: distance along reference radius 283 xcorner=[xcorner xcorner_new]; 284 ycorner=[ycorner ycorner_new]; 285 end 286 Rangx(1)=min(xcorner); 287 Rangx(2)=max(xcorner); 288 Rangy(2)=min(ycorner); 289 Rangy(1)=max(ycorner); 290 % test_multi=(max(npx)~=min(npx)) | (max(npy)~=min(npy)); 291 npx=max(npx); 292 npy=max(npy); 293 x=linspace(Rangx(1),Rangx(2),npx); 294 y=linspace(Rangy(1),Rangy(2),npy); 295 [X,Y]=meshgrid(x,y);%grid in physical coordinates 376 npx(icell)=siz(2); 377 npy(icell)=siz(1); 378 x_edge=[linspace(coord_x{icell}(1),coord_x{icell}(end),npx(icell)) coord_x{icell}(end)*ones(1,npy(icell))... 379 linspace(coord_x{icell}(end),coord_x{icell}(1),npx(icell)) coord_x{icell}(1)*ones(1,npy(icell))];%x coordinates of the image edge(four sides) 380 y_edge=[coord_y{icell}(1)*ones(1,npx(icell)) linspace(coord_y{icell}(1),coord_y{icell}(end),npy(icell))... 381 coord_y{icell}(end)*ones(1,npx(icell)) linspace(coord_y{icell}(end),coord_y{icell}(1),npy(icell))];%y coordinates of the image edge(four sides) 382 383 % transform edges into phys coordinates if requested 384 if ~isempty(CalibIn{icell}) 385 [x_edge,y_edge]=phys_XYZ(CalibIn{icell},x_edge,y_edge,ZIndex(icell));% physical coordinates of the image edge 386 end 387 388 %transform the corner coordinates into polar ones 389 x_edge=x_edge-origin_xy(1);%shift to the origin of the polar coordinates 390 y_edge=y_edge-origin_xy(2);%shift to the origin of the polar coordinates 391 [theta_edge,r_edge] = cart2pol(x_edge,y_edge);%theta and X are the polar coordinates angle and radius 392 if (max(theta_edge)-min(theta_edge))>pi %if the polar origin is inside the image 393 r_edge=[0 max(r_edge)]; 394 theta_edge=[-pi pi]; 395 end 396 rcorner=[rcorner r_edge]; 397 thetacorner=[thetacorner theta_edge]; 398 end 399 nbpoint=max(npx.*npy); 400 Min_r=min(rcorner); 401 Max_r=max(rcorner); 402 Min_theta=min(thetacorner)*angle_scale; 403 Max_theta=max(thetacorner)*angle_scale; 404 Dr=round_uvmat((Max_r-Min_r)/sqrt(nbpoint)); 405 Dtheta=round_uvmat((Max_theta-Min_theta)/sqrt(nbpoint));% get a simple mesh for the rescaled angle 406 radius=Min_r:Dr:Max_r;% polar coordinates for projections 407 theta=Min_theta:Dtheta:Max_theta; 408 [Radius,Theta]=meshgrid(radius,theta/angle_scale);%grid in polar coordinates (angles in radians) 296 409 %transform X, Y in cartesian 297 X=X+radius_offset;% 298 Y=(Y+angle_offset)/angle_scale;% normalized angle: distance along reference radius 299 [X,Y] = pol2cart(Y,X); 300 X=X+origin_xy(1);%shift to the origin of the polar coordinates 301 Y=Y+origin_xy(2);%shift to the origin of the polar coordinates 302 for icell=1:length(A) 410 [X,Y] = pol2cart(Theta,Radius);% cartesian coordinates associated to the grid in polar coordinates 411 X=X+origin_xy(1);%shift to the origin of the polar coordinates 412 Y=Y+origin_xy(2);%shift to the origin of the polar coordinates 413 radius=radius-radius_offset; 414 theta=theta-angle_offset*angle_scale; 415 [np_theta,np_r]=size(Radius); 416 417 for icell=1:length(A) 418 XIMA=X; 419 YIMA=Y; 420 if ~isempty(CalibIn{icell})%transform back to pixel if calibration parameters are introduced 421 Z=0; %default 422 if isfield(CalibIn{icell},'SliceCoord') %.Z= index of plane 423 if ZIndex(icell)==0 424 ZIndex(icell)=1; 425 end 426 SliceCoord=CalibIn{icell}.SliceCoord(ZIndex(icell),:); 427 Z=SliceCoord(3); %to generalize for non-parallel planes 428 if isfield(CalibIn{icell},'SliceAngle') 429 norm_plane=angle2normal(CalibIn{icell}.SliceAngle); 430 Z=Z-(norm_plane(1)*(X-SliceCoord(1))+norm_plane(2)*(Y-SliceCoord(2)))/norm_plane(3); 431 end 432 end 433 [XIMA,YIMA]=px_XYZ(CalibIn{icell},X,Y,Z);%corresponding image indices for each point in the real space grid 434 end 435 Dx=(coord_x{icell}(end)-coord_x{icell}(1))/(npx(icell)-1); 436 Dy=(coord_y{icell}(end)-coord_y{icell}(1))/(npy(icell)-1); 437 indx_ima=1+round((XIMA-coord_x{icell}(1))/Dx);%indices of the initial matrix close to the points of the new grid 438 indy_ima=1+round((YIMA-coord_y{icell}(1))/Dy); 439 Delta_x=1+(XIMA-coord_x{icell}(1))/Dx-indx_ima;% 440 Delta_y=1+(YIMA-coord_y{icell}(1))/Dy-indy_ima; 441 XIMA=reshape(indx_ima,1,[]);%indices reorganized in 'line' 442 YIMA=reshape(indy_ima,1,[]);%indices reorganized in 'line' 443 flagin=XIMA>=1 & XIMA<=npx(icell) & YIMA >=1 & YIMA<=npy(icell);%flagin=1 inside the original image 303 444 siz=size(A{icell}); 304 [XIMA,YIMA]=px_XYZ(CalibIn{icell},X,Y,zphys);%corresponding image indices for each point in the real space grid 305 XIMA=reshape(round(XIMA),1,npx*npy);%indices reorganized in 'line' 306 YIMA=reshape(round(YIMA),1,npx*npy); 307 flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image 445 checkuint8=isa(A{icell},'uint8');%check for image input with 8 bits 446 checkuint16=isa(A{icell},'uint8');%check for image input with 16 bits 447 A{icell}=double(A{icell}); 308 448 if numel(siz)==2 %(B/W images) 309 vec_A=reshape(A{icell}(:,:,1),1, npx*npy);%put the original image in line449 vec_A=reshape(A{icell}(:,:,1),1,[]);%put the original image in line 310 450 ind_in=find(flagin); 311 451 ind_out=find(~flagin); 312 ICOMB=((XIMA-1)*npy +(npy+1-YIMA));452 ICOMB=((XIMA-1)*npy(icell)+(npy(icell)+1-YIMA)); 313 453 ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A 314 454 vec_B(ind_in)=vec_A(ICOMB); 315 455 vec_B(ind_out)=zeros(size(ind_out)); 316 A_out{icell}=reshape(vec_B,npy,npx);%new image in real coordinates 456 A_out{icell}=reshape(vec_B,np_theta,np_r);%new image in real coordinates 457 DA_y=circshift(A_out{icell},-1,1)-A_out{icell}; 458 DA_y(end,:)=0; 459 DA_x=circshift(A_out{icell},-1,2)-A_out{icell}; 460 DA_x(:,end)=0; 461 A_out{icell}=A_out{icell}+Delta_x.*DA_x+Delta_y.*DA_y;%linear interpolation 317 462 else 318 463 for icolor=1:siz(3) 319 vec_A=reshape(A{icell}(:,:,icolor),1,npx*npy);%put the original image in line 320 ind_in=find(flagin); 321 ind_out=find(~flagin); 322 ICOMB=((XIMA-1)*npy+(npy+1-YIMA)); 323 ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A 324 vec_B(ind_in)=vec_A(ICOMB); 325 vec_B(ind_out)=zeros(size(ind_out)); 326 A_out{icell}(:,:,icolor)=reshape(vec_B,npy,npx);%new image in real coordinates 327 end 328 end 329 end 330 464 vec_A=reshape(A{icell}(:,:,icolor),1,[]);%put the original image in line 465 ind_in=find(flagin); 466 ind_out=find(~flagin); 467 ICOMB=((XIMA-1)*npy(icell)+(npy(icell)+1-YIMA)); 468 ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A 469 vec_B(ind_in)=vec_A(ICOMB); 470 vec_B(ind_out)=zeros(size(ind_out)); 471 A_out{icell}(:,:,icolor)=reshape(vec_B,np_theta,np_r);%new image in real coordinates 472 DA_y=circshift(A_out{icell}(:,:,icolor),-1,1)-A_out{icell}(:,:,icolor); 473 DA_y(end,:)=0; 474 DA_x=circshift(A_out{icell}(:,:,icolor),-1,2)-A_out{icell}(:,:,icolor); 475 DA_x(:,end)=0; 476 A_out{icell}(:,:,icolor)=A_out{icell}(:,:,icolor)+Delta_x.*DA_x+Delta_y.*DA_y;%linear interpolation 477 end 478 end 479 if checkuint8 480 A_out{icell}=uint8(A_out{icell}); 481 elseif checkuint16 482 A_out{icell}=uint16(A_out{icell}); 483 end 484 end 485 -
trunk/src/uvmat.m
r1077 r1078 640 640 641 641 %------------------------------------------------------------------------ 642 % function called by the upper bar menu item Export/make movie 642 643 % -------------------------------------------------------------------- 643 644 function MenuExportMovie_Callback(hObject, eventdata, handles) … … 645 646 set(handles.MenuExportMovie,'BusyAction','queue')% activate the button 646 647 647 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); 648 FileBase=fullfile(RootPath,RootFile); 648 [RootPath,SubDir,RootFile]=read_file_boxes(handles);%read input file path from the GUI uvmat 649 649 650 650 %% create a fig and axis for movies 651 figure_movie=findobj(allchild(0),'name','figure_movie'); 652 651 figure_movie=findobj(allchild(0),'name','figure_movie');% find existing movie figure 653 652 if ~isempty(figure_movie) 654 653 delete(figure_movie)%delete existing figure_movie 655 654 end 656 figure_movie=figure; 655 figure_movie=figure;% create a new movie figure 657 656 nbpix=[640 480];% resolution VGA 658 657 set(figure_movie,'name','figure_movie','Position',[1 1 nbpix]) … … 671 670 672 671 %% create the GUI set_movie 673 %set(0,'Units','points')674 %ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right675 672 Position=get(figure_movie,'Position'); 676 673 Position(2)=Position(2)+1.2*Position(4); … … 678 675 Position(4)=Position(4)/2; 679 676 hfig=findobj(allchild(0),'Tag','set_movie'); 680 if ~isempty(hfig),delete(hfig), end ;%delete existing version of the GUI677 if ~isempty(hfig),delete(hfig), end %delete existing version of the GUI 681 678 hfig=figure('name','set_movie','tag','set_movie','MenuBar','none','NumberTitle','off','Units','pixels',... 682 679 'Position',Position); … … 787 784 end 788 785 end 789 %create avi open 790 %aviobj=avifile(MovieName,'Compression','None','fps',fps); 791 786 787 %% create movie 788 % duration = 2*FrameNumber/60; 789 % [~,name,~] = fileparts(MovieName); 790 % ffmpegcmd = ['ffmpeg -i ' ' ' MovieName ' ' '-filter:v "setpts=(',... 791 % num2str(fps/duration),')*PTS"' ' ' strcat(MovieDir,... 792 % strcat('/',name,'.mkv'))]; 793 % [ffmpeg_err,~] = system(ffmpegcmd); 794 % if ffmpeg_err 795 % disp_uvmat('ERROR',['ERROR: Errors in conversion to mkv, close MATLAB and run "LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 matlab" in terminal'],1 ) 796 % return 797 % end 798 % msgbox_uvmat('CONFIRMATION',{['movie ' MovieName ' created '];['with ' num2str(FrameNumber) ' frames']}) 799 800 801 % 792 802 aviobj = VideoWriter(MovieName,'Motion JPEG AVI'); 793 803 open(aviobj) … … 1180 1190 'Callback',@(hObject,eventdata)set_slice_CheckRefraction_Callback(hObject,eventdata),... 1181 1191 'String','refraction','Value',CheckRefraction,'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''CheckRefraction'':=1 to provide refraction correction'); 1182 uicontrol('Style','text','Units','normalized', 'Position', [2*ii+2*ww 0.95-3*ii-1.7 5*hh ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Refraction_title',...1192 uicontrol('Style','text','Units','normalized', 'Position', [2*ii+2*ww 0.95-3*ii-1.7*hh ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Refraction_title',... 1183 1193 'String','index','Visible','off','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title 1184 1194 uicontrol('Style','edit','Units','normalized', 'Position', [4*ii+3*ww 0.95-3*ii-2*hh ww hh],'tag','num_RefractionIndex','BackgroundColor',[1 1 1],... 1185 1195 'String',num2str(RefractionIndex),'Visible','off','FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_RefractionIndex'': refraction index of water'); 1186 1196 % raw 4 of the GUI 1187 uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-4*ii-3. 25*hh ww hh],'BackgroundColor',BackgroundColor,'Tag','NbSlice_title',...1197 uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-4*ii-3.0*hh ww hh],'BackgroundColor',BackgroundColor,'Tag','NbSlice_title',... 1188 1198 'String','NbSlice','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title 1189 uicontrol('Style','edit','Units','normalized', 'Position', [2*ii+ww 0.95-4*ii- 3*hh ww hh],'tag','num_NbSlice','BackgroundColor',[1 1 1],...1199 uicontrol('Style','edit','Units','normalized', 'Position', [2*ii+ww 0.95-4*ii-2.8*hh ww hh],'tag','num_NbSlice','BackgroundColor',[1 1 1],... 1190 1200 'String',num2str(NbSlice),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_NbSlice'':number of slices');%edit box 1191 uicontrol('Style','checkbox','Units','normalized', 'Position', [3*ii+2*ww 0.95-4*ii- 3*hh 2*ww hh],'tag','CheckVolumeScan','BackgroundColor',BackgroundColor,...1201 uicontrol('Style','checkbox','Units','normalized', 'Position', [3*ii+2*ww 0.95-4*ii-2.7*hh 2*ww hh],'tag','CheckVolumeScan','BackgroundColor',BackgroundColor,... 1192 1202 'String','volume scan','Value',CheckVolumeScan,'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''CheckVolumeScan'':=1 for volume scan (z varies with j index)'); 1193 1203 % raw 5 of the GUI 1194 uicontrol('Style','text','Units','normalized', 'Position', [2*ii+2*ww 0.95-3*ii-3.5*hh ww hh/2],'BackgroundColor',BackgroundColor,... 1195 'String','first','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title 1196 uicontrol('Style','text','Units','normalized', 'Position', [3*ii+3*ww 0.95-3*ii-3.5*hh ww hh/2],'BackgroundColor',BackgroundColor,... 1197 'String','last','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title 1198 uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-5*ii-4*hh 2*ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Angle_title_1',... 1199 'String','tild angle x axis','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title 1200 uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-6*ii-5*hh 2*ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Angle_title_2',... 1201 'String','tild angle y axis','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title 1204 uicontrol('Style','text','Units','normalized', 'Position', [2*ii+1*ww 0.95-2*ii-3.9*hh ww hh],'BackgroundColor',BackgroundColor,... 1205 'String','origin','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title 1206 uicontrol('Style','text','Units','normalized', 'Position', [2*ii+2*ww 0.95-2*ii-3.5*hh ww hh],'BackgroundColor',BackgroundColor,... 1207 'String',{'first';'angle'},'FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title 1208 uicontrol('Style','text','Units','normalized', 'Position', [3*ii+3*ww 0.95-2*ii-3.5*hh ww hh],'BackgroundColor',BackgroundColor,... 1209 'String',{'last';'angle'},'FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title 1210 1211 uicontrol('Style','edit','Units','normalized', 'Position', [3*ii+ww 0.95-5*ii-4.2*hh ww hh],'tag','num_SliceCoord_1','BackgroundColor',[1 1 1],... 1212 'String',num2str(SliceCoord(1)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_SliceCoord_1'':x position of the tild origin');%edit box 1213 uicontrol('Style','edit','Units','normalized', 'Position', [3*ii+ww 0.95-6*ii-5.2*hh ww hh],'tag','num_SliceCoord_2','BackgroundColor',[1 1 1],... 1214 'String',num2str(SliceCoord(2)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_SliceCoord_2'':y position of the tild origin');%edit box 1215 1216 uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-5*ii-4*hh 1.3*ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Angle_title_1',... 1217 'String','tild x axis','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title 1218 uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-6*ii-5*hh 1.3*ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Angle_title_2',... 1219 'String','tild y axis','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title 1202 1220 % raw 6 of the GUI 1203 1221 uicontrol('Style','edit','Units','normalized', 'Position', [3*ii+2*ww 0.95-5*ii-4.2*hh ww hh],'tag','num_SliceAngle_1_1','BackgroundColor',[1 1 1],... … … 1270 1288 end 1271 1289 GeometryCalib.SliceCoord=Z_plane'*[0 0 1]; 1290 GeometryCalib.SliceCoord(:,1)=SliceData.SliceCoord(1); 1291 GeometryCalib.SliceCoord(:,2)=SliceData.SliceCoord(2); 1272 1292 GeometryCalib.SliceAngle=zeros(GeometryCalib.NbSlice,3); 1273 1293 Angle_1=linspace(SliceData.SliceAngle_1(1),SliceData.SliceAngle_1(2),SliceData.NbSlice); … … 3554 3574 end 3555 3575 switch UvData.FileInfo{1}.FieldType 3556 case {'civdata','netcdf'} ;3576 case {'civdata','netcdf'} 3557 3577 list_fields=get(handles.FieldName,'String');% list menu fields 3558 3578 FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field … … 3687 3707 end 3688 3708 end 3689 % switch UvData.FileType{2}3690 % case {'civx','civdata','netcdf'};3691 % list_fields=get(handles.FieldName_1,'String');% list menu fields3692 % if ischar(list_fields),list_fields={list_fields};end3693 % FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field3694 % if ~strcmp(FieldName_1,'get_field...')3695 % if get(handles.FixVelType,'Value')3696 % VelTypeList=get(handles.VelType_1,'String');3697 % VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type.3698 % end3699 % end3700 % if isempty(FieldName_1)3701 % FieldName_1=FieldName;% if blank reproduce the field name of the first field3702 % end3703 % if ~isempty(regexp(FieldName_1,'^vel', 'once'))&& strcmp(get(handles.ColorCode,'Visible'),'on')3704 % list_code=get(handles.ColorCode,'String');% list menu fields3705 % index_code=get(handles.ColorCode,'Value');% selected string index3706 % if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white')3707 % list_code=get(handles.ColorScalar,'String');% list menu fields3708 % index_code=get(handles.ColorScalar,'Value');% selected string index3709 % ParamIn_1.ColorVar= list_code{index_code}; % selected field for vector color display3710 % end3711 % end3712 % case {'video','mmreader','cine_phantom'}3713 % ParamIn_1=UvData.MovieObject{2};3714 % if ~strcmp(NomType_1,'*')3715 % frame_index_1=j1_1;%frame index for movies or multimage3716 % else3717 % frame_index_1=i1_1;3718 % end3719 % case 'multimage'3720 % if strcmp(NomType_1,'*')%frame index for movies or multimage3721 % frame_index_1=i1_1;3722 % else3723 % frame_index_1=j1_1;3724 % end3725 % case 'vol' %TODO: update3726 % if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')3727 % ParamIn_1.Npy=UvData.XmlData.Npy;3728 % ParamIn_1.Npx=UvData.XmlData.Npx;3729 % else3730 % errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';3731 % return3732 % end3733 % end3734 3709 3735 3710 test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged … … 3951 3926 if numel(Field)==2 3952 3927 UvData.Field=sub_field(Field{1},[],Field{2}); 3953 % UvData.Field.(FieldName)=Field{1}.(FieldName)-Field{2}.(FieldName_1);3954 3928 end 3955 3929 else … … 4024 3998 UvData.Field=tps_coeff_field(UvData.Field,check_proj_tps); 4025 3999 4026 %% reset the min and max of scalar if only the mask is displayed(TODO: check the need) 4027 % if isfield(UvData,'Mask')&& ~isfield(UvData,'A') 4028 % set(handles.num_MinA,'String','0') 4029 % set(handles.num_MaxA,'String','255') 4030 % end 4031 set(handles.Objects,'Visible','on') 4032 4033 %% Plot the projections on the selected projection objects 4000 4001 %% Plot the projections on the selected projection objects 4002 set(handles.Objects,'Visible','on') 4034 4003 %if no projection object exists, create a default one 4035 4004 if isempty(UvData.ProjObject{1}) … … 5461 5430 %------------------------------------------------------------------------ 5462 5431 set(handles.CheckFixLimits,'Value',1) %suppress auto mode 5463 % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])5464 5432 update_plot(handles); 5465 5433 … … 5471 5439 %------------------------------------------ 5472 5440 set(handles.CheckFixScalar,'Value',1) %suppress auto mode 5473 % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])5474 5441 MinA=str2double(get(handles.num_MinA,'String')); 5475 5442 MaxA=str2double(get(handles.num_MaxA,'String'));
Note: See TracChangeset
for help on using the changeset viewer.