Commit d38502a0 authored by Antonio Politi's avatar Antonio Politi
Browse files

writing of annotation

* fix of wrinting
* tool for writing
parent 69ee337c
This diff is collapsed.
function writeAnnotationResfile2xml(resfile, FAsession)
if nargin < 1
[resfile, pathname] = uigetfile({'*.res'; '*.*'},'Select res file', '');
if ~resfile
return
end
resfile = fullfile(pathname, resfile);
end
[pathname, resbase, ext] = fileparts(resfile);
[tmp, dirname] = fileparts(pathname);
if nargin < 2
FAsession = resbase;
FAsession = '2c'
end
restable = readtable(resfile, 'Delimiter', '\t', 'Header', 1, 'FileType', 'text', 'TreatAsEmpty',{'NA'});
xmlFAfiles = strrep(restable.FullPath, ['.zen'], ['.zen.' FAsession '.xml']);
for iD = 1:length(xmlFAfiles)
fprintf('%s Writing annotation of file %d/%d\n', resfile, iD, length(xmlFAfiles))
if ~exist(xmlFAfiles{iD})
% search locally
[m, iend] = regexp(xmlFAfiles{iD}, dirname, 'match', 'end');
xmlfile = fullfile(pathname, xmlFAfiles{iD}(iend+1:end));
else
xmlfile = xmlFAfiles{iD};
end
if ~exist(xmlfile)
error('Coul not find file');
end
node = xmlFA.readnode(xmlfile);
% [path1, fout, ext] = fileparts(xmlfile);
% [path, fout, ext] = fileparts(fout);
%
% fname_out = fullfile(path1, sprintf('%s.test.xml', fout));
if iscell(restable.Annotation)
ann = restable.Annotation{iD};
else
ann = restable.Annotation(iD);
end
if isnan(ann)
xmlFA.writeannotation(node, 32);
else
xmlFA.writeannotation(node, ann);
end
xmlFA.writenode(xmlfile, node);
end
end
......@@ -18,7 +18,7 @@ classdef xmlFA
node = nodes.item(i);
switch(char(node.item(1).getTextContent))
case 'm_nAnnotation'
ann = str2num(node.item(3).getTextContent);
ann = char(node.item(3).getTextContent);
break;
end
end
......@@ -31,8 +31,17 @@ classdef xmlFA
node = nodes.item(i);
switch(char(node.item(1).getTextContent))
case 'm_nAnnotation'
node.item(3).setTextContent(num2str(ann));
break;
if isempty(ann)
node.item(3).setTextContent('32');
break
else
if ischar(ann)
node.item(3).setTextContent(num2str(double(ann)));
else
node.item(3).setTextContent(num2str(ann));
end
break;
end
end
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment