Changeset 334 for trunk/src


Ignore:
Timestamp:
Dec 14, 2011, 1:33:18 PM (12 years ago)
Author:
sommeria
Message:

bugs corrected in fileparts_uvmat and find_file_series
name2dispaly replaced by fileparts_uvmat in uvmat, but not in other functions
bug corrected in plot_field, introduction of FileType? in read_field

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/fileparts_uvmat.m

    r333 r334  
    44%
    55%OUTPUT:
     6%RootPath: path to the base file
     7%SubDir: name of the SubDirectory for netcdf files (NomTypes with index pairs 1-2 or ab )
    68%RootFile: FileName without appendix
    79%i1: first number i
     
    911%j1: first number j
    1012%j2: second number j (only for .nc files)
    11 %Ext: file Extension
     13%FileExt: file Extension
    1214%NomType: char chain characterizing the file nomenclature: with values
    13 %   NomType='': constant name [filebase Ext] (default output if 'NomType' is undefined)
     15%   NomType='': constant name [filebase FileExt] (default output if 'NomType' is undefined)
    1416%   NomType='*':constant name for a file representing a series (e.g. avi movie)
    1517%   NomType='1','01',or '001'...': series of files with a single index i without separator(e.g. 'aa045.png').
     
    1719%   NomType='1_1','01_1',...: matrix of files with two indices i and j separated by '_'(e.g. 'aa45_2.png')
    1820%   NomType='1-1': from pairs from a single index (e.g. 'aa_45-47.nc')
    19 %   NomType='1_1-1': pairs of j indices (e.g. 'aa_45_2-3.nc')
    20 %   NomType='1-1_1': pairs of i indices (e.g. 'aa_45-46_2.nc')
    21 %   NomType='1_ab','01_ab','01_a-b'..., from pairs of '#' images (e.g.'aa045bc.nc'), Ext='.nc'
     21%   NomType='1_1-2': pairs of j indices (e.g. 'aa_45_2-3.nc')
     22%   NomType='1-2_1': pairs of i indices (e.g. 'aa_45-46_2.nc')
     23%   NomType='1_ab','01_ab','01ab'..., from pairs of '#' images (e.g.'aa045bc.nc'), FileExt='.nc'
    2224%SubDir: name of the SubDirectory for netcdf files
    23 
    24 %   OLD TYPES, not supported anymore
    25 %   NomType='_1','_01','_001'...':  series of files with a single index i with separator '_'(e.g. 'aa_045.png').
    26 %   NomType='_1a','_1A','_01a','_01A',...: idem, with a separator '_' before the index
    27 %   NomType='_1_1','_01_1',...: matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
    28 %   NomType='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc')
    29 %   NomType='_i_j1-j2': pairs of j indices (e.g. 'aa_45_2-3.nc')
    30 %   NomType='_i1-i2_j': pairs of i indices (e.g. 'aa_45-46_2.nc')
    31 %   NomType='_1_ab','1_ab','01_ab'..., from pairs of '#' images (e.g.'aa045bc.nc'), Ext='.nc'
    32 
    3325%
    3426%INPUT:
    3527%FileInput: complete name of the file, including path
    3628
    37 function [RootPath,SubDir,RootFile,i1,i2,j1,j2,Ext,NomType]=fileparts_uvmat(FileInput)
    38 
     29function [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(FileInput)
     30RootPath='';
     31SubDir='';
     32RootFile='';
    3933i1=[];
    4034i2=[];
    4135j1=[];
    4236j2=[];
     37FileExt='';
    4338NomType='';
    44 SubDir='';
    45 RootFile='';
    46 
     39
     40
     41
     42%% display help and test function in the absence of input arument
    4743if ~exist('FileInput','var')
    4844    help fileparts_uvmat;
     
    5147end
    5248
    53 
    54 [RootPath,FileName,Ext]=fileparts(FileInput);
    55 
    56 switch Ext
    57     case '.avi'
    58         NomType='*';
    59         return
    60     case {'.tif','.tiff'}
    61         if exist(FileInput,'file')
    62             info=iminfo(FileInput);
    63             if length(info)>1
    64                 NomType='*';
    65                 return
    66             end
    67         end
    68 end
     49[RootPath,FileName,FileExt]=fileparts(FileInput);
     50RootFile=FileName;%default
     51% switch FileExt
     52%     case '.avi'
     53%         NomType='*';
     54%         return
     55%     case {'.tif','.tiff'}
     56%         if exist(FileInput,'file')
     57%             info=iminfo(FileInput);
     58%             if length(info)>1
     59%                 NomType='*';
     60%                 return
     61%             end
     62%         end
     63% end
    6964
    7065% \D not a digit
     
    7267
    7368
    74 %% recursive test on FileName stqrting from the end
    75 
     69%% recursive test on FileName starting from the end
     70% case of pure number
     71if ~isnan(str2double(FileName))
     72    RootFile='';
     73    i1=str2double(FileName);
     74    return
     75end
    7676% test whether FileName ends with a number or not
    77 r=regexp(FileName,'.*\D(?<num1>\d+)\>','names');
     77r=regexp(FileName,'.*\D(?<num1>\d+)$','names');% \D = not a digit, \d =digit
    7878
    7979if ~isempty(r)% FileName end matches num1
    8080    num1=r.num1;
    81     r=regexp(FileName,['.*\D(?<num2>\d+)(?<delim1>[-_])' num1 '\>'],'names');
     81    r=regexp(FileName,['.*\D(?<num2>\d+)(?<delim1>[-_])' num1 '$'],'names');
    8282    if ~isempty(r)% FileName end matches num2+delim1+num1
    8383        delim1=r.delim1;
    8484        num2=r.num2;
    85         r=regexp(FileName,['.*\D(?<num3>\d+)(?<delim2>[-_])' num2 delim1 num1 '\>'],'names');
     85        r=regexp(FileName,['.*\D(?<num3>\d+)(?<delim2>[-_])' num2 delim1 num1 '$'],'names');
    8686        if ~isempty(r) % FileName end matches delim2 num2 delim1 num1
    8787            delim2=r.delim2;
     
    117117            RootFile=regexprep(FileName,[num2 delim1 num1],'');
    118118        end
     119        NomType=regexprep(NomType,'-1','-2'); %set 1-2 instead of 1-1
    119120    else% only one number at the end
    120121        i1=str2double(num1);
     
    123124    end
    124125else% FileName ends with a letter
    125     r=regexp(FileName,'.*[^a^b^A^B](?<end_string>ab|AB|[abAB])\>','names');
     126    %r=regexp(FileName,'.*[^a^b^A^B](?<end_string>ab|AB|[abAB])\>','names');
     127    NomType='';
     128    r=regexp(RootFile,'\D(?<num1>\d+)(?<end_string>[a-z]|[A-Z]|[a-z][a-z]|[A-Z][A-Z])$','names');
    126129    if ~isempty(r)
    127         end_string=r.end_string;
    128         r=regexp(FileName,['.+(?<delim1>[_-])' end_string '\>'],'names');
     130        NomType=get_type(r.end_string);
     131        RootFile=regexprep(RootFile,[r.num1 r.end_string '$'],'');
     132    else % case with separator '_'
     133        r=regexp(RootFile,'\D(?<num1>\d+)_(?<end_string>[a-z]|[A-Z]|[a-z][a-z]|[A-Z][A-Z])$','names');
    129134        if ~isempty(r)
    130             delim1=r.delim1;
    131             r=regexp(FileName,['.*\D(?<num1>\d+)' delim1 end_string '\>'],'names');
    132             if ~isempty(r)
    133                 num1=r.num1;
    134                 NomType=[get_type(num1) delim1 get_type(end_string)];
    135                 i1=str2double(num1);
    136                 [j1,j2]=get_value(end_string);
    137                 RootFile=regexprep(FileName,[num1 delim1 end_string],'');
    138                
    139             else
    140                 NomType=get_type(end_string);
    141                 [j1,j2]=get_value(end_string);
    142                 RootFile=regexprep(FileName,end_string,'');
    143 
    144             end
    145         else
    146             r=regexp(FileName,['.*\D(?<num1>\d+)' end_string '\>'],'names');
    147             if ~isempty(r)
    148                 num1=r.num1;
    149                 %                 r=regexp(FileName,['.+(?<delim1>[-_])' num1 end_string '\>'],'names');
    150                 %                 if ~isempty(r)
    151                 %                     delim1=r.delim1;
    152                 %                     i1=num1;
    153                 %                     str_a=end_string;
    154                 %                     NomType=[delim1 get_type(num1) get_type(end_string)];
    155                 %                     RootFile=regexprep(FileName,[delim1 num1 end_string],'');
    156                 %                 else
    157                 i1=str2double(num1);
    158                 [j1,j2]=get_value(end_string);
    159                 NomType=[get_type(num1) get_type(end_string)];
    160                 RootFile=regexprep(FileName,[num1 end_string],'');
    161                 %                 end
    162             else
    163             end
    164            
    165            
    166    
    167         end               
    168     else
    169     end
    170 end
    171 
    172 if ~isempty(regexp(NomType,'-|ab|AB'))
    173     r=regexp(RootPath,'\<(?<newrootpath>.+)(\\|/)(?<subdir>[^\\^/]+)(\\|/)*\>','names');
    174     if ~isempty(r)
    175     SubDir=r.subdir;
    176     RootPath=r.newrootpath;
    177     end
    178 end
     135            NomType=['_' get_type(r.end_string)];
     136            RootFile=regexprep(RootFile,[r.num1 '_' r.end_string '$'],'');
     137        end
     138    end
     139    if ~isempty(NomType)
     140        [j1,j2]=get_value(r.end_string);
     141        i1=str2double(r.num1);
     142        NomType=[get_type(r.num1) NomType];
     143        r=regexp(RootPath,'\<(?<newrootpath>.+)(\\|/)(?<subdir>[^\\^/]+)(\\|/)*\>','names');
     144        if ~isempty(r)
     145            SubDir=r.subdir;
     146            RootPath=r.newrootpath;
     147        end
     148    end
     149end
     150
     151%% suppress '_' at the end of RootFile, put it on NomType
     152if strcmp(RootFile(end),'_')
     153    RootFile(end)=[];
     154    NomType=['_' NomType];
     155end
     156
     157% if ~isempty(regexp(NomType,'-|ab|AB'))
     158%     r=regexp(RootPath,'\<(?<newrootpath>.+)(\\|/)(?<subdir>[^\\^/]+)(\\|/)*\>','names');
     159%     if ~isempty(r)
     160%     SubDir=r.subdir;
     161%     RootPath=r.newrootpath;
     162%     end
     163% end
    179164
    180165
     
    184169% returns the type of a label string:
    185170%   for numbers, whether filled with 0 or not.
    186 %   for letters, either a, A or ab, AB.
    187 
    188 switch s
    189     case {'a','b'}
    190         type='a';
    191     case {'A','B'}
    192         type='A';
    193     case 'ab'
    194         type='ab';
    195     case 'AB'
    196         type='AB';
    197     otherwise       
    198         if ~isempty(regexp(s,'\<\d+\>','ONCE'))
    199 %             switch s(1)
    200 %                 case '0'
    201                     type=num2str(1,['%0' num2str(length(s)) 'd']);
    202 %                 otherwise
    203 %                     type='1';
    204 %             end
    205         else
    206             type='';
    207             return
    208         end
    209 end
     171type='';%default
     172
     173if ~isempty(regexp(s,'\<\d+\>','ONCE'))
     174    type=num2str(1,['%0' num2str(length(s)) 'd']);
     175else
     176    code=double(s); % ascii code of the input string
     177    if code >= 65 & code <= 90 % test on ascii code for capital letters
     178        if length(s)==1
     179            type='A';
     180        elseif length(s)==2
     181            type='AB';
     182        end
     183    elseif  code >= 97 & code <= 122 % test on ascii code for small letters
     184        if length(s)==1
     185            type='a';
     186        elseif length(s)==2
     187            type='ab';
     188        end
     189    end
     190end
     191
    210192
    211193
    212194function [j1,j2]=get_value(s)
    213 % returns the type of a label string:
     195% returns the value of a label string:
    214196%   for numbers, whether filled with 0 or not.
    215197%   for letters, either a, A or ab, AB.
    216198j1=[];
    217199j2=[];
    218 
    219 switch lower(s)
    220     case {'a'}
    221         j1=1;
    222     case {'b','B'}
    223         j1=2;
    224     case 'ab'
    225         j1=1;j2=2;
    226     otherwise       
    227             return
    228 end
    229 
     200code=double(s); % ascii code of the input string
     201if code >= 65 & code <= 90 % test on ascii code for capital letters
     202    index=double(s)-64; %change capital letters to corresponding number in the alphabet
     203elseif code >= 97 & code <= 122 % test on ascii code for small letters
     204    index=double(s)-96; %change small letters to corresponding number in the alphabet
     205else
     206    index=str2num(s);
     207end
     208if ~isempty(index)
     209    j1=index(1);
     210    if length(index)==2
     211        j2=index(2);
     212    end
     213end
    230214
    231215
     
    256240        'Image_5_3-4.jpg'...
    257241        'Image_3_ab.jpg'...
    258         'Image005AB.jpg'...
    259         'Image_3_ab.jpg'...
     242        'Image005AD.jpg'...
     243        'Image_3_ac.jpg'...
    260244        'Image_3a-b.jpg'...
    261245        'Image3_a.jpg'...
     
    265249
    266250for FileName=FileName_list
    267 %     [RootPath,RootFile,i1,i2,str_a,str_b,Ext,NomType,SubDir]=name2display(FileName{1});
    268     [~,RootFile,i1,i2,j1,j2,~,NomType,SubDir]=...
     251%     [RootPath,RootFile,i1,i2,str_a,str_b,FileExt,NomType,SubDir]=name2display(FileName{1});
     252    [~,SubDir,RootFile,i1,i2,j1,j2,~,NomType]=...
    269253        fileparts_uvmat(FileName{1});
    270254    fprintf([...
  • trunk/src/find_file_series.m

    r332 r334  
    1 %'find_file_series': check the content onf an input fiel and find the corresponding file series
     1%'find_file_series': check the content onf an input field and find the corresponding file series
    22%--------------------------------------------------------------------------
    33% function [i1,i2,j1,j2,NomType,FileType,Object]=find_file_series(fileinput)
     
    3636function [i1,i2,j1,j2,NomType,FileType,Object]=find_file_series(fileinput)
    3737%------------------------------------------------------------------------
    38 i1=NaN;%default
    39 i2=NaN;%default
    40 j1=NaN;%default
    41 j2=NaN;%default
     38i1=[];%default
     39i2=[];%default
     40j1=[];%default
     41j2=[];%default
    4242
    4343%% get input root name and nomenclature type
    44 [RootPath,RootFile,~,~,~,~,FileExt,NomType,SubDir]=name2display(fileinput);
     44% [RootPath,RootFile,~,~,~,~,FileExt,NomType,SubDir]=name2display(fileinput);
     45[RootPath,SubDir,RootFile,~,~,~,~,FileExt,NomType]=fileparts_uvmat(fileinput);
    4546
    4647%% check for particular file types: images, movies, civ data
    4748FileType='';
    4849Object=[];
    49 if ~isempty(FileExt)&& ~isempty(imformats(FileExt(2:end)))
    50     imainfo=imfinfo(fileinput);
    51     FileType='image';
    52     if length(imainfo) >1 %case of image with multiple frames
    53         NomType='*';
    54         FileType='multimage';
    55         i1=1;
    56         i2=length(imainfo);
    57         [RootPath,RootFile]=fileparts(fileinput);
    58     end
     50switch FileExt
     51    % ancillary files, no field indexing
     52    case {'.civ','.log','.cmx','.cmx2','.txt','.bat'}
     53        FileType='txt';
     54        NomType='';
     55    case '.fig'
     56        FileType='figure';
     57        NomType='';
     58    case '.xml'
     59        FileType='xml';
     60        NomType='';
     61    case '.xls'
     62        FileType='xls';
     63        NomType='';
     64    otherwise
     65        if ~isempty(FileExt)&& ~isempty(imformats(FileExt(2:end)))
     66            imainfo=imfinfo(fileinput);
     67            FileType='image';
     68            if length(imainfo) >1 %case of image with multiple frames
     69                NomType='*';
     70                FileType='multimage';
     71                i1=1;
     72                i2=length(imainfo);
     73                [RootPath,RootFile]=fileparts(fileinput);
     74            end
     75        else
     76            try
     77                Data=nc2struct(fileinput,'ListGlobalAttribute','absolut_time_T0','Conventions');
     78                if ~isempty(Data.absolut_time_T0')
     79                    FileType='civx'; % test for civx velocity fields
     80                elseif strcmp(Data.Conventions','uvmat/civdata')
     81                    FileType='civdata'; % test for civx velocity fields
     82                else
     83                    FileType='netcdf';
     84                end
     85            end
     86            try
     87                Object=VideoReader(fileinput);
     88                NomType='*';
     89                FileType='video';
     90                i1=1;
     91                i2=get(Object,'NumberOfFrames');
     92                [RootPath,RootFile]=fileparts(fileinput);
     93            end
     94        end
     95end
     96if strcmp(NomType,'')||strcmp(NomType,'*')
     97    [RootPath,RootFile]=fileparts(fileinput);% case of constant name (no indexing)
     98%% get the list of existing files
    5999else
    60     try
    61         Data=nc2struct(fileinput,'ListGlobalAttribute',{'absolut_time_T0','Conventions'});
    62         if ~isempty(Data,'absolut_time_T0')
    63             FileType='civx'; % test for civx velocity fields
    64         elseif strcmp(Data.Conventions','uvmat/civdata')
    65             FileType='civdata'; % test for civx velocity fields
    66         else
    67             FileType='netcdf';
    68         end     
    69     end
    70     try
    71         Object=VideoReader(fileinput);
    72         NomType='*';
    73         FileType='video';
    74         i1=1;
    75         i2=get(Object,'NumberOfFrames');
    76         [RootPath,RootFile]=fileparts(fileinput);
    77     end
    78 end
    79 
    80 %% get the list of existing files
    81 if ~strcmp(NomType,'*')
    82100    if strcmp(SubDir,'')
    83101        filebasesub=fullfile(RootPath,RootFile);
     
    95113    end
    96114    dirpair=dir([filebasesub detect_string FileExt]);
    97     % switch NomType %TODO: complement for other cases
    98     %     case '_0001'
    99     %         dirpair=dir([filebasesub '_*' FileExt]);
    100     %     case '_1'
    101     %         dirpair=dir([filebasesub '_*' FileExt]);
    102     %     case '_1_1'
    103     %         dirpair=dir([filebasesub '_*_*' FileExt]);
    104     %     case '_i1-i2'
    105     %         dirpair=dir([filebasesub '_*-*' FileExt]);
    106     %     case '1_ab'
    107     %         dirpair=dir([filebasesub '*_*' FileExt]);
    108     %     case '_i_j1-j2'
    109     %         dirpair=dir([filebasesub '*_*-*' FileExt]);
    110     %     case '_i1-i2_j'
    111     %         dirpair=dir([filebasesub '*-*_*' FileExt]);
    112     % end
    113115    for ifile=1:length(dirpair)
    114         [~,~,str_1,str_2,str_a,str_b]=name2display(dirpair(ifile).name);
    115         i1(ifile)=str2double(str_1);
    116         i2(ifile)=str2double(str_2);
    117         if isnan(i2(ifile))
     116       % [~,~,str_1,str_2,str_a,str_b]=name2display(dirpair(ifile).name);
     117       dirpair(ifile).name
     118        [~,~,~,i1_ifile,i2_ifile,j1_ifile,j2_ifile]=fileparts_uvmat(dirpair(ifile).name); 
     119        if isempty(i1_ifile)
     120            i1(ifile)=1;
     121        else
     122            i1(ifile)=i1_ifile;
     123        end
     124        if isempty(i2_ifile)
    118125            i2(ifile)=i1(ifile);
     126        else
     127            i2(ifile)=i2_ifile;
    119128        end
    120         j1(ifile)=stra2num(str_a);
    121         if isnan(j1(ifile))
     129        end
     130        if isempty(j1_ifile)
    122131            j1(ifile)=1;
     132        else
     133            j1(ifile)=j1_ifile;
    123134        end
    124         j2(ifile)=stra2num(str_b);
    125         if isnan(j2(ifile))
     135        if isempty(j2_ifile)
    126136            j2(ifile)=j1(ifile);
     137        else
     138            j2(ifile)=j2_ifile;
    127139        end
    128     end
    129    
     140    end 
     141    % TODO : sort by reference index
    130142    % update the NomType from the minimal index detected (to deal with number strings beginning by 0)
    131143    [~,ifile]=min(i1);
    132     [~,~,~,~,~,~,~,NomType]=name2display(dirpair(ifile).name);
     144    %[~,~,~,~,~,~,~,NomType]=name2display(dirpair(ifile).name);
     145    if ~isempty(i1)
     146           [~,ifile]=min(i1);
     147    [~,~,~,~,~,~,~,~,NomType]=fileparts_uvmat(dirpair(ifile).name);
     148    end
    133149end
  • trunk/src/plot_field.m

    r313 r334  
    480480    PlotParam=[];
    481481end
     482if ~isfield(PlotParam,'Coordinates')
     483    PlotParam.Coordinates=[];
     484end
    482485if ~isfield(PlotParam,'Scalar')
    483486    PlotParam.Scalar=[];
     
    10141017    YMin=[];
    10151018    YMax=[];
    1016     fix_lim=isfield(PlotParam,'CheckFixLimits') && PlotParam.CheckFixLimits;
     1019    fix_lim=isfield(PlotParam.Coordinates,'CheckFixLimits') && PlotParam.Coordinates.CheckFixLimits;
    10171020    if fix_lim
    1018         if ~isfield(PlotParam,'MinX')||~isfield(PlotParam,'MaxX')||~isfield(PlotParam,'MinY')||~isfield(PlotParam,'MaxY')
    1019             fix_lim=0; %free limits if limits are not set,
    1020         else
    1021             XMin=PlotParam.MinX
    1022             XMax=PlotParam.MaxX;
    1023             YMin=PlotParam.MinY;
    1024             YMax=PlotParam.MaxY;
     1021        if isfield(PlotParam.Coordinates,'MinX')&&isfield(PlotParam.Coordinates,'MaxX')&&isfield(PlotParam.Coordinates,'MinY')&&isfield(PlotParam.Coordinates,'MaxY')
     1022            XMin=PlotParam.Coordinates.MinX;
     1023            XMax=PlotParam.Coordinates.MaxX;
     1024            YMin=PlotParam.Coordinates.MinY;
     1025            YMax=PlotParam.Coordinates.MaxY;
    10251026        end  %else PlotParamOut.XMin =PlotParam.XMin...
    10261027    else
     
    10461047%     PlotParamOut.RangeY=[YMin YMax]; %range of x, to be stored in the user data of the plot axes
    10471048%     if ~fix_lim
    1048         PlotParamOut.MinX=XMin;
    1049         PlotParamOut.MaxX=XMax;
    1050         PlotParamOut.MinY=YMin;
    1051         PlotParamOut.MaxY=YMax;
     1049        PlotParamOut.Coordinates.MinX=XMin;
     1050        PlotParamOut.Coordinates.MaxX=XMax;
     1051        PlotParamOut.Coordinates.MinY=YMin;
     1052        PlotParamOut.Coordinates.MaxY=YMax;
    10521053        if XMax>XMin
    10531054            set(haxes,'XLim',[XMin XMax]);% set x limits of frame in axes coordinates
     
    10601061    set(get(haxes,'XLabel'),'String',[XName ' (' x_units ')']);
    10611062    set(get(haxes,'YLabel'),'String',[YName ' (' y_units ')']);
    1062     PlotParamOut.x_units=x_units;
    1063     PlotParamOut.y_units=y_units;
     1063    PlotParamOut.Coordinates.x_units=x_units;
     1064    PlotParamOut.Coordinates.y_units=y_units;
    10641065end
    10651066%-------------------------------------------------------------------
  • trunk/src/read_field.m

    r273 r334  
    3434VelType=ParamIn.VelType;
    3535end
    36 
    37 %% case of netcdf input file
    38 if strcmp(FileType,'netcdf')  %read the first nc field
    39     ParamOut.FieldName=ParamIn.FieldName;
    40     GUIName='get_field'; %default name of the GUI get_field
    41     if isfield(ParamIn,'GUIName')
    42         GUIName=ParamIn.GUIName;
    43     end
    44     test_civx=0;
    45     if ~strcmp(ParamIn.FieldName,'get_field...')% if get_field is not requested, look for Civx data
    46         FieldList=calc_field;%list of possible fields for Civx data
    47         ParamOut.ColorVar='';%default
    48         field_index=strcmp(ParamIn.FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data
    49         if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist
    50             Data=nc2struct(ObjectName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ');
    51             % case of new civdata conventions
    52             if isequal(Data.Conventions,'uvmat/civdata')
    53                 ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default
    54                 ParamOut.ColorVar='ima_cor';
    55                 InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    56                 [Field,ParamOut.VelType]=read_civdata(ObjectName,InputField,ParamIn.VelType);
    57                 test_civx=Field.CivStage;
    58             %case of old civx conventions
    59             elseif ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)
    60                 ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default
    61                 ParamOut.ColorVar='ima_cor';
    62                 InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    63                 [Field,ParamOut.VelType]=read_civxdata(ObjectName,InputField,ParamIn.VelType);
     36A=[];
     37%% distingush different input file types
     38switch FileType
     39    case {'civx','civdata','netcdf'}  %read the first nc field
     40        ParamOut.FieldName=ParamIn.FieldName;
     41        GUIName='get_field'; %default name of the GUI get_field
     42        if isfield(ParamIn,'GUIName')
     43            GUIName=ParamIn.GUIName;
     44        end
     45        test_civx=0;
     46        if ~strcmp(ParamIn.FieldName,'get_field...')% if get_field is not requested, look for Civx data
     47            FieldList=calc_field;%list of possible fields for Civx data
     48            ParamOut.ColorVar='';%default
     49            field_index=strcmp(ParamIn.FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data
     50            if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist
     51                Data=nc2struct(ObjectName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ');
     52                % case of new civdata conventions
     53                if isequal(Data.Conventions,'uvmat/civdata')
     54                    ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default
     55                    ParamOut.ColorVar='ima_cor';
     56                    InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
     57                    [Field,ParamOut.VelType]=read_civdata(ObjectName,InputField,ParamIn.VelType);
     58                    test_civx=Field.CivStage;
     59                    %case of old civx conventions
     60                elseif ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)
     61                    ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default
     62                    ParamOut.ColorVar='ima_cor';
     63                    InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
     64                    [Field,ParamOut.VelType]=read_civxdata(ObjectName,InputField,ParamIn.VelType);
     65                    test_civx=Field.CivStage;
     66                    ParamOut.CivStage=Field.CivStage;
     67                    % not cvix file, fields will be chosen through the GUI get_field
     68                else
     69                    ParamOut.FieldName='get_field...';
     70                    hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI
     71                    if ~isempty(hget_field)
     72                        delete(hget_field)%delete  get_field for reinitialisation
     73                    end
     74                end
     75            else
     76                InputField={ParamOut.FieldName};
     77                if isfield(ParamIn,'ColorVar')
     78                    ParamOut.ColorVar=ParamIn.ColorVar;
     79                    InputField=[InputField {ParamOut.ColorVar}];
     80                end
     81                [Field,ParamOut.VelType,errormsg]=read_civxdata(ObjectName,InputField,ParamIn.VelType);
     82                if ~isempty(errormsg)
     83                    return
     84                end
    6485                test_civx=Field.CivStage;
    6586                ParamOut.CivStage=Field.CivStage;
    66             % not cvix file, fields will be chosen through the GUI get_field   
    67             else
    68                 ParamOut.FieldName='get_field...';
    69                 hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI
    70                 if ~isempty(hget_field)
    71                     delete(hget_field)%delete  get_field for reinitialisation
    72                 end
    73             end
     87            end
     88        end
     89        if ~test_civx% read the field names on the interface get_field.
     90            hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI
     91            if isempty(hget_field)% open the GUI get_field if it is not found
     92                hget_field= get_field(ObjectName);%open the get_field GUI
     93                set(hget_field,'Name',GUIName)%update the name of get_field (e.g. get_field_1)
     94            end
     95            hhget_field=guidata(hget_field);
     96            %% update  the get_field GUI
     97            set(hhget_field.inputfile,'String',ObjectName)
     98            set(hhget_field.list_fig,'Value',1)
     99            if exist('num','var')&&~isnan(num)
     100                set(hhget_field.TimeIndexValue,'String',num2str(num))
     101            end
     102            funct_list=get(hhget_field.ACTION,'UserData');
     103            funct_index=get(hhget_field.ACTION,'Value');
     104            funct=funct_list{funct_index};%select  the current action in get_field, e;g. PLOT
     105            Field=funct(hget_field); %%activate the current action selected in get_field, e;g.read the names of the variables to plot
     106            Tabchar={''};%default
     107            Tabcell=[];
     108            set(hhget_field.inputfile,'String',ObjectName)
     109            if isfield(Field,'ListGlobalAttribute')&& ~isempty(Field.ListGlobalAttribute)
     110                for iline=1:length(Field.ListGlobalAttribute)
     111                    Tabcell{iline,1}=Field.ListGlobalAttribute{iline};
     112                    if isfield(Field, Field.ListGlobalAttribute{iline})
     113                        eval(['val=Field.' Field.ListGlobalAttribute{iline} ';'])
     114                        if ischar(val);
     115                            Tabcell{iline,2}=val;
     116                        else
     117                            Tabcell{iline,2}=num2str(val);
     118                        end
     119                    end
     120                end
     121                if ~isempty(Tabcell)
     122                    Tabchar=cell2tab(Tabcell,'=');
     123                    Tabchar=[{''};Tabchar];
     124                end
     125            end
     126            %set(hhget_field.attributes,'String',Tabchar);%update list of global attributes in get_field
     127            ParamOut.CivStage=0;
     128            ParamOut.VelType=[];
     129            if isfield(Field,'TimeIndex')
     130                ParamOut.TimeIndex=Field.TimeIndex;
     131            end
     132            if isfield(Field,'TimeValue')
     133                ParamOut.TimeValue=Field.TimeValue;
     134            end
     135        end
     136        if test_civx
     137            ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}];
    74138        else
    75             InputField={ParamOut.FieldName};
    76             if isfield(ParamIn,'ColorVar')
    77                 ParamOut.ColorVar=ParamIn.ColorVar;
    78                 InputField=[InputField {ParamOut.ColorVar}];
    79             end
    80             [Field,ParamOut.VelType,errormsg]=read_civxdata(ObjectName,InputField,ParamIn.VelType);
    81             if ~isempty(errormsg)
    82                 return
    83             end
    84             test_civx=Field.CivStage;
    85             ParamOut.CivStage=Field.CivStage;
    86         end
    87     end
    88     if ~test_civx% read the field names on the interface get_field.
    89         hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI
    90         if isempty(hget_field)% open the GUI get_field if it is not found
    91             hget_field= get_field(ObjectName);%open the get_field GUI
    92             set(hget_field,'Name',GUIName)%update the name of get_field (e.g. get_field_1)
    93         end
    94         hhget_field=guidata(hget_field);
    95         %% update  the get_field GUI
    96         set(hhget_field.inputfile,'String',ObjectName)
    97         set(hhget_field.list_fig,'Value',1)
    98         if exist('num','var')&&~isnan(num)
    99             set(hhget_field.TimeIndexValue,'String',num2str(num))
    100         end
    101         funct_list=get(hhget_field.ACTION,'UserData');
    102         funct_index=get(hhget_field.ACTION,'Value');
    103         funct=funct_list{funct_index};%select  the current action in get_field, e;g. PLOT
    104         Field=funct(hget_field); %%activate the current action selected in get_field, e;g.read the names of the variables to plot
    105         Tabchar={''};%default
    106         Tabcell=[];
    107         set(hhget_field.inputfile,'String',ObjectName)
    108         if isfield(Field,'ListGlobalAttribute')&& ~isempty(Field.ListGlobalAttribute)
    109             for iline=1:length(Field.ListGlobalAttribute)
    110                 Tabcell{iline,1}=Field.ListGlobalAttribute{iline};
    111                 if isfield(Field, Field.ListGlobalAttribute{iline})
    112                     eval(['val=Field.' Field.ListGlobalAttribute{iline} ';'])
    113                     if ischar(val);
    114                         Tabcell{iline,2}=val;
    115                     else
    116                         Tabcell{iline,2}=num2str(val);
    117                     end
    118                 end
    119             end
    120             if ~isempty(Tabcell)
    121                 Tabchar=cell2tab(Tabcell,'=');
    122                 Tabchar=[{''};Tabchar];
    123             end
    124         end
    125         %set(hhget_field.attributes,'String',Tabchar);%update list of global attributes in get_field
    126         ParamOut.CivStage=0;
    127         ParamOut.VelType=[];
    128         if isfield(Field,'TimeIndex')
    129             ParamOut.TimeIndex=Field.TimeIndex;
    130         end
    131         if isfield(Field,'TimeValue')
    132             ParamOut.TimeValue=Field.TimeValue;
    133         end
    134     end
    135     if test_civx
    136         ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}];
    137     else
    138         ParamOut.FieldList={'get_field...'};
    139     end
    140 else
    141    
    142     %% case of image
     139            ParamOut.FieldList={'get_field...'};
     140        end
     141       
     142    case 'movie'
     143        try
     144            A=read(ObjectName,num);
     145            FieldName='image';
     146        catch ME
     147            errormsg=ME.message;
     148            return
     149        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';
     159    case 'vol'
     160        A=imread(ObjectName);
     161        Npz=size(A,1)/ParamIn.Npy;
     162        A=reshape(A',ParamIn.Npx,ParamIn.Npy,Npz);
     163        A=permute(A,[3 2 1]);
     164        FieldName='image';
     165    case 'multimage'
     166        A=imread(ObjectName,num);
     167        FieldName='image';
     168    case 'image'
     169        A=imread(ObjectName);
     170        FieldName='image';
     171end
     172%% case of image
     173if ~isempty(A)
    143174    ParamOut.FieldName='image';
    144175    ParamOut.FieldList={'image'};
    145176    Npz=1;%default
    146     switch FileType
    147         case 'movie'
    148             try
    149                 A=read(ObjectName,num);
    150                 FieldName='image';
    151             catch ME
    152                 errormsg=ME.message;
    153                 return
    154             end
    155         case 'avi'
    156             try
    157                 mov=aviread(ObjectName,num);
    158             catch ME
    159                 errormsg=ME.message;
    160                 return
    161             end
    162             A=frame2im(mov(1));
    163             FieldName='image';
    164         case 'vol'
    165             A=imread(ObjectName);
    166             Npz=size(A,1)/ParamIn.Npy;
    167             A=reshape(A',ParamIn.Npx,ParamIn.Npy,Npz);
    168             A=permute(A,[3 2 1]);
    169             FieldName='image';
    170         case 'multimage'
    171             A=imread(ObjectName,num);
    172             FieldName='image';
    173         case 'image'
    174             A=imread(ObjectName);
    175             FieldName='image';
    176     end
    177177    npxy=size(A);
    178178    Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
     
    213213
    214214
     215
  • trunk/src/uvmat.m

    r332 r334  
    468468function display_file_name(hObject, eventdata, handles,fileinput)
    469469%------------------------------------------------------------------------
     470%% analyse the input file
    470471if ~exist(fileinput,'file')
    471472    msgbox_uvmat('ERROR',['input file ' fileinput  ' does not exist'])
    472473    return
    473474end
    474 [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput);%extract information from the file name
    475 ext_test=''; %default
    476 if ~isempty(ext) % if a file extension is detected
    477     form=imformats(ext(2:end));%test valid Matlab image formats
    478     if ~isempty(form)
    479         ext_test='.image';
    480         imainfo=imfinfo(fileinput); 
    481         if length(imainfo) >1 %case of image with multiple frames
    482             i1='1'; % set the frame counter to 1 by default
    483             i2='';
    484             str_a='';
    485             str_b='';
    486             NomType='*'; %indicate a set of indexed frames within a single file
    487             [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
    488         end
    489     elseif isequal(lower(ext),'.avi')%case of avi movie file
    490         ext_test='.image';
    491         i1='1'; % set the frame counter to 1 by default
    492         i2='';
    493         str_a='';
    494         str_b='';
    495         NomType='*'; %indicate a set of indexed frames within a single file
    496         [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
    497     else
    498         ext_test=lower(ext);
    499     end
    500 end
    501 switch ext_test
    502     case {'.civ','.log','.cmx','.cmx2','.txt','.bat'}  %display text file
     475% detect root name, nomenclature and indices in the input file name:
     476[RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt]=fileparts_uvmat(fileinput);
     477% 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);
     479
     480% open the file or fill the GUI uvmat according to the detected file type
     481switch FileType
     482    case ''
     483       msgbox_uvmat('ERROR','invalid input file type')
     484    case 'txt'
    503485        edit(fileinput) 
    504     case '.fig'                           %display matlab figure
     486    case 'figure'                           %display matlab figure
    505487        hfig=open(fileinput);
    506488        set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
    507489        set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
    508490        set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
    509     case {'.xml','.xls'}                % edit xml or Excel files
     491    case {'xml','xls'}                % edit xml or Excel files
    510492       editxml(fileinput);
    511     case {'.avi','.image','.vol','.nc','.cdf'}   
     493    otherwise
    512494        set(handles.RootPath,'String',RootPath);
    513495        if  isequal(SubDir,'')
     
    520502        set(handles.RootFile,'String',['/' RootFile]); %display the separator
    521503        indices=fileinput(length(rootname)+1:end);
    522         indices(end-length(ext)+1:end)=[]; %remove extension
     504        indices(end-length(FileExt)+1:end)=[]; %remove extension
    523505        set(handles.FileIndex,'String',indices);       
    524506%         set(handles.FileIndex,'UserData',NomType);
    525 set(handles.NomType,'String',NomType);
    526         set(handles.FileExt,'String',ext);
     507        set(handles.NomType,'String',NomType);
     508        set(handles.FileExt,'String',FileExt);
    527509        % fill file index counters
    528         set(handles.i1,'String',i1);   
    529         set(handles.i2,'String',i2);
    530         set(handles.j1,'String',str_a);
    531         set(handles.j2,'String',str_b);
     510        set(handles.i1,'String',num2str(i1));   
     511        set(handles.i2,'String',num2str(i2));
     512        set(handles.j1,'String',num2str(j1));
     513        set(handles.j2,'String',num2str(j2));
    532514       
    533515        % synchronise indices of the second  input file if it exists
     
    536518            NomType_1=get(handles.NomType_1,'String');
    537519%             NomType_1=get(handles.FileIndex_1,'UserData');     
    538             FileName_1=name_generator(FileBase_1,str2double(i1),str2double(i2),FileExt_1,NomType_1,1,stra2num(str_a),stra2num(str_b),SubDir_1);
     520            FileName_1=name_generator(FileBase_1,i1,i2,FileExt_1,NomType_1,1,j1,j2,SubDir_1);
    539521            if exist(FileName_1,'file')
    540                 FileIndex_1=name_generator('',str2double(i1),str2double(i2),'',NomType_1,1,stra2num(str_a),stra2num(str_b),'');
     522                FileIndex_1=name_generator('',i1,i2,'',NomType_1,1,j1,j2,'');
    541523                set(handles.FileIndex_1,'String',FileIndex_1)
    542524            else
     
    561543        set(handles.ListObject,'Visible','on')
    562544        set(handles.frame_object,'Visible','on')
    563          %%%%%% initiate input file:
    564         update_rootinfo(hObject,eventdata,handles); 
    565     otherwise
    566        msgbox_uvmat('ERROR',['invalid input file extension' ext])
     545       
     546         % initiate input file series and refresh the current field view:
     547        update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject); 
    567548end
    568549
     
    571552function RootPath_Callback(hObject,eventdata,handles)
    572553%------------------------------------------------------------------------
    573 update_rootinfo(hObject,eventdata,handles);
     554% read the current input file name:
     555fileinput=read_file_boxes(handles);
     556% detect the file type, get the movie object if relevant, and look for the corresponding file series:
     557[i1_series,i2_series,j1_series,j2_series,~,FileType,MovieObject]=find_file_series(fileinput);
     558% initiate the input file series and refresh the current field view:
     559update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject);
    574560
    575561%------------------------------------------------------------------------
     
    579565%refresh the menu of input fields
    580566Fields_Callback(hObject, eventdata, handles);
    581 % refresh the current field
     567% refresh the current field view
    582568run0_Callback(hObject, eventdata, handles);
    583569
     
    586572function RootFile_Callback(hObject, eventdata, handles)
    587573%------------------------------------------------------------------------
    588 update_rootinfo(hObject,eventdata,handles)
     574RootPath_Callback(hObject,eventdata,handles)
    589575
    590576%------------------------------------------------------------------------
     
    592578function FileIndex_Callback(hObject, eventdata, handles)
    593579%------------------------------------------------------------------------
    594 FileIndices=get(handles.FileIndex,'String');
    595 if isempty(str2num(FileIndices))
    596     [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices);
    597 else
    598     str1=FileIndices;
    599     str2='';
    600     str_a='';
    601     str_b='';
    602 end
    603 set(handles.i1,'String',str1);
    604 set(handles.i2,'String',str2);
    605 set(handles.j1,'String',str_a);
    606 set(handles.j2,'String',str_b);
     580[~,~,~,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));
     581set(handles.i1,'String',num2str(i1));
     582set(handles.i2,'String',num2str(i2));
     583set(handles.j1,'String',num2str(j1));
     584set(handles.j2,'String',num2str(j2));
     585
     586% refresh the current field view
    607587run0_Callback(hObject, eventdata, handles)
    608588
     
    610590% --- Update information about a new field series (indices to scan, timing,
    611591%     calibration from an xml file, then refresh current plots
    612 function update_rootinfo(hObject,eventdata,handles)
     592function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject)
    613593%------------------------------------------------------------------------
    614594set(handles.RootPath,'BackgroundColor',[1 1 0])
     
    618598UvData.NewSeries=1; %flag for run0: begin a new series
    619599UvData.TestInputFile=1;
     600UvData.FileType=FileType;
    620601set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window
    621602set(handles.FixVelType,'Value',0); %desactivate fixed veltype
    622603[FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
     604
    623605if ~exist(FileName,'file')
    624606   msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
     
    626608end
    627609nbfield=[];%default
    628 nburst=[];%default
     610nbfield_j=[];%default
    629611
    630612% read timing and total frame number from the current file (movie files) !! may be overrid by xml file
     
    640622    imainfo=aviinfo([FileBase FileIndices FileExt]);
    641623    nbfield=imainfo.NumFrames;
    642     nburst=1;
     624    nbfield_j=1;
    643625    set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
    644626    XmlData.Time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
     
    657639    if length(imainfo) >1 %case of image with multiple frames
    658640        nbfield=length(imainfo);
    659         nburst=1;
     641        nbfield_j=1;
    660642    end
    661643end
     
    748730end
    749731
    750 % store last index in handles.lat_i and .last_j
     732%% store last index in handles.lat_i and .last_j
     733nbfield=max(i2_series);
     734if isempty(nbfield)
     735    nbfield=max(i1_series);
     736end
     737nbfield_j=max(j2_series);
     738if isempty(nbfield_j)
     739    nbfield_j=max(j1_series);
     740end
    751741if ~isempty(XmlData.Time)
    752742    nbfield=size(XmlData.Time,1);
    753     nburst=size(XmlData.Time,2);
     743    nbfield_j=size(XmlData.Time,2);
    754744    %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
    755     if isequal(nbfield,1) && ~isequal(nburst,1)% .Time is a line vector
     745    if isequal(nbfield,1) && ~isequal(nbfield_j,1)% .Time is a line vector
    756746        NomType=get(handles.NomType,'String');
    757747%         NomType=get(handles.FileIndex,'UserData');
    758748        if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
    759749            XmlData.Time=(XmlData.Time)';
    760             nbfield=nburst;
    761             nburst=1;
     750            nbfield=nbfield_j;
     751            nbfield_j=1;
    762752        end
    763753    end
     
    771761set(handles.last_i,'String',last_i_cell)
    772762last_j_cell=get(handles.last_j,'String');
    773 if isempty(nburst)
     763if isempty(nbfield_j)
    774764     last_j_cell{1}='';
    775765else
    776      last_j_cell{1}=num2str(nburst);
     766     last_j_cell{1}=num2str(nbfield_j);
    777767end
    778768set(handles.last_j,'String',last_j_cell);
     
    812802               set(handles.nb_slice,'String',num2str(NbSlice))
    813803           end
    814            slices_Callback(hObject, eventdata, handles)
     804           slices_Callback([],[], handles)
    815805        end           
    816806    end
     
    824814UvData.XmlData=XmlData;
    825815UvData.NewSeries=1;
    826 
     816UvData.MovieObject=MovieObject;
    827817
    828818%display warning message
     
    862852set(handles.RootPath,'BackgroundColor',[1 1 1])
    863853drawnow
    864 set_scan_options(hObject, eventdata, handles)
     854set_scan_options(handles)
    865855
    866856%% update list of recent files in the menubar
     
    886876%--- Set index navigation options for new series input and refresh plot
    887877%------------------------------------------------------------------------
    888 function set_scan_options(hObject, eventdata, handles)
     878function set_scan_options(handles)
    889879
    890880%  set the corresponding index navigation options
     
    918908if isequal(scan_option,'i')
    919909     set(handles.scan_i,'Value',1)
    920      scan_i_Callback(hObject, eventdata, handles);
     910     scan_i_Callback([],[], handles);
    921911else
    922912     set(handles.scan_j,'Value',1)
    923      scan_j_Callback(hObject, eventdata, handles);
     913     scan_j_Callback([],[], handles);
    924914end
    925915set(handles.scan_j,'Visible',state_j)
     
    936926
    937927%% view the field 
    938 run0_Callback(hObject, eventdata, handles); %view field
     928run0_Callback([],[], handles); %view field
    939929mask_test=get(handles.CheckMask,'value');
    940930if mask_test
     
    943933          delete(MaskData.maskhandle)    %delete old mask
    944934    end
    945     CheckMask_Callback(hObject, eventdata, handles)
     935    CheckMask_Callback([],[],handles)
    946936end
    947937
     
    10511041
    10521042%[path,name,ext]=fileparts(fileinput_1);
    1053 [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
    1054 nbfield_1=1; %default
    1055 ext_test=FileExt_1;%default
    1056 form=imformats(FileExt_1(2:end));
    1057 if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab
    1058     imainfo=imfinfo(fileinput_1); 
    1059     nbfield_1=length(imainfo);
    1060     ext_test='.image';
    1061 elseif isequal(lower(FileExt_1),'.avi')
    1062     info=aviinfo(fileinput_1);
    1063     nbfield_1=info.NumFrames;
    1064     ext_test='.image';
    1065 end
    1066 
    1067 %open directly fig or text files
    1068 switch ext_test
    1069     case {'.civ','.log','.cmx','.cmx2','.txt'}  %display text file
     1043[RootPath_1,SubDir_1,RootFile_1,i1,i2,j1,j2,FileExt_1]=fileparts_uvmat(fileinput_1);
     1044[i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fileinput_1);
     1045% [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
     1046switch FileType
     1047    case ''
     1048       msgbox_uvmat('ERROR','invalid input file type')
     1049    case 'txt'
    10701050        edit(fileinput) 
    1071         return
    1072     case '.fig'                           %display matlab figure
     1051    case 'figure'                           %display matlab figure
    10731052        hfig=open(fileinput);
    10741053        set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
    10751054        set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
    10761055        set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
    1077         return
    1078     case {'.xml','.xls'}                % edit xml or Excel files
    1079        heditxml=editxml(fileinput);
    1080        return
    1081     case {'.image','.nc','.cdf'}       
    1082 %         set(handles.FileIndex,'UserData',NomType_1);
     1056    case {'xml','xls'}                % edit xml or Excel files
     1057       editxml(fileinput);
     1058%     case {'.avi','.image','.vol','.nc','.cdf'} 
    10831059    otherwise
    1084         msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')
    1085         return
    1086 end
     1060        set(handles.RootPath,'String',RootPath);
     1061        if  isequal(SubDir,'')
     1062            rootname=fullfile(RootPath,RootFile);
     1063        else
     1064            rootname=fullfile(RootPath,SubDir,RootFile);
     1065            SubDir=['/' SubDir]; %display the separator
     1066        end
     1067        set(handles.SubDir,'String',SubDir);
     1068        set(handles.RootFile,'String',['/' RootFile]); %display the separator
     1069        indices=fileinput(length(rootname)+1:end);
     1070        indices(end-length(FileExt)+1:end)=[]; %remove extension
     1071        set(handles.FileIndex,'String',indices);       
     1072%         set(handles.FileIndex,'UserData',NomType);
     1073        set(handles.NomType,'String',NomType);
     1074        set(handles.FileExt,'String',FileExt);
     1075        % fill file index counters
     1076        set(handles.i1,'String',num2str(i1));   
     1077        set(handles.i2,'String',num2str(i2));
     1078        set(handles.j1,'String',num2str(j1));
     1079        set(handles.j2,'String',num2str(j2));
     1080       
     1081        % synchronise indices of the second  input file if it exists
     1082        if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
     1083            [ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
     1084            NomType_1=get(handles.NomType_1,'String');
     1085%             NomType_1=get(handles.FileIndex_1,'UserData');     
     1086            FileName_1=name_generator(FileBase_1,i1,i2,FileExt_1,NomType_1,1,j1,j2,SubDir_1);
     1087            if exist(FileName_1,'file')
     1088                FileIndex_1=name_generator('',i1,i2,'',NomType_1,1,j1,j2,'');
     1089                set(handles.FileIndex_1,'String',FileIndex_1)
     1090            else
     1091                set(handles.SubField,'Value',0)
     1092                SubField_Callback(hObject, eventdata, handles)
     1093            end
     1094        end 
     1095end
     1096%
     1097%
     1098% nbfield_1=1; %default
     1099% ext_test=FileExt_1;%default
     1100% form=imformats(FileExt_1(2:end));
     1101% if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab
     1102%     imainfo=imfinfo(fileinput_1); 
     1103%     nbfield_1=length(imainfo);
     1104%     ext_test='.image';
     1105% elseif isequal(lower(FileExt_1),'.avi')
     1106%     info=aviinfo(fileinput_1);
     1107%     nbfield_1=info.NumFrames;
     1108%     ext_test='.image';
     1109% end
     1110%
     1111% %open directly fig or text files
     1112% switch ext_test
     1113%     case {'.civ','.log','.cmx','.cmx2','.txt'}  %display text file
     1114%         edit(fileinput) 
     1115%         return
     1116%     case '.fig'                           %display matlab figure
     1117%         hfig=open(fileinput);
     1118%         set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
     1119%         set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
     1120%         set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
     1121%         return
     1122%     case {'.xml','.xls'}                % edit xml or Excel files
     1123%        heditxml=editxml(fileinput);
     1124%        return
     1125%     case {'.image','.nc','.cdf'}       
     1126% %         set(handles.FileIndex,'UserData',NomType_1);
     1127%     otherwise
     1128%         msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')
     1129%         return
     1130% end
    10871131
    10881132% test for image series in a single file and synchronise file indices of the two series
     
    11861230set(handles.FixVelType,'Value',0); %desactivate fixed veltype
    11871231nbfield_1=[];%default
    1188 nburst_1=[];%default
     1232nbfield_j_1=[];%default
    11891233XmlData.Time=[];
    11901234XmlData.GeometryCalib=[];%default
     
    11991243    imainfo=aviinfo([FileBase FileIndices FileExt]);
    12001244    nbfield_1=imainfo.NumFrames;
    1201     nburst_1=1;
     1245    nbfield_j_1=1;
    12021246    set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
    12031247    time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
     
    12141258    if length(imainfo) >1 %case of image with multiple frames
    12151259        nbfield_1=length(imainfo);
    1216         nburst_1=1;
     1260        nbfield_j_1=1;
    12171261    end
    12181262end
     
    12811325if ~isempty(XmlData.Time)
    12821326    nbfield_1=size(XmlData.Time,1);
    1283     nburst_1=size(XmlData.Time,2);   
     1327    nbfield_j_1=size(XmlData.Time,2);   
    12841328end
    12851329last_i_cell=get(handles.last_i,'String');
     
    12911335set(handles.last_i,'String',last_i_cell)
    12921336last_j_cell=get(handles.last_j,'String');
    1293 if isempty(nburst_1)
     1337if isempty(nbfield_j_1)
    12941338     last_j_cell{2}='';
    12951339else
    1296      last_j_cell{2}=num2str(nburst_1);
     1340     last_j_cell{2}=num2str(nbfield_j_1);
    12971341end
    12981342set(handles.last_j,'String',last_j_cell);
     
    13321376drawnow
    13331377
    1334 set_scan_options(hObject, eventdata, handles)
     1378set_scan_options(handles)
    13351379
    13361380%------------------------------------------------------------------------
     
    13861430set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])
    13871431if get(handles.SubField,'Value')==1
    1388     NomType_1=get(handles.FileIndex_1,'String');
    1389      FileExt_1=get(handles.FileExt_1,'String');
    1390     [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);
     1432    NomType_1=get(handles.NomType_1,'String');
     1433%      FileExt_1=get(handles.FileExt_1,'String');
     1434%     [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);
    13911435     indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
    13921436     set(handles.FileIndex_1,'String',indices)
     
    14781522        for ilist=1:length(maskfiles)
    14791523            maskname=maskfiles(ilist).name;% take the first mask file in the list
    1480             [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
    1481             [Path2,Name,ext]=fileparts(maskname);
     1524            [~,~,~,~,~,~,~,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname);
     1525%             [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
     1526             [~,Name]=fileparts(maskname);
    14821527            Namedouble=double(Name);
    14831528            val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
     
    15281573            errormsg='no file browsed';
    15291574        end
    1530         [RootDir,RootFile,x1,x2,xa,xb,xext,Mask.NomType]=name2display(maskname);
     1575        [RootDir,~,RootFile,~,~,~,~,~,Mask.NomType]=fileparts_uvmat(maskname);
     1576%         [RootDir,RootFile,x1,x2,xa,xb,xext,Mask.NomType]=name2display(maskname);
    15311577        Mask.Base=fullfile(RootDir,RootFile);
    15321578        Mask.NbSlice=1;
     
    17961842if sub_value % a second input file has been entered
    17971843    [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
    1798     [pp,ff,i1_1_str,i2_1_str,j1_1_str,j2_1_str]=name2display(FileIndices_1);
    1799     i1_1=stra2num(i1_1_str);%current set of indices for the second field (may be set different than the main indices)
    1800     i2_1=stra2num(i2_1_str);
    1801     j1_1=stra2num(j1_1_str);
    1802     j2_1=stra2num(j2_1_str);
     1844    [~,~,~,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndices_1);
     1845  %  [pp,ff,i1_1_str,i2_1_str,j1_1_str,j2_1_str]=name2display(FileIndices_1);
     1846%     i1_1=stra2num(i1_1_str);%current set of indices for the second field (may be set different than the main indices)
     1847%     i2_1=stra2num(i2_1_str);
     1848%     j1_1=stra2num(j1_1_str);
     1849%     j2_1=stra2num(j2_1_str);
    18031850    NomType_1=get(handles.NomType_1,'String');
    18041851%     NomType_1=get(handles.FileIndex_1,'UserData');
     
    20902137    VelType=[];%default
    20912138    Ext=get(handles.FileExt,'String');
    2092     if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf')
    2093         FileType='netcdf';
    2094         list_fields=get(handles.Fields,'String');% list menu fields
    2095         index_fields=get(handles.Fields,'Value');% selected string index
    2096         FieldName= list_fields{index_fields}; % selected field
    2097         if ~strcmp(FieldName,'get_field...')
    2098            TestVelType=get(handles.FixVelType,'Value');
    2099            if TestVelType
    2100                VelType=setfield(handles);% read the velocity type.
    2101            end
    2102         end
    2103         if strcmp(FieldName,'velocity')
    2104             list_code=get(handles.ListColorCode,'String');% list menu fields
    2105             index_code=get(handles.ListColorCode,'Value');% selected string index
    2106             if  ~strcmp(list_code{index_code},'black') &&  ~strcmp(list_code{index_code},'white')
    2107                 list_code=get(handles.ListColorScalar,'String');% list menu fields
    2108                 index_code=get(handles.ListColorScalar,'Value');% selected string index
    2109                 ParamIn.ColorVar= list_code{index_code}; % selected field
     2139    FileType=UvData.FileType;
     2140    switch FileType
     2141        %     if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf')
     2142        case {'civx','civdata','netcdf'};
     2143            list_fields=get(handles.Fields,'String');% list menu fields
     2144            index_fields=get(handles.Fields,'Value');% selected string index
     2145            FieldName= list_fields{index_fields}; % selected field
     2146            if ~strcmp(FieldName,'get_field...')
     2147                TestVelType=get(handles.FixVelType,'Value');
     2148                if TestVelType
     2149                    VelType=setfield(handles);% read the velocity type.
     2150                end
    21102151            end
    2111         end
    2112     elseif isfield(UvData,'MovieObject')
    2113         ObjectName=UvData.MovieObject;
    2114         FileType='movie';
    2115     elseif isequal(lower(Ext),'.avi')
    2116         FileType='avi';
    2117     elseif isequal(lower(Ext),'.vol')
    2118         FileType='vol';
    2119         if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')
    2120             ParamIn.Npy=UvData.XmlData.Npy;
    2121             ParamIn.Npx=UvData.XmlData.Npx;
    2122         else
    2123             errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
    2124             return
    2125         end
    2126     else
    2127        form=imformats(Ext(2:end));
    2128        if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    2129            if isequal(NomType,'*');
    2130                FileType='multimage';
    2131            else
    2132                FileType='image';
    2133            end
    2134        end
     2152            if strcmp(FieldName,'velocity')
     2153                list_code=get(handles.ListColorCode,'String');% list menu fields
     2154                index_code=get(handles.ListColorCode,'Value');% selected string index
     2155                if  ~strcmp(list_code{index_code},'black') &&  ~strcmp(list_code{index_code},'white')
     2156                    list_code=get(handles.ListColorScalar,'String');% list menu fields
     2157                    index_code=get(handles.ListColorScalar,'Value');% selected string index
     2158                    ParamIn.ColorVar= list_code{index_code}; % selected field
     2159                end
     2160            end
     2161        case 'video'
     2162            ObjectName=UvData.MovieObject;
     2163           
     2164        case 'vol' %TODO: update
     2165            if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')
     2166                ParamIn.Npy=UvData.XmlData.Npy;
     2167                ParamIn.Npx=UvData.XmlData.Npx;
     2168            else
     2169                errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
     2170                return
     2171            end
    21352172    end
    21362173    ParamIn.FieldName=FieldName;
     
    25782615%PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
    25792616PlotParam{1}=read_GUI(handles.uvmat);
     2617PlotParam{1}.Coordinates
    25802618if ~isfield(PlotParam{1},'Vectors')
    25812619    PlotParam{1}.Vectors.MaxVec=1;
     
    27842822end
    27852823if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
    2786     [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
    2787     num_i2=str2double(str2);
    2788     if isnan(num_i2)
     2824    [~,~,~,num_i1,num_i2,num_j1,num_j2]=fileparts_uvmat(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
     2825  %  [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
     2826    if isempty(num_i2)
    27892827        num_i2=num_i1;
    27902828    end
    2791     num_j1=str2double(str_a);
    2792     if isnan(num_j1)
     2829    if isempty(num_j1)
    27932830        num_j1=1;
    27942831    end
    2795     num_j2=str2double(str_b);
    2796     if isnan(num_j2)
     2832    if isempty(num_j2)
    27972833        num_j2=num_j1;
    27982834    end
    2799     num_i1=str2double(str1);
    28002835    siz=size(UvData.XmlData_1.Time);
    28012836    if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
     
    31463181%read the rootfile input display
    31473182[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
    3148 [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
     3183[~,~,~,i1,i2,j1,j2,~,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]);
     3184% [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
    31493185NomTypeNew=NomType;%default
    31503186if isequal(field,'image')
     
    31563192        NomTypeNew='_1';
    31573193    end
    3158     imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
     3194    imagename=name_generator(FileBase,i1,j1,'.png',NomTypeNew,1,i2,j2,'');
    31593195    if ~exist(imagename,'file')
    31603196        [FileName,PathName] = uigetfile( ...
     
    31863222    end
    31873223end
    3188 indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
     3224indices=name_generator('',i1,j1,'',NomTypeNew,1,i2,j2,'');
    31893225set(handles.FileIndex,'String',indices)
    31903226set(handles.NomType,'String',NomTypeNew)
     
    32263262%read the rootfile input display
    32273263[FileName,RootPath,FileBase,FileIndices,FileExt_1]=read_file_boxes_1(handles);
    3228 [P,F,str1,str2,str_a,str_b,E,NomType_1]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_1]);
     3264[~,~,~,i1,i2,j1,j2,~,NomType_1]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt_1]);
     3265% [P,F,str1,str2,str_a,str_b,E,NomType_1]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_1]);
    32293266if isempty(NomType_1)|| strcmp(NomType_1,'')
    32303267    [FileName,RootPath,FileBase,FileIndices,FileExt_1]=read_file_boxes(handles);
    3231     [P,F,str1,str2,str_a,str_b,E,NomType_1]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_1]);
     3268    [~,~,~,i1,i2,j1,j2,~,NomType_1]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt_1]);
     3269 %   [P,F,str1,str2,str_a,str_b,E,NomType_1]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_1]);
    32323270end
    32333271NomTypeNew=NomType_1;%default
     
    32803318        end 
    32813319    end
    3282     imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
     3320    imagename=name_generator(FileBase,i1,j1,'.png',NomTypeNew,1,i2,j2,'');
    32833321    if ~exist(imagename,'file')
    32843322        [FileName,PathName] = uigetfile( ...
Note: See TracChangeset for help on using the changeset viewer.