Changeset 855 for trunk/src/series/civ_series.m
- Timestamp:
- Jan 23, 2015, 9:48:26 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/civ_series.m
r854 r855 5 5 % filter_tps: make interpolation-smoothing 6 6 %------------------------------------------------------------------------ 7 % function [Data,errormsg,result_conv]= civ_series(Param ,ncfile)7 % function [Data,errormsg,result_conv]= civ_series(Param) 8 8 % 9 9 %OUTPUT … … 13 13 % 14 14 %INPUT: 15 % Param: input images and processing parameters 16 % .Civ1: for civ1 17 % .Fix1: 18 % .Patch1: 19 % .Civ2: for civ2 20 % .Fix2: 21 % .Patch2: 22 % ncfile: name of a netcdf file to be created for the result (extension .nc) 23 % 15 % Param: Matlab structure of input parameters 16 % Param contains info of the GUI series using the fct read_GUI. 17 % Param.Action.RUN = 0 (to set the status of the GUI series) or =1 to RUN the computation 18 % Param.InputTable: sets the input file(s) 19 % if absent, the fct looks for input data in Param.ActionInput (test mode) 20 % Param.OutputSubDir: sets the folder name of output file(s, 21 % if absent no file is produced, result in the output structure Data (test mode) 22 % Param.ActionInput: substructure with the parameters provided by the GUI civ_input 23 % .Civ1: parameters for civ1 24 % .Fix1: parameters for fix1 25 % .Patch1: 26 % .Civ2: for civ2 27 % .Fix2: 28 % .Patch2: 29 24 30 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 25 31 % Copyright 2011-2014, LEGI / CNRS UJF G-INP, Joel.Sommeria@legi.grenoble-inp.fr … … 73 79 checkrun=0; 74 80 end 81 82 %% test input 75 83 if ~isfield(Param,'ActionInput') 76 84 disp_uvmat('ERROR','no parameter set for PIV',checkrun) 77 85 return 78 86 end 79 hseries=findobj(allchild(0),'Tag','series'); 80 RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series 81 WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series 82 83 %% input files and indexing 84 % NbField=1; 85 MaxIndex_i=Param.IndexRange.MaxIndex_i; 86 MinIndex_i=Param.IndexRange.MinIndex_i; 87 MaxIndex_j=ones(size(MaxIndex_i));MinIndex_j=ones(size(MinIndex_i)); 88 if isfield(Param.IndexRange,'MaxIndex_j')&& isfield(Param.IndexRange,'MinIndex_j') 89 MaxIndex_j=Param.IndexRange.MaxIndex_j; 90 MinIndex_j=Param.IndexRange.MinIndex_j; 91 end 92 if isfield(Param,'InputTable') 93 [tild,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 94 % iview_nc=0;% series index (iview) for an input nc file (for civ2 or patch2) 95 iview_A=0;% series index (iview) for the first image series 96 iview_B=0;% series index (iview) for the second image series (only non zero for option 'shift' comparing two image series ) 97 if Param.ActionInput.CheckCiv1 98 iview_A=1;% usual PIV, the image series is on the first line of the table 99 elseif Param.ActionInput.CheckCiv2 % civ2 is performed without Civ1, a netcdf file series is needed in the first table line 100 iview_A=2;% the second line is used for the input images of Civ2 101 end 102 if strcmp(Param.ActionInput.ListCompareMode,'shift') 103 iview_B=iview_A+1; % the second image series is on the next line of the input table 104 end 105 if iview_A~=0 106 RootPath_A=Param.InputTable{iview_A,1}; 107 RootFile_A=Param.InputTable{iview_A,3}; 108 SubDir_A=Param.InputTable{iview_A,2}; 109 NomType_A=Param.InputTable{iview_A,4}; 110 FileExt_A=Param.InputTable{iview_A,5}; 111 if iview_B==0 112 iview_B=iview_A;% the second image series is the same as the first 113 end 114 RootPath_B=Param.InputTable{iview_B,1}; 115 RootFile_B=Param.InputTable{iview_B,3}; 116 SubDir_B=Param.InputTable{iview_B,2}; 117 NomType_B=Param.InputTable{iview_B,4}; 118 FileExt_B=Param.InputTable{iview_B,5}; 119 end 120 121 PairCiv2=''; 122 switch Param.ActionInput.ListCompareMode 123 case 'PIV' 124 PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1; 125 if isfield(Param.ActionInput.PairIndices,'ListPairCiv2') 126 PairCiv2=Param.ActionInput.PairIndices.ListPairCiv2;%string which determines the civ2 pair 127 end 128 if iview_A==1% if Civ1 is performed 129 [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=... 130 find_pair_indices(PairCiv1,i1_series{1},j1_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j); 131 if ~isempty(PairCiv2) 132 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=... 133 find_pair_indices(PairCiv2,i1_series{1},j1_series{1},MinIndex_i(1),MaxIndex_i(1),MinIndex_j(1),MaxIndex_j(1)); 134 check_bounds=check_bounds | check_bounds_Civ2; 87 iview_A=0;%default values 88 NbField=1; 89 RUNHandle=[]; 90 CheckInputFile=isfield(Param,'InputTable');%= 1 in test use for TestCiv (no nc file involved) 91 CheckOutputFile=isfield(Param,'OutputSubDir');%= 1 in test use for TestPatch (no nc file produced) 92 93 %% input files and indexing (skipped in Test mode) 94 if CheckInputFile 95 hseries=findobj(allchild(0),'Tag','series'); 96 RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series 97 WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series 98 MaxIndex_i=Param.IndexRange.MaxIndex_i; 99 MinIndex_i=Param.IndexRange.MinIndex_i; 100 MaxIndex_j=ones(size(MaxIndex_i));MinIndex_j=ones(size(MinIndex_i)); 101 if isfield(Param.IndexRange,'MaxIndex_j')&& isfield(Param.IndexRange,'MinIndex_j') 102 MaxIndex_j=Param.IndexRange.MaxIndex_j; 103 MinIndex_j=Param.IndexRange.MinIndex_j; 104 end 105 if isfield(Param,'InputTable') 106 [tild,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 107 % iview_nc=0;% series index (iview) for an input nc file (for civ2 or patch2) 108 iview_A=0;% series index (iview) for the first image series 109 iview_B=0;% series index (iview) for the second image series (only non zero for option 'shift' comparing two image series ) 110 if Param.ActionInput.CheckCiv1 111 iview_A=1;% usual PIV, the image series is on the first line of the table 112 elseif Param.ActionInput.CheckCiv2 % civ2 is performed without Civ1, a netcdf file series is needed in the first table line 113 iview_A=2;% the second line is used for the input images of Civ2 114 end 115 if strcmp(Param.ActionInput.ListCompareMode,'shift') 116 iview_B=iview_A+1; % the second image series is on the next line of the input table 117 end 118 if iview_A~=0 119 RootPath_A=Param.InputTable{iview_A,1}; 120 RootFile_A=Param.InputTable{iview_A,3}; 121 SubDir_A=Param.InputTable{iview_A,2}; 122 NomType_A=Param.InputTable{iview_A,4}; 123 FileExt_A=Param.InputTable{iview_A,5}; 124 if iview_B==0 125 iview_B=iview_A;% the second image series is the same as the first 126 end 127 RootPath_B=Param.InputTable{iview_B,1}; 128 RootFile_B=Param.InputTable{iview_B,3}; 129 SubDir_B=Param.InputTable{iview_B,2}; 130 NomType_B=Param.InputTable{iview_B,4}; 131 FileExt_B=Param.InputTable{iview_B,5}; 132 end 133 134 PairCiv2=''; 135 switch Param.ActionInput.ListCompareMode 136 case 'PIV' 137 PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1; 138 if isfield(Param.ActionInput.PairIndices,'ListPairCiv2') 139 PairCiv2=Param.ActionInput.PairIndices.ListPairCiv2;%string which determines the civ2 pair 135 140 end 136 else% we start from an existing Civ1 file 137 i1_series_Civ1=i1_series{1}; 138 i2_series_Civ1=i2_series{1}; 139 j1_series_Civ1=j1_series{1}; 140 j2_series_Civ1=j2_series{1}; 141 NomTypeNc=Param.InputTable{1,4}; 142 if ~isempty(PairCiv2) 143 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds,NomTypeNc]=... 144 find_pair_indices(PairCiv2,i1_series{2},j1_series{2},MinIndex_i(2),MaxIndex_i(2),MinIndex_j(2),MaxIndex_j(2)); 141 if iview_A==1% if Civ1 is performed 142 [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=... 143 find_pair_indices(PairCiv1,i1_series{1},j1_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j); 144 if ~isempty(PairCiv2) 145 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=... 146 find_pair_indices(PairCiv2,i1_series{1},j1_series{1},MinIndex_i(1),MaxIndex_i(1),MinIndex_j(1),MaxIndex_j(1)); 147 check_bounds=check_bounds | check_bounds_Civ2; 148 end 149 else% we start from an existing Civ1 file 150 i1_series_Civ1=i1_series{1}; 151 i2_series_Civ1=i2_series{1}; 152 j1_series_Civ1=j1_series{1}; 153 j2_series_Civ1=j2_series{1}; 154 NomTypeNc=Param.InputTable{1,4}; 155 if ~isempty(PairCiv2) 156 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds,NomTypeNc]=... 157 find_pair_indices(PairCiv2,i1_series{2},j1_series{2},MinIndex_i(2),MaxIndex_i(2),MinIndex_j(2),MaxIndex_j(2)); 158 end 145 159 end 146 end 147 % i1_series_Civ1=i1_series_Civ1(~check_bounds); 148 % i2_series_Civ1=i2_series_Civ1(~check_bounds); 149 % j1_series_Civ1=j1_series_Civ1(~check_bounds); 150 % j2_series_Civ1=j2_series_Civ1(~check_bounds); 151 case 'displacement' 152 i1_series_Civ1=Param.ActionInput.OriginIndex*ones(size(i1_series{1})); 153 i2_series_Civ1=i1_series{1};i2_series_Civ2=i1_series{1}; 154 j1_series_Civ1=ones(size(i1_series{1}));% first j index is 1 155 if isempty(j1_series_Civ1) 156 j2_series_Civ1=ones(size(i1_series{1})); 157 else 158 j2_series_Civ1=j1_series_Civ1; 159 end 160 i1_series_Civ2=i1_series_Civ1; 161 j1_series_Civ2=j1_series_Civ1; 162 j2_series_Civ2=j2_series_Civ1; 163 NomTypeNc=NomType; 164 case 'shift' 165 i1_series_Civ1=i1_series{1};i1_series_Civ2=i1_series{1}; 166 i2_series_Civ1=i1_series{2};i2_series_Civ2=i1_series{2}; 167 if isempty(j1_series{1}) 168 j1_series_Civ1=ones(size(i1_series{1})); 169 j2_series_Civ1=ones(size(i1_series{2})); 170 else 171 j1_series_Civ1=j1_series{1}; 172 j2_series_Civ1=j1_series{2}; 173 end 174 j1_series_Civ2=j1_series_Civ1; 175 j2_series_Civ2=j2_series_Civ1; 176 NomTypeNc=NomType_A; 177 end 178 if isempty(j1_series_Civ1) 179 FrameIndex_A_Civ1=i1_series_Civ1; 180 FrameIndex_B_Civ1=i2_series_Civ1; 181 j1_series_Civ1=ones(size(i1_series_Civ1)); 182 j2_series_Civ1=ones(size(i1_series_Civ1)); 183 else 184 FrameIndex_A_Civ1=j1_series_Civ1; 185 FrameIndex_B_Civ1=j2_series_Civ1; 186 end 187 if isempty(PairCiv2) 160 % i1_series_Civ1=i1_series_Civ1(~check_bounds); 161 % i2_series_Civ1=i2_series_Civ1(~check_bounds); 162 % j1_series_Civ1=j1_series_Civ1(~check_bounds); 163 % j2_series_Civ1=j2_series_Civ1(~check_bounds); 164 case 'displacement' 165 i1_series_Civ1=Param.ActionInput.OriginIndex*ones(size(i1_series{1})); 166 i2_series_Civ1=i1_series{1};i2_series_Civ2=i1_series{1}; 167 j1_series_Civ1=ones(size(i1_series{1}));% first j index is 1 168 if isempty(j1_series_Civ1) 169 j2_series_Civ1=ones(size(i1_series{1})); 170 else 171 j2_series_Civ1=j1_series_Civ1; 172 end 173 i1_series_Civ2=i1_series_Civ1; 174 j1_series_Civ2=j1_series_Civ1; 175 j2_series_Civ2=j2_series_Civ1; 176 NomTypeNc=NomType; 177 case 'PIV volume' 178 % TODO, TODO 179 end 180 if isempty(j1_series_Civ1) 181 FrameIndex_A_Civ1=i1_series_Civ1; 182 FrameIndex_B_Civ1=i2_series_Civ1; 183 j1_series_Civ1=ones(size(i1_series_Civ1)); 184 j2_series_Civ1=ones(size(i1_series_Civ1)); 185 else 186 FrameIndex_A_Civ1=j1_series_Civ1; 187 FrameIndex_B_Civ1=j2_series_Civ1; 188 end 189 if isempty(PairCiv2) 188 190 FrameIndex_A_Civ2=FrameIndex_A_Civ1; 189 191 FrameIndex_B_Civ2=FrameIndex_B_Civ1; 190 else 191 if isempty(j1_series_Civ2) 192 FrameIndex_A_Civ2=i1_series_Civ2; 193 FrameIndex_B_Civ2=i2_series_Civ2; 194 j1_series_Civ2=ones(size(i1_series_Civ2)); 195 j2_series_Civ2=ones(size(i1_series_Civ2)); 196 else 197 FrameIndex_A_Civ2=j1_series_Civ2; 198 FrameIndex_B_Civ2=j2_series_Civ2; 199 end 200 end 201 if isempty(i1_series_Civ1)||(~isempty(PairCiv2) && isempty(i1_series_Civ2)) 202 disp_uvmat('ERROR','no image pair fo civ in the input file index range',checkrun) 203 return 204 end 205 end 206 207 %% check the first image pair 208 try 209 if Param.ActionInput.CheckCiv1% Civ1 is performed 210 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1),[],j1_series_Civ1(1)); 211 if ~exist(ImageName_A,'file') 212 disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun) 192 else 193 if isempty(j1_series_Civ2) 194 FrameIndex_A_Civ2=i1_series_Civ2; 195 FrameIndex_B_Civ2=i2_series_Civ2; 196 j1_series_Civ2=ones(size(i1_series_Civ2)); 197 j2_series_Civ2=ones(size(i1_series_Civ2)); 198 else 199 FrameIndex_A_Civ2=j1_series_Civ2; 200 FrameIndex_B_Civ2=j2_series_Civ2; 201 end 202 end 203 if isempty(i1_series_Civ1)||(~isempty(PairCiv2) && isempty(i1_series_Civ2)) 204 disp_uvmat('ERROR','no image pair fo civ in the input file index range',checkrun) 213 205 return 214 206 end 215 [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A); 216 FileType_A=FileInfo_A.FileType; 217 if strcmp(FileInfo_A.FileType,'netcdf') 218 FieldName_A=Param.InputFields.FieldName; 219 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A}); 220 par_civ1.ImageA=DataIn.(FieldName_A); 221 else 222 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(1)); 223 end 224 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(1),[],j2_series_Civ1(1)); 225 if ~exist(ImageName_B,'file') 226 disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun) 207 end 208 209 %% check the first image pair 210 try 211 if Param.ActionInput.CheckCiv1% Civ1 is performed 212 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1),[],j1_series_Civ1(1)); 213 if ~exist(ImageName_A,'file') 214 disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun) 215 return 216 end 217 [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A); 218 FileType_A=FileInfo_A.FileType; 219 if strcmp(FileInfo_A.FileType,'netcdf') 220 FieldName_A=Param.InputFields.FieldName; 221 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A}); 222 par_civ1.ImageA=DataIn.(FieldName_A); 223 else 224 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(1)); 225 end 226 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(1),[],j2_series_Civ1(1)); 227 if ~exist(ImageName_B,'file') 228 disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun) 229 return 230 end 231 [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B); 232 FileType_B=FileInfo_B.FileType; 233 if strcmp(FileInfo_B.FileType,'netcdf') 234 FieldName_B=Param.InputFields.FieldName; 235 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B}); 236 par_civ1.ImageB=DataIn.(FieldName_B); 237 else 238 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(1)); 239 end 240 NbField=numel(i1_series_Civ1); 241 elseif Param.ActionInput.CheckCiv2 % Civ2 is performed without Civ1 242 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ2(1),[],j1_series_Civ2(1)); 243 if ~exist(ImageName_A,'file') 244 disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun) 245 return 246 end 247 [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A); 248 FileType_A=FileInfo_A.FileType; 249 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileInfo_A.FileType,VideoObject_A,FrameIndex_A_Civ2(1)); 250 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ2(1),[],j2_series_Civ2(1)); 251 if ~exist(ImageName_B,'file') 252 disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun) 253 return 254 end 255 [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B); 256 FileType_B=FileInfo_B.FileType; 257 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2(1)); 258 NbField=numel(i1_series_Civ2); 259 else 260 NbField=numel(i1_series_Civ1);% no image used (only fix or patch) TO CHECK 261 end 262 catch ME 263 if ~isempty(ME.message) 264 disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun) 227 265 return 228 266 end 229 [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B); 230 FileType_B=FileInfo_B.FileType; 231 if strcmp(FileInfo_B.FileType,'netcdf') 232 FieldName_B=Param.InputFields.FieldName; 233 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B}); 234 par_civ1.ImageB=DataIn.(FieldName_B); 235 else 236 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(1)); 237 end 238 NbField=numel(i1_series_Civ1); 239 elseif Param.ActionInput.CheckCiv2 % Civ2 is performed without Civ1 240 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ2(1),[],j1_series_Civ2(1)); 241 if ~exist(ImageName_A,'file') 242 disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun) 243 return 244 end 245 [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A); 246 FileType_A=FileInfo_A.FileType; 247 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileInfo_A.FileType,VideoObject_A,FrameIndex_A_Civ2(1)); 248 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ2(1),[],j2_series_Civ2(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 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2(1)); 256 NbField=numel(i1_series_Civ2); 257 else 258 NbField=numel(i1_series_Civ1);% no image used (only fix or patch) TO CHECK 259 end 260 catch ME 261 if ~isempty(ME.message) 262 disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun) 263 return 264 end 265 end 266 267 268 %% Output directory 269 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 270 267 end 268 269 270 %% Output directory 271 OutputDir=''; 272 if CheckOutputFile 273 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 274 end 275 end 276 277 %% prepare output Data 271 278 Data.ListGlobalAttribute={'Conventions','Program','CivStage'}; 272 279 Data.Conventions='uvmat/civdata';% states the conventions used for the description of field variables and attributes … … 323 330 %%%%% MAIN LOOP %%%%%% 324 331 for ifield=1:NbField 325 update_waitbar(WaitbarHandle,ifield/NbField) 326 if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue') 327 disp('program stopped by user') 328 break 329 end 330 if iview_A==0 331 ncfile=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},Param.InputTable{1,5},... 332 NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 333 else 334 if iview_A==1% if Civ1 is performed 335 Civ1Dir=OutputDir; 336 else 337 Civ1Dir=Param.InputTable{1,2}; 338 end 339 if strcmp(Param.ActionInput.ListCompareMode,'PIV') 340 ncfile=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.nc',NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),... 341 j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 342 else 343 ncfile=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.nc',NomTypeNc,i2_series_Civ1(ifield),[],... 344 j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 332 if ~isempty(RUNHandle)% update the waitbar in interactive mode with GUI series (checkrun=1) 333 update_waitbar(WaitbarHandle,ifield/NbField) 334 if get(RUNHandle,'Value')&& ~strcmp(get(RUNHandle,'BusyAction'),'queue') 335 disp('program stopped by user') 336 break 337 end 338 end 339 if CheckInputFile 340 if iview_A==0 % no nc file has been entered 341 ncfile=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},Param.InputTable{1,5},... 342 NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 343 else% an existing nc file has been entered 344 if iview_A==1% if Civ1 is performed 345 Civ1Dir=OutputDir; 346 else 347 Civ1Dir=Param.InputTable{1,2}; 348 end 349 if strcmp(Param.ActionInput.ListCompareMode,'PIV') 350 ncfile=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.nc',NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),... 351 j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 352 else 353 ncfile=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.nc',NomTypeNc,i2_series_Civ1(ifield),[],... 354 j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 355 end 345 356 end 346 357 end … … 349 360 if isfield (Param.ActionInput,'Civ1') 350 361 par_civ1=Param.ActionInput.Civ1; 351 try352 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield));353 if strcmp(FileInfo_A.FileType,'netcdf')354 FieldName_A=Param.InputFields.FieldName;355 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A});356 par_civ1.ImageA=DataIn.(FieldName_A);357 else358 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield));359 end360 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield));361 if strcmp(FileInfo_B.FileType,'netcdf')362 FieldName_B=Param.InputFields.FieldName;363 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B});364 par_civ1.ImageB=DataIn.(FieldName_B);365 else366 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield));367 end368 catch ME369 if ~isempty(ME.message)370 disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun)371 return372 end373 end374 par_civ1.ImageWidth=size(par_civ1.ImageA,2);%FileInfo_A.Width;375 par_civ1.ImageHeight=size(par_civ1.ImageA,1);%FileInfo_A.Height;376 list_param=(fieldnames(Param.ActionInput.Civ1))';377 ind_remove=find(strcmp('TestCiv1',list_param));378 list_param(ind_remove)=[];379 Civ1_param=regexprep(list_param,'^.+','Civ1_$0');% insert 'Civ1_' before each string in list_param380 Civ1_param=[{'Civ1_ImageA','Civ1_ImageB','Civ1_Time','Civ1_Dt'} Civ1_param]; %insert the names of the two input images381 %indicate the values of all the global attributes in the output data382 Data.Civ1_ImageA=ImageName_A;383 Data.Civ1_ImageB=ImageName_B;384 i1=i1_series_Civ1(ifield);385 i2=i1;386 if ~isempty(i2_series_Civ1)387 i2=i2_series_Civ1(ifield);388 end389 j1=1;390 if ~isempty(j1_series_Civ1)391 j1=j1_series_Civ1(ifield);392 end393 j2=j1;394 if ~isempty(j2_series_Civ1)395 j2=j2_series_Civ1(ifield);396 end397 Data.Civ1_Time=(time(i2+1,j2+1)+time(i1+1,j1+1))/2;398 Data.Civ1_Dt=time(i2+1,j2+1)-time(i1+1,j1+1);399 for ilist=1:length(list_param)400 Data.(Civ1_param{4+ilist})=Param.ActionInput.Civ1.(list_param{ilist});401 end402 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param];403 Data.CivStage=1;404 362 if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1) 363 try 364 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield)); 365 if strcmp(FileInfo_A.FileType,'netcdf')% case of input images in format netcdf 366 FieldName_A=Param.InputFields.FieldName; 367 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A}); 368 par_civ1.ImageA=DataIn.(FieldName_A); 369 else % usual image formats for image A 370 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield)); 371 end 372 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield)); 373 if strcmp(FileInfo_B.FileType,'netcdf') % case of input images in format netcdf 374 FieldName_B=Param.InputFields.FieldName; 375 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B}); 376 par_civ1.ImageB=DataIn.(FieldName_B); 377 else % usual image formats for image B 378 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield)); 379 end 380 catch ME % display errors in reading input images 381 if ~isempty(ME.message) 382 disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun) 383 return 384 end 385 end 386 par_civ1.ImageWidth=size(par_civ1.ImageA,2);%FileInfo_A.Width; 387 par_civ1.ImageHeight=size(par_civ1.ImageA,1);%FileInfo_A.Height; 388 list_param=(fieldnames(Param.ActionInput.Civ1))'; 389 list_param(strcmp('TestCiv1',list_param))=[];% remove the parameter TestCiv1 from the list 390 Civ1_param=regexprep(list_param,'^.+','Civ1_$0');% insert 'Civ1_' before each string in list_param 391 Civ1_param=[{'Civ1_ImageA','Civ1_ImageB','Civ1_Time','Civ1_Dt'} Civ1_param]; %insert the names of the two input images 392 %indicate the values of all the global attributes in the output data 393 Data.Civ1_ImageA=ImageName_A; 394 Data.Civ1_ImageB=ImageName_B; 395 i1=i1_series_Civ1(ifield); 396 i2=i1; 397 if ~isempty(i2_series_Civ1) 398 i2=i2_series_Civ1(ifield); 399 end 400 j1=1; 401 if ~isempty(j1_series_Civ1) 402 j1=j1_series_Civ1(ifield); 403 end 404 j2=j1; 405 if ~isempty(j2_series_Civ1) 406 j2=j2_series_Civ1(ifield); 407 end 408 Data.Civ1_Time=(time(i2+1,j2+1)+time(i1+1,j1+1))/2; 409 Data.Civ1_Dt=time(i2+1,j2+1)-time(i1+1,j1+1); 410 for ilist=1:length(list_param) 411 Data.(Civ1_param{4+ilist})=Param.ActionInput.Civ1.(list_param{ilist}); 412 end 413 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param]; 414 Data.CivStage=1; 415 end 405 416 % set the list of variables 406 417 Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_F','Civ1_C'};% cell array containing the names of the fields to record … … 448 459 if exist('ncfile','var') 449 460 CivFile=ncfile; 450 elseif isfield(Param.Patch1,'CivFile') 451 CivFile=Param.Patch1.CivFile; 452 end 453 [Data,tild,tild,errormsg]=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format 454 if ~isempty(errormsg) 455 disp_uvmat('ERROR',errormsg,checkrun) 456 return 457 end 458 if ~isempty(Data.absolut_time_T0')%read civx file 459 check_civx=1;% test for old civx data format 460 [Data,vardetect,ichoice]=nc2struct(CivFile);%read the variables in the netcdf file 461 else 462 [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file 461 % elseif isfield(Param.Patch1,'CivFile') 462 % CivFile=Param.Patch1.CivFile; 463 % end 464 [Data,tild,tild,errormsg]=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format 465 if ~isempty(errormsg) 466 disp_uvmat('ERROR',errormsg,checkrun) 467 return 468 end 469 if ~isempty(Data.absolut_time_T0')%read civx file 470 check_civx=1;% test for old civx data format 471 [Data,vardetect,ichoice]=nc2struct(CivFile);%read the variables in the netcdf file 472 else 473 [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file 474 end 475 else 476 Data.ListGlobalAttribute={}; 477 Data.ListVarName={}; 478 Data.VarDimName={}; 479 Data.Civ1_X=Param.Civ1_X; 480 Data.Civ1_Y=Param.Civ1_Y; 481 Data.Civ1_U=Param.Civ1_U; 482 Data.Civ1_V=Param.Civ1_V; 483 Data.Civ1_FF=Param.Civ1_FF; 463 484 end 464 485 end … … 511 532 return 512 533 end 534 535 % record the processing parameters of Patch1 as global attributes in the result nc file 513 536 list_param=fieldnames(Param.ActionInput.Patch1)'; 514 ind_remove=find(strcmp('TestPatch1',list_param)); 515 list_param(ind_remove)=[]; 516 Patch1_param=regexprep(list_param,'^.+','Patch1_$0');% insert 'Fix1_' before each string in ListFixParam 517 %indicate the values of all the global attributes in the output data 537 list_param(strcmp('TestPatch1',list_param))=[];% remove 'TestPatch1' from the list of parameters 538 Patch1_param=regexprep(list_param,'^.+','Patch1_$0');% insert 'Patch1_' before each parameter name 518 539 for ilist=1:length(list_param) 519 540 Data.(Patch1_param{ilist})=Param.ActionInput.Patch1.(list_param{ilist}); 520 541 end 542 Data.CivStage=3;% record the new state of processing 521 543 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Patch1_param]; 522 544 523 % Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch1_FieldSmooth','Patch1_MaxDiff','Patch1_SubDomainSize'}]; 524 % Data.Patch1_FieldSmooth=Param.ActionInput.Patch1.FieldSmooth; 525 % Data.Patch1_MaxDiff=Param.ActionInput.Patch1.MaxDiff; 526 % Data.Patch1_SubDomainSize=Param.ActionInput.Patch1.SubDomainSize; 545 % list the variables to record 527 546 nbvar=length(Data.ListVarName); 528 547 Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbCentres','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}]; … … 534 553 Data.VarAttribute{nbvar+6}.Role='vector_x'; 535 554 Data.VarAttribute{nbvar+7}.Role='vector_y'; 536 Data.Civ1_U_smooth= zeros(size(Data.Civ1_X));537 Data.Civ1_V_smooth= zeros(size(Data.Civ1_X));555 Data.Civ1_U_smooth=Data.Civ1_U; % zeros(size(Data.Civ1_X)); 556 Data.Civ1_V_smooth=Data.Civ1_V; %zeros(size(Data.Civ1_X)); 538 557 if isfield(Data,'Civ1_FF') 539 558 ind_good=find(Data.Civ1_FF==0); … … 541 560 ind_good=1:numel(Data.Civ1_X); 542 561 end 562 563 % perform Patch calculation using the UVMAT fct 'filter_tps' 543 564 [Data.Civ1_SubRange,Data.Civ1_NbCentres,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=... 544 565 filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomainSize,Data.Patch1_FieldSmooth,Data.Patch1_MaxDiff); 545 Data.Civ1_U_smooth(ind_good)=Ures; 566 Data.Civ1_U_smooth(ind_good)=Ures;% take the interpolated (smoothed) velocity values for good vectors, keep 0 for the others 546 567 Data.Civ1_V_smooth(ind_good)=Vres; 547 568 Data.Civ1_FF(ind_good)=FFres; 548 Data.CivStage=3;549 569 end 550 570 … … 554 574 par_civ2.ImageA=[]; 555 575 par_civ2.ImageB=[]; 556 % if ~isfield(Param.Civ1,'ImageA') 557 i1=i1_series_Civ2(ifield); 576 i1=i1_series_Civ2(ifield); 558 577 i2=i1; 559 578 if ~isempty(i2_series_Civ2) … … 610 629 end 611 630 612 % get the guess from patch1 or patch2 (case ' iterate')613 if isfield (par_civ2,' iterate') && strcmp(par_civ2.iterate,'civ3')631 % get the guess from patch1 or patch2 (case 'CheckCiv3') 632 if isfield (par_civ2,'CheckCiv3') && par_civ2.CheckCiv3 %get the guess from patch2 614 633 SubRange= Data.Civ2_SubRange; 615 634 NbCentres=Data.Civ2_NbCentres; … … 626 645 Data.ListVarName={}; 627 646 Data.VarDimName={}; 628 else 647 else % get the guess from patch1 629 648 SubRange= Data.Civ1_SubRange; 630 649 NbCentres=Data.Civ1_NbCentres; … … 781 800 782 801 %% write result in a netcdf file if requested 783 if exist('ncfile','var')802 if CheckOutputFile 784 803 errormsg=struct2nc(ncfile,Data); 785 804 if isempty(errormsg) … … 824 843 % mask: =[] for no mask 825 844 % roi: 4 element vector defining a region of interest: x position, y position, width, height, (in image indices), for the whole image, roi=[]; 826 function [xtable ytable utable vtable ctable F result_conv errormsg] = civ (par_civ) 827 %this funtion performs the DCC PIV analysis. Recent window-deformation 828 %methods perform better and will maybe be implemented in the future. 845 function [xtable,ytable,utable,vtable,ctable,F,result_conv,errormsg] = civ (par_civ) 829 846 830 847 %% prepare measurement grid … … 866 883 result_conv=[]; 867 884 errormsg=''; 868 885 869 886 %% prepare mask 870 887 if isfield(par_civ,'Mask') && ~isempty(par_civ.Mask)
Note: See TracChangeset
for help on using the changeset viewer.