You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LabRecorder puts clock offsets in the footer, but it also puts clock offsets throughout the recording. It shouldn't be strictly necessary to process the footer.
load_xdf should gracefully handle a corrupt footer.
It seems that load_xdf can open the file just fine if the corrupt element in the XML tree is completely missing. It only crashes because when an element is incomplete, xmlread throws an exception. Therefore the easiest working solution is to just catch and ignore the error:
case 6 % read [StreamFooter] chunk
% read [StreamId]
id = idmap(fread(f,1,'uint32'));
% read [Content]
try
footer = parse_xml_struct(fread(f,len-6,'*char')');
streams{id} = hlp_superimposedata(footer,streams{id});
catch e
fprintf(' got error "%s" (%s), ignoring truncated XML structure.\n',e.identifier,e.message);
end
Similarly, pyxdf.load_xdf crashes on a corrupt XML element in the footer in the exact same way, but works fine if you ignore the XML error:
elif tag == 6:
# read [StreamFooter] chunk
xml_string = f.read(chunklen - 6)
try:
streams[StreamId]["footer"] = _xml2dict(fromstring(xml_string))
except Exception as e:
if type(e).__name__ == 'ParseError':
logger.error(
"found likely XDF file corruption (%s), "
"ignoring corrupted XML element in footer." % e
)
else:
raise
An alternative is to "fix" the footer by looking for the incomplete element and deleting it. This is a solution I may use for myself but since it modifies the file, it probably won't be a good idea to implement into a reader function like load_xdf.
Of course in all of this, I am assuming there is no way to somehow calculate the information missing in the corrupt footer, which would be the true fix. But I didn't see anything wrong with the streams opened this way.
Prompted by a user issue here:
labstreaminglayer/App-LabRecorder#107
LabRecorder puts clock offsets in the footer, but it also puts clock offsets throughout the recording. It shouldn't be strictly necessary to process the footer.
load_xdf should gracefully handle a corrupt footer.
Related: xdf-modules/pyxdf#83
The text was updated successfully, but these errors were encountered: