<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;"><font size="2">Argh, replace 'nibabel.load' with 'img.get_data'.<br>
<br>
</font>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF326757"><font size="2" color="#000000" face="Tahoma"><b>From:</b> Neuroimaging [neuroimaging-bounces+moloney=ohsu.edu@python.org] on behalf of Brendan Moloney [moloney@ohsu.edu]<br>
<b>Sent:</b> Monday, July 06, 2015 3:04 PM<br>
<b>To:</b> Neuroimaging analysis in Python<br>
<b>Subject:</b> Re: [Neuroimaging] Nibabel API change - always read as float<br>
</font><br>
</div>
<div></div>
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">
<div style="font-family:Times New Roman; color:#000000; font-size:16px"><br>
<div>
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div>> For example, if the first column is an index, casting it to float makes no sense.<br>
<br>
And if the first row provides indices the given result makes no sense. If you are
<br>
going to appeal to the authority of numpy you should recognize that their <br>
default policy appears to be "when in doubt use floats".<br>
</div>
<div> </div>
<div>> Yes. So they could have casted all data to float if they wanted to, but they didn't.<br>
<br>
This is not analogous at all.</div>
<div><br>
</div>
<div>> Well the context is also obvious when you load MRI data, just cast it to float in
<br>
> all cases. And no, it's not simple to pass a dtype when loading a mask. If an <br>
> image is contains float values between 0 and 2, casting it to int will round the
<br>
> values to 0 and 1, ie a valid mask. But clearly, the file loaded was not meant to
<br>
> be used as a mask in the first place.<br>
<br>
So every time you load a mask you check if the values are strictly zeros and ones?<br>
I don't. I find it useful to allow a label image to be used as a mask. What if <br>
someone passes in the image and it is just zeros and ones? Do you raise an <br>
exception because you are guessing they accidentally passed in a mask instead <br>
of the image?<br>
<br>
If you passed an integer dtype to 'nibabel.load' and the file has scaling factors, we
<br>
could raise an exception. So your use case might actually be an argument for this<br>
proposal rather than against it.<br>
<br>
If this proposal goes through, and the default for 'dtype' becomes float, the only
<br>
time you will need to pass the 'dtype' will be:<br>
<br>
1) You know the image is providing a mask or labels from context<br>
<br>
2) You want to save memory and know what you are doing<br>
<br>
Without this proposal you need to cast everything to float except for the above <br>
cases, which seems worse to me (ignoring the argument for novices).<br>
<br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>