Changeset 354


Ignore:
Timestamp:
Dec 30, 2011, 5:00:25 PM (13 years ago)
Author:
sommeria
Message:
 
Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r353 r354  
    12101210                    nbslice_mask=str2double(Param.Civ1.Mask(1:end-4)); %
    12111211                    i1_mask=mod(i1_civ1(ifile)-1,nbslice_mask)+1;
    1212                     Param.Civ1.Mask=name_generator(maskbase,i1_mask,1,'.png','_i');
     1212                    [RootPathMask,RootFileMask]=fileparts(maskbase);
     1213                    Param.Civ1.Mask=fullfile_uvmat(RootPathMask,[],RootFileMask,'.png','_1',i1_mask);
     1214                   % Param.Civ1.Mask=name_generator(maskbase,i1_mask,1,'.png','_i');
    12131215                end
    12141216            end
     
    12191221                    if ~isnan(nbslice_grid)
    12201222                        i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1;
    1221                         Param.Civ1.Grid=[filecell.filebase '_' name_generator(Param.Civ1.Grid,i1_grid,1,'.grid','_i')];
     1223                        Param.Civ1.Grid=[filecell.filebase '_' fullfile_uvmat('','',Param.Civ1.Grid,'.grid','_1',i1_grid)];
     1224%                         Param.Civ1.Grid=[filecell.filebase '_' name_generator(Param.Civ1.Grid,i1_grid,1,'.grid','_i')];
    12221225                        if ~exist(Param.Civ1.GridName,'file')
    12231226                            msgbox_uvmat('ERROR','grid file absent for civ1')
     
    12971300                            if ~isnan(nbslice_grid)
    12981301                                i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1;
    1299                                 patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')];
     1302                                patch1.gridPatch=[filecell.filebase '_' fullfile_uvmat('','',gridname,'.grid','_1',i1_grid)];
     1303%                                 patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')];
    13001304                                if ~exist(patch1.gridPatch,'file')
    13011305                                    msgbox_uvmat('ERROR','grid file absent for patch1')
     
    13461350                    nbslice_mask=str2double(Param.Civ2.Mask(1:end-4)); %
    13471351                    i1_mask=mod(i1_civ2(ifile)-1,nbslice_mask)+1;
    1348                     Param.Civ2.Mask=name_generator(maskbase,i1_mask,1,'.png','_i');
     1352                    [RootPathMask,RootFileMask]=fileparts(maskbase);
     1353                    Param.Civ2.Mask=fullfile_uvmat(RootPathMask,[],RootFileMask,'.png','_1',i1_mask);
     1354%                     Param.Civ2.Mask=name_generator(maskbase,i1_mask,1,'.png','_i');
    13491355                end
    13501356            end
     
    13551361                    if ~isnan(nbslice_grid)
    13561362                        i1_grid=mod(i1_civ2(ifile)-1,nbslice_grid)+1;
    1357                         Param.Civ2.Grid=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')];
     1363                        Param.Civ2.Grid=[filecell.filebase '_' fullfile_uvmat('','',gridname,'.grid','_1',i1_grid)];
     1364%                         Param.Civ2.Grid=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')];
    13581365                    end
    13591366                end
     
    14311438                            if ~isnan(nbslice_grid)
    14321439                                i1_grid=mod(i1_civ2(ifile)-1,nbslice_grid)+1;
    1433                                 patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')];
     1440                                patch2.gridPatch=[filecell.filebase '_' fullfile_uvmat('','',gridname,'.grid','_1',i1_grid)];
     1441%                                 patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')];
    14341442                                if ~exist(patch2.gridPatch,'file')
    14351443                                    msgbox_uvmat('ERROR','grid file absent for patch2')
     
    16541662                fprintf(fid,['sh ' batch_file_list{p} '\n']);
    16551663            else
    1656                 fprintf(fid,['@call "' regexprep(filename_bat,'\\','\\\\') '"' '\n']);
     1664                fprintf(fid,['@call "' regexprep(batch_file_list{p},'\\','\\\\') '"' '\n']);
    16571665            end
    16581666        end
     
    18091817    filebase_nc=filebase_B;
    18101818end
    1811     [RootPath_ima1,RootFile_ima1]=fileparts(filebase_ima1);
    1812     [RootPath_ima2,RootFile_ima2]=fileparts(filebase_ima2);
    1813     [RootPath_nc,RootFile_ima1]=fileparts(filebase_nc);
     1819[RootPath_ima1,RootFile_ima1]=fileparts(filebase_ima1);
     1820[RootPath_ima2,RootFile_ima2]=fileparts(filebase_ima2);
     1821[RootPath_nc,RootFile_nc]=fileparts(filebase_nc);
     1822[RootPath_A,RootFile_A]=fileparts(filebase_A);
     1823[RootPath_AB,RootFile_AB]=fileparts(filebase_AB);
    18141824   
    18151825%determine reference files for fix:
     
    19551965        for ifile=1:nbfield
    19561966            for j=1:nbslice
    1957                 [RootPath,RootFile]=fileparts(ref.filebase_nc);
    1958                 filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new);
     1967                [RootPath,RootFile]=fileparts(filebase_nc);
     1968                filename=fullfile_uvmat(RootPath_nc,subdir_civ1_new,RootFile_nc,'.nc',nom_type_nc,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j));
     1969               % filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new);
    19591970                detect=exist(filename,'file')==2;
    19601971                if detect% if a netcdf file already exists
     
    19992010            for ifile=1:nbfield
    20002011                for j=1:nbslice
    2001                     filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new);%
     2012                     filename=fullfile_uvmat(RootPath_A,subdir_civ1_new,RootFile_A,'.nc',nom_type_nc,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j));
     2013                   % filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new);%
    20022014                    detect=exist(filename,'file')==2;
    20032015                    if detect% if a netcdf file already exists
     
    20452057    for ifile=1:nbfield
    20462058        for j=1:nbslice
    2047             filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1);
     2059             filename=fullfile_uvmat(RootPath_ima1,'',RootFile_ima1,ext_ima,nom_type_ima1,num1_civ1(ifile),[],num_a_civ1(j));
     2060           % filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1);
    20482061            idetect(j)=exist(filename,'file')==2;
    20492062            filecell.ima1.civ1(ifile,j)={filename}; %first image
    2050             filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2);
     2063            filename=fullfile_uvmat(RootPath_ima2,'',RootFile_ima2,ext_ima,nom_type_ima2,num2_civ1(ifile),[],num_b_civ1(j));
     2064          %  filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2);
    20512065            idetect_1(j)=exist(filename,'file')==2;
    20522066            filecell.ima2.civ1(ifile,j)={filename};%second image
     
    20702084        for ifile=1:nbfield
    20712085            for j=1:nbslice
    2072                 filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1);
     2086                filename=fullfile_uvmat(RootPath_A,'',RootFile_A,ext_ima,nom_type_ima1,num1_civ1(ifile),[],num_a_civ1(j));
     2087               % filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1);
    20732088                idetect(j)=exist(filename,'file')==2;
    20742089                filecell.imaA1.civ1(ifile,j)={filename} ;%first image
    2075                 filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2);
     2090                filename=fullfile_uvmat(RootPath_A,'',RootFile_A,ext_ima,nom_type_ima2,num2_civ1(ifile),[],num_b_civ1(j));
     2091               % filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2);
    20762092                idetect_1(j)=exist(filename,'file')==2;
    20772093                filecell.imaA2.civ1(ifile,j)={filename};%second image
     
    20982114    for ifile=1:nbfield
    20992115        for j=1:nbslice
    2100             filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',...
    2101                 nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);%
     2116            filename=fullfile_uvmat(RootPath_nc,subdir_civ1,RootFile_nc,'.nc',nom_type_nc,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j));
     2117           % filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',...
     2118           %     nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);%
    21022119            detect=exist(filename,'file')==2;
    21032120            if detect==0
     
    21132130        for ifile=1:nbfield
    21142131            for j=1:nbslice
    2115                 filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);%
     2132                filename=fullfile_uvmat(RootPath_A,subdir_civ1,RootFile_A,'.nc',nom_type_nc,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j));
     2133              %  filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);%
    21162134                filecell.ncA.civ1(ifile,j)={filename};
    21172135                if ~exist(filename,'file')
     
    21392157        for ifile=1:nbfield
    21402158            for j=1:nbslice
    2141                 filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2_new);%
     2159                filename=fullfile_uvmat(RootPath_nc,subdir_civ2_new,RootFile_nc,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
     2160               % filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2_new);%
    21422161                detect=exist(filename,'file')==2;
    21432162                if detect% if a netcdf file already exists
     
    21722191            for ifile=1:nbfield
    21732192                for j=1:nbslice
    2174                     filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',...
    2175                         nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);%
     2193                    filename=fullfile_uvmat(RootPath_A,subdir_civ2_new,RootFile_A,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
     2194                %   filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',...
     2195                 %       nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);%
    21762196                    detect=exist(filename,'file')==2;
    21772197                    if detect% if a netcdf file already exists
     
    22892309        for ifile=1:nbfield
    22902310            for j=1:nbslice
    2291                 filename=fullfile_uvmat(RootPath_ima1,[],RootFile_ima1,ext_ima,nom_type_ima1,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
     2311                filename=fullfile_uvmat(RootPath_ima1,[],RootFile_ima1,ext_ima,nom_type_ima1,num1_civ2(ifile),[],num_a_civ2(j));
    22922312                %filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1);
    22932313                idetect_2(j)=exist(filename,'file')==2;
     
    23092329        for ifile=1:nbfield
    23102330            for j=1:nbslice
    2311                 filename=fullfile_uvmat(RootPath_ima2,[],RootFile_ima2,ext_ima,nom_type_ima2,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
     2331                filename=fullfile_uvmat(RootPath_ima2,[],RootFile_ima2,ext_ima,nom_type_ima2,num2_civ2(ifile),[],num_b_civ2(j));
    23122332               % filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2);
    23132333                idetect_3(j)=exist(filename,'file')==2;
     
    24502470            waitbar(ifile/nbfield);
    24512471            for j=1:nbslice
    2452                  filename=fullfile_uvmat(RootPath_ima1,[],RootFile_ima1,'.png',nom_type_imanew1,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j));
     2472                 filename=fullfile_uvmat(RootPath_ima1,[],RootFile_ima1,'.png',nom_type_imanew1,num1_civ1(ifile),[],num_a_civ1(j));
    24532473%                 filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1);
    24542474                if ~exist(filename,'file')
     
    24572477                end
    24582478                filecell.ima1.civ1(ifile,j)={filename};
    2459                 filename=fullfile_uvmat(RootPath_ima2,[],RootFile_ima2,'.png',nom_type_imanew2,num2_civ1(ifile),num2_civ1(ifile),num_b_civ1(j),num_b_civ1(j));
     2479                filename=fullfile_uvmat(RootPath_ima2,[],RootFile_ima2,'.png',nom_type_imanew2,num2_civ1(ifile),[],num_b_civ1(j));
    24602480                %filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2);
    24612481                if ~exist(filename,'file')
     
    24732493            waitbar(ifile/nbfield);
    24742494            for j=1:nbslice
    2475                 filename=fullfile_uvmat(RootPath_ima1,[],RootFile_ima1,'.png',nom_type_imanew1,num1_civ2(ifile),[],num_a_civ1(j));
     2495                filename=fullfile_uvmat(RootPath_ima1,[],RootFile_ima1,'.png',nom_type_imanew1,num1_civ2(ifile),[],num_a_civ2(j));
    24762496                %filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1);
    24772497                if ~exist(filename,'file')
     
    24802500                end
    24812501                filecell.ima1.civ2(ifile,j)={filename};
    2482                 filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2);
     2502                filename=fullfile_uvmat(RootPath_ima2,[],RootFile_ima2,'.png',nom_type_imanew2,num2_civ2(ifile),[],num_b_civ2(j));
     2503               % filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2);
    24832504                if ~exist(filename,'file')
    24842505                    A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile));
     
    30543075
    30553076%% case with no Civ1 operation, netcdf files need to exist for reading
     3077[RootPath,RootFile]=fileparts(filebase);
    30563078if ~get(handles.CheckCiv1,'Value') %
    30573079    if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir')
     
    30613083    end
    30623084    for ipair=1:nbpair
    3063         filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
    3064             ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
     3085        filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,...
     3086            ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair));
     3087      %  filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
     3088       %     ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
    30653089        select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist
    30663090    end   
     
    30723096            num_j1=ref_j-floor(browse.incr_pair(2)/2);
    30733097            num_j2=ref_j+ceil(browse.incr_pair(2)/2);
    3074             filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1);
     3098            filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2);
     3099            %filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1);
    30753100            select(1)=exist(filename,'file')==2;
    30763101            testpair=1;
     
    32513276displ_pair={''}; %default
    32523277select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs
     3278[RootPath,RootFile]=fileparts(filebase);
    32533279if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value')
    32543280    if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir')
     
    32593285    end
    32603286    for ipair=1:nbpair
    3261         filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
    3262             ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
     3287        filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,...
     3288            ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair));
     3289       % filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
     3290        %    ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
    32633291        select(ipair)=exist(filename,'file')==2;
    32643292    end
     
    32693297            num_j1=ref_j-floor(browse.incr_pair(2)/2);
    32703298            num_j2=ref_j+floor((browse.incr_pair(2)+1)/2);
    3271             filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2);
     3299            filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2);
     3300            %filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2);
    32723301            select(1)=exist(filename,'file')==2;
    32733302        else
    32743303            if  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
    3275                 errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2])
     3304                msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2])
    32763305            else
    3277                 errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2])
     3306                msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2])
    32783307            end
    32793308            set(handles.ListPairCiv2,'Value',1);
  • trunk/src/find_file_series.m

    r353 r354  
    7171                    NomType='*';
    7272                    FileType='multimage';
    73                     i1_series=1:length(imainfo);
     73                    i1_series=(1:length(imainfo))';
    7474                    [RootPath,RootFile]=fileparts(fileinput);
    7575                end
     
    8080                if ~isempty(Data.absolut_time_T0')
    8181                    FileType='civx'; % test for civx velocity fields
    82                 elseif strcmp(Data.Conventions','uvmat/civdata')
     82                elseif strcmp(Data.Conventions,'uvmat/civdata')
    8383                    FileType='civdata'; % test for civx velocity fields
    8484                else
     
    8787            end
    8888            try
    89                 Object=VideoReader(fileinput);
     89                if exist('VideoReader','file')%recent version of Matlab
     90                    Object=VideoReader(fileinput);   
     91                else
     92                    Object=mmreader(fileinput);%older Matlab function for movies               
     93                end
    9094                NomType='*';
    91                 FileType='video';
    92                 i1_series=[1:get(Object,'NumberOfFrames')];
    93                 [RootPath,RootFile]=fileparts(fileinput);
     95                FileType='video'; 
     96                i1_series=(1:get(Object,'NumberOfFrames'))';
    9497            end
    9598        end
  • trunk/src/fullfile_uvmat.m

    r353 r354  
    133133        if ~isempty(r)&& ~isempty(j2)
    134134            sep4='-';
    135             j2_str=num2str(j2,['%0' num2str(length(r.num4)) 'd'])
     135            j2_str=num2str(j2,['%0' num2str(length(r.num4)) 'd']);
    136136        end
    137137    end
  • trunk/src/read_field.m

    r334 r354  
    2929function [Field,ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num)
    3030Field=[];
    31 ParamOut=[];
     31if ~exist('num','var')
     32    num=1;
     33end
     34if ~exist('ParamIn','var')
     35    ParamIn=[];
     36end
     37ParamOut=ParamIn;%default
    3238errormsg='';
    3339if isfield(ParamIn,'VelType')
     
    3844switch FileType
    3945    case {'civx','civdata','netcdf'}  %read the first nc field
    40         ParamOut.FieldName=ParamIn.FieldName;
     46%         ParamOut.FieldName=ParamIn.FieldName;
    4147        GUIName='get_field'; %default name of the GUI get_field
    4248        if isfield(ParamIn,'GUIName')
     
    140146        end
    141147       
    142     case 'movie'
     148    case 'video'
    143149        try
    144150            A=read(ObjectName,num);
    145             FieldName='image';
    146151        catch ME
    147             errormsg=ME.message;
     152            errormsg=ME.message
    148153            return
    149154        end
    150     case 'avi'
    151         try
    152             mov=aviread(ObjectName,num);
    153         catch ME
    154             errormsg=ME.message;
    155             return
    156         end
    157         A=frame2im(mov(1));
    158         FieldName='image';
     155        FieldName='image';
     156%     case 'avi'
     157%         try
     158%             mov=aviread(ObjectName,num);
     159%         catch ME
     160%             errormsg=ME.message;
     161%             return
     162%         end
     163%         A=frame2im(mov(1));
     164%         FieldName='image';
    159165    case 'vol'
    160166        A=imread(ObjectName);
  • trunk/src/uvmat.m

    r353 r354  
    391391% search the files, recognize their type according to their name and fill the rootfile input windows
    392392function MenuBrowse_Callback(hObject, eventdata, handles)
    393 oldfile=read_file_boxes(handles);
    394 
     393[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     394oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     395% oldfile=read_file_box,es(handles);
    395396if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
    396397         dir_perso=prefdir;
     
    466467%------------------------------------------------------------------------
    467468% --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
    468 function display_file_name(hObject, eventdata, handles,fileinput)
     469function display_file_name(hObject, eventdata, handles,fileinput,index)
    469470%------------------------------------------------------------------------
    470471%% analyse the input file
     
    473474    return
    474475end
     476
     477%% have a unique function for fileinput (index=1) and fileinput_1 (index=2)
     478if ~exist('index','var')
     479    index=1;
     480end
     481if index==1
     482    handles_RootPath=handles.RootPath;
     483    handles_SubDir=handles.SubDir;
     484    handles_RootFile=handles.RootFile;
     485    handles_FileIndex=handles.FileIndex;
     486    handles_NomType=handles.NomType;
     487    handles_FileExt=handles.FileExt;
     488    handles_Fields=handles.Fields;
     489elseif index==2
     490    handles_RootPath=handles.RootPath_1;
     491    handles_SubDir=handles.SubDir_1;
     492    handles_RootFile=handles.RootFile_1;
     493    handles_FileIndex=handles.FileIndex_1;
     494    handles_NomType=handles.NomType_1;
     495    handles_FileExt=handles.FileExt_1;
     496    handles_Fields=handles.Fields_1;
     497    set(handles.RootPath_1,'Visible','on')
     498    set(handles.RootFile_1,'Visible','on')
     499    set(handles.SubDir_1,'Visible','on');
     500    set(handles.FileIndex_1,'Visible','on');
     501    set(handles.FileExt_1,'Visible','on');
     502    set(handles.NomType_1,'Visible','on');
     503end
    475504% detect root name, nomenclature and indices in the input file name:
    476 [ff,SubDir,ii,i1,i2,j1,j2,FileExt]=fileparts_uvmat(fileinput);
     505[tild,SubDir,tild,i1,i2,j1,j2,FileExt]=fileparts_uvmat(fileinput);
    477506% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    478 % [i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fileinput);
    479507[RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fileinput);
     508if strcmp(NomType,'*')% movies will be opened at the first frame
     509    i1=1;
     510    i2=[];
     511    j1=[];
     512    j2=[];
     513end 
    480514% open the file or fill the GUI uvmat according to the detected file type
    481515switch FileType
    482516    case ''
    483        msgbox_uvmat('ERROR','invalid input file type')
     517        msgbox_uvmat('ERROR','invalid input file type')
    484518    case 'txt'
    485         edit(fileinput) 
     519        edit(fileinput)
    486520    case 'figure'                           %display matlab figure
    487521        hfig=open(fileinput);
     
    490524        set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
    491525    case {'xml','xls'}                % edit xml or Excel files
    492        editxml(fileinput);
     526        editxml(fileinput);
    493527    otherwise
    494         set(handles.RootPath,'String',RootPath);
    495         if  isequal(SubDir,'')
    496             rootname=fullfile(RootPath,RootFile);
    497         else
    498             rootname=fullfile(RootPath,SubDir,RootFile);
    499             SubDir=['/' SubDir]; %display the separator
    500         end
    501         set(handles.SubDir,'String',SubDir);
    502         set(handles.RootFile,'String',['/' RootFile]); %display the separator
     528        set(handles_RootPath,'String',RootPath);
     529        rootname=fullfile(RootPath,SubDir,RootFile);
     530        set(handles_SubDir,'String',['/' SubDir]);
     531        set(handles_RootFile,'String',['/' RootFile]); %display the separator
    503532        indices=fileinput(length(rootname)+1:end);
    504533        indices(end-length(FileExt)+1:end)=[]; %remove extension
    505         set(handles.FileIndex,'String',indices);       
    506 %         set(handles.FileIndex,'UserData',NomType);
    507         set(handles.NomType,'String',NomType);
    508         set(handles.FileExt,'String',FileExt);
    509         % fill file index counters
    510         set(handles.i1,'String',num2str(i1));   
    511         set(handles.i2,'String',num2str(i2));
    512         set(handles.j1,'String',num2stra(j1,NomType));
    513         set(handles.j2,'String',num2stra(j2,NomType));
    514        
     534        set(handles_FileIndex,'String',indices);
     535        set(handles_NomType,'String',NomType);
     536        set(handles_FileExt,'String',FileExt);
     537        if index==1
     538            % fill file index counters
     539            set(handles.i1,'String',num2str(i1));
     540            set(handles.i2,'String',num2str(i2));
     541            set(handles.j1,'String',num2stra(j1,NomType));
     542            set(handles.j2,'String',num2stra(j2,NomType));
     543        else %read the current field index
     544            i1=str2num(get(handles.i1,'String'));
     545            i2=str2num(get(handles.i2,'String'));
     546            j1=stra2num(get(handles.j1,'String'));
     547            j2=stra2num(get(handles.j2,'String'));
     548        end
    515549        % synchronise indices of the second  input file if it exists
    516550        if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
     551            %             if index==1
    517552            Input=read_GUI(handles.InputFile);
    518             if ~isfield(Input,'RootPath_1')
     553            if ~isfield(Input,'RootPath_1')||strcmp(Input.RootPath_1,'"')
    519554                Input.RootPath_1=Input.RootPath;
    520555            end
    521             if ~isfield(Input,'SubDir_1')
     556            if ~isfield(Input,'SubDir_1')||strcmp(Input.SubDir_1,'"')
    522557                Input.SubDir_1=Input.SubDir;
    523558            end
    524             if ~isfield(Input,'RootFile_1')
    525                 Input.SubDir_1=Input.RootFile;
     559            if ~isfield(Input,'RootFile_1')||strcmp(Input.RootFile_1,'"')
     560                Input.RootFile_1=Input.RootFile;
    526561            end
    527 %             [ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
    528 %             NomType_1=get(handles.NomType_1,'String');
    529 %             NomType_1=get(handles.FileIndex_1,'UserData');     
    530            % FileName_1=name_generator(FileBase_1,i1,i2,FileExt_1,NomType_1,1,j1,j2,SubDir_1);
     562            %updtate the indices of the second field series to correspond to the newly opened one
    531563            FileName_1=fullfile_uvmat(Input.RootPath_1,Input.SubDir_1,Input.RootFile_1,Input.FileExt_1,Input.NomType_1,i1,i2,j1,j2);
    532564            if exist(FileName_1,'file')
    533                 FileIndex_1=name_generator('',i1,i2,'',NomType_1,1,j1,j2,'');
     565                FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1,i2,j1,j2);
     566                %FileIndex_1=name_generator('',i1,i2,'',NomType_1,1,j1,j2,'');
    534567                set(handles.FileIndex_1,'String',FileIndex_1)
    535568            else
     
    537570                SubField_Callback(hObject, eventdata, handles)
    538571            end
    539         end 
    540 
     572        end
     573       
    541574        %enable other menus
    542575        set(handles.MenuOpen_1,'Enable','on')
     
    555588        set(handles.frame_object,'Visible','on')
    556589       
    557          % initiate input file series and refresh the current field view:
    558         update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject); 
     590        % initiate input file series and refresh the current field view:
     591       
     592        update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,index);
     593
    559594end
    560595
     
    564599%------------------------------------------------------------------------
    565600% read the current input file name:
    566 fileinput=read_file_boxes(handles);
     601[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     602fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     603% fileinput=read_file_boxes(handles);
    567604% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    568605[RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fileinput);
     
    601638% --- Update information about a new field series (indices to scan, timing,
    602639%     calibration from an xml file, then refresh current plots
    603 function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject)
    604 %------------------------------------------------------------------------
    605 set(handles.RootPath,'BackgroundColor',[1 1 0])
     640function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,index)
     641%------------------------------------------------------------------------
     642%% TODO: have a unique function for update_rootinfo and update_rootinfo_1
     643if ~exist('index','var')
     644    index=1;
     645end
     646if index==1
     647    handles_RootPath=handles.RootPath;
     648    handles_Fields=handles.Fields;
     649elseif index==2
     650    handles_RootPath=handles.RootPath_1;
     651    handles_Fields=handles.Fields_1;
     652    %..........................
     653end
     654
     655set(handles_RootPath,'BackgroundColor',[1 1 0])
    606656drawnow
    607657set(handles.Fields,'UserData',[])% reinialize data from uvmat opening
     
    609659UvData.NewSeries=1; %flag for run0: begin a new series
    610660UvData.TestInputFile=1;
    611 UvData.FileType=FileType;
    612 UvData.i1_series=i1_series;
    613 UvData.i2_series=i2_series;
    614 UvData.j1_series=j1_series;
    615 UvData.j2_series=j2_series;
     661UvData.FileType{index}=FileType;
     662UvData.i1_series{index}=i1_series;
     663UvData.i2_series{index}=i2_series;
     664UvData.j1_series{index}=j1_series;
     665UvData.j2_series{index}=j2_series;
    616666set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window
    617667set(handles.FixVelType,'Value',0); %desactivate fixed veltype
    618 [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
    619 
     668%[FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
     669if index==1
     670[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     671else
     672    [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
     673end
     674FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     675FileBase=fullfile(RootPath,RootFile);
    620676if ~exist(FileName,'file')
    621677   msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
     
    635691if isequal(lower(FileExt),'.avi') %.avi file
    636692    testima=1;
    637     imainfo=aviinfo([FileBase FileIndices FileExt]);
     693    imainfo=aviinfo([FileName]);
    638694    nbfield=imainfo.NumFrames;
    639695    nbfield_j=1;
     
    658714end
    659715if ~strcmp(hhh,'')% if the function mmreader is found (recent version of matlab)
    660     UvData.MovieObject=mmreader([FileBase FileIndices FileExt]);
    661 elseif isfield(UvData,'MovieObject')
    662     UvData=rmfield(UvData,'MovieObject');
     716    UvData.MovieObject{index}=mmreader([FileBase FileIndices FileExt]);
     717else
     718    UvData.MovieObject{index}=[];
    663719end
    664720if isfield(imainfo,'Width') && isfield(imainfo,'Height')
     
    700756    drawnow
    701757    if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib)
    702         XmlData.GeometryCalib
    703758        if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y')
    704759            set (handles.nb_slice,'String','volume')
     
    829884UvData.XmlData=XmlData;
    830885UvData.NewSeries=1;
    831 UvData.MovieObject=MovieObject;
     886% UvData.MovieObject=MovieObject;
    832887
    833888%display warning message
     
    840895    testcivx=0;
    841896    if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field)
    842         set(handles.Fields,'Value',1)
    843         set(handles.Fields,'String',{'get_field...'})
     897        set(handles_Fields,'Value',1)
     898        set(handles_Fields,'String',{'get_field...'})
    844899        UvData=rmfield(UvData,'FieldsString');
    845900    else
     
    847902        if strcmp(Data.Conventions,'uvmat/civdata') ||( ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0))%if the new input is Civx
    848903            FieldList=calc_field;
    849             set(handles.Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
    850             set(handles.Fields,'Value',2) % set menu to 'velocity'
     904            set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
     905            set(handles_Fields,'Value',2) % set menu to 'velocity'
    851906            col_vec=FieldList;
    852907            col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar)
     
    854909        end
    855910        if ~testcivx
    856             set(handles.Fields,'Value',1) % set menu to 'get_field...
    857             set(handles.Fields,'String',{'get_field...'})
     911            set(handles_Fields,'Value',1) % set menu to 'get_field...
     912            set(handles_Fields,'String',{'get_field...'})
    858913            col_vec={'get_field...'};
    859914        end
     
    9811036
    9821037% refresh the current displayed field
    983 display_file_name_1(hObject,eventdata,handles,fileinput_1)
     1038set(handles.SubField,'Value',1)
     1039display_file_name(hObject,eventdata,handles,fileinput_1,2)
    9841040
    9851041%update list of recent files in the menubar
     
    10191075% -----------------------------------------------------------------------
    10201076fileinput_1=get(handles.MenuFile_1_1,'Label');
    1021 display_file_name_1(hObject,eventdata,handles,fileinput_1)
     1077set(handles.SubField,'Value',1)
     1078display_file_name(hObject,eventdata,handles,fileinput_1,2)
    10221079
    10231080% -----------------------------------------------------------------------
     
    10261083% -----------------------------------------------------------------------
    10271084fileinput_1=get(handles.MenuFile_2_1,'Label');
    1028 display_file_name_1(hObject,eventdata,handles,fileinput_1)
     1085set(handles.SubField,'Value',1)
     1086display_file_name(hObject,eventdata,handles,fileinput_1,2)
    10291087
    10301088% -----------------------------------------------------------------------
     
    10331091% -----------------------------------------------------------------------
    10341092fileinput_1=get(handles.MenuFile_3_1,'Label');
    1035 display_file_name_1(hObject,eventdata,handles,fileinput_1)
     1093set(handles.SubField,'Value',1)
     1094display_file_name(hObject,eventdata,handles,fileinput_1,2)
    10361095
    10371096% -----------------------------------------------------------------------
     
    10401099% -----------------------------------------------------------------------
    10411100fileinput_1=get(handles.MenuFile_4_1,'Label');
    1042 display_file_name_1(hObject,eventdata,handles,fileinput_1)
     1101set(handles.SubField,'Value',1)
     1102display_file_name(hObject,eventdata,handles,fileinput_1,2)
    10431103
    10441104% -----------------------------------------------------------------------
     
    10471107% -----------------------------------------------------------------------
    10481108fileinput_1=get(handles.MenuFile_5_1,'Label');
    1049 display_file_name_1(hObject,eventdata,handles,fileinput_1)
    1050 
    1051 %------------------------------------------------------------------------
    1052 % fills the edit boxes RootPath_1, RootFile_1,NomType_1...from an input file name 'fileinput_1'
    1053 %------------------------------------------------------------------------
    1054 function display_file_name_1(hObject,eventdata,handles,fileinput_1)
    1055 
    1056 %[path,name,ext]=fileparts(fileinput_1);
    1057 [tild,SubDir_1,tild,i1,i2,j1,j2,FileExt_1]=fileparts_uvmat(fileinput_1);
    1058 [RootPath_1,RootFile_1,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fileinput_1);
    1059 % [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
    1060 switch FileType
    1061     case ''
    1062        msgbox_uvmat('ERROR','invalid input file type')
    1063     case 'txt'
    1064         edit(fileinput) 
    1065     case 'figure'                           %display matlab figure
    1066         hfig=open(fileinput);
    1067         set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
    1068         set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
    1069         set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
    1070     case {'xml','xls'}                % edit xml or Excel files
    1071        editxml(fileinput);
    1072 %     case {'.avi','.image','.vol','.nc','.cdf'} 
    1073     otherwise
    1074         set(handles.RootPath,'String',RootPath);
    1075         if  isequal(SubDir,'')
    1076             rootname=fullfile(RootPath,RootFile);
    1077         else
    1078             rootname=fullfile(RootPath,SubDir,RootFile);
    1079             SubDir=['/' SubDir]; %display the separator
    1080         end
    1081         set(handles.SubDir,'String',SubDir);
    1082         set(handles.RootFile,'String',['/' RootFile]); %display the separator
    1083         indices=fileinput(length(rootname)+1:end);
    1084         indices(end-length(FileExt)+1:end)=[]; %remove extension
    1085         set(handles.FileIndex,'String',indices);       
    1086 %         set(handles.FileIndex,'UserData',NomType);
    1087         set(handles.NomType,'String',NomType);
    1088         set(handles.FileExt,'String',FileExt);
    1089         % fill file index counters
    1090         set(handles.i1,'String',num2str(i1));   
    1091         set(handles.i2,'String',num2str(i2));
    1092         set(handles.j1,'String',num2str(j1));
    1093         set(handles.j2,'String',num2str(j2));
    1094        
    1095         % synchronise indices of the second  input file if it exists
    1096         if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
    1097             [ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
    1098             NomType_1=get(handles.NomType_1,'String');
    1099 %             NomType_1=get(handles.FileIndex_1,'UserData');     
    1100             FileName_1=name_generator(FileBase_1,i1,i2,FileExt_1,NomType_1,1,j1,j2,SubDir_1);
    1101             if exist(FileName_1,'file')
    1102                 FileIndex_1=name_generator('',i1,i2,'',NomType_1,1,j1,j2,'');
    1103                 set(handles.FileIndex_1,'String',FileIndex_1)
    1104             else
    1105                 set(handles.SubField,'Value',0)
    1106                 SubField_Callback(hObject, eventdata, handles)
    1107             end
    1108         end 
    1109 end
     1109set(handles.SubField,'Value',1)
     1110display_file_name(hObject,eventdata,handles,fileinput_1,2)
     1111
     1112%------------------------------------------------------------------------
     1113% NOT USED  fills the edit boxes RootPath_1, RootFile_1,NomType_1...from an input file name 'fileinput_1'
     1114%------------------------------------------------------------------------
     1115% function display_file_name_1(hObject,eventdata,handles,fileinput_1)
    11101116%
    1111 %
    1112 % nbfield_1=1; %default
    1113 % ext_test=FileExt_1;%default
    1114 % form=imformats(FileExt_1(2:end));
    1115 % if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab
    1116 %     imainfo=imfinfo(fileinput_1); 
    1117 %     nbfield_1=length(imainfo);
    1118 %     ext_test='.image';
    1119 % elseif isequal(lower(FileExt_1),'.avi')
    1120 %     info=aviinfo(fileinput_1);
    1121 %     nbfield_1=info.NumFrames;
    1122 %     ext_test='.image';
    1123 % end
    1124 %
    1125 % %open directly fig or text files
    1126 % switch ext_test
    1127 %     case {'.civ','.log','.cmx','.cmx2','.txt'}  %display text file
     1117% %[path,name,ext]=fileparts(fileinput_1);
     1118% [tild,SubDir_1,tild,i1,i2,j1,j2,FileExt_1]=fileparts_uvmat(fileinput_1);
     1119% [RootPath_1,RootFile_1,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fileinput_1);
     1120% % [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
     1121% switch FileType
     1122%     case ''
     1123%        msgbox_uvmat('ERROR','invalid input file type')
     1124%     case 'txt'
    11281125%         edit(fileinput) 
    1129 %         return
    1130 %     case '.fig'                           %display matlab figure
    1131 %         hfig=open(fileinput);
     1126%     case 'figure'                           %display matlab figure
     1127%         hfig=open(fileinput_1);
    11321128%         set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
    11331129%         set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
    11341130%         set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
     1131%     case {'xml','xls'}                % edit xml or Excel files
     1132%        editxml(fileinput_1);
     1133% %     case {'.avi','.image','.vol','.nc','.cdf'} 
     1134%     otherwise
     1135%         set(handles.RootPath_1,'String',RootPath_1);
     1136%         if  isequal(SubDir_1,'')
     1137%             rootname=fullfile(RootPath_1,RootFile_1);
     1138%         else
     1139%             rootname=fullfile(RootPath_1,SubDir_1,RootFile_1);
     1140%             SubDir=['/' SubDir_1]; %display the separator
     1141%         end
     1142%         set(handles.SubDir_1,'String',SubDir_1);
     1143%         set(handles.RootFile_1,'String',['/' RootFile_1]); %display the separator
     1144%         indices=fileinput_1(length(rootname)+1:end);
     1145%         indices(end-length(FileExt_1)+1:end)=[]; %remove extension
     1146%         set(handles.FileIndex,'String',indices);       
     1147% %         set(handles.FileIndex,'UserData',NomType);
     1148%         set(handles.NomType_1,'String',NomType);
     1149%         set(handles.FileExt_1,'String',FileExt_1);
     1150%         % fill file index counters
     1151%         set(handles.i1,'String',num2str(i1));   
     1152%         set(handles.i2,'String',num2str(i2));
     1153%         set(handles.j1,'String',num2str(j1));
     1154%         set(handles.j2,'String',num2str(j2));
     1155%         
     1156%         % synchronise indices of the second  input file if it exists
     1157%         if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
     1158%             [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
     1159%             %[ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
     1160%             NomType_1=get(handles.NomType_1,'String');
     1161% %             NomType_1=get(handles.FileIndex_1,'UserData');     
     1162%             %FileName_1=name_generator(FileBase_1,i1,i2,FileExt_1,NomType_1,1,j1,j2,SubDir_1);
     1163%             FileName_1=fullfile_uvmat(RootPath_1,SubDir_1,RootFile_1,FileExt_1,NomType_1,i1,i2,j1,j2);
     1164%             if exist(FileName_1,'file')
     1165%                 FileIndex_1=fullfile_uvmat('','','','',NomType_1,i1,i2,j1,j2);
     1166%                 %FileIndex_1=name_generator('',i1,i2,'',NomType_1,1,j1,j2,'');
     1167%                 set(handles.FileIndex_1,'String',FileIndex_1)
     1168%             else
     1169%                 set(handles.SubField,'Value',0)
     1170%                 SubField_Callback(hObject, eventdata, handles)
     1171%             end
     1172%         end 
     1173% end
     1174%
     1175% % test for image series in a single file and synchronise file indices of the two series
     1176% if nbfield_1 >1 %case of image with multiple frames
     1177%     if nbfield_1 < num_i1
     1178%         msgbox_uvmat('ERROR','current frame index beyond the input movie length')
    11351179%         return
    1136 %     case {'.xml','.xls'}                % edit xml or Excel files
    1137 %        heditxml=editxml(fileinput);
    1138 %        return
    1139 %     case {'.image','.nc','.cdf'}       
    1140 % %         set(handles.FileIndex,'UserData',NomType_1);
    1141 %     otherwise
    1142 %         msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')
    1143 %         return
     1180%     else
     1181%         NomType_1='*'; %indicate a set of indexed frames within a single file
     1182%         filename_new=fileinput_1;
     1183%     end
     1184% else  % cases of data files   
     1185%     RootPath=get(handles.RootPath,'String');
     1186%     RootFile=get(handles.RootFile,'String');
     1187%     FileBase=fullfile(RootPath,RootFile);
     1188%     FileBase_1=fullfile(RootPath_1,RootFile_1);
     1189%     if isequal(FileBase,FileBase_1)
     1190%         filename_new=fileinput_1;
     1191%     else       
     1192%         num_i1=stra2num(get(handles.i1,'String'));%get the current file indices from counters
     1193%         num_j1=stra2num(get(handles.j1,'String'));
     1194%         num_i2=stra2num(get(handles.i2,'String'));
     1195%         num_j2=stra2num(get(handles.j2,'String'));
     1196%         [filename_new,idetect]=...
     1197%            name_generator(FileBase_1,num_i1,num_j1,FileExt_1,NomType_1,1,num_i2,num_j2,SubDir_1);%create name with indices synchronised with the first file
     1198%         indices=''; %default
     1199%         if ~idetect
     1200%             msgbox_uvmat('ERROR','second input file with indices corresponding to the first one does not exist')
     1201%             return
     1202%         end
     1203%     end
    11441204% end
    1145 
    1146 % test for image series in a single file and synchronise file indices of the two series
    1147 if nbfield_1 >1 %case of image with multiple frames
    1148     if nbfield_1 < num_i1
    1149         msgbox_uvmat('ERROR','current frame index beyond the input movie length')
    1150         return
    1151     else
    1152         NomType_1='*'; %indicate a set of indexed frames within a single file
    1153         filename_new=fileinput_1;
    1154     end
    1155 else  % cases of data files   
    1156     RootPath=get(handles.RootPath,'String');
    1157     RootFile=get(handles.RootFile,'String');
    1158     FileBase=fullfile(RootPath,RootFile);
    1159     FileBase_1=fullfile(RootPath_1,RootFile_1);
    1160     if isequal(FileBase,FileBase_1)
    1161         filename_new=fileinput_1;
    1162     else       
    1163         num_i1=stra2num(get(handles.i1,'String'));%get the current file indices from counters
    1164         num_j1=stra2num(get(handles.j1,'String'));
    1165         num_i2=stra2num(get(handles.i2,'String'));
    1166         num_j2=stra2num(get(handles.j2,'String'));
    1167         [filename_new,idetect]=...
    1168            name_generator(FileBase_1,num_i1,num_j1,FileExt_1,NomType_1,1,num_i2,num_j2,SubDir_1);%create name with indices synchronised with the first file
    1169         indices=''; %default
    1170         if ~idetect
    1171             msgbox_uvmat('ERROR','second input file with indices corresponding to the first one does not exist')
    1172             return
    1173         end
    1174     end
    1175 end
    1176 set(handles.NomType_1,'String',NomType_1);
    1177 % set(handles.FileIndex_1,'UserData',NomType_1);
    1178 
    1179 % make visible and fill the second raw of edit boxes
    1180 set(handles.RootPath_1,'Visible','on')
    1181 set(handles.RootFile_1,'Visible','on')
    1182 set(handles.SubDir_1,'Visible','on');
    1183 set(handles.FileIndex_1,'Visible','on');
    1184 set(handles.FileExt_1,'Visible','on');
    1185 [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
    1186 if isequal(FileBase,FileBase_1)
    1187     set(handles.RootPath_1,'String','"')
    1188     set(handles.RootFile_1,'String','"');
    1189 else
    1190     set(handles.RootPath_1,'String',RootPath_1)
    1191     set(handles.RootFile_1,'String',['/' RootFile_1]);
    1192 end
    1193 if  isequal(SubDir_1,'')
    1194      set(handles.SubDir_1,'String','');
    1195      FileBaseSub_1=FileBase_1;
    1196 else 
    1197     set(handles.SubDir_1,'String',['/' SubDir_1]);
    1198     FileBaseSub_1=fullfile(FileBase_1,SubDir_1);
    1199 end
    1200 indices=filename_new(length(FileBaseSub_1)+1:end);
    1201 indices(end-length(FileExt_1)+1:end)=[]; %remove extension
    1202 set(handles.FileIndex_1,'String',indices)
    1203 set(handles.NomType_1,'String',NomType_1)
    1204 % set(handles.FileIndex_1,'UserData',NomType_1)
    1205 set(handles.FileExt_1,'String',FileExt_1);
    1206 
    1207 % % default choice of fields
    1208 %set(handles.SubField,'Visible','on')
    1209 set(handles.SubField,'Value',1)
    1210 RootPath_1_Callback(hObject,eventdata,handles); 
     1205% set(handles.NomType_1,'String',NomType_1);
     1206% % set(handles.FileIndex_1,'UserData',NomType_1);
     1207%
     1208% % make visible and fill the second raw of edit boxes
     1209% set(handles.RootPath_1,'Visible','on')
     1210% set(handles.RootFile_1,'Visible','on')
     1211% set(handles.SubDir_1,'Visible','on');
     1212% set(handles.FileIndex_1,'Visible','on');
     1213% set(handles.FileExt_1,'Visible','on');
     1214% %[FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
     1215% [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     1216% FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     1217% FileBase=fullfile(RootPath,RootFile);
     1218% if isequal(FileBase,FileBase_1)
     1219%     set(handles.RootPath_1,'String','"')
     1220%     set(handles.RootFile_1,'String','"');
     1221% else
     1222%     set(handles.RootPath_1,'String',RootPath_1)
     1223%     set(handles.RootFile_1,'String',['/' RootFile_1]);
     1224% end
     1225% if  isequal(SubDir_1,'')
     1226%      set(handles.SubDir_1,'String','');
     1227%      FileBaseSub_1=FileBase_1;
     1228% else 
     1229%     set(handles.SubDir_1,'String',['/' SubDir_1]);
     1230%     FileBaseSub_1=fullfile(FileBase_1,SubDir_1);
     1231% end
     1232% indices=filename_new(length(FileBaseSub_1)+1:end);
     1233% indices(end-length(FileExt_1)+1:end)=[]; %remove extension
     1234% set(handles.FileIndex_1,'String',indices)
     1235% set(handles.NomType_1,'String',NomType_1)
     1236% % set(handles.FileIndex_1,'UserData',NomType_1)
     1237% set(handles.FileExt_1,'String',FileExt_1);
     1238%
     1239% % % default choice of fields
     1240% %set(handles.SubField,'Visible','on')
     1241% set(handles.SubField,'Value',1)
     1242% RootPath_1_Callback(hObject,eventdata,handles); 
    12111243
    12121244%-----------------------------------------------------------------------
     
    12281260run0_Callback(hObject, eventdata, handles)
    12291261
    1230 %------------------------------------------------------------------------
    1231 % --- Update information about a new second field series (indices to scan, timing,
    1232 %     calibration from an xml file, then refresh current plots
    1233 function update_rootinfo_1(hObject,eventdata,handles) %A REVOIR
    1234 % -----------------------------------------------------------------------
    1235 set(handles.RootPath_1,'BackgroundColor',[1 1 0])% indicate active program by yellow color
    1236 drawnow
    1237 UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
    1238 UvData.NewSeries=1; %flag for run0: begin a new series
    1239 
    1240 [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes_1(handles);
    1241 if ~exist(FileName,'file')
    1242     msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
    1243 end
    1244 set(handles.FixVelType,'Value',0); %desactivate fixed veltype
    1245 nbfield_1=[];%default
    1246 nbfield_j_1=[];%default
    1247 XmlData.Time=[];
    1248 XmlData.GeometryCalib=[];%default
    1249 TimeUnit=[];
    1250 if isfield(UvData,'TimeUnit')
    1251     TimeUnit=UvData.TimeUnit;
    1252 end
    1253 TimeUnit_1=[];
    1254 hhh='';%default, test for  movie reading with mmreader
    1255 imainfo=[];
    1256 if isequal(lower(FileExt),'.avi') %.avi file
    1257     imainfo=aviinfo([FileBase FileIndices FileExt]);
    1258     nbfield_1=imainfo.NumFrames;
    1259     nbfield_j_1=1;
    1260     set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
    1261     time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
    1262     ColorType=imainfo.ImageType;%='truecolor' for color images
    1263     hhh=which('mmreader');
    1264 elseif ~isempty(imformats(FileExt(2:end)))|| isequal(FileExt,'.vol')
    1265     if ~isequal(SubDir,'')
    1266         RootFile=get(handles.RootFile,'String');
    1267         imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
    1268     else
    1269         imainfo=imfinfo([FileBase FileIndices FileExt]);
    1270     end
    1271     ColorType=imainfo.ColorType;%='truecolor' for color images
    1272     if length(imainfo) >1 %case of image with multiple frames
    1273         nbfield_1=length(imainfo);
    1274         nbfield_j_1=1;
    1275     end
    1276 end
    1277 if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
    1278     UvData.MovieObject_1=mmreader([FileBase FileIndices FileExt]);
    1279 elseif isfield(UvData,'MovieObject_1')
    1280     UvData=rmfield(UvData,'MovieObject_1');
    1281 end
    1282 if ~isempty(imainfo)% (an image has been introduced as second fierld input)
    1283     if strcmp(get(handles.num_Npx,'String'),'') || strcmp(get(handles.num_Npy,'String'),'')%update npx and npy if it is not already filled by the first input field
    1284         if  isfield(imainfo,'Width') && isfield(imainfo,'Height')
    1285             set(handles.num_Npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
    1286             set(handles.num_Npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
    1287         else
    1288             set(handles.num_Npx,'String','');%fills nbre of pixels x box
    1289             set(handles.num_Npy,'String','');%fills nbre of pixels x box
    1290         end
    1291         set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image
    1292     end
    1293 end
    1294 % find scaling parameters
    1295 filexml=[FileBase '.xml'];
    1296 fileciv=[FileBase '.civ'];
    1297 warntext='';%default warning text
    1298 if exist(filexml,'file')
    1299     [XmlData,warntext]=imadoc2struct(filexml);
    1300     if ~isempty(warntext)
    1301         msgbox_uvmat('WARNING',warntext)
    1302     end
    1303     if isfield(XmlData,'Camera')
    1304         if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
    1305             TimeUnit=XmlData.Camera.TimeUnit;
    1306         end
    1307     end
    1308 elseif exist(fileciv,'file')% if .civ file found
    1309     [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
    1310     GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
    1311     GeometryCalib.Tx=0;
    1312     GeometryCalib.Ty=0;
    1313     GeometryCalib.Tz=1;
    1314     GeometryCalib.dpx=1;
    1315     GeometryCalib.dpy=1;
    1316     GeometryCalib.sx=1;
    1317     GeometryCalib.Cx=0;
    1318     GeometryCalib.Cy=0;
    1319     GeometryCalib.f=1;
    1320     GeometryCalib.kappa1=0;
    1321     GeometryCalib.CoordUnit='cm';
    1322     XmlData.GeometryCalib=GeometryCalib;
    1323     if error==2, warntext=['no file ' FileBase '.civ'];
    1324     elseif error==1, warntext='inconsistent number of fields in the .civ file';
    1325     end
    1326    
    1327     set(handles.num_Npx,'String',num2str(npx));%fills nbre of pixels x box
    1328     set(handles.num_Npy,'String',num2str(npy));%fills nbre of pixels y box
    1329     set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
    1330     set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
    1331     set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
    1332     set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
    1333 end   
    1334 if ~isempty(TimeUnit_1) && ~isequal(TimeUnit_1,TimeUnit)
    1335         msgbox_uvmat('WARNING','the time units for the second series differs from the first one')
    1336 end
    1337        
    1338 % store last index in handles.lat_i and .last_j
    1339 if ~isempty(XmlData.Time)
    1340     nbfield_1=size(XmlData.Time,1);
    1341     nbfield_j_1=size(XmlData.Time,2);   
    1342 end
    1343 last_i_cell=get(handles.last_i,'String');
    1344 if isempty(nbfield_1)
    1345     last_i_cell{2}='';
    1346 else
    1347     last_i_cell{2}=num2str(nbfield_1);
    1348 end
    1349 set(handles.last_i,'String',last_i_cell)
    1350 last_j_cell=get(handles.last_j,'String');
    1351 if isempty(nbfield_j_1)
    1352      last_j_cell{2}='';
    1353 else
    1354      last_j_cell{2}=num2str(nbfield_j_1);
    1355 end
    1356 set(handles.last_j,'String',last_j_cell);
    1357 if ~isequal(last_i_cell{1},last_i_cell{2}) || ~isequal(last_j_cell{1},last_j_cell{2})
    1358         msgbox_uvmat('WARNING','the numbers of input file of the second series differs from the first one')
    1359 end
    1360 
    1361 % store calibration data
    1362 GeometryCalib=XmlData.GeometryCalib;
    1363 if isempty(GeometryCalib)
    1364     if isfield(UvData, 'GeometryCalib_1')
    1365         UvData=rmfield(UvData,'GeometryCalib_1');
    1366     end
    1367 else
    1368     UvData.GeometryCalib_1=GeometryCalib;
    1369     if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
    1370         (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
    1371         set(handles.pxcm,'String','var')
    1372         set(handles.pycm,'String','var')
    1373     else
    1374         if isfield(GeometryCalib,'fx_fy')
    1375             pixcmx=GeometryCalib.fx_fy(1);
    1376             pixcmy=GeometryCalib.fx_fy(2);
    1377             set(handles.pxcm,'String',num2str(pixcmx))
    1378             set(handles.pycm,'String',num2str(pixcmy))
    1379         end
    1380     end
    1381 end
    1382 UvData.XmlData_1=XmlData;
    1383 set(handles.uvmat,'UserData',UvData)%update the data attached to the uvmat interface
    1384 
    1385 if ~isequal(warntext,'')
    1386     msgbox_uvmat('WARNING',warntext)
    1387 end
    1388 
    1389 set(handles.RootPath_1,'BackgroundColor',[1 1 1])% signa the end the input operation
    1390 drawnow
    1391 
    1392 set_scan_options(handles)
     1262% %------------------------------------------------------------------------
     1263% % --- Update information about a new second field series (indices to scan, timing,
     1264% %     calibration from an xml file, then refresh current plots
     1265% function update_rootinfo_1(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject) %A REVOIR
     1266% % -----------------------------------------------------------------------
     1267% set(handles.RootPath_1,'BackgroundColor',[1 1 0])% indicate active program by yellow color
     1268% drawnow
     1269% UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
     1270% UvData.NewSeries=1; %flag for run0: begin a new series
     1271% [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
     1272% FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     1273% %[FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes_1(handles);
     1274% if ~exist(FileName,'file')
     1275%     msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
     1276% end
     1277% set(handles.FixVelType,'Value',0); %desactivate fixed veltype
     1278% nbfield_1=[];%default
     1279% nbfield_j_1=[];%default
     1280% XmlData.Time=[];
     1281% XmlData.GeometryCalib=[];%default
     1282% TimeUnit=[];
     1283% if isfield(UvData,'TimeUnit')
     1284%     TimeUnit=UvData.TimeUnit;
     1285% end
     1286% TimeUnit_1=[];
     1287% hhh='';%default, test for  movie reading with mmreader
     1288% imainfo=[];
     1289% FileBase=fullfile(RootPath,RootFile);
     1290% if isequal(lower(FileExt),'.avi') %.avi file
     1291%     imainfo=aviinfo([FileBase FileIndices FileExt]);
     1292%     nbfield_1=imainfo.NumFrames;
     1293%     nbfield_j_1=1;
     1294%     set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
     1295%     time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
     1296%     ColorType=imainfo.ImageType;%='truecolor' for color images
     1297%     hhh=which('mmreader');
     1298% elseif ~isempty(imformats(FileExt(2:end)))|| isequal(FileExt,'.vol')
     1299%     if ~isequal(SubDir,'')
     1300%         RootFile=get(handles.RootFile,'String');
     1301%         imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
     1302%     else
     1303%         imainfo=imfinfo([FileBase FileIndices FileExt]);
     1304%     end
     1305%     ColorType=imainfo.ColorType;%='truecolor' for color images
     1306%     if length(imainfo) >1 %case of image with multiple frames
     1307%         nbfield_1=length(imainfo);
     1308%         nbfield_j_1=1;
     1309%     end
     1310% end
     1311% if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
     1312%     UvData.MovieObject_1=mmreader([FileBase FileIndices FileExt]);
     1313% elseif isfield(UvData,'MovieObject_1')
     1314%     UvData=rmfield(UvData,'MovieObject_1');
     1315% end
     1316% if ~isempty(imainfo)% (an image has been introduced as second fierld input)
     1317%     if strcmp(get(handles.num_Npx,'String'),'') || strcmp(get(handles.num_Npy,'String'),'')%update npx and npy if it is not already filled by the first input field
     1318%         if  isfield(imainfo,'Width') && isfield(imainfo,'Height')
     1319%             set(handles.num_Npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
     1320%             set(handles.num_Npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
     1321%         else
     1322%             set(handles.num_Npx,'String','');%fills nbre of pixels x box
     1323%             set(handles.num_Npy,'String','');%fills nbre of pixels x box
     1324%         end
     1325%         set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image
     1326%     end
     1327% end
     1328% % find scaling parameters
     1329% filexml=[FileBase '.xml'];
     1330% fileciv=[FileBase '.civ'];
     1331% warntext='';%default warning text
     1332% if exist(filexml,'file')
     1333%     [XmlData,warntext]=imadoc2struct(filexml);
     1334%     if ~isempty(warntext)
     1335%         msgbox_uvmat('WARNING',warntext)
     1336%     end
     1337%     if isfield(XmlData,'Camera')
     1338%         if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
     1339%             TimeUnit=XmlData.Camera.TimeUnit;
     1340%         end
     1341%     end
     1342% elseif exist(fileciv,'file')% if .civ file found
     1343%     [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
     1344%     GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
     1345%     GeometryCalib.Tx=0;
     1346%     GeometryCalib.Ty=0;
     1347%     GeometryCalib.Tz=1;
     1348%     GeometryCalib.dpx=1;
     1349%     GeometryCalib.dpy=1;
     1350%     GeometryCalib.sx=1;
     1351%     GeometryCalib.Cx=0;
     1352%     GeometryCalib.Cy=0;
     1353%     GeometryCalib.f=1;
     1354%     GeometryCalib.kappa1=0;
     1355%     GeometryCalib.CoordUnit='cm';
     1356%     XmlData.GeometryCalib=GeometryCalib;
     1357%     if error==2, warntext=['no file ' FileBase '.civ'];
     1358%     elseif error==1, warntext='inconsistent number of fields in the .civ file';
     1359%     end
     1360%     
     1361%     set(handles.num_Npx,'String',num2str(npx));%fills nbre of pixels x box
     1362%     set(handles.num_Npy,'String',num2str(npy));%fills nbre of pixels y box
     1363%     set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
     1364%     set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
     1365%     set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
     1366%     set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
     1367% end   
     1368% if ~isempty(TimeUnit_1) && ~isequal(TimeUnit_1,TimeUnit)
     1369%         msgbox_uvmat('WARNING','the time units for the second series differs from the first one')
     1370% end
     1371%         
     1372% % store last index in handles.lat_i and .last_j
     1373% if ~isempty(XmlData.Time)
     1374%     nbfield_1=size(XmlData.Time,1);
     1375%     nbfield_j_1=size(XmlData.Time,2);   
     1376% end
     1377% last_i_cell=get(handles.last_i,'String');
     1378% if isempty(nbfield_1)
     1379%     last_i_cell{2}='';
     1380% else
     1381%     last_i_cell{2}=num2str(nbfield_1);
     1382% end
     1383% set(handles.last_i,'String',last_i_cell)
     1384% last_j_cell=get(handles.last_j,'String');
     1385% if isempty(nbfield_j_1)
     1386%      last_j_cell{2}='';
     1387% else
     1388%      last_j_cell{2}=num2str(nbfield_j_1);
     1389% end
     1390% set(handles.last_j,'String',last_j_cell);
     1391% if ~isequal(last_i_cell{1},last_i_cell{2}) || ~isequal(last_j_cell{1},last_j_cell{2})
     1392%         msgbox_uvmat('WARNING','the numbers of input file of the second series differs from the first one')
     1393% end
     1394%
     1395% % store calibration data
     1396% GeometryCalib=XmlData.GeometryCalib;
     1397% if isempty(GeometryCalib)
     1398%     if isfield(UvData, 'GeometryCalib_1')
     1399%         UvData=rmfield(UvData,'GeometryCalib_1');
     1400%     end
     1401% else
     1402%     UvData.GeometryCalib_1=GeometryCalib;
     1403%     if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
     1404%         (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
     1405%         set(handles.pxcm,'String','var')
     1406%         set(handles.pycm,'String','var')
     1407%     else
     1408%         if isfield(GeometryCalib,'fx_fy')
     1409%             pixcmx=GeometryCalib.fx_fy(1);
     1410%             pixcmy=GeometryCalib.fx_fy(2);
     1411%             set(handles.pxcm,'String',num2str(pixcmx))
     1412%             set(handles.pycm,'String',num2str(pixcmy))
     1413%         end
     1414%     end
     1415% end
     1416% UvData.XmlData_1=XmlData;
     1417% set(handles.uvmat,'UserData',UvData)%update the data attached to the uvmat interface
     1418%
     1419% if ~isequal(warntext,'')
     1420%     msgbox_uvmat('WARNING',warntext)
     1421% end
     1422%
     1423% set(handles.RootPath_1,'BackgroundColor',[1 1 1])% signa the end the input operation
     1424% drawnow
     1425%
     1426% set_scan_options(handles)
    13931427
    13941428%------------------------------------------------------------------------
     
    14351469set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])
    14361470NomType=get(handles.NomType,'String');
    1437 % NomType=get(handles.FileIndex,'UserData');
    1438 num1=stra2num(get(handles.i1,'String'));
    1439 num2=stra2num(get(handles.i2,'String'));
    1440 num_a=stra2num(get(handles.j1,'String'));
    1441 num_b=stra2num(get(handles.j2,'String'));
    1442 indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
     1471i1=stra2num(get(handles.i1,'String'));
     1472i2=stra2num(get(handles.i2,'String'));
     1473j1=stra2num(get(handles.j1,'String'));
     1474j2=stra2num(get(handles.j2,'String'));
     1475indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
     1476%indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
    14431477set(handles.FileIndex,'String',indices)
    14441478set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])
    14451479if get(handles.SubField,'Value')==1
    14461480    NomType_1=get(handles.NomType_1,'String');
    1447 %      FileExt_1=get(handles.FileExt_1,'String');
    1448 %     [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);
    1449      indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
     1481    indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
     1482     %indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
    14501483     set(handles.FileIndex_1,'String',indices)
    14511484     set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])
     
    15121545function view_xml_Callback(hObject, eventdata, handles)
    15131546%------------------------------------------------------------------------
    1514 [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
     1547%[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
     1548 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     1549FileBase=fullfile(RootPath,RootFile);
    15151550option=get(handles.view_xml,'String');
    15161551if isequal(option,'view .xml')
     
    15251560%case of view mask selection
    15261561if isequal(get(handles.CheckMask,'Value'),1)
    1527     [FF,RootPath,FileBase]=read_file_boxes(handles);
     1562   % [FF,RootPath,FileBase]=read_file_boxes(handles);
     1563     [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     1564     FileBase=fullfile(RootPath,RootFile);
    15281565    num_i1=stra2num(get(handles.i1,'String'));
    15291566    num_j1=stra2num(get(handles.j1,'String'));
     
    15621599            num_i1=mod(num_i1-1,nbslice)+1;
    15631600            Mask.NomType=regexprep(Mask_NomType{1},'0','');%remove '0' in nom type for masks
    1564             maskname=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
     1601            [RootPath,RootFile]=fileparts(Mask.Base);
     1602            maskname=fullfile_uvmat(RootPath,'',RootFile,'.png',Mask.NomType,num_i1,[],num_j1);
     1603            %maskname=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
    15651604            mdetect=exist(maskname,'file');
    15661605            if mdetect
     
    16241663end
    16251664num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
    1626 MaskName=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
     1665[RootPath,RootFile]=fileparts(MaskData.Base);
     1666MaskName=fullfile_uvmat(RootPath,'',RootFile,'.png',MaskData.NomType,num_i1_mask,[],num_j1);
     1667%MaskName=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
    16271668huvmat=get(handles.CheckMask,'parent');
    16281669UvData=get(huvmat,'UserData');
     
    18401881InputFile.RootFile=regexprep(InputFile.RootFile,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string
    18411882InputFile.SubDir=regexprep(InputFile.SubDir,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string
    1842 if isempty(InputFile.RootFile)
    1843     filebase=InputFile.RootPath;
    1844 else
    1845     filebase=fullfile(InputFile.RootPath,InputFile.RootFile);
    1846 end
     1883% if isempty(InputFile.RootFile)
     1884%     filebase=InputFile.RootPath;
     1885% else
     1886 filebase=fullfile(InputFile.RootPath,InputFile.RootFile);
     1887% end
    18471888FileExt=InputFile.FileExt;
    18481889% [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
     
    18551896sub_value= get(handles.SubField,'Value');
    18561897if sub_value % a second input file has been entered
     1898   
    18571899    [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
    18581900    [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndices_1);
     
    18731915    i1=i1+increment;
    18741916    i2=i2+increment;
     1917    if sub_value
     1918        i1_1=i1_1+increment;
     1919        i2_1=i2_1+increment;
     1920    end
    18751921else % case of scanning along index j (burst numbers)
    18761922    j1=j1+increment;
    18771923    j2=j2+increment;
     1924    if sub_value
     1925        j1_1=j1_1+increment;
     1926        j2_1=j2_1+increment;
     1927    end
    18781928end
    18791929if ~comp_input
     
    18901940        end
    18911941    end
    1892     if ref_i+1>size(UvData.i1_series,1)
     1942    if ref_i+1>size(UvData.i1_series{1},1)
    18931943        msgbox_uvmat('ERROR','maximum i index exceeded');
    18941944        return
    18951945    end
    1896     if ref_j+1>size(UvData.i1_series,2)
     1946    if ref_j+1>size(UvData.i1_series{1},2)
    18971947        msgbox_uvmat('ERROR','maximum j index exceeded');
    18981948        return
    18991949    end
    1900     i1=UvData.i1_series(ref_i+1,ref_j+1,1);
    1901     if ~isempty(UvData.i2_series)
    1902         i2=UvData.i2_series(ref_i+1,ref_j+1,1);
    1903     end
    1904     if ~isempty(UvData.j1_series)
    1905         j1=UvData.j1_series(ref_i+1,ref_j+1,1);
    1906     end
    1907     if ~isempty(UvData.j2_series)
    1908         j2=UvData.j2_series(ref_i+1,ref_j+1,1);
     1950    i1=UvData.i1_series{1}(ref_i+1,ref_j+1,1);
     1951    if ~isempty(UvData.i2_series{1})
     1952        i2=UvData.i2_series{1}(ref_i+1,ref_j+1,1);
     1953    end
     1954    if ~isempty(UvData.j1_series{1})
     1955        j1=UvData.j1_series{1}(ref_i+1,ref_j+1,1);
     1956    end
     1957    if ~isempty(UvData.j2_series{1})
     1958        j2=UvData.j2_series{1}(ref_i+1,ref_j+1,1);
    19091959    end
    19101960end
    19111961filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2);
    1912 % filename=name_generator(filebase,i1,j1,FileExt,NomType,comp_input,i2,j2,InputFile.SubDir);
    19131962if sub_value
    1914     j1_1=j1_1+increment;
    1915     j2_1=j2_1+increment;
    1916     filename_1=name_generator(filebase_1,i1_1,j1_1,FileExt_1,NomType_1,1,i2_1,j2_1,SubDir_1);
     1963    filename_1=fullfile_uvmat(InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,FileExt_1,NomType_1,i1_1,i2_1,j1_1,j2_1);
    19171964end
    19181965
     
    19381985    set(handles.FileIndex,'String',indices);
    19391986    if ~isempty(filename_1)
    1940         indices_1=name_generator('',i1_1,j1_1,'',NomType_1,1,i2_1,j2_1,'');
     1987        indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,j2_1);
     1988        %indices_1=name_generator('',i1_1,j1_1,'',NomType_1,1,i2_1,j2_1,'');
    19411989        set(handles.FileIndex_1,'String',indices_1);
    19421990    end
     
    19511999function movie_pair_Callback(hObject, eventdata, handles)
    19522000%------------------------------------------------------------------------
    1953 
    19542001%% stop movie action if the movie_pair button is off
    19552002if ~get(handles.movie_pair,'value')
     
    19712018if isequal(FieldName,'image')
    19722019    test_1=0;
    1973     [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
     2020    [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles);
    19742021    NomType=get(handles.NomType,'String');
    19752022else
     
    19792026    if isequal(FieldName,'image')
    19802027        test_1=1;
    1981         [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes_1(handles);
    1982         NomType=get(handles.NomType_1,'String');
    1983 %         NomType=get(handles.FileIndex_1,'UserData');
     2028        [RootPath,tild,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles);
    19842029    else
    19852030        msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
    19862031        set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
     2032        set(handles.movie_pair,'Value',0)
    19872033        return
    19882034    end
    19892035end
    1990 
    1991 num_i1=str2double(get(handles.i1,'String'));
     2036num_i1=str2num(get(handles.i1,'String'));
    19922037num_j1=stra2num(get(handles.j1,'String'));
    1993 num_i2=str2double(get(handles.i2,'String'));
     2038num_i2=str2num(get(handles.i2,'String'));
    19942039num_j2=stra2num(get(handles.j2,'String'));
    1995 if isnan(num_j2)
     2040if isempty(num_j2)
    19962041    if isempty(num_i2)   
    19972042        msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
    19982043        set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
     2044         set(handles.movie_pair,'Value',0)
    19992045        return
    20002046    else
     
    20022048    end
    20032049end
    2004 if isnan(num_i2)
     2050if isempty(num_i2)
    20052051    num_i2=num_i1;%repeat the index i1 by default
    20062052end
    2007 imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
     2053% imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
     2054imaname_1=fullfile_uvmat(RootPath,'',RootFile,Ext,NomType,num_i2,[],num_j2);
    20082055if ~exist(imaname_1,'file')
    20092056      msgbox_uvmat('ERROR',['second input open (-)  ' imaname_1 ' not found']);
    20102057      set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
     2058       set(handles.movie_pair,'Value',0)
    20112059      return
    20122060end
     
    20292077
    20302078%% determine the input file type
    2031 if (test_1 && isfield(UvData,'MovieObject_1'))||(~test_1 && ~isempty(UvData.MovieObject))
     2079if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1}))
    20322080    FileType='movie';
    20332081elseif isequal(lower(Ext),'.avi')
     
    20482096        case 'movie'
    20492097            if test_1
    2050                 Field_b.A=read(UvData.MovieObject_1,num_i2);
     2098                Field_b.A=read(UvData.MovieObject{2},num_i2);
    20512099            else
    2052                 Field_b.A=read(UvData.MovieObject,num_i2);
     2100                Field_b.A=read(UvData.MovieObject{1},num_i2);
    20532101            end
    20542102        case 'avi'
     
    20942142end
    20952143set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
     2144 set(handles.movie_pair,'Value',0)
    20962145
    20972146%------------------------------------------------------------------------
     
    21012150set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
    21022151drawnow
    2103 filename=read_file_boxes(handles);
    2104 
     2152%filename=read_file_boxes(handles);
     2153[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     2154filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    21052155filename_1=[];%default
    21062156if get(handles.SubField,'Value')
    2107     filename_1=read_file_boxes_1(handles);
     2157    [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
     2158    filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
     2159   % filename_1=read_file_boxes_1(handles);
    21082160end
    21092161num_i1=stra2num(get(handles.i1,'String'));
     
    21802232    FieldName=[];%default
    21812233    VelType=[];%default
    2182     Ext=get(handles.FileExt,'String');
    2183     FileType=UvData.FileType;
     2234    FileExt=get(handles.FileExt,'String');
     2235    FileType=UvData.FileType{1};
    21842236    switch FileType
    21852237        %     if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf')
     
    22042256            end
    22052257        case 'video'
    2206             ObjectName=UvData.MovieObject;
    2207            
     2258            ObjectName=UvData.MovieObject{1};         
    22082259        case 'vol' %TODO: update
    22092260            if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')
     
    22432294        errormsg=['second file ' filename_1 ' does not exist'];
    22442295        return
    2245     else
    2246         Name=filename_1;
    2247         FieldName_1=[];%default
    2248         VelType_1=[];%default
    2249         if strcmp(get(handles.FileExt_1,'Visible'),'on')
    2250             Ext_1=get(handles.FileExt_1,'String');
    2251         else
    2252             Ext_1=get(handles.FileExt,'String');%read the file extension for the first series (case of veltype comparison within a single file)
    2253         end
    2254         NomType_1=get(handles.NomType_1,'String');
    2255 %         NomType_1=get(handles.FileIndex_1,'UserData');
    2256         if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
    2257             FileType_1='netcdf';
    2258         elseif isfield(UvData,'MovieObject_1')
    2259             Name=UvData.MovieObject_1;
    2260             FileType_1='movie';
    2261         elseif isequal(lower(Ext_1),'.avi')
    2262             FileType_1='avi';
    2263         elseif isequal(lower(Ext_1),'.vol')
    2264             FileType_1='vol';
    2265             if isfield(UvData.XmlData_1,'Npy') && isfield(UvData.XmlData_1,'Npx')
    2266                 ParamIn.Npy=UvData.XmlData_1.Npy;
    2267                 ParamIn.Npx=UvData.XmlData_1.Npx;
    2268             else
    2269                 errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
    2270                 return
    2271             end
    2272         else
    2273            if length(Ext_1)>=2
    2274            form=imformats(Ext_1(2:end));
    2275            if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    2276                if isequal(NomType_1,'*');
    2277                    FileType_1='multimage';
    2278                else
    2279                    FileType_1='image';
    2280                end
    2281            end
    2282            end
    2283         end
    2284         if strcmp(FileType_1,'netcdf')
     2296    end
     2297    Name=filename_1;
     2298    FileType_1=UvData.FileType{2};
     2299    switch FileType_1
     2300        %     if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf')
     2301        case {'civx','civdata','netcdf'};
    22852302            list_fields=get(handles.Fields_1,'String');% list menu fields
    22862303            index_fields=get(handles.Fields_1,'Value');% selected string index
    22872304            FieldName_1= list_fields{index_fields}; % selected field
    2288             if ~isequal(FieldName_1,'get_field...')% read the field names on the interface get_field...
    2289                 VelType_1='';
    2290                 if get(handles.FixVelType,'Value')
    2291                     VelTypeList=get(handles.VelType_1,'String');
    2292                     index=get(handles.VelType_1,'Value');
    2293                     VelType_1=VelTypeList{index};
    2294                 end
    2295             end
    2296             if strcmp(VelType_1,'*')% free veltype choice
    2297                 VelType_1=[];
    2298             elseif strcmp(VelType_1,'"')% veltype the same as for the first field
    2299                 if isempty(VelType)
    2300                     VelType_1=[];
    2301                 else
    2302                     VelType_1=VelType;
     2305            if ~strcmp(FieldName,'get_field...')
     2306                TestVelType=get(handles.FixVelType,'Value');
     2307                if TestVelType
     2308                    VelType_1=setfield(handles);% read the velocity type.
    23032309                end
    23042310            end
     
    23122318                end
    23132319            end
    2314         end
    2315         test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
    2316         if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
    2317             if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
    2318                 test_keepdata_1= strcmp(filename_1,UvData.filename_1) && strcmp(VelType_1,UvData.VelType_1) && strcmp(FieldName_1,UvData.FieldName_1);
    2319             end
    2320         end
    2321         if test_keepdata_1
    2322             Field{2}=UvData.Field_1;
    2323         else
    2324             ParamIn.FieldName=FieldName_1;
    2325             ParamIn.VelType=VelType_1;
    2326             ParamIn.GUIName='get_field_1';
    2327             [Field{2},ParamOut_1,errormsg] = read_field(Name,FileType_1,ParamIn,num_i1);
    2328             if ~isempty(errormsg)
    2329                 errormsg=['error in reading ' FieldName_1 ' in ' filename_1 ': ' errormsg];
     2320        case 'video'
     2321            Name=UvData.MovieObject{2};
     2322        case 'vol' %TODO: update
     2323            if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')
     2324                ParamIn.Npy=UvData.XmlData.Npy;
     2325                ParamIn.Npx=UvData.XmlData.Npx;
     2326            else
     2327                errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
    23302328                return
    23312329            end
    2332             UvData.Field_1=Field{2}; %store the second field for possible use at next RUN
    2333         end
    2334     end
     2330    end
     2331%     if strcmp(get(handles.FileExt_1,'Visible'),'on')
     2332%         FileExt_1=get(handles.FileExt_1,'String');
     2333%     else
     2334%         FileExt_1=get(handles.FileExt,'String');%read the file extension for the first series (case of veltype comparison within a single file)
     2335%     end
     2336    NomType_1=get(handles.NomType_1,'String');
     2337%     %         NomType_1=get(handles.FileIndex_1,'UserData');
     2338%     if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
     2339%         FileType_1='netcdf';
     2340%     elseif isfield(UvData,'MovieObject_1')
     2341%         Name=UvData.MovieObject_1;
     2342%         FileType_1='movie';
     2343%     elseif isequal(lower(Ext_1),'.avi')
     2344%         FileType_1='avi';
     2345%     elseif isequal(lower(Ext_1),'.vol')
     2346%         FileType_1='vol';
     2347%         if isfield(UvData.XmlData_1,'Npy') && isfield(UvData.XmlData_1,'Npx')
     2348%             ParamIn.Npy=UvData.XmlData_1.Npy;
     2349%             ParamIn.Npx=UvData.XmlData_1.Npx;
     2350%         else
     2351%             errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
     2352%             return
     2353%         end
     2354%     else
     2355%         if length(Ext_1)>=2
     2356%             form=imformats(Ext_1(2:end));
     2357%             if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
     2358%                 if isequal(NomType_1,'*');
     2359%                     FileType_1='multimage';
     2360%                 else
     2361%                     FileType_1='image';
     2362%                 end
     2363%             end
     2364%         end
     2365%     end
     2366%     if strcmp(FileType_1,'netcdf')
     2367%         list_fields=get(handles.Fields_1,'String');% list menu fields
     2368%         index_fields=get(handles.Fields_1,'Value');% selected string index
     2369%         FieldName_1= list_fields{index_fields}; % selected field
     2370%         if ~isequal(FieldName_1,'get_field...')% read the field names on the interface get_field...
     2371%             VelType_1='';
     2372%             if get(handles.FixVelType,'Value')
     2373%                 VelTypeList=get(handles.VelType_1,'String');
     2374%                 index=get(handles.VelType_1,'Value');
     2375%                 VelType_1=VelTypeList{index};
     2376%             end
     2377%         end
     2378%         if strcmp(VelType_1,'*')% free veltype choice
     2379%             VelType_1=[];
     2380%         elseif strcmp(VelType_1,'"')% veltype the same as for the first field
     2381%             if isempty(VelType)
     2382%                 VelType_1=[];
     2383%             else
     2384%                 VelType_1=VelType;
     2385%             end
     2386%         end
     2387%         if strcmp(FieldName_1,'velocity')
     2388%             list_code=get(handles.ListColorCode,'String');% list menu fields
     2389%             index_code=get(handles.ListColorCode,'Value');% selected string index
     2390%             if  ~strcmp(list_code{index_code},'black') &&  ~strcmp(list_code{index_code},'white')
     2391%                 list_code=get(handles.ListColorScalar,'String');% list menu fields
     2392%                 index_code=get(handles.ListColorScalar,'Value');% selected string index
     2393%                 ParamIn.ColorVar= list_code{index_code}; % selected field
     2394%             end
     2395%         end
     2396%     end
     2397    test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
     2398    if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
     2399        if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
     2400            test_keepdata_1= strcmp(filename_1,UvData.filename_1) && strcmp(VelType_1,UvData.VelType_1) && strcmp(FieldName_1,UvData.FieldName_1);
     2401        end
     2402    end
     2403    if test_keepdata_1
     2404        Field{2}=UvData.Field_1;
     2405    else
     2406        ParamIn.FieldName=FieldName_1;
     2407        ParamIn.VelType=VelType_1;
     2408        ParamIn.GUIName='get_field_1';
     2409        [Field{2},ParamOut_1,errormsg] = read_field(Name,FileType_1,ParamIn,num_i1);
     2410        if ~isempty(errormsg)
     2411            errormsg=['error in reading ' FieldName_1 ' in ' filename_1 ': ' errormsg];
     2412            return
     2413        end
     2414        UvData.Field_1=Field{2}; %store the second field for possible use at next RUN
     2415    end
     2416    %     end
    23352417end
    23362418
     
    23462428%% update the display menu for the first velocity type (first menuline)
    23472429test_veltype=0;
    2348 if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...')
    2349     set(handles.VelType,'Visible','off')
    2350 else
     2430% if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...')
     2431if (strcmp(FileType,'civx')||strcmp(FileType,'civdata'))&& ~strcmp(FieldName,'get_field...')
    23512432    test_veltype=1;
    23522433    set(handles.VelType,'Visible','on')
     
    23612442     set(handles.VelType_1,'String',[{''};menu])
    23622443    end
     2444else
     2445    set(handles.VelType,'Visible','off')
    23632446end
    23642447field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList);
     
    24022485        set(handles.RootFile_1,'String','"')
    24032486        set(handles.SubDir_1,'String','"');
    2404         [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
     2487         indices=fullfile_uvmat('','','','',NomType,num_i1,num_i2,num_j1,num_j2);
     2488        %[indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
    24052489        set(handles.FileIndex_1,'String',indices)
    24062490        set(handles.FileExt_1,'String','"');
     
    24582542
    24592543%% calculate scalar
    2460 if isequal(FileType,'netcdf') && ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
     2544if strcmp(FileType(1:3),'civ') && ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
    24612545    Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1});
    24622546end
    2463 if numel(Field)==2 && ~test_keepdata_1 && isequal(FileType_1,'netcdf') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)
     2547if numel(Field)==2 && ~test_keepdata_1 && isequal(FileType_1(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)
    24642548    Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2});
    24652549end
     
    26592743%PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
    26602744PlotParam{1}=read_GUI(handles.uvmat);
    2661 PlotParam{1}.Coordinates
    26622745if ~isfield(PlotParam{1},'Vectors')
    26632746    PlotParam{1}.Vectors.MaxVec=1;
     
    29593042function record_Callback(hObject, eventdata, handles)
    29603043% [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
    2961 filename=read_file_boxes(handles);
     3044[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     3045filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     3046%filename=read_file_boxes(handles);
    29623047[erread,message]=fileattrib(filename);
    29633048if ~isempty(message) && ~isequal(message.UserWrite,1)
     
    31053190    set(handles.RootFile_1,'Visible','off')
    31063191    set(handles.SubDir_1,'Visible','off');
     3192    set(handles.NomType_1,'Visible','off');
     3193    set(handles.abs_time_1,'Visible','off')
    31073194    set(handles.FileIndex_1,'Visible','off');
    31083195    set(handles.FileExt_1,'Visible','off');
     
    31263213% --- read the data displayed for the input rootfile windows (new): TODO use read_GUI
    31273214
    3128 function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
     3215function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles)
    31293216%------------------------------------------------------------------------
    31303217InputFile=read_GUI(handles.InputFile);
    31313218RootPath=InputFile.RootPath;
    3132 FileName=InputFile.RootPath; %default
    3133 if ~isempty(InputFile.SubDir)
    3134     InputFile.SubDir=regexprep(InputFile.SubDir,'/|\','');
    3135     FileName=fullfile(InputFile.RootPath,InputFile.SubDir);
    3136 end
    3137 if ~isempty(InputFile.RootFile)
    3138     InputFile.RootFile=regexprep(InputFile.RootFile,'/|\','');
    3139     FileName=fullfile(FileName,InputFile.RootFile);
    3140 end
    3141 SubDir=InputFile.SubDir;
    3142 % if ~isempty(SubDir) && ~isequal(SubDir,'')
    3143 %     if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
    3144 %         SubDir(1)=[]; %suppress possible / or \ separator
    3145 %     end
    3146 %     FileName=fullfile(RootPath,SubDir);
    3147 % end
    3148 % RootFile=get(handles.RootFile,'String');
    3149 % if ~isempty(RootFile) && ~isequal(RootFile,'')
    3150 %     if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
    3151 %         RootFile(1)=[]; %suppress possible / or \ separator
    3152 %     end
    3153 %     FileName=fullfile(FileName,RootFile);
    3154 % end
    3155 FileBase=fullfile(InputFile.RootPath,InputFile.RootFile);
     3219SubDir=regexprep(InputFile.SubDir,'/|\','');
     3220RootFile=regexprep(InputFile.RootFile,'/|\','');
    31563221FileIndices=InputFile.FileIndex;
    31573222FileExt=InputFile.FileExt;
    3158 FileName=[FileName InputFile.FileIndex InputFile.FileExt];
     3223
    31593224
    31603225%------------------------------------------------------------------------
    31613226% ---- read the data displayed for the second input rootfile windows
    3162 function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
     3227function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles)
    31633228%------------------------------------------------------------------------
    31643229RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
     
    31663231    RootPath_1=get(handles.RootPath,'String');
    31673232end;
    3168 FileName_1=RootPath_1; %default
    31693233SubDir_1=get(handles.SubDir_1,'String');
    31703234if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"')
    31713235    SubDir_1=get(handles.SubDir,'String');
    31723236end
     3237SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string
    31733238RootFile_1=get(handles.RootFile_1,'String');
    3174 SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string
    3175 FileName_1=fullfile(RootPath_1,SubDir_1);
    31763239if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"')
    31773240    RootFile_1=get(handles.RootFile,'String');
    31783241end
    31793242RootFile_1=regexprep(RootFile_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string
    3180 if numel(RootFile_1)>=1
    3181     FileName_1=fullfile(FileName_1,RootFile_1);
    3182 end
    3183 FileBase_1=fullfile(RootPath_1,RootFile_1);
    3184 if isequal(get(handles.FileIndex_1,'Visible'),'off')
    3185     FileIndices_1=get(handles.FileIndex,'String');
    3186 else
    3187     FileIndices_1=get(handles.FileIndex_1,'String');
     3243FileIndex_1=get(handles.FileIndex_1,'String');
     3244if isequal(get(handles.FileIndex_1,'Visible'),'off')|| isequal(FileIndex_1,'"')
     3245    FileIndex_1=get(handles.FileIndex,'String');
    31883246end
    31893247FileExt_1=get(handles.FileExt_1,'String');
     
    31913249    FileExt_1=get(handles.FileExt,'String');%read FileExt by default
    31923250end
    3193 FileName_1=[FileName_1 FileIndices_1 FileExt_1];
    3194 
     3251NomType_1=get(handles.NomType_1,'String');
     3252if isequal(get(handles.NomType_1,'Visible'),'off') || isequal(NomType_1,'"')
     3253    NomType_1=get(handles.NomType,'String');%read FileExt by default
     3254end
    31953255%------------------------------------------------------------------------
    31963256% --- Executes on menu selection Fields
     
    32043264    set(handles.VelType,'visible','off')
    32053265    set(handles.VelType_1,'visible','off')
    3206     filename=read_file_boxes(handles);
     3266    [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     3267    filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     3268    %filename=read_file_boxes(handles);
    32073269    hget_field=findobj(allchild(0),'name','get_field');
    32083270    if ~isempty(hget_field)
     
    32243286
    32253287%read the rootfile input display
    3226 [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
     3288[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     3289FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     3290% [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
    32273291[tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]);
    32283292% [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
     
    32363300        NomTypeNew='_1';
    32373301    end
    3238     imagename=name_generator(FileBase,i1,j1,'.png',NomTypeNew,1,i2,j2,'');
     3302    imagename=fullfile_uvmat(RootPath,SubDir,RootFile,'.png',NomTypeNew,i1,i2,j1,j2);
     3303%     imagename=name_generator(FileBase,i1,j1,'.png',NomTypeNew,1,i2,j2,'');
    32393304    if ~exist(imagename,'file')
    32403305        [FileName,PathName] = uigetfile( ...
     
    32673332end
    32683333% indices=name_generator('',i1,j1,'',NomTypeNew,1,i2,j2,'');
    3269 indices=fullfile_uvmat('','','',FileExt,NomTypeNew,i1,i2,j1,j2);
     3334indices=fullfile_uvmat('','','','',NomTypeNew,i1,i2,j1,j2);
    32703335set(handles.FileIndex,'String',indices)
    32713336set(handles.NomType,'String',NomTypeNew)
     
    32923357function Fields_1_Callback(hObject, eventdata, handles)
    32933358%-------------------------------------------------
     3359%% read input data
     3360check_new=~get(handles.SubField,'Value'); %check_new=1 if a second field was not previously entered
     3361UvData=get(handles.uvmat,'UserData');
     3362if check_new && isfield(UvData,'XmlData')
     3363    UvData.XmlData_1=UvData.XmlData;
     3364end
    32943365list_fields=get(handles.Fields,'String');% list menu fields
    32953366index_fields=get(handles.Fields,'Value');% selected string index
     
    32983369index_fields=get(handles.Fields_1,'Value');% selected string index
    32993370field_1= list_fields{index_fields(1)}; % selected string for the second field
    3300 if isequal(field_1,'') %remove second field if 'blank' field is selected
     3371if isequal(field_1,'')||(numel(UvData.FileType)>=2 && strcmp(UvData.FileType{2},'image'))
    33013372    set(handles.SubField,'Value',0)
     3373    check_new=1;
    33023374    SubField_Callback(hObject, eventdata, handles)
    3303     return
    3304 end
    3305 UvData=get(handles.uvmat,'UserData');
    3306 
    3307 %read the rootfile input display
    3308 [FileName,RootPath,FileBase,FileIndices,FileExt_1]=read_file_boxes_1(handles);
    3309 [tild,tild,tild,i1,i2,j1,j2,tild,NomType_1]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt_1]);
    3310 % [P,F,str1,str2,str_a,str_b,E,NomType_1]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_1]);
    3311 if isempty(NomType_1)|| strcmp(NomType_1,'')
    3312     [FileName,RootPath,FileBase,FileIndices,FileExt_1]=read_file_boxes(handles);
    3313     [tild,tild,tild,i1,i2,j1,j2,tild,NomType_1]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt_1]);
    3314  %   [P,F,str1,str2,str_a,str_b,E,NomType_1]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_1]);
    3315 end
    3316 NomTypeNew=NomType_1;%default
    3317 
    3318 set(handles.SubField,'Value',1)%introduce second field
    3319 if isfield(UvData,'XmlData')
    3320     UvData.XmlData_1=UvData.XmlData;
    3321 end
     3375    if isempty(field_1)%remove second field if 'blank' field is selected
     3376        return
     3377    end
     3378end
     3379set(handles.SubField,'Value',1)%state that a second field is now entered
     3380
     3381%% read the rootfile input display
     3382[RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomTYpe_1]=read_file_boxes_1(handles);
     3383filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
     3384[tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));
    33223385set(handles.FileIndex_1,'Visible','on')
    33233386set(handles.FileExt_1,'Visible','on')
    3324 RootPath_1=get(handles.RootPath_1,'String');
    3325 RootFile_1=get(handles.RootFile_1,'String');
    3326 if isempty(RootPath_1)||isequal(RootPath_1,'')
    3327     set(handles.RootPath_1,'String','"')
    3328 end
    3329 if isempty(RootFile_1) || isequal(RootFile_1,'')
    3330     set(handles.RootFile_1,'String','"')
    3331 end
    3332 if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
    3333     RootFile_1(1)=[];
    3334 end
    3335 
    3336 if isequal(field_1,'get_field...')
    3337      veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
    3338      set_veltype_display(veltype_handles,0) % unvisible civ buttons
    3339      filename=read_file_boxes_1(handles);
    3340      hget_field=findobj(allchild(0),'name','get_field_1');
    3341      if ~isempty(hget_field)
    3342          delete(hget_field)
    3343      end
    3344      hget_field=get_field(filename);
    3345      set(hget_field,'name','get_field_1')
    3346      hhget_field=guidata(hget_field);
    3347      set(hhget_field.list_fig,'Value',1)
    3348      set(hhget_field.list_fig,'String',{'uvmat'})
    3349      set(handles.transform_fct,'Value',1)% no transform by default
    3350      set(handles.path_transform,'String','')
    3351     return %no action
    3352 end
    3353 if isequal(field_1,'image')
    3354     % transform netc type to the corresponding image type
    3355     if isequal(NomType_1,'_1-2_1')||isequal(NomType_1,'_1_1-2')|| isequal(NomType_1,'#_ab')|| isequal(NomType_1,'_1-2')
    3356         UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the InputFile.SubDir in memory   
    3357         if isequal(NomType_1,'_1-2_1')||isequal(NomType_1,'_1_1-2')
    3358             NomTypeNew='_1_1';
    3359         elseif isequal(NomType_1,'#_ab')
    3360             NomTypeNew='#a';
    3361         elseif isequal(NomType_1,'_1-2')
    3362             NomTypeNew='_1';
    3363         end 
    3364     end
    3365 %     imagename=name_generator(FileBase,i1,j1,'.png',NomTypeNew,1,i2,j2,'');
    3366     imagename=fullfile_uvmat(RootPath,SubDir,FileName,'.png',NomTypeNew,i1,i2,j1,j2);
    3367     if ~exist(imagename,'file')
    3368         [FileName,PathName] = uigetfile( ...
    3369             {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
    3370             '*.jpg',' jpeg image files'; ...
    3371             '*.png','.png image files'; ...
    3372             '*.tif','.tif image files'; ...
    3373             '*.avi;*.AVI','.avi movie files'; ...
    3374             '*.vol','.volume images (png)'; ...
    3375             '*.*',  'All Files (*.*)'}, ...
    3376             'Pick an image',imagename);
    3377         % display the selected field and related information
    3378         imagename=[PathName FileName];
    3379     end
    3380     display_file_name_1(hObject, eventdata, handles,imagename)%display the image
    3381     return
    3382 else
    3383     set(handles.SubDir_1,'Visible','on')
    3384     if ~isequal(FileExt_1,'.nc') %find the new NomType if the previous display was not already a netcdf file
    3385         RootPath_1=get(handles.RootPath_1,'String');
    3386         RootFile_1=get(handles.RootFile_1,'String');
    3387         if isempty(RootPath_1)||isequal(RootPath_1,'')
    3388             set(handles.RootPath_1,'String','"')
    3389         end
    3390         if isempty(RootFile_1) || isequal(RootFile_1,'')
    3391             set(handles.RootFile_1,'String','"')
    3392         end
    3393         if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
    3394             RootFile_1(1)=[];
    3395         end
    3396         filebase_1=fullfile(RootPath_1,RootFile_1);
    3397         SubDir_1=get(handles.SubDir,'String');
    3398         if isempty(SubDir_1)||isequal(SubDir_1,'')
    3399             if isfield(UvData,'SubDir_1')
    3400                 SubDir_1=UvData.SubDir_1;%retrieve previous subdir
    3401             else
    3402                 SubDir_1='?';
     3387switch field_1
     3388    case 'get_field...'
     3389        %veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
     3390        set_veltype_display(0) % no veltype display
     3391        %      [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
     3392        %      filename=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
     3393        hget_field=findobj(allchild(0),'name','get_field_1');
     3394        if ~isempty(hget_field)
     3395            delete(hget_field)
     3396        end
     3397        hget_field=get_field(filename_1);
     3398        set(hget_field,'name','get_field_1')
     3399        hhget_field=guidata(hget_field);
     3400        set(hhget_field.list_fig,'Value',1)
     3401        set(hhget_field.list_fig,'String',{'uvmat'})
     3402        set(handles.transform_fct,'Value',1)% no transform by default
     3403        set(handles.path_transform,'String','')
     3404    case 'image'
     3405        % transform netc type to the corresponding image type
     3406        NomType=get(handles.NomType,'string');
     3407        check_letter=~isempty(regexp(NomType,'[ab|AB]$'));%detect pair label by letter
     3408        NomType_1=NomType;
     3409        if check_letter
     3410            NomType_1=NomType_1(1:end-1);
     3411        else
     3412            r=regexp(NomType_1,'.-(?<num2>\d+$','names');
     3413            if ~isempty(r)
     3414                NomType_1=regexprep(NomType_1,['-' r.num2],'');
    34033415            end
    34043416        end
    3405         str1=get(handles.i1,'String');
    3406         str_a=get(handles.j1,'String');
    3407         if isequal(NomType_1,'#_ab')||isequal(NomType_1,'_1-2_1')||isequal(NomType_1,'_1_1-2')||isequal(NomType_1,'_1-2')
    3408             NomTypeNew=NomType_1;
    3409         elseif isequal(NomType_1,'#a')
    3410              [filename, n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),stra2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
    3411              NomTypeNew='#_ab';
    3412         elseif isequal(NomType_1,'_1_1')
    3413              [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_1-2_1',0,str2num(str1),[],SubDir_1);
    3414             if idetect==1
    3415                 NomTypeNew='_1-2_1';
    3416             else
    3417                 NomTypeNew='_1_1-2';
    3418             end
    3419         else %for instance avi files or any ima_num series
    3420             [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_1-2',0,str2num(str1),[],SubDir_1);
    3421             NomTypeNew='_1-2';
    3422         end           
    3423         [Path,Name]=fileparts(filebase_1);
    3424         set(handles.FileExt_1,'String','.nc');
    3425         if ~isempty(SubDir_1) && ~strcmp(SubDir_1,'''')&& ~strcmp(SubDir_1,'"')&& ~strcmp(SubDir_1(1),'/')
    3426             SubDir_1=['/' SubDir_1];
    3427         end
    3428         set(handles.SubDir_1,'String',SubDir_1);
    3429     end
    3430     if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
    3431         set(handles.VelType_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
    3432         set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
    3433         set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
    3434         set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
    3435     elseif isequal(field_1,'more...'); %add new item to the menu
    3436         set(handles.VelType_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
    3437         set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
    3438         str=calc_field;%get the list of available scalars by the function calc_scal
    3439         [ind_answer,v] = listdlg('PromptString','Select a file:',...
    3440                 'SelectionMode','single',...
    3441                 'ListString',str);
    3442        % edit the choice in the field and action menu
    3443         scalar=cell2mat(str(ind_answer));
    3444         menu=update_menu(handles.Fields_1,scalar);
    3445         set(handles.Fields_1,'String',menu);% store the selected scalar type
    3446     end
    3447 end
    3448 str1=get(handles.i1,'String');
    3449 str2=get(handles.i2,'String');
    3450 str_a=get(handles.j1,'String');
    3451 str_b=get(handles.j2,'String');
    3452 indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
    3453 set(handles.FileIndex_1,'String',indices)
    3454 set(handles.NomType_1,'String',NomTypeNew)
    3455 % set(handles.FileIndex_1,'UserData',NomTypeNew)
    3456 
    3457 %common to Fields_Callback
    3458 if isequal(field,'image')||isequal(field_1,'image')
    3459     set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons
    3460     set(handles.TitleNpy,'Visible','on')
    3461     set(handles.num_Npx,'Visible','on')
    3462     set(handles.num_Npy,'Visible','on')
    3463 %     set(handles.fix_pair,'Value',0)
    3464 else
    3465     set(handles.TitleNpx,'Visible','off')% visible npx,pxcm... buttons
    3466     set(handles.TitleNpy,'Visible','off')
    3467     set(handles.num_Npx,'Visible','off')
    3468     set(handles.num_Npy,'Visible','off')
    3469 %     set(handles.fix_pair,'Value',1)
    3470 end
    3471 if isequal(field,'velocity')||isequal(field_1,'velocity');
    3472     state_vect='on';
    3473 else
    3474     state_vect='off';
    3475 end
    3476 if ~isequal(field,'velocity')||(~isequal(field_1,'velocity')&~isequal(field_1,''));
    3477     state_scal='on';
    3478 else
    3479     state_scal='off';
    3480 end
    3481 set(handles.uvmat,'UserData',UvData)
    3482 setfield(handles);% update the field structure ('civ1'....)
    3483 if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
    3484     run0_Callback(hObject, eventdata, handles)
    3485 end
     3417        imagename=fullfile_uvmat(RootPath_1,'',RootFile_1,'.png',NomType_1,i1,[],j1);
     3418        if ~exist(imagename,'file')
     3419            [FileName,PathName] = uigetfile( ...
     3420                {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
     3421                '*.jpg',' jpeg image files'; ...
     3422                '*.png','.png image files'; ...
     3423                '*.tif','.tif image files'; ...
     3424                '*.avi;*.AVI','.avi movie files'; ...
     3425                '*.vol','.volume images (png)'; ...
     3426                '*.*',  'All Files (*.*)'}, ...
     3427                'Pick an image',imagename);
     3428            % display the selected field and related information
     3429            imagename=[PathName FileName];
     3430        end
     3431        set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons
     3432        set(handles.TitleNpy,'Visible','on')
     3433        set(handles.num_Npx,'Visible','on')
     3434        set(handles.num_Npy,'Visible','on')
     3435        display_file_name(hObject, eventdata, handles,imagename,2)%display the imag
     3436    otherwise
     3437        if check_new
     3438            UvData.FileType{2}=UvData.FileType{1};
     3439            set(handles.FileIndex_1,'String',get(handles.FileIndex,'String'))
     3440            set(handles.FileExt_1,'String',get(handles.FileExt,'String'))
     3441        end
     3442        if ~isequal(field,'image')
     3443            set(handles.TitleNpx,'Visible','off')% visible npx,pxcm... buttons
     3444            set(handles.TitleNpy,'Visible','off')
     3445            set(handles.num_Npx,'Visible','off')
     3446            set(handles.num_Npy,'Visible','off')
     3447        end
     3448        set(handles.uvmat,'UserData',UvData)
     3449        setfield(handles);% update the field structure ('civ1'....)
     3450        if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
     3451            run0_Callback(hObject, eventdata, handles)
     3452        end
     3453end
     3454
    34863455
    34873456%------------------------------------------------------------------------
     
    35023471menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'};
    35033472menu=menu(1:imax);
    3504 % for ibutton=1:imax;
    3505 %     set(handles(ibutton),'Visible','on')  % unvisible civ buttons
    3506 % end
    3507 % % for ibutton=max(imax+1,2):6;
    3508 % for ibutton=imax+1:6;
    3509 %     set(handles(ibutton),'Visible','off')  % unvisible civ buttons
    3510 %     set(handles(ibutton),'Value',0)%unactivate unvisible buttons
    3511 % end
    35123473
    35133474%------------------------------------------------------------------------
     
    35283489drawnow   
    35293490InputFile=read_GUI(handles.InputFile);
    3530 filename=read_file_boxes(handles);
     3491[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     3492filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     3493%filename=read_file_boxes(handles);
    35313494
    35323495index=get(handles.VelType_1,'Value');
     
    35363499        SubField_Callback(hObject, eventdata, handles)
    35373500elseif get(handles.SubField,'Value')% if subfield is already 'on'
    3538     filename_1=read_file_boxes_1(handles); %read the current second field
     3501      [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
     3502     filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
     3503    %filename_1=read_file_boxes_1(handles); %read the current second field
    35393504else
    35403505     filename_1=filename;% we compare two fields in the same file
     
    37223687masknumber=num2str(length(list));
    37233688maskindex=get(handles.masklevel,'Value');
    3724 mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
     3689mask_name=fullfile_uvmat(RootPath,SubDir,[RootFile '_' masknumber 'mask'],'.png','_1',maskindex);
     3690%mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
    37253691imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
    37263692imflag=flipdim(imflag,1);
     
    44964462huvmat=get(handles.run0,'parent');
    44974463UvData=get(huvmat,'UserData');
    4498 [xx,xx,FileBase]=read_file_boxes(handles);
     4464%[xx,xx,FileBase]=read_file_boxes(handles);
     4465[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     4466FileBase=fullfile(RootPath,RootFile);
    44994467 %read the current input file name
    45004468prompt = {'movie file name';'frames per second';'frame resolution (*[512x384] pixels)';'axis position relative to the frame';'total frame number (starting from the current uvmat display)'};
     
    45944562pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
    45954563pos(2)=pos(2)-0.02;
    4596 [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
     4564%[FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
     4565[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     4566FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    45974567set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib
    45984568if isfield(UvData.OpenParam,'CalOrigin')
     
    46874657    masknumber=num2str(length(list));
    46884658    maskindex=get(handles.masklevel,'Value');
    4689     mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
     4659    mask_name=fullfile_uvmat(RootPath,SubDir,[RootFile '_' masknumber 'mask'],'.png','_1',maskindex);
     4660    %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
    46904661    imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
    46914662    imflag=flipdim(imflag,1);
     
    47224693
    47234694%prepare display of the set_grid GUI
    4724 FileName=read_file_boxes(handles);
     4695[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     4696FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     4697%FileName=read_file_boxes(handles);
    47254698CoordList=get(handles.transform_fct,'String');
    47264699val=get(handles.transform_fct,'Value');
     
    47324705%------------------------------------------------------------------------
    47334706series; %first display of the GUI to fill waiting time
    4734 [param.FileName]=read_file_boxes(handles);
     4707[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     4708param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     4709%[param.FileName]=read_file_boxes(handles);
    47354710if isequal(get(handles.SubField,'Value'),1)
    4736     FileName_1=read_file_boxes_1(handles);%
     4711    [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
     4712    FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
     4713    %FileName_1=read_file_boxes_1(handles);%
    47374714    if ~isequal(FileName_1,param.FileName)
    47384715        param.FileName_1=FileName_1;
     
    47744751function MenuPIV_Callback(hObject, eventdata, handles)
    47754752%------------------------------------------------------------------------
    4776  FileName=read_file_boxes(handles);
     4753 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     4754 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     4755%FileName=read_file_boxes(handles);
    47774756%[FileName,RootPath,filebase,FileIndices,ext,SubDir]=read_file_boxes(handles)
    47784757% num1=stra2num(get(handles.i1,'String'));
Note: See TracChangeset for help on using the changeset viewer.