Changeset 1144 for trunk/src


Ignore:
Timestamp:
May 13, 2024, 9:49:09 PM (6 weeks ago)
Author:
sommeria
Message:

false flags modified in civ_series with new conventions, low pass filter adde to transform_field

Location:
trunk/src
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plot_field.m

    r1143 r1144  
    730730                end
    731731            end
    732            
    733 %                 if  ~(isfield(PlotParam.Vectors,'CheckHideWarning') && isequal(PlotParam.Vectors.CheckHideWarning,1))
    734 %                     test_black=1;
    735 %                 end
    736        
     732
    737733            if ~isempty(ivar_FF_vec) %&& ~test_false
    738734                vec_FF=Data.(Data.ListVarName{ivar_FF_vec}); % flags for false vectors
    739735                if ~isempty(ivar_F)%~(isfield(PlotParam.Vectors,'HideWarning')&& isequal(PlotParam.Vectors.HideWarning,1))
    740736                    vec_F=Data.(Data.ListVarName{ivar_F}); % warning flags for  dubious vectors
    741                     vec_FF(find(vec_F==-2))=-2;%set alseFlag to -2 (edge of the search box)
     737                    vec_FF(find(vec_F==-2))=1;%set alseFlag to 1(edge of the search box)
    742738                end
    743739            end
  • trunk/src/series.m

    r1141 r1144  
    645645    else %scan the input folder
    646646        InputTable{iview,3}=regexprep(InputTable{iview,3},'^/','');%suppress '/' at the beginning of the input name
    647         i1=str2num(get(handles.num_first_i,'String'));
    648         j1=str2num(get(handles.num_first_j,'String'));
    649         InputFile=fullfile_uvmat('','',InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,[],j1,[]);
    650             [RootPath,~,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=...
     647        i1=str2double(get(handles.num_first_i,'String'));
     648        j1=str2double(get(handles.num_first_j,'String'));
     649        j2=[];%default
     650        PairString=get(handles.PairString,'Data');
     651        if numel(PairString)>=iview
     652            checkpair=strfind(PairString{iview},'j=');
     653            if checkpair
     654                j1=str2double(PairString{iview}(4));
     655                j2=str2double(PairString{iview}(6));
     656            end
     657        end
     658        InputFile=fullfile_uvmat('','',InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,[],j1,j2);
     659        [RootPath,~,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=...
    651660                find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),InputFile);
    652661    end
     
    13111320function num_last_j_Callback(hObject, eventdata, handles)
    13121321%------------------------------------------------------------------------
    1313 % first_j=str2num(get(handles.num_first_j,'String'));
    1314 % last_j=str2num(get(handles.num_last_j,'String'));
    1315 % ref_j=ceil((first_j+last_j)/2);
    1316 % set(handles.num_ref_j,'String', num2str(ref_j))
    1317 % num_ref_j_Callback(hObject, eventdata, handles)
    13181322SeriesData=get(handles.series,'UserData');
    13191323if ~isfield(SeriesData,'Time')
     
    13461350%Pairs=get(handles.PairString,'Data');
    13471351for iview=1:size(TimeTable,1)
    1348     if size(SeriesData.Time,1)<iview
     1352    if numel(SeriesData.Time)<iview
    13491353        break
    13501354    end
     
    26892693
    26902694%% NbSlice visibility
    2691 if isfield(ParamOut,'OutputFileMode')&& strcmp(ParamOut.OutputFileMode,'NbSlice')
    2692     ParamOut.NbSlice='on';
    2693 end
     2695% if isfield(ParamOut,'OutputFileMode')&& strcmp(ParamOut.OutputFileMode,'NbSlice')
     2696%     ParamOut.NbSlice='on';
     2697% end
    26942698if isfield(ParamOut,'NbSlice') && (strcmp(ParamOut.NbSlice,'on')||isnumeric(ParamOut.NbSlice))
    26952699    set(handles.num_NbSlice,'Visible','on')
    26962700    set(handles.NbSlice_title,'Visible','on')
     2701    if isnumeric(ParamOut.NbSlice)
     2702        set(handles.num_NbSlice,'String',num2str(ParamOut.NbSlice))
     2703    end
    26972704else
    26982705    set(handles.num_NbSlice,'Visible','off')
  • trunk/src/series/civ2vel_3C.m

    r1141 r1144  
    5858    ParamOut.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    5959    ParamOut.NbSlice='off'; %nbre of slices ('off' by default)
    60     ParamOut.VelType='one';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     60    ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    6161    ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    6262    ParamOut.FieldTransform = 'off';%use the phys  transform function without choice
     
    108108hdisp=disp_uvmat('WAITING...','checking the file series',checkrun);
    109109[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
    110 if ~isempty(hdisp),delete(hdisp),end;
     110if ~isempty(hdisp),delete(hdisp),end
    111111%%%%%%%%%%%%
    112112% The cell array filecell is the list of input file names, while
     
    124124%% define the directory for result file (with path=RootPath{1})
    125125OutputDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
    126 %
    127 % if ~isfield(Param,'InputFields')
    128 %     Param.InputFields.FieldName='';
    129 % end
    130126
    131127%% calibration data and timing: read the ImaDoc files
     
    175171    CheckOverwrite=Param.CheckOverwrite;
    176172end
     173
    177174for index=1:NbField
    178175   
    179 
    180    
    181       %% generating the name of the merged field
     176    %% generating the name of the merged field
    182177    i1=i1_series{1}(index);
    183178    if ~isempty(i2_series{end})
     
    198193    OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},'.nc','_1-2',i1,i2,j1,j2);
    199194   
    200     %%
    201    
    202    
    203195    if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
    204196        disp('program stopped by user')
     
    206198    end
    207199   
    208      if (~CheckOverwrite && exist(OutputFile,'file')) 
    209             disp('existing output file already exists, skip to next field')
    210             continue% skip iteration if the mode overwrite is desactivated and the result file already exists
    211      end   
    212      
     200    if (~CheckOverwrite && exist(OutputFile,'file'))
     201        disp('existing output file already exists, skip to next field')
     202        continue% skip iteration if the mode overwrite is desactivated and the result file already exists
     203    end
     204   
    213205    %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
    214206    Data=cell(1,NbView);%initiate the set Data
     
    217209    %get Xphys,Yphys,Zphys from 1 or 2 stereo folders. Positions are taken
    218210    %at the middle between to time step
    219    clear ZItemp
    220    ZItemp=zeros(size(XI,1),size(XI,2),2);
    221    
    222    if index==1
     211    clear ZItemp
     212    ZItemp=zeros(size(XI,1),size(XI,2),2);
     213    CheckZ=0;
     214   
     215    if index==1
    223216        first_img=i1_series{1,1}(1,1); %id of the first image of the series
    224    end
    225      
    226      idtemp=0;
    227  for indextemp=index:index+1;
    228      idtemp=idtemp+1;
    229     if NbView==3 % if there is only 1 stereo folder, extract directly Xphys,Yphys and Zphys
    230      
     217    end
     218   
     219    idtemp=0;
     220    for indextemp=index:index+1
     221        idtemp=idtemp+1;
     222        if NbView==3 % if there is only 1 stereo folder, extract directly Xphys,Yphys and Zphys
     223           
     224            [Data{3},tild,errormsg] = nc2struct([Param.InputTable{3,1},'/',Param.InputTable{3,2},'/',Param.InputTable{3,3},'_',int2str(first_img+indextemp-1),'.nc']);
     225           
     226            if  exist('Data{3}.Civ3_FF','var') % FF is present, remove wrong vector
     227                temp=find(Data{3}.Civ3_FF==0);
     228                Zphys=Data{3}.Zphys(temp);
     229                Yphys=Data{3}.Yphys(temp);
     230                Xphys=Data{3}.Xphys(temp);
     231            else
     232                Zphys=Data{3}.Zphys;
     233                Yphys=Data{3}.Yphys;
     234                Xphys=Data{3}.Xphys;
     235            end
     236           
     237        elseif NbView==4 % is there is 2 stereo folders, get global U and V and compute Zphys
     238           
     239            %test if the seconde camera is the same for both folder
     240            for i=3:4
     241                indpt(i)=strfind(Param.InputTable{i,2},'.'); % indice of the "." is the folder name 1
     242                indline(i)=strfind(Param.InputTable{i,2},'-'); % indice of the "-" is the folder name1
     243                camname{i}=Param.InputTable{i,2}(indline(i)+1:indpt(i)-1);% extract the second camera name
     244            end
     245           
     246            if strcmp(camname{3},camname{4})==0
     247                disp_uvmat('ERROR','The 2 stereo folders should have the same camera for the second position',checkrun)
     248                return
     249            end
     250           
     251            [Data{3},tild,errormsg] = nc2struct([Param.InputTable{3,1},'/',Param.InputTable{3,2},'/',Param.InputTable{3,3},'_',int2str(first_img+indextemp-1),'.nc']);
     252           
     253            if exist('Data{3}.Civ3_FF','var') % if FF is present, remove wrong vector
     254                temp=find(Data{3}.Civ3_FF==0);
     255                Xmid3=Data{3}.Xmid(temp);
     256                Ymid3=Data{3}.Ymid(temp);
     257                U3=Data{3}.Uphys(temp);
     258                V3=Data{3}.Vphys(temp);
     259            else
     260                Xmid3=Data{3}.Xmid;
     261                Ymid3=Data{3}.Ymid;
     262                U3=Data{3}.Uphys;
     263                V3=Data{3}.Vphys;
     264            end
     265            %temporary gridd of merging the 2 stereos datas
     266            [xq,yq] = meshgrid(min(Xmid3+(U3)/2):(max(Xmid3+(U3)/2)-min(Xmid3+(U3)/2))/128:max(Xmid3+(U3)/2),min(Ymid3+(V3)/2):(max(Ymid3+(V3)/2)-min(Ymid3+(V3)/2))/128:max(Ymid3+(V3)/2));
     267           
     268            %1st folder : interpolate the first camera (Dalsa1) points on the second (common) camera
     269            %(Dalsa 3)
     270            x3Q=griddata(Xmid3+(U3)/2,Ymid3+(V3)/2,Xmid3-(U3)/2,xq,yq);
     271            y3Q=griddata(Xmid3+(U3)/2,Ymid3+(V3)/2,Ymid3-(V3)/2,xq,yq);
     272           
     273            [Data{4},tild,errormsg] = nc2struct([Param.InputTable{4,1},'/',Param.InputTable{4,2},'/',Param.InputTable{4,3},'_',int2str(first_img+indextemp-1),'.nc']);
     274            if exist('Data{4}.Civ3_FF','var') % if FF is present, remove wrong vector
     275                temp=find(Data{4}.Civ3_FF==0);
     276                Xmid4=Data{4}.Xmid(temp);
     277                Ymid4=Data{4}.Ymid(temp);
     278                U4=Data{4}.Uphys(temp);
     279                V4=Data{4}.Vphys(temp);
     280            else
     281                Xmid4=Data{4}.Xmid;
     282                Ymid4=Data{4}.Ymid;
     283                U4=Data{4}.Uphys;
     284                V4=Data{4}.Vphys;
     285            end
     286           
     287            %2nd folder :interpolate the first camera (Dalsa2) points on the second (common) camera
     288            %(Dalsa 3)
     289            x4Q=griddata(Xmid4+(U4)/2,Ymid4+(V4)/2,Xmid4-(U4)/2,xq,yq);
     290            y4Q=griddata(Xmid4+(U4)/2,Ymid4+(V4)/2,Ymid4-(V4)/2,xq,yq);
     291           
     292            xmid=reshape((x4Q+x3Q)/2,length(xq(:,1)).*length(xq(1,:)),1);
     293            ymid=reshape((y4Q+y3Q)/2,length(yq(:,1)).*length(yq(1,:)),1);
     294            u=reshape(x4Q-x3Q,length(xq(:,1)).*length(xq(1,:)),1);
     295            v=reshape(y4Q-y3Q,length(yq(:,1)).*length(yq(1,:)),1);
     296           
     297           
     298            [Zphys,Xphys,Yphys,error]=shift2z(xmid, ymid, u, v,XmlData); %get Xphy,Yphy and Zphys
     299            %remove NaN
     300            tempNaN=isnan(Zphys);tempind=find(tempNaN==1);
     301            Zphys(tempind)=[];
     302            Xphys(tempind)=[];
     303            Yphys(tempind)=[];       
     304        end
    231305       
    232        
    233         [Data{3},tild,errormsg] = nc2struct([Param.InputTable{3,1},'/',Param.InputTable{3,2},'/',Param.InputTable{3,3},'_',int2str(first_img+indextemp-1),'.nc']);
    234        
    235         if  exist('Data{3}.Civ3_FF','var') % FF is present, remove wrong vector
    236             temp=find(Data{3}.Civ3_FF==0);
    237             Zphys=Data{3}.Zphys(temp);
    238             Yphys=Data{3}.Yphys(temp);
    239             Xphys=Data{3}.Xphys(temp);
    240         else
    241             Zphys=Data{3}.Zphys;
    242             Yphys=Data{3}.Yphys;
    243             Xphys=Data{3}.Xphys;
    244         end
    245        
    246        
    247        
    248     elseif NbView==4 % is there is 2 stereo folders, get global U and V and compute Zphys
    249        
    250        
    251         %test if the seconde camera is the same for both folder
    252         for i=3:4
    253         indpt(i)=strfind(Param.InputTable{i,2},'.'); % indice of the "." is the folder name 1
    254         indline(i)=strfind(Param.InputTable{i,2},'-'); % indice of the "-" is the folder name1
    255         camname{i}=Param.InputTable{i,2}(indline(i)+1:indpt(i)-1);% extract the second camera name
    256         end
    257        
    258         if strcmp(camname{3},camname{4})==0
    259             disp_uvmat('ERROR','The 2 stereo folders should have the same camera for the second position',checkrun)
    260             return
    261         end
    262        
    263    
    264        
    265         [Data{3},tild,errormsg] = nc2struct([Param.InputTable{3,1},'/',Param.InputTable{3,2},'/',Param.InputTable{3,3},'_',int2str(first_img+indextemp-1),'.nc']);
    266    
    267         if exist('Data{3}.Civ3_FF','var') % if FF is present, remove wrong vector
    268             temp=find(Data{3}.Civ3_FF==0);
    269             Xmid3=Data{3}.Xmid(temp);
    270             Ymid3=Data{3}.Ymid(temp);
    271             U3=Data{3}.Uphys(temp);
    272             V3=Data{3}.Vphys(temp);
    273         else
    274             Xmid3=Data{3}.Xmid;
    275             Ymid3=Data{3}.Ymid;
    276             U3=Data{3}.Uphys;
    277             V3=Data{3}.Vphys;
    278         end
    279         %temporary gridd of merging the 2 stereos datas
    280         [xq,yq] = meshgrid(min(Xmid3+(U3)/2):(max(Xmid3+(U3)/2)-min(Xmid3+(U3)/2))/128:max(Xmid3+(U3)/2),min(Ymid3+(V3)/2):(max(Ymid3+(V3)/2)-min(Ymid3+(V3)/2))/128:max(Ymid3+(V3)/2));
    281        
    282         %1st folder : interpolate the first camera (Dalsa1) points on the second (common) camera
    283         %(Dalsa 3)
    284         x3Q=griddata(Xmid3+(U3)/2,Ymid3+(V3)/2,Xmid3-(U3)/2,xq,yq);
    285         y3Q=griddata(Xmid3+(U3)/2,Ymid3+(V3)/2,Ymid3-(V3)/2,xq,yq);
    286        
    287        
    288 
    289          [Data{4},tild,errormsg] = nc2struct([Param.InputTable{4,1},'/',Param.InputTable{4,2},'/',Param.InputTable{4,3},'_',int2str(first_img+indextemp-1),'.nc']);
    290         if exist('Data{4}.Civ3_FF','var') % if FF is present, remove wrong vector
    291             temp=find(Data{4}.Civ3_FF==0);
    292             Xmid4=Data{4}.Xmid(temp);
    293             Ymid4=Data{4}.Ymid(temp);
    294             U4=Data{4}.Uphys(temp);
    295             V4=Data{4}.Vphys(temp);
    296         else
    297             Xmid4=Data{4}.Xmid;
    298             Ymid4=Data{4}.Ymid;
    299             U4=Data{4}.Uphys;
    300             V4=Data{4}.Vphys;
    301         end
    302        
    303         %2nd folder :interpolate the first camera (Dalsa2) points on the second (common) camera
    304         %(Dalsa 3)
    305         x4Q=griddata(Xmid4+(U4)/2,Ymid4+(V4)/2,Xmid4-(U4)/2,xq,yq);
    306         y4Q=griddata(Xmid4+(U4)/2,Ymid4+(V4)/2,Ymid4-(V4)/2,xq,yq);
    307        
    308         xmid=reshape((x4Q+x3Q)/2,length(xq(:,1)).*length(xq(1,:)),1);
    309         ymid=reshape((y4Q+y3Q)/2,length(yq(:,1)).*length(yq(1,:)),1);
    310         u=reshape(x4Q-x3Q,length(xq(:,1)).*length(xq(1,:)),1);
    311         v=reshape(y4Q-y3Q,length(yq(:,1)).*length(yq(1,:)),1);
    312        
    313        
    314         [Zphys,Xphys,Yphys,error]=shift2z(xmid, ymid, u, v,XmlData); %get Xphy,Yphy and Zphys
    315         %remove NaN
    316         tempNaN=isnan(Zphys);tempind=find(tempNaN==1);
    317         Zphys(tempind)=[];
    318         Xphys(tempind)=[];
    319         Yphys(tempind)=[];
    320         error(tempind)=[];
    321          
    322     end
    323    
    324             if NbView>2   
    325        ZItemp(:,:,idtemp)=griddata(Xphys,Yphys,Zphys,XI,YI); %interpolation on the choosen gridd
    326             end
    327    
    328 end
    329     ZI=mean(ZItemp,3); %mean between two the two time step
    330     Vtest=ZItemp(:,:,2)-ZItemp(:,:,1);
     306        if NbView>2
     307            ZItemp(:,:,idtemp)=griddata(Xphys,Yphys,Zphys,XI,YI); %interpolation on the choosen gridd
     308            CheckZ=1;
     309        end     
     310    end
     311    ZI=mean(ZItemp,3); %mean between the two time step
    331312   
    332313    [Xa,Ya]=px_XYZ(XmlData{1}.GeometryCalib,[],XI,YI,ZI);% set of image coordinates on view a
    333314    [Xb,Yb]=px_XYZ(XmlData{2}.GeometryCalib,[],XI,YI,ZI);% set of image coordinates on view b
    334315   
    335    
     316    
    336317    for iview=1:2
    337318        %% reading input file(s)
     
    342323        end
    343324        % get the time defined in the current file if not already defined from the xml file
    344         if isfield(Data{iview},'Time')&& isequal(Data{iview}.Time,Data{1}.Time)
     325        if isfield(Data{iview},'Time')&& (Data{iview}.Time-Data{1}.Time)<0.0001
    345326            Time=Data{iview}.Time;
    346327        else
     
    355336        end
    356337    end
    357     %remove wrong vector 
     338    %remove wrong vector
    358339    if isfield(Data{1},'FF')
    359340        temp=find(Data{1}.FF==0);
     
    373354    [A]=get_coeff(XmlData{1}.GeometryCalib,Xa,Ya,XI,YI,ZI); %get coef A~
    374355   
    375     %remove wrong vector 
     356    %remove wrong vector
    376357    if isfield(Data{2},'FF')
    377358        temp=find(Data{2}.FF==0);
     
    396377    S=ones(size(XI,1),size(XI,2),3);
    397378    D=ones(size(XI,1),size(XI,2),3,3);
    398 
     379   
    399380    S(:,:,1)=A(:,:,1,1).*Ua+A(:,:,2,1).*Va+B(:,:,1,1).*Ub+B(:,:,2,1).*Vb;
    400381    S(:,:,2)=A(:,:,1,2).*Ua+A(:,:,2,2).*Va+B(:,:,1,2).*Ub+B(:,:,2,2).*Vb;
     
    416397            W(indj,indi)=dxyz(3);
    417398        end
    418     end   
     399    end
    419400    Error=zeros(size(XI,1),size(XI,2),4);
    420401    Error(:,:,1)=A(:,:,1,1).*U+A(:,:,1,2).*V+A(:,:,1,3).*W-Ua;
     
    424405   
    425406   
    426 
    427    
    428  
    429    
    430407    %% recording the merged field
    431408    if index==1% initiate the structure at first index
    432         MergeData.ListGlobalAttribute={'Conventions','Time','Dt'};
     409        MergeData.ListGlobalAttribute={'Conventions','Time','Dt','CoordUnit'};
    433410        MergeData.Conventions='uvmat';
    434         MergeData.Time=Time;
    435         MergeData.Dt=Dt;
    436         MergeData.ListVarName={'coord_x','coord_y','Z','U','V','W','Error'};
     411        if isfield (XmlData{1}.GeometryCalib,'CoordUnit') && isfield (XmlData{2}.GeometryCalib,'CoordUnit') && strcmp(XmlData{1}.GeometryCalib.CoordUnit, XmlData{2}.GeometryCalib.CoordUnit)
     412        MergeData.CoordUnit=XmlData{1}.GeometryCalib.CoordUnit;
     413        else
     414            disp_uvmat('ERROR','inconsistent coord units in the two input velocity series',checkrun)
     415            return
     416        end
     417        MergeData.ListVarName={'coord_x','coord_y','U','V','W','Error'};
    437418        MergeData.VarDimName={'coord_x','coord_y',{'coord_y','coord_x'},{'coord_y','coord_x'}...
    438                 {'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'}};
     419            {'coord_y','coord_x'},{'coord_y','coord_x'}};
     420        MergeData.VarAttribute{6}.unit='pixel'; %error estimate expressed in pixel
     421        if CheckZ
     422            MergeData.ListVarName=[MergeData.ListVarName {'Z'}];
     423            MergeData.VarDimName=[MergeData.ListVarName {'coord_y','coord_x'}];
     424            MergeData.Z=ZI;
     425        end
    439426        MergeData.coord_x=xI;
    440427        MergeData.coord_y=yI;
    441428    end
     429    MergeData.Time=Time;
     430    MergeData.Dt=Dt;
    442431    MergeData.U=U/Dt;
    443432    MergeData.V=V/Dt;
    444433    MergeData.W=W/Dt;
    445     MergeData.Z=ZI;
    446    
    447 %     mfx=(XmlData{1}.GeometryCalib.fx_fy(1)+XmlData{2}.GeometryCalib.fx_fy(1))/2;
    448 %     mfy=(XmlData{1}.GeometryCalib.fx_fy(2)+XmlData{2}.GeometryCalib.fx_fy(2))/2;
    449     MergeData.Error=0.5*sqrt(sum(Error.^2,3));
     434   
     435   
     436    mfx=(XmlData{1}.GeometryCalib.fx_fy(1)+XmlData{2}.GeometryCalib.fx_fy(1))/2;
     437    mfy=(XmlData{1}.GeometryCalib.fx_fy(2)+XmlData{2}.GeometryCalib.fx_fy(2))/2;
     438    MergeData.Error=0.25*(mfx+mfy)*sqrt(sum(Error.^2,3));
    450439    errormsg=struct2nc(OutputFile,MergeData);%save result file
    451440    if isempty(errormsg)
  • trunk/src/series/civ_series.m

    r1143 r1144  
    249249Data.Program='civ_series';
    250250Data.CivStage=0;%default
    251 check_civx=0;%default
    252251
    253252%% get timing from the ImaDoc file or input video
     
    332331            if strcmp(Param.ActionInput.ListCompareMode,'PIV')
    333332                ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2);
    334 %                 ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2);
    335333            else % displacement
    336334                ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_civ2,[],j2_civ2);
     
    448446        end
    449447        % set the list of variables
    450         Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_F','Civ1_C'};%  cell array containing the names of the fields to record
     448        Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_FF'};%  cell array containing the names of the fields to record
    451449        Data.VarDimName={'nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1'};
    452450        Data.VarAttribute{1}.Role='coord_x';
     
    454452        Data.VarAttribute{3}.Role='vector_x';
    455453        Data.VarAttribute{4}.Role='vector_y';
    456         Data.VarAttribute{5}.Role='warnflag';
     454        Data.VarAttribute{5}.Role='ancillary';
     455        Data.VarAttribute{6}.Role='errorflag';
    457456        % case of mask
    458457        if par_civ1.CheckMask&&~isempty(par_civ1.Mask)
     
    487486            Data.ListVarName=[Data.ListVarName 'Civ1_Z'];
    488487            Data.Civ1_X=[];Data.Civ1_Y=[];Data.Civ1_Z=[];
    489             Data.Civ1_U=[];Data.Civ1_V=[];Data.Civ1_C=[];Data.Civ1_F=[];
     488            Data.Civ1_U=[];Data.Civ1_V=[];Data.Civ1_C=[];
    490489            for ivol=1:NbSlice
    491490                % caluclate velocity data (y and v in indices, reverse to y component)
     
    501500                Data.Civ1_V=[Data.Civ1_V reshape(-vtable,[],1)];
    502501                Data.Civ1_C=[Data.Civ1_C reshape(ctable,[],1)];
    503                 Data.Civ1_F=[Data.Civ1_C reshape(F,[],1)];
     502                Data.Civ1_FF=[Data.Civ1_FF reshape(F,[],1)];
    504503            end
    505504        else %usual PIV
     
    516515            Data.Civ1_V=reshape(-vtable,[],1);
    517516            Data.Civ1_C=reshape(ctable,[],1);
    518             Data.Civ1_F=reshape(F,[],1);
     517            Data.Civ1_FF=reshape(F,[],1);
    519518            time_civ1=toc(tstart_civ1);
    520519        end
     
    557556        end
    558557        Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix1_param];
    559         Data.ListVarName=[Data.ListVarName {'Civ1_FF'}];
    560         Data.VarDimName=[Data.VarDimName {'nb_vec_1'}];
    561         nbvar=length(Data.ListVarName);
    562         Data.VarAttribute{nbvar}.Role='errorflag';
    563         Data.Civ1_FF=int8(detect_false(Param.ActionInput.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V));
     558        Data.Civ1_FF=uint8(detect_false(Param.ActionInput.Fix1,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V,Data.Civ1_FF));
    564559        Data.CivStage=2;
    565560    end
     
    568563        disp('patch1 started')
    569564         tstart_patch1=tic;
    570         if check_civx
    571             errormsg='Civ Matlab input needed for patch';
    572             disp_uvmat('ERROR',errormsg,checkrun)
    573             return
    574         end
    575        
     565       
    576566        % record the processing parameters of Patch1 as global attributes in the result nc file
    577567        list_param=fieldnames(Param.ActionInput.Patch1)';
     
    612602        Data.Civ1_U_smooth(ind_good)=Ures;% take the interpolated (smoothed) velocity values for good vectors, keep civ1 data for the other
    613603        Data.Civ1_V_smooth(ind_good)=Vres;
    614         Data.Civ1_FF(ind_good)=int8(FFres);
     604        Data.Civ1_FF(ind_good)=uint8(FFres);
    615605        time_patch1=toc(tstart_patch1);
    616606        disp('patch1 performed')
     
    802792        % define the Civ2 variable (if Civ2 data are not replaced from previous calculation)
    803793        if isempty(find(strcmp('Civ2_X',Data.ListVarName),1))
    804             Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_F','Civ2_C'}];%  cell array containing the names of the fields to record
     794            Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_C','Civ2_FF'}];%  cell array containing the names of the fields to record
    805795            Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2'}];
    806796            Data.VarAttribute{nbvar+1}.Role='coord_x';
     
    808798            Data.VarAttribute{nbvar+3}.Role='vector_x';
    809799            Data.VarAttribute{nbvar+4}.Role='vector_y';
    810             Data.VarAttribute{nbvar+5}.Role='warnflag';
     800            Data.VarAttribute{nbvar+5}.Role='ancillary';
     801            Data.VarAttribute{nbvar+6}.Role='errorflag';
    811802        end
    812803        Data.Civ2_X=reshape(xtable,[],1);
     
    815806        Data.Civ2_V=reshape(-vtable,[],1);
    816807        Data.Civ2_C=reshape(ctable,[],1);
    817         Data.Civ2_F=reshape(F,[],1);
     808        Data.Civ2_FF=reshape(F,[],1);
    818809        disp('civ2 performed')
    819810        time_civ2=toc(tstart_civ2);
     
    847838            Data.(Fix2_param{ilist})=Param.ActionInput.Fix2.(list_param{ilist});
    848839        end
    849         Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix2_param];
    850         if check_civx
    851             if ~isfield(Data,'fix2')
    852                 Data.ListGlobalAttribute=[Data.ListGlobalAttribute 'fix2'];
    853                 Data.fix2=1;
    854                 Data.ListVarName=[Data.ListVarName {'vec2_FixFlag'}];
    855                 Data.VarDimName=[Data.VarDimName {'nb_vectors2'}];
    856             end
    857             Data.vec_FixFlag=detect_false(Param.Fix2,Data.vec2_F,Data.vec2_C,Data.vec2_U,Data.vec2_V);
    858         else
    859             Data.ListVarName=[Data.ListVarName {'Civ2_FF'}];
    860             Data.VarDimName=[Data.VarDimName {'nb_vec_2'}];
    861             nbvar=length(Data.ListVarName);
    862             Data.VarAttribute{nbvar}.Role='errorflag';
    863             Data.Civ2_FF=double(detect_false(Param.ActionInput.Fix2,Data.Civ2_F,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V));
    864             Data.CivStage=Data.CivStage+1;
    865         end
     840        Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix2_param];     
     841        Data.Civ2_FF=double(detect_false(Param.ActionInput.Fix2,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V,Data.Civ2_FF));
     842        Data.CivStage=Data.CivStage+1;
    866843    end
    867844   
     
    10821059            if sizemask > 1/2% eliminate point if more than half of the correlation box is masked
    10831060                F(ivec)=3; %
    1084                 utable(ivec)=0;
    1085                 vtable(ivec)=0;
     1061                utable(ivec)=NaN;
     1062                vtable(ivec)=NaN;
    10861063            else
    10871064                image1_crop=image1_crop.*~mask1_crop;% put to zero the masked pixels (mask1_crop='true'=1)
     
    11031080            end
    11041081            if F(ivec)==3
    1105                 utable(ivec)=0;
    1106                 vtable(ivec)=0;
     1082                utable(ivec)=NaN;
     1083                vtable(ivec)=NaN;
    11071084            else
    11081085                %mask
     
    11971174    peaky = peaky+ (f1-f2)/(2*f1-4*f0+2*f2);
    11981175else
    1199     F=-2; % warning flag for vector truncated by the limited search box
     1176    F=1; % warning flag for vector truncated by the limited search box
    12001177end
    12011178peakx=x;
     
    12061183    peakx = peakx+ (f1-f2)/(2*f1-4*f0+2*f2);
    12071184else
    1208     F=-2; % warning flag for vector truncated by the limited search box
     1185    F=1; % warning flag for vector truncated by the limited search box
    12091186end
    12101187vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1];
     
    12151192%------------------------------------------------------------------------
    12161193% vector=[0 0]; %default
    1217 F=-2;
     1194F=1;
    12181195peaky=y;
    12191196peakx=x;
     
    12581235[npy,npx]=size(result_conv);
    12591236if x<4 || y<4 || npx-x<4 ||npy-y <4
    1260     F=-2;
     1237    F=1;
    12611238    vector=[x y];
    12621239else
     
    12921269
    12931270
    1294 function FF=detect_false(Param,F,C,U,V)
    1295 FF=zeros(size(F));%default
    1296 % FF=-2, for correlation max at edge
    1297 % FF=-1, for too small correlation
    1298 % FF=1, for velocity outside bounds
    1299 % FF=2 for exclusion by difference with the smoothed field
    1300 FF(F==-2)=-2;
     1271function FF=detect_false(Param,C,U,V,FFIn)
     1272FF=FFIn;%default, good vectors
     1273% FF=1, for correlation max at edge, not set in this function
     1274% FF=2, for too small correlation
     1275% FF=3, for velocity outside bounds
     1276% FF=4 for exclusion by difference with the smoothed field, not set in this function
     1277
    13011278if isfield (Param,'MinCorr')
    1302      FF(C<Param.MinCorr)=-1;
     1279     FF(C<Param.MinCorr & FFIn==0)=2;
    13031280end
    13041281if (isfield(Param,'MinVel')&&~isempty(Param.MinVel))||(isfield (Param,'MaxVel')&&~isempty(Param.MaxVel))
     
    13061283    if isfield (Param,'MinVel')&&~isempty(Param.MinVel)
    13071284        U2Min=Param.MinVel*Param.MinVel;
    1308         FF(Umod<U2Min)=1;
     1285        FF(Umod<U2Min & FFIn==0)=3;
    13091286    end
    13101287    if isfield (Param,'MaxVel')&&~isempty(Param.MaxVel)
    13111288         U2Max=Param.MaxVel*Param.MaxVel;
    1312         FF(Umod>U2Max)=1;
    1313     end
    1314 end
    1315 
    1316 
    1317 %criterium on warn flags
    1318 % FlagName={'CheckFmin2','CheckF2','CheckF3','CheckF4'};
    1319 % FlagVal=[-2 2 3 4];
    1320 % for iflag=1:numel(FlagName)
    1321 %     if isfield(Param,FlagName{iflag}) && Param.(FlagName{iflag})
    1322 %         FF=(FF==1| F==FlagVal(iflag));
    1323 %     end
    1324 % end
    1325 % %criterium on correlation values
    1326 % if isfield (Param,'MinCorr')
    1327 %     FF=FF==1 | C<Param.MinCorr;
    1328 % end
    1329 % if (isfield(Param,'MinVel')&&~isempty(Param.MinVel))||(isfield (Param,'MaxVel')&&~isempty(Param.MaxVel))
    1330 %     Umod= U.*U+V.*V;
    1331 %     if isfield (Param,'MinVel')&&~isempty(Param.MinVel)
    1332 %         FF=FF==1 | Umod<(Param.MinVel*Param.MinVel);
    1333 %     end
    1334 %     if isfield (Param,'MaxVel')&&~isempty(Param.MaxVel)
    1335 %         FF=FF==1 | Umod>(Param.MaxVel*Param.MaxVel);
    1336 %     end
    1337 % end
    1338 
     1289        FF(Umod>U2Max & FFIn==0)=3;
     1290    end
     1291end
    13391292
    13401293%------------------------------------------------------------------------
  • trunk/src/series/extract_multitif.m

    r1129 r1144  
    7777    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
    7878    ParamOut.WholeIndexRange='on';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    79     ParamOut.NbSlice='off'; % impose calculation in a single process (no parallel processing to avoid 'holes'))
     79    ParamOut.NbSlice='on'; %
    8080    ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    8181    ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     
    9191        first_j=[];% note that the function will propose to cover the whole range of indices
    9292    if isfield(Param.IndexRange,'MinIndex_j'); first_j=Param.IndexRange.MinIndex_j; end
    93     last_j=[];
    94     if isfield(Param.IndexRange,'MaxIndex_j'); last_j=Param.IndexRange.MaxIndex_j; end
     93% %     last_j=[];
     94% %     if isfield(Param.IndexRange,'MaxIndex_j'); last_j=Param.IndexRange.MaxIndex_j; end
    9595    PairString='';
    9696    if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
     
    101101        msgbox_uvmat('WARNING',['the first input file ' FirstFileName ' does not exist'])
    102102    end
    103 
     103    ParamOut.NbSlice=Param.IndexRange.MaxIndex_i;
    104104    %% check the validity of  input file types
    105105    FileInfo=get_file_info(FirstFileName);
    106106    if ~strcmp(FileInfo.FileType,'multimage')
    107         msgbox_uvmat('ERROR',['invalid file type input: ' FileInfo.FileType ' not an image'])
     107        msgbox_uvmat('ERROR',['invalid file type input: ' FileInfo.FileType ' not a tiff image series'])
    108108        return
    109109    end
  • trunk/src/uigetfile_uvmat.m

    r1127 r1144  
    335335%-------------------------------------------------------------------------
    336336ListStruct=dir_uvmat(DirName);% get structure of the current directory
     337if ~isstruct(ListStruct)
     338    return
     339end
     340   
    337341date_index=find(strcmp('datenum',fieldnames(ListStruct)));% find the index of the date displayin the list of fields
    338342NumFiles=0; %default
Note: See TracChangeset for help on using the changeset viewer.