Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Voxel size rounding errors when converting between formats #420
I get a slightly odd voxel size reporting using mrinfo on some data sets.
When I run mrinfo on the raw DICOM dir, I get:
2.4000000953674316 x 2.4000000953674316 x 2.4000015258789062 x ?
When I convert the data to mif and run mrinfo, I get:
2.3999999999999999 x 2.3999999999999999 x 2.3999999999999999 x ?
When I convert the mif to nifti and run mrinfo, I get:
2.4000000953674316 x 2.4000000953674316 x 2.4000000953674316 x ?
Where are these minute discrepancies coming from? Looks pretty harmless, but it might be confusing to end users.
Is this on
NIfTI is different again, storing the transform in floating-point format, as either a quaternion (qform) or the coefficients of the affine matrix directly (sform). I'm guessing results would differ depending on which version was used. On top of that, the sform includes the voxel scaling (it's the full voxel->world matrix), so the matrix needs to be adjusted to remove that for use in MRtrix, which might introduce further loss of precision.
So there's plenty of scope for minor discrepancies. I am surprised about the DICOM vs mif difference though. The mif format shouldn't be lossy now. Unless that commit of @maxpietsch hasn't made it to
As to getting
Can you check whether
I agree that the full precision is probably not needed in the default
added a commit
Dec 15, 2015
I can't really check much from where I am now, but I recall seeing (minor) loss of precision in other places as well (over at least the last year or so), such as, e.g., certain tractography parameters after they've been written to the header (comments). Things like step sizes that were requested to be exactly 0.5mm or something, but then the header (well, at least as reported by mrinfo) reads 0.4999999999 or 0.50000000001 or similar. The most obvious other times I saw loss of precision, was indeed the voxel size. I haven't consciously made the comparison between before and after Max' commits yet.