Home > . > name2display.m

# name2display

## PURPOSE

'name2display': extracts the root name and field numbers from an input filename

## SYNOPSIS

function [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput)

## DESCRIPTION

    'name2display': extracts the root name and field numbers from an input filename
    --------------------------------------------------------------------
    [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput)

    OUTPUT:
    filebasesub: filename without appendix
    field_count: string for the first number i
    str2: string for the second number i (only for .nc files)
    str_a: string for the first number j
    str_b:string for the second number j (only for .nc files)
    ext: file extension
    nom_type: char chain characterizing the file nomenclature: with values
       nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
       nom_type='*':constant name for a file representing a series (e.g. avi movie)
       nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png').
       nom_type='#', series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
       nom_type='_i_j': matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
       nom_type='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc')
       nom_type='_i_j1-j2': pairs of j indices (e.g. 'aa_45_2-3.nc')
       nom_type='_i1-i2_j': pairs of i indices (e.g. 'aa_45-46_2.nc')
       nom_type='#a','#A", with a numerical index and an index letter(e.g.'aa045b.png') (lower or upper case)
       nom_type='raw_SMD', same as '#' but with no extension ext='', OBSOLETE
       nom_type='#_ab', from pairs of '#' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by '_i_j1-j2')
    subdir: name of the subdirectory for netcdf files

    INPUT:
    fileinput: complete name of the file, including path

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- civ 'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch)
- civ_3D 'civ_3D': function associated with the interface 'civ_3D.fig' for PIV in volume
- geometry_calib 'geometry_calib': performs geometric calibration from a set of reference points
- name_generator 'name_generator': creates a file name from a root name and indices.
- probe_calib 'probe_calib': performs geometric calibration from a set of reference points
- read_xls 'read_xls': function for reading and displaying Excel files
- series 'series': master function associated to the GUI series.m for analysis field series
- set_grid 'set_grid':produce grid for PIV with one or two images (stereo case)
- uvmat 'uvmat': function associated with the GUI 'uvmat.fig' for images and data field visualization

