Changeset 1164
- Timestamp:
- Jul 29, 2024, 9:43:17 AM (5 months ago)
- Location:
- trunk/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/filter_tps_3D.m
r1163 r1164 38 38 %======================================================================= 39 39 40 function [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps (Coord,U,V,W,SubDomainSize,FieldSmooth,Threshold)40 function [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps_3D(Coord_x,Coord_y,Coord_z,U,V,W,SubDomainSize,FieldSmooth,Threshold) 41 41 42 42 %% adjust subdomain decomposition 43 43 warning off 44 NbVec=size(Coord,1);% nbre of vectors in the field to interpolate 45 NbCoord=size(Coord,2);% space dimension,Coord(:,1)= x,Coord(:,2)= y , Coord(:,3)= z 44 % [npz,npy,npx]=size(Coord_x); 45 Coord=[Coord_x Coord_y Coord_z]; 46 NbVec=numel(Coord_x);% nbre of vectors in the field to interpolate 47 NbCoord=3;% space dimension,Coord(:,1)= x,Coord(:,2)= y , Coord(:,3)= z 46 48 MinCoord=min(Coord,[],1);%lower coordinate bounds 47 49 MaxCoord=max(Coord,[],1);%upper coordinate bounds 48 50 Range=MaxCoord-MinCoord;%along eacch coordiante x,y,z 49 Cellmesh=( prod(Range)/NbVec)^(1/3);50 NbSubDomainX= floor(range(1)/Cellmesh);51 NbSubDomainY= floor(range(2)/Cellmesh);52 NbSubDomainZ= floor(range(3)/Cellmesh);51 Cellmesh=(10*prod(Range)/NbVec)^(1/3); 52 NbSubDomainX=ceil(Range(1)/Cellmesh); 53 NbSubDomainY=ceil(Range(2)/Cellmesh); 54 NbSubDomainZ=ceil(10*Range(3)/Cellmesh); 53 55 54 56 % NbSubDomain=NbVec/SubDomainSize;% estimated number of subdomains … … 56 58 % NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1);% estimated number of subdomains in y 57 59 % NbSubDomainZ=max(floor(sqrt(NbSubDomain*AspectRatio)),1);% estimated number of subdomains in y 58 NbSubDomain=NbSubDomainX*NbSubDomainY ;% new estimated number of subdomains in a matrix shape partition in subdomains60 NbSubDomain=NbSubDomainX*NbSubDomainY*NbSubDomainZ;% new estimated number of subdomains in a matrix shape partition in subdomains 59 61 Siz(1)=Range(1)/NbSubDomainX;%width of subdomains 60 62 Siz(2)=Range(2)/NbSubDomainY;%height of subdomains … … 71 73 %smoothing=Siz(1)*Siz(2)*FieldSmooth/1000%old calculation before 03 May < r1129 72 74 NbVecSub=NbVec/NbSubDomain;% refined estimation of the nbre of vectors per subdomain 73 smoothing= sqrt(Siz(1)*Siz(2)/NbVecSub)*FieldSmooth;%optimum smoothing increase as the typical mesh size =sqrt(SizX*SizY/NbVecSub)^1/275 smoothing=(Siz(1)*Siz(2)*Siz(3)/NbVecSub)^(1/3)*FieldSmooth;%optimum smoothing increase as the typical mesh size =sqrt(SizX*SizY/NbVecSub)^1/2 74 76 Threshold=Threshold*Threshold;% take the square of the threshold to work with the modulus squared (not done before r1154) 75 77 … … 79 81 U_tps=zeros(1,NbSubDomain);% initialize interpolated u component 80 82 V_tps=zeros(1,NbSubDomain);% initialize interpolated v component 83 W_tps=zeros(1,NbSubDomain);% initialize interpolated v component 81 84 NbCentre=zeros(1,NbSubDomain);%number of interpolated field values per subdomain, =0 by default 82 W_tps=[];%default (2 component case)83 85 U_smooth=zeros(NbVec,1); % smoothed velocity U at the initial positions 84 86 V_smooth=zeros(NbVec,1);% smoothed velocity V at the initial positions 85 W_smooth= [];%default (2 component case)87 W_smooth=zeros(NbVec,1);%default (2 component case) 86 88 FF=false(NbVec,1);%false flag=0 (false) by default 87 89 nb_select=zeros(NbVec,1); … … 100 102 %check_next=false;% test to go to next iteration with wider subdomain 101 103 ind_sel_previous=ind_sel;% record the set of selected vector indices for next iteration 102 ind_sel= find(~FF & Coord(:,1)>=SubRange(1,1,isub) & Coord(:,1)<=SubRange(1,2,isub) & Coord(:,2)>=SubRange(2,1,isub) & Coord(:,2)<=SubRange(2,2,isub));% indices of vectors in the subdomain #isub 104 ind_sel= find(~FF & Coord(:,1)>=SubRange(1,1,isub) & Coord(:,1)<=SubRange(1,2,isub)... 105 & Coord(:,2)>=SubRange(2,1,isub) & Coord(:,2)<=SubRange(2,2,isub)&... 106 Coord(:,3)>=SubRange(3,1,isub) & Coord(:,3)<=SubRange(3,2,isub));% indices of vectors in the subdomain #isub 103 107 check_partial_domain=sum(SubRange(:,1,isub)> MinCoord' | SubRange(:,2,isub)< MaxCoord'); 104 108 % isub … … 121 125 [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel,:),U(ind_sel),smoothing); 122 126 [V_smooth_sub,V_tps_sub]=tps_coeff(Coord(ind_sel,:),V(ind_sel),smoothing); 127 [W_smooth_sub,W_tps_sub]=tps_coeff(Coord(ind_sel,:),W(ind_sel),smoothing); 123 128 UDiff=U_smooth_sub-U(ind_sel);% difference between interpolated U component and initial value 124 129 VDiff=V_smooth_sub-V(ind_sel);% difference between interpolated V component and initial value 125 NormDiff=UDiff.*UDiff+VDiff.*VDiff;% Square of difference norm 130 WDiff=W_smooth_sub-W(ind_sel);% difference between interpolated V component and initial value 131 NormDiff=UDiff.*UDiff+VDiff.*VDiff+WDiff.*WDiff;% Square of difference norm 126 132 ind_ind_sel=1:numel(ind_sel);%default 127 133 if exist('Threshold','var')&&~isempty(Threshold) … … 134 140 x_width=(SubRange(1,2,isub)-SubRange(1,1,isub))/pi; 135 141 y_width=(SubRange(2,2,isub)-SubRange(2,1,isub))/pi; 142 z_width=(SubRange(3,2,isub)-SubRange(3,1,isub))/pi; 136 143 x_dist=(Coord(ind_sel,1)-CentreX(isub))/x_width;% relative x distance to the retangle centre 137 144 y_dist=(Coord(ind_sel,2)-CentreY(isub))/y_width;% relative ydistance to the retangle centre 138 weight=cos(x_dist).*cos(y_dist);%weighting fct =1 at the rectangle center and 0 at edge139 %weight=1;% case for r1129 and before145 z_dist=(Coord(ind_sel,3)-CentreZ(isub))/z_width;% relative ydistance to the retangle centre 146 weight=cos(x_dist).*cos(y_dist).*cos(z_dist);%weighting fct =1 at the rectangle center and 0 at edge 140 147 U_smooth(ind_sel)=U_smooth(ind_sel)+weight.*U_smooth_sub; 141 148 V_smooth(ind_sel)=V_smooth(ind_sel)+weight.*V_smooth_sub; 149 W_smooth(ind_sel)=W_smooth(ind_sel)+weight.*W_smooth_sub; 142 150 NbCentre(isub)=numel(ind_sel); 143 151 Coord_tps(1:NbCentre(isub),:,isub)=Coord(ind_sel,:); 144 U_tps(1:NbCentre(isub)+3,isub)=U_tps_sub; 145 V_tps(1:NbCentre(isub)+3,isub)=V_tps_sub; 152 U_tps(1:NbCentre(isub)+4,isub)=U_tps_sub; 153 V_tps(1:NbCentre(isub)+4,isub)=V_tps_sub; 154 W_tps(1:NbCentre(isub)+4,isub)=W_tps_sub; 146 155 nb_select(ind_sel)=nb_select(ind_sel)+weight; 147 156 display(['tps done with ' num2str(numel(ind_sel)) ' vectors in subdomain # ' num2str(isub) ' among ' num2str(NbSubDomain)]) … … 157 166 [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel(ind_ind_sel),:),U(ind_sel(ind_ind_sel)),smoothing); 158 167 [V_smooth_sub,V_tps_sub]=tps_coeff(Coord(ind_sel(ind_ind_sel),:),V(ind_sel(ind_ind_sel)),smoothing); 168 [W_smooth_sub,W_tps_sub]=tps_coeff(Coord(ind_sel(ind_ind_sel),:),W(ind_sel(ind_ind_sel)),smoothing); 159 169 x_width=(SubRange(1,2,isub)-SubRange(1,1,isub))/pi; 160 170 y_width=(SubRange(2,2,isub)-SubRange(2,1,isub))/pi; 171 z_width=(SubRange(3,2,isub)-SubRange(3,1,isub))/pi; 161 172 x_dist=(Coord(ind_sel(ind_ind_sel),1)-CentreX(isub))/x_width;% relative x distance to the retangle centre 162 173 y_dist=(Coord(ind_sel(ind_ind_sel),2)-CentreY(isub))/y_width;% relative ydistance to the retangle centre 163 weight=cos(x_dist).*cos(y_dist);%weighting fct =1 at the rectangle center and 0 at edge 174 z_dist=(Coord(ind_sel(ind_ind_sel),3)-CentreZ(isub))/z_width;% relative ydistance to the retangle centre 175 weight=cos(x_dist).*cos(y_dist).*cos(z_dist);%weighting fct =1 at the rectangle center and 0 at edge 164 176 %weight=1; 165 177 U_smooth(ind_sel(ind_ind_sel))=U_smooth(ind_sel(ind_ind_sel))+weight.*U_smooth_sub; 166 178 V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+weight.*V_smooth_sub; 179 W_smooth(ind_sel(ind_ind_sel))=W_smooth(ind_sel(ind_ind_sel))+weight.*W_smooth_sub; 167 180 NbCentre(isub)=numel(ind_ind_sel); 168 181 Coord_tps(1:NbCentre(isub),:,isub)=Coord(ind_sel(ind_ind_sel),:); 169 U_tps(1:NbCentre(isub)+3,isub)=U_tps_sub; 170 V_tps(1:NbCentre(isub)+3,isub)=V_tps_sub; 182 U_tps(1:NbCentre(isub)+4,isub)=U_tps_sub; 183 V_tps(1:NbCentre(isub)+4,isub)=V_tps_sub; 184 W_tps(1:NbCentre(isub)+4,isub)=W_tps_sub; 171 185 nb_select(ind_sel(ind_ind_sel))=nb_select(ind_sel(ind_ind_sel))+weight; 172 186 display(['tps redone with ' num2str(numel(ind_sel)) ' vectors after elimination of ' num2str(numel(ind_sel)-numel(ind_ind_sel)) ' erratic vectors in subdomain # ' num2str(isub) ' among ' num2str(NbSubDomain)]) … … 189 203 U_tps(:,ind_empty)=[]; 190 204 V_tps(:,ind_empty)=[]; 205 W_tps(:,ind_empty)=[]; 191 206 NbCentre(ind_empty)=[]; 192 207 end … … 196 211 U_smooth=U_smooth./nb_select;% take the average at the intersection of several subdomains 197 212 V_smooth=V_smooth./nb_select; 213 W_smooth=W_smooth./nb_select; 198 214 199 215 %eliminate the vectors with diff>threshold not yet eliminated … … 201 217 UDiff=U_smooth-U;% difference between interpolated U component and initial value 202 218 VDiff=V_smooth-V;% difference between interpolated V component and initial value 203 NormDiff=UDiff.*UDiff+VDiff.*VDiff;% Square of difference norm 219 WDiff=W_smooth-W;% difference between interpolated V component and initial value 220 NormDiff=UDiff.*UDiff+VDiff.*VDiff+WDiff.*WDiff;% Square of difference norm 204 221 FF(NormDiff>Threshold)=true;%put FF value to 1 to identify the criterium of elimmination 205 222 end … … 207 224 U_smooth(FF)=U(FF);% set to the initial values the eliminated vectors (flagged as false) 208 225 V_smooth(FF)=V(FF); 226 W_smooth(FF)=W(FF); 209 227 fill=zeros(NbCoord+1,NbCoord,size(SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage) 210 228 Coord_tps=cat(1,Coord_tps,fill); 211 229 230 -
trunk/src/find_file_series.m
r1127 r1164 49 49 50 50 %% get input root name and info on the input file 51 if isempty(regexp(FilePath,'^http://','once')) 51 if isempty(regexp(FilePath,'^http://','once'))% case of usual file input 52 52 fullfileinput=fullfile(FilePath,fileinput);% input file name with path 53 53 else 54 fullfileinput=[FilePath '/' fileinput]; 54 fullfileinput=[FilePath '/' fileinput]; % case of web input 55 55 end 56 56 [FileInfo,MovieObject]=get_file_info(fullfileinput); … … 105 105 sep2=''; 106 106 i1_str='(?<i1>)';%will set i1=[]; 107 i1_star='';108 107 i2_str='(?<i2>)';%will set i2=[]; 109 i2_star='';110 108 j1_str='(?<j1>)';%will set j1=[]; 111 j1_star='';112 109 j2_str='(?<j2>)';%will set j2=[]; 113 j2_star=''; 110 114 111 %Look for cases with letter indexing for the second index 115 112 r=regexp(NomType,'^(?<sep1>_?)(?<i1>\d+)(?<sep2>_?)(?<j1>[a|A])(?<j2>[b|B]?)$','names'); … … 118 115 sep2=r.sep2; 119 116 i1_str='(?<i1>\d+)'; 120 i1_star='*';121 117 if strcmp(lower(r.j1),r.j1)% lower case index 122 118 j1_str='(?<j1>[a-z])'; … … 124 120 j1_str='(?<j1>[A-Z])'; % upper case index 125 121 end 126 j1_star='*';127 122 if ~isempty(r.j2) 128 123 if strcmp(lower(r.j1),r.j1) … … 131 126 j2_str='(?<j2>[A-Z])'; 132 127 end 133 j2_star='*';134 128 end 135 129 else %numerical indexing … … 138 132 sep1=r.sep1; 139 133 i1_str='(?<i1>\d+)'; 140 i1_star='*';141 134 if ~isempty(r.i2) 142 135 i2_str='(?<i2>-\d+)'; 143 i2_star='-*';144 136 end 145 137 if ~isempty(r.j1) 146 138 j1_str='(?<j1>_\d+)'; 147 j1_star='_*';148 139 end 149 140 if ~isempty(r.j2) 150 141 j2_str='(?<j2>-\d+)'; 151 j2_star='-*';152 142 end 153 143 end … … 290 280 i1_series=i1_series(:,2)*ones(1,FileInfo.NumberOfFrames);% 291 281 i1_series=[zeros(size(i1_series,1),1) i1_series]; 282 if ~isempty(i2_series) 283 i2_series=i2_series(:,2)*ones(1,FileInfo.NumberOfFrames);% 284 i2_series=[zeros(size(i2_series,1),1) i2_series]; 285 end 292 286 j1_series=ones(size(i1_series,1),1)*(1:FileInfo.NumberOfFrames);% 293 287 j1_series=[zeros(size(i1_series,1),1) j1_series]; -
trunk/src/get_file_info.m
r1162 r1164 153 153 [Data,tild,tild,errormsg]=nc2struct(fileinput,[]); 154 154 if isempty(errormsg) 155 if isfield(Data,'absolut_time_T0') && isfield(Data,'hart') && ~isempty(Data.absolut_time_T0) && ~isempty(Data.hart) 156 FileInfo.FileType='civx';%old civ data from the Fortran program 157 if isfield(Data,'patch2') && isequal(Data.patch2,1) 158 FileInfo.CivStage=6; 159 elseif isfield(Data,'fix2') && isequal(Data.fix2,1) 160 FileInfo.CivStage=5; 161 elseif isfield(Data,'civ2')&& isequal(Data.civ2,1) 162 FileInfo.CivStage=4; 163 elseif isfield(Data,'patch')&&isequal(Data.patch,1) 164 FileInfo.CivStage=3; 165 elseif isfield(Data,'fix')&&isequal(Data.fix,1) 166 FileInfo.CivStage=2; 167 else 168 FileInfo.CivStage=1; 169 end 170 elseif isfield(Data,'Conventions') && strcmp(Data.Conventions,'uvmat/civdata') 155 % if isfield(Data,'absolut_time_T0') && isfield(Data,'hart') && ~isempty(Data.absolut_time_T0) && ~isempty(Data.hart) 156 % FileInfo.FileType='civx';%old civ data from the Fortran program 157 % if isfield(Data,'patch2') && isequal(Data.patch2,1) 158 % FileInfo.CivStage=6; 159 % elseif isfield(Data,'fix2') && isequal(Data.fix2,1) 160 % FileInfo.CivStage=5; 161 % elseif isfield(Data,'civ2')&& isequal(Data.civ2,1) 162 % FileInfo.CivStage=4; 163 % elseif isfield(Data,'patch')&&isequal(Data.patch,1) 164 % FileInfo.CivStage=3; 165 % elseif isfield(Data,'fix')&&isequal(Data.fix,1) 166 % FileInfo.CivStage=2; 167 % else 168 % FileInfo.CivStage=1; 169 % end 170 % else 171 if isfield(Data,'Conventions') && strcmp(Data.Conventions,'uvmat/civdata') 171 172 FileInfo.FileType='civdata'; % test for civ velocity fields 172 173 FileInfo.CivStage=Data.CivStage; 174 MaskFile=''; 175 if isfield(Data,'Civ2_Mask') 176 MaskFile=Data.Civ2_Mask; 177 if isfield(Data,'Civ2_NbSlice') 178 FileInfo.MaskNbSlice=Data.Civ2_NbSlice; 179 end 180 elseif isfield(Data,'Civ1_Mask') 181 MaskFile=Data.Civ1_Mask; 182 if isfield(Data,'Civ1_NbSlice') 183 FileInfo.MaskNbSlice=Data.Civ1_NbSlice; 184 end 185 end 186 if isfield(Data,'VolumeScan') 187 FileInfo.VolumeScan=Data.VolumeScan; 188 end 189 if ~isempty(MaskFile) 190 [RootPath,SubDir,RootFile,~,~,~,~,FileExt,NomType]=fileparts_uvmat(MaskFile); 191 if strcmp(NomType,'_1')&& isfield(FileInfo,'MaskNbSlice') 192 FileInfo.MaskFile=fullfile(RootPath,SubDir,RootFile); 193 else 194 FileInfo.MaskFile=MaskFile;% single mask for the series (no indexing) 195 end 196 FileInfo.MaskExt=FileExt; 197 end 173 198 elseif isfield(Data,'Conventions') && strcmp(Data.Conventions,'uvmat/civdata_3D') 174 199 FileInfo.FileType='civdata_3D'; % test for 3D volume civ velocity fields -
trunk/src/get_file_series.m
r1134 r1164 84 84 FilePath=fullfile(InputTable{iview,1},InputTable{iview,2}); 85 85 fileinput=[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]; 86 [tild,tild,tild,i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview},NomType,FileInfo,MovieObject,... 87 i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput); 86 [tild,tild,tild,i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview}]=find_file_series(FilePath,fileinput); 88 87 i1_series{iview}=squeeze(i1_series{iview}(1,:,:)); %select first pair index as ordered by find_file_series 89 88 i2_series{iview}=squeeze(i2_series{iview}(1,:,:)); %select first pair index as ordered by find_file_series … … 137 136 [i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview}]=find_file_indices(ref_i,ref_j,str2num(r.num1),str2num(r.num2),r.mode); 138 137 end 139 % if ~isequal(r(1).mode,'*-*')% imposed pairs or single i and/or j index140 % [i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview}]=find_file_indices(ref_i,ref_j,str2num(r.num1),str2num(r.num2),r.mode);141 % end142 138 143 139 %list of files -
trunk/src/series/check_data_files.m
r1127 r1164 63 63 ParamOut.ProjObject='off';%can use projection object(option 'off'/'on', 64 64 ParamOut.Mask='off';%can use mask option (option 'off'/'on', 'off' by default) 65 ParamOut.OutputSubDirMode=' none'; %(options 'none'/'custom'/'auto'/'first'/'last','auto' by default)65 ParamOut.OutputSubDirMode='auto'; %(options 'none'/'custom'/'auto'/'first'/'last','auto' by default) 66 66 % 'none' =no output files 67 ParamOut.OutputDirExt='.check_series';%set the output dir extension 67 68 return 68 69 end … … 120 121 for iview=1:nbview 121 122 if isequal(FileType{iview},'mmreader')||isequal(FileType{iview},'video')||isequal(FileType{iview},'multimage') 122 [FileInfo]=get_file_info(filecell{iview,1}); 123 [FileInfo]=get_file_info(filecell{iview,1});% get infos on the first file in the current line 123 124 Tabchar{1}=filecell{iview,1};%info.Filename; 124 125 Tabchar{2}=''; … … 128 129 message=''; 129 130 else 130 Tabchar= {};131 Tabchar=cell(nbfield_i+1,NbSlice); 131 132 %LOOP ON SLICES 132 133 for i_slice=1:NbSlice 133 134 index_slice=i_slice:NbSlice:nbfield; 134 filefound={}; 135 datnum=zeros(1,nbfield_j); 135 filefound=cell(nbfield_i); 136 datnum=zeros(1,nbfield_i); 137 Tabchar(1,i_slice)={['slice #' num2str(i_slice)]}; 136 138 for ifile=1:nbfield_i 137 update_waitbar(WaitbarHandle,ifile/nbfield_i)138 if ishandle(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')139 disp('program stopped by user')140 break141 end139 % update_waitbar(WaitbarHandle,ifile/nbfield_i) 140 % if ishandle(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue') 141 % disp('program stopped by user') 142 % break 143 % end 142 144 file=filecell{iview,index_slice(ifile)}; 143 145 [Path,Name,ext]=fileparts(file); … … 149 151 if isfield(datfile,'datenum') 150 152 datnum(ifile)=datfile.datenum; 151 filefound (ifile)={datfile.name};153 filefound{ifile}=datfile.name; 152 154 end 153 155 lastfield=''; 154 [FileInfo ,Object]=get_file_info(file);156 [FileInfo]=get_file_info(file); 155 157 FileType{iview}=FileInfo.FileType; 156 158 if strcmp(FileType{iview},'civx')||strcmp(FileType{iview},'civdata') … … 159 161 stagechoice=1+mod(FileInfo.CivStage-1,3); 160 162 iter=1+floor((FileInfo.CivStage-1)/3); 161 lastfield=[liststage{stagechoice} num2str(iter)]; 162 %liststage={'civ1','fix1','patch1','civ2','fix2','patch2'}; 163 %lastfield=liststage{FileInfo.CivStage}; 163 lastfield=[liststage{stagechoice} num2str(iter)]; 164 164 end 165 165 end 166 166 lastfield=[FileType{iview} ', ' lastfield]; 167 167 end 168 Tabchar(1,i_slice)={['slice #' num2str(i_slice)]};169 168 Tabchar(ifile+1,i_slice)={[file '...' lastfield]}; 170 169 end … … 177 176 end 178 177 else 179 datnum=datnum( find(datnum));%keep the non zero values corresponding to existing files180 filefound=filefound( find(datnum));178 datnum=datnum(datnum);%keep the non zero values corresponding to existing files 179 filefound=filefound(datnum); 181 180 [first,ind]=min(datnum); 182 181 [last,indlast]=max(datnum); … … 188 187 end 189 188 end 190 hfig=figure(iview); 191 clf 192 if iview>1 193 pos=get(iview-1,'Position'); 194 pos(1)=pos(1)+(iview-1)*pos(1)/nbview; 195 set(hfig,'Position',pos) 189 if checkrun 190 hfig=figure(iview); 191 clf 192 if iview>1 193 pos=get(iview-1,'Position'); 194 pos(1)=pos(1)+(iview-1)*pos(1)/nbview; 195 set(hfig,'Position',pos) 196 end 197 set(hfig,'name',['check_data_files:view= ' num2str(iview)]) 198 set(hfig,'MenuBar','none')% suppress the menu bar 199 set(hfig,'NumberTitle','off')%suppress the fig number in the title 200 h=uicontrol('Style','listbox', 'Position', [20 20 500 300], 'String', Tabchar, 'Callback', {'open_uvmat'}); 201 hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message); 202 else % show results in log file 203 disp(Tabchar) 204 disp(message) 196 205 end 197 set(hfig,'name',['check_data_files:view= ' num2str(iview)]) 198 set(hfig,'MenuBar','none')% suppress the menu bar 199 set(hfig,'NumberTitle','off')%suppress the fig number in the title 200 h=uicontrol('Style','listbox', 'Position', [20 20 500 300], 'String', Tabchar, 'Callback', {'open_uvmat'}); 201 hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message); 202 end 203 206 end 207 'END' 204 208 % 'open_uvmat': open with uvmat the field selected in the list of 'series/check_data_files' 205 209 %------------------------------------------------------------------------ -
trunk/src/series/civ_3D.m
r1163 r1164 1 %'civ_3D': 3D PIV from image scan in a volume 1 %'civ_3D': 3D PIV from image scan in a volume 2 2 3 3 %------------------------------------------------------------------------ … … 12 12 % Param: Matlab structure of input parameters 13 13 % Param contains info of the GUI series using the fct read_GUI. 14 % Param.Action.RUN = 0 (to set the status of the GUI series) or =1 to RUN the computation 14 % Param.Action.RUN = 0 (to set the status of the GUI series) or =1 to RUN the computation 15 15 % Param.InputTable: sets the input file(s) 16 16 % if absent, the fct looks for input data in Param.ActionInput (test mode) … … 49 49 path_series=fileparts(which('series')); 50 50 addpath(fullfile(path_series,'series')) 51 52 Data=civ_input(Param)53 51 52 Data=civ_input(Param) 53 54 54 Data.Program=mfilename;%gives the name of the current function 55 55 Data.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default) … … 83 83 end 84 84 end 85 86 85 86 87 87 return 88 88 end … … 114 114 if isfield(Param,'OutputSubDir')&& isfield(Param,'OutputDirExt') 115 115 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 116 116 OutputPath=fullfile(Param.OutputPath,num2str(Param.Experiment),num2str(Param.Device)); 117 117 else 118 118 disp_uvmat('ERROR','no output folder defined',checkrun) … … 129 129 end 130 130 131 [~,i1_series,~,j1_series,~]=get_file_series(Param); 132 iview_A=0;% series index (iview) for the first image series 133 iview_B=0;% series index (iview) for the second image series (only non zero for option 'shift' comparing two image series ) 134 if Param.ActionInput.CheckCiv1 135 iview_A=1;% usual PIV, the image series is on the first line of the table 136 elseif Param.ActionInput.CheckCiv2 % civ2 is performed without Civ1, a netcdf file series is needed in the first table line 137 iview_A=2;% the second line is used for the input images of Civ2 138 end 139 if iview_A~=0 140 RootPath_A=Param.InputTable{iview_A,1}; 141 RootFile_A=Param.InputTable{iview_A,3}; 142 SubDir_A=Param.InputTable{iview_A,2}; 143 NomType_A=Param.InputTable{iview_A,4}; 144 FileExt_A=Param.InputTable{iview_A,5}; 145 if iview_B==0 146 iview_B=iview_A;% the second image series is the same as the first 147 end 148 RootPath_B=Param.InputTable{iview_B,1}; 149 RootFile_B=Param.InputTable{iview_B,3}; 150 SubDir_B=Param.InputTable{iview_B,2}; 151 NomType_B=Param.InputTable{iview_B,4}; 152 FileExt_B=Param.InputTable{iview_B,5}; 153 end 131 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 132 133 if size(Param.InputTable,1)==2% netcdf file as first input line 134 RootPath_nc=Param.InputTable{1,1}; 135 RootFile_nc=Param.InputTable{1,3}; 136 SubDir_nc=Param.InputTable{1,2}; 137 NomType_nc=Param.InputTable{1,4}; 138 FileExt_nc=Param.InputTable{1,5}; 139 iview_A=2;%second line used for image input 140 iview_B=2; 141 else 142 iview_A=1;%second line used for image input 143 iview_B=1; 144 end 145 RootPath_A=Param.InputTable{iview_A,1}; 146 RootFile_A=Param.InputTable{iview_A,3}; 147 SubDir_A=Param.InputTable{iview_A,2}; 148 NomType_A=Param.InputTable{iview_A,4}; 149 FileExt_A=Param.InputTable{iview_A,5}; 150 RootPath_B=Param.InputTable{iview_B,1}; 151 RootFile_B=Param.InputTable{iview_B,3}; 152 SubDir_B=Param.InputTable{iview_B,2}; 153 NomType_B=Param.InputTable{iview_B,4}; 154 FileExt_B=Param.InputTable{iview_B,5}; 155 154 156 155 157 PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1; 156 158 157 159 [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,~,NomTypeNc]=... 158 159 160 find_pair_indices(PairCiv1,i1_series{1},j1_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j); 161 160 162 if isempty(i1_series_Civ1) 161 163 disp_uvmat('ERROR','no image pair for civ in the input file index range',checkrun) … … 173 175 end 174 176 Data.CivStage=0;%default 175 list_param=(fieldnames(Param.ActionInput.Civ1))'; 176 list_param(strcmp('TestCiv1',list_param))=[];% remove the parameter TestCiv1 from the list 177 Civ1_param=regexprep(list_param,'^.+','Civ1_$0');% insert 'Civ1_' before each string in list_param 178 Civ1_param=[{'Civ1_ImageA','Civ1_ImageB','Civ1_Time','Civ1_Dt'} Civ1_param]; %insert the names of the two input images 179 Data.ListGlobalAttribute=[ListGlobalAttribute Civ1_param]; 177 if Param.ActionInput.CheckCiv1 178 list_param=(fieldnames(Param.ActionInput.Civ1))'; 179 list_param(strcmp('TestCiv1',list_param))=[];% remove the parameter TestCiv1 from the list 180 Civ1_param=regexprep(list_param,'^.+','Civ1_$0');% insert 'Civ1_' before each string in list_param 181 Civ1_param=[{'Civ1_ImageA','Civ1_ImageB','Civ1_Time','Civ1_Dt'} Civ1_param]; %insert the names of the two input images 182 Data.ListGlobalAttribute=[ListGlobalAttribute Civ1_param]; 183 end 180 184 % set the list of variables 181 185 Data.ListVarName={'Coord_z','Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_FF'};% cell array containing the names of the fields to record … … 224 228 CheckOverwrite=Param.CheckOverwrite; 225 229 end 226 227 228 229 230 231 230 Data.Civ1_ImageA=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1),[],j1_series_Civ1(1,1)); 231 Data.Civ1_ImageB=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i1_series_Civ1(1),[],j2_series_Civ1(1,1)); 232 FileInfo=get_file_info(Data.Civ1_ImageA); 233 par_civ1=Param.ActionInput.Civ1;% parameters for civ1 234 par_civ1.ImageHeight=FileInfo.Height;npy=FileInfo.Height; 235 par_civ1.ImageWidth=FileInfo.Width;npx=FileInfo.Width; 232 236 SearchRange_z=Param.ActionInput.Civ1.SearchRange(3); 233 234 237 par_civ1.Dz=Param.ActionInput.Civ1.Dz; 238 par_civ1.ImageA=zeros(2*SearchRange_z+1,npy,npx); 235 239 par_civ1.ImageB=zeros(2*SearchRange_z+1,npy,npx); 236 240 … … 268 272 j2=j2_series_Civ1(ifield); 269 273 end 270 271 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 272 Data.Civ1_Dt=Time(i2+1,j2+1)-Time(i1+1,j1+1); 273 274 for ilist=1:length(list_param) 275 Data.(Civ1_param{4+ilist})=Param.ActionInput.Civ1.(list_param{ilist}); 276 end 277 278 Data.CivStage=1; 279 274 275 276 280 277 ncfile_out=fullfile_uvmat(OutputPath,'',Param.InputTable{1,3},'.nc',... 281 282 278 '_1-1',i1_series_Civ1(ifield),i2_series_Civ1(ifield)); %output file name 279 283 280 if ~CheckOverwrite && exist(ncfile_out,'file') 284 281 disp(['existing output file ' ncfile_out ' already exists, skip to next field']) 285 282 continue% skip iteration if the mode overwrite is desactivated and the result file already exists 286 283 end 287 288 289 %% Civ1 290 % if Civ1 computation is requested 291 if isfield (Param.ActionInput,'Civ1') 292 284 285 286 %% Civ1 computation if requested 287 if Param.ActionInput.CheckCiv1 288 293 289 disp('civ1 started') 294 290 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 291 Data.Civ1_Dt=Time(i2+1,j2+1)-Time(i1+1,j1+1); 292 293 for ilist=1:length(list_param) 294 Data.(Civ1_param{4+ilist})=Param.ActionInput.Civ1.(list_param{ilist}); 295 end 296 297 Data.CivStage=1; 295 298 % read input images by vertical blocks with nbre of images equal to 2*SearchRange+1, 296 299 par_civ1.ImageA=zeros(2*SearchRange_z+1,npy,npx);%image block initiation … … 307 310 par_civ1.ImageB(iz,:,:) = B; 308 311 end 309 % calculate velocity data at the first position z, corresponding to j_index=par_civ1.Dz 310 [Data.Civ1_X(1,:,:),Data.Civ1_Y(1,:,:), Data.Civ1_U(1,:,:), Data.Civ1_V(1,:,:),Data.Civ1_W(1,:,:),... 311 Data.Civ1_C(1,:,:), Data.Civ1_FF(1,:,:), ~, errormsg] = civ3D (par_civ1); 312 if ~isempty(errormsg) 313 disp_uvmat('ERROR',errormsg,checkrun) 314 return 315 end 316 % loop on slices 317 318 for z_index=2:floor((NbSlice-SearchRange_z)/par_civ1.Dz)% loop on slices 319 par_civ1.ImageA=circshift(par_civ1.ImageA,-par_civ1.Dz,1);%shift the indices in the image block upward by par_civ1.Dz 320 par_civ1.ImageB=circshift(par_civ1.ImageB,-par_civ1.Dz,1); 321 for iz=1:par_civ1.Dz %read the new images at the end of the image block 322 image_index=z_index*par_civ1.Dz+SearchRange_z-par_civ1.Dz+iz+1; 323 if image_index<=size(j1_series_Civ1,1) 324 j_image_index=j1_series_Civ1(z_index*par_civ1.Dz+SearchRange_z-par_civ1.Dz+iz+1,1) 325 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1,ifield),[],j_image_index);% 326 A= read_image(ImageName_A,FileType_A); 327 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(1,ifield),[],j_image_index); 328 B= read_image(ImageName_B,FileType_B); 329 else 330 A=zeros(1,size(par_civ1.ImageA,2),size(par_civ1.ImageA,3)); 331 B=zeros(1,size(par_civ1.ImageA,2),size(par_civ1.ImageA,3)); 332 end 333 par_civ1.ImageA(2*SearchRange_z+1-par_civ1.Dz+iz,:,:) = A; 334 par_civ1.ImageB(2*SearchRange_z+1-par_civ1.Dz+iz,:,:) = B; 335 end 336 % caluclate velocity data (y and v in indices, reverse to y component) 337 [Data.Civ1_X(z_index,:,:),Data.Civ1_Y(z_index,:,:), Data.Civ1_U(z_index,:,:), Data.Civ1_V(z_index,:,:),Data.Civ1_W(z_index,:,:),... 338 Data.Civ1_C(z_index,:,:), Data.Civ1_FF(z_index,:,:), result_conv, errormsg] = civ3D (par_civ1); 339 if ~isempty(errormsg) 340 disp_uvmat('ERROR',errormsg,checkrun) 341 return 342 end 343 end 344 Data.Civ1_V=-Data.Civ1_V;%reverse v 345 Data.Civ1_Y=npy-Data.Civ1_Y+1;%reverse y 346 [npz,npy,npx]=size(Data.Civ1_X); 347 348 % Data.Coord_y=flip(1:npy); 349 % Data.Coord_x=1:npx; 312 350 313 % case of mask TO ADAPT 351 314 if par_civ1.CheckMask&&~isempty(par_civ1.Mask) … … 377 340 end 378 341 end 342 343 % calculate velocity data at the first position z, corresponding to j_index=par_civ1.Dz 344 [Data.Civ1_X(1,:,:),Data.Civ1_Y(1,:,:), Data.Civ1_U(1,:,:), Data.Civ1_V(1,:,:),Data.Civ1_W(1,:,:),... 345 Data.Civ1_C(1,:,:), Data.Civ1_FF(1,:,:), ~, errormsg] = civ3D (par_civ1); 346 if ~isempty(errormsg) 347 disp_uvmat('ERROR',errormsg,checkrun) 348 return 349 end 350 351 % loop on slices 352 for z_index=2:floor((NbSlice-SearchRange_z)/par_civ1.Dz)% loop on slices 353 par_civ1.ImageA=circshift(par_civ1.ImageA,-par_civ1.Dz,1);%shift the indices in the image block upward by par_civ1.Dz 354 par_civ1.ImageB=circshift(par_civ1.ImageB,-par_civ1.Dz,1); 355 for iz=1:par_civ1.Dz %read the new images at the end of the image block 356 image_index=z_index*par_civ1.Dz+SearchRange_z-par_civ1.Dz+iz+1; 357 if image_index<=size(j1_series_Civ1,1) 358 j_image_index=j1_series_Civ1(z_index*par_civ1.Dz+SearchRange_z-par_civ1.Dz+iz+1,1) 359 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1,ifield),[],j_image_index);% 360 A= read_image(ImageName_A,FileType_A); 361 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(1,ifield),[],j_image_index); 362 B= read_image(ImageName_B,FileType_B); 363 else 364 A=zeros(1,size(par_civ1.ImageA,2),size(par_civ1.ImageA,3)); 365 B=zeros(1,size(par_civ1.ImageA,2),size(par_civ1.ImageA,3)); 366 end 367 par_civ1.ImageA(2*SearchRange_z+1-par_civ1.Dz+iz,:,:) = A; 368 par_civ1.ImageB(2*SearchRange_z+1-par_civ1.Dz+iz,:,:) = B; 369 end 370 % caluclate velocity data 371 [Data.Civ1_X(z_index,:,:),Data.Civ1_Y(z_index,:,:), Data.Civ1_U(z_index,:,:), Data.Civ1_V(z_index,:,:),Data.Civ1_W(z_index,:,:),... 372 Data.Civ1_C(z_index,:,:), Data.Civ1_FF(z_index,:,:), result_conv, errormsg] = civ3D (par_civ1); 373 if ~isempty(errormsg) 374 disp_uvmat('ERROR',errormsg,checkrun) 375 return 376 end 377 end 378 % Data.Civ1_V=-Data.Civ1_V;%reverse v 379 % Data.Civ1_Y=npy-Data.Civ1_Y+1;%reverse y 380 381 382 % Data.Coord_y=flip(1:npy); 383 % Data.Coord_x=1:npx; 384 385 else 386 Data=nc2struct(filecell{1,ifield});%read civ1 and fix1 data in the existing netcdf file 387 379 388 % Data.ListVarName=[Data.ListVarName 'Civ1_Z']; 380 389 % Data.Civ1_X=[];Data.Civ1_Y=[];Data.Civ1_Z=[]; 381 390 % Data.Civ1_U=[];Data.Civ1_V=[];Data.Civ1_C=[]; 382 % 383 % 391 % 392 % 384 393 % Data.Civ1_X=[Data.Civ1_X reshape(xtable,[],1)]; 385 394 % Data.Civ1_Y=[Data.Civ1_Y reshape(Param.Civ1.ImageHeight-ytable+1,[],1)]; … … 389 398 % Data.Civ1_C=[Data.Civ1_C reshape(ctable,[],1)]; 390 399 % Data.Civ1_FF=[Data.Civ1_FF reshape(F,[],1)]; 391 392 end 393 394 400 401 end 402 403 %% Fix1 395 404 if isfield (Param.ActionInput,'Fix1') 396 405 disp('detect_false1 started') … … 412 421 Data.CivStage=2; 413 422 end 414 %% Patch1 423 424 %% Patch1 415 425 if isfield (Param.ActionInput,'Patch1') 416 426 disp('patch1 started') 417 427 tstart_patch1=tic; 418 428 419 429 % record the processing parameters of Patch1 as global attributes in the result nc file 420 430 list_param=fieldnames(Param.ActionInput.Patch1)'; … … 426 436 Data.CivStage=3;% record the new state of processing 427 437 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Patch1_param]; 428 438 429 439 % list the variables to record 430 440 nbvar=length(Data.ListVarName); … … 433 443 Data.VarAttribute{nbvar+1}.Role='vector_x'; 434 444 Data.VarAttribute{nbvar+2}.Role='vector_y'; 435 Data.VarAttribute{nbvar+5}.Role='vector_z'; 445 Data.VarAttribute{nbvar+5}.Role='vector_z'; 436 446 Data.Civ1_U_smooth=Data.Civ1_U; 437 Data.Civ1_V_smooth=Data.Civ1_V; 438 Data.Civ1_W_smooth=Data.Civ1_W; 447 Data.Civ1_V_smooth=Data.Civ1_V; 448 Data.Civ1_W_smooth=Data.Civ1_W; 439 449 if isfield(Data,'Civ1_FF') 440 450 ind_good=find(Data.Civ1_FF==0); … … 447 457 return 448 458 end 449 459 450 460 % perform Patch calculation using the UVMAT fct 'filter_tps' 451 Civ1_Z=0.5*Data.Civ1_W(ind_good); 452 for iz=1:numel(Data.Coord_z) 453 Civ1_Z(iz,:,:)=Civ1_Z(iz,:,:)+Data.Coord_z(iz); 454 end 461 Civ1_Z=0.5*Data.Civ1_W; 462 for iz=1:numel(Data.Coord_z) 463 Civ1_Z(iz,:,:)=Civ1_Z(iz,:,:)+Data.Coord_z(iz); 464 end 465 [npz,npy,npx]=size(Data.Civ1_X); 455 466 [Data.Civ1_SubRange,Data.Civ1_NbCentres,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,Data.Civ1_W_tps,... 456 Data.Civ1_U_smooth(ind_good),Data.Civ1_V_smooth(ind_good),Data.Civ1_V_smooth(ind_good),FFres]=... 457 filter_tps_3D([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Civ_1_Z,Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),Data.Civ1_W(ind_good),Data.Patch1_SubDomainSize,Data.Patch1_FieldSmooth,Data.Patch1_MaxDiff); 458 Data.Civ1_FF(ind_good)=uint8(FFres); 467 Data.Civ1_U_smooth(ind_good),Data.Civ1_V_smooth(ind_good),Data.Civ1_W_smooth(ind_good),FFres]=... 468 filter_tps_3D(Data.Civ1_X(ind_good),Data.Civ1_Y(ind_good),Civ1_Z(ind_good),Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),Data.Civ1_W(ind_good),... 469 Data.Patch1_SubDomainSize,Data.Patch1_FieldSmooth,Data.Patch1_MaxDiff); 470 Data.Civ1_FF(ind_good)=uint8(4*FFres); 471 Data.Civ1_FF=reshape(Data.Civ1_FF,npz,npy,npx); 472 Data.Civ1_U=reshape(Data.Civ1_U,npz,npy,npx); 473 Data.Civ1_V=reshape(Data.Civ1_V,npz,npy,npx); 474 Data.Civ1_W=reshape(Data.Civ1_W,npz,npy,npx); 459 475 time_patch1=toc(tstart_patch1); 460 476 disp('patch1 performed') 461 477 end 462 478 463 479 %% Civ2 464 480 if isfield (Param.ActionInput,'Civ2') … … 503 519 end 504 520 % end 505 521 506 522 % get the guess from patch1 or patch2 (case 'CheckCiv3') 507 523 508 524 if isfield (par_civ2,'CheckCiv3') && par_civ2.CheckCiv3 %get the guess from patch2 509 525 SubRange= Data.Civ2_SubRange; … … 530 546 Data.CivStage=4; 531 547 end 532 548 533 549 Shiftx=zeros(size(par_civ2.Grid,1),1);% shift expected from civ1 data 534 550 Shifty=zeros(size(par_civ2.Grid,1),1); 535 551 nbval=zeros(size(par_civ2.Grid,1),1);% nbre of interpolated values at each grid point (from the different patch subdomains) 536 552 537 553 NbSubDomain=size(SubRange,3); 538 554 for isub=1:NbSubDomain% for each sub-domain of Patch1 … … 577 593 end 578 594 end 579 580 595 596 581 597 if strcmp(Param.ActionInput.ListCompareMode,'displacement') 582 598 Civ1_Dt=1; … … 585 601 Civ2_Dt=Time(i2_civ2+1,j2_civ2+1)-Time(i1_civ2+1,j1_civ2+1); 586 602 end 587 603 588 604 par_civ2.SearchBoxShift=(Civ2_Dt/Civ1_Dt)*[Shiftx(nbval>=1)./nbval(nbval>=1) Shifty(nbval>=1)./nbval(nbval>=1)]; 589 605 % shift the grid points by half the expected shift to provide the correlation box position in image A … … 595 611 par_civ2.DVDY=DVDY(nbval>=1)./nbval(nbval>=1); 596 612 end 597 613 598 614 % calculate velocity data (y and v in image indices, reverse to y component) 599 615 600 616 [xtable, ytable, utable, vtable, ctable, F,result_conv,errormsg] = civ (par_civ2); 601 617 602 618 list_param=(fieldnames(Param.ActionInput.Civ2))'; 603 619 list_param(strcmp('TestCiv2',list_param))=[];% remove the parameter TestCiv2 from the list … … 620 636 end 621 637 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ2_param]; 622 638 623 639 nbvar=numel(Data.ListVarName); 624 640 % define the Civ2 variable (if Civ2 data are not replaced from previous calculation) … … 651 667 end 652 668 end 653 669 654 670 %% Fix2 655 671 if isfield (Param.ActionInput,'Fix2') … … 665 681 Data.CivStage=Data.CivStage+1; 666 682 end 667 683 668 684 %% Patch2 669 685 if isfield (Param.ActionInput,'Patch2') … … 678 694 end 679 695 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Patch2_param]; 680 696 681 697 nbvar=length(Data.ListVarName); 682 698 Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbCentres','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}]; 683 699 Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2',{'nb_coord','nb_bounds','nb_subdomain_2'},{'nb_subdomain_2'},... 684 700 {'nb_tps_2','nb_coord','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'}}]; 685 701 686 702 Data.VarAttribute{nbvar+1}.Role='vector_x'; 687 703 Data.VarAttribute{nbvar+2}.Role='vector_y'; … … 700 716 return 701 717 end 702 718 703 719 [Data.Civ2_SubRange,Data.Civ2_NbCentres,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures,Vres,tild,FFres]=... 704 720 filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomainSize,Data.Patch2_FieldSmooth,Data.Patch2_MaxDiff); … … 710 726 disp('patch2 performed') 711 727 end 712 728 713 729 %% write result in a netcdf file if requested 714 730 % if CheckOutputFile … … 726 742 disp(['time civ2 ' num2str(time_civ2,2) ' s']) 727 743 disp(['time patch2 ' num2str(time_patch2,2) ' s']) 728 744 729 745 end 730 746 … … 747 763 % .ImageB: second image for correlation(matrix) 748 764 % .CorrBoxSize: 1,2 vector giving the size of the correlation box in x and y 749 % .Search BoxSize: 1,2 vector giving the size of the search boxin x and y765 % .SearchRange: 1,2 vector giving the range of the search in x and y 750 766 % .SearchBoxShift: 1,2 vector or 2 column matrix (for civ2) giving the shift of the search box in x and y 751 767 % .CorrSmooth: =1 or 2 determines the choice of the sub-pixel determination of the correlation max … … 764 780 function [xtable,ytable,utable,vtable,wtable,ctable,FF,result_conv,errormsg] = civ3D (par_civ) 765 781 %% check image sizes 766 [npz,npy_ima,npx_ima]=size(par_civ.ImageA);% npz = 782 [npz,npy_ima,npx_ima]=size(par_civ.ImageA);% npz = 767 783 if ~isequal(size(par_civ.ImageB),[npz npy_ima npx_ima]) 768 784 errormsg='image pair with unequal size'; … … 786 802 ibx2=floor(par_civ.CorrBoxSize(1)/2); 787 803 iby2=floor(par_civ.CorrBoxSize(2)/2); 788 isx2=par_civ.SearchRange(1) ;789 isy2=par_civ.SearchRange(2) ;804 isx2=par_civ.SearchRange(1)+ibx2; 805 isy2=par_civ.SearchRange(2)+iby2; 790 806 isz2=par_civ.SearchRange(3); 791 807 kref=isz2+1;%middle index of the z slice … … 878 894 image2_mean=mean(mean(image2_crop,2),3); 879 895 end 880 896 881 897 if FF(ivec_y,ivec_x)==0 882 898 if check_MinIma && (image1_mean < par_civ.MinIma || image2_mean < par_civ.MinIma) 883 899 FF(ivec_y,ivec_x)=1; %threshold on image minimum 884 900 885 901 elseif check_MaxIma && (image1_mean > par_civ.MaxIma || image2_mean > par_civ.MaxIma) 886 902 FF(ivec_y,ivec_x)=1; %threshold on image maximum 887 903 end 888 904 if FF(ivec_y,ivec_x)==1 889 utable(ivec_y,ivec_x)=NaN; 905 utable(ivec_y,ivec_x)=NaN; 890 906 vtable(ivec_y,ivec_x)=NaN; 891 907 else … … 898 914 % % image2_crop=(image2_crop-image2_mean); 899 915 % end 900 916 901 917 npxycorr=2*par_civ.SearchRange(1:2)+1; 902 918 result_conv=zeros([2*par_civ.SearchRange(3)+1 npxycorr]);%initialise the conv product 903 919 max_xy=zeros(2*par_civ.SearchRange(3)+1,1);%initialise the max correlation vs z 904 xk=ones(npz,1);%initialise the x displacement corresponding to the max corr 905 yk=ones(npz,1);%initialise the y displacement corresponding to the max corr 920 xk=ones(npz,1);%initialise the x displacement corresponding to the max corr 921 yk=ones(npz,1);%initialise the y displacement corresponding to the max corr 906 922 subima1=squeeze(image1_crop(kref,:,:))-image1_mean(kref); 907 923 for kz=1:npz 908 subima2=squeeze(image2_crop(kz,:,:))-image2_mean(kz); 924 subima2=squeeze(image2_crop(kz,:,:))-image2_mean(kz); 909 925 correl_xy=conv2(subima2,flip(flip(subima1,2),1),'valid'); 910 926 result_conv(kz,:,:)=correl_xy; 911 max_xy(kz)=max(max(correl_xy)); 912 927 max_xy(kz)=max(max(correl_xy)); 928 [yk(kz),xk(kz)]=find(correl_xy==max_xy(kz),1);%find the indices of the maximum, use 0.999 to avoid rounding errors 913 929 end 914 930 [corrmax,dz]=max(max_xy); … … 932 948 end 933 949 utable(ivec_y,ivec_x)=vector(1)+shiftx(ivec_y,ivec_x); 934 vtable(ivec_y,ivec_x)= vector(2)+shifty(ivec_y,ivec_x);950 vtable(ivec_y,ivec_x)=-vector(2)+shifty(ivec_y,ivec_x); 935 951 wtable(ivec_y,ivec_x)=vector(3); 936 952 xtable(ivec_y,ivec_x)=iref+utable(ivec_y,ivec_x)/2-0.5;% convec flow (velocity taken at the point middle from imgae 1 and 2) … … 938 954 iref=round(xtable(ivec_y,ivec_x)+0.5);% nearest image index for the middle of the vector 939 955 jref=round(ytable(ivec_y,ivec_x)+0.5); 940 % if utable(ivec_y,ivec_x)==0 && vtable(ivec_y,ivec_x)==0941 % 'test'942 % end956 % if utable(ivec_y,ivec_x)==0 && vtable(ivec_y,ivec_x)==0 957 % 'test' 958 % end 943 959 % eliminate vectors located in the mask 944 960 if checkmask && (iref<1 || jref<1 ||iref>npx_ima || jref>npy_ima ||( par_civ.Mask(jref,iref)<200 && par_civ.Mask(jref,iref)>=100)) … … 956 972 end 957 973 end 974 ytable=npy_ima-ytable+1;%reverse from j index to image coordinate y 958 975 result_conv=result_conv*corrmax/(255*sum_square);% keep the last correlation matrix for output 959 976 … … 980 997 f2 = log(result_conv(z+1,y,x)); 981 998 peakz = peakz+ (f1-f2)/(2*f1-4*f0+2*f2); 982 999 983 1000 f1 = log(result_conv(z,y-1,x)); 984 1001 f2 = log(result_conv(z,y+1,x)); 985 1002 peaky = peaky+ (f1-f2)/(2*f1-4*f0+2*f2); 986 1003 987 1004 f1 = log(result_conv(z,y,x-1)); 988 1005 f2 = log(result_conv(z,y,x+1)); … … 1084 1101 1085 1102 if isfield (Param,'MinCorr') 1086 1103 FF(C<Param.MinCorr & FFIn==0)=2; 1087 1104 end 1088 1105 if (isfield(Param,'MinVel')&&~isempty(Param.MinVel))||(isfield (Param,'MaxVel')&&~isempty(Param.MaxVel)) … … 1093 1110 end 1094 1111 if isfield (Param,'MaxVel')&&~isempty(Param.MaxVel) 1095 1112 U2Max=Param.MaxVel*Param.MaxVel; 1096 1113 FF(Umod>U2Max & FFIn==0)=3; 1097 1114 end … … 1139 1156 i1_series=i_series-ind1;% set of first image numbers 1140 1157 i2_series=i_series+ind2; 1141 check_bounds=i1_series <MinIndex_i | i2_series>MaxIndex_i;1158 check_bounds=i1_series(1)<MinIndex_i | i2_series(1)>MaxIndex_i; 1142 1159 if isempty(j_series) 1143 1160 NomTypeNc='_1-2'; -
trunk/src/series/civ_input.m
r1163 r1164 101 101 NomTypeImaA=NomTypeInput; 102 102 iview_image=1;%line # for the input images 103 switch FileType 104 case 'civdata' 105 if ~strcmp(Param.Action.ActionName,'civ_series') 106 msgbox_uvmat('ERROR','bad input data file: open an image or a nc file from civ_series') 107 return 108 end 103 if ismember( FileType,{'civdata','civdata_3D'}) 109 104 NomTypeNc=NomTypeInput; 110 105 ind_opening=SeriesData.FileInfo{1}.CivStage; … … 120 115 end 121 116 122 if size(Param.InputTable,1)==1 123 124 Param.InputTable(2,:)=Param.InputTable(1,:); 125 set(hhseries.InputTable,'Data',Param.InputTable) 117 if size(Param.InputTable,1)==1 126 118 if isfield(Data,'Civ2_ImageA') 127 119 ImageName=Data.Civ2_ImageA; 128 120 elseif isfield(Data,'Civ1_ImageA') 129 121 ImageName=Data.Civ1_ImageA; 122 else 123 msgbox_uvmat('ERROR','no original image defined in netcdf input file ') 124 return 130 125 end 131 series('display_file_name',hhseries,ImageName, 1);%append the image series to the input list126 series('display_file_name',hhseries,ImageName,'append');%append the image series to the input list 132 127 [~,~,~,~,~,~,~,~,NomTypeImaA]=fileparts_uvmat(ImageName); 133 134 % elseif isfield(Data,'Civ2_ImageA') 135 % series('display_file_name',hhseries,Data.Civ2_ImageA,'append');%append the image series to the input list 136 % [~,~,~,~,~,~,~,~,NomTypeImaA]=fileparts_uvmat(Data.Civ2_ImageA); 137 % 138 % end 139 end 140 141 iview_image=1;%line # for the input images 142 otherwise 143 % if ~strcmp(FileType,'image') 144 % msgbox_uvmat('ERROR','civ_series needs images, scalar fields in netcdf format, or civ data as input') 145 % return 146 % end 128 end 129 130 iview_image=2;%line # for the input images 147 131 end 148 132 … … 162 146 return 163 147 end 148 164 149 MaxIndex_i=Param.IndexRange.MaxIndex_i(1); 165 150 MinIndex_i=Param.IndexRange.MinIndex_i(1); -
trunk/src/series/civ_series.m
r1163 r1164 117 117 if Param.ActionInput.CheckCiv1 118 118 iview_A=1;% usual PIV, the image series is on the first line of the table 119 else if Param.ActionInput.CheckCiv2 % civ2 is performed without Civ1, a netcdf file series is needed in the first table line120 iview_A=2;% the second line is used for the input images of Civ2119 else % Civ1 has been already stored in a netcdf file input 120 iview_A=2;% the second line is used for the input images 121 121 end 122 122 if iview_A~=0 … … 274 274 tstart=tic; 275 275 time_civ1=0; 276 time_patch1=0;277 time_civ2=0;278 time_patch2=0;276 time_patch1=0; 277 time_civ2=0; 278 time_patch2=0; 279 279 if ~isempty(RUNHandle)% update the waitbar in interactive mode with GUI series (checkrun=1) 280 280 update_waitbar(WaitbarHandle,ifield/NbField) … … 335 335 %% Civ1 336 336 % if Civ1 computation is requested 337 if isfield (Param.ActionInput,'Civ1')337 if Param.ActionInput.CheckCiv1 338 338 if CheckInputFile 339 339 disp('civ1 started') … … 377 377 end 378 378 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield)); 379 380 381 382 383 384 385 386 387 379 if isempty(FileType_B)% determine the image type for the first field 380 [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B); 381 FileType_B=FileInfo_B.FileType; 382 end 383 if isempty(regexp(ImageName_B,'(^http://)|(^https://)', 'once')) && ~exist(ImageName_B,'file') 384 disp([ImageName_B ' missing']) 385 continue 386 end 387 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield)); 388 388 catch ME % display errors in reading input images 389 389 if ~isempty(ME.message) … … 392 392 end 393 393 end 394 394 395 % par_civ1.ImageWidth=size(par_civ1.ImageA,2); 395 396 % par_civ1.ImageHeight=size(par_civ1.ImageA,1); … … 425 426 end 426 427 Data.ListGlobalAttribute=[ListGlobalAttribute Civ1_param]; 428 427 429 Data.CivStage=1; 428 430 else … … 438 440 Data.VarAttribute{5}.Role='ancillary'; 439 441 Data.VarAttribute{6}.Role='errorflag'; 440 442 441 443 % case of mask 442 444 if par_civ1.CheckMask&&~isempty(par_civ1.Mask) … … 451 453 i1_mask=mod(i1-1,par_civ1.NbSlice)+1; 452 454 maskname=fullfile_uvmat(RootPath_mask,SubDir_mask,RootFile_mask,Ext_mask,'_1',i1_mask); 453 else 454 maskname=Param.ActionInput.Civ1.Mask; 455 end 456 if strcmp(maskoldname,maskname)% mask exist, not already read in civ1 457 par_civ1.Mask=mask; %use mask already opened 458 else 459 if ~isempty(regexp(maskname,'(^http://)|(^https://)', 'once'))|| exist(maskname,'file') 460 try 461 par_civ1.Mask=imread(maskname);%update the mask, an store it for future use 462 catch ME 463 if ~isempty(ME.message) 464 errormsg=['error reading input image: ' ME.message]; 465 disp_uvmat('ERROR',errormsg,checkrun) 466 return 467 end 455 if strcmp(Param.ActionInput.PairIndices.ListPairMode,'series(Di)')% case of volume, mask index refers to j index 456 par_civ1.NbSlice_j=par_civ1.NbSlice; 457 end 458 end 459 else 460 maskname=Param.ActionInput.Civ1.Mask; 461 end 462 if strcmp(maskoldname,maskname)% mask exist, not already read in civ1 463 par_civ1.Mask=mask; %use mask already opened 464 else 465 if ~isempty(regexp(maskname,'(^http://)|(^https://)', 'once'))|| exist(maskname,'file') 466 try 467 par_civ1.Mask=imread(maskname);%update the mask, an store it for future use 468 catch ME 469 if ~isempty(ME.message) 470 errormsg=['error reading input image: ' ME.message]; 471 disp_uvmat('ERROR',errormsg,checkrun) 472 return 468 473 end 469 else 470 par_civ1.Mask=[]; 471 end 472 mask=par_civ1.Mask; 473 maskoldname=maskname; 474 end 475 end 476 474 end 475 else 476 par_civ1.Mask=[]; 477 end 478 mask=par_civ1.Mask; 479 maskoldname=maskname; 480 end 481 482 477 483 % case of input grid 478 484 if par_civ1.CheckGrid &&~isempty(par_civ1.Grid) … … 481 487 par_civ1.CorrBoxSize=GridData.CorrBox; 482 488 end 483 484 % caluclate velocity data 489 490 % caluclate velocity data 485 491 tstart_civ1=tic; 486 492 [Data.Civ1_X,Data.Civ1_Y,Data.Civ1_U,Data.Civ1_V,Data.Civ1_C,Data.Civ1_FF, result_conv, errormsg] = civ (par_civ1); … … 489 495 return 490 496 end 491 492 else% we use existing Civ1 data 497 493 498 if exist('ncfile','var') 494 499 CivFile=ncfile; 495 [Data,tild,tild,errormsg]=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format496 if ~isempty(errormsg)497 disp_uvmat('ERROR',errormsg,checkrun)498 return499 end500 % [Data,tild,tild,errormsg]=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format 501 % if ~isempty(errormsg) 502 % disp_uvmat('ERROR',errormsg,checkrun) 503 % return 504 % end 500 505 [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file 501 506 elseif isfield(Param,'Civ1_X') … … 510 515 end 511 516 end 517 512 518 513 519 %% Fix1 … … 717 723 i1_mask=mod(i1-1,par_civ2.NbSlice)+1; 718 724 maskname=fullfile_uvmat(RootPath_mask,SubDir_mask,RootFile_mask,Ext_mask,'_1',i1_mask); 725 if strcmp(Param.ActionInput.PairIndices.ListPairMode,'series(Di)')% case of volume, mask index refers to j index 726 par_civ2.NbSlice_j=par_civ2.NbSlice; 727 end 719 728 else 720 729 maskname=Param.ActionInput.Civ2.Mask; … … 876 885 if isempty(errormsg) 877 886 disp([ncfile_out ' written']) 878 %[success,msg] = fileattrib(ncfile_out ,'+w','g');% done in struct2nc879 887 else 880 888 disp(errormsg) -
trunk/src/series/extract_rdvision.m
r1163 r1164 160 160 timestamp(ii)=m.Data(ii).timestamp; 161 161 end 162 163 % 164 % %%%%%BRICOLAGE EXP40 165 % ind1=5*59-10; 166 % ind2=12*59-10; 167 % ind3=119*59-10; 168 % ind4=483*59-10; 169 % timestamp=[timestamp(1:ind4) timestamp(ind4) timestamp(ind4+1:end)]; 170 % timestamp=[timestamp(1:ind3) timestamp(ind3) timestamp(ind3+1:end)]; 171 % timestamp=[timestamp(1:ind2) timestamp(ind2) timestamp(ind2+1:end)]; 172 % timestamp=[timestamp(1:ind1) timestamp(ind1) timestamp(ind1+1:end)]; 173 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 174 175 162 176 163 if ParamOut.ActionInput.Createxml 177 164 ParamOut.ActionInput.XmlData.Camera.BurstTiming=time2xmlburst(timestamp,ParamOut.ActionInput.BurstLength); … … 457 444 end 458 445 bin_file_counter=0; 459 %for ii=1:SeqData.nb_frames460 %%%%%BRICOLAGE EXP40461 ind1=5*59-10;462 ind2=12*59-10;463 ind3=119*59-10;464 ind4=483*59-10;465 446 466 447 for ii=first:last 467 448 j1=[]; 468 449 iinew=ii; 469 % %%%%%BRICOLAGE EXP40 470 % switch ii 471 % case ii>=ind1 && ii<ind2 472 % iinew=ii+1; 473 % case ii>=ind2 && ii<ind3 474 % iinew=ii+2; 475 % case ii>=ind3 && ii<ind4 476 % iinew=ii+3; 477 % case ii>=ind4 && ii<ind3 478 % iinew=ii+4; 479 % end 480 % %%%%%%%%% 450 481 451 if ~isequal(nbfield2,1) 482 452 j1=mod(iinew-1,nbfield2)+1; -
trunk/src/uvmat.m
r1163 r1164 2198 2198 %------------------------------------------------------------------------ 2199 2199 % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput' 2200 function errormsg=display_file_name(handles,fileinput,in dex)2200 function errormsg=display_file_name(handles,fileinput,input_line) 2201 2201 %------------------------------------------------------------------------ 2202 2202 %% look for the input file existence … … 2208 2208 end 2209 2209 2210 %% define the relevant handles for the first field series (in dex=1) or the second file series (index=2)2211 if ~exist('in dex','var')2212 in dex=1;2213 end 2214 if in dex==12210 %% define the relevant handles for the first field series (input_line=1) or the second file series (input_line=2) 2211 if ~exist('input_line','var') 2212 input_line=1; 2213 end 2214 if input_line==1 2215 2215 handles_RootPath=handles.RootPath; 2216 2216 handles_SubDir=handles.SubDir; … … 2219 2219 handles_NomType=handles.NomType; 2220 2220 handles_FileExt=handles.FileExt; 2221 elseif in dex==22221 elseif input_line==2 2222 2222 handles_RootPath=handles.RootPath_1; 2223 2223 handles_SubDir=handles.SubDir_1; … … 2287 2287 set(handles_NomType,'String',NomType); 2288 2288 set(handles_FileExt,'String',FileExt); 2289 if in dex==12289 if input_line==1 2290 2290 % fill file index counters if the first file series is opened 2291 2291 set(handles.i1,'String',num2str(i1)); … … 2293 2293 set(handles.j1,'String',num2stra(j1,NomType)); 2294 2294 set(handles.j2,'String',num2stra(j2,NomType)); 2295 if isfield(FileInfo,'MaskFile') 2296 set(handles.CheckMask,'Value',1) 2297 Mask.File=FileInfo.MaskFile; 2298 if isfield(FileInfo,'MaskNbSlice') 2299 Mask.NbSlice=FileInfo.MaskNbSlice; 2300 elseif isfield(FileInfo,'VolumeScan') 2301 Mask.VolumeScan=FileInfo.VolumeScan; 2302 end 2303 set(handles.CheckMask,'UserData', Mask) 2304 else 2305 set(handles.CheckMask,'Value',0) 2306 CheckMask_Callback(handles.CheckMask, [], handles) 2307 end 2295 2308 else %read the current field index to synchronise with the first series 2296 2309 i1_s=str2num(get(handles.i1,'String')); … … 2351 2364 2352 2365 % initiate input file series and inputfilerefresh the current field view: 2353 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,in dex);2366 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,input_line); 2354 2367 end 2355 2368 … … 2379 2392 % --- Update information about a new field series (indices to scan, timing, 2380 2393 % calibration from an xml file, then inputfilerefresh current plots 2381 function errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,VideoObject,in dex)2394 function errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,VideoObject,input_line) 2382 2395 %------------------------------------------------------------------------ 2383 2396 errormsg=''; %default error msg 2384 2397 2385 %% define the relevant handles depending on the in dex(1=first file series, 2= second file series)2386 if ~exist('in dex','var')2387 in dex=1;2388 end 2389 if in dex==12398 %% define the relevant handles depending on the input_line (1=first file series, 2= second file series) 2399 if ~exist('input_line','var') 2400 input_line=1; 2401 end 2402 if input_line==1 2390 2403 handles_Fields=handles.FieldName; 2391 elseif in dex==22404 elseif input_line==2 2392 2405 handles_Fields=handles.FieldName_1; 2393 2406 end … … 2398 2411 UvData.NewSeries=1; %flag for REFRESH: begin a new series 2399 2412 UvData.FileName_1='';% name of the current second field (used to detect a constant field during file scanning) 2400 %UvData.FileType{in dex}=FileInfo.FileType;2401 UvData.FileInfo{in dex}=FileInfo;2402 UvData.MovieObject{in dex}=VideoObject;2403 UvData.i1_series{in dex}=i1_series;2404 UvData.i2_series{in dex}=i2_series;2405 UvData.j1_series{in dex}=j1_series;2406 UvData.j2_series{in dex}=j2_series;2413 %UvData.FileType{input_line}=FileInfo.FileType; 2414 UvData.FileInfo{input_line}=FileInfo; 2415 UvData.MovieObject{input_line}=VideoObject; 2416 UvData.i1_series{input_line}=i1_series; 2417 UvData.i2_series{input_line}=i2_series; 2418 UvData.j1_series{input_line}=j1_series; 2419 UvData.j2_series{input_line}=j2_series; 2407 2420 nbfield=max(max(max(i2_series)));% total number of fields (i index) 2408 2421 if isempty(nbfield) … … 2447 2460 %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) 2448 2461 XmlData.GeometryCalib=[];%default 2449 if in dex==12462 if input_line==1 2450 2463 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 2451 2464 else … … 2515 2528 TimeName='civdata_3D'; 2516 2529 end 2517 if in dex==12530 if input_line==1 2518 2531 set(handles.TimeName,'String',TimeName) 2519 2532 else … … 2531 2544 last_i_cell=get(handles.MaxIndex_i,'String'); 2532 2545 if isempty(nbfield) 2533 last_i_cell{in dex}='';2534 else 2535 last_i_cell{in dex}=num2str(nbfield);2546 last_i_cell{input_line}=''; 2547 else 2548 last_i_cell{input_line}=num2str(nbfield); 2536 2549 end 2537 2550 set(handles.MaxIndex_i,'String',last_i_cell) 2538 2551 last_j_cell=get(handles.MaxIndex_j,'String'); 2539 2552 if isempty(nbfield_j) 2540 last_j_cell{in dex}='';2541 else 2542 last_j_cell{in dex}=num2str(nbfield_j);2553 last_j_cell{input_line}=''; 2554 else 2555 last_j_cell{input_line}=num2str(nbfield_j); 2543 2556 end 2544 2557 set(handles.MaxIndex_j,'String',last_j_cell); … … 2552 2565 set(handles.pxcmx,'Visible','off') 2553 2566 set(handles.pxcmy,'Visible','off') 2554 if in dex==12567 if input_line==1 2555 2568 set(handles.TransformName,'Value',1); % no transform by default 2556 2569 end … … 2568 2581 set(handles.pxcmy,'String',num2str(pixcmy)) 2569 2582 end 2570 if ~get(handles.CheckFixLimits,'Value')&& in dex==12583 if ~get(handles.CheckFixLimits,'Value')&& input_line==1 2571 2584 set(handles.TransformName,'Value',3); % phys transform by default if fixedLimits is off 2572 2585 end … … 2591 2604 %% update the data attached to the uvmat interface 2592 2605 if ~isempty(TimeUnit) 2593 if in dex==2 && isfield(UvData,'TimeUnit') && ~strcmp(UvData.TimeUnit,TimeUnit)2606 if input_line==2 && isfield(UvData,'TimeUnit') && ~strcmp(UvData.TimeUnit,TimeUnit) 2594 2607 msgbox_uvmat('WARNING',['time unit for second file series ' TimeUnit ' inconsistent with first series']) 2595 2608 else … … 2597 2610 end 2598 2611 end 2599 UvData.XmlData{in dex}=XmlData;2612 UvData.XmlData{input_line}=XmlData; 2600 2613 UvData.NewSeries=1; 2601 2614 set(handles.uvmat,'UserData',UvData) … … 2612 2625 set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data 2613 2626 set(handles_Fields,'Value',2) % set menu to 'velocity 2614 if in dex==12627 if input_line==1 2615 2628 set(handles.FieldName_1,'Value',1); 2616 2629 set(handles.FieldName_1,'String',[{''};{'image'};FieldList;{'get_field...'}]);%standard menu for civx data reproduced for the second field … … 2627 2640 set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data 2628 2641 set(handles_Fields,'Value',2) % set menu to 'velocity 2629 if in dex==12642 if input_line==1 2630 2643 set(handles.FieldName_1,'Value',1); 2631 2644 set(handles.FieldName_1,'String',[{''};{'image'};FieldList;{'get_field...'}]);%standard menu for civx data reproduced for the second field … … 2641 2654 set(handles_Fields,'Value',1) 2642 2655 set(handles_Fields,'String',{'get_field...'}) 2643 if in dex==12656 if input_line==1 2644 2657 FieldName_Callback([],[], handles) 2645 2658 else … … 2660 2673 scan_option='i';%default 2661 2674 state_j='off'; %default 2662 if in dex==22675 if input_line==2 2663 2676 if get(handles.scan_j,'Value') 2664 2677 scan_option='j'; %keep the scan option for the second file series … … 2672 2685 if ~isempty(j1_series) 2673 2686 state_j='on'; 2674 if in dex==12687 if input_line==1 2675 2688 if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first value 2676 2689 scan_option='j'; %scan j indext … … 2707 2720 if ~isempty(i2_series)||~isempty(j2_series) 2708 2721 set(handles.CheckFixPair,'Visible','on') 2709 elseif in dex==12722 elseif input_line==1 2710 2723 set(handles.CheckFixPair,'Visible','off') 2711 2724 end … … 2713 2726 %% apply the effect of the transform fct and view the field 2714 2727 transform=get(handles.TransformPath,'UserData'); 2715 if in dex==2 && (~isa(transform,'function_handle')||nargin(transform)<3)2728 if input_line==2 && (~isa(transform,'function_handle')||nargin(transform)<3) 2716 2729 set(handles.TransformName,'value',2); % set transform to sub_field if the current fct doe not accept two input fields 2717 2730 end … … 2908 2921 end 2909 2922 if mdetect==0 % if no mask is detected in the current folder 2910 MaskFullName=uigetfile_uvmat('pick a mask image file:',RootPath,'image'); 2911 if isempty(MaskFullName) 2912 set(handles.CheckMask,'Value',0) 2913 end 2914 2915 [MaskPath,MaskName,MaskExt]=fileparts(MaskFullName); 2916 [tild,tild,MaskFile,i1_series,i2,j1,j2,MaskNomType]=find_file_series(MaskPath,[MaskName MaskExt],0); 2923 filemask= uigetfile_uvmat('pick a mask image file:',RootPath,'image'); 2924 if ~isempty(filemask) 2925 [FilePath,FileName,FileExt]=fileparts(filemask); 2926 [RootPath,SubDir,RootFile,i1_series,i2,j1,j2,NomType]=find_file_series(FilePath,[FileName FileExt]); 2917 2927 if strcmp(NomType,'_1') 2918 2928 NbSlice=i1_series(1,2,end); 2919 set(handles.num_NbSlice,'String',num2str(NbSlice)) 2920 end 2929 set(handles.num_NbSlice,'String',num2str(NbSlice)) 2930 elseif ~strcmp(NomType,'*') 2931 msgbox_uvmat('ERROR','multilevel masks must be labeled with a single index as _1,_2,...'); 2932 return 2933 end 2934 set(hObject,'UserData',filemask);%store for future use 2935 testmask=1; 2936 end 2937 2938 %TO COMPLEMENT...................... 2939 2940 2941 % MaskFullName=uigetfile_uvmat('pick a mask image file:',RootPath,'image'); 2942 % if isempty(MaskFullName) 2943 % set(handles.CheckMask,'Value',0) 2944 % end 2945 % 2946 % [MaskPath,MaskName,MaskExt]=fileparts(MaskFullName); 2947 % [tild,tild,MaskFile,i1_series,i2,j1,j2,MaskNomType]=find_file_series(MaskPath,[MaskName MaskExt],0); 2948 % if strcmp(MaskNomType,'_1') 2949 % NbSlice=i1_series(1,2,end); 2950 % set(handles.num_NbSlice,'String',num2str(NbSlice)) 2951 % end 2921 2952 end 2922 2953 % Mask.Path=MaskPath; … … 2961 2992 %------------------------------------------------------------------------ 2962 2993 errormsg=[];%default 2963 Mask=get(handles.CheckMask,'UserData'); 2964 if strcmp(get(handles.z_index,'Visible'),'on') 2965 MaskIndex_i=str2num(get(handles.z_index,'String')); 2966 else 2967 MaskIndex_i=mod(str2num(get(handles.i1,'String'))-1,Mask.NbSlice_i)+1; 2968 end 2969 MaskIndex_z=MaskIndex_i;%default 2970 if Mask.NbSlice_j>1 2971 MaskIndex_j=str2num(get(handles.j1,'String')); 2972 MaskIndex_z=MaskIndex_j; 2973 else 2974 MaskIndex_j=1; 2975 end 2976 if isfield(Mask,'maskhandle')&& ishandle(Mask.maskhandle) 2977 uistack(Mask.maskhandle,'top'); 2978 end 2979 MaskName=fullfile_uvmat(Mask.Path,'',Mask.File,Mask.Ext,Mask.NomType,MaskIndex_i,[],MaskIndex_j); 2980 UvData=get(handles.uvmat,'UserData'); 2981 2982 %% update mask image if the mask is new 2983 if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName)) 2984 UvData.MaskName=MaskName; %update the recorded name on UvData 2985 set(handles.uvmat,'UserData',UvData); 2986 if ~exist(MaskName,'file') 2987 if isfield(Mask,'maskhandle')&& ishandle(Mask.maskhandle) 2988 delete(Mask.maskhandle) 2989 end 2994 MaskName=''; 2995 2996 %% get the current mask name recorded in CheckMask/UserData, possibly indexed with file index 2997 MaskInfo=get(handles.CheckMask,'UserData'); 2998 if isfield(MaskInfo,'File') 2999 if isfield(MaskInfo,'NbSlice') 3000 if isfield(MaskInfo,'VolumeScan') && MaskInfo.VolumeScan 3001 MaskIndex_i=str2num(get(handles.j1,'String')); 3002 else 3003 MaskIndex_i=mod(str2num(get(handles.i1,'String'))-1,MaskInfo.NbSlice)+1; 3004 end 3005 MaskName=[MaskInfo.File '_' num2str(MaskIndex_i) '.png']; 2990 3006 else 2991 %read mask image 2992 [MaskField,tild,errormsg] = read_field(MaskName,'image'); 2993 if ~isempty(errormsg) 2994 return 2995 end 2996 npxy=size(MaskField.A); 2997 if length(npxy)>2 2998 errormsg=[MaskName ' is not a grey scale image']; 2999 return 3000 elseif ~isa(MaskField.A,'uint8') 3001 errormsg=[MaskName ' is not a 8 bit grey level image']; 3002 return 3003 end 3004 MaskField.ZIndex=MaskIndex_z; 3005 %px to phys or other transform on field 3006 menu_transform=get(handles.TransformName,'String'); 3007 choice_value=get(handles.TransformName,'Value'); 3008 transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' 3009 transform=get(handles.TransformPath,'UserData'); 3010 if ~isequal(transform_name,'') && ~isequal(transform_name,'px') 3011 if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority 3012 Calib=UvData.XmlData{1}.GeometryCalib; 3013 MaskField=transform(MaskField,UvData.XmlData{1}); 3014 end 3015 end 3016 flagmask=MaskField.A < 200; 3017 3018 %make brown color image 3019 imflag(:,:,1)=0.9*flagmask; 3020 imflag(:,:,2)=0.7*flagmask; 3021 imflag(:,:,3)=zeros(size(flagmask)); 3022 3023 %update mask image 3024 hmask=[]; %default 3025 if isfield(Mask,'maskhandle')&& ishandle(Mask.maskhandle) 3026 hmask=Mask.maskhandle; 3027 end 3028 if ~isempty(hmask) 3029 set(hmask,'CData',imflag) 3030 set(hmask,'AlphaData',flagmask*0.6) 3031 set(hmask,'XData',MaskField.Coord_x); 3032 set(hmask,'YData',MaskField.Coord_y); 3033 % uistack(hmask,'top') 3007 MaskIndex_i=1; 3008 MaskName=MaskInfo.MaskFile; 3009 end 3010 3011 %% update mask image if the mask is new 3012 UvData=get(handles.uvmat,'UserData'); 3013 if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName)) 3014 UvData.MaskName=MaskName; %update the recorded name on UvData 3015 set(handles.uvmat,'UserData',UvData); 3016 if ~exist(MaskName,'file') 3017 if isfield(Mask,'maskhandle')&& ishandle(Mask.maskhandle) 3018 delete(Mask.maskhandle) 3019 end 3034 3020 else 3035 axes(handles.PlotAxes) 3036 hold on 3037 Mask.maskhandle=image(MaskField.Coord_x,MaskField.Coord_y,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*ones(size(flagmask))); 3038 set(handles.CheckMask,'UserData',Mask) 3039 end 3040 end 3041 end 3042 3021 %read mask image 3022 [MaskField,tild,errormsg] = read_field(MaskName,'image'); 3023 if ~isempty(errormsg) 3024 return 3025 end 3026 npxy=size(MaskField.A); 3027 if length(npxy)>2 3028 errormsg=[MaskName ' is not a grey scale image']; 3029 return 3030 elseif ~isa(MaskField.A,'uint8') 3031 errormsg=[MaskName ' is not a 8 bit grey level image']; 3032 return 3033 end 3034 MaskField.ZIndex=MaskIndex_i; 3035 %px to phys or other transform on field 3036 menu_transform=get(handles.TransformName,'String'); 3037 choice_value=get(handles.TransformName,'Value'); 3038 transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' 3039 transform=get(handles.TransformPath,'UserData'); 3040 if ~isequal(transform_name,'') && ~isequal(transform_name,'px') 3041 if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority 3042 Calib=UvData.XmlData{1}.GeometryCalib; 3043 MaskField=transform(MaskField,UvData.XmlData{1}); 3044 end 3045 end 3046 flagmask=MaskField.A < 200; 3047 3048 %make brown color image 3049 imflag(:,:,1)=0.9*flagmask; 3050 imflag(:,:,2)=0.7*flagmask; 3051 imflag(:,:,3)=zeros(size(flagmask)); 3052 3053 %update mask image 3054 hmask=[]; %default 3055 if isfield(MaskInfo,'maskhandle')&& ishandle(MaskInfo.maskhandle) 3056 hmask=MaskInfo.maskhandle; 3057 end 3058 if ~isempty(hmask) 3059 set(hmask,'CData',imflag) 3060 set(hmask,'AlphaData',flagmask*0.6) 3061 set(hmask,'XData',MaskField.Coord_x); 3062 set(hmask,'YData',MaskField.Coord_y); 3063 % uistack(hmask,'top') 3064 else 3065 axes(handles.PlotAxes) 3066 hold on 3067 MaskInfo.maskhandle=image(MaskField.Coord_x,MaskField.Coord_y,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*ones(size(flagmask))); 3068 set(handles.CheckMask,'UserData',MaskInfo) 3069 end 3070 end 3071 end 3072 end 3043 3073 %------------------------------------------------------------------------ 3044 3074 %------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.