Practically speaking, your program should deal with both cases.
> The NIfTI standards says, "If the scl_slope field is nonzero,
> then each voxel value in the dataset should be scaled as:
> y = scl_slope * x + scl_inter".
That's true but I know a lot of programs will simply ignore scl_slope and scl_inter. By ignoring I mean it will not be copied over to the output, nor is the data scaled, i.e., the scaling will not be applied and lost in output.
Frankly speaking, I think permitting scaliing is a mistake coz it is not worth the additional complexity it introduce but that's is only my view. For example, take FSL's whie matter probability map. (Not picking on FSL specificly but unfortunately my memory can only recall this) It is a char datatype [0-255] using scaling factor to rework it to [0,1.0]. In C I either have to convert it on the fly from char to float/double which invariably makes my program code difficult to read, maintain or specific to that probability map, or write a special routine to allocate char array to read data in, then another float array and convert, which waste memory and processing time. I don't think it is worth it because the probability map is quite small and don't take up a lot of diskspace. I much prefer it to be float which I can just read in immediately without fiddling with it.
> While it does not explicitly state what do to in the the case
> of zero, there is only one reasonable thing (which is probably
> why it wasn't written).
This is precisely the grievence I have with NifTI. As a specification you cannot say because it is reasonable I am not going to mention it. It has to be mention explicitly.
Just look at XML or other standards from standards body. They are explicit, e.g. the prefix "xml" is reserved for the namespace XML, eventhough it is reasonable to assume by inferring. Yes, making them explicit is pedantic, but had to be done.
> Many fields are allowed to be zero so
> that programmers can create a dataset without having to
> memorize
> all of the documentation.
Nice try. Unless you read the documentation, you do not know that you have to honour scl_slope and scl_inter, which I know a lot of people still don't know they have to. As for me, I virtually always forgotten.
I still come across a lot of nifti file where the programmer will accept whatever rubbish that is in the allocated memory rather than set it to all zero. This makes it really frustrating in deciding what can be trusted, what cannot.
I much prefer the approach that ALL fields are mandatory rather than ignore it if it is zero. This leave out a lot of checking routines that must be imposed before I can use the header value. From a programming perspective, nifti_image_create() or similar functions in other languages can set the fields to reasonable value, or force the programmers to supply the required value.
Quite a lot of time I find that data cannot transfer from one application to another because of the loose header data specification, e.g., slice_code is not compulsary.