Changeset 1164 for trunk/src/uvmat.m


Ignore:
Timestamp:
Jul 29, 2024, 9:43:17 AM (2 months ago)
Author:
sommeria
Message:

civ3D updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r1163 r1164  
    21982198%------------------------------------------------------------------------
    21992199% --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
    2200 function errormsg=display_file_name(handles,fileinput,index)
     2200function errormsg=display_file_name(handles,fileinput,input_line)
    22012201%------------------------------------------------------------------------
    22022202%% look for the input file existence
     
    22082208end
    22092209
    2210 %% define the relevant handles for the first field series (index=1) or the second file series (index=2)
    2211 if ~exist('index','var')
    2212     index=1;
    2213 end
    2214 if index==1
     2210%% define the relevant handles for the first field series (input_line=1) or the second file series (input_line=2)
     2211if ~exist('input_line','var')
     2212    input_line=1;
     2213end
     2214if input_line==1
    22152215    handles_RootPath=handles.RootPath;
    22162216    handles_SubDir=handles.SubDir;
     
    22192219    handles_NomType=handles.NomType;
    22202220    handles_FileExt=handles.FileExt;
    2221 elseif index==2
     2221elseif input_line==2
    22222222    handles_RootPath=handles.RootPath_1;
    22232223    handles_SubDir=handles.SubDir_1;
     
    22872287        set(handles_NomType,'String',NomType);
    22882288        set(handles_FileExt,'String',FileExt);
    2289         if index==1
     2289        if input_line==1
    22902290            % fill file index counters if the first file series is opened
    22912291            set(handles.i1,'String',num2str(i1));
     
    22932293            set(handles.j1,'String',num2stra(j1,NomType));
    22942294            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                         
    22952308        else %read the current field index to synchronise with the first series
    22962309            i1_s=str2num(get(handles.i1,'String'));
     
    23512364       
    23522365        % initiate input file series and inputfilerefresh the current field view:
    2353         update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,index);
     2366        update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,input_line);
    23542367end
    23552368
     
    23792392% --- Update information about a new field series (indices to scan, timing,
    23802393%     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,index)
     2394function errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,VideoObject,input_line)
    23822395%------------------------------------------------------------------------
    23832396errormsg=''; %default error msg
    23842397
    2385 %% define the relevant handles depending on the index (1=first file series, 2= second file series)
    2386 if ~exist('index','var')
    2387     index=1;
    2388 end
    2389 if index==1
     2398%% define the relevant handles depending on the input_line (1=first file series, 2= second file series)
     2399if ~exist('input_line','var')
     2400    input_line=1;
     2401end
     2402if input_line==1
    23902403    handles_Fields=handles.FieldName;
    2391 elseif index==2
     2404elseif input_line==2
    23922405    handles_Fields=handles.FieldName_1;
    23932406end
     
    23982411UvData.NewSeries=1; %flag for REFRESH: begin a new series
    23992412UvData.FileName_1='';% name of the current second field (used to detect a  constant field during file scanning)
    2400 %UvData.FileType{index}=FileInfo.FileType;
    2401 UvData.FileInfo{index}=FileInfo;
    2402 UvData.MovieObject{index}=VideoObject;
    2403 UvData.i1_series{index}=i1_series;
    2404 UvData.i2_series{index}=i2_series;
    2405 UvData.j1_series{index}=j1_series;
    2406 UvData.j2_series{index}=j2_series;
     2413%UvData.FileType{input_line}=FileInfo.FileType;
     2414UvData.FileInfo{input_line}=FileInfo;
     2415UvData.MovieObject{input_line}=VideoObject;
     2416UvData.i1_series{input_line}=i1_series;
     2417UvData.i2_series{input_line}=i2_series;
     2418UvData.j1_series{input_line}=j1_series;
     2419UvData.j2_series{input_line}=j2_series;
    24072420nbfield=max(max(max(i2_series)));% total number of fields (i index)
    24082421if isempty(nbfield)
     
    24472460%% read parameters (time, geometric calibration..) from a documentation file (.xml advised)
    24482461XmlData.GeometryCalib=[];%default
    2449 if index==1
     2462if input_line==1
    24502463    [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    24512464else
     
    25152528    TimeName='civdata_3D';
    25162529end
    2517 if index==1
     2530if input_line==1
    25182531    set(handles.TimeName,'String',TimeName)
    25192532else
     
    25312544last_i_cell=get(handles.MaxIndex_i,'String');
    25322545if isempty(nbfield)
    2533     last_i_cell{index}='';
    2534 else
    2535     last_i_cell{index}=num2str(nbfield);
     2546    last_i_cell{input_line}='';
     2547else
     2548    last_i_cell{input_line}=num2str(nbfield);
    25362549end
    25372550set(handles.MaxIndex_i,'String',last_i_cell)
    25382551last_j_cell=get(handles.MaxIndex_j,'String');
    25392552if isempty(nbfield_j)
    2540      last_j_cell{index}='';
    2541 else
    2542      last_j_cell{index}=num2str(nbfield_j);
     2553     last_j_cell{input_line}='';
     2554else
     2555     last_j_cell{input_line}=num2str(nbfield_j);
    25432556end
    25442557set(handles.MaxIndex_j,'String',last_j_cell);
     
    25522565        set(handles.pxcmx,'Visible','off')
    25532566        set(handles.pxcmy,'Visible','off')
    2554         if index==1
     2567        if input_line==1
    25552568        set(handles.TransformName,'Value',1); %  no transform by default
    25562569        end
     
    25682581            set(handles.pxcmy,'String',num2str(pixcmy))
    25692582        end
    2570         if ~get(handles.CheckFixLimits,'Value')&& index==1
     2583        if ~get(handles.CheckFixLimits,'Value')&& input_line==1
    25712584            set(handles.TransformName,'Value',3); % phys transform by default if fixedLimits is off
    25722585        end
     
    25912604%% update the data attached to the uvmat interface
    25922605if ~isempty(TimeUnit)
    2593     if index==2 && isfield(UvData,'TimeUnit') && ~strcmp(UvData.TimeUnit,TimeUnit)
     2606    if input_line==2 && isfield(UvData,'TimeUnit') && ~strcmp(UvData.TimeUnit,TimeUnit)
    25942607        msgbox_uvmat('WARNING',['time unit for second file series ' TimeUnit ' inconsistent with first series'])
    25952608    else
     
    25972610    end
    25982611end
    2599 UvData.XmlData{index}=XmlData;
     2612UvData.XmlData{input_line}=XmlData;
    26002613UvData.NewSeries=1;
    26012614set(handles.uvmat,'UserData',UvData)
     
    26122625        set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
    26132626        set(handles_Fields,'Value',2) % set menu to 'velocity
    2614         if index==1
     2627        if input_line==1
    26152628            set(handles.FieldName_1,'Value',1);
    26162629            set(handles.FieldName_1,'String',[{''};{'image'};FieldList;{'get_field...'}]);%standard menu for civx data reproduced for the second field
     
    26272640        set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
    26282641        set(handles_Fields,'Value',2) % set menu to 'velocity
    2629         if index==1
     2642        if input_line==1
    26302643            set(handles.FieldName_1,'Value',1);
    26312644            set(handles.FieldName_1,'String',[{''};{'image'};FieldList;{'get_field...'}]);%standard menu for civx data reproduced for the second field
     
    26412654        set(handles_Fields,'Value',1)
    26422655        set(handles_Fields,'String',{'get_field...'})
    2643         if index==1
     2656        if input_line==1
    26442657            FieldName_Callback([],[], handles)
    26452658        else
     
    26602673scan_option='i';%default
    26612674state_j='off'; %default
    2662 if index==2
     2675if input_line==2
    26632676    if get(handles.scan_j,'Value')
    26642677        scan_option='j'; %keep the scan option for the second file series
     
    26722685    if ~isempty(j1_series)
    26732686        state_j='on';
    2674         if index==1
     2687        if input_line==1
    26752688            if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first value
    26762689                scan_option='j'; %scan j indext
     
    27072720if ~isempty(i2_series)||~isempty(j2_series)
    27082721    set(handles.CheckFixPair,'Visible','on')
    2709 elseif index==1
     2722elseif input_line==1
    27102723    set(handles.CheckFixPair,'Visible','off')
    27112724end
     
    27132726%% apply the effect of the transform fct and view the field
    27142727transform=get(handles.TransformPath,'UserData');
    2715 if index==2 && (~isa(transform,'function_handle')||nargin(transform)<3)
     2728if input_line==2 && (~isa(transform,'function_handle')||nargin(transform)<3)
    27162729    set(handles.TransformName,'value',2); % set transform to sub_field if the current fct doe not accept two input fields
    27172730end
     
    29082921    end
    29092922    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]);
    29172927        if strcmp(NomType,'_1')
    29182928            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
    29212952    end
    29222953    % Mask.Path=MaskPath;
     
    29612992%------------------------------------------------------------------------
    29622993errormsg=[];%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
     2994MaskName='';
     2995
     2996%% get the current mask name recorded in CheckMask/UserData, possibly indexed with file index
     2997MaskInfo=get(handles.CheckMask,'UserData');
     2998if 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'];
    29903006    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
    30343020        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
     3072end
    30433073%------------------------------------------------------------------------
    30443074%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.