Changeset 1072 for trunk


Ignore:
Timestamp:
Jan 17, 2020, 8:13:53 PM (15 months ago)
Author:
sommeria
Message:

LIF updated and bug corrections

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_field.m

    r1071 r1072  
    317317
    318318%% set z coordinate menu if relevant
    319 if Field.MaxDim>=3 && prod(Field.DimValue)<10^8 && ~isempty(ParamIn.Coord_z); % 3D field (with memory content smaller than 400 Mo)
     319if Field.MaxDim>=3 && prod(Field.DimValue)<10^8 && ~(isfield(ParamIn,'Coord_z') && isempty(ParamIn.Coord_z)) % 3D field (with memory content smaller than 400 Mo)
    320320    set(handles.Check3D,'Value',1)
    321321else
  • trunk/src/mouse_down.m

    r1071 r1072  
    288288
    289289%% selection of an existing projection object (third priority)
    290 if  test_edit
     290if  test_edit && ~strcmp(get(hcurrentobject,'Type'),'figure')
    291291    testdeform=0;
    292292    if ~(isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'create'))
     
    360360               end
    361361            end
    362 %             if testdeform==0
    363 %                 AxeData.Drawing='translate';
    364 %                 set(AxeData.CurrentObject,'Selected','on')
    365 %                 set(gcbo,'Pointer','fleur');
    366 %             end
    367362        else
    368363            if strcmp(get(hCurrentGUI,'tag'),'uvmat') %if the uvmat graph has been selected, object projection is on the other frame view_field
     
    433428    h_set_object=findobj(allchild(0),'Tag','set_object');
    434429    hh_set_object=guidata(h_set_object);
    435     if strcmp(ObjectData.Type,'plane_z')&& ~isempty(ObjectData.Coord)
    436         Delta_x=(xy(1,1)-ObjectData.Coord(1,1));%displacement along x
    437         Delta_y=(xy(1,2)-ObjectData.Coord(1,2));%displacement along y
    438         ObjectData.Angle(1)=(180/pi)*angle(Delta_x+i*Delta_y);
    439         ObjectData.Angle(2)=90;       
    440         set(hh_set_object.num_Angle_1,'String',num2str(ObjectData.Angle(1)))
    441         set(hh_set_object.num_Angle_2,'String',num2str(ObjectData.Angle(2)))
    442          drawing_status='off';
     430    if strcmp(ObjectData.Type,'plane')
     431        if isempty(ObjectData.Coord)||(isfield(ObjectData,'RangeX') && size(ObjectData.RangeX,2)==2)% draw a new plane
     432            ObjectData.Coord=xy(1,1:2);% record the coordinates marked by the mouse as origin of the new plane
     433            set(hh_set_object.Coord,'Data',ObjectData.Coord);%append the current mouse cordinates in the GUI set_object
     434            set(hh_set_object.num_RangeX_2,'String','')
     435            set(hh_set_object.num_Angle_1,'String','0')
     436            drawing_status='create';
     437        else
     438            Delta_x=(xy(1,1)-ObjectData.Coord(1,1));%displacement along x
     439            Delta_y=(xy(1,2)-ObjectData.Coord(1,2));%displacement along y
     440            ObjectData.Angle(1)=(180/pi)*angle(Delta_x+i*Delta_y);
     441            ObjectData.Angle(2)=90;
     442            ObjectData.RangeX(1)=0;
     443            ObjectData.RangeX(2)=abs(Delta_x+i*Delta_y);
     444            set(hh_set_object.num_Angle_1,'String',num2str(ObjectData.Angle(1)))
     445            set(hh_set_object.num_Angle_2,'String',num2str(ObjectData.Angle(2)))
     446            set(hh_set_object.num_RangeX_1,'String',num2str(ObjectData.RangeX(1)))
     447            set(hh_set_object.num_RangeX_2,'String',num2str(ObjectData.RangeX(2)))
     448            drawing_status='off';
     449        end
    443450    else
    444451        ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];% append the coordinates marked by the mouse to the object
  • trunk/src/mouse_motion.m

    r1071 r1072  
    402402    if isequal(AxeData.Drawing,'create') && isfield(AxeData,'CurrentOrigin') && ~isempty(AxeData.CurrentOrigin)
    403403        switch ObjectData.Type
    404             case {'line','polyline','polygon','points','plane_z'}
     404            case {'line','polyline','polygon','points'}
    405405                ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];
    406406                % ObjectData.Coord(end,:)=xy(1,:);
  • trunk/src/mouse_up.m

    r1071 r1072  
    9595    else
    9696        switch ObjectData.Type
    97             case {'line','plane_z'}
     97            case {'line','plane'}
    9898                if size(ObjectData.Coord,1)==1 % this is the mouse up for the first point, continue until next click
    9999                    check_multiple=1;
     
    106106                    check_multiple=1;% pass to next mous up if width of height=0
    107107                end
    108             case 'plane' %case of 'plane', TODO: NOT ACTIVATED
    109                 DX=(xy(1,1)-ObjectData.Coord(1,1));
    110                 DY=(xy(1,2)-ObjectData.Coord(1,2));
    111                 ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle width
    112                 if isfield(ObjectData,'RangeX')
    113                     XMax=sqrt(DX*DX+DY*DY);
    114                     if XMax>max(ObjectData.RangeX)
    115                         ObjectData.RangeX=[min(ObjectData.RangeX) XMax];
    116                     end
    117                 end
     108%             case 'plane' %case of 'plane', TODO: NOT ACTIVATED
     109%                 DX=(xy(1,1)-ObjectData.Coord(1,1));
     110%                 DY=(xy(1,2)-ObjectData.Coord(1,2));
     111%                 ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle width
     112%                 if isfield(ObjectData,'RangeX')
     113%                     XMax=sqrt(DX*DX+DY*DY);
     114%                     if XMax>max(ObjectData.RangeX)
     115%                         ObjectData.RangeX=[min(ObjectData.RangeX) XMax];
     116%                     end
     117%                 end
    118118            otherwise
    119119                check_multiple=1;
  • trunk/src/proj_field.m

    r1071 r1072  
    999999    end
    10001000    PlaneAngle=(pi/180)*ObjectData.Angle;
     1001    if PlaneAngle==0
     1002        PlaneAngle=[0 0];
     1003    end
    10011004    %     om=norm(PlaneAngle);%norm of rotation angle in radians
    10021005    %     OmAxis=PlaneAngle/om; %unit vector marking the rotation axis
     
    10091012    %     norm_plane(3)=OmAxis(3)*coeff+cos_om;
    10101013   
    1011     M1=[cos(PlaneAngle(1)) sin(PlaneAngle(1)) 0;-sin(PlaneAngle(1)) cos(PlaneAngle(1)) 0;0 0 1];
     1014    M1=[cos(PlaneAngle(1)) -sin(PlaneAngle(1)) 0;sin(PlaneAngle(1)) cos(PlaneAngle(1)) 0;0 0 1];
    10121015    M=M1;
    10131016    if checkM2
    1014         M2=[1 0 0;0 cos(PlaneAngle(2)) sin(PlaneAngle(2));0 -sin(PlaneAngle(2)) cos(PlaneAngle(2))];
    1015         M=M2*M1;% first rotate in the x,y plane with angle PlaneAngle(1), then slant around the new x axis0 with angle PlaneAngle(2)
     1017        M2=[1 0 0;0 cos(PlaneAngle(2)) -sin(PlaneAngle(2));0 sin(PlaneAngle(2)) cos(PlaneAngle(2))];
     1018        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)
    10161019    end
    10171020    norm_plane=M*[0 0 1]';
     
    10381041end
    10391042InterpMesh=min(DX,DY);%mesh used for interpolation in a slanted plane
    1040 % if strcmp(ObjectData.Type,'plane_z')
    1041 %     InterpMesh=10*InterpMesh;%TODO: temporary, to shorten computation
    1042 % end
    10431043
    10441044%% extrema along each axis
     
    11261126% end
    11271127icell_grid=[];% field cell index which defines the grid
    1128 if ~strcmp(ObjectData.ProjMode,'projection')&& ~strcmp(ObjectData.Type,'plane_z')% TODO:rationalize
    1129     %% define the new coordinates in case of interpolation on a imposed grid
    1130     if ~testYMin
    1131         errormsg='min Y value not defined for the projection grid';return
    1132     end
    1133     if ~testYMax
    1134         errormsg='max Y value not defined for the projection grid';return
    1135     end
    1136     if ~testXMin
    1137         errormsg='min X value not defined for the projection grid';return
    1138     end
    1139     if ~testXMax
    1140         errormsg='max X value not defined for the projection grid';return
    1141     end
    1142 else
     1128if strcmp(ObjectData.ProjMode,'projection')
    11431129    %% case of a grid requested by the input field
    11441130    for icell=1:numel(CellInfo)% TODO: recalculate coordinates here to get the bounds in the rotated coordinates
     
    11621148        end
    11631149    end
    1164     if ~isempty(find(check_grid))% if a grid is requested by the input field
     1150    if ~isempty(find(check_grid,1))% if a grid is requested by the input field
    11651151        if isempty(icell_grid)%  if the grid is not given by cell #icell_grid
    11661152            if ~isfield(FieldData,'XMax')
     
    11691155        end
    11701156    end
    1171 end
    1172 if ~isempty(find(check_grid))||~strcmp(ObjectData.ProjMode,'projection')%no existing gridded data used
     1157else
     1158    %% define the new coordinates in case of interpolation on a imposed grid
     1159    if ~testYMin
     1160        errormsg='min Y value not defined for the projection grid';return% %%%%%%%%%%%%%%%%        A REVOIR
     1161
     1162    end
     1163    if ~testYMax
     1164        errormsg='max Y value not defined for the projection grid';return
     1165    end
     1166    if ~testXMin
     1167        errormsg='min X value not defined for the projection grid';return
     1168    end
     1169    if ~testXMax
     1170        errormsg='max X value not defined for the projection grid';return
     1171    end
     1172end
     1173if ~isempty(find(check_grid,1))||~strcmp(ObjectData.ProjMode,'projection')%no existing gridded data used
    11731174    if isempty(icell_grid)||~strcmp(ObjectData.ProjMode,'projection')%no existing gridded data used
    11741175        AYName='coord_y';
    11751176        AXName='coord_x';
    1176         if strcmp(ObjectData.ProjMode,'projection')||strcmp(ObjectData.Type,'plane_z')
     1177        if strcmp(ObjectData.ProjMode,'projection')||strcmp(ObjectData.Type,'plane')
    11771178            ProjData.coord_y=[FieldData.YMin FieldData.YMax];%note that if projection is done on a grid, the Min and Max along each direction must have been defined
    11781179            ProjData.coord_x=[FieldData.XMin FieldData.XMax];
     
    14721473            end
    14731474           
    1474             if isequal(ProjMode{icell},'projection')% && (~testangle || test90y || test90x)
     1475            if strcmp(ProjMode{icell},'projection')% && (~testangle || test90y || test90x)
    14751476                if  NbDim==2 && ~testXMin && ~testXMax && ~testYMin && ~testYMax% no range restriction
    14761477                    ListVarName=[ListVarName FieldData.ListVarName(VarIndex)];
     
    16531654                        if isfield(FieldData,'VarAttribute')&&length(FieldData.VarAttribute)>=ivar
    16541655                            VarAttribute{length(ListVarName)+nbcoord}=FieldData.VarAttribute{ivar};
    1655                         end;
     1656                        end
    16561657                        ProjData.(FFName)=isnan(ProjData.(VarName));%detact NaN (points outside the interpolation range)
    16571658                        ProjData.(VarName)(ProjData.(FFName))=0; %set to 0 the NaN data
     
    16611662                    VarDimName=[VarDimName {DimCell}];
    16621663                    VarAttribute{numel(ListVarName)}.Role='errorflag';
    1663                 elseif ~testangle
     1664                elseif ~testangle % 3Dcase without change of angle
    16641665                    % unstructured z coordinate
    16651666                    test_sup=(Coord{1}>=ObjectData.Coord(1,3));
     
    16831684                    % determine the boundaries of the projected field,
    16841685                    % first find the 8 summits of the initial volume in the
    1685                     PlaneAngle=ObjectData.Angle*pi/180;
     1686                    PlaneAngle=[0 0 0];% default
     1687                    PlaneAngle(1:numel(ObjectData.Angle))=ObjectData.Angle*pi/180;
    16861688                    % new coordinates
    16871689                    Coord{1}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)});%initial z coordinates
    16881690                    Coord{2}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)});%initial y coordinates
    16891691                    Coord{3}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(3)});%initial x coordinates
    1690                     summit=zeros(3,8);% initialize summit coordinates
    1691                     summit(1,1:4)=[Coord{3}(1) Coord{3}(end) Coord{3}(1) Coord{3}(end)];%square
    1692                     summit(2,1:4)=[Coord{2}(1) Coord{2}(1) Coord{2}(end) Coord{2}(end)];% square at z= Coord{1}(1)
    1693                     summit(1:2,5:8)=summit(1:2,1:4);
    1694                     summit(3,:)=[Coord{1}(1)*ones(1,4) Coord{1}(end)*ones(1,4)];
    1695                     %Mrot_inv=rodrigues(-PlaneAngle);
    1696                     newsummit=zeros(3,8);% initialize the rotated summit coordinates
     1692%                     summit=zeros(3,8);% initialize summit coordinates
     1693%                     summit(1,1:4)=[Coord{3}(1) Coord{3}(end) Coord{3}(1) Coord{3}(end)];%square
     1694%                     summit(2,1:4)=[Coord{2}(1) Coord{2}(1) Coord{2}(end) Coord{2}(end)];% square at z= Coord{1}(1)
     1695%                     summit(1:2,5:8)=summit(1:2,1:4);
     1696%                     summit(3,:)=[Coord{1}(1)*ones(1,4) Coord{1}(end)*ones(1,4)];
     1697%                     %Mrot_inv=rodrigues(-PlaneAngle);
     1698%                     newsummit=zeros(3,8);% initialize the rotated summit coordinates
    16971699                    ObjectData.Coord=ObjectData.Coord';% set ObjectData.Coord as a vertical vector
    16981700                    if size(ObjectData.Coord,1)<3
     
    17001702                    end
    17011703                   
    1702                     M1=[cos(PlaneAngle(1)) sin(PlaneAngle(1)) 0;-sin(PlaneAngle(1)) cos(PlaneAngle(1)) 0;0 0 1];
    1703                     M2=[1 0 0;0 cos(PlaneAngle(2)) sin(PlaneAngle(2));0 -sin(PlaneAngle(2)) cos(PlaneAngle(2))];
    1704                     M=M2*M1;
     1704%                     M1=[cos(PlaneAngle(1)) sin(PlaneAngle(1)) 0;-sin(PlaneAngle(1)) cos(PlaneAngle(1)) 0;0 0 1];
     1705%                     M2=[1 0 0;0 cos(PlaneAngle(2)) sin(PlaneAngle(2));0 -sin(PlaneAngle(2)) cos(PlaneAngle(2))];
     1706%                     M=M1*M2;
    17051707                    M_inv=inv(M);
    17061708                   
    1707                     for isummit=1:8% TODO: introduce a function for rotation of n points (to use also for scattered data)
    1708                         newsummit(:,isummit)=M*(summit(:,isummit)-(ObjectData.Coord));
    1709                     end
    1710                     coord_x_proj=min(newsummit(1,:)):InterpMesh: max(newsummit(1,:));% set of coordinqtes in the projection plane
    1711                     coord_y_proj=min(newsummit(2,:)):InterpMesh: max(newsummit(2,:));
    1712                     coord_z_proj=-width:width;
     1709%                     for isummit=1:8% TODO: introduce a function for rotation of n points (to use also for scattered data)
     1710%                         newsummit(:,isummit)=M*(summit(:,isummit)-(ObjectData.Coord));
     1711%                     end
     1712%                     coord_x_proj=min(newsummit(1,:)):InterpMesh: max(newsummit(1,:));% set of coordinqtes in the projection plane
     1713%                     coord_y_proj=min(newsummit(2,:)):InterpMesh: max(newsummit(2,:));
     1714%                     coord_z_proj=-width:width;
     1715                    coord_x_proj=ObjectData.RangeX(1):InterpMesh:ObjectData.RangeX(2);% set of coordinqtes in the projection plane
     1716                     coord_y_proj=ObjectData.RangeY(1):InterpMesh:ObjectData.RangeY(2);
     1717                    coord_z_proj=-floor(ObjectData.RangeInterp/InterpMesh):InterpMesh:floor(ObjectData.RangeInterp/InterpMesh);
    17131718                    %Mrot=rodrigues(PlaneAngle);% inverse rotation matrix
    1714                     Origin=M_inv*[coord_x_proj(1);coord_y_proj(1);coord_z_proj(1)]+ObjectData.Coord;
     1719                    %Origin=M_inv*[coord_x_proj(1);coord_y_proj(1);coord_z_proj(1)]+ObjectData.Coord;
    17151720                    npx=numel(coord_x_proj);
    17161721                    npy=numel(coord_y_proj);
     
    17221727                    iX=[coord_x_proj(end)-coord_x_proj(1);0;0]/(npx-1);
    17231728                    iY=[0;coord_y_proj(end)-coord_y_proj(1);0]/(npy-1);
     1729                    if npz==1
     1730                        iZ=[0;0;0];
     1731                    else
    17241732                    iZ=[0;0;coord_z_proj(end)-coord_z_proj(1)]/(npz-1);
     1733                    end
    17251734                    %                     iX(1:2)=[cosphi -sinphi;sinphi cosphi]*iX(1:2);
    17261735                    %                     iY(1:2)=[-cosphi -sinphi;sinphi cosphi]*iY(1:2);
     
    17311740                   
    17321741                    [Grid_x,Grid_y,Grid_z]=meshgrid(0:npx-1,0:npy-1,0:npz-1);
     1742                    %[Grid_x,Grid_y,Grid_z]=meshgrid(0:npz-1,0:npy-1,0:npx-1);
    17331743                    if ismatrix(Grid_x)% add a singleton in case of a single z value
    17341744                        Grid_x=shiftdim(Grid_x,-1);
     
    17361746                        Grid_z=shiftdim(Grid_z,-1);
    17371747                    end
    1738                     XI=Origin(1)+ix(1)*Grid_x+iy(1)*Grid_y+iz(1)*Grid_z;
    1739                     YI=Origin(2)+ix(2)*Grid_x+iy(2)*Grid_y+iz(2)*Grid_z;
    1740                     ZI=Origin(3)+ix(3)*Grid_x+iy(3)*Grid_y+iz(3)*Grid_z;
    1741                     [X,Y,Z]=meshgrid(Coord{3},Coord{2},Coord{1});% mesh in the initial coordinates
     1748                    XI=ObjectData.Coord(1)+ix(1)*Grid_x+iy(1)*Grid_y+iz(1)*Grid_z;
     1749                    YI=ObjectData.Coord(2)+ix(2)*Grid_x+iy(2)*Grid_y+iz(2)*Grid_z;
     1750                    ZI=ObjectData.Coord(3)+ix(3)*Grid_x+iy(3)*Grid_y+iz(3)*Grid_z;
     1751                  %  [X,Y,Z]=meshgrid(Coord{3},Coord{2},Coord{1});% grid of initial coordinates
    17421752                    for ivar=VarIndex
    17431753                        VarName=FieldData.ListVarName{ivar};
     
    17451755                        VarDimName=[VarDimName {{'coord_y','coord_x'}}];
    17461756                        VarAttribute{length(ListVarName)}=FieldData.VarAttribute{ivar}; %reproduce the variable attributes
    1747                         FieldData.(VarName)=permute(FieldData.(VarName),[2 3 1]);
     1757                        FieldData.(VarName)=permute(FieldData.(VarName),[2 3 1]); %coordinate permutation needed to use interp3
     1758                        indexnan=isnan(FieldData.(VarName));
     1759                        FieldData.(VarName)(indexnan)=0;%set to zero the undefined values
    17481760                        ProjData.coord_x=coord_x_proj;
    17491761                        ProjData.coord_y=coord_y_proj;
    1750                         ProjData.(VarName)=interp3(X,Y,Z,double(FieldData.(VarName)),XI,YI,ZI,'*linear');
    1751                         ProjData.(VarName)=nanmean(ProjData.(VarName),3);
     1762                        ProjData.(VarName)=interp3(Coord{3},Coord{2},Coord{1},double(FieldData.(VarName)),ZI,YI,XI,'*linear');
     1763                        ProjData.(VarName)=nanmean(ProjData.(VarName),1);
    17521764                        ProjData.(VarName)=squeeze(ProjData.(VarName));
    17531765                    end
  • trunk/src/series.m

    r1071 r1072  
    14521452    Param.TransformInput=SeriesData.TransformInput;
    14531453end
     1454if isfield(SeriesData,'ProjObject')
     1455    Param.ProjObject=SeriesData.ProjObject;
     1456end
    14541457if ~isfield(SeriesData,'i1_series')
    14551458    errormsg='The input field series needs to be refreshed: press REFRESH';
     
    16021605NbExp=1;% initiate the number of experiments set by the GUI browse_data, =1 otherwise
    16031606if get(handles.Replicate,'Value')
    1604     set(handles.Replicate,'BackgroundColor',[1 1 0])%paint Relicate button in yellow
    16051607    hh=findobj(allchild(0),'Tag','browse_data');
    1606     BrowseData=guidata(hh);
    1607     SourceDir=get(BrowseData.SourceDir,'String');
    1608     ListExp=get(BrowseData.ListExperiments,'String');
    1609     ExpIndices=get(BrowseData.ListExperiments,'Value');
    1610     ListExp=ListExp(ExpIndices);
    1611     ListDevices=get(BrowseData.ListDevices,'String');
    1612     DeviceIndices=get(BrowseData.ListDevices,'Value');
    1613     ListDevices=ListDevices(DeviceIndices);
    1614     ListDataSeries=get(BrowseData.DataSeries,'String');
    1615     DataSeriesIndices=get(BrowseData.DataSeries,'Value');
    1616     ListDataSeries=ListDataSeries(DataSeriesIndices);
    1617     NbExp=0; % counter of the number of experiments set by the GUI browse_data
    1618     for iexp=1:numel(ListExp)
    1619         if ~isempty(regexp(ListExp{iexp},'^\+/'))% if it is a folder
    1620             if strcmp(get(BrowseData.DataSeries,'enable'),'off');%case of a multiple input line for series
    1621                 NbExp=NbExp+1;
    1622                 ExpIndex{NbExp}=iexp;
    1623                 for idevice=1:numel(ListDevices)
    1624                     lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),...
    1625                         regexprep(ListDevices{idevice},'^\+/',''));
    1626                     ldir=regexprep(ListDataSeries{idevice},'^\+/','');
    1627                     ListPath{idevice,NbExp}=lpath;
    1628                     ListSubdir{idevice,NbExp}=ldir;
    1629                 end
    1630             else
    1631                 for idevice=1:numel(ListDevices)
    1632                     if ~isempty(regexp(ListDevices{idevice},'^\+/'))% if it is a folder
    1633                         for isubdir=1:numel(ListDataSeries)
    1634                             if ~isempty(regexp(ListDataSeries{isubdir},'^\+/'))% if it is a folder
    1635                                 lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),...
    1636                                     regexprep(ListDevices{idevice},'^\+/',''));
    1637                                 ldir= regexprep(ListDataSeries{isubdir},'^\+/','');
    1638                                 if exist(fullfile(lpath,ldir),'dir')
    1639                                     NbExp=NbExp+1;
    1640                                     ExpIndex{NbExp}=iexp;
    1641                                     ListPath{NbExp}=lpath;
    1642                                     ListSubdir{NbExp}=ldir;
     1608    if isempty(hh)
     1609        set(handles.Replicate,'Value',0)
     1610    else
     1611        set(handles.Replicate,'BackgroundColor',[1 1 0])%paint Relicate button in yellow
     1612        BrowseData=guidata(hh);
     1613        SourceDir=get(BrowseData.SourceDir,'String');
     1614        ListExp=get(BrowseData.ListExperiments,'String');
     1615        ExpIndices=get(BrowseData.ListExperiments,'Value');
     1616        ListExp=ListExp(ExpIndices);
     1617        ListDevices=get(BrowseData.ListDevices,'String');
     1618        DeviceIndices=get(BrowseData.ListDevices,'Value');
     1619        ListDevices=ListDevices(DeviceIndices);
     1620        ListDataSeries=get(BrowseData.DataSeries,'String');
     1621        DataSeriesIndices=get(BrowseData.DataSeries,'Value');
     1622        ListDataSeries=ListDataSeries(DataSeriesIndices);
     1623        NbExp=0; % counter of the number of experiments set by the GUI browse_data
     1624        for iexp=1:numel(ListExp)
     1625            if ~isempty(regexp(ListExp{iexp},'^\+/'))% if it is a folder
     1626                if strcmp(get(BrowseData.DataSeries,'enable'),'off');%case of a multiple input line for series
     1627                    NbExp=NbExp+1;
     1628                    ExpIndex{NbExp}=iexp;
     1629                    for idevice=1:numel(ListDevices)
     1630                        lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),...
     1631                            regexprep(ListDevices{idevice},'^\+/',''));
     1632                        ldir=regexprep(ListDataSeries{idevice},'^\+/','');
     1633                        ListPath{idevice,NbExp}=lpath;
     1634                        ListSubdir{idevice,NbExp}=ldir;
     1635                    end
     1636                else
     1637                    for idevice=1:numel(ListDevices)
     1638                        if ~isempty(regexp(ListDevices{idevice},'^\+/'))% if it is a folder
     1639                            for isubdir=1:numel(ListDataSeries)
     1640                                if ~isempty(regexp(ListDataSeries{isubdir},'^\+/'))% if it is a folder
     1641                                    lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),...
     1642                                        regexprep(ListDevices{idevice},'^\+/',''));
     1643                                    ldir= regexprep(ListDataSeries{isubdir},'^\+/','');
     1644                                    if exist(fullfile(lpath,ldir),'dir')
     1645                                        NbExp=NbExp+1;
     1646                                        ExpIndex{NbExp}=iexp;
     1647                                        ListPath{NbExp}=lpath;
     1648                                        ListSubdir{NbExp}=ldir;
     1649                                    end
    16431650                                end
    16441651                            end
     
    16481655            end
    16491656        end
    1650     end
    1651     answer=msgbox_uvmat('INPUT_Y-N-Cancel',['replicate the processing on ' num2str(NbExp) ' data series']);
    1652     if strcmp(answer,'Cancel')||strcmp(answer,'No')
    1653         return
     1657        answer=msgbox_uvmat('INPUT_Y-N-Cancel',['replicate the processing on ' num2str(NbExp) ' data series']);
     1658        if strcmp(answer,'Cancel')||strcmp(answer,'No')
     1659            return
     1660        end
    16541661    end
    16551662end
     
    16781685    Param.IndexRange.last_i=str2num(get(handles.num_last_i,'String'));
    16791686   
    1680     %% create the output data directory if needed, after chcking its existence
     1687    %% create the output data directory if needed, after checking its existence
    16811688    OutputDir='';
    16821689    answer='';
     
    26542661    ProjObjectVisible='off';
    26552662end
    2656 set(handles.ProjObject,'Visible',ProjObjectVisible)
     2663set(handles.ProjObjectName,'Visible',ProjObjectVisible)
    26572664set(handles.DeleteObject,'Visible',ProjObjectVisible)
    26582665set(handles.ViewObject,'Visible',ProjObjectVisible)
     
    30743081        end
    30753082        ProjObject=read_GUI(hset_object);
    3076         set(handles.ProjObject,'String',ProjObject.Name); % display the object name
     3083        set(handles.ProjObjectName,'String',ProjObject.Name); % display the object name
    30773084        SeriesData=get(handles.series,'UserData');
    30783085        SeriesData.ProjObject=ProjObject;
     
    30823089    set(handles.DeleteObject,'Visible','on');
    30833090    set(handles.ViewObject,'Visible','on');
    3084     set(handles.ProjObject,'Visible','on');
     3091    set(handles.ProjObjectName,'Visible','on');
    30853092else
    30863093    set(handles.EditObject,'Visible','off');
     
    30903097        set(handles.ViewObject,'Value',0);
    30913098    end
    3092     set(handles.ProjObject,'Visible','off');
     3099    set(handles.ProjObjectName,'Visible','off');
    30933100end
    30943101
     
    31313138SeriesData.ProjObject=[];
    31323139set(handles.series,'UserData',SeriesData)
    3133 set(handles.ProjObject,'String','')
    3134 set(handles.ProjObject,'Visible','off')
     3140set(handles.ProjObjectName,'String','')
     3141set(handles.ProjObjectName,'Visible','off')
    31353142set(handles.CheckObject,'Value',0)
    31363143set(handles.ViewObject,'Visible','off')
     
    33893396set(handles.series,'UserData',SeriesData)
    33903397if isfield(Param,'CheckObject') && isequal(Param.CheckObject,1)
    3391     set(handles.ProjObject,'String',Param.ProjObject.Name)
     3398    set(handles.ProjObjectName,'String',Param.ProjObject.Name)
    33923399    set(handles.ViewObject,'Visible','on')
    33933400    set(handles.EditObject,'Visible','on')
    33943401    set(handles.DeleteObject,'Visible','on')
    33953402else     
    3396     set(handles.ProjObject,'String','')
    3397     set(handles.ProjObject,'Visible','off')
     3403    set(handles.ProjObjectName,'String','')
     3404    set(handles.ProjObjectName,'Visible','off')
    33983405    set(handles.ViewObject,'Visible','off')
    33993406    set(handles.EditObject,'Visible','off')
     
    38743881    end
    38753882end
     3883
     3884
     3885
  • trunk/src/set_object.m

    r1071 r1072  
    100100
    101101% fill the interface as set in the input data:
    102 if exist('data','var') 
     102if exist('data','var')
    103103    if isfield(data,'Coord')
    104104        set(handles.Coord,'Data',data.Coord)
    105105        if size(data.Coord,2)==3
    106         set(handles.z_slider,'Visible','on')
     106            set(handles.z_slider,'Visible','on')
    107107        end
    108108    else
     
    114114    if isfield(data,'ProjModeMenu')
    115115        set(handles.ProjMode,'UserData',data.ProjModeMenu)% data.ProjModeMenu as default menu (used in Type_Callback)
    116     end     
     116    end
    117117    errormsg=fill_GUI(data,handles.set_object);
    118118    if ~isempty(errormsg)
     
    120120        return
    121121    end
    122     Type_Callback(hObject, eventdata, handles)% update the GUI set_object depending on the object type   
     122    Type_Callback(hObject, eventdata, handles)% update the GUI set_object depending on the object type
    123123    set(handles.REFRESH,'BackgroundColor',[1 0 0])
    124124    if isfield(data,'RangeZ')
     
    151151        set(handles.num_RangeY_1,'String',num2str(min(data.RangeY),3))
    152152    end
    153     if isfield(data,'RangeZ')&& ~strcmp(data.Type,'plane_z')%TODO: generalise
     153    if isfield(data,'RangeZ')%&& ~strcmp(data.Type,'plane_z')%TODO: generalise
    154154        if ischar(data.RangeZ)
    155155            data.RangeZ=str2num(data.RangeZ);
     
    159159            set(handles.num_RangeZ_1,'String',num2str(min(data.RangeZ),3))
    160160        end
    161     end 
     161    end
    162162    if ~isfield(data,'Angle')
    163163        data.Angle=[0 0];
    164164    end
    165 %     if isfield(data,'Angle') && isequal(numel(data.Angle),3)
    166          set(handles.num_Angle_1,'String',num2str(data.Angle(1)))
    167 %          set(handles.num_Angle_2,'String',num2str(data.Angle(2)))
    168 %         set(handles.num_Angle_3,'String',num2str(data.Angle(3)))
    169 %     end
     165    set(handles.num_Angle_1,'String',num2str(data.Angle(1)))
     166    if numel(data.Angle)==2
     167        set(handles.num_Angle_2,'Visible','on')
     168        set(handles.num_Angle_2,'String',num2str(data.Angle(2)))
     169    end
    170170end
    171171set(get(handles.set_object,'children'),'enable','off')
    172172set(handles.SAVE,'enable','on')
    173 % set(handles.REFRESH,'enable','off')
    174173
    175174
     
    245244        end
    246245    case {'rectangle','ellipse','plane','volume'}
     246        if ~isempty(Coord)
    247247        Coord=Coord(1,:);
     248        end
    248249end
    249250set(handles.Coord,'Data',Coord)
  • trunk/src/uvmat.m

    r1071 r1072  
    10071007                data.RangeY=UvData.Field.CoordMesh;
    10081008            case 'plane_z'
     1009                data.Type='plane';
     1010                if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
     1011                    data.RangeY=[UvData.Field.ZMin UvData.Field.ZMax];
     1012                else
     1013                    msgbox_uvmat('ERROR','The input field is not 3D: no vertical plane projection')
     1014                    return
     1015                end
    10091016                data.Angle=[0 90];
    10101017                data.DX=UvData.Field.CoordMesh;
    10111018                data.DY=UvData.Field.CoordMesh;
    1012                 data.RangeZ=UvData.Field.CoordMesh;
     1019                data.RangeZ=UvData.Field.CoordMesh;     
    10131020                data.Coord=[];
    10141021            otherwise
     
    10211028    end
    10221029end
    1023 
     1030hset_object=findobj(allchild(0),'Tag','set_object');
     1031if ~isempty(hset_object)
     1032    delete(hset_object)%delete existing GUI set_object
     1033end
    10241034hset_object=set_object(data,handles);% call the GUI set_object
    10251035hchild=get(hset_object,'children');
     
    14381448end
    14391449if numel(find(select_line))<2
    1440     msgbox_uvmat('ERROR',{'light rays must be defined by at least two lines created by Projection object/line in the menu bar'; ...
    1441     'use a third line to get a reference luminosity profile accross the illumination beam'});
     1450    msgbox_uvmat('ERROR',{'lines must be defined by Projection object in the upper menu bar: ';'1-two lines following the illumination rays'; ...
     1451    '2-a reference line near the fluid boundary receiving the illumination beam';'a mask polygon to select the area in which the exponential decay is fitted'});
    14421452    return
    14431453else
     
    14571467    blackoffset=XmlData.LIFCalib.BlackOffset ;% image value for black background, to be determined by taking images with a cover on the objective lens
    14581468end
    1459 answer=msgbox_uvmat('INPUT_TXT','camera offset value in the absence of illumination:', num2str(blackoffset));
     1469
     1470prompt = {'offset luminosity value in the absence of illumination';'smoothing length for the reference line (in pixels)'};
     1471    dlg_title = 'set the parameters for LIF';
     1472    num_lines= 2;
     1473    def     = { '0';'20'};
     1474    answer = inputdlg(prompt,dlg_title,num_lines,def);
     1475
    14601476if strcmp(answer,'Cancel')
    14611477    return
    14621478else
    1463     XmlData.LIFCalib.BlackOffset=str2num(answer) ;% image value for black background, to be determined by taking images with a cover on the objective lens
     1479    XmlData.LIFCalib.BlackOffset=str2num(answer{1}) ;% image value for black background, to be determined by taking images with a cover on the objective lens
     1480    XmlData.LIFCalib.SmoothingLength=str2num(answer{2}) ;% smoothing length used for the reference line
    14641481end
    14651482
     
    14911508
    14921509%% use the third line for reference luminosity, renormalize the image intensity along each ray to get a uniform brightness along this line
     1510%UvData.Field.CoordMesh
    14931511if numel(find(select_line))==3
    14941512    x_ref=linspace(LineData{3}.Coord(1,1),LineData{3}.Coord(2,1),10);
     
    15081526    line_nan= isnan(dist_source);
    15091527    dist_source_pixel(line_nan)=1;
    1510     width=20; %number of pixels used for reference
     1528    width=XmlData.LIFCalib.SmoothingLength; %number of pixels used for reference
    15111529    DataPol.A=double(DataPol.A)-XmlData.LIFCalib.BlackOffset;% black background substracted
    15121530    Anorm=zeros(size(DataPol.A));
     
    15161534    end
    15171535    lum(line_nan)=NaN;
     1536    XmlData.LIFCalib.RefLineAzimuth=DataPol.Coord_y;
     1537    XmlData.LIFCalib.RefLineRadius=dist_source;
     1538    XmlData.LIFCalib.RefLineLum=lum;
    15181539    figure(11)
    15191540    plot(1:size(DataPol.A,1),lum)
     
    15541575    [XLine,YLine] = pol2cart(ThetaLine,RLine);
    15551576    XLine=XLine+x0;
    1556     YLine=YLine+y0; 
     1577    YLine=YLine+y0;
    15571578    if ~isempty(index_mask)
    15581579        ind_good=inpolygon(XLine,YLine,MaskData.Coord(:,1),MaskData.Coord(:,2));
    15591580        if numel(find(ind_good))>100
    1560         ALine=ALine(ind_good);
    1561         RLine=RLine(ind_good);
     1581            ALine=ALine(ind_good);
     1582            RLine=RLine(ind_good);
    15621583        else
    15631584            continue
     
    15651586    end
    15661587    p = polyfit(RLine,ALine,1);
    1567         gamma_coeff(iY)=-p(1);
     1588    gamma_coeff(iY)=-p(1);
    15681589end
    15691590
     
    15781599ylabel('decay coeff(m-1)')
    15791600
     1601%% keep the average of gamma_coeff
     1602XmlData.LIFCalib.DecayRate=mean(gamma_coeff(gamma_coeff>0));
     1603
    15801604%% record the calibration data in the xml file
    15811605XmlFileName=find_imadoc(get(handles.RootPath,'String'),get(handles.SubDir,'String'),get(handles.RootFile,'String'),get(handles.FileExt,'String'));
    1582 answer=msgbox_uvmat('INPUT_Y-N','save the illumination origin in the current xml file?');
     1606answer=msgbox_uvmat('INPUT_Y-N','save the LIF parameters in the current xml file?');
    15831607if strcmp(answer,'Yes')
    15841608    t=xmltree(XmlFileName); %read the file
     
    16051629    end
    16061630    uid_origin=find(t,'ImaDoc/LIFCalib/LightOrigin');
    1607     if ~isempty(uid_origin)  %if GeometryCalib does not already exists, create it
    1608          t=delete(t,uid_origin);
     1631    if ~isempty(uid_origin)  %if LightOrigin already exists, delete it
     1632        t=delete(t,uid_origin);
    16091633    end
    16101634    uid_line=find(t,'ImaDoc/LIFCalib/Ray1Coord');
    1611     if ~isempty(uid_line)  %if GeometryCalib does not already exists, create it
    1612          t=delete(t,uid_line);
    1613     end
    1614        uid_line=find(t,'ImaDoc/LIFCalib/Ray2Coord');
    1615     if ~isempty(uid_line)  %if GeometryCalib does not already exists, create it
    1616          t=delete(t,uid_line);
    1617     end
    1618        uid_mask=find(t,'ImaDoc/LIFCalib/MaskPolygonCoord');
    1619     if ~isempty(uid_mask)  %if GeometryCalib does not already exists, create it
    1620          t=delete(t,uid_mask);
    1621     end
    1622      uid_BlackOffset=find(t,'ImaDoc/LIFCalib/BlackOffset');
    1623     if ~isempty(uid_BlackOffset)  %if GeometryCalib does not already exists, create it
    1624          t=delete(t,uid_BlackOffset);
    1625     end
     1635    if ~isempty(uid_line)  %if Ray1Coord already exists, delete it
     1636        t=delete(t,uid_line);
     1637    end
     1638    uid_line=find(t,'ImaDoc/LIFCalib/Ray2Coord');
     1639    if ~isempty(uid_line)  %if Ray2Coord already exists, delete it
     1640        t=delete(t,uid_line);
     1641    end
     1642    uid_line=find(t,'ImaDoc/LIFCalib/RefLineCoord');
     1643    if ~isempty(uid_line)  %if RefLineCoord already exists, delete it
     1644        t=delete(t,uid_line);
     1645    end
     1646    uid_mask=find(t,'ImaDoc/LIFCalib/MaskPolygonCoord');
     1647    if ~isempty(uid_mask) %if MaskPolygonCoord already exists, delete it
     1648        t=delete(t,uid_mask);
     1649    end
     1650    uid_BlackOffset=find(t,'ImaDoc/LIFCalib/BlackOffset');
     1651    if ~isempty(uid_BlackOffset)  %if BlackOffset already exists, delete it
     1652        t=delete(t,uid_BlackOffset);
     1653    end
     1654    uid_DecayRate=find(t,'ImaDoc/LIFCalib/DecayRate');
     1655    if ~isempty(uid_DecayRate)  %if DecayRate already exists, delete it
     1656        t=delete(t,uid_DecayRate);
     1657    end
     1658    uid_RefLineRadius=find(t,'ImaDoc/LIFCalib/RefLineRadius');
     1659    if ~isempty(uid_RefLineRadius)  %if RefLineLum already exists, delete it
     1660        t=delete(t,uid_RefLineRadius);
     1661    end
     1662    uid_RefLineLum=find(t,'ImaDoc/LIFCalib/RefLineLum');
     1663    if ~isempty(uid_RefLineLum)  %if RefLineLum already exists, delete it
     1664        t=delete(t,uid_RefLineLum);
     1665    end
     1666    uid_RefLineAzimuth=find(t,'ImaDoc/LIFCalib/RefLineAzimuth');
     1667    if ~isempty(uid_RefLineAzimuth)  %if RefLineLum already exists, delete it
     1668        t=delete(t,uid_RefLineAzimuth);
     1669    end
     1670   
    16261671    % save the LIF calibration data
    16271672    t=struct2xml(XmlData.LIFCalib,t,uid_illumination);
    16281673    save(t,XmlFileName);
    1629 end
    1630 
    1631 
    1632 
    1633 
     1674   
     1675    % display the concentration in uvmat
     1676    InputFileREFRESH_Callback(hObject, eventdata, handles);% refresh the current xml file to apply 'ima2concentration'
     1677    transform_list=get(handles.TransformName,'String');
     1678    ichoice=find(strcmp('ima2concentration',transform_list),1);%look for the selected fct in the existing menu
     1679    if isempty(ichoice)% if the item is not found, add it to the menu (before 'more...' and select it)
     1680        transform_list=transform_list(1:end-1);
     1681        ichoice=numel(transform_list)-1;
     1682    end
     1683    set(handles.TransformName,'Value',ichoice)
     1684    TransformName_Callback(hObject, eventdata, handles)
     1685end
    16341686
    16351687
     
    31493201    set(handles.Dt_txt,'String','')% the time interval indication is suppressed
    31503202    return
    3151 end
    3152 
    3153 %% check the input file indexing:
    3154 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    3155 NomType=get(handles.NomType,'String');
    3156 if ~isempty(find(regexp(NomType,'-')))
    3157     msgbox_uvmat('ERROR','The movie pair requires file series with a single index on the first input line')
    3158     return
    3159 end
    3160 filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line)
    3161 
    3162 set(handles.movie_pair,'BusyAction','queue')%
    3163 set(handles.CheckFixPair,'Value',1)% impose fixed pair (needed for function runpm)
    3164 set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity
    3165 set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity
    3166 drawnow
    3167 % list_fields=get(handles.FieldName,'String');% list menu fields
    3168 % index_fields=get(handles.FieldName,'Value');% selected string index
    3169 % FieldName=list_fields{index_fields}; % selected field
    3170 
    3171 
    3172 % if isequal(FieldName,'image')
    3173 %     index=1;
    3174 
    3175 % else
    3176 %     list_fields=get(handles.FieldName_1,'String');% list menu fields
    3177 %     index_fields=get(handles.FieldName_1,'Value');% selected string index
    3178 %     FieldName=list_fields{index_fields}; % selected field
    3179 %     if isequal(FieldName,'image')
    3180 %         index=2;
    3181 %         [RootPath,SubDir,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles);% get info from the second input line
    3182 %     else
    3183 %         msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
    3184 %         set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
    3185 %         set(handles.movie_pair,'Value',0)
    3186 %         return
    3187 %     end
    3188 % end
    3189 num_i1=str2num(get(handles.i1,'String'));
    3190 num_j1=stra2num(get(handles.j1,'String'));
    3191 num_i2=str2num(get(handles.i2,'String'));
    3192 num_j2=stra2num(get(handles.j2,'String'));
    3193 
    3194 %% determine the name 'imaname_1' of the second file in the pair
    3195 imaname_1='';
    3196 if isempty(num_j2)% no second j index indicated
    3197     if isempty(num_i2)
    3198         if strcmp(get(handles.j2,'Visible'),'on') %if the j box is visible
    3199             imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1,[],num_j1+1);
    3200         end
    3201         if exist(imaname_1,'file')
    3202             num_j2=num_j1+1;% look by default for the next j index as the second file
    3203             set(handles.j2,'String',num2stra(num_j2,NomType));
    3204         else
    3205             imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1+1,[],num_j1);
    3206             if exist(imaname_1,'file')
    3207                 num_i2=num_i1+1;
    3208                 set(handles.i2,'String',num2str(num_i2));
    3209             else
    3210                 msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
    3211                 set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
    3212                 set(handles.movie_pair,'Value',0)
    3213                 return
    3214             end
    3215         end
    3216     else
    3217         num_j2=num_j1;%repeat the index i1 by default
    3218     end
    3219 end
    3220 if isempty(num_i2)
    3221     num_i2=num_i1;%repeat the index i1 by default
    3222 end
    3223 if isempty(num_j1)
    3224     num_j1=1;
    3225 end
    3226 if isempty(num_j2)
    3227     num_j2=num_j1;%repeat the index i1 by default
    3228 end
    3229 imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i2,[],num_j2);
    3230 if strcmp(NomType,'*')
    3231     num_frame=num_i2;
    3232 else
    3233     num_frame=num_j2;
    3234 end
    3235 if ~exist(imaname_1,'file')
    3236       msgbox_uvmat('ERROR',['second input open (-)  ' imaname_1 ' not found']);
    3237       set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
    3238        set(handles.movie_pair,'Value',0)
    3239       return
    3240 end
    3241 
    3242 %% display the first field in the pair (including possibly a background field from second line input filename_1)
    3243 filename_1='';%default
    3244 FileIndex_1='';
    3245 if get(handles.SubField,'Value')
    3246     [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
    3247     filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
    3248 end
    3249 % num_i1=stra2num(get(handles.i1,'String'));
    3250 % num_i2=stra2num(get(handles.i2,'String'));
    3251 % num_j1=stra2num(get(handles.j1,'String'));
    3252 % num_j2=stra2num(get(handles.j2,'String'));
    3253 [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);% get the indices of the second series from the string FileIndex_1
    3254 if isempty(j1_1)% case of movies, the index is not given by file index
    3255     j1_1=num_j1;
    3256 end
    3257 
    3258 errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
    3259 
    3260 if isempty(errormsg)
    3261     set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull
    3262 else
    3263      msgbox_uvmat('ERROR',errormsg);
    3264      set(handles.REFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull
    3265 end
    3266 UvData=get(handles.uvmat,'UserData');
    3267 Field_a=UvData.Field;% movie on the field defined by the second input line
    3268 
    3269 %% display time interval for the image pair
    3270 if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'Time')...
    3271         && size(UvData.XmlData{1}.Time,1)>=num_i2+1 && size(UvData.XmlData{1}.Time,2)>=num_j2+1
    3272     dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1));
    3273     if  isfield(UvData,'TimeUnit')
    3274         set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  m' UvData.TimeUnit] )
    3275     else
    3276         set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  10^(-3)'] )
    3277     end
    3278 else
    3279     set(handles.Dt_txt,'String','')
    3280 end
    3281 
    3282 %% read the second field
    3283 if isempty(UvData.MovieObject)
    3284     [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileInfo{index}.FileType,[],num_frame);
    3285 else
    3286     [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileInfo{1}.FileType,UvData.MovieObject{1},num_frame);
    3287 end
    3288 if ~isempty(errormsg)
    3289     msgbox_uvmat('ERROR',['Error in reading second image: ' errormsg])
    3290     return
    3291 end
    3292 
    3293 %% apply phys or other transform on the two input fields
    3294 transform=get(handles.TransformPath,'UserData');
    3295 if  ~isempty(transform)
    3296     if isfield(UvData,'XmlData') && ~isempty(UvData.XmlData) %use geometry calib recorded from the ImaDoc xml file as first priority
    3297         if nargin(transform)>=2
    3298             Field_b=transform(Field_b,UvData.XmlData{1});
    3299         else
    3300             Field_b=transform(Field_b);
    3301         end
    3302     end
     3203else
     3204    set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
     3205    drawnow
     3206end
     3207
     3208increment=str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d
     3209if isnan(increment)% case of free increment: move to next available field index
     3210    increment='+';
    33033211end
    33043212
     
    33083216set(handles.speed,'Visible','on')
    33093217set(handles.speed_txt,'Visible','on')
     3218set(handles.movie_pair,'BusyAction','queue')
    33103219while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue') % enable STOP command
    33113220    % read and plot the series of images in non erase mode
    3312     set(hima,'CData',Field_b.A); %TODO: generalise to other kinds of fields
     3221    errormsg=runpm(hObject,eventdata,handles,increment);
     3222    if ~isempty(errormsg)
     3223        msgbox_uvmat('ERROR',errormsg);
     3224    end
     3225   
     3226    %     set(hima,'CData',Field_b.A); %TODO: generalise to other kinds of fields
    33133227    pause(1.02-get(handles.speed,'Value'));% wait for next image
    3314     set(hima,'CData',Field_a.A);
     3228    errormsg=runpm(hObject,eventdata,handles,-increment);
     3229   
     3230    %     set(hima,'CData',Field_a.A);
    33153231    pause(1.02-get(handles.speed,'Value'));% wait for next image
    33163232end
     
    33183234set(handles.movie_pair,'Value',0)
    33193235set(handles.Dt_txt,'String','')
     3236
     3237
     3238
     3239
     3240set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back in red
     3241
     3242%
     3243% set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
     3244% drawnow
     3245% increment=-str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d
     3246% if isnan(increment)% case of free increment: move to previous available field index
     3247%     increment='-';
     3248% end
     3249% errormsg=runpm(hObject,eventdata,handles,increment);
     3250% if ~isempty(errormsg)
     3251%     msgbox_uvmat('ERROR',errormsg);
     3252% end
     3253% set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back in red
     3254%
     3255% %% check the input file indexing:
     3256% [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     3257% NomType=get(handles.NomType,'String');
     3258% if ~isempty(find(regexp(NomType,'-')))
     3259%     msgbox_uvmat('ERROR','The movie pair requires file series with a single index on the first input line')
     3260%     return
     3261% end
     3262% filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line)
     3263%
     3264% set(handles.movie_pair,'BusyAction','queue')%
     3265% set(handles.CheckFixPair,'Value',1)% impose fixed pair (needed for function runpm)
     3266% set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity
     3267% set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity
     3268% drawnow
     3269%
     3270% num_i1=str2num(get(handles.i1,'String'));
     3271% num_j1=stra2num(get(handles.j1,'String'));
     3272% num_i2=str2num(get(handles.i2,'String'));
     3273% num_j2=stra2num(get(handles.j2,'String'));
     3274%
     3275% %% determine the name 'imaname_1' of the second file in the pair
     3276% imaname_1='';
     3277% if isempty(num_j2)% no second j index indicated
     3278%     if isempty(num_i2)
     3279%         if strcmp(get(handles.j2,'Visible'),'on') %if the j box is visible
     3280%             imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1,[],num_j1+1);
     3281%         end
     3282%         if exist(imaname_1,'file')
     3283%             num_j2=num_j1+1;% look by default for the next j index as the second file
     3284%             set(handles.j2,'String',num2stra(num_j2,NomType));
     3285%         else
     3286%             imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1+1,[],num_j1);
     3287%             if exist(imaname_1,'file')
     3288%                 num_i2=num_i1+1;
     3289%                 set(handles.i2,'String',num2str(num_i2));
     3290%             else
     3291%                 msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
     3292%                 set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
     3293%                 set(handles.movie_pair,'Value',0)
     3294%                 return
     3295%             end
     3296%         end
     3297%     else
     3298%         num_j2=num_j1;%repeat the index i1 by default
     3299%     end
     3300% end
     3301% if isempty(num_i2)
     3302%     num_i2=num_i1;%repeat the index i1 by default
     3303% end
     3304% if isempty(num_j1)
     3305%     num_j1=1;
     3306% end
     3307% if isempty(num_j2)
     3308%     num_j2=num_j1;%repeat the index i1 by default
     3309% end
     3310% imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i2,[],num_j2);
     3311% if strcmp(NomType,'*')
     3312%     num_frame=num_i2;
     3313% else
     3314%     num_frame=num_j2;
     3315% end
     3316% if ~exist(imaname_1,'file')
     3317%       msgbox_uvmat('ERROR',['second input open (-)  ' imaname_1 ' not found']);
     3318%       set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
     3319%        set(handles.movie_pair,'Value',0)
     3320%       return
     3321% end
     3322%
     3323% %% display the first field in the pair (including possibly a background field from second line input filename_1)
     3324% filename_1='';%default
     3325% FileIndex_1='';
     3326% if get(handles.SubField,'Value')
     3327%     [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
     3328%     filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
     3329% end
     3330% [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);% get the indices of the second series from the string FileIndex_1
     3331% if isempty(j1_1)% case of movies, the index is not given by file index
     3332%     j1_1=num_j1;
     3333% end
     3334%
     3335% errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
     3336%
     3337% if isempty(errormsg)
     3338%     set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull
     3339% else
     3340%      msgbox_uvmat('ERROR',errormsg);
     3341%      set(handles.REFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull
     3342% end
     3343% UvData=get(handles.uvmat,'UserData');
     3344% Field_a=UvData.Field;% movie on the field defined by the second input line
     3345%
     3346% %% display time interval for the image pair
     3347% if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'Time')...
     3348%         && size(UvData.XmlData{1}.Time,1)>=num_i2+1 && size(UvData.XmlData{1}.Time,2)>=num_j2+1
     3349%     dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1));
     3350%     if  isfield(UvData,'TimeUnit')
     3351%         set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  m' UvData.TimeUnit] )
     3352%     else
     3353%         set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  10^(-3)'] )
     3354%     end
     3355% else
     3356%     set(handles.Dt_txt,'String','')
     3357% end
     3358%
     3359% %% read the second field
     3360% if isempty(UvData.MovieObject)
     3361%     [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileInfo{index}.FileType,[],num_frame);
     3362% else
     3363%     [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileInfo{1}.FileType,UvData.MovieObject{1},num_frame);
     3364% end
     3365% if ~isempty(errormsg)
     3366%     msgbox_uvmat('ERROR',['Error in reading second image: ' errormsg])
     3367%     return
     3368% end
     3369%
     3370% %% apply phys or other transform on the two input fields
     3371% transform=get(handles.TransformPath,'UserData');
     3372% if  ~isempty(transform)
     3373%     if isfield(UvData,'XmlData') && ~isempty(UvData.XmlData) %use geometry calib recorded from the ImaDoc xml file as first priority
     3374%         if nargin(transform)>=2
     3375%             Field_b=transform(Field_b,UvData.XmlData{1});
     3376%         else
     3377%             Field_b=transform(Field_b);
     3378%         end
     3379%     end
     3380% end
     3381%
     3382% %% make movie until movie speed is set to 0 or STOP is activated
     3383% hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER)
     3384% set(handles.STOP,'Visible','on')
     3385% set(handles.speed,'Visible','on')
     3386% set(handles.speed_txt,'Visible','on')
     3387% while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue') % enable STOP command
     3388%     % read and plot the series of images in non erase mode
     3389%     set(hima,'CData',Field_b.A); %TODO: generalise to other kinds of fields
     3390%     pause(1.02-get(handles.speed,'Value'));% wait for next image
     3391%     set(hima,'CData',Field_a.A);
     3392%     pause(1.02-get(handles.speed,'Value'));% wait for next image
     3393% end
     3394% set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
     3395% set(handles.movie_pair,'Value',0)
     3396% set(handles.Dt_txt,'String','')
    33203397
    33213398%------------------------------------------------------------------------
     
    59256002        set(hhset_object.SAVE,'Enable','on')
    59266003    end
     6004else
     6005    delete(hset_object)
    59276006end
    59286007
Note: See TracChangeset for help on using the changeset viewer.