Changeset 450 for trunk/src/read_field.m


Ignore:
Timestamp:
Jun 12, 2012, 12:27:42 AM (12 years ago)
Author:
sommeria
Message:

various bugs repaired

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/read_field.m

    r445 r450  
    22%'read_field': read input fields in different formats
    33%--------------------------------------------------------------------------
    4 %  function [Field,ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn)
     4%  function [Field,ParamOut,errormsg] = read_field(FileName,FileType,ParamIn,num)
    55%
    66% OUTPUT:
     
    2323%     = video: movie read with VideoReader (recent versions of Matlab)
    2424%     = vol: images representing scanned volume (images concatened in the y direction)
    25 % ParamIn: Matlab structure of input parameters
     25% ParamIn: movie object or Matlab structure of input parameters
    2626%     .FieldName: name (char string) of the input field (for Civx data)
    2727%     .VelType: char string giving the type of velocity data ('civ1', 'filter1', 'civ2'...)
    2828%     .ColorVar: variable used for vector color
    2929%     .Npx, .Npy: nbre of pixels along x and y (used for .vol input files)
    30 function [Field,ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num)
     30function [Field,ParamOut,errormsg] = read_field(FileName,FileType,ParamIn,num)
    3131Field=[];
    3232if ~exist('num','var')
     
    5757                field_index=strcmp(ParamIn.FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data
    5858                if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist
    59                     Data=nc2struct(ObjectName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ','CivStage');
     59                    Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ','CivStage');
    6060                    % case of new civdata conventions
    6161                    if isequal(Data.Conventions,'uvmat/civdata')
     
    6363                        ParamOut.ColorVar='ima_cor';
    6464                        InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    65                         [Field,ParamOut.VelType,errormsg]=read_civdata(ObjectName,InputField,ParamIn.VelType,Data.CivStage);
     65                        [Field,ParamOut.VelType,errormsg]=read_civdata(FileName,InputField,ParamIn.VelType,Data.CivStage);
    6666                        CivStage=Field.CivStage;
    6767                        ParamOut.CivStage=Field.CivStage;
     
    7171                        ParamOut.ColorVar='ima_cor';
    7272                        InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    73                         [Field,ParamOut.VelType]=read_civxdata(ObjectName,InputField,ParamIn.VelType);
     73                        [Field,ParamOut.VelType]=read_civxdata(FileName,InputField,ParamIn.VelType);
    7474                        CivStage=Field.CivStage;
    7575                        ParamOut.CivStage=Field.CivStage;
     
    8888                        InputField=[InputField {ParamOut.ColorVar}];
    8989                    end
    90                     [Field,ParamOut.VelType,errormsg]=read_civxdata(ObjectName,InputField,ParamIn.VelType);
     90                    [Field,ParamOut.VelType,errormsg]=read_civxdata(FileName,InputField,ParamIn.VelType);
    9191                    if ~isempty(errormsg)
    9292                        return
     
    100100                hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI
    101101                if isempty(hget_field)% open the GUI get_field if it is not found
    102                     hget_field= get_field(ObjectName);%open the get_field GUI
     102                    hget_field= get_field(FileName);%open the get_field GUI
    103103                    set(hget_field,'Name',GUIName)%update the name of get_field (e.g. get_field_1)
    104104                end
    105105                hhget_field=guidata(hget_field);
    106106                %% update  the get_field GUI
    107                 set(hhget_field.inputfile,'String',ObjectName)
     107                set(hhget_field.inputfile,'String',FileName)
    108108                set(hhget_field.list_fig,'Value',1)
    109109                if exist('num','var')&&~isnan(num)
     
    116116                Tabchar={''};%default
    117117                Tabcell=[];
    118                 set(hhget_field.inputfile,'String',ObjectName)
     118                set(hhget_field.inputfile,'String',FileName)
    119119                if isfield(Field,'ListGlobalAttribute')&& ~isempty(Field.ListGlobalAttribute)
    120120                    for iline=1:length(Field.ListGlobalAttribute)
     
    145145            end
    146146        case {'video','mmreader'}
    147             A=read(ObjectName,num);
     147            A=read(ParamIn,num);
    148148        case 'vol'
    149             A=imread(ObjectName);
     149            A=imread(FileName);
    150150            Npz=size(A,1)/ParamIn.Npy;
    151151            A=reshape(A',ParamIn.Npx,ParamIn.Npy,Npz);
     
    153153        case 'multimage'
    154154            warning 'off'
    155             A=imread(ObjectName,num);
     155            A=imread(FileName,num);
    156156        case 'image'
    157             A=imread(ObjectName);
     157            A=imread(FileName);
    158158    end
    159159catch ME
Note: See TracChangeset for help on using the changeset viewer.