Changeset 1164 for trunk/src/uvmat.m
- Timestamp:
- Jul 29, 2024, 9:43:17 AM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.