[Neuroimaging] NiBabel - Streamlines API - TRK header extension

Matthew Brett matthew.brett at gmail.com
Tue May 31 14:55:01 EDT 2016


On Tue, May 31, 2016 at 11:32 AM, Marc-Alexandre Côté
<marc.cote.19 at gmail.com> wrote:
> You are right there is no guarantee. I rely on the common sense of
> initializing memory to \x00. Especially, when that memory corresponds to a
> documented header field.
>
> A more robust approach could be to replace \x00 by a checksum of the tag
> name. However, I don't think it is worth doing it right now.

Well - I guess the checksum could end up being a valid ascii char.

Other options are:

* add a magic value after the \x0 and before the number of properties;
* use ascii for the number N, as in `name\ x0 8 \x0 \x0 ... `.  This
has the advantage that it's a little easier for the person reading
this file to guess what's going on, uses no extra bytes when N<10, and
a check for [ascii name] then [\x0] then [ascii number] then [\x0 or
end of field] would be reasonably reliable as check against random
bytes in the fields.

Matthew


More information about the Neuroimaging mailing list