Changeset 1022 for trunk/src/find_file_series.m
- Timestamp:
- Dec 11, 2017, 1:15:03 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_file_series.m
r1011 r1022 49 49 50 50 %% get input root name and nomenclature type 51 if isempty(regexp(FilePath,'^http://')) 51 52 fullfileinput=fullfile(FilePath,fileinput);% input file name with path 53 else 54 fullfileinput=[FilePath '/' fileinput]; 55 end 52 56 [FileInfo,MovieObject]=get_file_info(fullfileinput); 53 57 54 58 %% check for particular file types: images, movies, civ data 55 %if isfield(FileInfo,'FileIndexing') && strcmp(FileInfo.FileIndexing,'on') 56 [RootPath,SubDir,RootFile,i1_input,i2_input,j1_input,j2_input,FileExt,NomType]=fileparts_uvmat(fullfileinput); 57 % if ~isempty(regexp(SubDir,'^level\d+$')) && exist([RootPath '.xml'],'file') 58 % NomType='level'; 59 % end 60 i1_series=zeros(1,1,1); 61 i2_series=zeros(1,1,1); 62 j1_series=zeros(1,1,1); 63 j2_series=zeros(1,1,1); 64 checkfileindexing=1; 65 %else % no file indexing 66 % [PathDir,RootFile]=fileparts(fullfileinput); 67 % [RootPath,SubDir,DirExt]=fileparts(PathDir); 68 % SubDir=[SubDir DirExt];% include part after . in the name (considered as a file extension) 69 % NomType='*'; 70 % i1_series=[];i2_series=[];j1_series=[];j2_series=[]; 71 % i1_input=1;i2_input=[];j1_input=[];j2_input=[]; 72 % if exist(fullfileinput,'file')~=2 73 % RootFile=''; 74 % return 75 % end 76 % checkfileindexing=0; 77 %end 78 if ~exist(FilePath,'dir') 59 [RootPath,SubDir,RootFile,i1_input,i2_input,j1_input,j2_input,FileExt,NomType]=fileparts_uvmat(fullfileinput); 60 i1_series=zeros(1,1,1); 61 i2_series=zeros(1,1,1); 62 j1_series=zeros(1,1,1); 63 j2_series=zeros(1,1,1); 64 checkfileindexing=1; 65 if isempty(regexp(FilePath,'^http://')) && ~exist(FilePath,'dir') 79 66 return % don't go further if the dir path does not exist 80 67 end … … 109 96 j1_input=[]; 110 97 j2_input=[]; 111 elseif exist([RootPath '.xml'],'file')% new convention with j indices in sub-folders level0, 1...112 rj=regexp(SubDir,'^level(?<j1>\d+)$','names');113 if ~isempty(rj)114 j1_input=rj.j1;115 NomType='level';116 [RootPath,SubDir]=fileparts(RootPath);117 end118 98 end 119 99 end … … 134 114 %Look for cases with letter indexing for the second index 135 115 r=regexp(NomType,'^(?<sep1>_?)(?<i1>\d+)(?<sep2>_?)(?<j1>[a|A])(?<j2>[b|B]?)$','names'); 136 if ~isempty(r) 116 if ~isempty(r) %indexing image pair with letters 137 117 sep1=r.sep1; 138 118 sep2=r.sep2; … … 175 155 176 156 detect_string=['^' RootFile sep1 i1_str i2_str sep2 j1_str j2_str FileExt '$'];%string used in regexp to detect file indices 157 % if isempty(regexp(FilePath,'^http://')) 177 158 %find the string used to extract the relevant files with the command dir 178 star_string=[RootFile sep1 i1_star i2_star sep2 j1_star j2_star FileExt]; 179 wd=pwd;%current working directory 180 cd (FilePath)% move to the local dir to save time in the operation dir. 181 dirpair=dir(star_string);% look for relevant files in the file directory 182 cd(wd) 183 nbpair=numel(dirpair); 159 % star_string=[RootFile sep1 i1_star i2_star sep2 j1_star j2_star FileExt]; 160 % wd=pwd;%current working directory 161 % cd (FilePath)% move to the local dir to save time in the operation dir. 162 % dirpair=dir(star_string);% look for relevant files in the file directory 163 % cd(wd) 164 % else 165 ListStruct=dir_uvmat(FilePath); 166 ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray 167 ListFiles=ListCells(1,:);%list of file names 168 rr=regexp(ListFiles,detect_string,'names'); 169 % end 170 % nbpair=numel(dirpair); 171 nbpair=numel(rr); 184 172 ref_i_list=zeros(1,nbpair); 185 173 ref_j_list=zeros(1,nbpair); … … 189 177 % scan the list of relevant files, extract the indices 190 178 for ifile=1:nbpair 191 rr=regexp(dirpair(ifile).name,detect_string,'names');192 if ~isempty(rr )193 i1=str2num(rr .i1);194 i2=str2num(regexprep(rr .i2,'^-',''));195 j1=stra2num(regexprep(rr .j1,'^_',''));196 j2=stra2num(regexprep(rr .j2,'^-',''));179 % rr=regexp(dirpair(ifile).name,detect_string,'names'); 180 if ~isempty(rr{ifile}) 181 i1=str2num(rr{ifile}.i1); 182 i2=str2num(regexprep(rr{ifile}.i2,'^-','')); 183 j1=stra2num(regexprep(rr{ifile}.j1,'^_','')); 184 j2=stra2num(regexprep(rr{ifile}.j2,'^-','')); 197 185 ref_i=i1; 198 186 if isempty(i2_input) … … 263 251 if ~isempty(ind_select) 264 252 [tild,ifile_min]=min(ref_ij(ind_select)); 265 [tild,tild,tild,tild,tild,tild,tild,tild,NomType]=fileparts_uvmat( dirpair(ind_select(ifile_min)).name);% update the representation of indices (number of 0 before the number)253 [tild,tild,tild,tild,tild,tild,tild,tild,NomType]=fileparts_uvmat(ListFiles{ind_select(ifile_min)});% update the representation of indices (number of 0 before the number) 266 254 NomType=regexprep(NomType,['^' NomTypePref],''); 267 255 %% update the file type if the input file does not exist (pb of 0001) 268 256 if isempty(FileInfo.FileType) 269 [FileInfo,MovieObject]=get_file_info(fullfile(FilePath, dirpair(ifile_min).name));257 [FileInfo,MovieObject]=get_file_info(fullfile(FilePath,ListFiles(ifile_min))); 270 258 end 271 259 end
Note: See TracChangeset
for help on using the changeset viewer.