[Neuroimaging] Nibabel API change - always read as float

Matthew Brett matthew.brett at gmail.com
Wed Jul 22 15:37:08 CEST 2015


On Wed, Jul 22, 2015 at 2:09 PM, Satrajit Ghosh <satra at mit.edu> wrote:
> hi matthew,
>
>>
>> Oh - sorry - you were only trying to say that either 0 or scalefactors
>> (1, 0) mean that scaling does not get applied?  Yes, sure, it would be
>> inefficient to apply scaling where it has no effect.
>>
>> I was only saying that scl_slope of 1 and 0 are treated the same
>> (apart from the fact that scl_slope of 0 results in scl_inter being
>> discarded).
>>
>>
>> But you agree that scl_slope of 1 or 0 are treated the same (apart
>> from scl_inter being discarded for scl_slope == 0)?   In both cases
>> the check returns False.
>
>
> i do agree that these are being treated similarly, but unlike the proposed
> change in nibabel, the ITK library would return unscaled data in its native
> datatype when scalefactors (0, X) or (1, 0).

I didn't look to see what data type ITK returns, but it's easy to
believe that they would do what we were doing before.

> with the proposed change to as_float, i was hoping that these instances
> would allow for some flexibility in the nibabel api to at least get at the
> raw header version of these values, or perhaps set a property based on the
> raw values. if we read unscaled data and wanted to do something with it, we
> could read the original intent of the writer of the file (whether rightly or
> wrongly). currently, it appears that we cannot recover this information
> without re-reading the binary header.

Just to check once more - you believe that 0 in scl_slope means that
the writer of the file intended for the data to be read into memory
with the on-disk datatype?  I don't think that's what the standard
means by:

"""
If the scl_slope field is nonzero, then each voxel value in the dataset
   should be scaled as
      y = scl_slope * x + scl_inter
"""

I think the standard is only saying that the scalefactors are for
scaling the data values.  For example. I really don't think the
standard is saying that scalefactors of (1, 0) should be interpreted
as meaning the data should be necessarily be float in memory, and the
code you've pointed to suggests to me these other libraries don't
think that either.

Cheers,

Matthew


More information about the Neuroimaging mailing list