dmriprep icon indicating copy to clipboard operation
dmriprep copied to clipboard

nibabel get_data vs get_fdata

Open akeshavan opened this issue 6 years ago • 5 comments

for some odd reason img.get_fdata kills my python kernel, but the deprecated get_data does not. I'm not sure how to debug this because everything just dies!

akeshavan avatar Dec 18 '18 05:12 akeshavan

but we could just use img_data = np.asarray(img.dataobj) in the drop_outliers_fn function

akeshavan avatar Dec 18 '18 05:12 akeshavan

Seems like something the nibabel developers might want to know.

arokem avatar Dec 18 '18 15:12 arokem

We know :) - when I changed the default, I knew it would be a problem for some people. I'm sure what's happening is that the floating point version of the image is too large to fit into memory along with everything else. get_fdata is meant to be a safe high-level method, in the sense that it's behavior is predictable, but sometimes you'll need to optimize for memory by using workarounds like np.array(img.dataobj).

matthew-brett avatar Dec 18 '18 18:12 matthew-brett

Thanks Matthew! So np.array(img.dataobj) is prefereable to get_data for long-term?

arokem avatar Dec 18 '18 18:12 arokem

Yes, get_data will go away eventually. np.array(img.dataobj) also gives the correct impression of being something a bit dark and advanced.

matthew-brett avatar Dec 18 '18 19:12 matthew-brett