Ignore:
Timestamp:
Nov 6, 2025, 7:03:02 PM (4 weeks ago)
Author:
sommeria
Message:

bed-scan updated and many updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/imadoc2struct.m

    r1183 r1184  
    3434
    3535function [s,errormsg]=imadoc2struct(ImaDoc,varargin)
    36 %% default input and output
    37 errormsg='';%default
    38 s=[];
     36
     37s=[]; %default output
    3938
    4039%% opening the xml file
    41 [tild,tild,FileExt]=fileparts(ImaDoc);
    42 
    4340if nargin ==1% no additional input variable beyond 'ImaDoc'
    4441    [s,Heading,errormsg]=xml2struct(ImaDoc);% convert the whole xml file in a structure s
     
    5653    return
    5754end
     55
    5856%% reading timing
    5957if isfield(s,'Camera')
     
    6765end
    6866
    69 
    70 function [s,errormsg]=read_subtree(subt,Data,NbOccur,NumTest)
    71 %--------------------------------------------------
    72 s=[];%default
    73 errormsg='';
    74 head_element=get(subt,1,'name');
    75     cont=get(subt,1,'contents');
    76     if ~isempty(cont)
    77         for ilist=1:length(Data)
    78             uid_key=find(subt,[head_element '/' Data{ilist}]);
    79             if ~isequal(length(uid_key),NbOccur(ilist))
    80                 errormsg=['wrong number of occurence for ' Data{ilist}];
    81                 return
    82             end
    83             for ival=1:length(uid_key)
    84                 val=get(subt,children(subt,uid_key(ival)),'value');
    85                 if ~NumTest(ilist)
    86                     eval(['s.' Data{ilist} '=val;']);
    87                 else
    88                     eval(['s.' Data{ilist} '=str2double(val);'])
    89                 end
    90             end
    91         end
    92     end
    93 
    94 
    95 %--------------------------------------------------
    96 %  read an xml element
    97 function val=get_value(t,label,default)
    98 %--------------------------------------------------
    99 val=default;
    100 uid=find(t,label);%find the element iud(s)
    101 if ~isempty(uid) %if the element named label exists
    102    uid_child=children(t,uid);%find the children
    103    if ~isempty(uid_child)
    104        data=get(t,uid_child,'type');%get the type of child
    105        if iscell(data)% case of multiple element
    106            for icell=1:numel(data)
    107                val_read=str2num(get(t,uid_child(icell),'value'));
    108                if ~isempty(val_read)
    109                    val(icell,:)=val_read;
    110                end
    111            end
    112 %           val=val';
    113        else % case of unique element value
    114            val_read=str2num(get(t,uid_child,'value'));
    115            if ~isempty(val_read)
    116                val=val_read;
    117            else
    118               val=get(t,uid_child,'value');%char string data
    119            end
    120        end
    121    end
    122 end
    123 
    124 %------------------------------------------------------------------------
    125 %'read_imatext': reads the .civ file for image documentation (obsolete)
    126 % fileinput: name of the documentation file
    127 % time: matrix of times for the set of images
    128 %pxcmx: scale along x in pixels/cm
    129 %pxcmy: scale along y in pixels/cm
    130 function [error,time,TimeUnit,mode,npx,npy,GeometryCalib]=read_imatext(fileinput)
    131 %------------------------------------------------------------------------
    132 error='';%default
    133 time=[]; %default
    134 TimeUnit='s';
    135 mode='pairs';
    136 npx=[]; %default
    137 npy=[]; %default
    138 GeometryCalib=[];
    139 if ~exist(fileinput,'file'), error=['image doc file ' fileinput ' does not exist']; return;end;%input file does not exist
    140 dotciv=textread(fileinput);
    141 sizdot=size(dotciv);
    142 if ~isequal(sizdot(1)-8,dotciv(1,1));
    143     error=1; %inconsistent number of bursts
    144 end
    145 nbfield=sizdot(1)-8;
    146 npx=(dotciv(2,1));
    147 npy=(dotciv(2,2));
    148 pxcmx=(dotciv(6,1));% pixels/cm in the .civ file
    149 pxcmy=(dotciv(6,2));
    150 % nburst=dotciv(3,1); % nbre of bursts
    151 abs_time1=dotciv([9:nbfield+8],2);
    152 dtime=dotciv(5,1)*(dotciv([9:nbfield+8],[3:end-1])+1);
    153 timeshift=[abs_time1 dtime];
    154 time=cumsum(timeshift,2);
    155 GeometryCalib.CalibrationType='rescale';
    156 GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
    157 GeometryCalib.Tx=0;
    158 GeometryCalib.Ty=0;
    159 GeometryCalib.Tz=1;
    160 GeometryCalib.dpx=1;
    161 GeometryCalib.dpy=1;
    162 GeometryCalib.sx=1;
    163 GeometryCalib.Cx=0;
    164 GeometryCalib.Cy=0;
    165 GeometryCalib.f=1;
    166 GeometryCalib.kappa1=0;
    167 GeometryCalib.CoordUnit='cm';
Note: See TracChangeset for help on using the changeset viewer.