Changeset 997 for trunk/src/series
- Timestamp:
- Feb 6, 2017, 8:05:39 PM (8 years ago)
- Location:
- trunk/src/series
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/check_data_files.m
r984 r997 52 52 function ParamOut=check_data_files(Param) 53 53 54 ParamOut=[]; 54 55 %% input preparation mode (no RUN) 55 56 if isstruct(Param) && isequal(Param.Action.RUN,0) -
trunk/src/series/civ_series.m
r996 r997 224 224 225 225 %% check the first image pair 226 try226 % try 227 227 if Param.ActionInput.CheckCiv1% Civ1 is performed 228 first_ima=1; 229 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1),[],j1_series_Civ1(1)); 230 if checkrun 231 if ~exist(ImageName_A,'file') 232 disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun) 233 return 234 end 235 else 236 % for ifile=1:numel(i1_series_Civ1) 237 % if 238 end 239 [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A); 240 FileType_A=FileInfo_A.FileType; 241 if strcmp(FileInfo_A.FileType,'netcdf') 242 FieldName_A=Param.InputFields.FieldName; 243 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A}); 244 par_civ1.ImageA=DataIn.(FieldName_A); 245 else 246 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(1)); 247 end 248 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(1),[],j2_series_Civ1(1)); 249 if ~exist(ImageName_B,'file') 250 disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun) 251 return 252 end 253 [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B); 254 FileType_B=FileInfo_B.FileType; 255 if strcmp(FileInfo_B.FileType,'netcdf') 256 FieldName_B=Param.InputFields.FieldName; 257 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B}); 258 par_civ1.ImageB=DataIn.(FieldName_B); 259 else 260 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(1)); 261 end 228 % ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1),[],j1_series_Civ1(1)); 229 % [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A); 230 % FileType_A=FileInfo_A.FileType; 231 % if strcmp(FileInfo_A.FileType,'netcdf') 232 % FieldName_A=Param.InputFields.FieldName; 233 % [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A}); 234 % par_civ1.ImageA=DataIn.(FieldName_A); 235 % else 236 % [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(1)); 237 % end 238 % ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(1),[],j2_series_Civ1(1)); 239 % if ~exist(ImageName_B,'file') 240 % disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun) 241 % return 242 % end 243 % [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B); 244 % FileType_B=FileInfo_B.FileType; 245 % if strcmp(FileInfo_B.FileType,'netcdf') 246 % FieldName_B=Param.InputFields.FieldName; 247 % [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B}); 248 % par_civ1.ImageB=DataIn.(FieldName_B); 249 % else 250 % [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(1)); 251 % end 262 252 NbField=numel(i1_series_Civ1); 263 253 elseif Param.ActionInput.CheckCiv2 % Civ2 is performed without Civ1 264 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ2(1),[],j1_series_Civ2(1));265 if ~exist(ImageName_A,'file')266 disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun)267 return268 end269 [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A);270 FileType_A=FileInfo_A.FileType;271 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileInfo_A.FileType,VideoObject_A,FrameIndex_A_Civ2(1));272 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ2(1),[],j2_series_Civ2(1));273 if ~exist(ImageName_B,'file')274 disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun)275 return276 end277 [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B);278 FileType_B=FileInfo_B.FileType;279 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2(1));254 % ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ2(1),[],j1_series_Civ2(1)); 255 % if ~exist(ImageName_A,'file') 256 % disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun) 257 % return 258 % end 259 % [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A); 260 % FileType_A=FileInfo_A.FileType; 261 % [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileInfo_A.FileType,VideoObject_A,FrameIndex_A_Civ2(1)); 262 % ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ2(1),[],j2_series_Civ2(1)); 263 % if ~exist(ImageName_B,'file') 264 % disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun) 265 % return 266 % end 267 % [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B); 268 % FileType_B=FileInfo_B.FileType; 269 % [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2(1)); 280 270 NbField=numel(i1_series_Civ2); 281 271 else 282 272 NbField=numel(i1_series_Civ1);% no image used (only fix or patch) TO CHECK 283 273 end 284 catch ME285 if ~isempty(ME.message)286 disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun)287 return288 end289 end274 % catch ME 275 % if ~isempty(ME.message) 276 % disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun) 277 % return 278 % end 279 % end 290 280 291 281 … … 326 316 end 327 317 end 328 if isempty(Time) && ~isempty(find(strcmp(FileType_A,{'mmreader','video','cine_phantom'})))% case of video input 329 Time=zeros(FileInfo_A.NumberOfFrames+1,2); 330 Time(:,2)=(0:1/FileInfo_A.FrameRate:(FileInfo_A.NumberOfFrames)/FileInfo_A.FrameRate)'; 331 TimeSource='video'; 332 ColorType='truecolor'; 333 end 334 if isempty(Time)% Time = index i +0.001 index j by default 335 %MinIndex_i=min(i1_series_Civ1); 336 MaxIndex_i=max(i2_series_Civ1); 337 %MinIndex_j=min(j1_series_Civ1); 338 MaxIndex_j=max(j2_series_Civ1); 339 Time=(1:MaxIndex_i)'*ones(1,MaxIndex_j); 340 Time=Time+0.001*ones(MaxIndex_i,1)*(1:MaxIndex_j); 341 Time=[zeros(1,MaxIndex_j);Time];% insert a first line of zeros 342 Time=[zeros(MaxIndex_i+1,1) Time];% insert a first column of zeros 343 end 344 345 if length(FileInfo_A) >1 %case of image with multiple frames 346 nbfield=length(FileInfo_A); 347 nbfield_j=1; 348 end 318 319 349 320 end 350 321 351 322 %%%%% MAIN LOOP %%%%%% 352 323 maskname='';% initiate the mask name 353 tic; 324 FileType_A=''; 325 FileType_B=''; 354 326 CheckOverwrite=1;%default 355 327 if isfield(Param,'CheckOverwrite') … … 357 329 end 358 330 for ifield=1:NbField 331 tic 359 332 if ~isempty(RUNHandle)% update the waitbar in interactive mode with GUI series (checkrun=1) 360 333 update_waitbar(WaitbarHandle,ifield/NbField) … … 382 355 end 383 356 end 384 ncfile_out=ncfile;% by default 357 ncfile_out=ncfile;% by default 385 358 if isfield (Param.ActionInput,'Civ2') 386 359 i1_civ2=i1_series_Civ2(ifield); … … 412 385 if isfield (Param.ActionInput,'Civ1') 413 386 if CheckInputFile 414 disp('civ1 started')387 disp('civ1 started') 415 388 end 416 389 par_civ1=Param.ActionInput.Civ1; … … 418 391 try 419 392 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield)); 420 if strcmp(File Info_A.FileType,'netcdf')% case of input images in format netcdf393 if strcmp(FileExt_A,'.nc')% case of input images in format netcdf 421 394 FieldName_A=Param.InputFields.FieldName; 422 395 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A}); 423 396 par_civ1.ImageA=DataIn.(FieldName_A); 424 397 else % usual image formats for image A 398 if isempty(FileType_A) 399 [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A); 400 FileType_A=FileInfo_A.FileType; 401 if isempty(Time) && ~isempty(find(strcmp(FileType_A,{'mmreader','video','cine_phantom'})))% case of video input 402 Time=zeros(FileInfo_A.NumberOfFrames+1,2); 403 Time(:,2)=(0:1/FileInfo_A.FrameRate:(FileInfo_A.NumberOfFrames)/FileInfo_A.FrameRate)'; 404 TimeSource='video'; 405 ColorType='truecolor'; 406 end 407 if ~isempty(FileType_A) && isempty(Time)% Time = index i +0.001 index j by default 408 MaxIndex_i=max(i2_series_Civ1); 409 MaxIndex_j=max(j2_series_Civ1); 410 Time=(1:MaxIndex_i)'*ones(1,MaxIndex_j); 411 Time=Time+0.001*ones(MaxIndex_i,1)*(1:MaxIndex_j); 412 Time=[zeros(1,MaxIndex_j);Time];% insert a first line of zeros 413 Time=[zeros(MaxIndex_i+1,1) Time];% insert a first column of zeros 414 end 415 end 416 if ~exist(ImageName_A,'file') 417 disp([ImageName_A ' missing']) 418 continue 419 end 425 420 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield)); 426 421 end 427 422 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield)); 428 if strcmp(File Info_B.FileType,'netcdf') % case of input images in format netcdf423 if strcmp(FileExt_B,'.nc') % case of input images in format netcdf 429 424 FieldName_B=Param.InputFields.FieldName; 430 425 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B}); 431 426 par_civ1.ImageB=DataIn.(FieldName_B); 432 427 else % usual image formats for image B 428 if isempty(FileType_B) 429 [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B); 430 FileType_B=FileInfo_B.FileType; 431 end 432 if ~exist(ImageName_B,'file') 433 disp([ImageName_B ' missing']) 434 continue 435 end 433 436 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield)); 434 437 end … … 465 468 Data.Civ1_Dt=1;% Time interval is 1, to yield displacement instead of velocity=displacement/Dt at reading 466 469 else 467 Data.Civ1_Time=(Time(i2+1,j2+1)+Time(i1+1,j1+1))/2;% the Time is the Time at the middle of the image pair468 Data.Civ1_Dt=Time(i2+1,j2+1)-Time(i1+1,j1+1);470 Data.Civ1_Time=(Time(i2+1,j2+1)+Time(i1+1,j1+1))/2;% the Time is the Time at the middle of the image pair 471 Data.Civ1_Dt=Time(i2+1,j2+1)-Time(i1+1,j1+1); 469 472 end 470 473 for ilist=1:length(list_param) … … 555 558 %% Fix1 556 559 if isfield (Param.ActionInput,'Fix1') 557 560 disp('fix1 started') 558 561 if ~isfield (Param.ActionInput,'Civ1')% if we use existing Civ1, remove previous data beyond Civ1 559 562 Fix1_attr=find(strcmp('Fix1',Data.ListGlobalAttribute)); … … 630 633 par_civ2.ImageA=[]; 631 634 par_civ2.ImageB=[]; 632 % i1_civ2=i1_series_Civ2(ifield);633 % i2_civ2=i1_civ2;634 % if ~isempty(i2_series_Civ2)635 % i2_civ2=i2_series_Civ2(ifield);636 % end637 % j1_civ2=1;638 % if ~isempty(j1_series_Civ2)639 % j1_civ2=j1_series_Civ2(ifield);640 % end641 % j2_civ2=i1_civ2;642 % if ~isempty(j2_series_Civ2)643 % j2_civ2=j2_series_Civ2(ifield);644 % end635 % i1_civ2=i1_series_Civ2(ifield); 636 % i2_civ2=i1_civ2; 637 % if ~isempty(i2_series_Civ2) 638 % i2_civ2=i2_series_Civ2(ifield); 639 % end 640 % j1_civ2=1; 641 % if ~isempty(j1_series_Civ2) 642 % j1_civ2=j1_series_Civ2(ifield); 643 % end 644 % j2_civ2=i1_civ2; 645 % if ~isempty(j2_series_Civ2) 646 % j2_civ2=j2_series_Civ2(ifield); 647 % end 645 648 ImageName_A_Civ2=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_civ2,[],j1_civ2); 646 649 … … 656 659 [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B_Civ2,FileType_B,VideoObject_B,FrameIndex_B_Civ2(ifield)); 657 660 end 658 % if strcmp(Param.ActionInput.ListCompareMode,'PIV')659 % ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1,i2,j1,j2);660 % else % displacement661 % ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i2,[],j2);662 % end661 % if strcmp(Param.ActionInput.ListCompareMode,'PIV') 662 % ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1,i2,j1,j2); 663 % else % displacement 664 % ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i2,[],j2); 665 % end 663 666 par_civ2.ImageWidth=FileInfo_A.Width; 664 667 par_civ2.ImageHeight=FileInfo_A.Height; … … 784 787 Data.Civ2_ImageA=ImageName_A; 785 788 Data.Civ2_ImageB=ImageName_B; 786 789 if strcmp(Param.ActionInput.ListCompareMode,'displacement') 787 790 Data.Civ2_Time=Time(i2_civ2+1,j2_civ2+1);% the Time is the Time of the secodn image 788 791 Data.Civ2_Dt=1;% Time interval is 1, to yield displacement instead of velocity=displacement/Dt at reading 789 790 Data.Civ2_Time=(Time(i2_civ2+1,j2_civ2+1)+Time(i1_civ2+1,j1_civ2+1))/2;791 Data.Civ2_Dt=Civ2_Dt;792 792 else 793 Data.Civ2_Time=(Time(i2_civ2+1,j2_civ2+1)+Time(i1_civ2+1,j1_civ2+1))/2; 794 Data.Civ2_Dt=Civ2_Dt; 795 end 793 796 end 794 797 for ilist=1:length(list_param) … … 822 825 disp_uvmat('ERROR',errormsg,checkrun) 823 826 return 824 end 827 end 825 828 elseif isfield(Param,'Civ2_X')% use Civ2 data as input in Param (test mode) 826 829 Data.ListGlobalAttribute={}; … … 893 896 Data.VarAttribute{nbvar+6}.Role='vector_x'; 894 897 Data.VarAttribute{nbvar+7}.Role='vector_y'; 895 Data.Civ2_U_smooth=Data.Civ2_U; 896 Data.Civ2_V_smooth=Data.Civ2_V; 898 Data.Civ2_U_smooth=Data.Civ2_U; 899 Data.Civ2_V_smooth=Data.Civ2_V; 897 900 if isfield(Data,'Civ2_FF') 898 901 ind_good=find(Data.Civ2_FF==0); … … 1034 1037 end 1035 1038 check_undefined=(par_civ.Mask<200 & par_civ.Mask>=20 ); 1036 % par_civ.ImageA(check_undefined)=0;% put image A to zero (i.e. the min image value) in the undefined area1037 % par_civ.ImageB(check_undefined)=0;% put image B to zero (i.e. the min image value) in the undefined area1039 % par_civ.ImageA(check_undefined)=0;% put image A to zero (i.e. the min image value) in the undefined area 1040 % par_civ.ImageB(check_undefined)=0;% put image B to zero (i.e. the min image value) in the undefined area 1038 1041 end 1039 1042
Note: See TracChangeset
for help on using the changeset viewer.