Ignore:
Timestamp:
Nov 14, 2010, 9:58:15 PM (13 years ago)
Author:
sommeria
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/name2display.m

    r120 r122  
    1313%   nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
    1414%   nom_type='*':constant name for a file representing a series (e.g. avi movie)
    15 %   nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png').
    16 %   nom_type='#', series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
    17 %   nom_type='_i_j': matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
    18 %   nom_type='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc')
     15%   nom_type='1','01',or '001'...': series of files with a single index i without separator(e.g. 'aa045.png').
     16%   nom_type='_1','_01','_001'...':  series of files with a single index i with separator '_'(e.g. 'aa_045.png').
     17%   nom_type='1a','1A','01a','01A',... with a numerical index and an index letter(e.g.'aa45b.png') (lower or upper case)
     18%   nom_type='_1a','_1A','_01a','_01A',...: idem, with a separator '_' before the index
     19%   nom_type='_1_1','_01_1',...: matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
     20%   nom_type='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc')
    1921%   nom_type='_i_j1-j2': pairs of j indices (e.g. 'aa_45_2-3.nc')
    2022%   nom_type='_i1-i2_j': pairs of i indices (e.g. 'aa_45-46_2.nc')
    21 %   nom_type='#a','#A", with a numerical index and an index letter(e.g.'aa045b.png') (lower or upper case)
    22 %   nom_type='raw_SMD', same as '#' but with no extension ext='', OBSOLETE
    23 %   nom_type='#_ab', from pairs of '#' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by '_i_j1-j2')
     23%   nom_type='_1_ab','1_ab','01_ab'..., from pairs of '#' images (e.g.'aa045bc.nc'), ext='.nc'
    2424%subdir: name of the subdirectory for netcdf files
    2525%
     
    4444
    4545        %recognize the name form
    46 filerawascii=double(RootFile);%ascci code
    47 val=(48>filerawascii)|(filerawascii>57); % test for the non-numerical characters
    48 indsel=find(val);% character indices of non numerical characters
     46% filerawascii=double(RootFile);%ascci code
     47% val=(48>filerawascii)|(filerawascii>57); % test for the non-numerical characters
     48indsel=regexp(RootFile,'\D');% character indices of non numerical characters
    4949filelit=RootFile(indsel);% fileraw name with numbers removed
    5050nbchar=length(indsel);
     
    6969penult=double(RootFile(indcur-1));%ascii code of the penultimate character
    7070testsub=0; %default
     71% case of an indexed series in a single file
    7172if strcmpi(ext,'.avi')
    7273     nom_type='*';
    73       %case of old image nomenclature
    74 elseif (strcmp(ext,'.png') || strcmp(ext,'')) &&  penult >= 48 && penult <= 57 && (last < 48 || last > 57)
    75     % if the penultimate character is a number and the last a letter
    76     % search the appendix a,b,c,
    77     str_a=last_str; %put appendix a,b,c....
    78     indcur=indcur-1;
    79     if strcmp(ext,'.png'), nom_type='#a'; end
    80     if strcmp(ext,''), nom_type='raw_SMD'; end     
    81     num=1;count=0; % extract the numerical appendix
    82     while num==1;
    83         filascii=double(RootFile(indcur));
    84         if (48>filascii)||(filascii>57); % select the non-numerical characters
    85             num=0;
    86         else
    87             indcur=indcur-1; count=count+1;
    88         end
     74%case of a numerical index follewed by a lower case letter (e.g. a,b,c):
     75%the penultimate character is a number and the last one a letter (lower case: last >= 97 && last <= 122
     76%                                                                 capital letter:  last >= 65 && last <= 90)                                                             
     77elseif  penult >= 48 && penult <= 57 && (last >= 65 && last <= 90)||(last >= 97 && last <= 122)
     78    str_a=last_str; %extract appendix a,b,c... or A,B,C... as output.
     79    ind_end=indcur-1; %current index just before the suffix letter
     80    indices_root=regexp(RootFile(1:indcur-1),'\D');%detect non digit characters
     81    indcur=max(indices_root);
     82    field_count=RootFile(indcur+1:ind_end);
     83    charstring=['%0' num2str(length(field_count)) 'd'];
     84    nom_type=num2str(1,charstring);
     85    if strcmp(RootFile(indcur),'_')
     86       nom_type=['_' nom_type];
     87       indcur=indcur-1;
    8988    end
    90     if count~=0             
    91             field_count=RootFile(indcur+1:indcur+count);% set the selected field number
    92     end
    93 elseif  penult >= 48 && penult <= 57  && (last <= 66 && last >= 65)% PCO camera Toulouse, end with A or B (NEW)
    94     % if the penultimate character is a number and the last a letter
    95     % search the appendix a,b,c,
    96     str_a=last_str; %put appendix a,b,c....
    97     indcur=indcur-1;
    98     num=1;count=0; % extract the numerical appendix
    99     while num==1;
    100         filascii=double(RootFile(indcur));
    101         if (48>filascii)||(filascii>57); % select the non-numerical characters
    102             num=0;
    103         else
    104             indcur=indcur-1; count=count+1;
    105         end
    106     end
    107     if strcmp('0',RootFile(indcur+1)); % select the non-numerical characters
    108         nom_type=['%0' num2str(length(RootFile(indcur+1:end-1))) 'dA'];
     89    if (last >= 65 && last <= 90)
     90        nom_type=[nom_type 'A'];
    10991    else
    110         nom_type='#A';
    111     end 
    112    
    113     if count~=0             
    114             field_count=RootFile(indcur+1:indcur+count);% set the selected field number
     92        nom_type=[nom_type 'a'];
    11593    end   
    116 %     indcur=indcur-1;
    11794elseif strcmp(filelit(end-2:end),'-_-_')%new  nomenclature appendix num1-num2_num_a-num_b
    11895    field_count=num0;
     
    149126    str2='';
    150127    str_a=num3;
    151     nom_type='_i_j';
     128    nom_type='_1_1';
    152129elseif strcmp(filelit(end),'_')
    153130    indcur=separ3-1;
     
    157134    %detect zeros before the number
    158135%     count=0; % extract the numerical appendix
    159     if strcmp('0',RootFile(separ3+1)); % select the non-numerical characters
    160         nom_type=['_%0' num2str(length(RootFile(separ3+1:end))) 'd'];
    161     else
    162         nom_type='_i';
    163     end 
    164     field_count=RootFile(separ3+1:end);% set the selected field number'%03d'
     136    field_count=RootFile(separ3+1:end);% set the selected field number'%03d'
     137    charstring=['%0' num2str(length(field_count)) 'd'];
     138    nom_type=['_' num2str(1,charstring)];
     139%     if strcmp('0',RootFile(separ3+1)); % select the non-numerical characters
     140%         nom_type=['_%0' num2str(length(RootFile(separ3+1:end))) 'd'];
     141%     else
     142%         nom_type='_i';
     143%     end 
     144     
    165145elseif RootFile(indcur-2)=='_'% search appendix a,b,c,d
    166146    last=RootFile(indcur-1:indcur);
    167     if isequal(length(last),2) && double(last(1)) >= 97 && double(last(1)) <= 122 ...% = 1 for letters
    168             && double(last(2)) >= 97 && double(last(2)) <= 122
     147    if isequal(length(last),2)
    169148          str_a=last(1);%put appendix a,b,c, ou d
    170149          str_b=last(2);%put appendix a,b,c, ou d
    171150%           indcur=indcur-3;
    172151          separ0=indsel(end-3);
    173         num0=RootFile(separ0+1:separ1-1);
    174         field_count=num0;
     152        field_count=RootFile(separ0+1:separ1-1);
    175153        indcur=separ0;
    176         nom_type='#_ab';
    177         testsub=1;
     154        if double(last) >= 97 & double(last)<= 122
     155            nom_type='_ab';
     156            testsub=1;
     157        elseif double(last) >= 65 & double(last) <= 90
     158            nom_type='_AB';
     159            testsub=1;
     160        end
     161        charstring=['%0' num2str(length(field_count)) 'd'];
     162        nom_type=[num2str(1,charstring) nom_type];
    178163    end
    179164%search for other names with counter
     
    191176            if count~=0   
    192177                field_count=RootFile(indcur+1:indcur+count);% set the selected field number'%03d'
    193                 if isequal(field_count(1),'0')
    194                     nbfigures=length(field_count);
    195                     nom_type=['%0' num2str(nbfigures) 'd'];
    196                 else
    197                     nom_type='#';
    198                 end
     178                charstring=['%0' num2str(length(field_count)) 'd'];
     179                nom_type=num2str(1,charstring);
     180%                 if isequal(field_count(1),'0')
     181%                     nbfigures=length(field_count);
     182%                     nom_type=['%0' num2str(nbfigures) 'd'];
     183%                 else
     184%                     nom_type='#';
     185%                 end
    199186            end
    200187    end
Note: See TracChangeset for help on using the changeset viewer.