Changeset 565 for trunk/src


Ignore:
Timestamp:
Jan 30, 2013, 10:15:30 PM (12 years ago)
Author:
sommeria
Message:

small bugs corrected

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r544 r565  
    13671367%------------------------------------------------------------------------
    13681368Heading=[];%default
    1369 [s,errormsg]=imadoc2struct(fileinput,'GeometryCalib');
     1369[s,errormsg]=imadoc2struct(fileinput,'Heading','GeometryCalib');
    13701370if ~isempty(errormsg)
    13711371    msgbox_uvmat('ERROR',errormsg)
     
    14051405        set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4))
    14061406    end
    1407     calib=reshape(GeometryCalib.PointCoord,[],1);
     1407    calib=reshape(GeometryCalib.SourceCalib.PointCoord,[],1);
    14081408    for ilist=1:numel(calib)
    14091409        CoordCell{ilist}=num2str(calib(ilist));
  • trunk/src/imadoc2struct.m

    r561 r565  
    1717function [s,errormsg]=imadoc2struct(ImaDoc,varargin)
    1818%% default input and output
    19 errormsg=[];%default
    20 s.Heading=[];%default
    21 s.Time=[]; %default
    22 s.TimeUnit=[]; %default
    23 s.GeometryCalib=[];
     19errormsg='';%default
     20s=[];
     21% s.Heading=[];%default
     22% s.Time=[]; %default
     23% s.TimeUnit=[]; %default
     24% s.GeometryCalib=[];
    2425% tsai=[];%default
    2526
     
    3334
    3435%% case of xml files
    35 if nargin >1
    36     [s,Heading]=xml2struct(ImaDoc,varargin);% convert the xml file in a structure s, keeping only the subtree defined in input
    37 else
     36if nargin ==1
    3837    [s,Heading]=xml2struct(ImaDoc);% convert the whole xml file in a structure s
     38elseif nargin ==2
     39    [s,Heading]=xml2struct(ImaDoc,varargin{1});% convert the xml file in a structure s, keeping only the subtree defined in input
     40else %TODO: deal with more than two subtrees?
     41    [s,Heading]=xml2struct(ImaDoc,varargin{1},varargin{2});% convert the xml file in a structure s, keeping only the subtree defined in input
    3942end
    4043if ~strcmp(Heading,'ImaDoc')
     
    4346end
    4447%% reading timing
    45 Timing=s.Camera.BurstTiming;
    46 if ~iscell(Timing)
    47     Timing={Timing};
    48 end
    49 s.Time=[];
    50 for k=1:length(Timing)
    51     Frequency=1;
    52     if isfield(Timing{k},'Frequency')
    53         Frequency=Timing{k}.FrameFrequency;
     48if isfield(s,'Camera')
     49    Timing=s.Camera.BurstTiming;
     50    if ~iscell(Timing)
     51        Timing={Timing};
    5452    end
    55     Dtj=[];
    56     if isfield(Timing{k},'Dtj')
    57         Dtj=Timing{k}.Dtj/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's');
     53    s.Time=[];
     54    for k=1:length(Timing)
     55        Frequency=1;
     56        if isfield(Timing{k},'Frequency')
     57            Frequency=Timing{k}.FrameFrequency;
     58        end
     59        Dtj=[];
     60        if isfield(Timing{k},'Dtj')
     61            Dtj=Timing{k}.Dtj/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's');
     62        end
     63        NbDtj=1;
     64        if isfield(Timing{k},'NbDtj')&&~isempty(Timing{k}.NbDtj)
     65            NbDtj=Timing{k}.NbDtj;
     66        end
     67        Dti=[];
     68        if isfield(Timing{k},'Dti')
     69            Dti=Timing{k}.Dti/Frequency;%Dti converted from frame unit to TimeUnit (e.g. 's');
     70        end
     71        NbDti=1;
     72        if isfield(Timing{k},'NbDti')&&~isempty(Timing{k}.NbDti)
     73            NbDti=Timing{k}.NbDti;
     74        end
     75        Time_val=Timing{k}.Time;%time in TimeUnit
     76        if ~isempty(Dti)
     77            Dti=reshape(Dti'*ones(1,NbDti),NbDti*numel(Dti),1); %concatene Dti vector NbDti times
     78            Time_val=[Time_val;Time_val(end)+cumsum(Dti)];%append the times defined by the intervals  Dti
     79        end
     80        if ~isempty(Dtj)
     81            Dtj=reshape(Dtj'*ones(1,NbDtj),1,NbDtj*numel(Dtj)); %concatene Dtj vector NbDtj times
     82            Dtj=[0 Dtj];
     83            Time_val=Time_val*ones(1,numel(Dtj))+ones(numel(Time_val),1)*cumsum(Dtj);% produce a time matrix with Dtj
     84        end
     85        % reading Dtk
     86        Dtk=[];%default
     87        NbDtk=1;%default
     88        if isfield(Timing,'Dtk')
     89            Dtk=Timing{k}.Dtk;
     90        end
     91        if isfield(Timing,'NbDtk')&&~isempty(Timing{k}.NbDtk)
     92            NbDtk=Timing{k}.NbDtk;
     93        end
     94        if isempty(Dtk)
     95            s.Time=[s.Time;Time_val];
     96        else
     97            for kblock=1:NbDtk+1
     98                Time_val_k=Time_val+(kblock-1)*Dtk;
     99                s.Time=[s.Time;Time_val_k];
     100            end
     101        end
    58102    end
    59     NbDtj=1;
    60     if isfield(Timing{k},'NbDtj')&&~isempty(Timing{k}.NbDtj)
    61         NbDtj=Timing{k}.NbDtj;
    62     end
    63     Dti=[];
    64     if isfield(Timing{k},'Dti')
    65         Dti=Timing{k}.Dti/Frequency;%Dti converted from frame unit to TimeUnit (e.g. 's');
    66     end
    67     NbDti=1;
    68     if isfield(Timing{k},'NbDti')&&~isempty(Timing{k}.NbDti)
    69         NbDti=Timing{k}.NbDti;
    70     end
    71     Time_val=Timing{k}.Time;%time in TimeUnit
    72     if ~isempty(Dti)
    73         Dti=reshape(Dti'*ones(1,NbDti),NbDti*numel(Dti),1); %concatene Dti vector NbDti times
    74         Time_val=[Time_val;Time_val(end)+cumsum(Dti)];%append the times defined by the intervals  Dti
    75     end
    76     if ~isempty(Dtj)
    77         Dtj=reshape(Dtj'*ones(1,NbDtj),1,NbDtj*numel(Dtj)); %concatene Dtj vector NbDtj times
    78         Dtj=[0 Dtj];
    79         Time_val=Time_val*ones(1,numel(Dtj))+ones(numel(Time_val),1)*cumsum(Dtj);% produce a time matrix with Dtj
    80     end
    81     % reading Dtk
    82     Dtk=[];%default
    83     NbDtk=1;%default
    84     if isfield(Timing,'Dtk')
    85         Dtk=Timing{k}.Dtk;
    86     end
    87     if isfield(Timing,'NbDtk')&&~isempty(Timing{k}.NbDtk)
    88         NbDtk=Timing{k}.NbDtk;
    89     end
    90     if isempty(Dtk)
    91         s.Time=[s.Time;Time_val];
    92     else
    93         for kblock=1:NbDtk+1
    94             Time_val_k=Time_val+(kblock-1)*Dtk;
    95             s.Time=[s.Time;Time_val_k];
    96         end
    97     end
    98 end
    99            
     103end
    100104
    101105% try
  • trunk/src/series/aver_stat.m

    r526 r565  
    303303        end
    304304    else  % time from ImaDoc prevails if it exists
    305         j1=1;%default
    306         if ~isempty(j1_series{1})
    307             j1=j1_series{1};
    308         end
    309         DataOut.Time=time(1,i1_series{1}(1),j1filexml);
    310         DataOut.Time_end=time(end,i1_series{end}(end),j1_series{end}(end));
     305%         j1=1;%default
     306%         if ~isempty(j1_series{1})
     307%             j1=j1_series{1};
     308%         end
     309        %DataOut.Time=time(1,i1_series{1}(1),j1);
     310        %DataOut.Time_end=time(end,i1_series{end}(end),j1_series{end}(end));
     311        DataOut.Time=time(1);
     312        DataOut.Time_end=time(end);
    311313    end
    312314   
  • trunk/src/struct2xml.m

    r493 r565  
    3131          if isstruct(fieldnames_sub{ilist_sub})
    3232                t=struct2xml(fieldnames_sub{ilist_sub},t,uid);
    33                 save(t)
     33%                 save(t)
    3434          else
    35               eval(['val_sub=val.' fieldnames_sub{ilist_sub} ';'])
     35              val_sub=val.(fieldnames_sub{ilist_sub});
    3636              t=add_element(t,uid,fieldnames_sub{ilist_sub},val_sub);
    3737          end
  • trunk/src/xml2struct.m

    r560 r565  
    1212function [s,Heading]=xml2struct(filename,varargin)
    1313t=xmltree(filename);
    14 Heading=get(t,1,'name');
     14iline=0;
     15Heading='';
     16while isempty(Heading)
     17    iline=iline+1;
     18    if strcmp(get(t,iline,'type'),'element')
     19        Heading=get(t,iline,'name');
     20    end
     21end
    1522if nargin>1
    1623    for isub=1:nargin-1
    1724        uid_sub=find(t,['/' Heading '/' varargin{isub}]);
     25        if isempty(uid_sub)
     26            s.(varargin{isub})=[];
     27        else
    1828        tsub=branch(t,uid_sub);
    1929        ss=convert(tsub);
    2030        s.(varargin{isub})=convert_string(ss);
     31        end
    2132    end
    2233else
Note: See TracChangeset for help on using the changeset viewer.