Changeset 371 for trunk/src/find_file_series.m
- Timestamp:
- Jan 14, 2012, 1:44:13 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_file_series.m
r365 r371 4 4 % 5 5 % OUTPUT: 6 % Root Path,RootFile: root path and root name detected in fileinput, possibly modified for movies (indexing is then done on image view, not file)6 % RootFile: root file detected in fileinput, possibly modified for movies (indexing is then done on image view, not file) 7 7 % i1_series(ref_i+1, ref_j+1,pair),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 8 % (ref_i+1 is used to deal with the image index zero sometimes used) … … 18 18 % 19 19 %INPUT 20 % fileinput: name (including path) of the input file 20 % RootPath: path to the directory to be scanned 21 % fileinput: name (without path) of the input file sample 21 22 % 22 23 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA … … 36 37 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 37 38 38 function [Root Path,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(fileinput)39 function [RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(RootPath,fileinput) 39 40 %------------------------------------------------------------------------ 40 41 41 42 %% get input root name and nomenclature type 42 [RootPath,SubDir,RootFile,tild,i2_input,j1_input,j2_input,FileExt,NomType]=fileparts_uvmat(fileinput); 43 [tild,tild,RootFile,tild,i2_input,j1_input,j2_input,FileExt,NomType]=fileparts_uvmat(fileinput); 44 fullfileinput=fullfile(RootPath,fileinput); 43 45 44 46 %% check for particular file types: images, movies, civ data … … 49 51 j1_series=zeros(1,1,1); 50 52 j2_series=zeros(1,1,1); 53 51 54 switch FileExt 52 55 % ancillary files, no field indexing … … 64 67 NomType=''; 65 68 otherwise 69 66 70 if ~isempty(FileExt)&& ~isempty(imformats(FileExt(2:end))) 67 71 try 68 imainfo=imfinfo(f ileinput);72 imainfo=imfinfo(fullfileinput); 69 73 FileType='image'; 70 74 if length(imainfo) >1 %case of image with multiple frames … … 72 76 FileType='multimage'; 73 77 i1_series=(1:length(imainfo))'; 74 [RootPath,RootFile]=fileparts(f ileinput);78 [RootPath,RootFile]=fileparts(fullfileinput); 75 79 end 76 80 end 77 81 else 78 82 try 79 Data=nc2struct(f ileinput,'ListGlobalAttribute','absolut_time_T0','Conventions');83 Data=nc2struct(fullfileinput,'ListGlobalAttribute','absolut_time_T0','Conventions'); 80 84 if ~isempty(Data.absolut_time_T0') 81 85 FileType='civx'; % test for civx velocity fields … … 88 92 try 89 93 if exist('VideoReader','file')%recent version of Matlab 90 Object=VideoReader(f ileinput);94 Object=VideoReader(fullfileinput); 91 95 else 92 Object=mmreader(f ileinput);%older Matlab function for movies96 Object=mmreader(fullfileinput);%older Matlab function for movies 93 97 end 94 98 NomType='*'; … … 100 104 101 105 if strcmp(NomType,'')||strcmp(NomType,'*') 102 if exist(fileinput,'file') 103 [RootPath,RootFile]=fileparts(fileinput);% case of constant name (no indexing) 104 else 105 RootPath=''; 106 if exist(fullfileinput,'file') 107 [tild,RootFile]=fileparts(fileinput);% case of constant name (no indexing) 108 else 106 109 RootFile=''; 107 110 end … … 163 166 end 164 167 end 165 detect_string=[ sep1 i1_str sep2 i2_str sep3 j1_str sep4 j2_str];%string used in regexp to detect file indices168 detect_string=['^' RootFile sep1 i1_str sep2 i2_str sep3 j1_str sep4 j2_str FileExt '$'];%string used in regexp to detect file indices 166 169 %find the string used to extract the relevant files with the command dir 167 star_string=[ '*'sep1 i1_star sep2 i2_star sep3 j1_star sep4 j2_star '*'];170 star_string=[RootFile sep1 i1_star sep2 i2_star sep3 j1_star sep4 j2_star '*']; 168 171 wd=pwd;%current working directory 169 RR=fullfile(RootPath,SubDir);170 cd (R R)% move to the local dir to save time in the operation dir.171 dirpair=dir([ RootFilestar_string FileExt]);% look for relevant files in the file directory172 %RR=fullfile(RootPath,SubDir); 173 cd (RootPath)% move to the local dir to save time in the operation dir. 174 dirpair=dir([star_string FileExt]);% look for relevant files in the file directory 172 175 cd(wd) 173 176 nbpair=numel(dirpair);
Note: See TracChangeset
for help on using the changeset viewer.