## SOURCE CODE

    0001 %'name2display': extracts the root name and field numbers from an input filename
    0002 %--------------------------------------------------------------------
    0003 %[RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput)
    0004 %
    0005 %OUTPUT:
    0006 %filebasesub: filename without appendix
    0007 %field_count: string for the first number i
    0008 %str2: string for the second number i (only for .nc files)
    0009 %str_a: string for the first number j
    0010 %str_b:string for the second number j (only for .nc files)
    0011 %ext: file extension
    0012 %nom_type: char chain characterizing the file nomenclature: with values
    0013 %   nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
    0014 %   nom_type='*':constant name for a file representing a series (e.g. avi movie)
    0015 %   nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png').
    0016 %   nom_type='#', series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
    0017 %   nom_type='_i_j': matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
    0018 %   nom_type='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc')
    0019 %   nom_type='_i_j1-j2': pairs of j indices (e.g. 'aa_45_2-3.nc')
    0020 %   nom_type='_i1-i2_j': pairs of i indices (e.g. 'aa_45-46_2.nc')
    0021 %   nom_type='#a','#A", with a numerical index and an index letter(e.g.'aa045b.png') (lower or upper case)
    0022 %   nom_type='raw_SMD', same as '#' but with no extension ext='', OBSOLETE
    0023 %   nom_type='#_ab', from pairs of '#' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by '_i_j1-j2')
    0024 %subdir: name of the subdirectory for netcdf files
    0025 %
    0026 %INPUT:
    0027 %fileinput: complete name of the file, including path
    0028
    0029 function [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput)
    0030 % siz=length(fileinput);
    0031 % indcur=siz;
    0032 % default values:
    0033 % test_=0;
    0034 field_count='';%character string
    0035 str2='';
    0036 str_a='';
    0037 str_b='';
    0038 % ext='';
    0039 nom_type='';
    0040 subdir='';
    0041         %select file extension
    0042 [RootPath,RootFile,ext]=fileparts(fileinput);
    0043 indcur=length(RootFile);% nbre of characters in fileraw
    0044
    0045         %recognize the name form
    0046 filerawascii=double(RootFile);%ascci code
    0047 val=(48>filerawascii)|(filerawascii>57); % test for the non-numerical characters
    0048 indsel=find(val);% character indices of non numerical characters
    0049 filelit=RootFile(indsel);% fileraw name with numbers removed
    0050 nbchar=length(indsel);
    0051 if nbchar<4% put '*' before the name (remove at the end)
    0052    prefilelit(1:4-nbchar)='*';%insert 3_nbchar '*' in the file name
    0053    filelit=[prefilelit filelit];
    0054    indsel=[1:4-nbchar indsel+4-nbchar];
    0055    RootFile=[prefilelit RootFile];
    0056    indcur=indcur+4-nbchar;
    0057 end
    0058 separ3=indsel(end);% index of last non numerical character in fileraw
    0059 separ2=indsel(end-1);% index of previous non numerical character
    0060 separ1=indsel(end-2);
    0061 separ0=indsel(end-3);
    0062 num1='';num2='';num3='';
    0063 if separ1>=separ0+1,num0=RootFile(separ0+1:separ1-1);end
    0064 if separ2>=separ1+1,num1=RootFile(separ1+1:separ2-1);end
    0065 if separ3>=separ2+1,num2=RootFile(separ2+1:separ3-1);end
    0066 if indcur>=separ3+1,num3=RootFile(separ3+1:indcur);end
    0067 last_str=RootFile(indcur);%last character in fileraw
    0068 last=double(last_str);%corresponding ascii code
    0069 penult=double(RootFile(indcur-1));%ascii code of the penultimate character
    0070 testsub=0; %default
    0071 if strcmpi(ext,'.avi')
    0072      nom_type='*';
    0073       %case of old image nomenclature
    0074 elseif (strcmp(ext,'.png') || strcmp(ext,'')) &&  penult >= 48 && penult <= 57 && (last < 48 || last > 57)
    0075     % if the penultimate character is a number and the last a letter
    0076     % search the appendix a,b,c,
    0077     str_a=last_str; %put appendix a,b,c....
    0078     indcur=indcur-1;
    0079     if strcmp(ext,'.png'), nom_type='#a'; end
    0080     if strcmp(ext,''), nom_type='raw_SMD'; end
    0081     num=1;count=0; % extract the numerical appendix
    0082     while num==1;
    0083         filascii=double(RootFile(indcur));
    0084         if (48>filascii)||(filascii>57); % select the non-numerical characters
    0085             num=0;
    0086         else
    0087             indcur=indcur-1; count=count+1;
    0088         end
    0089     end
    0090     if count~=0
    0091             field_count=RootFile(indcur+1:indcur+count);% set the selected field number
    0092     end
    0093 elseif  penult >= 48 && penult <= 57  && (last <= 66 && last >= 65)% PCO camera Toulouse, end with A or B (NEW)
    0094     % if the penultimate character is a number and the last a letter
    0095     % search the appendix a,b,c,
    0096     str_a=last_str; %put appendix a,b,c....
    0097     indcur=indcur-1;
    0098     nom_type='#A';
    0099     num=1;count=0; % extract the numerical appendix
    0100     while num==1;
    0101         filascii=double(RootFile(indcur));
    0102         if (48>filascii)||(filascii>57); % select the non-numerical characters
    0103             num=0;
    0104         else
    0105             indcur=indcur-1; count=count+1;
    0106         end
    0107     end
    0108     if count~=0
    0109             field_count=RootFile(indcur+1:indcur+count);% set the selected field number
    0110     end
    0111     indcur=indcur-1;
    0112 elseif strcmp(filelit(end-2:end),'-_-_')%new  nomenclature appendix num1-num2_num_a-num_b
    0113     field_count=num0;
    0114     str2=num1;
    0115     str_a=num2;
    0116     str_b=num3;
    0117     nom_type='_i1-i2_j1-j2';
    0118     testsub=1;
    0119     indcur=separ0-1;
    0120 elseif strcmp(filelit(end-2:end),'_-_')%new  nomenclature appendix num1-num2_num_a
    0121     field_count=num1;
    0122     str2=num2;
    0123     str_a=num3;
    0124     nom_type='_i1-i2_j';
    0125     testsub=1;
    0126     indcur=separ1-1;
    0127 elseif strcmp(filelit(end-2:end),'__-')%new  nomenclature appendix num1_num2-num2
    0128     indcur=separ1-1;
    0129     field_count=num1;
    0130     str_a=num2;
    0131     str_b=num3;
    0132     nom_type='_i_j1-j2';
    0133     testsub=1;
    0134 elseif strcmp(filelit(end-1:end),'_-')
    0135     indcur=separ2-1;
    0136     field_count=num2;
    0137     str2=num3;
    0138     str_a='';
    0139     nom_type='_i1-i2';
    0140     testsub=1;
    0141 elseif strcmp(filelit(end-1:end),'__')
    0142     indcur=separ2-1;
    0143     field_count=num2;
    0144     str2='';
    0145     str_a=num3;
    0146     nom_type='_i_j';
    0147 elseif strcmp(filelit(end),'_')
    0148     indcur=separ3-1;
    0149 %     field_count=num3;
    0150     str2='';
    0151     str_a='';
    0152     %detect zeros before the number
    0153 %     count=0; % extract the numerical appendix
    0154     if strcmp('0',RootFile(separ3+1)); % select the non-numerical characters
    0155         nom_type=['_%0' num2str(length(RootFile(separ3+1:end))) 'd'];
    0156     else
    0157         nom_type='_i';
    0158     end
    0159     field_count=RootFile(separ3+1:end);% set the selected field number'%03d'
    0160 elseif RootFile(indcur-2)=='_'% search appendix a,b,c,d
    0161     last=RootFile(indcur-1:indcur);
    0162     if isequal(length(last),2) && double(last(1)) >= 97 && double(last(1)) <= 122 ...% = 1 for letters
    0163             && double(last(2)) >= 97 && double(last(2)) <= 122
    0164           str_a=last(1);%put appendix a,b,c, ou d
    0165           str_b=last(2);%put appendix a,b,c, ou d
    0166 %           indcur=indcur-3;
    0167           separ0=indsel(end-3);
    0168         num0=RootFile(separ0+1:separ1-1);
    0169         field_count=num0;
    0170         indcur=separ0;
    0171         nom_type='#_ab';
    0172         testsub=1;
    0173     end
    0174 %search for other names with counter
    0175 else
    0176     if length(ext)>1
    0177             num=1;count=0; % extract the numerical appendix
    0178             while num==1;
    0179                 filascii=double(RootFile(indcur));
    0180                 if (48>filascii)||(filascii>57); % select the non-numerical characters
    0181                     num=0;
    0182                 else
    0183                     indcur=indcur-1; count=count+1;
    0184                 end
    0185             end
    0186             if count~=0
    0187                 field_count=RootFile(indcur+1:indcur+count);% set the selected field number'%03d'
    0188                 if isequal(field_count(1),'0')
    0189                     nbfigures=length(field_count);
    0190                     nom_type=['%0' num2str(nbfigures) 'd'];
    0191                 else
    0192                     nom_type='#';
    0193                 end
    0194             end
    0195     end
    0196 end
    0197             %select the root name in the file_input window
    0198 RootFile=RootFile(1:indcur);
    0199 if nbchar<4% put '*' before the name (remove at the end)
    0200    RootFile(1:4-nbchar)=[];
    0201 end
    0202 if testsub
    0203     [RootPath,subdir,extdir]=fileparts(RootPath);
    0204     subdir=[subdir extdir];
    0205 end