Changeset 610 for trunk/src/series
 Timestamp:
 Apr 14, 2013, 9:37:42 AM (11 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/series/civ_series.m
r609 r610 76 76 %% input files and indexing 77 77 NbField=1; 78 MaxIndex=cell2mat(Param.IndexRange.MaxIndex); 79 MinIndex=cell2mat(Param.IndexRange.MinIndex); 78 80 if isfield(Param,'InputTable') 79 RootPath=Param.InputTable{1,1};80 RootFile=Param.InputTable{1,3};81 SubDir=Param.InputTable{1,2};82 NomType=Param.InputTable{1,4};83 FileExt=Param.InputTable{1,5};84 PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1;85 PairCiv2='';86 if isfield(Param.ActionInput.PairIndices,'ListPairCiv2')87 PairCiv2=Param.ActionInput.PairIndices.ListPairCiv2;88 end89 MaxIndex=cell2mat(Param.IndexRange.MaxIndex);90 MinIndex=cell2mat(Param.IndexRange.MinIndex);91 81 [filecell,i_series,tild,j_series]=get_file_series(Param); 92 [FileType_A,FileInfo,MovieObject_A]=get_file_type(filecell{1,1}); 93 if strcmp(FileType_A,'civdata')% a civdata file has been introduced as input. 94 [FileType_A,FileInfo,MovieObject_A]=get_file_type(filecell{2,1}); 95 end 96 [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=... 97 find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex,MaxIndex); 98 if ~isempty(PairCiv2) 99 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=... 100 find_pair_indices(PairCiv2,i_series{1},j_series{1},MinIndex,MaxIndex); 101 check_bounds=check_bounds  check_bounds_Civ2; 102 end 103 i1_series_Civ1=i1_series_Civ1(~check_bounds); 104 i2_series_Civ1=i2_series_Civ1(~check_bounds); 105 j1_series_Civ1=j1_series_Civ1(~check_bounds); 106 j2_series_Civ1=j2_series_Civ1(~check_bounds); 107 if ~isempty(j1_series_Civ1) 108 FrameIndex_A_Civ1=j1_series_Civ1; 109 FrameIndex_B_Civ1=j2_series_Civ1; 82 if ~exist(filecell{1,1},'file') 83 displ('ERROR: the first input file does not exist') 84 return 110 85 else 111 FrameIndex_A_Civ1=i1_series_Civ1; 112 FrameIndex_B_Civ1=i2_series_Civ1; 113 end 114 if ~isempty(PairCiv2) 115 i1_series_Civ2=i1_series_Civ2(~check_bounds); 116 i2_series_Civ2=i2_series_Civ2(~check_bounds); 117 j1_series_Civ2=j1_series_Civ2(~check_bounds); 118 j2_series_Civ2=j2_series_Civ2(~check_bounds); 119 if ~isempty(j1_series_Civ2) 120 FrameIndex_A_Civ2=j1_series_Civ2; 121 FrameIndex_B_Civ2=j2_series_Civ2; 122 else 123 FrameIndex_A_Civ2=i1_series_Civ2; 124 FrameIndex_B_Civ2=i2_series_Civ2; 125 end 126 end 127 128 NbField=numel(i1_series_Civ1); 129 130 FileType_B=FileType_A; 131 MovieObject_B=MovieObject_A; 132 if size(filecell,1)>=2 && ~strcmp(filecell{1,1},filecell{2,1}) 133 [FileType_B,FileInfo,MovieObject_B]=get_file_type(filecell{2,1}); 134 end 135 end 136 86 FileType=get_file_type(filecell{1,1}); 87 iview_nc=0; 88 iview_A=0; 89 iview_B=0; 90 switch FileType 91 case 'civdata';% =1 for images 92 iview_nc=1; 93 if size(filecell,1)>=2 94 iview_A=2;iview_B=2; 95 if size(filecell,1)>=3 96 iview_B=3; 97 end 98 end 99 case {'image','multimage','mmreader','video'} 100 iview_A=1; 101 if size(filecell,1)>=2 102 iview_B=2; 103 end 104 end 105 end 106 if iview_A~=0 107 [FileType_A,FileInfo_A,VideoObject_A]=get_file_type(filecell{1,1}); 108 if isempty(strcmp(FileType_A,{'multimage','mmreader','video'})) 109 displ(['ERROR: the file line ' num2str(iview_A) ' must be an image']) 110 end 111 RootPath=Param.InputTable{1,1}; 112 RootFile=Param.InputTable{1,3}; 113 SubDir=Param.InputTable{1,2}; 114 NomType=Param.InputTable{1,4}; 115 FileExt=Param.InputTable{1,5}; 116 end 117 if iview_B==0 118 FileType_B=FileType_A; 119 VideoObject_B=VideoObject_A; 120 PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1; 121 PairCiv2=''; 122 if isfield(Param.ActionInput.PairIndices,'ListPairCiv2') 123 PairCiv2=Param.ActionInput.PairIndices.ListPairCiv2; 124 end 125 [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=... 126 find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex,MaxIndex); 127 if ~isempty(PairCiv2) 128 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=... 129 find_pair_indices(PairCiv2,i_series{1},j_series{1},MinIndex,MaxIndex); 130 check_bounds=check_bounds  check_bounds_Civ2; 131 end 132 i1_series_Civ1=i1_series_Civ1(~check_bounds); 133 i2_series_Civ1=i2_series_Civ1(~check_bounds); 134 j1_series_Civ1=j1_series_Civ1(~check_bounds); 135 j2_series_Civ1=j2_series_Civ1(~check_bounds); 136 if isempty(j_series{1}) 137 FrameIndex_A_Civ1=i1_series_Civ1; 138 FrameIndex_B_Civ1=i2_series_Civ1; 139 else 140 FrameIndex_A_Civ1=j1_series_Civ1; 141 FrameIndex_B_Civ1=j2_series_Civ1; 142 end 143 if ~isempty(PairCiv2) 144 i1_series_Civ2=i1_series_Civ2(~check_bounds); 145 i2_series_Civ2=i2_series_Civ2(~check_bounds); 146 j1_series_Civ2=j1_series_Civ2(~check_bounds); 147 j2_series_Civ2=j2_series_Civ2(~check_bounds); 148 if isempty(j_series{1}) 149 FrameIndex_A_Civ2=i1_series_Civ2; 150 FrameIndex_B_Civ2=i2_series_Civ2; 151 else 152 FrameIndex_A_Civ2=j1_series_Civ2; 153 FrameIndex_B_Civ2=j2_series_Civ2; 154 end 155 end 156 else 157 [FileType_B,FileInfo,VideoObject_B]=get_file_type(filecell{2,1}); 158 if isempty(strcmp(FileType_B,{'multimage','mmreader','video'})) 159 displ(['ERROR: the file line ' num2str(iview_B) ' must be an image']) 160 end 161 %TODO : introduce the second file series if relevant: case %displacement 162 end 163 end 164 NbField=numel(i1_series_Civ1); 137 165 138 166 %% Output directory … … 172 200 end 173 201 end 174 if strcmp(InputTable{iview,4},'*') 175 if ~isempty(VideoObject) 176 imainfo=get(VideoObject); 177 time=zeros(imainfo.NumberOfFrames+1,2); 178 time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)'; 179 TimeSource='video'; 180 % set(han:dles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec 181 ColorType='truecolor'; 182 elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.','')))  isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multiframe image 183 if ~isempty(InputTable{iview,2}) 184 imainfo=imfinfo(fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,5}])); 185 else 186 imainfo=imfinfo([FileBase InputTable{iview,5}]); 187 end 188 ColorType=imainfo.ColorType;%='truecolor' for color images 189 if length(imainfo) >1 %case of image with multiple frames 190 nbfield=length(imainfo); 191 nbfield_j=1; 192 end 193 end 194 end 195 196 %TODO: get time_A and time_B 197 198 if isempty(time) && (strcmp(FileType,'video')  strcmp(FileType,'mmreader')) 199 set(handles.ListPairMode,'Value',1); 200 dt=1/get(MovieObject,'FrameRate');%time interval between successive frames 201 if strcmp(NomTypeIma,'*') 202 set(handles.ListPairMode,'String',{'series(Di)'}) 203 MaxIndex_i=get(MovieObject,'NumberOfFrames'); 204 time=(dt*(0:MaxIndex_i1))';%list of image times 205 else 206 set(handles.ListPairMode,'String',[{'series(Dj)'};{'series(Di)'}]) 207 MaxIndex_i=max(i1_series(i1_series>0)); 208 MaxIndex_j=get(MovieObject,'NumberOfFrames'); 209 time=ones(MaxIndex_i,1)*(dt*(0:MaxIndex_j1));%list of image times 210 enable_j(handles,'on') 211 end 212 TimeUnit='s'; 213 end 202 if ~isempty(strcmp(FileType_A,{'mmreader','video'}))% case of video input 203 time=zeros(2,FileInfo_A.NumberOfFrames+1); 204 time(2,:)=(0:1/FileInfo_A.FrameRate:(FileInfo_A.NumberOfFrames)/FileInfo_A.FrameRate); 205 TimeSource='video'; 206 % set(han:dles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec 207 ColorType='truecolor'; 208 end 209 if length(FileInfo_A) >1 %case of image with multiple frames 210 nbfield=length(FileInfo_A); 211 nbfield_j=1; 212 end 213 214 214 %%%%% MAIN LOOP %%%%%% 215 216 MovieObject_A=[];217 215 for ifield=1:NbField 218 216 … … 232 230 else 233 231 ImageName_A=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield)); 234 [par_civ1.ImageA, MovieObject_A] = read_image(ImageName_A,FileType_A,MovieObject_A,FrameIndex_A_Civ1(ifield));232 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield)); 235 233 ImageName_B=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield)); 236 [par_civ1.ImageB, MovieObject_B] = read_image(ImageName_B,FileType_B,MovieObject_B,FrameIndex_B_Civ1(ifield));234 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield)); 237 235 end 238 236 ncfile=fullfile_uvmat(RootPath,OutputDir,RootFile,'.nc',NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),... 239 237 j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 240 par_civ1.ImageWidth=FileInfo .Width;241 par_civ1.ImageHeight=FileInfo .Height;238 par_civ1.ImageWidth=FileInfo_A.Width; 239 par_civ1.ImageHeight=FileInfo_A.Height; 242 240 list_param=(fieldnames(Param.ActionInput.Civ1))'; 243 241 Civ1_param=regexprep(list_param,'^.+','Civ1_$0');% insert 'Civ1_' before each string in list_param … … 246 244 Data.Civ1_ImageA=ImageName_A; 247 245 Data.Civ1_ImageB=ImageName_B; 248 Data.Civ1_Time=((time(i2_civ1(ifile)+1,j2_civ1(j)+1)+time(i1_civ1(ifile)+1,j1_civ1(j)+1))/2); 249 Data.Civ1_Dt=(time(i2_civ1(ifile)+1,j2_civ1(j)+1)time(i1_civ1(ifile)+1,j1_civ1(j)+1)); 246 i1=i1_series_Civ1(ifield); 247 i2=i1; 248 if ~isempty(i2_series_Civ1) 249 i2=i2_series_Civ1(ifield); 250 end 251 j1=1; 252 if ~isempty(j1_series_Civ1) 253 j1=j1_series_Civ1(ifield); 254 end 255 j2=j1; 256 if ~isempty(j2_series_Civ1) 257 j2=j2_series_Civ1(ifield); 258 end 259 Data.Civ1_Time=(time(j2+1,i2+1)+time(j1+1,i1+1))/2; 260 Data.Civ1_Dt=time(j2+1,i2+1)time(j1+1,i1+1) 250 261 for ilist=1:length(list_param) 251 262 Data.(Civ1_param{4+ilist})=Param.ActionInput.Civ1.(list_param{ilist}); … … 385 396 par_civ2.ImageA=par_civ1.ImageA; 386 397 else 387 [par_civ2.ImageA, MovieObject_A] = read_image(ImageName_A,FileType_A,MovieObject_A,FrameIndex_A_Civ2);398 [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ2); 388 399 end 389 400 ImageName_B_Civ2=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i2_series_Civ2(ifield),[],j2_series_Civ2(ifield)); … … 391 402 par_civ2.ImageB=par_civ1.ImageB; 392 403 else 393 [par_civ2.ImageB, MovieObject_B] = read_image(ImageName_B,FileType_B,MovieObject_B,FrameIndex_B_Civ2);404 [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2); 394 405 end 395 406 … … 919 930 find_pair_indices(str_civ,i_series,j_series,MinIndex,MaxIndex) 920 931 % 921 i1_series=i_series;% set of first image numbers932 i1_series=i_series;% set of first image indexes 922 933 i2_series=i_series; 923 934 j1_series=ones(size(i_series));% set of first image numbers 924 935 j2_series=ones(size(i_series)); 925 936 check_bounds=false(size(i_series)); 926 r=regexp(str_civ,'^\D(?<ind>[ij])= 937 r=regexp(str_civ,'^\D(?<ind>[ij])=(  )(?<num1>\d+)\(?<num2>\d+)','names'); 927 938 if ~isempty(r) 928 939 mode=['D' r.ind];
Note: See TracChangeset
for help on using the changeset viewer.