Changeset 388
- Timestamp:
- Apr 6, 2012, 4:37:12 PM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r387 r388 919 919 drawnow 920 920 end 921 % datnum=[];922 921 Tabchar={}; 923 922 nbfiles=numel(civ_files); … … 1169 1168 nbfield=numel(i1_civ1); 1170 1169 nbslice=numel(j1_civ1); 1170 if ~strcmp(CivMode,'CivX') 1171 [Param.Civ1.FileTypeA,FileInfo,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1}); 1172 [Param.Civ1.FileTypeB,FileInfo,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1}); 1173 end 1171 1174 1172 1175 %% MAIN LOOP … … 1219 1222 Param.Civ1.ImageHeight=ImageInfo.Height; 1220 1223 Param.Civ1.ImageBitDepth=ImageInfo.BitDepth; 1224 Param.Civ1.i1=i1_civ1; 1225 Param.Civ1.i2=i2_civ1; 1221 1226 % read mask parameters 1222 1227 if Param.Civ1.CheckMask % the lines below should be changed with the new gui … … 1227 1232 [RootPathMask,RootFileMask]=fileparts(maskbase); 1228 1233 Param.Civ1.Mask=fullfile_uvmat(RootPathMask,[],RootFileMask,'.png','_1',i1_mask); 1229 % Param.Civ1.Mask=name_generator(maskbase,i1_mask,1,'.png','_i');1230 1234 end 1231 1235 end … … 1388 1392 Param.Civ2.ImageHeight=ImageInfo.Height; 1389 1393 Param.Civ2.ImageBitDepth=ImageInfo.BitDepth; 1394 Param.Civ2.i1=i1_civ2; 1395 Param.Civ2.i2=i2_civ2; 1390 1396 % TODO: case of movie 1391 1397 switch CivMode … … 1796 1802 %------------------------------------------------------------------------ 1797 1803 filecell=[];%default 1804 ListProgram=get(handles.ListProgram,'String'); 1805 CivMode=ListProgram{get(handles.ListProgram,'Value')};%Program to use , CivX or Matlab 1798 1806 1799 1807 %% get the root name and check dir … … 1809 1817 return 1810 1818 end 1811 [ xx,message]=fileattrib(RootPath);1819 [tild,message]=fileattrib(RootPath); 1812 1820 if ~isempty(message) && ~isequal(message.UserWrite,1) 1813 1821 msgbox_uvmat('ERROR',['No writting access to ' RootPath]) … … 2414 2422 set(handles.SubdirCiv2,'String',subdir_civ2);%update the edit box 2415 2423 2416 %COPY IMAGES TO THE FORMAT .png IF NEEDED 2417 if isequal(NomType_ima1,'*')%case of movie files 2418 NomType_imanew1='_i'; 2419 else 2420 NomType_imanew1=NomType_ima1; 2421 end 2422 if isequal(NomType_ima2,'*')%case of movie files 2423 NomType_imanew2='_i'; 2424 else 2425 NomType_imanew2=NomType_ima2; 2426 end 2427 if ~isequal(ext_ima,'.png') 2428 %%type of image file 2429 type_ima1='none';%default 2430 movieobject1=[];%default 2431 if strcmpi(ext_ima,'.avi') 2432 if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab) 2433 type_ima1='movie'; 2434 movieobject1=mmreader([filecell.filebase ext_ima]); 2435 else 2436 type_ima1='avi'; 2437 end 2438 elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) 2439 form=imformats(ext_ima(2:end)); 2440 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 2441 if isequal(NomType_ima1,'*'); 2442 type_ima1='multimage';%image series in a single image file 2424 % For CivX COPY IMAGES TO THE FORMAT .png IF NEEDED 2425 if strcmp(CivMode,'CivX') 2426 if isequal(NomType_ima1,'*')%case of movie files 2427 NomType_imanew1='_i'; 2428 else 2429 NomType_imanew1=NomType_ima1; 2430 end 2431 if isequal(NomType_ima2,'*')%case of movie files 2432 NomType_imanew2='_i'; 2433 else 2434 NomType_imanew2=NomType_ima2; 2435 end 2436 if ~isequal(ext_ima,'.png') 2437 %%type of image file 2438 type_ima1='none';%default 2439 movieobject1=[];%default 2440 if strcmpi(ext_ima,'.avi') 2441 if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab) 2442 type_ima1='movie'; 2443 movieobject1=mmreader([filecell.filebase ext_ima]); 2443 2444 else 2444 type_ima1=' image';2445 end 2446 e nd2447 end2448 type_ima2='none';%default2449 movieobject2=[];2450 if strcmpi(ext_ima,'.avi')2451 if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab)2452 type_ima2='movie';2453 movieobject2=mmreader([filecell.filebase ext_ima]);2454 else2455 type_ima2='avi';2456 end2457 elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))2458 form=imformats(ext_ima(2:end));2459 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab2460 if isequal(NomType_ima1,'*');2461 type_ima2='multimage';%image series in a single image file2445 type_ima1='avi'; 2446 end 2447 elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) 2448 form=imformats(ext_ima(2:end)); 2449 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 2450 if isequal(NomType_ima1,'*'); 2451 type_ima1='multimage';%image series in a single image file 2452 else 2453 type_ima1='image'; 2454 end 2455 end 2456 end 2457 type_ima2='none';%default 2458 movieobject2=[]; 2459 if strcmpi(ext_ima,'.avi') 2460 if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab) 2461 type_ima2='movie'; 2462 movieobject2=mmreader([filecell.filebase ext_ima]); 2462 2463 else 2463 type_ima2='image'; 2464 end 2465 end 2466 end 2467 if checkbox(1) %if civ1 is performed 2468 h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar 2469 for ifile=1:nbfield 2470 waitbar(ifile/nbfield); 2471 for j=1:nbslice 2472 filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j)); 2473 if ~exist(filename,'file') 2474 A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,i1_civ1(ifile),movieobject1); 2475 imwrite(A,filename,'BitDepth',16); 2464 type_ima2='avi'; 2465 end 2466 elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) 2467 form=imformats(ext_ima(2:end)); 2468 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 2469 if isequal(NomType_ima1,'*'); 2470 type_ima2='multimage';%image series in a single image file 2471 else 2472 type_ima2='image'; 2476 2473 end 2477 filecell.ima1.civ1(ifile,j)={filename}; 2478 filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ1(ifile),[],j2_civ1(j)); 2479 if ~exist(filename,'file') 2480 A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,i2_civ1(ifile),movieobject2); 2481 imwrite(A,filename,'BitDepth',16); 2474 end 2475 end 2476 if checkbox(1) %if civ1 is performed 2477 h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar 2478 for ifile=1:nbfield 2479 waitbar(ifile/nbfield); 2480 for j=1:nbslice 2481 filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j)); 2482 if ~exist(filename,'file') 2483 A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,i1_civ1(ifile),movieobject1); 2484 imwrite(A,filename,'BitDepth',16); 2485 end 2486 filecell.ima1.civ1(ifile,j)={filename}; 2487 filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ1(ifile),[],j2_civ1(j)); 2488 if ~exist(filename,'file') 2489 A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,i2_civ1(ifile),movieobject2); 2490 imwrite(A,filename,'BitDepth',16); 2491 end 2492 filecell.ima2.civ1(ifile,j)={filename}; 2482 2493 end 2483 filecell.ima2.civ1(ifile,j)={filename}; 2484 end 2485 end 2486 close(h) 2487 end 2488 if checkbox(4) %if civ2 is performed 2489 h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar 2490 for ifile=1:nbfield 2491 waitbar(ifile/nbfield); 2492 for j=1:nbslice 2493 filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j)); 2494 if ~exist(filename,'file') 2495 A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,i1_civ2(ifile)); 2496 imwrite(A,filename,'BitDepth',16); 2494 end 2495 close(h) 2496 end 2497 if checkbox(4) %if civ2 is performed 2498 h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar 2499 for ifile=1:nbfield 2500 waitbar(ifile/nbfield); 2501 for j=1:nbslice 2502 filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j)); 2503 if ~exist(filename,'file') 2504 A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,i1_civ2(ifile)); 2505 imwrite(A,filename,'BitDepth',16); 2506 end 2507 filecell.ima1.civ2(ifile,j)={filename}; 2508 filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j)); 2509 if ~exist(filename,'file') 2510 A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,i2_civ2(ifile)); 2511 imwrite(A,filename,'BitDepth',16); 2512 end 2513 filecell.ima2.civ2(ifile,j)={filename}; 2497 2514 end 2498 filecell.ima1.civ2(ifile,j)={filename}; 2499 filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j)); 2500 if ~exist(filename,'file') 2501 A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,i2_civ2(ifile)); 2502 imwrite(A,filename,'BitDepth',16); 2503 end 2504 filecell.ima2.civ2(ifile,j)={filename}; 2505 end 2506 end 2507 close(h); 2515 end 2516 close(h); 2517 end 2508 2518 end 2509 2519 end … … 3916 3926 Data.nx=[1 size(Data.A,2)]; 3917 3927 par_civ1=read_GUI(handles.Civ1); 3918 par_civ1.ImageWidth=size(Data.A, 1);3919 par_civ1.ImageHeight=size(Data.A, 2);3928 par_civ1.ImageWidth=size(Data.A,2); 3929 par_civ1.ImageHeight=size(Data.A,1); 3920 3930 par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation 3931 par_civ1.i1=i1_civ1; 3932 par_civ1.i2=i2_civ1; 3921 3933 Param.Civ1=par_civ1; 3922 3934 Grid=civ_matlab(Param);% get the grid of x, y positions set for PIV -
trunk/src/civ_matlab.m
r387 r388 65 65 if ischar(par_civ1.ImageB) 66 66 temp=par_civ1.ImageA; 67 par_civ1.ImageA= sum(imread(par_civ1.ImageB),3);67 par_civ1.ImageA=imread(par_civ1.ImageB); 68 68 end 69 69 if ischar(temp) 70 par_civ1.ImageB= sum(imread(temp),3);70 par_civ1.ImageB=imread(temp); 71 71 end 72 72 end 73 73 else 74 74 if isfield(par_civ1,'ImageA') && ischar(par_civ1.ImageA) % case with no image: only the PIV grid is calculated 75 par_civ1.ImageA=sum(imread(par_civ1.ImageA),3); 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) 76 77 end 77 78 if isfield(par_civ1,'ImageB')&& ischar(par_civ1.ImageB) 78 par_civ1.ImageB=sum(imread(par_civ1.ImageB),3); 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); 79 81 end 80 82 end … … 466 468 % end 467 469 % end 468 470 par_civ.ImageA=sum(double(par_civ.ImageA),3);%sum over rgb component for color images 471 par_civ.ImageB=sum(double(par_civ.ImageB),3); 469 472 [npy_ima npx_ima]=size(par_civ.ImageA); 470 473 if ~isequal(size(par_civ.ImageB),[npy_ima npx_ima]) … … 472 475 return 473 476 end 474 par_civ.ImageA=double(par_civ.ImageA);475 par_civ.ImageB=double(par_civ.ImageB);476 477 477 478 478 %% Apply mask -
trunk/src/find_file_series.m
r386 r388 54 54 [FileType,FileInfo,Object]=get_file_type(fullfileinput); 55 55 if strcmp( FileType,'multimage')||strcmp( FileType,'video') 56 57 56 NomType='*'; 57 i1_series=(1:FileInfo.NbFrame)'; 58 58 end 59 59 … … 61 61 if exist(fullfileinput,'file') 62 62 [tild,RootFile]=fileparts(fileinput);% case of constant name (no indexing) 63 else 63 else 64 64 RootFile=''; 65 65 end 66 else 67 %% possibly include the first index in the root name, if there exists a corresponding xml file 66 else 67 %% possibly include the first index in the root name, if there exists a corresponding xml file 68 % RootFileNew=RootFile; 69 % if ~isempty(regexp(NomType,['^_'])) 70 % NomTypePref='_'; 71 % RootFileNew=[RootFileNew '_']; 72 % end RootPath=''; 68 73 NomTypePref=''; 69 RootFileNew=RootFile;70 % if ~isempty(regexp(NomType,['^_']))71 % NomTypePref='_';72 % RootFileNew=[RootFileNew '_'];73 % end RootPath='';74 74 r=regexp(NomType,'^(?<tiretnum>_?\d+)','names');%look for a number or _1 at the beginning of NomType 75 % r=regexp(NomType,['^' NomTypePref '(?<num1>\d+)'],'names');%look for a number at the beginning of NomTypeSt75 % r=regexp(NomType,['^' NomTypePref '(?<num1>\d+)'],'names');%look for a number at the beginning of NomTypeSt 76 76 if ~isempty(r) 77 NomTypePref=r.tiretnum; 78 fileinput_end=regexprep(fileinput,['^' RootFileNew],''); 79 r=regexp(fileinput_end,'^(?<num1>\d+)','names'); 80 if ~isempty(r) 81 RootFileNew=[RootFileNew r.num1]; 82 end 83 if exist(fullfile(RootPath,[RootFileNew '.xml']),'file') 84 RootFile=RootFileNew; 85 NomType=regexprep(NomType,['^' NomTypePref],''); 86 i2_input=j2_input; 87 j1_input=[]; 88 j2_input=[]; 89 else 90 NomTypePref=''; 77 fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput 78 if isempty(regexp(r.tiretnum,'^_'))% if a separator '_' is not detected 79 rr=regexp(fileinput_end,'^(?<i1>\d+)','names'); 80 else% if a separator '_' is detected 81 rr=regexp(fileinput_end,'^(?<i1>_\d+)','names'); 82 end 83 if ~isempty(rr) 84 RootFileNew=[RootFile rr.i1]; 85 if exist(fullfile(RootPath,[RootFileNew '.xml']),'file') 86 RootFile=RootFileNew; 87 NomType=regexprep(NomType,['^' NomTypePref],''); 88 NomTypePref=r.tiretnum; 89 i2_input=j2_input; 90 j1_input=[]; 91 j2_input=[]; 92 end 91 93 end 92 94 end 93 95 %% analyse the list of existing files when relevant 94 96 sep1=''; 95 i1_str='(?<i1>)'; 97 i1_str='(?<i1>)';%will set i1=[]; 96 98 i1_star=''; 97 sep2='';98 i2_str='(?<i2>)'; 99 % r.sep2=''; 100 i2_str='(?<i2>)';%will set i2=[]; 99 101 i2_star=''; 100 sep3='';101 j1_str='(?<j1>)'; 102 % sep3=''; 103 j1_str='(?<j1>)';%will set j1=[]; 102 104 j1_star=''; 103 sep4='';104 j2_str='(?<j2>)'; 105 % sep4=''; 106 j2_str='(?<j2>)';%will set j2=[]; 105 107 j2_star=''; 106 NomTypeStr=NomType; 107 if ~isempty(regexp(NomTypeStr,'^_\d')) 108 sep1='_'; 109 NomTypeStr(1)=[];%remove '_' from the beginning of NomTypeStr 110 end 111 r=regexp(NomTypeStr,'^(?<num1>\d+)','names');%look for a number at the beginning of NomTypeStr 108 % NomTypeStr=NomType; 109 %Look for cases with letter indexing for the second index 110 r=regexp(NomType,'^(?<sep1>_?)(?<i1>\d+)(?<j1>[a|A])(?<j2>[b|B]?)$','names'); 112 111 if ~isempty(r) 113 i1_str='(?<i1>\d+)'; 114 i1_star='*'; 115 NomTypeStr=regexprep(NomTypeStr,['^' r.num1],''); 116 r=regexp(NomTypeStr,'^-(?<num2>\d+)','names');%look for a pair i1-i2 112 sep1=r.sep1; 113 if strcmp(lower(r.j1),r.j1) 114 j1_str='(?<j1>[a-z])'; 115 else 116 j1_str='(?<j1>[A-Z])'; 117 end 118 j1_star='*'; 119 if ~isempty(r.j2) 120 if strcmp(lower(r.j1),r.j1) 121 j2_str='(?<j2>[a-z])'; 122 else 123 j2_str='(?<j2>[A-Z])'; 124 end 125 j2_star='*'; 126 end 127 else %numerical indexing 128 r=regexp(NomType,'^(?<sep1>_?)(?<i1>\d+)(?<i2>(-\d+)?)(?<j1>(_\d+)?)(?<j2>(-\d+)?)$','names'); 117 129 if ~isempty(r) 118 sep2='-'; 119 i2_str='(?<i2>\d+)'; 120 i2_star='*'; 121 NomTypeStr=regexprep(NomTypeStr,['^-' r.num2],''); 122 end 123 if ~isempty(regexp(NomTypeStr,'^_')); 124 sep3='_'; 125 NomTypeStr(1)=[];%remove '_' from the beginning of NomTypeStr 126 end 127 if ~isempty(regexp(NomTypeStr,'^[a|A]')); 128 j1_str='(?<j1>[a-z]|[A-Z])'; 129 j1_star='*'; 130 if ~isempty(regexp(NomTypeStr,'[b|B]$')); 131 j2_str='(?<j2>[a-z]|[A-Z])'; 132 j2_star='*'; 133 end 134 else 135 r=regexp(NomTypeStr,'^(?<num3>\d+)','names'); 136 if ~isempty(r) 137 j1_str='(?<j1>\d+)'; 138 j1_star='*'; 139 NomTypeStr=regexprep(NomTypeStr,['^' r.num3],''); 140 end 141 r=regexp(NomTypeStr,'-(?<num4>\d+)','names'); 142 if ~isempty(r) 143 sep4='-'; 144 j2_str='(?<j2>\d+)'; 145 j2_star='*'; 146 end 147 end 148 end 149 detect_string=['^' RootFile sep1 i1_str sep2 i2_str sep3 j1_str sep4 j2_str FileExt '$'];%string used in regexp to detect file indices 130 sep1=r.sep1; 131 i1_str='(?<i1>\d+)'; 132 i1_star='*'; 133 if ~isempty(r.i2) 134 i2_str='(?<i2>-\d+)'; 135 i2_star='-*'; 136 end 137 if ~isempty(r.j1) 138 j1_str='(?<j1>_\d+)'; 139 j1_star='_*'; 140 end 141 if ~isempty(r.j2) 142 j2_str='(?<j2>-\d+)'; 143 j2_star='-*'; 144 end 145 end 146 end 147 detect_string=['^' RootFile sep1 i1_str i2_str j1_str j2_str FileExt '$'];%string used in regexp to detect file indices 150 148 %find the string used to extract the relevant files with the command dir 151 star_string=[RootFile sep1 i1_star sep2 i2_star sep3 j1_star sep4 j2_star '*'];149 star_string=[RootFile sep1 i1_star i2_star j1_star j2_star FileExt]; 152 150 wd=pwd;%current working directory 153 151 cd (RootPath)% move to the local dir to save time in the operation dir. 154 dirpair=dir( [star_string FileExt]);% look for relevant files in the file directory152 dirpair=dir(star_string);% look for relevant files in the file directory 155 153 cd(wd) 156 154 nbpair=numel(dirpair); … … 158 156 ref_j_list=zeros(1,nbpair); 159 157 if nbpair==0% no detected file 160 % RootPath='';158 % RootPath=''; 161 159 RootFile=''; 162 160 end … … 165 163 rr=regexp(dirpair(ifile).name,detect_string,'names'); 166 164 if ~isempty(rr) 167 i1=str2num(rr.i1); 168 i2=str2num(rr.i2); 169 j1=stra2num(rr.j1); 170 j2=stra2num(rr.j2); 171 ref_i=i1; 172 if isempty(i2_input) 173 if ~isempty(i2)% invalid file name if i2 does not exist in the input file 174 break 175 end 176 else 177 ref_i=floor((i1+i2)/2); 178 end 179 ref_j=1; 180 if isempty(j1_input) 181 if ~isempty(j1)% invalid file name if j1 does not exist in the input file 182 break 183 end 184 else %j1_input is not empty 185 if isempty(j1)% the detected name does not fit with the input 186 break 165 i1=str2num(rr.i1); 166 i2=str2num(regexprep(rr.i2,'^-','')); 167 j1=stra2num(regexprep(rr.j1,'^_','')); 168 j2=stra2num(regexprep(rr.j2,'^-','')); 169 ref_i=i1; 170 if isempty(i2_input) 171 if ~isempty(i2)% invalid file name if i2 does not exist in the input file 172 break 173 end 187 174 else 188 ref_j=j1; 189 if isempty(j2_input) 190 if ~isempty(j2)% invalid file name if j2 does not exist in the input file 191 break 175 ref_i=floor((i1+i2)/2); 176 end 177 ref_j=1; 178 if isempty(j1_input) 179 if ~isempty(j1)% invalid file name if j1 does not exist in the input file 180 break 181 end 182 else %j1_input is not empty 183 if isempty(j1)% the detected name does not fit with the input 184 break 185 else 186 ref_j=j1; 187 if isempty(j2_input) 188 if ~isempty(j2)% invalid file name if j2 does not exist in the input file 189 break 190 end 191 else 192 ref_j=floor((j1+j2)/2); 192 193 end 193 else 194 ref_j=floor((j1+j2)/2); 195 end 196 end 197 end 198 % update the detected index series 199 ref_i_list(ifile)=ref_i; 200 ref_j_list(ifile)=ref_j; 201 nb_pairs=0; 202 if ~isempty(i2_input)|| ~isempty(j2_input) %deals with pairs 203 if size(i1_series,1)>=ref_i+1 && size(i1_series,2)>=ref_j+1 204 nb_pairs=numel(find(i1_series(ref_i+1,ref_j+1,:)~=0)); 205 end 206 end 207 i1_series(ref_i+1,ref_j+1,nb_pairs+1)=i1; 208 if ~isempty(i2_input) 209 i2_series(ref_i+1,ref_j+1,nb_pairs+1)=i2; 210 end 211 if ~isempty(j1_input) 212 j1_series(ref_i+1,ref_j+1,nb_pairs+1)=j1; 213 end 214 if ~isempty(j2_input) 215 j1_series(ref_i+1,ref_j+1,nb_pairs+1)=j1; 216 j2_series(ref_i+1,ref_j+1,nb_pairs+1)=j2; 217 end 194 end 195 end 196 % update the detected index series 197 ref_i_list(ifile)=ref_i; 198 ref_j_list(ifile)=ref_j; 199 nb_pairs=0; 200 if ~isempty(i2_input)|| ~isempty(j2_input) %deals with pairs 201 if size(i1_series,1)>=ref_i+1 && size(i1_series,2)>=ref_j+1 202 nb_pairs=numel(find(i1_series(ref_i+1,ref_j+1,:)~=0)); 203 end 204 end 205 i1_series(ref_i+1,ref_j+1,nb_pairs+1)=i1; 206 if ~isempty(i2_input) 207 i2_series(ref_i+1,ref_j+1,nb_pairs+1)=i2; 208 end 209 if ~isempty(j1_input) 210 j1_series(ref_i+1,ref_j+1,nb_pairs+1)=j1; 211 end 212 if ~isempty(j2_input) 213 j1_series(ref_i+1,ref_j+1,nb_pairs+1)=j1; 214 j2_series(ref_i+1,ref_j+1,nb_pairs+1)=j2; 215 end 218 216 end 219 217 end … … 227 225 [tild,ifile_min]=min(ref_ij(ref_ij>0)); 228 226 if isempty(ifile_min) 229 % RootPath='';227 % RootPath=''; 230 228 RootFile=''; 231 229 NomType=''; … … 239 237 end 240 238 end 241 242 243 239 244 240 %% set to empty array the irrelevant index series -
trunk/src/mouse_motion.m
r387 r388 102 102 if isfield(Field,'ListVarName') 103 103 [CellVarIndex,NbDim,VarType]=find_field_indices(Field);%analyse the physical fields contained in Field 104 % if isfield(Field,'Mesh') && ~isempty(Field.Mesh)105 104 text_displ_1=''; 106 105 text_displ_2=''; … … 207 206 text_displ_1=[text_displ_1 ' z=' num2str(z,3)]; 208 207 end 209 %coordinate transform if proj_coord differs from menu_coord A REVOIR 210 % if isfield(Field,'CoordUnit') 211 % mouse.CoordUnit=Field.CoordUnit; 212 % end 213 % case of PIV correlation display 208 % case of PIV correlation display 214 209 if test_piv 215 210 par=read_GUI(hhciv.Civ1); … … 221 216 par.ImageA=Field.A; 222 217 par.ImageB=Field.B; 223 [par.ImageHeight,par.ImageWidth]=size(par.ImageA); 218 par.ImageHeight=size(par.ImageA,1); 219 par.ImageWidth=size(par.ImageA,2); 224 220 Param.Civ1=par; 225 221 ibx2=floor((par.Bx-1)/2); … … 287 283 set(handles.text_display,'String',get(handles.text_display,'UserData')) 288 284 end 289 % set(handles.text_display_1,'String',text_displ_1);290 % set(handles.text_display_2,'String',text_displ_2);291 % set(handles.text_display_3,'String',text_displ_3);292 % set(handles.text_display_4,'String',text_displ_4);293 285 294 286 %%%%%%%%%%%%% -
trunk/src/mouse_up.m
r379 r388 122 122 % set(hh_set_object.ZObject,'String',num2str(ObjectData.Coord(:,3),4)); 123 123 if strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse') 124 set(hh_set_object. XMax,'String',num2str(ObjectData.RangeX,4));125 set(hh_set_object. YMax,'String',num2str(ObjectData.RangeY,4));124 set(hh_set_object.num_RangeX_2,'String',num2str(ObjectData.RangeX,4)); 125 set(hh_set_object.num_RangeY_2,'String',num2str(ObjectData.RangeY,4)); 126 126 end 127 127 if NbDefPoint<=2 || isequal(get(currentfig,'SelectionType'),'alt') ||... -
trunk/src/plot_field.m
r379 r388 94 94 95 95 function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,PosColorbar) 96 % use htext: handles of the text edit box (uicontrol) 97 % introduce PlotParam.Hold: 'on' or 'off' (for curves) 98 %default output 99 96 97 %% default input and output 100 98 if ~exist('PlotParam','var'),PlotParam=[];end; 101 99 if ~exist('PosColorbar','var'),PosColorbar=[];end; … … 107 105 end 108 106 109 %% test axes and figure110 testnewfig=1;%test to create a new figure (default)111 testzoomaxes=0;%test for the existence of a zoom secondary figure attached to the plotting axes112 if exist('haxes','var')113 if ishandle(haxes)114 if isequal(get(haxes,'Type'),'axes')115 testnewfig=0;116 AxeData=get(haxes,'UserData');117 if isfield(AxeData,'ZoomAxes')&& ishandle(AxeData.ZoomAxes)118 if isequal(get(AxeData.ZoomAxes,'Type'),'axes')119 testzoomaxes=1;120 zoomaxes=AxeData.ZoomAxes;121 end122 end123 end124 end125 end126 127 % create a new figure and axes if the plotting axes does not exist128 if testnewfig129 hfig=figure;130 set(hfig,'Units','normalized')131 haxes=axes;132 set(haxes,'position',[0.13,0.2,0.775,0.73])133 PlotParam.NextPlot='add'; %parameter for plot_profile and plot_his134 else135 hfig=get(haxes,'parent');136 set(0,'CurrentFigure',hfig)% the parent of haxes becomes the current figure137 set(hfig,'CurrentAxes',haxes)% haxes becomes the current axes of the parent figure138 end139 140 107 %% check input structure 141 if ~isempty(Data) 142 [Data,errormsg]=check_field_structure(Data); 143 if ~isempty(errormsg) 144 msgbox_uvmat('ERROR',['input of plot_field/check_field_structure: ' errormsg]) 145 display(['input of plot_field/check_field_structure:: ' errormsg]) 146 return 147 end 148 149 %% check the cells of fields : 150 [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data); 151 if ~isempty(errormsg) 152 msgbox_uvmat('ERROR',['input of plot_field/find_field_indices: ' errormsg]); 153 return 154 end 155 index_2D=find(NbDim==2,2);%find 2D fields (at most 2) 156 index_3D=find(NbDim>2,1); 157 if ~isempty(index_3D) 158 if isfield(Data,'NbDim')&& isequal(Data.NbDim,2) 159 index_2D=[index_2D index_3D]; 160 else 108 index_2D=[]; 109 index_1D=[]; 110 index_0D=[]; 111 [Data,errormsg]=check_field_structure(Data); 112 if ~isempty(errormsg) 113 msgbox_uvmat('ERROR',['input of plot_field/check_field_structure: ' errormsg]) 114 display(['input of plot_field/check_field_structure: ' errormsg]) 115 return 116 end 117 % check the cells of fields : 118 [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data); 119 if ~isempty(errormsg) 120 msgbox_uvmat('ERROR',['input of plot_field/find_field_indices: ' errormsg]); 121 return 122 end 123 index_2D=find(NbDim==2,2);%find 2D fields (at most 2) 124 index_3D=find(NbDim>2,1); 125 if ~isempty(index_3D) 126 if isfield(Data,'NbDim')&& isequal(Data.NbDim,2) 127 index_2D=[index_2D index_3D]; 128 else 161 129 msgbox_uvmat('ERROR','volume plot not implemented yet'); 162 130 return 163 end 164 end 165 166 index_1D=find(NbDim==1); 167 index_0D=find(NbDim==0); 131 end 132 end 133 index_1D=find(NbDim==1); 134 index_0D=find(NbDim==0); 135 %remove coordinates variables from 1D plot 136 if ~isempty(index_2D) 137 for ivar=1:length(index_1D) 138 if isequal(CellVarIndex{index_1D(ivar)},VarType{index_1D(ivar)}.coord) 139 index_1D(ivar)=0; 140 end 141 end 142 index_1D=index_1D(index_1D>0); 143 end 144 145 %% pure text display 146 if isempty(index_2D) && isempty(index_1D)% no plot 147 hfig=findobj(allchild(0),'Tag','fig_text_display'); 148 if isempty(hfig) 149 hfig=figure('name','text_display','Tag','fig_text_display'); 150 end 151 htext=findobj(hfig,'Tag','text_display'); 152 if isempty(htext) 153 htext=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71],'Tag','text_display'); 154 end 155 if isempty(index_0D) 156 set(htext,'String',{''}) 157 else 158 [errormsg]=plot_text(Data,CellVarIndex(index_0D),htext); 159 end 160 haxes=[]; 161 end 162 163 %% test axes and figure 164 if ~isempty(index_2D)|| ~isempty(index_1D)% plot 165 testnewfig=1;%test to create a new figure (default) 166 testzoomaxes=0;%test for the existence of a zoom secondary figure attached to the plotting axes 167 if exist('haxes','var') 168 if ishandle(haxes) 169 if isequal(get(haxes,'Type'),'axes') 170 testnewfig=0; 171 AxeData=get(haxes,'UserData'); 172 if isfield(AxeData,'ZoomAxes')&& ishandle(AxeData.ZoomAxes) 173 if isequal(get(AxeData.ZoomAxes,'Type'),'axes') 174 testzoomaxes=1; 175 zoomaxes=AxeData.ZoomAxes; 176 end 177 end 178 end 179 end 180 end 181 % create a new figure and axes if the plotting axes does not exist 182 if testnewfig 183 hfig=figure; 184 set(hfig,'Units','normalized') 185 haxes=axes; 186 set(haxes,'position',[0.13,0.2,0.775,0.73]) 187 PlotParam.NextPlot='add'; %parameter for plot_profile and plot_his 188 else 189 hfig=get(haxes,'parent'); 190 set(0,'CurrentFigure',hfig)% the parent of haxes becomes the current figure 191 set(hfig,'CurrentAxes',haxes)% haxes becomes the current axes of the parent figure 192 end 168 193 169 194 %% set axes properties 170 if isfield(Coordinates,'CheckFixLimits') && isequal(Coordinates.CheckFixLimits,1) %adjust the graph limits *195 if isfield(Coordinates,'CheckFixLimits') && isequal(Coordinates.CheckFixLimits,1) %adjust the graph limits 171 196 set(haxes,'XLimMode', 'manual') 172 197 set(haxes,'YLimMode', 'manual') … … 184 209 set(haxes,'DataAspectRatioMode','auto')%automatic aspect ratio 185 210 end 186 else 187 index_2D=[]; 188 index_1D=[]; 189 index_0D=[]; 190 end 191 192 %% plot if the input field is valid 193 PlotType='text'; 194 errormsg=[]; 195 AxeData=get(haxes,'UserData'); 196 if isempty(index_2D) 197 plot_plane([],[],[],haxes);%removes images or vector plots if any 198 else 199 [xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),haxes,PlotParam,PosColorbar); 200 AxeData.NbDim=2; 201 if testzoomaxes && isempty(errormsg) 202 [zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),zoomaxes,PlotParam,PosColorbar); 203 AxeData.ZoomAxes=zoomaxes; 204 end 205 %remove coordinates variables from 1D plot 206 for ivar=1:length(index_1D) 207 if isequal(CellVarIndex{index_1D(ivar)},VarType{index_1D(ivar)}.coord) 208 index_1D(ivar)=0; 209 end 210 end 211 index_1D=find(index_1D); 212 end 213 214 if isempty(index_1D) 215 plot_profile([],[],[],haxes);% 216 else 217 Coordinates=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,Coordinates);% 218 if testzoomaxes 219 [zoomaxes,Coordinates]=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),zoomaxes,PlotParam.Coordinates); 220 AxeData.ZoomAxes=zoomaxes; 221 end 222 if ~isempty(Coordinates) 223 PlotParamOut.Coordinates=Coordinates; 224 end 225 PlotType='line'; 226 end 227 htext=findobj(hfig,'Tag','text_display'); 228 if ~isempty(htext) 229 if isempty(index_0D) 230 set(htext,'String',{''}) 231 else 232 [errormsg]=plot_text(Data,CellVarIndex(index_0D),htext); 233 end 234 end 235 211 errormsg=''; 212 213 %% plot if the input field is valid 214 AxeData=get(haxes,'UserData'); 215 if isempty(index_2D) 216 plot_plane([],[],[],haxes);%removes images or vector plots if any 217 else 218 [tild,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),haxes,PlotParam,PosColorbar); 219 AxeData.NbDim=2; 220 if testzoomaxes && isempty(errormsg) 221 [zoomaxes,PlotParamOut,tild,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),zoomaxes,PlotParam,PosColorbar); 222 AxeData.ZoomAxes=zoomaxes; 223 end 224 end 225 if isempty(index_1D) 226 if ~isempty(haxes) 227 plot_profile([],[],[],haxes);% 228 end 229 else 230 Coordinates=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,Coordinates);% 231 if testzoomaxes 232 [zoomaxes,Coordinates]=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),zoomaxes,PlotParam.Coordinates); 233 AxeData.ZoomAxes=zoomaxes; 234 end 235 if ~isempty(Coordinates) 236 PlotParamOut.Coordinates=Coordinates; 237 end 238 PlotType='line'; 239 end 240 % text display 241 htext=findobj(hfig,'Tag','text_display'); 242 if ~isempty(htext) 243 if isempty(index_0D) 244 set(htext,'String',{''}) 245 else 246 [errormsg]=plot_text(Data,CellVarIndex(index_0D),htext); 247 end 248 end 249 end 250 251 %% display error message 236 252 if ~isempty(errormsg) 237 253 msgbox_uvmat('ERROR', errormsg) 238 254 end 239 if isfield(PlotParamOut,'MinX')240 AxeData.RangeX=[PlotParamOut.MinX PlotParamOut.MaxX];%'[PlotParamOut.MinX PlotParamOut.MaxX];241 AxeData.RangeY=[PlotParamOut.MinY PlotParamOut.MaxY];%[PlotParamOut.MinY PlotParamOut.MaxY]242 end243 255 244 256 %% update the parameters stored in AxeData 245 set(haxes,'UserData',AxeData) 257 if ishandle(haxes) 258 if isfield(PlotParamOut,'MinX') 259 AxeData.RangeX=[PlotParamOut.MinX PlotParamOut.MaxX];%'[PlotParamOut.MinX PlotParamOut.MaxX]; 260 AxeData.RangeY=[PlotParamOut.MinY PlotParamOut.MaxY];%[PlotParamOut.MinY PlotParamOut.MaxY] 261 end 262 set(haxes,'UserData',AxeData) 263 end 246 264 247 265 %% update the plotted field stored in parent figure 266 248 267 FigData=get(hfig,'UserData'); 249 tagaxes=get(haxes,'tag'); 268 if strcmp(get(hfig,'tag'),'view_field') 269 set(hfig,'UserData',[]); % refresh user data in view_field (set by civ/TestCiv ) 270 end 271 tagaxes=get(haxes,'tag');% tag of the current plot axis 250 272 if isfield(FigData,tagaxes) 251 eval(['FigData.' tagaxes '=Data;'])273 FigData.(tagaxes)=Data; 252 274 set(hfig,'UserData',FigData) 253 275 end -
trunk/src/proj_field.m
r382 r388 182 182 end 183 183 VarIndex=CellVarIndex{icell};% indices of the selected variables in the list FieldData.ListVarName 184 VarType=VarTypeCell{icell}; 184 VarType=VarTypeCell{icell};% structure defining the types of variables in the cell 185 185 ivar_X=VarType.coord_x; 186 186 ivar_Y=VarType.coord_y; … … 211 211 for ivar=VarIndex 212 212 VarName=FieldData.ListVarName{ivar}; 213 ProjData.ListVarName=[ProjData.ListVarName {VarName}]; 214 ProjData.VarDimName=[ProjData.VarDimName {'nb_points'}]; 213 ProjData.ListVarName=[ProjData.ListVarName {VarName}];% add the current variable to the list of projected variables 214 ProjData.VarDimName=[ProjData.VarDimName {'nb_points'}]; % projected VarName has a single dimension called 'nb_points' (set of projection points) 215 215 end 216 216 if ~test_grid … … 236 236 if isequal(length(ivar_FF),1) 237 237 FFName=FieldData.ListVarName{ivar_FF}; 238 eval(['FF=FieldData.' FFName '(indsel);']) 239 %ind_indsel=find(~FF); 238 FF=FieldData.(FFName)(indsel); 240 239 indsel=indsel(~FF); 241 240 end … … 244 243 VarName=FieldData.ListVarName{ivar}; 245 244 if isempty(indsel) 246 eval(['ProjData.' VarName '(ipoint,1)=NaN;'])245 ProjData.(VarName)(ipoint,1)=NaN; 247 246 else 248 eval(['Var=FieldData.' VarName '(indsel);'])249 eval(['ProjData.' VarName '(ipoint,1)=mean(Var);'])247 Var=FieldData.(VarName)(indsel); 248 ProjData.(VarName)(ipoint,1)=mean(Var); 250 249 if isequal(ObjectData.ProjMode,'interp') 251 250 ProjData.(VarName)(ipoint,1)=griddata_uvmat(coord_x(indsel),coord_y(indsel),Var,Xpoint(1),Xpoint(2)); … … 254 253 end 255 254 end 256 else 257 %DimIndices=FieldData.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell) 258 %case of structured coordinates 255 else %case of structured coordinates 259 256 if numel(VarType.coord)>=2 & VarType.coord(1:2) > 0; 260 257 AYName=FieldData.ListVarName{VarType.coord(1)}; … … 262 259 eval(['AX=FieldData.' AXName ';']);% set of x positions 263 260 eval(['AY=FieldData.' AYName ';']);% set of y positions 264 AName=FieldData.ListVarName{VarIndex(1)}; 261 AName=FieldData.ListVarName{VarIndex(1)};% a single variable assumed in the current cell 265 262 eval(['A=FieldData.' AName ';']);% scalar 266 npxy=size(A); 267 268 % % nbcolor=1; %default 269 % for idim=1:length(ListDimName) 270 % DimName=ListDimName{idim}; 271 % if isequal(DimName,'rgb')|isequal(DimName,'nb_coord')|isequal(DimName,'nb_coord_i') 272 % nbcolor=npxy(idim); 273 % DimIndices(idim)=[]; 274 % npxy(idim)=[]; 275 % end 276 % if isequal(DimName,'nb_coord_j')% NOTE: CASE OF TENSOR NOT TREATED 277 % DimIndices(idim)=[]; 278 % npxy(idim)=[]; 279 % end 280 % end 281 ind_1=find(npxy==1); 282 %DimIndices(ind_1)=[]; %suppress singleton dimensions 283 % indxy=find(DimVarIndex(DimIndices));%select dimension variables (DimIndices non zero) 284 %NbDim=length(DimIndices)%number of space dimensions 285 NbDim=numel(VarType.coord); 286 Coord_z=[]; 287 Coord_y=[]; 288 Coord_x=[]; 263 npxy=size(A); 264 NbDim=numel(VarType.coord(VarType.coord>0));%number of space dimensions 265 %update VarDimName in case of components (non coordinate dimensions e;g. color components) 266 if numel(npxy)>NbDim 267 ProjData.VarDimName{end}={'nb_points','component'}; 268 end 289 269 for idim=1:NbDim %loop on space dimensions 290 270 test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default 291 271 test_coord(idim)=0;%test for defined coordinates, =0 by default 292 %ivar=DimVarIndex(DimIndices(idim));% index of the variable corresponding to the current dimension293 272 ivar=VarType.coord(idim); 294 % if ~isequal(ivar,0)% a variable corresponds to the current dimension 295 eval(['Coord{idim}=FieldData.' FieldData.ListVarName{ivar} ';']) ;% position for the first index 296 if numel(Coord{idim})==2 297 DCoord_min(idim)= (Coord{idim}(2)-Coord{idim}(1))/(npxy(idim)-1); 298 else 299 DCoord=diff(Coord{idim}); 300 DCoord_min(idim)=min(DCoord); 301 DCoord_max=max(DCoord); 302 test_direct(idim)=DCoord_max>0;% =1 for increasing values, 0 otherwise 303 test_direct_min=DCoord_min(idim)>0;% =1 for increasing values, 0 otherwise 304 if ~isequal(test_direct(idim),test_direct_min) 305 errormsg=['non monotonic dimension variable # ' num2str(idim) ' in proj_field.m']; 306 return 307 end 308 test_interp(idim)=(DCoord_max-DCoord_min(idim))> 0.0001*abs(DCoord_max);% test grid regularity 309 test_coord(idim)=1; 310 end 311 % else % no variable associated with the first dimension, look fo variable attributes Coord_1, _2 or _3 312 % Coord_i_str=['Coord_' num2str(idim)]; 313 % DCoord_min(idim)=1;%default 314 % Coord{idim}=[0.5 npxy(idim)]; 315 % test_direct(idim)=1; 316 % end 273 Coord{idim}=FieldData.(FieldData.ListVarName{ivar}); % position for the first index 274 if numel(Coord{idim})==2 275 DCoord_min(idim)= (Coord{idim}(2)-Coord{idim}(1))/(npxy(idim)-1); 276 else 277 DCoord=diff(Coord{idim}); 278 DCoord_min(idim)=min(DCoord); 279 DCoord_max=max(DCoord); 280 test_direct(idim)=DCoord_max>0;% =1 for increasing values, 0 otherwise 281 test_direct_min=DCoord_min(idim)>0;% =1 for increasing values, 0 otherwise 282 if ~isequal(test_direct(idim),test_direct_min) 283 errormsg=['non monotonic dimension variable # ' num2str(idim) ' in proj_field.m']; 284 return 285 end 286 test_interp(idim)=(DCoord_max-DCoord_min(idim))> 0.0001*abs(DCoord_max);% test grid regularity 287 test_coord(idim)=1; 288 end 317 289 end 318 290 DX=DCoord_min(2); … … 343 315 %[I,J]=meshgrid([1:j_int],[1:i_int]); 344 316 for ivar=VarIndex 345 eval(['Avalue=FieldData.' FieldData.ListVarName{ivar} '(j_int,i_int,:);']);346 eval(['ProjData.' FieldData.ListVarName{ivar} '(ipoint,:)=mean(mean(Avalue));']);317 Avalue=FieldData.(FieldData.ListVarName{ivar})(j_int,i_int,:); 318 ProjData.(FieldData.ListVarName{ivar})(ipoint,:)=mean(mean(Avalue)); 347 319 end 348 320 end … … 445 417 eval(['AY=FieldData.' AYName ';'])% y coordinate 446 418 VarName=FieldData.ListVarName{VarIndex(1)}; 447 eval(['DimValue=size(FieldData.' VarName ');'])419 DimValue=size(FieldData.(VarName)); 448 420 if length(AX)==2 449 421 AX=linspace(AX(1),AX(end),DimValue(2)); … … 460 432 % AX=linspace(Coord{2}(1),Coord{2}(2),DimValue(2)); 461 433 % AY=linspace(Coord{1}(1),Coord{1}(2),DimValue(1)); %TODO : 3D case 462 testcolor=find(numel(DimValue)==3);434 % testcolor=find(numel(DimValue)==3); 463 435 if length(DimValue)==3 464 436 testcolor=1; … … 475 447 for ivar=1:length(VarIndex) 476 448 VarName=FieldData.ListVarName{VarIndex(ivar)}; 477 eval(['FieldData.' VarName '=reshape(FieldData.' VarName ',npxy(1)*npxy(2),npxy(3));']); % keep only non false vectors449 FieldData.(VarName)=reshape(FieldData.(VarName),npxy(1)*npxy(2),npxy(3)); % keep only non false vectors 478 450 end 479 451 end … … 526 498 if testproj(ivar) 527 499 VarName=FieldData.ListVarName{ivar}; 528 eval(['ProjData.' VarName 'Mean=mean(mean(double(FieldData.' VarName '(indsel,:))));']); % keep only non false vectors529 eval(['ProjData.' VarName 'Min=min(min(double(FieldData.' VarName '(indsel,:))));']); % keep only non false vectors530 eval(['ProjData.' VarName 'Max=max(max(double(FieldData.' VarName '(indsel,:))));']); % keep only non false vectors500 ProjData.([VarName 'Mean'])=mean(double(FieldData.(VarName)(indsel,:))); % take the mean in the selected region, for each color component 501 ProjData.([VarName 'Min'])=min(double(FieldData.(VarName)(indsel,:))); % take the min in the selected region , for each color component 502 ProjData.([VarName 'Max'])=max(double(FieldData.(VarName)(indsel,:))); % take the max in the selected region , for each color component 531 503 if isequal(Mesh(ivar),0) 532 eval(['[ProjData.' VarName 'Histo,ProjData.' VarName ']=hist(double(FieldData.' VarName '(indsel,: )),100);']); % default histogram with 100 bins504 eval(['[ProjData.' VarName 'Histo,ProjData.' VarName ']=hist(double(FieldData.' VarName '(indsel,:,:)),100);']); % default histogram with 100 bins 533 505 else 534 506 eval(['ProjData.' VarName '=(ProjData.' VarName 'Min+Mesh(ivar)/2:Mesh(ivar):ProjData.' VarName 'Max);']); % list of bin values … … 537 509 ProjData.ListVarName=[ProjData.ListVarName {VarName} {[VarName 'Histo']} {[VarName 'Mean']} {[VarName 'Min']} {[VarName 'Max']}]; 538 510 if test_Amat && testcolor 539 ProjData.VarDimName=[ProjData.VarDimName {VarName} {{VarName,'rgb'}} {'rgb'} ];%{{'nb_point','rgb'}};511 ProjData.VarDimName=[ProjData.VarDimName {VarName} {{VarName,'rgb'}} {'rgb'} {'rgb'} {'rgb'}];%{{'nb_point','rgb'}}; 540 512 else 541 ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName} {' nbpoint'} {'nbpoint'} {'nbpoint'}];513 ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName} {'one'} {'one'} {'one'}]; 542 514 end 543 515 ProjData.VarAttribute=[ProjData.VarAttribute FieldData.VarAttribute{ivar} {[]} {[]} {[]} {[]}]; -
trunk/src/set_object.m
r387 r388 220 220 set(handles.ProjMode,'String',menu_proj) 221 221 ProjMode_Callback(hObject, eventdata, handles) 222 223 %store the current option224 % str=get(handles.Type,'String');225 % val=get(handles.Type,'Value');226 % set(handles.Type,'UserData',style)227 228 %------------------------------------------------------------------------229 function xObject_Callback(hObject, eventdata, handles)230 231 %------------------------------------------------------------------------232 function yObject_Callback(hObject, eventdata, handles)233 234 %------------------------------------------------------------------------235 % --- Executes on selection change in zObject.236 function zObject_Callback(hObject, eventdata, handles)237 %------------------------------------------------------------------------238 222 239 223 %------------------------------------------------------------------------ … … 403 387 404 388 %% reading the object parameters on the GUI uvmat 405 huvmat=findobj('tag','uvmat');%find the current uvmat interfacehandle389 huvmat=findobj('tag','uvmat');%find the current uvmat GUI handle 406 390 UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat 407 hhuvmat=guidata(huvmat);%handles in the uvmat GUI 408 ListObject=get(hhuvmat.ListObject,'String');%position in the objet list 409 IndexObj=get(hhuvmat.ListObject,'Value'); 391 hhuvmat=guidata(huvmat);%handles of the objects children of the GUI uvmat 392 ListObject=get(hhuvmat.ListObject,'String');% list of objects displyed in uvmat 393 IndexObj=get(hhuvmat.ListObject,'Value');% index(indices) of the selected object(s) in uvmat 394 % (the first one is plotted in uvmat axis, the second one in view_field) 410 395 411 396 %% read the object on the GUI set_object 412 %ObjectData=read_set_object(handles.set_object);%read the input parameters defining the object in the GUI set_object 413 ObjectData=read_GUI(handles.set_object);%read the input parameters defining the object in the GUI set_object 414 %ObjectData.Coord=cell2mat(ObjectData.Coord); 415 ObjectName=ObjectData.Name;%name of the current object defiend in set_object 397 ObjectData=read_GUI(handles.set_object);%read the parameters defining the object in the GUI set_object 398 ObjectName=ObjectData.Name;%name of the current object defined in set_object 399 checknan=isnan(sum(ObjectData.Coord,2));%check for NaN lines 400 if ~isempty(checknan) 401 ObjectData.Coord(checknan,:)=[];%remove the NaN lines 402 end 416 403 if isempty(ObjectName) 417 404 if get(hhuvmat.edit_object,'Value')% edit mode … … 449 436 testnew=0; 450 437 if numel(IndexObj)==1 % if only one object is selected, the projection is in uvmat 451 % PlotHandles=hhuvmat;452 438 plotaxes=hhuvmat.axes3;%handle of axes3 in view_field 453 439 else % if a second object is selected, the projection is in view_field, and this second object is selected 454 440 hview_field=findobj(allchild(0),'tag','view_field'); 455 441 if isempty(hview_field) 456 hview_field=view_field; 442 hview_field=view_field;%open the GUI view_field if it is not found 457 443 end 458 444 PlotHandles=guidata(hview_field); … … 464 450 set(hhuvmat.ListObject,'String',ListObject) 465 451 466 %% update the object plot and projection field452 %% update the object plot 467 453 if testnew 468 454 set(hhuvmat.ListObject,'Value',IndexObj) … … 488 474 489 475 %% plot the field projected on the object and store in the corresponding figue 490 [ProjData,errormsg]= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData 491 if ~isempty(errormsg) 492 msgbox_uvmat('ERROR', errormsg) 493 return 494 end 495 fighandle=get(plotaxes,'parent'); 496 PlotParam=read_GUI(fighandle); 497 [PlotType,Object_out{IndexObj(end)}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot 498 476 if strcmp(ObjectData.ProjMode,'mask_inside')||strcmp(ObjectData.ProjMode,'mask_outside')||strcmp(ObjectData.ProjMode,'none') 477 PlotType='text'; 478 479 else 480 [ProjData,errormsg]= proj_field(UvData.Field,ObjectData);%project the current field of uvmat on ObjectData 481 if ~isempty(errormsg) 482 msgbox_uvmat('ERROR', errormsg) 483 return 484 end 485 fighandle=get(plotaxes,'parent'); 486 PlotParam=read_GUI(fighandle); 487 PlotType=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot 488 end 489 if strcmp(PlotType,'text') 490 hview_field=findobj(allchild(0),'tag','view_field'); %case of no projection (pure object display) 491 if ~isempty(hview_field) 492 delete(hview_field) 493 end 494 end 495 499 496 %% update the GUI uvmat 500 497 hhuvmat=guidata(huvmat);%handles of elements in the uvmat GUI … … 603 600 end 604 601 605 %set new plane position and update graph 606 % set(handles.XObject,'String',num2str(norm_plane(1)*Z_value,4)) 607 % set(handles.YObject,'String',num2str(norm_plane(2)*Z_value,4)) 608 % set(handles.ZObject,'String',num2str(norm_plane(3)*Z_value,4)) 602 % update graph 609 603 PLOT_Callback(hObject, eventdata, handles) 610 604 … … 616 610 pathelp=fileparts(path_to_uvmat); 617 611 helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); 618 if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') 619 else 612 if ~isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') 620 613 addpath (fullfile(pathelp,'uvmat_doc')) 621 614 web([helpfile '#set_object']) … … 641 634 case{'points','polyline','polygon'} 642 635 Coord=get(handles.Coord,'Data'); 643 if isequal(size(Coord,2),3) 644 Coord=[Coord;{[]} {[]} {[]}];%add a line for edition (3D case) 645 else 646 Coord=[Coord;{[]} {[]}]; %add a line for edition (2D case) 647 end 648 set(handles.Coord,'Data',Coord) 636 if ~isnan(Coord(end,1)) 637 if isequal(size(Coord,2),3) 638 %Coord=[Coord;{[]} {[]} {[]}];%add a line for edition (3D case) 639 Coord=[Coord;NaN NaN NaN]; %add a line for edition (3D case) 640 else 641 Coord=[Coord;NaN NaN]; %add a line for edition (2D case) 642 end 643 set(handles.Coord,'Data',Coord) 644 end 649 645 end 650 646 -
trunk/src/uvmat.m
r387 r388 1631 1631 ref_j=ref_j+increment; 1632 1632 end 1633 else % free increment1633 else % free increment 1634 1634 if isequal(get(handles.runplus,'BackgroundColor'),[1 1 0])% if runplus is activated 1635 1635 step=1; … … 1662 1662 end 1663 1663 if get(handles.scan_i,'Value')==1% case of scanning along index i 1664 i1_subseries=UvData.i1_series{1}(ref_i+1, :,:);1664 i1_subseries=UvData.i1_series{1}(ref_i+1,ref_j+1,:); 1665 1665 else 1666 i1_subseries=UvData.i1_series{1}( :,ref_j+1,:);1666 i1_subseries=UvData.i1_series{1}(ref_i+1,ref_j+1,:); 1667 1667 end 1668 1668 i1_subseries=i1_subseries(i1_subseries>0); … … 1674 1674 if ~isempty(UvData.i2_series{1}) 1675 1675 if get(handles.scan_i,'Value')==1% case of scanning along index i 1676 i2_subseries=UvData.i2_series{1}(ref_i+1, :,:);1676 i2_subseries=UvData.i2_series{1}(ref_i+1,ref_j+1,:); 1677 1677 else 1678 i2_subseries=UvData.i2_series{1}( :,ref_j+1,:);1678 i2_subseries=UvData.i2_series{1}(ref_i+1,ref_j+1,:); 1679 1679 end 1680 1680 i2_subseries=i2_subseries(i2_subseries>0); … … 1683 1683 if ~isempty(UvData.j1_series{1}) 1684 1684 if get(handles.scan_i,'Value')==1% case of scanning along index i 1685 j1_subseries=UvData.j1_series{1}(ref_i+1, :,:);1685 j1_subseries=UvData.j1_series{1}(ref_i+1,ref_j+1,:); 1686 1686 else 1687 j1_subseries=UvData.j1_series{1}( :,ref_j+1,:);1687 j1_subseries=UvData.j1_series{1}(ref_i+1,ref_j+1,:); 1688 1688 end 1689 1689 j1_subseries=j1_subseries(j1_subseries>0); … … 1692 1692 if ~isempty(UvData.j2_series{1}) 1693 1693 if get(handles.scan_i,'Value')==1% case of scanning along index i 1694 j2_subseries=UvData.j2_series{1}(ref_i+1, :,:);1694 j2_subseries=UvData.j2_series{1}(ref_i+1,ref_j+1,:); 1695 1695 else 1696 j2_subseries=UvData.j2_series{1}( :,ref_j+1,:);1696 j2_subseries=UvData.j2_series{1}(ref_i+1,ref_j+1,:); 1697 1697 end 1698 1698 j2_subseries=j2_subseries(j2_subseries>0);
Note: See TracChangeset
for help on using the changeset viewer.