Changeset 334 for trunk/src/find_file_series.m
- Timestamp:
- Dec 14, 2011, 1:33:18 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_file_series.m
r332 r334 1 %'find_file_series': check the content onf an input fiel and find the corresponding file series1 %'find_file_series': check the content onf an input field and find the corresponding file series 2 2 %-------------------------------------------------------------------------- 3 3 % function [i1,i2,j1,j2,NomType,FileType,Object]=find_file_series(fileinput) … … 36 36 function [i1,i2,j1,j2,NomType,FileType,Object]=find_file_series(fileinput) 37 37 %------------------------------------------------------------------------ 38 i1= NaN;%default39 i2= NaN;%default40 j1= NaN;%default41 j2= NaN;%default38 i1=[];%default 39 i2=[];%default 40 j1=[];%default 41 j2=[];%default 42 42 43 43 %% 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); 45 46 46 47 %% check for particular file types: images, movies, civ data 47 48 FileType=''; 48 49 Object=[]; 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 50 switch 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 95 end 96 if strcmp(NomType,'')||strcmp(NomType,'*') 97 [RootPath,RootFile]=fileparts(fileinput);% case of constant name (no indexing) 98 %% get the list of existing files 59 99 else 60 try61 Data=nc2struct(fileinput,'ListGlobalAttribute',{'absolut_time_T0','Conventions'});62 if ~isempty(Data,'absolut_time_T0')63 FileType='civx'; % test for civx velocity fields64 elseif strcmp(Data.Conventions','uvmat/civdata')65 FileType='civdata'; % test for civx velocity fields66 else67 FileType='netcdf';68 end69 end70 try71 Object=VideoReader(fileinput);72 NomType='*';73 FileType='video';74 i1=1;75 i2=get(Object,'NumberOfFrames');76 [RootPath,RootFile]=fileparts(fileinput);77 end78 end79 80 %% get the list of existing files81 if ~strcmp(NomType,'*')82 100 if strcmp(SubDir,'') 83 101 filebasesub=fullfile(RootPath,RootFile); … … 95 113 end 96 114 dirpair=dir([filebasesub detect_string FileExt]); 97 % switch NomType %TODO: complement for other cases98 % 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 % end113 115 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) 118 125 i2(ifile)=i1(ifile); 126 else 127 i2(ifile)=i2_ifile; 119 128 end 120 j1(ifile)=stra2num(str_a);121 if is nan(j1(ifile))129 end 130 if isempty(j1_ifile) 122 131 j1(ifile)=1; 132 else 133 j1(ifile)=j1_ifile; 123 134 end 124 j2(ifile)=stra2num(str_b); 125 if isnan(j2(ifile)) 135 if isempty(j2_ifile) 126 136 j2(ifile)=j1(ifile); 137 else 138 j2(ifile)=j2_ifile; 127 139 end 128 end 129 140 end 141 % TODO : sort by reference index 130 142 % update the NomType from the minimal index detected (to deal with number strings beginning by 0) 131 143 [~,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 133 149 end
Note: See TracChangeset
for help on using the changeset viewer.