[Insight-users] [ITK Community] MHA/MHD File Format

coderforlife jeff at coderforlife.com
Wed Feb 19 16:12:36 EST 2014


Thanks for your pointers. I have been looking at the source at
http://www.opengatecollaboration.org/sites/opengatecollaboration.org/files/doc620/html/files.html
since its the only one I could find easily. Some of my comments may be wrong
because I have been looking at old source code. I will look at GitHub for
the latest soon.

----

The code is complex and confusing but I have been able to answer my
questions. I have also found what I believe are bugs. For example, if
BinaryData = True and CompressedData = True and CompressedDataSize is not
provided or is 0 then the HeaderSize is completely ignored and if
ElementDataFile is 'LOCAL' it will try to uncompress the header itself!

** Answers I have found **

1. Yes, all fields that have data as MET_*_ARRAY or MET_FLOAT_MATRIX can
technically be over any number of lines.
2. Yes, the capitalization of enumerated types is important.
3. When using BinaryData = False the values are simply written out in ASCII
with spaces between them.
4. It is allowed to have CompressedData=True with HeaderSize=-1 but the
results will likely be wrong so should not be used. There are bugs using
HeaderSize (or ElementDataFile=LOCAL) with CompressedData. 
5. HeaderSize is allowed with ElementDataFile=LOCAL and HeaderSize takes
precedence over the end of the header.
6. It turns out the MET_*_ARRAY and MET_* types are apparently identical for
the data-reading part. They are only treated differently with header values.
Thus ElementNumberOfChannels is allowed for non-MET_*_ARRAY types. 
7. ElementByteOrderMSB and BinaryDataByteOrderMSB are synonyms. If both
used, ElementByteOrderMSB overwrites.
8. The Rotation/Orientation/TransformMatrix are saved as a space or newline
separated set of values. They can be one line or many.
9. Data arrays are saved like in #8, so spaces and newlines are the only
separators.
10. A local data file can be specified using ElementDataFile=LOCAL, Local,
or local in some cases but needs be LOCAL in other cases so should always
use LOCAL (inconsistency seems like another bug). LIST must always be LIST.


** I have found some other undocumented features **
- When the field ElementDataFile uses the printf-style string format, the
min, max, and step values are optional. Min and step default to 1. Max
defaults to whatever it would need to be for the values to make sense
knowing min, step, and the image data dimensions.
- When ElementDataFile is a single file, not 'LOCAL', and not found, then
the filename is tried with the extensions .gz and .Z as well and if those
are found forces data to be binary and compressed. The .Z extension is for
Unix compressed files, not gzip/zlib, but MetaIO only really supports
gzip/zlib.
- Both zlib and gzip headers are allowed for compressed data.
- Boolean values accept any string starting with T, t, or 0 regardless of
the length of the string.
- Number of undocumented header fields:
    ImagePosition (MET_FLOAT_ARRAY[NDIMS])
    ElementNBits (MET_INT)
    ElementToIntensityFunctionSlope (MET_FLOAT, default 1)
    ElementToIntensityFunctionOffset (MET_FLOAT, default 0)
    AcquisitionDate (MET_STRING)
    CompressedDataSize (MET_FLOAT)
    DistanceUnits (MET_STRING)
- It appears that the character ':' is special in the header, possibly a
comment delimiter, but I can't really tell. This does not seem to be
documented anywhere. Any insights?




--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/MHA-MHD-File-Format-tp7585031p7585049.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.


More information about the Insight-users mailing list