Changeset 494 for trunk/src


Ignore:
Timestamp:
Jul 19, 2012, 11:50:39 AM (12 years ago)
Author:
sommeria
Message:

various bugs corrected after testing in Windows OS. Introduction
of filter tps

Location:
trunk/src
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r493 r494  
    2424%TODO: search range
    2525
    26 % Last Modified by GUIDE v2.5 13-Jul-2012 15:11:00
     26% Last Modified by GUIDE v2.5 18-Jul-2012 23:20:12
    2727% Begin initialization code - DO NOT EDIT
    2828gui_Singleton = 1;
     
    297297set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    298298RootPath=get(handles.RootPath,'String');
    299 SubdirImages=get(handles.SubdirImages,'String');
     299SubDirImages=get(handles.SubDirImages,'String');
    300300RootFile=get(handles.RootFile,'String');
    301301ref_i=str2num(get(handles.ref_i,'String'));
     
    303303NomType=get(handles.NomType,'String');
    304304ImaExt=get(handles.ImaExt,'String');
    305 fileinput=fullfile_uvmat(RootPath,SubdirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j);
     305fileinput=fullfile_uvmat(RootPath,SubDirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j);
    306306errormsg=display_file_name(handles,fileinput);
    307307if ~isempty(errormsg)
     
    344344if strcmp(ExtInput,'.nc')
    345345    NomTypeNc=NomTypeInput;
    346     if isempty(regexp(NomTypeInput,'[ab|AB|-]'))
     346    if isempty(regexp(NomTypeInput,'[ab|AB|-]', 'once'))
    347347        set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomencalture does not involve index pairs
    348348      %  [RootPath,SubDir]=fileparts(RootPath);
     
    435435% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    436436% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
    437 [RootPath,SubdirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject]=find_file_series(FilePath,[FileName ImaExt]);
     437[RootPath,SubDirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject]=find_file_series(FilePath,[FileName ImaExt]);
    438438switch FileType
    439439    case {'image','multimage','video','mmreader'}
     
    443443end
    444444set(handles.RootPath,'String',RootPath)
    445 set(handles.SubdirImages,'String',SubdirImages)
     445set(handles.SubDirImages,'String',SubDirImages)
    446446set(handles.RootFile,'String',RootFile)
    447447if strcmp(ExtInput,'.nc')
    448     SubDirCiv=regexprep(SubDir,['^' SubdirImages],'');%suppress the root  SuddirImages;
     448    SubDirCiv=regexprep(SubDir,['^' SubDirImages],'');%suppress the root  SuddirImages;
    449449else
    450450    SubDirCiv= '.civ';
     
    460460MaxIndex_i=max(i1_series(i1_series>0));
    461461MaxIndex_j=max(j1_series(j1_series>0));
    462 
    463 %% fill reference indices from the input file indices
    464 num_ref_i=str2num(get(handles.ref_i,'String'));
    465 num_ref_j=str2num(get(handles.ref_j,'String'));
    466 % for movies don't modify except if the current ref is outside index bounds
    467 if strcmp(ExtInput,'.nc')|| ~(strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader') && num_ref_i<=MaxIndex_i && num_ref_j<=MaxIndex_j)
    468     num_ref_i=i1;%default ref index
    469     if ~isempty(i2)
    470         num_ref_i=floor((num_ref_i+i2)/2);
    471     end
    472     num_ref_j=j1;
    473     if ~isempty(j2)
    474         num_ref_j=floor((num_ref_j+j2)/2);
    475     end
    476 end
    477462
    478463%% look for an image documentation file
     
    524509end
    525510if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
    526                set(handles.ListPairMode,'Value',1);
     511    set(handles.ListPairMode,'Value',1);
    527512    dt=1/get(MovieObject,'FrameRate');%time interval between successive frames
    528513    if strcmp(NomTypeIma,'*')
     
    533518        set(handles.ListPairMode,'String',[{'series(Dj)'};{'series(Di)'}])
    534519        MaxIndex_i=max(i1_series(i1_series>0));
    535         MaxIndex_j=get(MovieObject,'NumberOfFrames');   
     520        MaxIndex_j=get(MovieObject,'NumberOfFrames');
    536521        time=ones(MaxIndex_i,1)*(dt*(0:MaxIndex_j-1));%list of image times
    537522        enable_j(handles,'on')
    538     end 
     523    end
    539524    TimeUnit='s';
    540525    set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter
     
    544529%show the reference image edit box if relevant (not needed for movies or in the absence of time information
    545530if numel(time)>=2 % if there are at least two time values to define dt
    546     MaxIndex_i=min(size(time,1),MaxIndex_i);
     531    MaxIndex_i=min(size(time,1),MaxIndex_i);%possibly adjust the max index according to time data
    547532    MaxIndex_j=min(size(time,2),MaxIndex_j);
    548533    time=[zeros(size(time,1),1) time]; %insert a vertical line of zeros (to deal with zero file indices)
     
    563548set(handles.ImaExt,'String',ImaExt)
    564549set(handles.NomType,'String',NomTypeIma)
    565 set(handles.ref_i,'String',num2str(num_ref_i))
    566 set(handles.ref_j,'String',num2str(num_ref_j))
     550
     551%% set the reference indices from the input file indices
     552num_ref_i=str2num(get(handles.ref_i,'String'));
     553num_ref_j=str2num(get(handles.ref_j,'String'));
     554% for movies don't modify except if the current ref is outside index bounds
     555%if strcmp(ExtInput,'.nc')|| ~(strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader') && num_ref_i<=MaxIndex_i && num_ref_j<=MaxIndex_j)
     556if ~isempty(i1)% if i1 has been selected by the input
     557    num_ref_i=i1;%default ref index
     558    if ~isempty(i2)
     559        num_ref_i=floor((num_ref_i+i2)/2);
     560    end
     561    if ~isempty(j1)
     562    num_ref_j=j1;
     563    if ~isempty(j2)
     564        num_ref_j=floor((num_ref_j+j2)/2);
     565    end
     566    end
     567end
     568if num_ref_i>MaxIndex_i||num_ref_i<MinIndex_i
     569    num_ref_i=round((MinIndex_i+MaxIndex_i)/2);
     570end
     571if ~isempty(num_ref_j)&&~isempty(MaxIndex_j)&& ~isempty(MinIndex_j)
     572    if (num_ref_j>MaxIndex_j||num_ref_j<MinIndex_j)
     573        num_ref_j=round((MinIndex_j+MaxIndex_j)/2);
     574    end
     575end
     576if isempty(num_ref_j)
     577    num_ref_j=1;
     578end
    567579
    568580%% update i and j index range if a nc file has been opened or pb withmin max image indices:
     
    570582first_i=str2num(get(handles.first_i,'String'));
    571583last_i=str2num(get(handles.last_i,'String'));
    572 if isempty(first_i) || isempty(last_i)||isempty(MinIndex_i)||isempty(MaxIndex_i)
    573     set(handles.first_i,'String',num2str(num_ref_i));
    574     set(handles.last_i,'String',num2str(num_ref_i));%
    575 end
    576 if ind_opening~=0 || isempty(first_i) || isempty(last_i)|| first_i<MinIndex_i || last_i>MaxIndex_i
    577     set(handles.first_i,'String',num2str(num_ref_i));
    578     set(handles.last_i,'String',num2str(num_ref_i));%
     584if isempty(first_i) || isempty(last_i)||isempty(MinIndex_i)||isempty(MaxIndex_i)||ind_opening~=0 || isempty(first_i) || isempty(last_i)|| first_i<MinIndex_i || last_i>MaxIndex_i
     585   first_i=num_ref_i;
     586   last_i=num_ref_i;
     587    set(handles.first_i,'String',num2str(first_i));
     588    set(handles.last_i,'String',num2str(last_i));%
    579589end
    580590
    581591%j index range
    582592first_j=str2num(get(handles.first_j,'String'));
    583 last_j=str2num(get(handles.last_i,'String'));
    584 if isempty(first_j) || isempty(last_j)||isempty(MinIndex_j)||isempty(MaxIndex_j)
    585     set(handles.first_j,'String',num2str(num_ref_j));
    586     set(handles.last_j,'String',num2str(num_ref_j));%
    587 elseif ind_opening~=0 || first_j<MinIndex_j || last_j>MaxIndex_j
    588     set(handles.first_j,'String',num2str(num_ref_j));
    589 set(handles.last_j,'String',num2str(num_ref_j));%
    590 end
     593last_j=str2num(get(handles.last_j,'String'));
     594if isempty(first_j) || isempty(last_j)||isempty(MinIndex_j)||isempty(MaxIndex_j)||ind_opening~=0 || first_j<MinIndex_j || last_j>MaxIndex_j
     595       first_j=num_ref_j;
     596   last_j=num_ref_j;
     597    set(handles.first_j,'String',num2str(first_j));
     598    set(handles.last_j,'String',num2str(last_j));%
     599end
     600if num_ref_i>last_i || num_ref_i<first_i
     601    num_ref_i=round((first_i+last_i)/2);
     602end
     603if num_ref_j>last_j || num_ref_j<first_j
     604    num_ref_j=round((first_j+last_j)/2);
     605end
     606set(handles.ref_i,'String',num2str(num_ref_i))
     607set(handles.ref_j,'String',num2str(num_ref_j))
    591608
    592609%% set the civ options depending on the input file content when a nc file has been opened
     
    11191136for bin_name=binary_list %loop on the list of binaries
    11201137    if isfield(Param.xml,bin_name{1})% bin_name{1} =current name in the list
     1138        if ~isunix
     1139        Param.xml.(bin_name{1})=[regexprep(Param.xml.(bin_name{1}),'/','\') '.exe'];
     1140        end
    11211141        if exist(Param.xml.(bin_name{1}),'file')
    11221142            [path,name,ext]=fileparts(Param.xml.(bin_name{1}));
     
    11461166    end
    11471167end
    1148 display('files OK, processing...')
    11491168
    11501169%% set the list of files and check them
     
    11601179end
    11611180set(handles.civ,'UserData',filecell);%store for futur use of status callback
    1162 
     1181display('files OK, processing...')
    11631182
    11641183%% create subfolders for log, cmx, nml, xml, bat
     
    11711190end
    11721191
    1173    
    11741192%% get information on input images or movies
    11751193nbfield=numel(i1_civ1);
     
    11911209checkframe=strcmp(TimeUnit,'frame');
    11921210batch_file_list=[];%should be renamed file_list, can be used for xml or bash files
    1193  
     1211NomTypeIma=get(handles.NomType,'String');
    11941212for ifile=1:nbfield
    11951213    for j=1:nbslice
     
    12201238            Param.Civ1.ImageWidth=ImageInfoA_civ1.Width;
    12211239            Param.Civ1.ImageHeight=ImageInfoA_civ1.Height;
    1222             Param.Civ1.FrameIndexA=i1_civ1(ifile);
    1223             Param.Civ1.FrameIndexB=i2_civ1(ifile);
     1240            if strcmp(NomTypeIma,'*')
     1241                Param.Civ1.FrameIndexA=i1_civ1(ifile);
     1242                Param.Civ1.FrameIndexB=i2_civ1(ifile);
     1243            else% case of movies indexed with i, the frame index is then in j
     1244                Param.Civ1.FrameIndexA=j1_civ1(j);
     1245                Param.Civ1.FrameIndexB=j2_civ1(j);
     1246            end
    12241247            % read mask )parameters
    12251248            if Param.Civ1.CheckMask % the lines below should be changed with the new gui
     
    12941317            Param.Civ2.ImageWidth=ImageInfoA_civ2.Width;
    12951318            Param.Civ2.ImageHeight=ImageInfoA_civ2.Height;
    1296             Param.Civ2.FrameIndexA=i1_civ2(ifile);
    1297             Param.Civ2.FrameIndexB=i2_civ2(ifile);           
     1319            if strcmp(NomTypeIma,'*')
     1320                Param.Civ2.FrameIndexA=i1_civ2(ifile,j);
     1321                Param.Civ2.FrameIndexB=i2_civ2(ifile,j);
     1322            else% case of movies indexed with i, the frame index is then in j
     1323                Param.Civ2.FrameIndexA=j1_civ2(ifile,j);
     1324                Param.Civ2.FrameIndexB=j2_civ2(ifile,j);
     1325            end
    12981326        end
    12991327       
     
    16801708%% get the root name and check dir
    16811709RootPath=get(handles.RootPath,'String');
    1682 SubdirImages=get(handles.SubdirImages,'String');
     1710SubDirImages=get(handles.SubDirImages,'String');
    16831711RootFile=get(handles.RootFile,'String');
    1684 filecell.filebase=fullfile(RootPath,SubdirImages,RootFile);
     1712filecell.filebase=fullfile(RootPath,SubDirImages,RootFile);
    16851713if isempty(filecell.filebase)
    16861714    errormsg='please open an image with the upper menu option Open/Browse...';
     
    17031731% subdir_civ2=[ '.' subdir_civ2];
    17041732if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir
    1705 subdir_civ1=[SubdirImages '.' subdir_civ1];
    1706 subdir_civ2=[SubdirImages '.' subdir_civ2];
     1733subdir_civ1=[SubDirImages '.' subdir_civ1];
     1734subdir_civ2=[SubDirImages '.' subdir_civ2];
    17071735
    17081736%% choose root names depending on ListCompareMode =displacement, shift, PIV or stereo PIV
     
    19782006    for ifile=1:nbfield
    19792007        for j=1:nbslice
    1980              filename=fullfile_uvmat(RootPath,SubdirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j));
     2008             filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j));
    19812009            idetect(j)=exist(filename,'file')==2;
    19822010            filecell.ima1.civ1(ifile,j)={filename}; %first image
    1983             filename=fullfile_uvmat(RootPath,SubdirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j));
     2011            filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j));
    19842012            idetect_1(j)=exist(filename,'file')==2;
    19852013            filecell.ima2.civ1(ifile,j)={filename};%second image
     
    21962224        for ifile=1:nbfield
    21972225            for j=1:nbslice
    2198                 filename=fullfile_uvmat(RootPath,[],RootFile_ima1,ext_ima,NomType_ima1,i1_civ2(ifile),[],j1_civ2(j));
     2226                filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ2(ifile),[],j1_civ2(j));
    21992227                idetect_2(j)=exist(filename,'file')==2;
    22002228                filecell.ima1.civ2(ifile,j)={filename};%first image
     
    22142242        for ifile=1:nbfield
    22152243            for j=1:nbslice
    2216                 filename=fullfile_uvmat(RootPath,[],RootFile_ima2,ext_ima,NomType_ima2,i2_civ2(ifile),[],j2_civ2(j));
     2244                filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ2(ifile),[],j2_civ2(j));
    22172245                idetect_3(j)=exist(filename,'file')==2;
    22182246                filecell.ima2.civ2(ifile,j)={filename};%first image
     
    22712299    end
    22722300end
    2273 set(handles.SubdirCiv1,'String',regexprep(subdir_civ1,['^' SubdirImages],''));%suppress the root  SuddirImages;);%update the edit box
    2274 set(handles.SubdirCiv2,'String',regexprep(subdir_civ2,['^' SubdirImages],''));%update the edit box
     2301set(handles.SubdirCiv1,'String',regexprep(subdir_civ1,['^' SubDirImages],''));%suppress the root  SuddirImages;);%update the edit box
     2302set(handles.SubdirCiv2,'String',regexprep(subdir_civ2,['^' SubDirImages],''));%update the edit box
    22752303
    22762304% For CivX COPY IMAGES TO THE FORMAT .png IF NEEDED
    22772305if strcmp(CivMode,'CivX')
    2278     if isequal(NomType_ima1,'*')%case of movie files
    2279         NomType_imanew1='_i';
    2280     else
    2281         NomType_imanew1=NomType_ima1;
    2282     end
    2283     if isequal(NomType_ima2,'*')%case of movie files
    2284         NomType_imanew2='_i';
    2285     else
    2286         NomType_imanew2=NomType_ima2;
    2287     end
     2306    NomType_imanew1=NomType_ima1;
     2307    NomType_imanew2=NomType_ima2;
    22882308    if ~isequal(ext_ima,'.png')
    2289         %%type of image file
    2290         type_ima1='none';%default
    2291         movieobject1=[];%default
    2292         if strcmpi(ext_ima,'.avi')
    2293             if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab)
    2294                 type_ima1='movie';
    2295                 movieobject1=mmreader([filecell.filebase ext_ima]);
    2296             else
    2297                 type_ima1='avi';
    2298             end
    2299         elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))
    2300             form=imformats(ext_ima(2:end));
    2301             if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    2302                 if isequal(NomType_ima1,'*');
    2303                     type_ima1='multimage';%image series in a single image file
     2309        if checkbox(1) %if civ1 is performed
     2310             [FileType,FileInfo,MovieObject]=get_file_type(filecell.ima1.civ1{1});
     2311            check_j=0;
     2312            if strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader')||strcmp(FileType,'multimage')
     2313                if max(j1_civ1)>1
     2314                    check_j=1;
     2315                    NomType_imanew1='_1_1';
    23042316                else
    2305                     type_ima1='image';
     2317                    NomType_imanew1='_1';
    23062318                end
    23072319            end
    2308         end
    2309         type_ima2='none';%default
    2310         movieobject2=[];
    2311         if strcmpi(ext_ima,'.avi')
    2312             if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab)
    2313                 type_ima2='movie';
    2314                 movieobject2=mmreader([filecell.filebase ext_ima]);
    2315             else
    2316                 type_ima2='avi';
    2317             end
    2318         elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))
    2319             form=imformats(ext_ima(2:end));
    2320             if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    2321                 if isequal(NomType_ima1,'*');
    2322                     type_ima2='multimage';%image series in a single image file
    2323                 else
    2324                     type_ima2='image';
    2325                 end
    2326             end
    2327         end
    2328         if checkbox(1) %if civ1 is performed
    23292320            h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar
    23302321            for ifile=1:nbfield
    23312322                waitbar(ifile/nbfield);
    23322323                for j=1:nbslice
    2333                     filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j));
     2324                    filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j));
    23342325                    if ~exist(filename,'file')
    2335                         A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,i1_civ1(ifile),movieobject1);
    2336                         imwrite(A,filename,'BitDepth',16);
     2326                        if check_j
     2327                        A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ1(j));
     2328                        else
     2329                            A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ1(ifile));
     2330                        end
     2331                        imwrite(uint16(sum(A,3)),filename,'BitDepth',16);
    23372332                    end
    23382333                    filecell.ima1.civ1(ifile,j)={filename};
    2339                     filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ1(ifile),[],j2_civ1(j));
     2334                    filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,'.png',NomType_imanew1,i2_civ1(ifile),[],j2_civ1(j));
    23402335                    if ~exist(filename,'file')
    2341                         A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,i2_civ1(ifile),movieobject2);
    2342                         imwrite(A,filename,'BitDepth',16);
     2336                         if check_j
     2337                            A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j2_civ1(j));
     2338                        else
     2339                            A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i2_civ1(ifile));
     2340                         end
     2341                        imwrite(uint16(sum(A,3)),filename,'BitDepth',16);
    23432342                    end
    23442343                    filecell.ima2.civ1(ifile,j)={filename};
     
    23482347        end
    23492348        if checkbox(4) %if civ2 is performed
     2349             [FileType,FileInfo,MovieObject]=get_file_type(filecell.ima1.civ2{1});
     2350            check_j=0;
     2351            if strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader')||strcmp(FileType,'multimage')
     2352                if max(j1_civ2)>1
     2353                    check_j=1;
     2354                    NomType_imanew1='_1_1';
     2355                else
     2356                    NomType_imanew1='_1';
     2357                end
     2358            end
    23502359            h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar
    23512360            for ifile=1:nbfield
    23522361                waitbar(ifile/nbfield);
    23532362                for j=1:nbslice
    2354                     filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j));
     2363                    filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j));
    23552364                    if ~exist(filename,'file')
    2356                         A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,i1_civ2(ifile));
    2357                         imwrite(A,filename,'BitDepth',16);
     2365                        if check_j
     2366                        A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ2(j));
     2367                        else
     2368                            A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ2(ifile));
     2369                        end
     2370                        imwrite(uint16(sum(A,3)),filename,'BitDepth',16);
    23582371                    end
    23592372                    filecell.ima1.civ2(ifile,j)={filename};
    2360                     filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j));
     2373                    filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j));
    23612374                    if ~exist(filename,'file')
    2362                         A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,i2_civ2(ifile));
    2363                         imwrite(A,filename,'BitDepth',16);
     2375                        if check_j
     2376                        A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ2(j));
     2377                        else
     2378                            A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ2(ifile));
     2379                        end
     2380                        imwrite(uint16(sum(A,3)),filename,'BitDepth',16);
    23642381                    end
    23652382                    filecell.ima2.civ2(ifile,j)={filename};
     
    23732390%------------------------------------------------------------------------
    23742391% --- determine the list of index pairs of processing file
    2375 function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=...
     2392function [i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2]=...
    23762393    find_pair_indices(handles,ref_i,ref_j,mode)
    23772394%------------------------------------------------------------------------
     
    23942411if isequal (mode,'series(Di)')
    23952412    lastfield=str2double(get(handles.nb_field,'String'));
    2396     num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers
    2397     num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i));
    2398     num_a_civ1=ref_j;
    2399     num_b_civ1=ref_j;
    2400     num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i));
    2401     num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i));
    2402     num_a_civ2=ref_j;
    2403     num_b_civ2=ref_j;   
     2413    i1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers
     2414    i2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i));
     2415    j1_civ1=ref_j;
     2416    j2_civ1=ref_j;
     2417    i1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i));
     2418    i2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i));
     2419    j1_civ2=ref_j;
     2420    j2_civ2=ref_j;   
    24042421   
    24052422    % adjust the first and last field number
    24062423    lastfield=str2double(get(handles.nb_field,'String'));
    24072424    if isnan(lastfield)
    2408         indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1));
     2425        indsel=find((i1_civ1 >= 1)&(i1_civ2 >= 1));
    24092426    else
    2410         indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1));
     2427        indsel=find((i2_civ1 <= lastfield)&(i2_civ2 <= lastfield)&(i1_civ1 >= 1)&(i1_civ2 >= 1));
    24112428    end
    24122429    if length(indsel)>=1
     
    24162433        set(handles.last_i,'String',num2str(ref_i(lastind)))
    24172434        ref_i=ref_i(indsel);
    2418         num1_civ1=num1_civ1(indsel);
    2419         num1_civ2=num1_civ2(indsel);
    2420         num2_civ1=num2_civ1(indsel);
    2421         num2_civ2=num2_civ2(indsel);
     2435        i1_civ1=i1_civ1(indsel);
     2436        i1_civ2=i1_civ2(indsel);
     2437        i2_civ1=i2_civ1(indsel);
     2438        i2_civ2=i2_civ2(indsel);
    24222439    end
    24232440elseif isequal (mode,'series(Dj)')
    24242441    lastfield_j=str2double(get(handles.nb_field2,'String'));
    2425     num1_civ1=ref_i;% set of first image numbers
    2426     num2_civ1=ref_i;
    2427     num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j));
    2428     num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j));
    2429     num1_civ2=ref_i;
    2430     num2_civ2=ref_i;
    2431     num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j));
    2432     num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j));
     2442    i1_civ1=ref_i;% set of first image numbers
     2443    i2_civ1=ref_i;
     2444    j1_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j));
     2445    j2_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j));
     2446    i1_civ2=ref_i;
     2447    i2_civ2=ref_i;
     2448    j1_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j));
     2449    j2_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j));
    24332450    % adjust the first and last field number
    24342451    if isnan(lastfield_j)
    2435         indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1));
     2452        indsel=find((j1_civ1 >= 1)&(j1_civ2 >= 1));
    24362453    else
    2437         indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1));
     2454        indsel=find((j2_civ1 <= lastfield_j)&(j2_civ2 <= lastfield_j)&(j1_civ1 >= 1)&(j1_civ2 >= 1));
    24382455    end
    24392456    if length(indsel)>=1
     
    24432460        set(handles.last_j,'String',num2str(ref_j(lastind)))
    24442461        ref_j=ref_j(indsel);
    2445         num_a_civ1=num_a_civ1(indsel);
    2446         num_b_civ1=num_b_civ1(indsel);
    2447         num_a_civ2=num_a_civ2(indsel);
    2448         num_b_civ2=num_b_civ2(indsel);
     2462        j1_civ1=j1_civ1(indsel);
     2463        j2_civ1=j2_civ1(indsel);
     2464        j1_civ2=j1_civ2(indsel);
     2465        j2_civ2=j2_civ2(indsel);
    24492466    end
    24502467elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D)
    24512468    displ_num=get(handles.ListPairCiv1,'UserData');
    2452     num1_civ1=ref_i;
    2453     num2_civ1=ref_i;
    2454     num_a_civ1=displ_num(1,index_civ1);
    2455     num_b_civ1=displ_num(2,index_civ1);
    2456     num1_civ2=ref_i;
    2457     num2_civ2=ref_i;
    2458     num_a_civ2=displ_num(1,index_civ2);
    2459     num_b_civ2=displ_num(2,index_civ2);
     2469    i1_civ1=ref_i;
     2470    i2_civ1=ref_i;
     2471    j1_civ1=displ_num(1,index_civ1);
     2472    j2_civ1=displ_num(2,index_civ1);
     2473    i1_civ2=ref_i;
     2474    i2_civ2=ref_i;
     2475    j1_civ2=displ_num(1,index_civ2);
     2476    j2_civ2=displ_num(2,index_civ2);
    24602477elseif isequal(mode,'displacement')
    2461     num1_civ1=ref_i;
    2462     num2_civ1=ref_i;
    2463     num_a_civ1=ref_j;
    2464     num_b_civ1=ref_j;
    2465     num1_civ2=ref_i;
    2466     num2_civ2=ref_i;
    2467     num_a_civ2=ref_j;
    2468     num_b_civ2=ref_j;
     2478    i1_civ1=ref_i;
     2479    i2_civ1=ref_i;
     2480    j1_civ1=ref_j;
     2481    j2_civ1=ref_j;
     2482    i1_civ2=ref_i;
     2483    i2_civ2=ref_i;
     2484    j1_civ2=ref_j;
     2485    j2_civ2=ref_j;
    24692486end
    24702487
     
    26762693index_pair=get(handles.ListPairCiv1,'Value');
    26772694displ_num=get(handles.ListPairCiv1,'UserData');
    2678 % num_a=displ_num(1,index_pair);
    2679 % num_b=displ_num(2,index_pair);
    26802695list_pair2=get(handles.ListPairCiv2,'String');%get the menu of image pairs
    26812696if index_pair<=length(list_pair2)
     
    28162831
    28172832%% reads .nc subdirectoy and image numbers from the interface
    2818 SubDirImages=get(handles.SubdirImages,'String');
     2833SubDirImages=get(handles.SubDirImages,'String');
    28192834subdir_civ1=[SubDirImages get(handles.SubdirCiv1,'String')];%subdirectory subdir_civ1 for the netcdf data
    28202835subdir_civ2=[SubDirImages get(handles.SubdirCiv2,'String')];%subdirectory subdir_civ2 for the netcdf data
    28212836ref_i=str2double(get(handles.ref_i,'String'));
     2837ref_j=[];
    28222838if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')
    28232839    ref_j=0;
    2824 else
     2840elseif strcmp(get(handles.ref_j,'Visible'),'on')
    28252841    ref_j=str2double(get(handles.ref_j,'String'));
    2826     if isnan(ref_j)
    2827         ref_j=1;
    2828     end
     2842end
     2843if isempty(ref_j)
     2844    ref_j=1;
    28292845end
    28302846time=get(handles.ImaDoc,'UserData');%get the set of times
     
    28752891                testpair=1;
    28762892            else
    2877                 if  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
    2878                     errormsg=['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1];
    2879                 else
     2893%                 if  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
     2894%                     errormsg=['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1];
     2895%                 else
    28802896                    errormsg=['no civ1 file available for the selected reference indices (i,j)= ' num2str(ref_i) ', ' num2str(ref_j) ' and subdirectory ' subdir_civ1];
    2881                 end
     2897%                 end
    28822898                set(handles.ListPairCiv1,'String',{''});
    28832899                %COMPLETER CAS STEREO
     
    35613577    ' -m ' nx_patch  ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ' -c1 ' xmlA ' -c2 ' xmlB '  -xy  x -Nfy 1024 > ' namelog ' 2>&1']; % redirect standard output to the log file
    35623578
    3563 %------------------------------------------------------------------------
    3564 %--read images and convert them to the uint16 format used for PIV
    3565 function A=read_image(filename,type_ima,num,movieobject)
    3566 %------------------------------------------------------------------------
    3567 %num is the view number needed for an avi movie
    3568 switch type_ima
    3569     case 'movie'
    3570         A=read(movieobject,num);
    3571     case 'avi'
    3572         mov=aviread(filename,num);
    3573         A=frame2im(mov(1));
    3574     case 'multimage'
    3575         A=imread(filename,num);
    3576     case 'image'
    3577         A=imread(filename);
    3578 end
    3579 siz=size(A);
    3580 if length(siz)==3;%color images
    3581     A=sum(double(A),3);
    3582     A=uint16(A);
    3583 end
     3579% %------------------------------------------------------------------------
     3580% %--read images and convert them to the uint16 format used for PIV
     3581% function A=read_image(filename,type_ima,num,movieobject)
     3582% %------------------------------------------------------------------------
     3583% %num is the view number needed for an avi movie
     3584% switch type_ima
     3585%     case 'movie'
     3586%         A=read(movieobject,num);
     3587%     case 'avi'
     3588%         mov=aviread(filename,num);
     3589%         A=frame2im(mov(1));
     3590%     case 'multimage'
     3591%         A=imread(filename,num);
     3592%     case 'image'
     3593%         A=imread(filename);
     3594% end
     3595% siz=size(A);
     3596% if length(siz)==3;%color images
     3597%     A=sum(double(A),3);
     3598%     A=uint16(A);
     3599% end
    35843600
    35853601
     
    38593875RootPath=get(handles.RootPath,'String');
    38603876RootFile=get(handles.RootFile,'String');
     3877SubDirImages=get(handles.SubDirImages,'String');
    38613878ref_i=str2num(get(handles.ref_i,'String'));
    38623879ref_j=str2num(get(handles.ref_j,'String'));
    38633880NomType=get(handles.NomType,'String');
    38643881ImaExt=get(handles.ImaExt,'String');
    3865 fileinput=fullfile_uvmat(RootPath,'',RootFile,ImaExt,NomType,ref_i,[],ref_j);
     3882fileinput=fullfile_uvmat(RootPath,SubDirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j);
    38663883errormsg=display_file_name(handles,fileinput);
    38673884if ~isempty(errormsg)
     
    39573974function RootFile_Callback(hObject, eventdata, handles)
    39583975
    3959 function SubdirImages_Callback(hObject, eventdata, handles)
     3976function SubDirImages_Callback(hObject, eventdata, handles)
    39603977
    39613978
     
    41474164            else %Windows system
    41484165                filename=regexprep(filename,'\\','\\\\');
    4149                 cmd=['copy /Y ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_CMX\\\\$2.civ1.cmx" ') regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.civ1.cmx" \n')...
     4166                cmd=['copy /Y ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_CMX\\\\$2.civ1.cmx" ') regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')...
    41504167                    '"' regexprep(Param.xml.Civ1Bin,'\\','\\\\') '" -f ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" > ')...
    41514168                    regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_LOG\\\\$2.civ1.log" \n')... % redirect standard output to the log file
     
    42534270                    'rm ' regexprep(filename,'(.+)/(.+$)','$1/$2.cmx \n')];%rename .cmx as .checkciv2.cmx, the result file is named [filename '.nc'] by CIVx
    42544271            else
     4272                filename=regexprep(Param.OutputFile,'.nc','');
    42554273                filename=regexprep(filename,'\\','\\\\');
    42564274                cmd=[cmd 'copy /Y ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_CMX\\\\$2.civ2.cmx" ') regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')...
    4257                     '"' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f "' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" > ')...
     4275                    '"' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" > ')...
    42584276                     regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_LOG\\\\$2.civ2.log" \n')... % redirect standard output to the log file
    4259                     'del ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')];
    4260             end
     4277                    'del ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')];                       
     4278            end
     4279                 
    42614280        case 'CivAll'
    42624281            CivAllCmd=[CivAllCmd ' civ2 '];
     
    44414460
    44424461
    4443 
    4444 
    44454462%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    44464463% USELESS FUNCTIONS BELOW HERE,  TO CLEAN
    44474464%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    4448 
    4449 
    4450 
    4451 
    44524465
    44534466%------------------------------------------------------------------------
     
    45464559
    45474560
    4548 
    45494561function nb_field2_Callback(hObject, eventdata, handles)
    4550 % hObject    handle to nb_field2 (see GCBO)
    4551 % eventdata  reserved - to be defined in a future version of MATLAB
    4552 % handles    structure with handles and user data (see GUIDATA)
    4553 
    4554 % Hints: get(hObject,'String') returns contents of nb_field2 as text
    4555 %        str2double(get(hObject,'String')) returns contents of nb_field2 as a double
    4556 
    45574562
    45584563
    45594564function last_j_Callback(hObject, eventdata, handles)
    4560 % hObject    handle to last_j (see GCBO)
    4561 % eventdata  reserved - to be defined in a future version of MATLAB
    4562 % handles    structure with handles and user data (see GUIDATA)
    4563 
    4564 % Hints: get(hObject,'String') returns contents of last_j as text
    4565 %        str2double(get(hObject,'String')) returns contents of last_j as a double
    4566 
    45674565
    45684566
    45694567function last_i_Callback(hObject, eventdata, handles)
    4570 % hObject    handle to last_i (see GCBO)
    4571 % eventdata  reserved - to be defined in a future version of MATLAB
    4572 % handles    structure with handles and user data (see GUIDATA)
    4573 
    4574 % Hints: get(hObject,'String') returns contents of last_i as text
    4575 %        str2double(get(hObject,'String')) returns contents of last_i as a double
     4568
  • trunk/src/civ_matlab.m

    r493 r494  
    8888%% Civ1
    8989if isfield (Param,'Civ1')
    90     %     check_civ1=1;% test for further use of civ1 results
    91     % %% prepare images
    92 
    9390    par_civ1=Param.Civ1;
    94     if isfield(par_civ1,'reverse_pair')
     91    if isfield(par_civ1,'reverse_pair')% A REVOIR
    9592        if par_civ1.reverse_pair
    9693            if ischar(par_civ1.ImageB)
     
    103100        end
    104101    else
    105         if isfield(par_civ1,'ImageA')%&&...
    106             %    (ischar(par_civ1.ImageA)||strcmp(class(par_civ1.ImageA),'VideoReader')||strcmp(class(par_civ1.ImageA),'mmreader')) % case with no image: only the PIV grid is calculated           
     102        if isfield(Param.Civ1,'ImageA')%&&...   
    107103             Param.Civ1.ImageA=regexprep(Param.Civ1.ImageA,'''','\');
    108             [par_civ1.ImageA,ParamOut] = read_image(Param.Civ1.ImageA,par_civ1.FileTypeA,par_civ1.ImageA,par_civ1.FrameIndexA);
    109 %             if ~isempty(errormsg)
    110 %                 errormsg=['error in civ_matlab/read_field:' errormsg];
    111 %                 return
    112 %             end
    113             %par_civ1.ImageA=Field.A;%= image matrix A in the first input field
    114         end
    115         if isfield(par_civ1,'ImageB')%&& ...
    116               %  (ischar(par_civ1.ImageB)||strcmp(class(par_civ1.ImageB),'VideoReader')||strcmp(class(par_civ1.ImageB),'mmreader'))
     104            [par_civ1.ImageA,VideoObject] = read_image(Param.Civ1.ImageA,par_civ1.FileTypeA,[],par_civ1.FrameIndexA);
     105        end
     106        if isfield(Param.Civ1,'ImageB')%&& ...
    117107             Param.Civ1.ImageB=regexprep(Param.Civ1.ImageB,'''','\');
    118             [par_civ1.ImageB,ParamOut] = read_image(Param.Civ1.ImageB,par_civ1.FileTypeB,par_civ1.ImageB,par_civ1.FrameIndexB);
    119 %             if ~isempty(errormsg)
    120 %                 errormsg=['error in civ_matlab/read_field:' errormsg];
    121 %                 return
    122 %             end
    123            % par_civ1.ImageB=Field.A;%= image matrix A in the second input field
     108             if strcmp(Param.Civ1.ImageA,Param.Civ1.ImageB)% use the same movie object
     109                 [par_civ1.ImageB,VideoObject] = read_image(Param.Civ1.ImageB,par_civ1.FileTypeB,VideoObject,par_civ1.FrameIndexB);
     110             else
     111            [par_civ1.ImageB,VideoObject] = read_image(Param.Civ1.ImageB,par_civ1.FileTypeB,par_civ1.ImageB,par_civ1.FrameIndexB);
     112             end
    124113        end
    125114    end
     
    239228    [Data.Civ1_SubRange,Data.Civ1_NbSites,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=...
    240229        filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomain,Data.Patch1_Rho,Data.Patch1_Threshold);
    241     fill=zeros(3,2,size(Data.Civ1_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
    242     Data.Civ1_Coord_tps=cat(1,Data.Civ1_Coord_tps,fill);
     230%     fill=zeros(3,2,size(Data.Civ1_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
     231%     Data.Civ1_Coord_tps=cat(1,Data.Civ1_Coord_tps,fill);
    243232    Data.Civ1_U_smooth(ind_good)=Ures;
    244233    Data.Civ1_V_smooth(ind_good)=Vres;
     
    250239if isfield (Param,'Civ2')
    251240    par_civ2=Param.Civ2;
    252     if ~isfield (Param,'Civ1') || ~strcmp(Param.Civ1.ImageA,par_civ2.ImageA)
    253         %read first image if not already done for civ1
    254         [Field,ParamOut,errormsg] = read_field(Param.Civ2.ImageA,par_civ2.FileTypeA,par_civ2.ImageA,par_civ2.FrameIndexA);
    255                     if ~isempty(errormsg)
    256                 errormsg=['error in civ_matlab/read_field:' errormsg];
    257                 return
    258             end
    259         par_civ2.ImageA=Field.A;
    260     else
    261         par_civ2.ImageA=par_civ1.ImageA;
    262     end
    263     if ~isfield (Param,'Civ1') || ~strcmp(Param.Civ1.ImageB,par_civ2.ImageB)
    264         %read first image if not already done for civ1
    265         [Field,ParamOut,errormsg] = read_field(Param.Civ2.ImageB,par_civ2.FileTypeB,par_civ2.ImageB,par_civ2.FrameIndexB);
    266          if ~isempty(errormsg)
    267                 errormsg=['error in civ_matlab/read_field:' errormsg];
    268                 return
    269             end
    270         par_civ2.ImageB=Field.A;
    271     else
    272         par_civ2.ImageB=par_civ1.ImageB;
     241    par_civ2.ImageA=[];
     242    par_civ2.ImageB=[];
     243    if isfield(Param.Civ2,'ImageA') && isfield(Param.Civ2,'ImageB')
     244        Param.Civ2.ImageA=regexprep(Param.Civ2.ImageA,'''','\');
     245        Param.Civ2.ImageB=regexprep(Param.Civ2.ImageB,'''','\');
     246        if isfield (Param,'Civ1')
     247            Param.Civ2.ImageA=regexprep(Param.Civ2.ImageA,'''','\');
     248            if strcmp(Param.Civ1.ImageA,Param.Civ2.ImageA)
     249                if isequal(Param.Civ1.FrameIndexA,Param.Civ2.FrameIndexA)
     250                    par_civ2.ImageA=par_civ1.ImageA;
     251                else % read another frame of the same movie object
     252                    par_civ2.ImageA = read_image(Param.Civ2.ImageA,Param.Civ2.FileTypeA,VideoObject,Param.Civ2.FrameIndexA);
     253                end
     254            end
     255            Param.Civ2.ImageB=regexprep(Param.Civ2.ImageB,'''','\');
     256            if strcmp(Param.Civ1.ImageB,Param.Civ2.ImageB)
     257                if isequal(Param.Civ1.FrameIndexB,Param.Civ2.FrameIndexB)
     258                    par_civ2.ImageB=par_civ1.ImageB;
     259                else % read another frame of the same movie object
     260                    par_civ2.ImageB = read_image(Param.Civ2.ImageB,Param.Civ2.FileTypeB,VideoObject,Param.Civ2.FrameIndexB);
     261                end
     262            end
     263        end
     264        if isempty(par_civ2.ImageA) && isfield(Param.Civ2,'ImageA')
     265            [par_civ2.ImageA,VideoObject] = read_image(Param.Civ2.ImageA,Param.Civ2.FileTypeA,[],Param.Civ2.FrameIndexA);
     266        end
     267        if isempty(par_civ2.ImageB)&& isfield(Param.Civ2,'ImageB')
     268            if strcmp(Param.Civ2.ImageA,Param.Civ2.ImageB)
     269                par_civ2.ImageB = read_image(Param.Civ2.ImageB,Param.Civ2.FileTypeB,VideoObject,Param.Civ2.FrameIndexB);
     270            else
     271                par_civ2.ImageB = read_image(Param.Civ2.ImageB,Param.Civ2.FileTypeB,[],Param.Civ2.FrameIndexB);
     272            end
     273        end
    273274    end
    274275    ibx2=ceil(par_civ2.CorrBoxSize(1)/2);
     
    423424    [Data.Civ2_SubRange,Data.Civ2_NbSites,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures, Vres,tild,FFres]=...
    424425        filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomain,Data.Patch2_Rho,Data.Patch2_Threshold);
    425     fill=zeros(3,2,size(Data.Civ2_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
    426     Data.Civ2_Coord_tps=cat(1,Data.Civ2_Coord_tps,fill);
     426%     fill=zeros(3,2,size(Data.Civ2_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
     427%     Data.Civ2_Coord_tps=cat(1,Data.Civ2_Coord_tps,fill);
    427428    Data.Civ2_U_smooth(ind_good)=Ures;
    428429    Data.Civ2_V_smooth(ind_good)=Vres;
     
    434435if exist('ncfile','var')
    435436    errormsg=struct2nc(ncfile,Data);
     437    if isempty(errormsg)
     438        disp([ncfile ' written'])
     439    else
     440        disp(errormsg)
     441    end
    436442end
    437443
  • trunk/src/filter_tps.m

    r476 r494  
    1010% Coord_tps(NbSites,NbCoord,NbSubdomain): positions of the tps centres
    1111% U_tps,V_tps: weight of the tps for each subdomain
     12% to get the interpolated field values, use the function calc_field.m
    1213%
    1314% INPUT:
     
    123124U_smooth=U_smooth./nb_select;
    124125V_smooth=V_smooth./nb_select;
     126fill=zeros(NbCoord+1,NbCoord,size(SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
     127Coord_tps=cat(1,Coord_tps,fill);
     128
  • trunk/src/find_field_indices.m

    r491 r494  
    258258                CellVarType{icell}.nbsites_tps=VarType.nbsites_tps(ilist);
    259259                CellVarType{icell}.subrange_tps=VarType.subrange_tps(ilist);
     260                if isfield(Data,'ListDimName')
     261                    dim_index=find(strcmp(tps_dimnames{2},Data.ListDimName));
     262                    NbDim(icell)=Data.DimValue(dim_index);
     263                else
    260264                NbDim(icell)=size(Data.(Data.ListVarName{VarType.coord_tps(ilist)}),2);
     265                end
    261266            end
    262267            end
  • trunk/src/find_file_series.m

    r485 r494  
    216216    else
    217217        [tild,ifile_min]=min(ref_ij(ind_select));
    218         [tild,tild,tild,tild,tild,tild,tild,tild,NomType]=fileparts_uvmat(dirpair(ifile_min).name);% update the representation of indices (number of 0 before the number)
     218        [tild,tild,tild,tild,tild,tild,tild,tild,NomType]=fileparts_uvmat(dirpair(ind_select(ifile_min)).name);% update the representation of indices (number of 0 before the number)
    219219        NomType=regexprep(NomType,['^' NomTypePref],'');
    220220    end
     
    238238        NomType='*';
    239239    else
    240         j1_series=(1:FileInfo.NumberOfFrames)';
     240        i1_series=i1_series(:,2)*ones(1,FileInfo.NumberOfFrames);
     241        i1_series=[i1_series(:,1) i1_series];
     242        j1_series=ones(size(i1_series,1),1)*(0:FileInfo.NumberOfFrames);
    241243        %  include the first index in the root name
    242244        r=regexp(NomType,'^(?<tiretnum>_?\d+)','names');%look for a number or _1 at the beginning of NomType
  • trunk/src/geometry_calib.m

    r444 r494  
    9191%set the position of the interface
    9292if exist('pos','var')&& length(pos)>=4
    93 %     %pos_gui=get(hObject,'Position');
    94 %     pos_gui(1)=pos(1);
    95 %     pos_gui(2)=pos(2);
    9693    set(hObject,'Position',pos);
    9794end
     
    9996%set menu of calibration options
    10097set(handles.calib_type,'String',{'rescale';'linear';'3D_linear';'3D_quadr';'3D_extrinsic'})
    101 % inputxml='';
    10298if exist('inputfile','var')&& ~isempty(inputfile)
    10399    struct.XmlInputFile=inputfile;
    104 %     [Pathsub,RootFile,field_count,str2,str_a,str_b,ext]=name2display(inputfile);
    105     [RootPath,~,RootFile,~,~,~,~,FileExt]=fileparts_uvmat(inputfile);
     100    [RootPath,SubDir,RootFile,tild,tild,tild,tild,FileExt]=fileparts_uvmat(inputfile);
    106101    if ~strcmp(FileExt,'.xml')
    107         inputfile=[fullfile(RootPath,RootFile) '.xml'];%xml file corresponding to the input file
     102        inputfile=fullfile(RootPath,[SubDir '.xml']);%xml file corresponding to the input file
     103        if ~exist(inputfile,'file')% case of civ files , removes the extension for subdir
     104            inputfile=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']);
     105            if ~exist(inputfile,'file')
     106                inputfile=[fullfile(RootPath,SubDir,RootFile) '.xml'];%old convention
     107                if ~exist(inputfile,'file')
     108                    inputfile='';
     109                end
     110            end
     111        end
    108112    end
    109113    set(handles.ListCoord,'String',{'......'})
    110114    if exist(inputfile,'file')
    111         Heading=loadfile(handles,inputfile);% load the point coordiantes existing in the xml file
     115        Heading=loadfile(handles,inputfile);% load the point coordinates existing in the xml file
    112116        if isfield(Heading,'Campaign')&& ischar(Heading.Campaign)
    113117            struct.Campaign=Heading.Campaign;
     
    190194    GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));
    191195    [GeometryCalib.ErrorMax(2),index(2)]=max(abs(Ypoints-y_ima));
    192     [~,ind_dim]=max(GeometryCalib.ErrorMax);
     196    [tild,ind_dim]=max(GeometryCalib.ErrorMax);
    193197    index=index(ind_dim);
    194198    %set the Z position of the reference plane used for calibration
     
    12571261set(handles.ListCoord,'String',Tabchar)
    12581262
    1259 
    1260 % %------------------------------------------------------------------------
    1261 % % --- Executes on button press in rotation.
    1262 % function rotation_Callback(hObject, eventdata, handles)
    1263 % %------------------------------------------------------------------------
    1264 % angle_rot=(pi/180)*str2num(get(handles.Phi,'String'));
    1265 % Coord_cell=get(handles.ListCoord,'String');
    1266 % data=read_geometry_calib(Coord_cell);
    1267 % data.Coord(:,1)=cos(angle_rot)*data.Coord(:,1)+sin(angle_rot)*data.Coord(:,2);
    1268 % data.Coord(:,1)=-sin(angle_rot)*data.Coord(:,1)+cos(angle_rot)*data.Coord(:,2);
    1269 % set(handles.XObject,'String',num2str(data.Coord(:,1),4));
    1270 % set(handles.YObject,'String',num2str(data.Coord(:,2),4));
    1271 
    1272 
    1273 %------------------------------------------------------------------------
    1274 % image transform from px to phys
    1275 %INPUT:
    1276 %Zindex: index of plane
    1277 % function [A_out,Rangx,Rangy]=phys_Ima(A,Calib,ZIndex)
    1278 % %------------------------------------------------------------------------
    1279 % xcorner=[];
    1280 % ycorner=[];
    1281 % npx=[];
    1282 % npy=[];
    1283 % siz=size(A)
    1284 % npx=[npx siz(2)];
    1285 % npy=[npy siz(1)]
    1286 % xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];%image coordinates of corners
    1287 % yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5];
    1288 % [xcorner,ycorner]=phys_XYZ(Calib,xima,yima,ZIndex);%corresponding physical coordinates
    1289 % Rangx(1)=min(xcorner);
    1290 % Rangx(2)=max(xcorner);
    1291 % Rangy(2)=min(ycorner);
    1292 % Rangy(1)=max(ycorner);
    1293 % test_multi=(max(npx)~=min(npx)) | (max(npy)~=min(npy));
    1294 % npx=max(npx);
    1295 % npy=max(npy);
    1296 % x=linspace(Rangx(1),Rangx(2),npx);
    1297 % y=linspace(Rangy(1),Rangy(2),npy);
    1298 % [X,Y]=meshgrid(x,y);%grid in physical coordiantes
    1299 % vec_B=[];
    1300 %
    1301 % zphys=0; %default
    1302 % if isfield(Calib,'SliceCoord') %.Z= index of plane
    1303 %    SliceCoord=Calib.SliceCoord(ZIndex,:);
    1304 %    zphys=SliceCoord(3); %to generalize for non-parallel planes
    1305 % end
    1306 % [XIMA,YIMA]=px_XYZ(Calib,X,Y,zphys);%corresponding image indices for each point in the real space grid
    1307 % XIMA=reshape(round(XIMA),1,npx*npy);%indices reorganized in 'line'
    1308 % YIMA=reshape(round(YIMA),1,npx*npy);
    1309 % flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image
    1310 % testuint8=isa(A,'uint8');
    1311 % testuint16=isa(A,'uint16');
    1312 % if numel(siz)==2 %(B/W images)
    1313 %     vec_A=reshape(A,1,npx*npy);%put the original image in line
    1314 %     ind_in=find(flagin);
    1315 %     ind_out=find(~flagin);
    1316 %     ICOMB=((XIMA-1)*npy+(npy+1-YIMA));
    1317 %     ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
    1318 %     vec_B(ind_in)=vec_A(ICOMB);
    1319 %     vec_B(ind_out)=zeros(size(ind_out));
    1320 %     A_out=reshape(vec_B,npy,npx);%new image in real coordinates
    1321 % elseif numel(siz)==3     
    1322 %     for icolor=1:siz(3)
    1323 %         vec_A=reshape(A{icell}(:,:,icolor),1,npx*npy);%put the original image in line
    1324 %         ind_in=find(flagin);
    1325 %         ind_out=find(~flagin);
    1326 %         ICOMB=((XIMA-1)*npy+(npy+1-YIMA));
    1327 %         ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
    1328 %         vec_B(ind_in)=vec_A(ICOMB);
    1329 %         vec_B(ind_out)=zeros(size(ind_out));
    1330 %         A_out(:,:,icolor)=reshape(vec_B,npy,npx);%new image in real coordinates
    1331 %     end
    1332 % end
    1333 % if testuint8
    1334 %     A_out=uint8(A_out);
    1335 % end
    1336 % if testuint16
    1337 %     A_out=uint16(A_out);
    1338 % end
    1339 
    1340 %------------------------------------------------------------------------
    1341 % pointwise transform from px to phys
    1342 %INPUT:
    1343 %Z: index of plane
    1344 % function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Z)
    1345 % %------------------------------------------------------------------------
    1346 % if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'SliceCoord')&length(Calib.SliceCoord)>=Z
    1347 %     Zindex=Z;
    1348 %     Zphys=Calib.SliceCoord(Zindex,3);%GENERALISER AUX CAS AVEC ANGLE
    1349 % else
    1350 %     Zphys=0;
    1351 % end
    1352 % if ~exist('X','var')||~exist('Y','var')
    1353 %     Xphys=[];
    1354 %     Yphys=[];%default
    1355 %     return
    1356 % end
    1357 % Xphys=X;%default
    1358 % Yphys=Y;
    1359 % %image transform
    1360 % if isfield(Calib,'R')
    1361 %     R=(Calib.R)';
    1362 %     Dx=R(5)*R(7)-R(4)*R(8);
    1363 %     Dy=R(1)*R(8)-R(2)*R(7);
    1364 %     D0=Calib.f*(R(2)*R(4)-R(1)*R(5));
    1365 %     Z11=R(6)*R(8)-R(5)*R(9);
    1366 %     Z12=R(2)*R(9)-R(3)*R(8); 
    1367 %     Z21=R(4)*R(9)-R(6)*R(7);
    1368 %     Z22=R(3)*R(7)-R(1)*R(9);
    1369 %     Zx0=R(3)*R(5)-R(2)*R(6);
    1370 %     Zy0=R(1)*R(6)-R(3)*R(4);
    1371 %     A11=R(8)*Calib.Ty-R(5)*Calib.Tz+Z11*Zphys;
    1372 %     A12=R(2)*Calib.Tz-R(8)*Calib.Tx+Z12*Zphys;
    1373 %     A21=-R(7)*Calib.Ty+R(4)*Calib.Tz+Z21*Zphys;
    1374 %     A22=-R(1)*Calib.Tz+R(7)*Calib.Tx+Z11*Zphys;
    1375 %     X0=Calib.f*(R(5)*Calib.Tx-R(2)*Calib.Ty+Zx0*Zphys);
    1376 %     Y0=Calib.f*(-R(4)*Calib.Tx+R(1)*Calib.Ty+Zy0*Zphys);
    1377 %         %px to camera:
    1378 %     Xd=(Calib.dpx/Calib.sx)*(X-Calib.Cx); % sensor coordinates
    1379 %     Yd=Calib.dpy*(Y-Calib.Cy);
    1380 %     dist_fact=1+Calib.kappa1*(Xd.*Xd+Yd.*Yd); %distortion factor
    1381 %     Xu=dist_fact.*Xd;%undistorted sensor coordinates
    1382 %     Yu=dist_fact.*Yd;
    1383 %     denom=Dx*Xu+Dy*Yu+D0;
    1384 %     % denom2=denom.*denom;
    1385 %     Xphys=(A11.*Xu+A12.*Yu+X0)./denom;%world coordinates
    1386 %     Yphys=(A21.*Xu+A22.*Yu+Y0)./denom;
    1387 % end
    1388 
    1389 
    13901263% --------------------------------------------------------------------
    13911264function MenuImportPoints_Callback(hObject, eventdata, handles)
  • trunk/src/get_field.m

    r436 r494  
    110110if exist('filename','var') && ischar(filename) %transfer input file name in slave mode
    111111    set(handles.inputfile,'String',filename)% prefill the input file name
    112     Field=nc2struct(filename,[]);% reads the whole field
     112    Field=nc2struct(filename,[]);% reads the  field structure, without variables
    113113    if isfield(Field,'Txt')
    114114        msgbox_uvmat('ERROR',Field.Txt)
    115115    else
    116116        set(handles.get_field,'UserData',Field);
    117         Field_input(eventdata,handles,Field);
     117        Field_input(handles,Field);
    118118    end
    119119else  %master mode
     
    177177else
    178178set(handles.get_field,'UserData',Field);
    179 Field_input(eventdata,handles,Field);
     179Field_input(handles,Field);
    180180end
    181181huvmat=findobj(allchild(0),'tag','uvmat');
     
    186186%------------------------------------------------------------------------
    187187% --- update the display when a new field is introduced.
    188 function Field_input(eventdata,handles,Field)
     188function Field_input(handles,Field)
    189189%------------------------------------------------------------------------
    190190if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName)
     
    282282        end
    283283    end
    284     check_1Dplot_Callback(handles.check_1Dplot, eventdata, handles)
    285     check_scalar_Callback(handles.check_scalar, eventdata, handles)
    286     check_vector_Callback(handles.check_vector, eventdata, handles)
     284    check_1Dplot_Callback(handles.check_1Dplot, [], handles)
     285    check_scalar_Callback(handles.check_scalar, [], handles)
     286    check_vector_Callback(handles.check_vector, [], handles)
    287287end
    288288%scalar_Callback(handles.get_field, eventdata, handles)
  • trunk/src/proj_field.m

    r492 r494  
    12381238                        ProjData.VarAttribute{ivar_new+1+nbcoord}.Role='errorflag';
    12391239                    end
     1240%                     case 'filter'%interpolate data on a regular grid
     1241%                         errormsg='tps required for filter option'
     1242                       
    12401243            end
    12411244           
     
    20762079                eval(['ProjData.' AXName '=[Xbound(1) Xbound(2)];']) %record the new (projected ) x coordinates
    20772080            end
    2078         else       % case with rotation and/or interpolation
     2081        elseif isfield(FieldData,'A') %TO GENERALISE       % case with rotation and/or interpolation
    20792082            if NbDim==2 %2D case
    20802083                [X,Y]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates
     
    21042107                    if test_filter 
    21052108                         Aclass=class(FieldData.A);
    2106                          eval(['ProjData.' VarName '=filter2(Mfilter,FieldData.' VarName ',''valid'');'])
     2109                         ProjData.(VarName)=filter2(Mfilter,FieldData.(VarName),'valid');
    21072110                         if ~isequal(Aclass,'double')
    2108                              eval(['ProjData.' VarName '=' Aclass '(FieldData.' VarName ');'])%revert to integer values
     2111                             ProjData.(VarName)=Aclass(FieldData.(VarName));%revert to integer values
    21092112                         end
    21102113                    end
  • trunk/src/read_civdata.m

    r492 r494  
    8181end
    8282switch VelTypeOut
    83     case{'civ1','civ-filter1','filter1'}
     83    case{'civ1','filter1'}
     84        if isfield(Field,'Patch1_SubDomain')
     85            Field.SubDomain=Field.Patch1_SubDomain;
     86            Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'SubDomain'}];
     87        end     
    8488        Field.Dt=Field.Civ1_Dt;
    85     case{'civ2','civ-filter2','filter2'}
     89        Field.Time=Field.Civ1_Time;
     90    case{'civ2','filter2'}
     91        if isfield(Field,'Patch2_SubDomain')
     92            Field.SubDomain=Field.Patch2_SubDomain;
     93            Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'SubDomain'}];
     94        end
    8695        Field.Dt=Field.Civ2_Dt;
     96        Field.Time=Field.Civ2_Time;
    8797end
    88 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'Dt'}];
     98Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'Dt','Time'}];
    8999var_ind=find(vardetect);
    90100for ivar=1:numel(var_ind)
     
    93103    Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel
    94104end
    95 
    96105Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'NbCoord','NbDim','TimeUnit','CoordUnit'}];
    97106% %% update list of global attributes
  • trunk/src/series.m

    r490 r494  
    17761776                set(handles.TransformName,'Enable','on')
    17771777                set(handles.FieldTransform,'Visible','on')
     1778                TransformName_Callback([],[], handles)
    17781779            end
    17791780        case 'ProjObject'   %hidden by default
     
    20482049%check the current ActionPath to the selected function
    20492050if ~isempty(list_transform{ind_coord})
    2050 func=functions(list_transform{ind_coord});
    2051 set(handles.TransformPath,'String',fileparts(func.file)); %show the path to the senlected function
    2052 else
    2053    set(handles.TransformPath,'String',''); %show the path to the senlected function
     2051    func=functions(list_transform{ind_coord});
     2052    set(handles.TransformPath,'String',fileparts(func.file)); %show the path to the senlected function
     2053else
     2054    set(handles.TransformPath,'String',''); %show the path to the senlected function
    20542055end
    20552056
  • trunk/src/series/aver_stat.m

    r478 r494  
    227227            end
    228228           
    229             % field calculation (vort, div...)
     229            %% check whether tps is needed, then calculate tps coefficients if needed
     230            check_tps=0;
     231            if ischar(Param.InputFields.FieldName)
     232                Param.InputFields.FieldName={Param.InputFields.FieldName};
     233            end
     234            for ilist=1:numel(Param.InputFields.FieldName)
     235                switch Param.InputFields.FieldName{ilist}
     236                    case {'vort','div','strain'}
     237                        check_tps=1;
     238                end
     239            end
     240            if strcmp(Param.ProjObject.ProjMode,'filter')
     241                check_tps=1;
     242            end
     243            if check_tps
     244                SubDomain=1500; %default, estimated nbre of vectors in a subdomain used for tps
     245                if isfield(Data{iview},'SubDomain')
     246                    SubDomain=Data{iview}.SubDomain;%
     247                end
     248                [Data{iview}.SubRange,Data{iview}.NbSites,Data{iview}.Coord_tps,Data{iview}.U_tps,Data{iview}.V_tps,tild,U_smooth,V_smooth,W_smooth,FF] =...
     249                    filter_tps([Data{iview}.X(Data{iview}.FF==0) Data{iview}.Y(Data{iview}.FF==0)],Data{iview}.U(Data{iview}.FF==0),Data{iview}.V(Data{iview}.FF==0),[],SubDomain,0);
     250                nbvar=numel(Data{iview}.ListVarName);
     251                Data{iview}.ListVarName=[Data{iview}.ListVarName {'SubRange','NbSites','Coord_tps','U_tps','V_tps'}];
     252                Data{iview}.VarDimName=[Data{iview}.VarDimName {{'nb_coord','nb_bounds','nb_subdomain'},{'nb_subdomain'},...
     253                    {'nb_tps','nb_coord','nb_subdomain'},{'nb_tps','nb_subdomain'},{'nb_tps','nb_subdomain'}}];
     254                Data{iview}.VarAttribute{nbvar+3}.Role='coord_tps';
     255                Data{iview}.VarAttribute{nbvar+4}.Role='vector_x';
     256                Data{iview}.VarAttribute{nbvar+5}.Role='vector_y';
     257                if isfield(Data{iview},'ListDimName')%cleaning
     258                    Data{iview}=rmfield(Data{iview},'ListDimName');
     259                end
     260                if isfield(Data{iview},'DimValue')%cleaning
     261                    Data{iview}=rmfield(Data{iview},'DimValue');
     262                end
     263            end
     264                 
     265            % field calculation (vort, div...)   
    230266            if strcmp(FileType{1},'civx')||strcmp(FileType{1},'civdata')
    231                 Data{1}=calc_field(InputFields{1}.FieldName,Data{1});%calculate field (vort..)
    232             end
    233            
     267                if isfield(Data{1},'Coord_tps')
     268                    Data{1}.FieldList=Param.InputFields.FieldName;
     269                else
     270                    Data{1}=calc_field(Param.InputFields.FieldName,Data{1});%calculate field (vort..)
     271                end
     272            end
     273         
    234274            % field substration (for two input file series)
    235275            if length(Data)==2
    236                 if strcmp(FileType{2},'civx')||strcmp(FileType{2},'civ')
    237                     Data{2}=calc_field(InputFields{2}.FieldName,Data{2});%calculate field (vort..)
     276                if strcmp(FileType{2},'civx')||strcmp(FileType{2},'civdata')
     277                    if isfield(Data{2},'Coord_tps')
     278                        Data{2}.FieldList=Param.InputFields.FieldName;
     279                    else
     280                        Data{2}=calc_field(Param.InputFields.FieldName,Data{2});%calculate field (vort..)
     281                    end
    238282                end
    239283                [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields
  • trunk/src/series/merge_proj.m

    r478 r494  
    193193        for iview=1:nbview
    194194            % reading input file(s)
     195            filecell{iview,index}
    195196            [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index));
    196197            if ~isempty(errormsg)
     
    207208                Data{iview}.ZIndex=mod(i1_series{iview}(index)-1,NbSlice_calib{iview})+1;%Zindex for phys transform
    208209            end
     210           
    209211            %transform the input field (e.g; phys) if requested
    210212            if ~isempty(transform_fct)
    211213                Data{iview}=transform_fct(Data{iview},XmlData{iview});  %transform to phys if requested
    212214            end
    213             % field calculation (vort, div...)
     215           
     216            %% check whether tps is needed, then calculate tps coefficients if needed
     217            check_tps=0;
     218            if ischar(Param.InputFields.FieldName)
     219                Param.InputFields.FieldName={Param.InputFields.FieldName};
     220            end
     221            for ilist=1:numel(Param.InputFields.FieldName)
     222                switch Param.InputFields.FieldName{ilist}
     223                    case {'vort','div','strain'}
     224                        check_tps=1;
     225                end
     226            end
     227            if strcmp(Param.ProjObject.ProjMode,'filter')
     228                check_tps=1;
     229            end
     230            if check_tps
     231                SubDomain=1500; %default, estimated nbre of vectors in a subdomain used for tps
     232                if isfield(Data{iview},'SubDomain')
     233                    SubDomain=Data{iview}.SubDomain;%
     234                end
     235                [Data{iview}.SubRange,Data{iview}.NbSites,Data{iview}.Coord_tps,Data{iview}.U_tps,Data{iview}.V_tps,tild,U_smooth,V_smooth,W_smooth,FF] =...
     236                    filter_tps([Data{iview}.X(Data{iview}.FF==0) Data{iview}.Y(Data{iview}.FF==0)],Data{iview}.U(Data{iview}.FF==0),Data{iview}.V(Data{iview}.FF==0),[],SubDomain,0);
     237                nbvar=numel(Data{iview}.ListVarName);
     238                Data{iview}.ListVarName=[Data{iview}.ListVarName {'SubRange','NbSites','Coord_tps','U_tps','V_tps'}];
     239                Data{iview}.VarDimName=[Data{iview}.VarDimName {{'nb_coord','nb_bounds','nb_subdomain'},{'nb_subdomain'},...
     240                    {'nb_tps','nb_coord','nb_subdomain'},{'nb_tps','nb_subdomain'},{'nb_tps','nb_subdomain'}}];
     241                Data{iview}.VarAttribute{nbvar+3}.Role='coord_tps';
     242                Data{iview}.VarAttribute{nbvar+4}.Role='vector_x';
     243                Data{iview}.VarAttribute{nbvar+5}.Role='vector_y';
     244                if isfield(Data{iview},'ListDimName')%cleaning
     245                    Data{iview}=rmfield(Data{iview},'ListDimName');
     246                end
     247                if isfield(Data{iview},'DimValue')%cleaning
     248                    Data{iview}=rmfield(Data{iview},'DimValue');
     249                end
     250            end
     251                 
     252            % field calculation (vort, div...)   
    214253            if strcmp(FileType{iview},'civx')||strcmp(FileType{iview},'civdata')
    215                 Data{iview}=calc_field(Param.InputFields.FieldName,Data{iview});%calculate field (vort..)
     254                if isfield(Data{iview},'Coord_tps')
     255                    Data{iview}.FieldList=Param.InputFields.FieldName;
     256                else
     257                    Data{iview}=calc_field(Param.InputFields.FieldName,Data{iview});%calculate field (vort..)
     258                end
    216259            end
    217260           
  • trunk/src/sub_field.m

    r428 r494  
    301301    end     
    302302    if ~testX_1% if the second field has structured coordinates
     303        ilist_1=find(strcmp(AName_1,Field_1.ListVarName));
     304        DimCell_1=Field_1.VarDimName{ilist_1};
     305        if numel(DimCell_1)>2
     306             DimCell={XName_1_1,YName_1_1, [{YName_1_1,XName_1_1} DimCell_1(3:end)]};
     307        else
    303308          DimCell={XName_1_1,YName_1_1, {YName_1_1,XName_1_1}};
     309        end
    304310    else
    305311        DimCell=[DimCell Field_1.VarDimName(ivar_C_1)];
  • trunk/src/transform_field/phys.m

    r433 r494  
    159159        DataOut.V=(YOut_2-YOut_1)/Dt;
    160160    end
    161     if ~strcmp(Calib.CalibrationType,'rescale') && isfield(Data,'X_tps') && isfield(Data,'Y_tps')
    162         [DataOut.X_tps,DataOut.Y_tps]=phys_XYZ(Calib,Data.X,Data.Y,ZIndex);
    163     end
    164 end
     161%     if ~strcmp(Calib.CalibrationType,'rescale') && isfield(Data,'X_tps') && isfield(Data,'Y_tps')
     162%         [DataOut.X_tps,DataOut.Y_tps]=phys_XYZ(Calib,Data.X,Data.Y,ZIndex);
     163%     end
     164end
     165
     166%% suppress tps
     167list_tps={'Coord_tps'  'U_tps'  'V_tps'  'SubRange'  'NbSites'};
     168ind_remove=[];
     169for ilist=1:numel(list_tps)
     170    ind_tps=find(strcmp(list_tps{ilist},Data.ListVarName));
     171    if ~isempty(ind_tps)
     172        ind_remove=[ind_remove ind_tps];
     173        DataOut=rmfield(DataOut,list_tps{ilist});
     174    end
     175end
     176DataOut.ListVarName(ind_remove)=[];
     177DataOut.VarDimName(ind_remove)=[];
     178DataOut.VarAttribute(ind_remove)=[];
     179   
     180   
    165181
    166182%% transform of spatial derivatives: TODO check the case with plane angles
  • trunk/src/uvmat.m

    r491 r494  
    859859XmlData.Time=[];%default
    860860XmlData.GeometryCalib=[];%default
    861 TimeUnit=[];%default
     861TimeUnit='';%default
     862Time=[];
    862863testima=0; %test for image input
    863864imainfo=[];
     
    870871%     nbfield_j=1;
    871872    TimeUnit='s';
    872     XmlData.Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)';
     873    if isempty(j1_series); %frame index along i
     874        Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
     875    else
     876    Time=ones(size(i1_series,1),1)*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
     877    end
    873878    %nbfield=imainfo.NumberOfFrames;
    874879    set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
     
    945950        end
    946951    end
     952end
     953if ~(isfield(XmlData,'Time')&& ~isempty(XmlData.Time))
     954    XmlData.Time=Time; %time set by video
    947955end
    948956
     
    10631071if index==2
    10641072    if get(handles.scan_j,'Value')
    1065         scan_option='j'; %keep the scan option for the second fiel series
     1073        scan_option='j'; %keep the scan option for the second file series
    10661074    end
    10671075    if strcmp(get(handles.j1,'Visible'),'on')
     
    10691077    end
    10701078end
     1079[ref_i,ref_j]=find(i1_series);
    10711080if ~isempty(j1_series)
    10721081        state_j='on';
    1073         if isequal(nbfield,1) &&index==1
    1074             scan_option='j'; %scan j index by default if nbfield=1               
    1075         end
     1082        if index==1
     1083            if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first vzlue
     1084                scan_option='j'; %scan j indext               
     1085            end
     1086        end
    10761087end
    10771088if isequal(scan_option,'i')
     1089    diff_ref_i=diff(ref_i,1);
     1090    if isempty(diff_ref_i)
     1091        diff_ref_i=1;
     1092    end
     1093    if isequal (diff_ref_i,diff_ref_i(1)*ones(size(diff_ref_i)))
     1094        set(handles.increment_scan,'String',num2str(diff_ref_i(1)))
     1095    end
    10781096     set(handles.scan_i,'Value',1)
    10791097     scan_i_Callback([],[], handles);
    10801098else
     1099    diff_ref_j=diff(ref_j);
     1100    if isempty(diff_ref_j)
     1101        diff_ref_j=1;
     1102    end
     1103    if isequal (diff_ref_j,diff_ref_j(1)*ones(size(diff_ref_j)))
     1104        set(handles.increment_scan,'String',num2str(diff_ref_j(1)))
     1105    end
    10811106     set(handles.scan_j,'Value',1)
    10821107     scan_j_Callback([],[], handles);
     
    12461271option=get(handles.view_xml,'String');
    12471272if isequal(option,'view .xml')
    1248     FileXml=[FileBase '.xml'];
     1273    FileXml=fullfile(RootPath,[SubDir '.xml']);
     1274    if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir
     1275        FileXml=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']);
     1276    end
    12491277    heditxml=editxml(FileXml);
    12501278end
     
    12561284%case of view mask selection
    12571285if isequal(get(handles.CheckMask,'Value'),1)
    1258    % [FF,RootPath,FileBase]=read_file_boxes(handles);
    12591286     [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    12601287     FileBase=fullfile(RootPath,RootFile);
     
    12701297            maskname=maskfiles(ilist).name;% take the first mask file in the list
    12711298            [tild,tild,tild,tild,tild,tild,tild,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname);
    1272 %             [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
    12731299             [tild,Name]=fileparts(maskname);
    12741300            Namedouble=double(Name);
     
    19551981end
    19561982NomType=get(handles.NomType,'String');
     1983NomType_1='';
     1984if strcmp(get(handles.NomType_1,'Visible'),'on')
     1985    NomType_1=get(handles.NomType_1,'String');
     1986end
    19571987% NomType=get(handles.FileIndex,'UserData');
    19581988%update the z position index
     
    21102140        ParamOut_1=UvData.ParamOut_1;
    21112141    else
     2142        if isstruct(ParamIn_1)
    21122143        ParamIn_1.FieldName=FieldName_1;
    21132144        ParamIn_1.VelType=VelType_1;
    21142145        ParamIn_1.GUIName='get_field_1';
     2146        end
    21152147        [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,frame_index_1);
    21162148        if ~isempty(errormsg)
     
    21742206        test_veltype_1=1;
    21752207        set(handles.VelType_1,'Visible','on')
    2176 %         if ~get(handles.FixVelType,'Value')
    2177             menu=set_veltype_display(ParamOut_1.CivStage);
    2178             index_menu=strcmp(ParamOut_1.VelType,menu);
    2179             set(handles.VelType_1,'Value',1+find(index_menu,1))
    2180             set(handles.VelType_1,'String',[{''};menu])
    2181 %         end
     2208        menu=set_veltype_display(ParamOut_1.CivStage);
     2209        index_menu=strcmp(ParamOut_1.VelType,menu);
     2210        set(handles.VelType_1,'Value',1+find(index_menu,1))
     2211        set(handles.VelType_1,'String',[{''};menu])
    21822212    end
    21832213    % update the second field menu: the same quantity
     2214    if isstruct(ParamOut_1)
    21842215    set(handles.Fields_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu
    21852216    % display the Fields menu from the input file and pick the selected one:
    21862217    field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
    21872218    set(handles.Fields_1,'Value',find(field_index,1)+1) 
    2188 %     % synchronise  with the first menu if the first selection is not 'velocity'
    2189 %     if ~strcmp(ParamOut.FieldName,'velocity')
    2190 %         field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
    2191 %         set(handles.Fields_1,'Value',field_index); %update the field menu
    2192 %         ParamOut_1.FieldName=ParamOut.FieldName;
    2193 %         set(handles.Fields_1,'String',ParamOut_1.FieldList)
    2194 %     end
     2219    end
     2220   
    21952221end
    21962222if test_veltype||test_veltype_1
     
    23372363        Field{1}=transform(Field{1},XmlData);
    23382364    end
    2339     %% update tps in phys coordinates if needed
    2340     if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& strcmp(UvData.FileType{1},'civdata')&&isfield(Field{1},'U')&& isfield(Field{1},'V')
    2341         Field{1}.X=Field{1}.X(Field{1}.FF==0);
    2342         Field{1}.Y=Field{1}.Y(Field{1}.FF==0);
    2343         Field{1}.U=Field{1}.U(Field{1}.FF==0);
    2344         Field{1}.V=Field{1}.V(Field{1}.FF==0);
    2345         [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps]=filter_tps([Field{1}.X Field{1}.Y],Field{1}.U,Field{1}.V,[],Field{1}.Patch1_SubDomain,0);
    2346     end
    2347     if numel(Field)==2 && ~test_keepdata_1 && isequal(UvData.FileType{2}(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)
    2348         %update tps in phys coordinates if needed
    2349         if (strcmp(VelType_1,'filter1')||strcmp(VelType_1,'filter2'))&& strcmp(UvData.FileType{2},'civdata')&&isfield(Field{2},'U')&& isfield(Field{2},'V')
    2350             Field{2}.X=Field{2}.X(Field{2}.FF==0);
    2351             Field{2}.Y=Field{1}.Y(Field{2}.FF==0);
    2352             Field{2}.U=Field{1}.U(Field{2}.FF==0);
    2353             Field{2}.V=Field{1}.V(Field{2}.FF==0);
    2354             [Field{2}.SubRange,Field{2}.NbSites,Field{2}.Coord_tps,Field{2}.U_tps,Field{2}.V_tps]=filter_tps([Field{2}.X Field{2}.Y],Field{2}.U,Field{2}.V,[],1500,0);
     2365   
     2366    %% check whether tps is needed, then calculate tps coefficients if needed
     2367    check_tps=0;
     2368    if strcmp(UvData.FileType{1},'civdata')|| strcmp(UvData.FileType{1},'civx')
     2369        switch ParamOut.FieldName
     2370            case {'vort','div','strain'}
     2371                check_tps=1;
     2372            otherwise
     2373                check_tps=0;
     2374                if isfield(UvData,'Object')
     2375                for iobj=1:numel(UvData.Object)
     2376                    UvData.Object{iobj}
     2377                    if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'filter')
     2378                        check_tps=1;
     2379                        break
     2380                    end
     2381                end
     2382                end
     2383        end
     2384    end
     2385    if check_tps
     2386        SubDomain=1500; %default, estimated nbre of vectors in a subdomain used for tps
     2387        if isfield(Field{1},'SubDomain')
     2388            SubDomain=Field{1}.SubDomain;%
     2389        end
     2390        [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps,tild,U_smooth,V_smooth,W_smooth,FF] =...
     2391           filter_tps([Field{1}.X(Field{1}.FF==0) Field{1}.Y(Field{1}.FF==0)],Field{1}.U(Field{1}.FF==0),Field{1}.V(Field{1}.FF==0),[],SubDomain,0);
     2392        nbvar=numel(Field{1}.ListVarName);
     2393        Field{1}.ListVarName=[Field{1}.ListVarName {'SubRange','NbSites','Coord_tps','U_tps','V_tps'}];
     2394        Field{1}.VarDimName=[Field{1}.VarDimName {{'nb_coord','nb_bounds','nb_subdomain'},{'nb_subdomain'},...
     2395            {'nb_tps','nb_coord','nb_subdomain'},{'nb_tps','nb_subdomain'},{'nb_tps','nb_subdomain'}}];
     2396        Field{1}.VarAttribute{nbvar+3}.Role='coord_tps';
     2397        Field{1}.VarAttribute{nbvar+4}.Role='vector_x';
     2398        Field{1}.VarAttribute{nbvar+5}.Role='vector_y';
     2399        if isfield(Field{1},'ListDimName')%cleaning
     2400            Field{1}=rmfield(Field{1},'ListDimName');
     2401        end
     2402        if isfield(Field{1},'DimValue')%cleaning
     2403            Field{1}=rmfield(Field{1},'DimValue');
    23552404        end
    23562405    end
     
    30953144[tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]);
    30963145if isequal(field,'image')
    3097     SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
    3098     imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]);
     3146    if  isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file
     3147        imagename=UvData.Field.Civ2_ImageA;
     3148    elseif isfield(UvData.Field,'Civ1_ImageA')%
     3149        imagename=UvData.Field.Civ1_ImageA;
     3150    else
     3151        SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
     3152        imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]);
     3153    end
    30993154    if ~exist(imagename,'file')
    31003155        [FileName,PathName] = uigetfile( ...
     
    31993254        end
    32003255    case 'image'
    3201         % guess the image name corresponding to the current netcdf name (no unique correspondance)
    3202         SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.'
    3203         imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1);
     3256        % get the image name corresponding to the current netcdf name (no unique correspondance)
     3257        if  isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file
     3258            imagename=UvData.Field.Civ2_ImageA;
     3259        elseif isfield(UvData.Field,'Civ1_ImageA')%
     3260            imagename=UvData.Field.Civ1_ImageA;
     3261        else
     3262            SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.'
     3263            imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1);
     3264        end
    32043265        if ~exist(imagename,'file') % browse for images if it is not found
    32053266            [FileName,PathName] = uigetfile( ...
Note: See TracChangeset for help on using the changeset viewer.