Changeset 1184 for trunk/src/imadoc2struct.m
- Timestamp:
- Nov 6, 2025, 7:03:02 PM (4 weeks ago)
- File:
-
- 1 edited
-
trunk/src/imadoc2struct.m (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/imadoc2struct.m
r1183 r1184 34 34 35 35 function [s,errormsg]=imadoc2struct(ImaDoc,varargin) 36 %% default input and output 37 errormsg='';%default 38 s=[]; 36 37 s=[]; %default output 39 38 40 39 %% opening the xml file 41 [tild,tild,FileExt]=fileparts(ImaDoc);42 43 40 if nargin ==1% no additional input variable beyond 'ImaDoc' 44 41 [s,Heading,errormsg]=xml2struct(ImaDoc);% convert the whole xml file in a structure s … … 56 53 return 57 54 end 55 58 56 %% reading timing 59 57 if isfield(s,'Camera') … … 67 65 end 68 66 69 70 function [s,errormsg]=read_subtree(subt,Data,NbOccur,NumTest)71 %--------------------------------------------------72 s=[];%default73 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 return82 end83 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 else88 eval(['s.' Data{ilist} '=str2double(val);'])89 end90 end91 end92 end93 94 95 %--------------------------------------------------96 % read an xml element97 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 exists102 uid_child=children(t,uid);%find the children103 if ~isempty(uid_child)104 data=get(t,uid_child,'type');%get the type of child105 if iscell(data)% case of multiple element106 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 end111 end112 % val=val';113 else % case of unique element value114 val_read=str2num(get(t,uid_child,'value'));115 if ~isempty(val_read)116 val=val_read;117 else118 val=get(t,uid_child,'value');%char string data119 end120 end121 end122 end123 124 %------------------------------------------------------------------------125 %'read_imatext': reads the .civ file for image documentation (obsolete)126 % fileinput: name of the documentation file127 % time: matrix of times for the set of images128 %pxcmx: scale along x in pixels/cm129 %pxcmy: scale along y in pixels/cm130 function [error,time,TimeUnit,mode,npx,npy,GeometryCalib]=read_imatext(fileinput)131 %------------------------------------------------------------------------132 error='';%default133 time=[]; %default134 TimeUnit='s';135 mode='pairs';136 npx=[]; %default137 npy=[]; %default138 GeometryCalib=[];139 if ~exist(fileinput,'file'), error=['image doc file ' fileinput ' does not exist']; return;end;%input file does not exist140 dotciv=textread(fileinput);141 sizdot=size(dotciv);142 if ~isequal(sizdot(1)-8,dotciv(1,1));143 error=1; %inconsistent number of bursts144 end145 nbfield=sizdot(1)-8;146 npx=(dotciv(2,1));147 npy=(dotciv(2,2));148 pxcmx=(dotciv(6,1));% pixels/cm in the .civ file149 pxcmy=(dotciv(6,2));150 % nburst=dotciv(3,1); % nbre of bursts151 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.
