[Neuroimaging] Nibabel API change - always read as float

Matthew Brett matthew.brett at gmail.com
Wed Jul 22 16:44:24 CEST 2015


Hi,

On Wed, Jul 22, 2015 at 2:57 PM, Satrajit Ghosh <satra at mit.edu> wrote:
> hi matthew,
>
>> 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 don't think the standard says anything about in-memory representation.
> it's easy to see that subject to not scaling beyond limits and precision
> capabilities of the native datatype, one can keep the data in native dtype.
>
> i don't really know what the writers meant. what i do know is that the
> reference niftiio library that was written by a subset of the same authors
> did not interpret this and stored the data in native dtype and without
> scaling.

I'm not sure what you mean by 'did not interpret this' unless you are
agreeing with me that the niftiio library gives no clues as what the
intention for the in-memory type was.  If anything I think that
supports my reading that the authors had not considered the
interpretation of "scl_slope != 0 -> in-memory float".

>> 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.
>
>
> i agree. which is why i am suggesting  that our new api have a pathway to
> let the developer decide what to do with the data without having to re-read
> binary headers. i.e. a developer should have access to raw scalefactors
> (this is not there) and the raw data in native dtype (this is already
> there).

I can surely attach the raw scalefactors to the array proxy (dataobj),
but I think it's a terrible idea to use the scl_slope == 0 as an
indication for in-memory type, because it's not a convention that (as
far as I know) anyone else uses,

Cheers,

Matthew


More information about the Neuroimaging mailing list