- Timestamp:
- May 31, 2012, 8:21:06 AM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src
- Property svn:ignore
-
old new 4 4 XML_SCHEMAS 5 5 bin 6 check_files.m 6 7 toolbox_calib 7 8 uvmat_doc
-
- Property svn:ignore
-
trunk/src/civ.m
r427 r435 1 1 2 %'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch) 2 3 %------------------------------------------------------------------------ … … 63 64 t=xmltree(xmlfile); 64 65 sparam=convert(t); 65 catch 66 errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr};66 catch ME 67 errormsg={' Unable to read the file PARAM.xml defining the civx binaries:';ME.message}; 67 68 end 68 69 else … … 409 410 % end 410 411 switch FileType 411 case {'image','multimage','video' }412 case {'image','multimage','video','mmreader'} 412 413 otherwise 413 414 errormsg='invalid input file: enter an image, a movie or civ .nc file'; … … 1059 1060 1060 1061 1061 %-------------- ----------------------------------------------------------1062 %--------------orm---------------------------------------------------------- 1062 1063 % --- Main lauch command, called by RUN and BATCH 1063 1064 function errormsg=launch_jobs(hObject, eventdata, handles, batch) … … 1227 1228 if ~strcmp(CivMode,'CivX') 1228 1229 if Param.CheckCiv1 1229 [Param.Civ1.FileTypeA,FileInfo,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1});1230 [Param.Civ1.FileTypeB,FileInfo,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1});1230 [Param.Civ1.FileTypeA,FileInfo,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1}); 1231 [Param.Civ1.FileTypeB,FileInfo,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1}); 1231 1232 end 1232 1233 if Param.CheckCiv2 1233 [Param.Civ2.FileTypeA,FileInfo,Param.Civ2.ImageA]=get_file_type(filecell.ima1.civ2{1});1234 [Param.Civ2.FileTypeB,FileInfo,Param.Civ2.ImageB]=get_file_type(filecell.ima2.civ2{1});1234 [Param.Civ2.FileTypeA,FileInfo,Param.Civ2.ImageA]=get_file_type(filecell.ima1.civ2{1}); 1235 [Param.Civ2.FileTypeB,FileInfo,Param.Civ2.ImageB]=get_file_type(filecell.ima2.civ2{1}); 1235 1236 end 1236 1237 end … … 1271 1272 if Param.CheckCiv1 1272 1273 % read image-dependent parameters 1273 Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j}; 1274 Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j}; 1274 1275 1275 if ~checkframe% && size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j) 1276 1276 Param.Civ1.Dt=(time(i2_civ1(ifile)+1,j2_civ1(j)+1)-time(i1_civ1(ifile)+1,j1_civ1(j)+1)); … … 1280 1280 Param.Civ1.Time=((time(i2_civ1(ifile)+1,j2_civ1(j)+1)+time(i1_civ1(ifile)+1,j1_civ1(j)+1))/2); 1281 1281 if strcmp(CivMode,'CivX') 1282 Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE? 1283 Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);% 1284 end 1285 form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats 1286 if isempty(form) 1287 ImageInfo=get(VideoReader(filecell.ima1.civ1{1,1})); 1282 Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE? 1283 Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);% 1284 end 1285 if strcmp(Param.Civ1.FileTypeA,'video')|| strcmp(Param.Civ1.FileTypeA,'mmreader') 1286 % ImageInfo=get(VideoReader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt]))); 1287 ImageInfo=get(Param.Civ1.ImageA); 1288 % elseif strcmp(Param.Civ1.FileTypeA,'mmreader') 1289 % ImageInfo=get(mmreader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt]))); 1288 1290 Param.Civ1.ImageBitDepth=ImageInfo.BitsPerPixel/3; 1291 if batch 1292 Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j};%file name must be used for batch instead of video object 1293 Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j}; 1294 end 1289 1295 else 1296 Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j}; 1297 Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j}; 1298 form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats 1290 1299 ImageInfo=imfinfo(filecell.ima1.civ1{1,1});%read the first image to get the size 1291 1300 Param.Civ1.ImageBitDepth=ImageInfo.BitDepth; 1292 1301 end 1302 1293 1303 Param.Civ1.ImageWidth=ImageInfo.Width; 1294 1304 Param.Civ1.ImageHeight=ImageInfo.Height; 1295 Param.Civ1. i1=i1_civ1(ifile);1296 Param.Civ1. i2=i2_civ1(ifile);1297 % read mask parameters1305 Param.Civ1.FrameIndexA=i1_civ1(ifile); 1306 Param.Civ1.FrameIndexB=i2_civ1(ifile); 1307 % read mask )parameters 1298 1308 if Param.Civ1.CheckMask % the lines below should be changed with the new gui 1299 1309 if ~exist(Param.Civ1.Mask,'file') … … 1312 1322 i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1; 1313 1323 Param.Civ1.Grid=[filecell.filebase '_' fullfile_uvmat('','',Param.Civ1.Grid,'.grid','_1',i1_grid)]; 1314 % Param.Civ1.Grid=[filecell.filebase '_' name_generator(Param.Civ1.Grid,i1_grid,1,'.grid','_i')];1324 % Param.Civ1.Grid=[filecell.filebase '_' name_generator(Param.Civ1.Grid,i1_grid,1,'.grid','_i')]; 1315 1325 if ~exist(Param.Civ1.GridName,'file') 1316 1326 errormsg='grid file absent for civ1'; … … 1424 1434 end 1425 1435 if Param.CheckCiv2==1 1426 Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j}; 1427 Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j}; 1436 if strcmp(Param.Civ2.FileTypeA,'video')|| strcmp(Param.Civ2.FileTypeA,'mmreader') 1437 % ImageInfo=get(VideoReader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt]))); 1438 ImageInfo=get(Param.Civ2.ImageA); 1439 % elseif strcmp(Param.Civ1.FileTypeA,'mmreader') 1440 % ImageInfo=get(mmreader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt]))); 1441 Param.Civ2.ImageBitDepth=ImageInfo.BitsPerPixel/3; 1442 if batch 1443 Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j};%file name must be used for batch instead of video object 1444 Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j}; 1445 end 1446 else 1447 Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j}; 1448 Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j}; 1449 form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats 1450 ImageInfo=imfinfo(filecell.ima1.civ2{1,1});%read the first image to get the size 1451 Param.Civ2.ImageBitDepth=ImageInfo.BitDepth; 1452 end 1453 1428 1454 if ~checkframe %&& size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j) 1429 1455 Param.Civ2.Dt=time(i2_civ2(ifile)+1,j2_civ2(j)+1)-time(i1_civ2(ifile)+1,j1_civ2(j)+1); … … 1463 1489 form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats 1464 1490 if isempty(form) 1465 ImageInfo=get(VideoReader(filecell.ima1.civ2{1,1}));1491 % ImageInfo=get(VideoReader(fullfile()); 1466 1492 Param.Civ2.ImageBitDepth=ImageInfo.BitsPerPixel/3; 1467 1493 else … … 1471 1497 Param.Civ2.ImageWidth=ImageInfo.Width; 1472 1498 Param.Civ2.ImageHeight=ImageInfo.Height; 1473 Param.Civ2.i1=i1_civ2(ifile); 1474 Param.Civ2.i2=i2_civ2(ifile); 1499 Param.Civ2.FrameIndexA=i1_civ2(ifile); 1500 Param.Civ2.FrameIndexB=i2_civ2(ifile); 1501 % Param.Civ2.i1=i1_civ2(ifile); 1502 % Param.Civ2.i2=i2_civ2(ifile); 1475 1503 switch CivMode 1476 1504 case 'CivX' … … 4000 4028 par_civ1.ImageHeight=size(Data.A,1); 4001 4029 par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation 4002 par_civ1. i1=i1;4003 par_civ1. i2=i2;4030 par_civ1.FrameIndexA=num2str(i1); 4031 par_civ1.FrameIndexB=num2str(i2); 4004 4032 Param.Civ1=par_civ1; 4005 4033 Grid=civ_matlab(Param);% get the grid of x, y positions set for PIV -
trunk/src/civ_matlab.m
r411 r435 52 52 check_patch1=0;%default 53 53 54 % case of input Param set by an xml file (batch mode) 54 55 if ischar(Param) 55 56 Param=xml2struct(Param); %if Param is the name of an xml file, read this file as a Matlab structure 57 if isfield(Param,'Civ1') 58 if strcmp(Param.Civ1.FileTypeA,'video') 59 Param.Civ1.ImageA=VideoReader(Param.Civ1.ImageA); 60 elseif strcmp(Param.Civ1.FileTypeA,'mmreader') 61 Param.Civ1.ImageA=mmreader(Param.Civ1.ImageA); 62 end 63 if strcmp(Param.Civ1.FileTypeB,'video') 64 Param.Civ1.ImageB=VideoReader(Param.Civ1.ImageB); 65 elseif strcmp(Param.Civ1.FileTypeB,'mmreader') 66 Param.Civ1.ImageB=mmreader(Param.Civ1.ImageB); 67 end 68 end 69 if isfield(Param,'Civ2') 70 if strcmp(Param.Civ2.FileTypeA,'video') 71 Param.Civ2.ImageA=VideoReader(Param.Civ2.ImageA); 72 elseif strcmp(Param.Civ2.FileTypeA,'mmreader') 73 Param.Civ2.ImageA=mmreader(Param.Civ2.ImageA); 74 end 75 if strcmp(Param.Civ2.FileTypeB,'video') 76 Param.Civ2.ImageB=VideoReader(Param.Civ2.ImageB); 77 elseif strcmp(Param.Civ2.FileTypeB,'mmreader') 78 Param.Civ2.ImageB=mmreader(Param.Civ2.ImageB); 79 end 80 end 56 81 end 57 82 58 83 %% Civ1 59 84 if isfield (Param,'Civ1') 60 % check_civ1=1;% test for further use of civ1 results85 % check_civ1=1;% test for further use of civ1 results 61 86 % %% prepare images 62 87 par_civ1=Param.Civ1; … … 72 97 end 73 98 else 74 if isfield(par_civ1,'ImageA')&&(ischar(par_civ1.ImageA)||strcmp(class(par_civ1.ImageA),'VideoReader')) % case with no image: only the PIV grid is calculated 75 [Field,ParamOut,errormsg] = read_field(par_civ1.ImageA,par_civ1.FileTypeA,[],par_civ1.i1); 76 par_civ1.ImageA=Field.A;%imread(par_civ1.ImageA);%[Field,ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num) 77 end 78 if isfield(par_civ1,'ImageB')&& (ischar(par_civ1.ImageB)||strcmp(class(par_civ1.ImageA),'VideoReader')) 79 [Field,ParamOut,errormsg] = read_field(par_civ1.ImageB,par_civ1.FileTypeB,[],par_civ1.i2); 80 par_civ1.ImageB=Field.A;%=imread(par_civ1.ImageB); 99 if isfield(par_civ1,'ImageA')%&&(ischar(par_civ1.ImageA)||strcmp(class(par_civ1.ImageA),'VideoReader')) % case with no image: only the PIV grid is calculated 100 101 [Field,ParamOut,errormsg] = read_field(par_civ1.ImageA,par_civ1.FileTypeA,[],par_civ1.FrameIndexA); 102 if ~isempty(errormsg) 103 errormsg=['error in civ_matlab/read_field:' errormsg]; 104 return 105 end 106 par_civ1.ImageA=Field.A;%= image matrix A in the first input field 107 end 108 if isfield(par_civ1,'ImageB')%&& (ischar(par_civ1.ImageB)||strcmp(class(par_civ1.ImageA),'VideoReader')) 109 [Field,ParamOut,errormsg] = read_field(par_civ1.ImageB,par_civ1.FileTypeB,[],par_civ1.FrameIndexB); 110 if ~isempty(errormsg) 111 errormsg=['error in civ_matlab/read_field:' errormsg]; 112 return 113 end 114 par_civ1.ImageB=Field.A;%= image matrix A in the second input field 81 115 end 82 116 end … … 121 155 Data.Civ1_C=reshape(ctable,[],1); 122 156 Data.Civ1_F=reshape(F,[],1); 123 Data.CivStage=1; 157 Data.CivStage=1; 124 158 else 125 159 if exist('ncfile','var') … … 162 196 Data.VarDimName=[Data.VarDimName {'nb_vec_1'}]; 163 197 nbvar=length(Data.ListVarName); 164 Data.VarAttribute{nbvar}.Role='errorflag'; 198 Data.VarAttribute{nbvar}.Role='errorflag'; 165 199 Data.Civ1_FF=fix(Param.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V); 166 Data.CivStage=2; 167 end 168 end 200 Data.CivStage=2; 201 end 202 end 169 203 %% Patch1 170 204 if isfield (Param,'Patch1') … … 180 214 nbvar=length(Data.ListVarName); 181 215 Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbSites','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}]; 182 183 216 Data.VarDimName=[Data.VarDimName {'nb_vec_1','nb_vec_1',{'nb_coord','nb_bounds','nb_subdomain_1'},{'nb_subdomain_1'},... 217 {'nb_tps_1','nb_coord','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'}}]; 184 218 Data.VarAttribute{nbvar+1}.Role='vector_x'; 185 219 Data.VarAttribute{nbvar+2}.Role='vector_y'; … … 191 225 if isfield(Data,'Civ1_FF') 192 226 ind_good=find(Data.Civ1_FF==0); 193 else 227 else 194 228 ind_good=1:numel(Data.Civ1_X); 195 229 end 196 230 [Data.Civ1_SubRange,Data.Civ1_NbSites,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=... 197 filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomain,Data.Patch1_Rho,Data.Patch1_Threshold);198 199 200 201 202 203 Data.CivStage=3;204 end 231 filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomain,Data.Patch1_Rho,Data.Patch1_Threshold); 232 fill=zeros(3,2,size(Data.Civ1_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage) 233 Data.Civ1_Coord_tps=cat(1,Data.Civ1_Coord_tps,fill); 234 Data.Civ1_U_smooth(ind_good)=Ures; 235 Data.Civ1_V_smooth(ind_good)=Vres; 236 Data.Civ1_FF(ind_good)=FFres; 237 Data.CivStage=3; 238 end 205 239 206 240 %% Civ2 … … 209 243 if ~isfield (Param,'Civ1') || ~strcmp(Param.Civ1.ImageA,par_civ2.ImageA) 210 244 %read first image if not already done for civ1 211 [Field,ParamOut,errormsg] = read_field(par_civ2.ImageA,par_civ2.FileTypeA,[],par_civ2.i1); 245 [Field,ParamOut,errormsg] = read_field(par_civ2.ImageA,par_civ2.FileTypeA,[],par_civ2.FrameIndexA); 246 if ~isempty(errormsg) 247 errormsg=['error in civ_matlab/read_field:' errormsg]; 248 return 249 end 212 250 par_civ2.ImageA=Field.A; 213 251 else … … 216 254 if ~isfield (Param,'Civ1') || ~strcmp(Param.Civ1.ImageB,par_civ2.ImageB) 217 255 %read first image if not already done for civ1 218 [Field,ParamOut,errormsg] = read_field(par_civ2.ImageB,par_civ2.FileTypeB,[],par_civ2.i2); 256 [Field,ParamOut,errormsg] = read_field(par_civ2.ImageB,par_civ2.FileTypeB,[],par_civ2.FrameIndexB); 257 if ~isempty(errormsg) 258 errormsg=['error in civ_matlab/read_field:' errormsg]; 259 return 260 end 219 261 par_civ2.ImageB=Field.A; 220 262 else … … 233 275 [GridX,GridY]=meshgrid(minix:par_civ2.Dx:maxix,miniy:par_civ2.Dy:maxiy); 234 276 GridX=reshape(GridX,[],1); 235 GridY=reshape(GridY,[],1); 277 GridY=reshape(GridY,[],1); 236 278 Shiftx=zeros(size(GridX));% shift expected from civ1 data 237 279 Shifty=zeros(size(GridX)); … … 270 312 par_civ2.Shiftx=Shiftx(nbval>=1)./nbval(nbval>=1); 271 313 par_civ2.Shifty=Shifty(nbval>=1)./nbval(nbval>=1); 272 par_civ2.Grid=[GridX(nbval>=1)-par_civ2.Shiftx/2 GridY(nbval>=1)-par_civ2.Shifty/2];% grid taken at the extrapolated origin of the displacement vectors 314 par_civ2.Grid=[GridX(nbval>=1)-par_civ2.Shiftx/2 GridY(nbval>=1)-par_civ2.Shifty/2];% grid taken at the extrapolated origin of the displacement vectors 273 315 if par_civ2.CheckDeformation 274 316 par_civ2.DUDX=DUDX./nbval; … … 279 321 % caluclate velocity data (y and v in indices, reverse to y component) 280 322 [xtable ytable utable vtable ctable F] = civ (par_civ2); 281 % diff_squared=(utable-par_civ2.Shiftx).*(utable-par_civ2.Shiftx)+(vtable+par_civ2.Shifty).*(vtable+par_civ2.Shifty);282 % F(diff_squared>=4)=4; %flag vectors whose distance to the guess exceeds 2 pixels323 % diff_squared=(utable-par_civ2.Shiftx).*(utable-par_civ2.Shiftx)+(vtable+par_civ2.Shifty).*(vtable+par_civ2.Shifty); 324 % F(diff_squared>=4)=4; %flag vectors whose distance to the guess exceeds 2 pixels 283 325 list_param=(fieldnames(Param.Civ2))'; 284 326 list_remove={'pxcmx','pxcmy','npx','npy','gridflag','maskflag','term_a','term_b','T0'}; … … 300 342 end 301 343 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ2_param {'Civ2_Time','Civ2_Dt'}]; 302 % Data.Civ2_Time=par_civ2.Time;303 % Data.Civ2_Dt=par_civ2.Dt;344 % Data.Civ2_Time=par_civ2.Time; 345 % Data.Civ2_Dt=par_civ2.Dt; 304 346 nbvar=numel(Data.ListVarName); 305 347 Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_F','Civ2_C'}];% cell array containing the names of the fields to record … … 340 382 Data.VarDimName=[Data.VarDimName {'nb_vec_2'}]; 341 383 nbvar=length(Data.ListVarName); 342 Data.VarAttribute{nbvar}.Role='errorflag'; 384 Data.VarAttribute{nbvar}.Role='errorflag'; 343 385 Data.Civ2_FF=fix(Param.Fix2,Data.Civ2_F,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V); 344 Data.CivStage=Data.CivStage+1; 386 Data.CivStage=Data.CivStage+1; 345 387 end 346 388 347 end 389 end 348 390 349 391 %% Patch2 … … 356 398 Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbSites','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}]; 357 399 Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2',{'nb_coord','nb_bounds','nb_subdomain_2'},{'nb_subdomain_2'},... 358 359 360 400 {'nb_tps_2','nb_coord','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'}}]; 401 402 Data.VarAttribute{nbvar+1}.Role='vector_x'; 361 403 Data.VarAttribute{nbvar+2}.Role='vector_y'; 362 404 Data.VarAttribute{nbvar+5}.Role='coord_tps'; … … 369 411 else 370 412 ind_good=1:numel(Data.Civ2_X); 371 end 413 end 372 414 [Data.Civ2_SubRange,Data.Civ2_NbSites,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures, Vres,tild,FFres]=... 373 filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomain,Data.Patch2_Rho,Data.Patch2_Threshold);374 375 415 filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomain,Data.Patch2_Rho,Data.Patch2_Threshold); 416 fill=zeros(3,2,size(Data.Civ2_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage) 417 Data.Civ2_Coord_tps=cat(1,Data.Civ2_Coord_tps,fill); 376 418 Data.Civ2_U_smooth(ind_good)=Ures; 377 419 Data.Civ2_V_smooth(ind_good)=Vres; 378 420 Data.Civ2_FF(ind_good)=FFres; 379 Data.CivStage=Data.CivStage+1; 380 end 421 Data.CivStage=Data.CivStage+1; 422 end 381 423 382 424 %% write result in a netcdf file if requested -
trunk/src/find_file_series.m
r421 r435 52 52 % ifile_min=1;%default 53 53 [FileType,FileInfo,Object]=get_file_type(fullfileinput); 54 if strcmp( FileType,'multimage')||strcmp( FileType,'video') 54 if strcmp( FileType,'multimage')||strcmp( FileType,'video')||strcmp( FileType,'mmreader') 55 55 NomType='*'; 56 56 i1_series=(1:FileInfo.NumberOfFrames)'; -
trunk/src/get_file_type.m
r397 r435 74 74 FileInfo.NumberOfFrames=get(VideoObject,'NumberOfFrames'); 75 75 FileType='video'; 76 elseif exist('mmreader.m','file')% Matlab 2009a 77 VideoObject=mmreader(fileinput); 78 FileInfo.NumberOfFrames=get(VideoObject,'NumberOfFrames'); 79 FileType='mmreader'; 76 80 end 77 81 end -
trunk/src/read_field.m
r406 r435 150 150 % % ParamOut.FieldList={'get_field...'}; 151 151 % end 152 case 'video'152 case {'video','mmreader'} 153 153 try 154 154 A=read(ObjectName,num); 155 155 catch ME 156 errormsg=ME.message 156 errormsg=ME.message; 157 157 return 158 158 end -
trunk/src/uvmat.m
r434 r435 1528 1528 UvData=get(handles.uvmat,'UserData'); 1529 1529 1530 while get(handles. speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command1530 while get(handles.Movie,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command 1531 1531 errormsg=runpm(hObject,eventdata,handles,increment); 1532 1532 if ~isempty(errormsg) … … 1555 1555 UvData=get(handles.uvmat,'UserData'); 1556 1556 1557 while get(handles. speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command1557 while get(handles.MovieBackward,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command 1558 1558 errormsg=runpm(hObject,eventdata,handles,increment); 1559 1559 if ~isempty(errormsg) … … 2034 2034 end 2035 2035 end 2036 case 'video'2036 case {'video','mmreader'} 2037 2037 ObjectName=UvData.MovieObject{1}; 2038 2038 case 'vol' %TODO: update … … 2094 2094 end 2095 2095 end 2096 case 'video'2096 case {'video','mmreader'} 2097 2097 Name=UvData.MovieObject{2}; 2098 2098 case 'vol' %TODO: update … … 2406 2406 2407 2407 %% get bounds and mesh (needed for mouse action and to open set_object) 2408 XName=''; %default 2409 YName=''; 2410 if ~isempty(VarType{imax}.coord_x) 2411 XName=UvData.Field.ListVarName{VarType{imax}.coord_x}; 2412 DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable 2413 nbpoints_x=DimValue(DimIndex(NbDim)); 2414 %unstructured coordinates 2415 if ~isempty(VarType{imax}.coord_y) 2408 if NbDim>1 2409 XName=''; %default 2410 YName=''; 2411 %unstructured coordinates 2412 if ~isempty(VarType{imax}.coord_x)&&~isempty(VarType{imax}.coord_y) 2413 XName=UvData.Field.ListVarName{VarType{imax}.coord_x}; 2416 2414 YName=UvData.Field.ListVarName{VarType{imax}.coord_y}; 2417 2415 %nbvec=length(UvData.Field.(XName));%nbre of measurement points (e.g. vectors) … … 2422 2420 NbDim=2; 2423 2421 end 2424 end 2425 %structured coordinate 2426 elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 2427 XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)}; 2428 if NbDim> 1 && VarType{imax}.coord(NbDim-1)>0 2429 YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates 2430 end 2431 % VarIndex=CellVarIndex{imax}; % list of variable indices 2432 DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable 2433 nbpoints_x=DimValue(DimIndex(NbDim)); 2434 XMax=nbpoints_x;%default 2435 XMin=1;%default 2436 end 2437 2438 if NbDim==3 2439 if ~test_x 2440 ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D 2441 end 2442 ZMax=max(UvData.Field.(ZName)); 2443 ZMin=min(UvData.Field.(ZName)); 2444 UvData.Field.ZMax=ZMax; 2445 UvData.Field.ZMin=ZMin; 2446 test_z=1; 2447 if isequal(ZMin,ZMax)%no z dependency 2448 NbDim=2; 2449 test_z=0; 2450 end 2451 end 2452 if ~isempty (XName) 2453 XMax=max(max(UvData.Field.(XName))); 2454 XMin=min(min(UvData.Field.(XName))); 2455 UvData.Field.NbDim=NbDim; 2456 UvData.Field.XMax=XMax; 2457 UvData.Field.XMin=XMin; 2458 if NbDim >1&& ~isempty(YName) 2459 YMax=max(max(UvData.Field.(YName))); 2460 YMin=min(min(UvData.Field.(YName))); 2461 UvData.Field.YMax=YMax; 2462 UvData.Field.YMin=YMin; 2463 end 2464 nbvec=length(UvData.Field.(XName)); 2465 if test_x %unstructured coordinates 2466 if test_z 2467 UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector 2468 UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3); 2469 else 2470 UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D 2471 end 2472 end 2473 end 2474 % case of structured coordinates 2475 if ~test_x 2476 DX=(XMax-XMin)/(nbpoints_x-1); 2477 if NbDim >1 2478 nbpoints_y=DimValue(DimIndex(NbDim-1)); 2479 if isempty(YName)% if the y coordinate is not expressed, it is taken as the matrix index 2480 DY=1; 2481 UvData.Field.YMax=nbpoints_y; 2482 UvData.Field.YMin=1; 2483 else 2484 DY=(YMax-YMin)/(nbpoints_y-1); 2485 end 2486 end 2422 %structured coordinate 2423 elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 2424 XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)}; 2425 if NbDim> 1 && VarType{imax}.coord(NbDim-1)>0 2426 YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates 2427 end 2428 % VarIndex=CellVarIndex{imax}; % list of variable indices 2429 DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable 2430 nbpoints_x=DimValue(DimIndex(NbDim)); 2431 XMax=nbpoints_x;%default 2432 XMin=1;%default 2433 end 2434 2487 2435 if NbDim==3 2488 nbpoints_z=DimValue(DimIndex(1)); 2489 DZ=(ZMax-ZMin)/(nbpoints_z-1); 2490 UvData.Field.Mesh=(DX*DY*DZ)^(1/3); 2436 if ~test_x 2437 ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D 2438 end 2439 ZMax=max(UvData.Field.(ZName)); 2440 ZMin=min(UvData.Field.(ZName)); 2491 2441 UvData.Field.ZMax=ZMax; 2492 2442 UvData.Field.ZMin=ZMin; 2443 test_z=1; 2444 if isequal(ZMin,ZMax)%no z dependency 2445 NbDim=2; 2446 test_z=0; 2447 end 2448 end 2449 if ~isempty (XName) 2450 XMax=max(max(UvData.Field.(XName))); 2451 XMin=min(min(UvData.Field.(XName))); 2452 UvData.Field.NbDim=NbDim; 2453 UvData.Field.XMax=XMax; 2454 UvData.Field.XMin=XMin; 2455 if NbDim >1&& ~isempty(YName) 2456 YMax=max(max(UvData.Field.(YName))); 2457 YMin=min(min(UvData.Field.(YName))); 2458 UvData.Field.YMax=YMax; 2459 UvData.Field.YMin=YMin; 2460 end 2461 nbvec=length(UvData.Field.(XName)); 2462 if test_x %unstructured coordinates 2463 if test_z 2464 UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector 2465 UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3); 2466 else 2467 UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D 2468 end 2469 end 2470 end 2471 % case of structured coordinates 2472 if ~test_x 2473 DX=(XMax-XMin)/(nbpoints_x-1); 2474 if NbDim >1 2475 nbpoints_y=DimValue(DimIndex(NbDim-1)); 2476 if isempty(YName)% if the y coordinate is not expressed, it is taken as the matrix index 2477 DY=1; 2478 UvData.Field.YMax=nbpoints_y; 2479 UvData.Field.YMin=1; 2480 else 2481 DY=(YMax-YMin)/(nbpoints_y-1); 2482 end 2483 end 2484 if NbDim==3 2485 nbpoints_z=DimValue(DimIndex(1)); 2486 DZ=(ZMax-ZMin)/(nbpoints_z-1); 2487 UvData.Field.Mesh=(DX*DY*DZ)^(1/3); 2488 UvData.Field.ZMax=ZMax; 2489 UvData.Field.ZMin=ZMin; 2490 else 2491 UvData.Field.Mesh=DX;%sqrt(DX*DY); 2492 end 2493 end 2494 % adjust the mesh to a value 1, 2 , 5 *10^n 2495 ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude 2496 if UvData.Field.Mesh/ord>=5 2497 UvData.Field.Mesh=5*ord; 2498 elseif UvData.Field.Mesh/ord>=2 2499 UvData.Field.Mesh=2*ord; 2493 2500 else 2494 UvData.Field.Mesh=DX;%sqrt(DX*DY); 2495 end 2496 end 2497 % adjust the mesh to a value 1, 2 , 5 *10^n 2498 ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude 2499 if UvData.Field.Mesh/ord>=5 2500 UvData.Field.Mesh=5*ord; 2501 elseif UvData.Field.Mesh/ord>=2 2502 UvData.Field.Mesh=2*ord; 2503 else 2504 UvData.Field.Mesh=ord; 2505 end 2506 UvData.Object{1}.Type='plane';%main plotting plane 2507 UvData.Object{1}.ProjMode='projection';%main plotting plane 2508 UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat 2509 UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat 2510 2511 %% 3D case (menuvolume) 2512 if NbDim==3% && UvData.NewSeries 2513 test_set_object=1; 2514 hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI 2515 ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider 2516 ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider 2517 if ~isempty(hset_object) %if set_object is detected 2518 delete(hset_object);% delete the GUI set_object if it does not fit 2519 end 2520 if test_set_object% reinitiate the GUI set_object 2521 delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2 2522 UvData.Object{1}.NbDim=NbDim;%test for 3D objects 2523 UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane 2524 UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen 2525 UvData.Object{1}.Angle=[0 0 0]; 2526 UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR 2527 UvData.Object{1}.Name='1-PLANE'; 2528 UvData.Object{1}.enable_plot=1; 2529 set_object(UvData.Object{1},handles,ZBounds); 2530 set(handles.ListObject,'Value',1); 2531 set(handles.ListObject,'String',{'1-PLANE'}); 2532 set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor 2533 edit_object_Callback([],[], handles) 2534 end 2535 %multilevel case (single menuplane in a 3D space) 2536 elseif isfield(UvData,'Z') 2537 if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData') 2538 XmlData=UvData.XmlData{1}; 2539 if isfield(XmlData,'PlanePos') 2540 UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:); 2541 end 2542 if isfield(XmlData,'PlaneAngle') 2543 siz=size(XmlData.PlaneAngle); 2544 indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning) 2545 UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:); 2546 end 2547 elseif isfield(UvData,'ZIndex') 2548 UvData.Object{1}.ZObject=UvData.ZIndex; 2549 end 2550 end 2501 UvData.Field.Mesh=ord; 2502 end 2503 UvData.Object{1}.Type='plane';%main plotting plane 2504 UvData.Object{1}.ProjMode='projection';%main plotting plane 2505 UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat 2506 UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat 2507 2508 %% 3D case (menuvolume) 2509 if NbDim==3% && UvData.NewSeries 2510 test_set_object=1; 2511 hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI 2512 ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider 2513 ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider 2514 if ~isempty(hset_object) %if set_object is detected 2515 delete(hset_object);% delete the GUI set_object if it does not fit 2516 end 2517 if test_set_object% reinitiate the GUI set_object 2518 delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2 2519 UvData.Object{1}.NbDim=NbDim;%test for 3D objects 2520 UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane 2521 UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen 2522 UvData.Object{1}.Angle=[0 0 0]; 2523 UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR 2524 UvData.Object{1}.Name='1-PLANE'; 2525 UvData.Object{1}.enable_plot=1; 2526 set_object(UvData.Object{1},handles,ZBounds); 2527 set(handles.ListObject,'Value',1); 2528 set(handles.ListObject,'String',{'1-PLANE'}); 2529 set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor 2530 edit_object_Callback([],[], handles) 2531 end 2532 %multilevel case (single menuplane in a 3D space) 2533 elseif isfield(UvData,'Z') 2534 if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData') 2535 XmlData=UvData.XmlData{1}; 2536 if isfield(XmlData,'PlanePos') 2537 UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:); 2538 end 2539 if isfield(XmlData,'PlaneAngle') 2540 siz=size(XmlData.PlaneAngle); 2541 indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning) 2542 UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:); 2543 end 2544 elseif isfield(UvData,'ZIndex') 2545 UvData.Object{1}.ZObject=UvData.ZIndex; 2546 end 2547 end 2548 end 2549 2551 2550 testnewseries=UvData.NewSeries; 2552 2551 UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
Note: See TracChangeset
for help on using the changeset viewer.