Changeset 783 for trunk/src/find_file_series.m
- Timestamp:
- Jun 5, 2014, 10:39:28 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_file_series.m
r667 r783 1 1 %'find_file_series': check the content of an input file and find the corresponding file series 2 2 %-------------------------------------------------------------------------- 3 % function [RootPath, RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object,i1_input,i2_input,j1_input,j2_input]=find_file_series(fileinput)3 % function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,Object,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput,checkxml) 4 4 % 5 5 % OUTPUT: 6 % RootPath: path to the dir containing the input file 7 % SubDir: data dir containing the input file series 6 8 % RootFile: root file detected in fileinput, possibly modified for movies (indexing is then done on image view, not file) 7 9 % i1_series(pair,ref_j+1, ref_i+1),i2_series,j1_series,j2_series: set of indices (i1,i2,j1,j2) sorted by ref index ref_i, ref_j, and pairindex in case of multiple pairs with the same ref 8 10 % (ref_i+1 is used to deal with the image index zero sometimes used) 9 11 % NomType: nomenclature type corrected after checking the first file (problem of 0 before the number string) 10 % FileType: type of file, = 11 % = 'image', usual image as recognised by Matlab 12 % = 'multimage', image series stored in a single file 13 % = 'civx', netcdf file with civx convention 14 % = 'civdata', civ data with new convention 15 % = 'netcdf' other netcdf files 16 % = 'video': movie recognised by VideoReader (e;g. avi) 17 % MovieObject: video object (=[] otherwise) 12 % FileInfo: structure containing info on the input files (assumed identical on the whole series) 13 % FileInfo.FileType: type of file, = 14 % = 'image', usual image as recognised by Matlab 15 % = 'multimage', image series stored in a single file 16 % = 'civx', netcdf file with civx convention 17 % = 'civdata', civ data with new convention 18 % = 'netcdf' other netcdf files 19 % = 'video': movie recognised by VideoReader (e;g. avi) 20 % MovieObject: video object (=[] otherwise 21 % i1_input,i2_input,j1_input,j2_input: indices of the input file, or of the first file in the series if the input file does not exist 18 22 % 19 23 %INPUT 20 % RootPath: path to the directory to be scanned24 % FilePath: path to the directory to be scanned 21 25 % fileinput: name (without path) of the input file sample 22 26 % checkxml: =1(default) take into account xml file existence to possibly include indexes in RootFile … … 39 43 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 40 44 41 function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,File Type,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput,checkxml)45 function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput,checkxml) 42 46 %------------------------------------------------------------------------ 43 47 … … 52 56 j1_series=zeros(1,1,1); 53 57 j2_series=zeros(1,1,1); 54 [File Type,FileInfo,MovieObject]=get_file_type(fullfileinput);58 [FileInfo,MovieObject]=get_file_type(fullfileinput); 55 59 if ~exist(FilePath,'dir') 56 60 return % don't go further if the dir path does not exist … … 233 237 NomType=regexprep(NomType,['^' NomTypePref],''); 234 238 %% update the file type if the input file does not exist (pb of 0001) 235 if isempty(File Type)236 [File Type,FileInfo,MovieObject]=get_file_type(fullfile(FilePath,dirpair(ifile_min).name));239 if isempty(FileInfo.FileType) 240 [FileInfo,MovieObject]=get_file_type(fullfile(FilePath,dirpair(ifile_min).name)); 237 241 end 238 242 end … … 247 251 %% introduce the frame index in case of movies or multimage type 248 252 if isfield(FileInfo,'NumberOfFrames') && FileInfo.NumberOfFrames >1 249 if isempty(i1_series) 253 if isempty(i1_series)% if there is no file index, i denotes the frame index 250 254 i1_series=zeros(FileInfo.NumberOfFrames+1,2);% first column =0 251 255 i1_series(:,2)=(0:FileInfo.NumberOfFrames)'; % second column=frame index -1 252 256 i1_input=1; 253 257 NomType='*'; 254 else 255 i1_series=i1_series(:,2)*ones(1,FileInfo.NumberOfFrames); 256 i1_series=[zeros(size(i1_series,1),1) i1_series]; 257 j1_series=ones(size(i1_series,1),1)*(1:FileInfo.NumberOfFrames); 258 j1_series=[zeros(size(i1_series,1),1) j1_series]; 259 % include the first index in the root name 260 r=regexp(NomType,'^(?<tiretnum>_?\d+)','names');%look for a number or _1 at the beginning of NomType 261 if ~isempty(r) 262 fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput 263 if isempty(regexp(r.tiretnum,'^_','once'))% if a separator '_' is not detected 264 rr=regexp(fileinput_end,'^(?<i1>\d+)','names'); 265 else% if a separator '_' is detected 266 rr=regexp(fileinput_end,'^(?<i1>_\d+)','names'); 267 end 268 if ~isempty(rr) 269 % RootFile=[RootFile rr.i1];% new root file 270 % NomTypePref=r.tiretnum; 271 % NomType=regexprep(NomType,['^' NomTypePref],''); 272 % i1_input=j1_input; 273 % i2_input=j2_input; 274 j1_input=1; 275 j2_input=[]; 258 else % if there is a file index, j denotes the frame index while i denotes the file index 259 if strcmp(NomType(end-1:end),'ab')% recognized as a pair 260 RootFile=fullfile_uvmat('','',RootFile,'',NomType,i1_input,i2_input,j1_input,j2_input);% restitute the root name without the detected indices 261 i1_series=zeros(FileInfo.NumberOfFrames+1,2);% first column =0 262 i1_series(:,2)=(0:FileInfo.NumberOfFrames)'; % second column=frame index -1 263 j1_series=[]; 264 i1_input=1; 265 NomType='*'; 266 else 267 i1_series=i1_series(:,2)*ones(1,FileInfo.NumberOfFrames);% 268 i1_series=[zeros(size(i1_series,1),1) i1_series]; 269 j1_series=ones(size(i1_series,1),1)*(1:FileInfo.NumberOfFrames);% 270 j1_series=[zeros(size(i1_series,1),1) j1_series]; 271 % include the first index in the root name 272 r=regexp(NomType,'^(?<tiretnum>_?\d+)','names');%look for a number or _1 at the beginning of NomType 273 if ~isempty(r) 274 fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput 275 if isempty(regexp(r.tiretnum,'^_','once'))% if a separator '_' is not detected 276 rr=regexp(fileinput_end,'^(?<i1>\d+)','names'); 277 else% if a separator '_' is detected 278 rr=regexp(fileinput_end,'^(?<i1>_\d+)','names'); 279 end 280 if ~isempty(rr) 281 j1_input=1; 282 j2_input=[]; 283 end 276 284 end 277 285 end
Note: See TracChangeset
for help on using the changeset viewer.