Changeset 1040 for trunk/src/uvmat.m


Ignore:
Timestamp:
May 4, 2018, 10:57:13 PM (6 years ago)
Author:
sommeria
Message:

get_field improved to select variables, uvmat rationalized with respect to input file types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r1033 r1040  
    31673167%% read the second field
    31683168if isempty(UvData.MovieObject)
    3169     [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},[],num_frame);
    3170 else
    3171     [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{1},UvData.MovieObject{1},num_frame);
     3169    [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileInfo{index}.FileType,[],num_frame);
     3170else
     3171    [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileInfo{1}.FileType,UvData.MovieObject{1},num_frame);
    31723172end
    31733173if ~isempty(errormsg)
     
    33043304%% test for need of tps
    33053305check_proj_tps=0;
    3306 if  (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))
     3306if  (strcmp(UvData.FileInfo{1}.FileType,'civdata')||strcmp(UvData.FileInfo{1}.FileType,'civx'))
    33073307    for iobj=1:numel(UvData.ProjObject)
    33083308        if isfield(UvData.ProjObject{iobj},'ProjMode')&& strcmp(UvData.ProjObject{iobj}.ProjMode,'interp_tps')
     
    33183318FieldName='';%default
    33193319VelType='';%default
    3320 switch UvData.FileType{1}
     3320if strcmp(UvData.FileInfo{1}.FieldType,'image')
     3321    FieldName='image';
     3322    frame_index=1;%default
     3323    if UvData.FileInfo{1}.NumberOfFrames>1
     3324        if strcmp(NomType,'*')
     3325            if num_i1>UvData.FileInfo{1}.NumberOfFrames
     3326                errormsg='specified frame index exceeds file content';
     3327                return
     3328            else
     3329                frame_index=num_i1;%frame index from a single movies or multimage
     3330            end
     3331        else
     3332            if num_j1>UvData.FileInfo{1}.NumberOfFrames
     3333                errormsg='specified frame index exceeds file content';
     3334                return
     3335            else
     3336                frame_index=num_j1;% frame index from a set of indexed movies
     3337            end
     3338        end
     3339    end
     3340    if isfield(UvData,'MovieObject')
     3341        ParamIn=UvData.MovieObject{1};
     3342    end
     3343end
     3344switch UvData.FileInfo{1}.FileType
    33213345    case {'civx','civdata','netcdf','pivdata_fluidimage'};
    33223346        list_fields=get(handles.FieldName,'String');% list menu fields
     
    33383362            end
    33393363        end
    3340     case {'video','mmreader','rdvision','cine_phantom'}
    3341         FieldName='image';
    3342         ParamIn=UvData.MovieObject{1}; % movie object
    3343         if strcmp(NomType,'*')
    3344             frame_index=num_i1;%frame index from a single movies or multimage
    3345         else
    3346             frame_index=num_j1;% frame index from a set of indexed movies
    3347         end
    3348         if isempty(frame_index)
    3349             frame_index=1;
    3350         end
    3351     case 'multimage'
    3352         FieldName='image';
    3353         if ~strcmp(NomType,'*')
    3354             MaxIndex_j_cell=get(handles.MaxIndex_j,'String');
    3355             if num_j1>str2num(MaxIndex_j_cell{1})
    3356                 errormsg='specified frame index exceeds file content';
    3357                 return
    3358             else
    3359             frame_index=num_j1;%frame index for movies or multimage
    3360             end
    3361         else
    3362             MaxIndex_i_cell=get(handles.MaxIndex_i,'String');
    3363             if num_i1>str2num(MaxIndex_i_cell{1})
    3364                 errormsg='specified frame index exceeds file content';
    3365                 return
    3366             else
    3367             frame_index=num_i1;
    3368             end
    3369         end
    33703364    case 'vol' %TODO: update
    33713365        if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')
     
    33763370            return
    33773371        end
    3378     case {'image','image_DaVis'}
    3379         FieldName='image'; 
    3380         frame_index=num_j1;%frame index for image pairs
    33813372end
    33823373if isstruct (ParamIn)
     
    33993390end
    34003391
    3401 [Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index);
     3392[Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileInfo{1}.FileType,ParamIn,frame_index);
    34023393if ~isempty(errormsg)
    34033394    errormsg=['uvmat / refresh_field / read_field( ' FileName ') / ' errormsg];
     
    34113402
    34123403%% choose and read a second field FileName_1 if defined
    3413 VelType_1=[];%default
    3414 FieldName_1=[];
    3415 ParamIn_1=[];
    34163404ParamOut_1=[];
    3417 frame_index_1=1;
    3418 if ~isempty(FileName_1)
    3419     if ~exist(FileName_1,'file')
    3420         errormsg=['second file ' FileName_1 ' does not exist'];
    3421         return
    3422     end
    3423     switch UvData.FileType{2}
    3424         case {'civx','civdata','netcdf'};
     3405if numel(UvData.FileInfo)>1
     3406    VelType_1=[];%default
     3407    FieldName_1=[];
     3408    ParamIn_1=[];
     3409 
     3410    frame_index_1=1;
     3411    if ~isempty(FileName_1)
     3412        if ~exist(FileName_1,'file')
     3413            errormsg=['second file ' FileName_1 ' does not exist'];
     3414            return
     3415        end
     3416    end
     3417    if isequal(get(handles.NomType_1,'Visible'),'on')
     3418        NomType_1=get(handles.NomType_1,'String');
     3419    else
     3420        NomType_1=get(handles.NomType,'String');
     3421    end
     3422    if strcmp(UvData.FileInfo{2}.FieldType,'image')
     3423        FieldName_1='image';
     3424        frame_index_1=1;%default
     3425        if UvData.FileInfo{2}.NumberOfFrames>1
     3426            if strcmp(NomType_1,'*')
     3427                if num_i1>UvData.FileInfo{2}.NumberOfFrames
     3428                    errormsg='specified frame index exceeds file content';
     3429                    return
     3430                else
     3431                    frame_index_1=num_i1;%frame index from a single movies or multimage
     3432                end
     3433            else
     3434                if num_j1>UvData.FileInfo{2}.NumberOfFrames
     3435                    errormsg='specified frame index exceeds file content';
     3436                    return
     3437                else
     3438                    frame_index_1=num_j1;% frame index from a set of indexed movies
     3439                end
     3440            end
     3441        end
     3442        if isfield(UvData,'MovieObject')
     3443            ParamIn_1=UvData.MovieObject{2};
     3444        end
     3445    end
     3446    switch UvData.FileInfo{2}.FileType
     3447        case {'civx','civdata','netcdf','pivdata_fluidimage'};
    34253448            list_fields=get(handles.FieldName_1,'String');% list menu fields
    3426             if ischar(list_fields),list_fields={list_fields};end
    34273449            FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field
    34283450            if ~strcmp(FieldName_1,'get_field...')
    34293451                if get(handles.FixVelType,'Value')
    34303452                    VelTypeList=get(handles.VelType_1,'String');
    3431                     VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type.
     3453                    VelType_1=VelTypeList{get(handles.VelType_1,'Value')};
    34323454                end
    34333455            end
    3434             if isempty(FieldName_1)
    3435                 FieldName_1=FieldName;% if blank reproduce the field name of the first field
    3436             end
    3437             if ~isempty(regexp(FieldName_1,'^vel', 'once'))&& strcmp(get(handles.ColorCode,'Visible'),'on')
     3456            % case of input vector field, get the scalar used for vector color
     3457            if ~isempty(regexp(FieldName_1,'^vec('))
    34383458                list_code=get(handles.ColorCode,'String');% list menu fields
    34393459                index_code=get(handles.ColorCode,'Value');% selected string index
     
    34413461                    list_code=get(handles.ColorScalar,'String');% list menu fields
    34423462                    index_code=get(handles.ColorScalar,'Value');% selected string index
    3443                     ParamIn_1.ColorVar= list_code{index_code}; % selected field for vector color display
     3463                    ParamIn_1.ColorVar= list_code{index_code}; % selected field
    34443464                end
    3445             end
    3446         case {'video','mmreader','cine_phantom'}
    3447             ParamIn_1=UvData.MovieObject{2};
    3448             if ~strcmp(NomType_1,'*')
    3449                 frame_index_1=j1_1;%frame index for movies or multimage
    3450             else
    3451                 frame_index_1=i1_1;
    3452             end
    3453          case 'multimage'
    3454             if strcmp(NomType_1,'*')%frame index for movies or multimage
    3455                 frame_index_1=i1_1;
    3456             else
    3457                 frame_index_1=j1_1;
    34583465            end
    34593466        case 'vol' %TODO: update
     
    34663473            end
    34673474    end
    3468     if isequal(get(handles.NomType_1,'Visible'),'on')
    3469         NomType_1=get(handles.NomType_1,'String');
    3470     else
    3471         NomType_1=get(handles.NomType,'String');
    3472     end
     3475    %     switch UvData.FileType{2}
     3476    %         case {'civx','civdata','netcdf'};
     3477    %             list_fields=get(handles.FieldName_1,'String');% list menu fields
     3478    %             if ischar(list_fields),list_fields={list_fields};end
     3479    %             FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field
     3480    %             if ~strcmp(FieldName_1,'get_field...')
     3481    %                 if get(handles.FixVelType,'Value')
     3482    %                     VelTypeList=get(handles.VelType_1,'String');
     3483    %                     VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type.
     3484    %                 end
     3485    %             end
     3486    %             if isempty(FieldName_1)
     3487    %                 FieldName_1=FieldName;% if blank reproduce the field name of the first field
     3488    %             end
     3489    %             if ~isempty(regexp(FieldName_1,'^vel', 'once'))&& strcmp(get(handles.ColorCode,'Visible'),'on')
     3490    %                 list_code=get(handles.ColorCode,'String');% list menu fields
     3491    %                 index_code=get(handles.ColorCode,'Value');% selected string index
     3492    %                 if  ~strcmp(list_code{index_code},'black') &&  ~strcmp(list_code{index_code},'white')
     3493    %                     list_code=get(handles.ColorScalar,'String');% list menu fields
     3494    %                     index_code=get(handles.ColorScalar,'Value');% selected string index
     3495    %                     ParamIn_1.ColorVar= list_code{index_code}; % selected field for vector color display
     3496    %                 end
     3497    %             end
     3498    %         case {'video','mmreader','cine_phantom'}
     3499    %             ParamIn_1=UvData.MovieObject{2};
     3500    %             if ~strcmp(NomType_1,'*')
     3501    %                 frame_index_1=j1_1;%frame index for movies or multimage
     3502    %             else
     3503    %                 frame_index_1=i1_1;
     3504    %             end
     3505    %          case 'multimage'
     3506    %             if strcmp(NomType_1,'*')%frame index for movies or multimage
     3507    %                 frame_index_1=i1_1;
     3508    %             else
     3509    %                 frame_index_1=j1_1;
     3510    %             end
     3511    %         case 'vol' %TODO: update
     3512    %             if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')
     3513    %                 ParamIn_1.Npy=UvData.XmlData.Npy;
     3514    %                 ParamIn_1.Npx=UvData.XmlData.Npx;
     3515    %             else
     3516    %                 errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
     3517    %                 return
     3518    %             end
     3519    %     end
     3520   
    34733521    test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
    3474 %     if ~isequal(NomType_1,'*')&& isfield(UvData,'FileName_1')
    3475 %            test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ;
    3476 %     end
    34773522    if test_keepdata_1
    34783523        Field{2}=UvData.Field_1;% keep the stored field
     
    34803525    else
    34813526        if isempty(ParamIn_1) || isstruct(ParamIn_1)
    3482         ParamIn_1.FieldName=FieldName_1;
    3483         ParamIn_1.VelType=VelType_1;
    3484         ParamIn_1.Coord_x=get(handles.Coord_x,'String');
    3485         ParamIn_1.Coord_y=get(handles.Coord_y,'String');
     3527            ParamIn_1.FieldName=FieldName_1;
     3528            ParamIn_1.VelType=VelType_1;
     3529            ParamIn_1.Coord_x=get(handles.Coord_x,'String');
     3530            ParamIn_1.Coord_y=get(handles.Coord_y,'String');
    34863531        end
    34873532        [Field{2},ParamOut_1,errormsg] = read_field(FileName_1,UvData.FileType{2},ParamIn_1,frame_index_1);
     
    35103555%% update the display menu for the first velocity type (first menuline)
    35113556test_veltype=0;
    3512 if (strcmp(UvData.FileType{1},'civx')||strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'pivdata_fluidimage'))...
     3557if (strcmp(UvData.FileInfo{1}.FileType,'civx')||strcmp(UvData.FileInfo{1}.FileType,'civdata')||strcmp(UvData.FileInfo{1}.FileType,'pivdata_fluidimage'))...
    35133558        && ~strcmp(FieldName,'get_field...')
    35143559    test_veltype=1;
     
    35163561    set(handles.VelType_1,'Visible','on')
    35173562    set(handles.FixVelType,'Visible','on')
    3518     menu=set_veltype_display(ParamOut.CivStage,UvData.FileType{1});
     3563    menu=set_veltype_display(ParamOut.CivStage,UvData.FileInfo{1}.FileType);
    35193564    index_menu=strcmp(ParamOut.VelType,menu);%look for VelType in  the menu
    35203565    index_val=find(index_menu,1);
     
    35363581if isempty(FileName_1)
    35373582elseif ~test_keepdata_1
    3538     if (strcmp(UvData.FileType{2},'civx')||strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{1},'pivdata_fluidimage'))...
     3583    if (strcmp(UvData.FileType{2},'civx')||strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileInfo{1}.FileType,'pivdata_fluidimage'))...
    35393584            && ~strcmp(FieldName_1,'get_field...')
    35403585        test_veltype_1=1;
     
    45144559            set(handles.ColorScalar,'Value',1)
    45154560            set(handles.ColorScalar,'String',VecColorList);
    4516             UvData.FileType{1}='netcdf';
     4561            UvData.FileInfo{1}.FileType='netcdf';
    45174562            set(handles.uvmat,'UserData',UvData)
    45184563            REFRESH_Callback(hObject, eventdata, handles)
     
    47114756            set(handles.FileExt_1,'String',get(handles.FileExt,'String'))
    47124757
    4713             UvData.FileType{2}=UvData.FileType{1};
     4758            UvData.FileType{2}=UvData.FileInfo{1}.FileType;
    47144759            UvData.XmlData{2}= UvData.XmlData{1};
    47154760            transform=get(handles.TransformPath,'UserData');
     
    48124857else% we introduce the same file (with a different field) for the second series
    48134858     FileName_1=FileName;% we compare two fields in the same file
    4814      UvData.FileType{2}=UvData.FileType{1};
     4859     UvData.FileType{2}=UvData.FileInfo{1}.FileType;
    48154860     UvData.XmlData{2}= UvData.XmlData{1};
    48164861     set(handles.SubField,'Value',1)
Note: See TracChangeset for help on using the changeset viewer.