[Neuroimaging] Nibabel API change - always read as float

Christopher J Markiewicz effigies at bu.edu
Tue Jul 7 01:45:19 CEST 2015


On 07/06/2015 07:27 PM, Matthew Brett wrote:
> On Tue, Jul 7, 2015 at 12:19 AM, Alexandre ABRAHAM
> <abraham.alexandre at gmail.com> wrote:
>> On Tue, Jul 7, 2015 at 1:08 AM, Brendan Moloney <moloney at ohsu.edu> wrote:
>>>
>>> Sorry, I could be a bit more diplomatic some times. I don't mean to
>>> discourage anyone from participating in the conversation.
>>
>>
>> Don't worry, you were diplomatic enough ;). What I meant is that we clearly
>> have two sides here: people who consider nifti data as intrinsically float,
>> and people who think that the type is actually meaningful.
> 
> I think I missed the argument for this.
> 
> Don't forget the the output dtype is not the dtype as specified in the
> header, but the dtype as specified in the header then cast to float if
> the slope == 1 and offset == 0.
> 
> Sometimes I suppose this might be the algorithm intended by the author
> of the image, but most of the time the author had no such intention.
> They usually just meant to find a good datatype to keep a smaller data
> size on disk.  Do you disagree?    I can show you lots of OpenFMRI
> images where I think that is clearly the case.

It sounds like consensus is rolling around to a dtype parameter, but I'm
not entirely clear on what the semantics should be. The least surprising
interpretation would be this:

    if dtype is not None:
        np.array_equal(dtype(img.get_data()), img.get_data(dtype=dtype))

However, if the type is clearly specified in the headers and not
(uint16, m=1, b=0), would the dtype be ignored, or would we get
dtype(img.get_data())? As noted, the former would be surprising, but the
latter makes anything other than setting the default parameter to None
impossible without making the default behavior even more surprising.
Perhaps a dtype that conflicts with the header-specified type should
cause an exception?

Further, is the goal here to make this arbitrarily castable, or limited
to float64 or the header-specified datatype, as in the original proposal
of as_float?

-- 
Christopher J Markiewicz
Ph.D. Candidate, Quantitative Neuroscience Laboratory
Boston University

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20150706/995751ac/attachment.sig>


More information about the Neuroimaging mailing list