Closed nilgoyette closed 3 years ago
Unless I overlooked something, I think that we would be safe to keep using dim
as we are now. Here is my rationale:
dim[i]
where i
is in a "valid" dimension range, which is from 1
to dim[0]
inclusive. So an unused dim[6]
would not need to be positive.dim[0]
and dim[1]
are required, by their words. It continues with dim[2]
being required for images and dim[3]
being required for volumes. As one cannot omit writing or reading any bytes in dim
, they ought to mean that setting non-required parts to some value is not necessary.dim
in NiftiHeader
, but to be fair, this information can only be fully specified alongside a volume. This default set up is mostly done for convenience. The header can still be malformed in other ways anyway. It has been up to reader and writer functions to validate the header.I believe that was originally intended in NIfTI-1 from the start was that implementers:
dim
from dim[i]
up to dim[0]
, and reading beyond that is a bug that could lead to ill-formed behavior;We are good with the first rule, and for the creation of fresh new volumes we should be good with the second one too. In a similar fashion, it's faster to just copy a [u16; 8]
into a Dim
or Idx
without cleaning up the unused values. The only exception I can think of from the second rule would be if we stumble upon a... creative implementation that relies on these unused parameters to be set to something reasonable. Should something like that come around, we would then assess the implications of making the library more compatible with that implementation.
Ok, perfect, thank you for your input. It was useful at least to discuss it and to make things clearer.
We were looking at the nifti specification to know if we should write
but it's not entirelly clear! The standard says
Is zero positive or negative? Such is the question :) A quick research returns a math.stackexchange page. It seems that there a difference between "positive" and "strickly positive", but the standard doesn't use the clear term "strickly positive"... 0 seems to be both "positive" and "negative" AND neither, depending on who you ask, the context and the position of Venus.
What do we have in nifti-rs?
NiftiHeader
creates a dim[1, 0, 0, 0, 0, 0, 0]
Dim
andIdx
structs both receive a[u16; 8]
without modifying it. It's validated for its length and negative values, but not for unused values. It currently accepts [3, 100, 100, 100, 0, 42, 1].What do we do with this? It's not a bug, nifti-rs still works as intended, but... do we "fix" it?